/[gpgoe]/trunk/src/GPGOE.h
ViewVC logotype

Contents of /trunk/src/GPGOE.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (show annotations)
Tue Dec 13 10:40:30 2011 UTC (13 years, 4 months ago) by twoaday
File MIME type: text/plain
File size: 5105 byte(s)
Commit code for backup purposes.


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 #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>
36 /* safe wrapper around free. */
37 #define free_if_alloc(ptr) \
38 do { \
39 if (ptr) free (ptr); \
40 ptr = NULL; \
41 } while (0)
42
43
44 /* Wrapper for memory deallocation but overwrite the buffer before.
45 Useful for sentensive information like PINs or passwords. */
46 #define wipememory2(_ptr,_set,_len) do { \
47 volatile char *_vptr = (volatile char *)(_ptr); \
48 size_t _vlen = (_len); \
49 while (_vlen) { *_vptr = (_set); _vptr++; _vlen--; } \
50 } while(0)
51
52 #define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len)
53
54 #ifndef DIM
55 #define DIM(v) (sizeof (v) / sizeof ((v)[0]))
56 #endif
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. */
79 struct recip_list_s {
80 struct recip_list_s *next;
81 gpgme_key_t key; /* The actual key to use */
82 char *addr; /* The email address. */
83 };
84 typedef struct recip_list_s *recip_list_t;
85
86 /* Actual plugin context. */
87 struct plugin_ctx_s {
88 HWND msg_wnd, main_wnd, addr_wnd;
89 HWND to_wnd, cc_wnd, bcc_wnd;
90 HWND attach;
91 char *to;
92 char *cc;
93 char *bcc;
94 int sign;
95 int encrypt;
96 recip_list_t rset;
97 char errbuf[256];
98 char *orig_text;
99 int use_utf8;
100 };
101 typedef struct plugin_ctx_s *plugin_ctx_t;
102
103 /* Viewer context. */
104 struct viewer_ctx_s {
105 HWND main_wnd;
106 const char *msg;
107 };
108 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 --*/
124 extern plugin_ctx_t oe_plug;
125 extern HINSTANCE mod_hinst_dll;
126 extern HANDLE plugin_active;
127
128 /* support for the mailer window. */
129 extern WNDPROC oe_proc_old;
130 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
143
144 /*-- OECrypto.c --*/
145 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 --*/
149 void center_window (HWND hwndChild, HWND parent);
150 char* utf8_to_native (const char *string);
151 char* native_to_utf8 (const char *string);
152 char* get_clip_text (HWND hwnd);
153 int set_clip_text (HWND hwnd, const char *text, int nbytes);
154 void show_error (HWND hwnd, const char *caption,
155 UINT type, const char *fmt, ...);
156 void* xcalloc (size_t n, size_t m);
157 char* xstrdup (const char *s);
158 void xfree (void *p);
159 void quote_msg_text (const char *inp, char **r_outp);
160
161 /*-- dialogs --*/
162 BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam,
163 LPARAM lparam);
164 BOOL CALLBACK viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam,
165 LPARAM lparam);
166 BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam,
167 LPARAM lparam);
168
169 /* Opaque passphrase callback handle. */
170 struct pass_cb_s;
171 typedef struct pass_cb_s *pass_cb_t;
172
173 gpgme_error_t passphrase_cb (void *hook,
174 const char *uid_hint,
175 const char *passphrase_info,
176 int prev_was_bad, int fd);
177 void free_pass_cb (pass_cb_t cb);
178 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 /*-- OENLS.c --*/
183 int setup_gettext (void);
184
185 #endif /* GPGOE_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26