1 |
/* GPGOE.h - GnuPG for Outlook Express |
/* GPGOE.h - GnuPG for Outlook Express |
2 |
* Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz |
* Copyright (C) 2001, 2002, 2003, 2006, 2007 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of GPGOE. |
* This file is part of GPGOE. |
5 |
* |
* |
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 |
#ifndef GPGOE_H |
#ifndef GPGOE_H |
18 |
#define GPGOE_H |
#define GPGOE_H |
19 |
|
|
20 |
#ifdef __cplusplus |
/* Macros to support a separate section for variables. */ |
21 |
extern "C" { |
#ifdef __GNUC__ |
22 |
|
#define ATTR_SEC __attribute__((section (".SHARDAT"), shared)) |
23 |
|
#else |
24 |
|
#define ATTR_SEC |
25 |
#endif |
#endif |
26 |
|
|
27 |
/* dummy until gettext support is finished. */ |
/* How many items we can store in the dictionary */ |
28 |
#define _(X) (X) |
#define HASH_BUCKETS 3 |
29 |
|
#define MAX_PASS_LEN 2048 |
30 |
|
|
31 |
|
/* gettext support. */ |
32 |
|
const char *gettext (const char *msgid); |
33 |
|
#define _(X) gettext ((X)) |
34 |
|
|
35 |
#include <malloc.h> |
#include <malloc.h> |
36 |
/* wrapper around free. */ |
/* safe wrapper around free. */ |
37 |
#define free_if_alloc(ptr) \ |
#define free_if_alloc(ptr) \ |
38 |
do { \ |
do { \ |
39 |
if (ptr) free (ptr); \ |
if (ptr) free (ptr); \ |
40 |
ptr = NULL; \ |
ptr = NULL; \ |
41 |
} while (0) |
} while (0) |
42 |
|
|
43 |
|
|
44 |
/* Wrapper for memory deallocation but overwrite the buffer before. |
/* Wrapper for memory deallocation but overwrite the buffer before. |
51 |
|
|
52 |
#define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len) |
#define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len) |
53 |
|
|
54 |
/* OE5 V5.x/V6 command id's. */ |
#ifndef DIM |
55 |
#define ID_OE5_SELECTALL 40125 |
#define DIM(v) (sizeof (v) / sizeof ((v)[0])) |
56 |
#define ID_OE5_COPY 40484 |
#endif |
|
#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 |
|
57 |
|
|
58 |
|
/* Dialog IDs for the various operations. */ |
59 |
|
#define ID_OE_SELECTALL 40125 |
60 |
|
#define ID_OE_COPY 40484 |
61 |
|
#define ID_OE_PASTE 40231 |
62 |
|
#define ID_OE_SAVE_ATT 40104 |
63 |
|
|
64 |
|
/* Common dialogs (Get{Open,Save}FileName) */ |
65 |
|
#define ID_OF_OK 1 |
66 |
|
#define ID_OF_CANCEL 2 |
67 |
|
#define ID_OF_OPEN_FILE 1152 |
68 |
|
#define ID_OF_SAVE_FILE 1148 |
69 |
|
|
70 |
|
|
71 |
|
/* Supported plug-in modes. */ |
72 |
|
enum gpgoe_mode_t { |
73 |
|
GPGOE_MODE_NORMAL = 0, |
74 |
|
GPGOE_MODE_PLAINREPLY = 1, /* decrypt mails before a reply. */ |
75 |
|
GPGOE_MODE_CACHEPASS = 2, /* cache passphrase. */ |
76 |
|
}; |
77 |
|
|
78 |
/* Context for the recipient list. */ |
/* Context for the recipient list. */ |
79 |
struct recip_list_s { |
struct recip_list_s { |
80 |
struct recip_list_s *next; |
struct recip_list_s *next; |
81 |
gpgme_key_t key; |
gpgme_key_t key; /* The actual key to use */ |
82 |
char *addr; |
char *addr; /* The email address. */ |
83 |
}; |
}; |
84 |
typedef struct recip_list_s *recip_list_t; |
typedef struct recip_list_s *recip_list_t; |
85 |
|
|
87 |
struct plugin_ctx_s { |
struct plugin_ctx_s { |
88 |
HWND msg_wnd, main_wnd, addr_wnd; |
HWND msg_wnd, main_wnd, addr_wnd; |
89 |
HWND to_wnd, cc_wnd, bcc_wnd; |
HWND to_wnd, cc_wnd, bcc_wnd; |
90 |
|
HWND attach; |
91 |
char *to; |
char *to; |
92 |
char *cc; |
char *cc; |
93 |
char *bcc; |
char *bcc; |
95 |
int encrypt; |
int encrypt; |
96 |
recip_list_t rset; |
recip_list_t rset; |
97 |
char errbuf[256]; |
char errbuf[256]; |
98 |
|
char *orig_text; |
99 |
|
int use_utf8; |
100 |
}; |
}; |
101 |
typedef struct plugin_ctx_s *plugin_ctx_t; |
typedef struct plugin_ctx_s *plugin_ctx_t; |
102 |
|
|
103 |
/* Viewer context. */ |
/* Viewer context. */ |
104 |
struct viewer_ctx_s { |
struct viewer_ctx_s { |
105 |
|
HWND main_wnd; |
106 |
const char *msg; |
const char *msg; |
107 |
}; |
}; |
108 |
typedef struct viewer_ctx_s *viewer_ctx_t; |
typedef struct viewer_ctx_s *viewer_ctx_t; |
109 |
|
|
110 |
|
/* Signature verify context. */ |
111 |
|
struct verify_ctx_s { |
112 |
|
gpgme_signature_t sig; |
113 |
|
gpgme_data_t text; |
114 |
|
}; |
115 |
|
typedef struct verify_ctx_s *verify_ctx_t; |
116 |
|
|
117 |
|
/*-- GPGOE.c --*/ |
118 |
|
int gpgoe_initialize (void); |
119 |
|
int gpgoe_remove (void); |
120 |
|
void gpgoe_set_active_modes (int mode); |
121 |
|
int gpgoe_get_active_modes (void); |
122 |
|
|
123 |
/*-- OEProc.c --*/ |
/*-- OEProc.c --*/ |
124 |
|
extern plugin_ctx_t oe_plug; |
125 |
extern HINSTANCE mod_hinst_dll; |
extern HINSTANCE mod_hinst_dll; |
126 |
|
extern HANDLE plugin_active; |
127 |
|
|
128 |
|
/* support for the mailer window. */ |
129 |
extern WNDPROC oe_proc_old; |
extern WNDPROC oe_proc_old; |
130 |
LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); |
LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, |
131 |
|
WPARAM wparam, LPARAM lparam); |
132 |
|
|
133 |
|
/* support for the common dialogs. */ |
134 |
|
extern WNDPROC of_proc_old; |
135 |
|
LRESULT CALLBACK of_proc (HWND hwnd, UINT msg, |
136 |
|
WPARAM wparam, LPARAM lparam); |
137 |
|
|
138 |
|
/* support for the main window. */ |
139 |
|
extern WNDPROC oe_main_proc_old; |
140 |
|
LRESULT CALLBACK oe_main_proc (HWND hwnd, UINT msg, |
141 |
|
WPARAM wparam, LPARAM lparam); |
142 |
|
|
|
/*-- GPGOE.c --*/ |
|
|
int gpgoe_initialize (void); |
|
|
int gpgoe_remove (void); |
|
143 |
|
|
144 |
/*-- OECrypto.c --*/ |
/*-- OECrypto.c --*/ |
145 |
gpgme_error_t oe_handle_mail (plugin_ctx_t ctx); |
gpgme_error_t oe_handle_mail (plugin_ctx_t ctx); |
146 |
|
gpgme_error_t oe_decrypt_msg (HWND main_wnd, char **r_msg); |
147 |
|
|
148 |
/*-- OEMisc.c --*/ |
/*-- OEMisc.c --*/ |
149 |
|
void center_window (HWND hwndChild, HWND parent); |
150 |
char* utf8_to_native (const char *string); |
char* utf8_to_native (const char *string); |
151 |
|
char* native_to_utf8 (const char *string); |
152 |
char* get_clip_text (HWND hwnd); |
char* get_clip_text (HWND hwnd); |
153 |
int set_clip_text (HWND hwnd, const char *text, int nbytes); |
int set_clip_text (HWND hwnd, const char *text, int nbytes); |
154 |
void show_error (HWND hwnd, const char *caption, |
void show_error (HWND hwnd, const char *caption, |
155 |
UINT type, const char *fmt, ...); |
UINT type, const char *fmt, ...); |
156 |
void* xcalloc (size_t n, size_t m); |
void* xcalloc (size_t n, size_t m); |
157 |
char* xstrdup (const char *s); |
char* xstrdup (const char *s); |
158 |
|
void xfree (void *p); |
159 |
|
void quote_msg_text (const char *inp, char **r_outp); |
160 |
|
|
161 |
/*-- dialogs --*/ |
/*-- dialogs --*/ |
162 |
BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
165 |
LPARAM lparam); |
LPARAM lparam); |
166 |
BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
167 |
LPARAM lparam); |
LPARAM lparam); |
|
BOOL CALLBACK pass_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
|
|
LPARAM lparam); |
|
168 |
|
|
169 |
|
/* Opaque passphrase callback handle. */ |
170 |
struct pass_cb_s; |
struct pass_cb_s; |
171 |
typedef struct pass_cb_s *pass_cb_t; |
typedef struct pass_cb_s *pass_cb_t; |
172 |
|
|
176 |
int prev_was_bad, int fd); |
int prev_was_bad, int fd); |
177 |
void free_pass_cb (pass_cb_t cb); |
void free_pass_cb (pass_cb_t cb); |
178 |
pass_cb_t new_pass_cb (HWND main); |
pass_cb_t new_pass_cb (HWND main); |
179 |
|
int pass_cb_cancelled (pass_cb_t cb); |
180 |
|
void reset_pass_cache (void); |
181 |
|
|
182 |
#ifdef __cplusplus |
/*-- OENLS.c --*/ |
183 |
} |
int setup_gettext (void); |
|
#endif |
|
184 |
|
|
185 |
#endif /* GPGOE_H */ |
#endif /* GPGOE_H */ |