--- trunk/src/GPGOE.h 2006/03/24 13:36:54 1 +++ trunk/src/GPGOE.h 2007/08/18 10:55:14 23 @@ -1,5 +1,5 @@ /* GPGOE.h - GnuPG for Outlook Express - * Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz + * Copyright (C) 2001, 2002, 2003, 2006, 2007 Timo Schulz * * This file is part of GPGOE. * @@ -12,29 +12,32 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 */ #ifndef GPGOE_H #define GPGOE_H -#ifdef __cplusplus -extern "C" { +/* Macros to support a separate section for variables. */ +#ifdef __GNUC__ +#define ATTR_SEC __attribute__((section (".SHARDAT"), shared)) +#else +#define ATTR_SEC #endif -/* dummy until gettext support is finished. */ -#define _(X) (X) +/* How many items we can store in the dictionary */ +#define HASH_BUCKETS 3 + +/* gettext support. */ +const char *gettext (const char *msgid); +#define _(X) gettext ((X)) #include -/* wrapper around free. */ +/* safe wrapper around free. */ #define free_if_alloc(ptr) \ - do { \ +do { \ if (ptr) free (ptr); \ ptr = NULL; \ - } while (0) +} while (0) /* Wrapper for memory deallocation but overwrite the buffer before. @@ -47,33 +50,35 @@ #define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len) -/* OE5 V5.x/V6 command id's. */ -#define ID_OE5_SELECTALL 40125 -#define ID_OE5_COPY 40484 -#define ID_OE5_PASTE 40231 -#define ID_OE5_ENCRYPT 40260 -#define ID_OE5_SIGN 40299 -#define ID_OE5_SEND 40411 -#define ID_OE5_PREVMSG 40145 -#define ID_OE5_NEXTMSG 40146 - -/* Common dialogs (GetOpenFileName) */ -#define OF_IDOK 1 -#define OF_IDFILE 1152 - -/* Config dialog id's */ -#define ID_OE5_CFGENCRYPT 1053 -#define ID_OE5_CFGSIGN 1052 -#define ID_OE5_CFGDETAILS 2118 -#define ID_OE5_CFGUID 2112 -#define ID_OE5_UIDREQ 2117 +#ifndef DIM +#define DIM(v) (sizeof (v) / sizeof ((v)[0])) +#endif +/* Dialog IDs for the various operations. */ +#define ID_OE_SELECTALL 40125 +#define ID_OE_COPY 40484 +#define ID_OE_PASTE 40231 +#define ID_OE_SAVE_ATT 40104 + +/* Common dialogs (Get{Open,Save}FileName) */ +#define ID_OF_OK 1 +#define ID_OF_CANCEL 2 +#define ID_OF_OPEN_FILE 1152 +#define ID_OF_SAVE_FILE 1148 + + +/* Supported plug-in modes. */ +enum gpgoe_mode_t { + GPGOE_MODE_NORMAL = 0, + GPGOE_MODE_PLAINREPLY = 1, /* decrypt mails before a reply. */ + GPGOE_MODE_CACHEPASS = 2, /* cache passphrase. */ +}; /* Context for the recipient list. */ struct recip_list_s { struct recip_list_s *next; - gpgme_key_t key; - char *addr; + gpgme_key_t key; /* The actual key to use */ + char *addr; /* The email address. */ }; typedef struct recip_list_s *recip_list_t; @@ -81,6 +86,7 @@ struct plugin_ctx_s { HWND msg_wnd, main_wnd, addr_wnd; HWND to_wnd, cc_wnd, bcc_wnd; + HWND attach; char *to; char *cc; char *bcc; @@ -88,36 +94,68 @@ int encrypt; recip_list_t rset; char errbuf[256]; + char *orig_text; + int use_utf8; }; typedef struct plugin_ctx_s *plugin_ctx_t; /* Viewer context. */ struct viewer_ctx_s { + HWND main_wnd; const char *msg; }; typedef struct viewer_ctx_s *viewer_ctx_t; +/* Signature verify context. */ +struct verify_ctx_s { + gpgme_signature_t sig; + gpgme_data_t text; +}; +typedef struct verify_ctx_s *verify_ctx_t; + +/*-- GPGOE.c --*/ +int gpgoe_initialize (void); +int gpgoe_remove (void); +void gpgoe_set_active_modes (int mode); +int gpgoe_get_active_modes (void); /*-- OEProc.c --*/ +extern plugin_ctx_t oe_plug; extern HINSTANCE mod_hinst_dll; +extern HANDLE plugin_active; + +/* support for the mailer window. */ extern WNDPROC oe_proc_old; -LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); +LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, + WPARAM wparam, LPARAM lparam); + +/* support for the common dialogs. */ +extern WNDPROC of_proc_old; +LRESULT CALLBACK of_proc (HWND hwnd, UINT msg, + WPARAM wparam, LPARAM lparam); + +/* support for the main window. */ +extern WNDPROC oe_main_proc_old; +LRESULT CALLBACK oe_main_proc (HWND hwnd, UINT msg, + WPARAM wparam, LPARAM lparam); -/*-- GPGOE.c --*/ -int gpgoe_initialize (void); -int gpgoe_remove (void); /*-- OECrypto.c --*/ gpgme_error_t oe_handle_mail (plugin_ctx_t ctx); +gpgme_error_t oe_decrypt_msg (HWND main_wnd, char **r_msg); /*-- OEMisc.c --*/ +void center_window (HWND hwndChild, HWND parent); char* utf8_to_native (const char *string); +char* native_to_utf8 (const char *string); char* get_clip_text (HWND hwnd); int set_clip_text (HWND hwnd, const char *text, int nbytes); void show_error (HWND hwnd, const char *caption, UINT type, const char *fmt, ...); void* xcalloc (size_t n, size_t m); char* xstrdup (const char *s); +void xfree (void *p); +void quote_msg_text (const char *inp, char **r_outp); /*-- dialogs --*/ BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, @@ -126,9 +164,8 @@ LPARAM lparam); BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam); -BOOL CALLBACK pass_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, - LPARAM lparam); +/* Opaque passphrase callback handle. */ struct pass_cb_s; typedef struct pass_cb_s *pass_cb_t; @@ -138,9 +175,10 @@ int prev_was_bad, int fd); void free_pass_cb (pass_cb_t cb); pass_cb_t new_pass_cb (HWND main); +int pass_cb_cancelled (pass_cb_t cb); +void reset_pass_cache (void); -#ifdef __cplusplus -} -#endif +/*-- OENLS.c --*/ +int setup_gettext (void); #endif /* GPGOE_H */