21 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
22 |
#include <config.h> |
#include <config.h> |
23 |
#endif |
#endif |
24 |
|
#include <ctype.h> |
25 |
#include <windows.h> |
#include <windows.h> |
26 |
#include <tlhelp32.h> |
#include <tlhelp32.h> |
27 |
#include <stdio.h> |
#include <stdio.h> |
|
#include <ctype.h> |
|
28 |
|
|
29 |
#include "resource.h" |
#include "resource.h" |
30 |
|
|
32 |
/* Supported plug-in modes. */ |
/* Supported plug-in modes. */ |
33 |
enum gpgoe_mode_t { |
enum gpgoe_mode_t { |
34 |
GPGOE_MODE_NORMAL = 0, |
GPGOE_MODE_NORMAL = 0, |
35 |
GPGOE_MODE_PLAINREPLY = 1 |
GPGOE_MODE_PLAINREPLY = 1, |
36 |
|
GPGOE_MODE_CACHEPASS = 2 |
37 |
}; |
}; |
38 |
|
|
39 |
/* DLL imports. */ |
/* DLL imports. */ |
46 |
/* Global module handle. */ |
/* Global module handle. */ |
47 |
static HINSTANCE glob_hinst = NULL; |
static HINSTANCE glob_hinst = NULL; |
48 |
|
|
49 |
|
struct { |
50 |
|
int decrypt_replies; |
51 |
|
int cache_passwd; |
52 |
|
} opt; |
53 |
|
|
54 |
|
|
55 |
/* String array of programs which are known to cause trouble |
/* String array of programs which are known to cause trouble |
56 |
with GPGoe. */ |
with GPGoe. */ |
57 |
static const char *conflict_apps[] = { |
static const char *conflict_apps[] = { |
58 |
"DUMMY", /* dummy entry. */ |
"DUMMY", /* dummy entry. */ |
59 |
"SPYXX.EXE", |
"SPYXX.EXE", |
60 |
|
"FDM.EXE", /* fast download manager. */ |
61 |
NULL |
NULL |
62 |
}; |
}; |
63 |
|
|
83 |
size_t i; |
size_t i; |
84 |
|
|
85 |
for (i=0; i < strlen (pe.szExeFile); i++) |
for (i=0; i < strlen (pe.szExeFile); i++) |
86 |
pe.szExeFile[i] = (char)toupper ((int)pe.szExeFile[i]); |
pe.szExeFile[i] = (char)toupper (pe.szExeFile[i]); |
87 |
for (i=0; conflict_apps[i] != NULL; i++) { |
for (i=0; conflict_apps[i] != NULL; i++) { |
88 |
if (strstr (pe.szExeFile, conflict_apps[i])) { |
if (strstr (pe.szExeFile, conflict_apps[i])) { |
89 |
fnd = i; |
fnd = i; |
109 |
} |
} |
110 |
|
|
111 |
|
|
112 |
|
#if 0 |
113 |
/* Set the menu item @muid to the state @state. */ |
/* Set the menu item @muid to the state @state. */ |
114 |
void |
void |
115 |
set_menu_state (HMENU menu, UINT muid, UINT state) |
set_menu_state (HMENU menu, UINT muid, UINT state) |
122 |
mii.fState = state; |
mii.fState = state; |
123 |
SetMenuItemInfo (menu, muid, FALSE, &mii); |
SetMenuItemInfo (menu, muid, FALSE, &mii); |
124 |
} |
} |
125 |
|
#endif |
126 |
|
|
127 |
|
|
128 |
/* Get an option with the name @name from the registry. */ |
/* Get an option with the name @name from the registry. */ |
186 |
} |
} |
187 |
|
|
188 |
|
|
189 |
|
/* Dialog box procedure for setting preferences. */ |
190 |
|
BOOL CALLBACK |
191 |
|
prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
192 |
|
{ |
193 |
|
int modes; |
194 |
|
|
195 |
|
switch (msg) { |
196 |
|
case WM_INITDIALOG: |
197 |
|
CheckDlgButton (dlg, IDC_OPT_PLAINREPLY, |
198 |
|
opt.decrypt_replies? BST_CHECKED : BST_UNCHECKED); |
199 |
|
CheckDlgButton (dlg, IDC_OPT_CACHEPASS, |
200 |
|
opt.cache_passwd? BST_CHECKED : BST_UNCHECKED); |
201 |
|
SetForegroundWindow (dlg); |
202 |
|
return TRUE; |
203 |
|
|
204 |
|
case WM_COMMAND: |
205 |
|
switch (LOWORD (wparam)) { |
206 |
|
case IDOK: |
207 |
|
opt.decrypt_replies = IsDlgButtonChecked (dlg, IDC_OPT_PLAINREPLY)? 1: 0; |
208 |
|
opt.cache_passwd = IsDlgButtonChecked (dlg, IDC_OPT_CACHEPASS)? 1 : 0; |
209 |
|
modes = gpgoe_get_active_modes (); |
210 |
|
if (!opt.decrypt_replies) |
211 |
|
gpgoe_set_active_modes (modes & (~GPGOE_MODE_PLAINREPLY)); |
212 |
|
else |
213 |
|
gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY); |
214 |
|
if (!opt.cache_passwd) |
215 |
|
gpgoe_set_active_modes (modes & (~GPGOE_MODE_CACHEPASS)); |
216 |
|
else |
217 |
|
gpgoe_set_active_modes (GPGOE_MODE_CACHEPASS); |
218 |
|
if (outlook_is_running ()) |
219 |
|
MessageBox (NULL, "You need to restart Outlook Express.", |
220 |
|
"GPGOE Information", MB_ICONINFORMATION|MB_OK); |
221 |
|
EndDialog (dlg, TRUE); |
222 |
|
break; |
223 |
|
|
224 |
|
case IDCANCEL: |
225 |
|
EndDialog (dlg, FALSE); |
226 |
|
break; |
227 |
|
} |
228 |
|
break; |
229 |
|
} |
230 |
|
|
231 |
|
return FALSE; |
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
/* Main window procedure for the taskbar program. */ |
/* Main window procedure for the taskbar program. */ |
236 |
LRESULT CALLBACK |
LRESULT CALLBACK |
237 |
gpgoe_main_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
gpgoe_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
238 |
{ |
{ |
239 |
static int decrypt_replies = 0; |
|
240 |
NOTIFYICONDATA NID; |
NOTIFYICONDATA NID; |
241 |
POINT p; |
POINT p; |
242 |
HMENU hm, popup; |
HMENU hm, popup; |
253 |
Shell_NotifyIcon (NIM_ADD, &NID); |
Shell_NotifyIcon (NIM_ADD, &NID); |
254 |
DestroyIcon (NID.hIcon); |
DestroyIcon (NID.hIcon); |
255 |
|
|
256 |
decrypt_replies = get_gpgoe_option ("PlaintextReply"); |
opt.decrypt_replies = get_gpgoe_option ("PlaintextReply"); |
257 |
if (decrypt_replies) |
if (opt.decrypt_replies) |
258 |
gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY); |
gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY); |
259 |
|
opt.cache_passwd = get_gpgoe_option ("CachePassphrase"); |
260 |
|
if (opt.cache_passwd) |
261 |
|
gpgoe_set_active_modes (GPGOE_MODE_CACHEPASS); |
262 |
if (gpgoe_initialize ()) { |
if (gpgoe_initialize ()) { |
263 |
MessageBox (hwnd, "Couldn't register GPG OE hook", "Error", MB_ICONERROR|MB_OK); |
MessageBox (hwnd, "Couldn't register GPG OE hook", "Error", MB_ICONERROR|MB_OK); |
264 |
ExitProcess (0); |
ExitProcess (0); |
267 |
|
|
268 |
case WM_DESTROY: |
case WM_DESTROY: |
269 |
case WM_ENDSESSION: |
case WM_ENDSESSION: |
270 |
put_gpgoe_option ("PlaintextReply", decrypt_replies); |
put_gpgoe_option ("PlaintextReply", opt.decrypt_replies); |
271 |
|
put_gpgoe_option ("CachePassphrase", opt.cache_passwd); |
272 |
gpgoe_remove (); |
gpgoe_remove (); |
273 |
Shell_NotifyIcon (NIM_DELETE, &NID); |
Shell_NotifyIcon (NIM_DELETE, &NID); |
274 |
PostQuitMessage (0); |
PostQuitMessage (0); |
277 |
|
|
278 |
case WM_COMMAND: |
case WM_COMMAND: |
279 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
280 |
case ID_INIT_SUPP_PLAINREPLY: |
case ID_INIT_PREFS: |
281 |
decrypt_replies ^= 1; |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_CONFIG, |
282 |
if (!decrypt_replies) { |
GetDesktopWindow (), prefs_dlg_proc, 0); |
|
int modes = gpgoe_get_active_modes (); |
|
|
gpgoe_set_active_modes (modes & (~GPGOE_MODE_PLAINREPLY)); |
|
|
} |
|
|
else { |
|
|
gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY); |
|
|
if (outlook_is_running ()) |
|
|
MessageBox (NULL, "You need to restart Outlook Express.", |
|
|
"GPGOE Information", MB_ICONINFORMATION|MB_OK); |
|
|
} |
|
283 |
break; |
break; |
284 |
|
|
285 |
case ID_INIT_QUIT: |
case ID_INIT_QUIT: |
303 |
GetCursorPos (&p); |
GetCursorPos (&p); |
304 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_INIT)); |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_INIT)); |
305 |
popup = GetSubMenu (hm, 0); |
popup = GetSubMenu (hm, 0); |
|
set_menu_state (popup, ID_INIT_SUPP_PLAINREPLY, |
|
|
decrypt_replies? MFS_CHECKED : MFS_UNCHECKED); |
|
306 |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL); |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL); |
307 |
PostMessage (hwnd, WM_USER, 0, 0); |
PostMessage (hwnd, WM_USER, 0, 0); |
308 |
DestroyMenu (popup); |
DestroyMenu (popup); |
325 |
MSG msg; |
MSG msg; |
326 |
int idx; |
int idx; |
327 |
|
|
328 |
|
memset (&opt, 0, sizeof (opt)); |
329 |
idx = check_for_conflict_apps (); |
idx = check_for_conflict_apps (); |
330 |
if (idx > 0) { |
if (idx > 0) { |
331 |
char buf[256]; |
char buf[256]; |