1
#if !defined(lint) && !defined(DOS)
2
static char rcsid[] = "$Id: kblock.c 140 2006-09-26 19:30:49Z hubert@u.washington.edu $";
6
* ========================================================================
7
* Copyright 2006 University of Washington
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
* you may not use this file except in compliance with the License.
11
* You may obtain a copy of the License at
13
* http://www.apache.org/licenses/LICENSE-2.0
15
* ========================================================================
18
#ifndef NO_KEYBOARD_LOCK
25
#include "../pith/conf.h"
26
#include "../pith/state.h"
32
void redraw_kl_body(void);
33
void redraw_klocked_body(void);
34
void draw_klocked_body(char *, char *);
37
static char *klockin, *klockame;
45
set_titlebar(_("KEYBOARD LOCK"), ps_global->mail_stream,
46
ps_global->context_current, ps_global->cur_folder, NULL,
47
1, FolderName, 0, 0, NULL);
50
_("You may lock this keyboard so that no one else can access your mail"));
52
_("while you are away. The screen will be locked after entering the "));
54
_("password to be used for unlocking the keyboard when you return."));
60
redraw_klocked_body(void)
64
set_titlebar(_("KEYBOARD LOCK"), ps_global->mail_stream,
65
ps_global->context_current, ps_global->cur_folder, NULL,
66
1, FolderName, 0, 0, NULL);
68
PutLine2(6, 3, _("This keyboard is locked by %s <%s>."),klockame, klockin);
69
PutLine0(8, 3, _("To unlock, enter password used to lock the keyboard."));
75
draw_klocked_body(char *login, char *username)
79
redraw_klocked_body();
83
/*----------------------------------------------------------------------
84
Execute the lock keyboard command
88
Result: keyboard is locked until user gives password
93
struct pine *ps = ps_global;
94
char inpasswd[80], passwd[80], pw[80];
95
HelpType help = NO_HELP;
96
int i, times, old_suspend, flags;
100
ps->redrawer = redraw_kl_body;
102
times = atoi(ps->VAR_KBLOCK_PASSWD_COUNT);
103
if(times < 1 || times > 5){
105
"Kblock-passwd-count var out of range (1 to 5) [%d]\n", times));
111
for(i = 0; i < times; i++){
113
while(1){ /* input pasword to use for locking */
118
snprintf(prompt, sizeof(prompt), _("Retype password to LOCK keyboard (Yes, again) : "));
120
snprintf(prompt, sizeof(prompt), _("Retype password to LOCK keyboard : "));
122
snprintf(prompt, sizeof(prompt), _("Enter password to LOCK keyboard : "));
125
rc = optionally_enter(pw, -FOOTER_ROWS(ps), 0, sizeof(pw),
126
prompt, NULL, help, &flags);
129
help = help == NO_HELP ? h_kb_lock : NO_HELP;
130
else if(rc == 1 || pw[0] == '\0'){
131
q_status_message(SM_ORDER, 0, 2, _("Keyboard lock cancelled"));
139
strncpy(inpasswd, pw, sizeof(inpasswd));
140
inpasswd[sizeof(inpasswd)-1] = '\0';
142
else if(strcmp(inpasswd, pw)){
143
q_status_message(SM_ORDER, 0, 2,
144
_("Mismatch with initial password: keyboard lock cancelled"));
149
if(want_to(_("Really lock keyboard with entered password"), 'y', 'n',
150
NO_HELP, WT_NORM) != 'y'){
151
q_status_message(SM_ORDER, 0, 2, _("Keyboard lock cancelled"));
155
draw_klocked_body(ps->VAR_USER_ID ? ps->VAR_USER_ID : "<no-user>",
156
ps->VAR_PERSONAL_NAME ? ps->VAR_PERSONAL_NAME : "<no-name>");
158
ps->redrawer = redraw_klocked_body;
159
if(old_suspend = F_ON(F_CAN_SUSPEND, ps_global))
160
F_TURN_OFF(F_CAN_SUSPEND, ps_global);
162
while(strcmp(inpasswd, passwd)){
164
q_status_message(SM_ORDER | SM_DING, 3, 3,
165
_("Password to UNLOCK doesn't match password used to LOCK"));
171
flags = OE_PASSWD | OE_DISALLOW_CANCEL;
172
rc = optionally_enter(passwd, -FOOTER_ROWS(ps), 0, sizeof(passwd),
173
_("Enter password to UNLOCK keyboard : "),NULL,
176
help = help == NO_HELP ? h_oe_keylock : NO_HELP;
186
F_TURN_ON(F_CAN_SUSPEND, ps_global);
188
q_status_message(SM_ORDER, 0, 3, _("Keyboard Unlocked"));
193
#endif /* !NO_KEYBOARD_LOCK */