1 |
/* GPGOE.h - GnuPG for Outlook Express |
2 |
* Copyright (C) 2001, 2002, 2003, 2006, 2007 Timo Schulz |
3 |
* |
4 |
* This file is part of GPGOE. |
5 |
* |
6 |
* GPGOE is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU Lesser General Public License as published by |
8 |
* the Free Software Foundation; either version 2.1 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* GPGOE is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
*/ |
16 |
|
17 |
#ifndef GPGOE_H |
18 |
#define GPGOE_H |
19 |
|
20 |
/* Macros to support a separate section for variables. */ |
21 |
#ifdef __GNUC__ |
22 |
#define ATTR_SEC __attribute__((section (".SHARDAT"), shared)) |
23 |
#else |
24 |
#define ATTR_SEC |
25 |
#endif |
26 |
|
27 |
/* How many items we can store in the dictionary */ |
28 |
#define HASH_BUCKETS 3 |
29 |
|
30 |
/* gettext support. */ |
31 |
const char *gettext (const char *msgid); |
32 |
#define _(X) gettext ((X)) |
33 |
|
34 |
#include <malloc.h> |
35 |
/* safe wrapper around free. */ |
36 |
#define free_if_alloc(ptr) \ |
37 |
do { \ |
38 |
if (ptr) free (ptr); \ |
39 |
ptr = NULL; \ |
40 |
} while (0) |
41 |
|
42 |
|
43 |
/* Wrapper for memory deallocation but overwrite the buffer before. |
44 |
Useful for sentensive information like PINs or passwords. */ |
45 |
#define wipememory2(_ptr,_set,_len) do { \ |
46 |
volatile char *_vptr = (volatile char *)(_ptr); \ |
47 |
size_t _vlen = (_len); \ |
48 |
while (_vlen) { *_vptr = (_set); _vptr++; _vlen--; } \ |
49 |
} while(0) |
50 |
|
51 |
#define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len) |
52 |
|
53 |
#ifndef DIM |
54 |
#define DIM(v) (sizeof (v) / sizeof ((v)[0])) |
55 |
#endif |
56 |
|
57 |
/* Dialog IDs for the various operations. */ |
58 |
#define ID_OE_SELECTALL 40125 |
59 |
#define ID_OE_COPY 40484 |
60 |
#define ID_OE_PASTE 40231 |
61 |
#define ID_OE_SAVE_ATT 40104 |
62 |
|
63 |
/* Common dialogs (Get{Open,Save}FileName) */ |
64 |
#define ID_OF_OK 1 |
65 |
#define ID_OF_CANCEL 2 |
66 |
#define ID_OF_OPEN_FILE 1152 |
67 |
#define ID_OF_SAVE_FILE 1148 |
68 |
|
69 |
|
70 |
/* Supported plug-in modes. */ |
71 |
enum gpgoe_mode_t { |
72 |
GPGOE_MODE_NORMAL = 0, |
73 |
GPGOE_MODE_PLAINREPLY = 1, /* decrypt mails before a reply. */ |
74 |
GPGOE_MODE_CACHEPASS = 2, /* cache passphrase. */ |
75 |
}; |
76 |
|
77 |
/* Context for the recipient list. */ |
78 |
struct recip_list_s { |
79 |
struct recip_list_s *next; |
80 |
gpgme_key_t key; /* The actual key to use */ |
81 |
char *addr; /* The email address. */ |
82 |
}; |
83 |
typedef struct recip_list_s *recip_list_t; |
84 |
|
85 |
/* Actual plugin context. */ |
86 |
struct plugin_ctx_s { |
87 |
HWND msg_wnd, main_wnd, addr_wnd; |
88 |
HWND to_wnd, cc_wnd, bcc_wnd; |
89 |
HWND attach; |
90 |
char *to; |
91 |
char *cc; |
92 |
char *bcc; |
93 |
int sign; |
94 |
int encrypt; |
95 |
recip_list_t rset; |
96 |
char errbuf[256]; |
97 |
char *orig_text; |
98 |
int use_utf8; |
99 |
}; |
100 |
typedef struct plugin_ctx_s *plugin_ctx_t; |
101 |
|
102 |
/* Viewer context. */ |
103 |
struct viewer_ctx_s { |
104 |
HWND main_wnd; |
105 |
const char *msg; |
106 |
}; |
107 |
typedef struct viewer_ctx_s *viewer_ctx_t; |
108 |
|
109 |
/* Signature verify context. */ |
110 |
struct verify_ctx_s { |
111 |
gpgme_signature_t sig; |
112 |
gpgme_data_t text; |
113 |
}; |
114 |
typedef struct verify_ctx_s *verify_ctx_t; |
115 |
|
116 |
/*-- GPGOE.c --*/ |
117 |
int gpgoe_initialize (void); |
118 |
int gpgoe_remove (void); |
119 |
void gpgoe_set_active_modes (int mode); |
120 |
int gpgoe_get_active_modes (void); |
121 |
|
122 |
/*-- OEProc.c --*/ |
123 |
extern plugin_ctx_t oe_plug; |
124 |
extern HINSTANCE mod_hinst_dll; |
125 |
extern HANDLE plugin_active; |
126 |
|
127 |
/* support for the mailer window. */ |
128 |
extern WNDPROC oe_proc_old; |
129 |
LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, |
130 |
WPARAM wparam, LPARAM lparam); |
131 |
|
132 |
/* support for the common dialogs. */ |
133 |
extern WNDPROC of_proc_old; |
134 |
LRESULT CALLBACK of_proc (HWND hwnd, UINT msg, |
135 |
WPARAM wparam, LPARAM lparam); |
136 |
|
137 |
/* support for the main window. */ |
138 |
extern WNDPROC oe_main_proc_old; |
139 |
LRESULT CALLBACK oe_main_proc (HWND hwnd, UINT msg, |
140 |
WPARAM wparam, LPARAM lparam); |
141 |
|
142 |
|
143 |
/*-- OECrypto.c --*/ |
144 |
gpgme_error_t oe_handle_mail (plugin_ctx_t ctx); |
145 |
gpgme_error_t oe_decrypt_msg (HWND main_wnd, char **r_msg); |
146 |
|
147 |
/*-- OEMisc.c --*/ |
148 |
void center_window (HWND hwndChild, HWND parent); |
149 |
char* utf8_to_native (const char *string); |
150 |
char* native_to_utf8 (const char *string); |
151 |
char* get_clip_text (HWND hwnd); |
152 |
int set_clip_text (HWND hwnd, const char *text, int nbytes); |
153 |
void show_error (HWND hwnd, const char *caption, |
154 |
UINT type, const char *fmt, ...); |
155 |
void* xcalloc (size_t n, size_t m); |
156 |
char* xstrdup (const char *s); |
157 |
void xfree (void *p); |
158 |
void quote_msg_text (const char *inp, char **r_outp); |
159 |
|
160 |
/*-- dialogs --*/ |
161 |
BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
162 |
LPARAM lparam); |
163 |
BOOL CALLBACK viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
164 |
LPARAM lparam); |
165 |
BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
166 |
LPARAM lparam); |
167 |
|
168 |
/* Opaque passphrase callback handle. */ |
169 |
struct pass_cb_s; |
170 |
typedef struct pass_cb_s *pass_cb_t; |
171 |
|
172 |
gpgme_error_t passphrase_cb (void *hook, |
173 |
const char *uid_hint, |
174 |
const char *passphrase_info, |
175 |
int prev_was_bad, int fd); |
176 |
void free_pass_cb (pass_cb_t cb); |
177 |
pass_cb_t new_pass_cb (HWND main); |
178 |
int pass_cb_cancelled (pass_cb_t cb); |
179 |
void reset_pass_cache (void); |
180 |
|
181 |
/*-- OENLS.c --*/ |
182 |
int setup_gettext (void); |
183 |
|
184 |
#endif /* GPGOE_H */ |