12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
|
* along with GPGOE; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
15 |
*/ |
*/ |
16 |
|
|
17 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
42 |
/* Global module handle. */ |
/* Global module handle. */ |
43 |
static HINSTANCE glob_hinst = NULL; |
static HINSTANCE glob_hinst = NULL; |
44 |
|
|
45 |
|
|
46 |
|
/* Valid options for the plug-in. */ |
47 |
struct { |
struct { |
48 |
int decrypt_replies; |
int decrypt_replies; |
49 |
int cache_passwd; |
int cache_passwd; |
68 |
PROCESSENTRY32 pe; |
PROCESSENTRY32 pe; |
69 |
HANDLE hd; |
HANDLE hd; |
70 |
BOOL next; |
BOOL next; |
71 |
int fnd = 0; |
size_t i; |
72 |
|
int fnd; |
73 |
|
|
74 |
hd = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0); |
hd = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0); |
75 |
if (hd == (HANDLE)-1) |
if (hd == (HANDLE)-1) |
78 |
memset (&pe, 0, sizeof (pe)); |
memset (&pe, 0, sizeof (pe)); |
79 |
pe.dwSize = sizeof (pe); |
pe.dwSize = sizeof (pe); |
80 |
next = Process32First (hd, &pe); |
next = Process32First (hd, &pe); |
81 |
|
fnd = 0; |
82 |
while (next) { |
while (next) { |
|
size_t i; |
|
|
|
|
83 |
for (i=0; i < strlen (pe.szExeFile); i++) |
for (i=0; i < strlen (pe.szExeFile); i++) |
84 |
pe.szExeFile[i] = (char)toupper (pe.szExeFile[i]); |
pe.szExeFile[i] = (char)toupper (pe.szExeFile[i]); |
85 |
for (i=0; conflict_apps[i] != NULL; i++) { |
for (i=0; conflict_apps[i] != NULL; i++) { |
89 |
} |
} |
90 |
} |
} |
91 |
next = Process32Next (hd, &pe); |
next = Process32Next (hd, &pe); |
|
if (!next) |
|
|
break; |
|
92 |
} |
} |
93 |
CloseHandle (hd); |
CloseHandle (hd); |
94 |
return fnd; |
return fnd; |
105 |
} |
} |
106 |
|
|
107 |
|
|
|
#if 0 |
|
|
/* Set the menu item @muid to the state @state. */ |
|
|
void |
|
|
set_menu_state (HMENU menu, UINT muid, UINT state) |
|
|
{ |
|
|
MENUITEMINFO mii; |
|
|
|
|
|
memset (&mii, 0, sizeof (mii)); |
|
|
mii.cbSize = sizeof (mii); |
|
|
mii.fMask = MIIM_STATE; |
|
|
mii.fState = state; |
|
|
SetMenuItemInfo (menu, muid, FALSE, &mii); |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
108 |
/* Get an option with the name @name from the registry. */ |
/* Get an option with the name @name from the registry. */ |
109 |
int |
int |
110 |
get_gpgoe_option (const char *name) |
get_gpgoe_option (const char *name) |
215 |
/* Main window procedure for the taskbar program. */ |
/* Main window procedure for the taskbar program. */ |
216 |
LRESULT CALLBACK |
LRESULT CALLBACK |
217 |
gpgoe_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
gpgoe_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
218 |
{ |
{ |
|
|
|
219 |
NOTIFYICONDATA NID; |
NOTIFYICONDATA NID; |
220 |
POINT p; |
POINT p; |
221 |
HMENU hm, popup; |
HMENU hm, popup; |
228 |
NID.uCallbackMessage = WM_USER; |
NID.uCallbackMessage = WM_USER; |
229 |
NID.hWnd = hwnd; |
NID.hWnd = hwnd; |
230 |
NID.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_GPGOE)); |
NID.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_GPGOE)); |
231 |
strcpy(NID.szTip, "GPG for Outlook Express"); |
strcpy (NID.szTip, "GPG for Outlook Express"); |
232 |
Shell_NotifyIcon (NIM_ADD, &NID); |
Shell_NotifyIcon (NIM_ADD, &NID); |
233 |
DestroyIcon (NID.hIcon); |
DestroyIcon (NID.hIcon); |
234 |
|
|
239 |
if (opt.cache_passwd) |
if (opt.cache_passwd) |
240 |
gpgoe_set_active_modes (GPGOE_MODE_CACHEPASS); |
gpgoe_set_active_modes (GPGOE_MODE_CACHEPASS); |
241 |
if (gpgoe_initialize ()) { |
if (gpgoe_initialize ()) { |
242 |
MessageBox (hwnd, "Couldn't register GPG OE hook", "Error", MB_ICONERROR|MB_OK); |
MessageBox (hwnd, "Could not register GPG OE hook", |
243 |
|
"Error", MB_ICONERROR|MB_OK); |
244 |
ExitProcess (0); |
ExitProcess (0); |
245 |
} |
} |
246 |
break; |
break; |
272 |
switch (lparam) { |
switch (lparam) { |
273 |
case WM_LBUTTONDBLCLK: |
case WM_LBUTTONDBLCLK: |
274 |
SetForegroundWindow (hwnd); |
SetForegroundWindow (hwnd); |
275 |
id = MessageBox (NULL, "Remove the GPG OE plug-in from the system?", |
id = MessageBox (NULL, |
276 |
|
"Remove the GPG OE plug-in from the system?", |
277 |
"Are you sure?", MB_YESNO|MB_ICONINFORMATION); |
"Are you sure?", MB_YESNO|MB_ICONINFORMATION); |
278 |
if (id == IDYES) |
if (id == IDYES) |
279 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
312 |
char buf[256]; |
char buf[256]; |
313 |
_snprintf (buf, sizeof (buf)-1, |
_snprintf (buf, sizeof (buf)-1, |
314 |
"GPGoe found an instance of a program which\n" |
"GPGoe found an instance of a program which\n" |
315 |
"might be effect the functionality of the plugin.\n" |
"might effect the functionality of the plugin.\n" |
316 |
"\n" |
"\n" |
317 |
"Name of the process: %s\n" |
"Name of the process: %s\n" |
318 |
"\n" |
"\n" |
338 |
return 1; |
return 1; |
339 |
} |
} |
340 |
|
|
341 |
hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0, NULL, NULL, hinst, NULL); |
hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0, |
342 |
|
NULL, NULL, hinst, NULL); |
343 |
if (!hwnd) { |
if (!hwnd) { |
344 |
MessageBox (NULL, "Couldn't create window", "Error", MB_ICONERROR|MB_OK); |
MessageBox (NULL, "Could not create window", |
345 |
|
"Error", MB_ICONERROR|MB_OK); |
346 |
return 1; |
return 1; |
347 |
} |
} |
348 |
UpdateWindow (hwnd); |
UpdateWindow (hwnd); |