1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: kblock.c 1025 2008-04-08 22:59:38Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2013-2020 Eduardo Chappa
8 * Copyright 2006-2008 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
24 #include "../pith/conf.h"
25 #include "../pith/state.h"
33 void redraw_kl_body(void);
34 void redraw_klocked_body(void);
35 void draw_klocked_body(char *, char *);
38 static char *klockin
, *klockame
;
46 set_titlebar(_("KEYBOARD LOCK"), ps_global
->mail_stream
,
47 ps_global
->context_current
, ps_global
->cur_folder
, NULL
,
48 1, FolderName
, 0, 0, NULL
);
51 _("You may lock this keyboard so that no one else can access your mail"));
53 _("while you are away. The screen will be locked after entering the "));
55 _("password to be used for unlocking the keyboard when you return."));
61 redraw_klocked_body(void)
65 set_titlebar(_("KEYBOARD LOCK"), ps_global
->mail_stream
,
66 ps_global
->context_current
, ps_global
->cur_folder
, NULL
,
67 1, FolderName
, 0, 0, NULL
);
69 PutLine2(6, 3, _("This keyboard is locked by %s <%s>."),klockame
, klockin
);
70 PutLine0(8, 3, _("To unlock, enter password used to lock the keyboard."));
76 draw_klocked_body(char *login
, char *username
)
80 redraw_klocked_body();
84 /*----------------------------------------------------------------------
85 Execute the lock keyboard command
89 Result: keyboard is locked until user gives password
95 struct pine
*ps
= ps_global
;
96 char inpasswd
[80], passwd
[80], pw
[80];
97 HelpType help
= NO_HELP
;
98 int i
, times
, old_suspend
, flags
;
102 ps
->redrawer
= redraw_kl_body
;
104 times
= atoi(ps
->VAR_KBLOCK_PASSWD_COUNT
);
105 if(times
< 1 || times
> 5){
107 "Kblock-passwd-count var out of range (1 to 5) [%d]\n", times
));
113 for(i
= 0; i
< times
; i
++){
115 while(1){ /* input password to use for locking */
120 snprintf(prompt
, sizeof(prompt
), _("Retype password to LOCK keyboard (Yes, again) : "));
122 snprintf(prompt
, sizeof(prompt
), _("Retype password to LOCK keyboard : "));
124 snprintf(prompt
, sizeof(prompt
), _("Enter password to LOCK keyboard : "));
126 flags
= F_ON(F_QUELL_ASTERISKS
, ps_global
) ? OE_PASSWD_NOAST
: OE_PASSWD
;
127 rc
= optionally_enter(pw
, -FOOTER_ROWS(ps
), 0, sizeof(pw
),
128 prompt
, NULL
, help
, &flags
);
131 help
= help
== NO_HELP
? h_kb_lock
: NO_HELP
;
132 else if(rc
== 1 || pw
[0] == '\0'){
133 q_status_message(SM_ORDER
, 0, 2, _("Keyboard lock cancelled"));
141 strncpy(inpasswd
, pw
, sizeof(inpasswd
));
142 inpasswd
[sizeof(inpasswd
)-1] = '\0';
144 else if(strcmp(inpasswd
, pw
)){
145 q_status_message(SM_ORDER
, 0, 2,
146 _("Mismatch with initial password: keyboard lock cancelled"));
151 if(want_to(_("Really lock keyboard with entered password"), 'y', 'n',
152 NO_HELP
, WT_NORM
) != 'y'){
153 q_status_message(SM_ORDER
, 0, 2, _("Keyboard lock cancelled"));
157 draw_klocked_body(ps
->VAR_USER_ID
? ps
->VAR_USER_ID
: "<no-user>",
158 ps
->VAR_PERSONAL_NAME
? ps
->VAR_PERSONAL_NAME
: "<no-name>");
160 ps
->redrawer
= redraw_klocked_body
;
161 if((old_suspend
= F_ON(F_CAN_SUSPEND
, ps_global
)) != 0)
162 F_TURN_OFF(F_CAN_SUSPEND
, ps_global
);
164 while(strcmp(inpasswd
, passwd
)){
166 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
167 _("Password to UNLOCK doesn't match password used to LOCK"));
173 flags
= OE_DISALLOW_CANCEL
174 | (F_ON(F_QUELL_ASTERISKS
, ps_global
) ? OE_PASSWD_NOAST
: OE_PASSWD
);
175 rc
= optionally_enter(passwd
, -FOOTER_ROWS(ps
), 0, sizeof(passwd
),
176 _("Enter password to UNLOCK keyboard : "),NULL
,
179 help
= help
== NO_HELP
? h_oe_keylock
: NO_HELP
;
189 F_TURN_ON(F_CAN_SUSPEND
, ps_global
);
191 q_status_message(SM_ORDER
, 0, 3, _("Keyboard Unlocked"));
196 #endif /* KEYBOARD_LOCK */