--- trunk/src/GPGOE.c 2006/04/11 19:05:05 17 +++ trunk/src/GPGOE.c 2006/04/13 07:41:30 18 @@ -39,6 +39,27 @@ /* Outlook Express window handle. */ static HWND oe_hwnd = NULL; +/* We need a shared section to define variables which + will keep their values in all address spaces. */ +#ifdef __GNUC__ +#define ATTR_SEC __attribute__((section (".SHARDAT"), shared)) +#else +#define ATTR_SEC +#pragma data_seg(".SHARDAT") +#endif +static int gpgoe_active_modes ATTR_SEC = 0; +#ifndef __GNUC__ +#pragma data_seg() +#endif +#undef ATTR_SEC + + +/* Supported plug-in modes. */ +enum gpgoe_mode_t { + GPGOE_MODE_NORMAL = 0, + GPGOE_MODE_PLAINREPLY = 1 /* decrypt mails before a reply. */ +}; + /* Main DLL entry point. */ BOOL WINAPI @@ -112,7 +133,8 @@ oe_hwnd = hwnd; } - if (!strcmp (wclass, "Outlook Express Browser Class")) { + if ((gpgoe_active_modes & GPGOE_MODE_PLAINREPLY) && + !strcmp (wclass, "Outlook Express Browser Class")) { oe_main_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC); if (!oe_main_proc_old) show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK, @@ -125,8 +147,8 @@ } break; - case HCBT_ACTIVATE: #if 0 + case HCBT_ACTIVATE: if (plugin_active != NULL && WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) { char wclass[200]; @@ -137,8 +159,8 @@ of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC); SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc); } -#endif break; +#endif } return CallNextHookEx (ctb_hook, code, wparam, lparam); } @@ -175,3 +197,19 @@ rc = UnhookWindowsHookEx (ctb_hook); return rc ? 0 : (int)GetLastError (); } + + +/* Change the active plug-in modes, enable mode @mode. */ +void +gpgoe_set_active_modes (int mode) +{ + gpgoe_active_modes = mode; +} + + +int +gpgoe_get_active_modes (void) +{ + return gpgoe_active_modes; +} +