1 |
twoaday |
1 |
/* GPGOE.h - GnuPG for Outlook Express |
2 |
|
|
* Copyright (C) 2001, 2002, 2003, 2006 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 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
17 |
|
|
* along with GPGOE; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef GPGOE_H |
22 |
|
|
#define GPGOE_H |
23 |
|
|
|
24 |
twoaday |
12 |
/* gettext support. */ |
25 |
|
|
const char *gettext (const char *msgid); |
26 |
|
|
#define _(X) gettext ((X)) |
27 |
twoaday |
1 |
|
28 |
twoaday |
12 |
|
29 |
twoaday |
1 |
#include <malloc.h> |
30 |
twoaday |
16 |
/* safe wrapper around free. */ |
31 |
twoaday |
1 |
#define free_if_alloc(ptr) \ |
32 |
twoaday |
11 |
do { \ |
33 |
twoaday |
1 |
if (ptr) free (ptr); \ |
34 |
|
|
ptr = NULL; \ |
35 |
twoaday |
11 |
} while (0) |
36 |
twoaday |
1 |
|
37 |
|
|
|
38 |
|
|
/* Wrapper for memory deallocation but overwrite the buffer before. |
39 |
|
|
Useful for sentensive information like PINs or passwords. */ |
40 |
|
|
#define wipememory2(_ptr,_set,_len) do { \ |
41 |
|
|
volatile char *_vptr = (volatile char *)(_ptr); \ |
42 |
|
|
size_t _vlen = (_len); \ |
43 |
|
|
while (_vlen) { *_vptr = (_set); _vptr++; _vlen--; } \ |
44 |
|
|
} while(0) |
45 |
|
|
|
46 |
|
|
#define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len) |
47 |
|
|
|
48 |
twoaday |
16 |
/* Dialog IDs for the various operations. */ |
49 |
twoaday |
12 |
#define ID_OE_SELECTALL 40125 |
50 |
|
|
#define ID_OE_COPY 40484 |
51 |
|
|
#define ID_OE_PASTE 40231 |
52 |
|
|
#define ID_OE_SAVE_ATT 40104 |
53 |
twoaday |
1 |
|
54 |
twoaday |
12 |
/* Common dialogs (Get{Open,Save}FileName) */ |
55 |
|
|
#define ID_OF_OK 1 |
56 |
|
|
#define ID_OF_CANCEL 2 |
57 |
|
|
#define ID_OF_OPEN_FILE 1152 |
58 |
|
|
#define ID_OF_SAVE_FILE 1148 |
59 |
twoaday |
1 |
|
60 |
|
|
|
61 |
|
|
/* Context for the recipient list. */ |
62 |
|
|
struct recip_list_s { |
63 |
|
|
struct recip_list_s *next; |
64 |
|
|
gpgme_key_t key; |
65 |
|
|
char *addr; |
66 |
|
|
}; |
67 |
|
|
typedef struct recip_list_s *recip_list_t; |
68 |
|
|
|
69 |
|
|
/* Actual plugin context. */ |
70 |
|
|
struct plugin_ctx_s { |
71 |
|
|
HWND msg_wnd, main_wnd, addr_wnd; |
72 |
|
|
HWND to_wnd, cc_wnd, bcc_wnd; |
73 |
twoaday |
12 |
HWND attach; |
74 |
twoaday |
1 |
char *to; |
75 |
|
|
char *cc; |
76 |
|
|
char *bcc; |
77 |
|
|
int sign; |
78 |
|
|
int encrypt; |
79 |
|
|
recip_list_t rset; |
80 |
|
|
char errbuf[256]; |
81 |
twoaday |
11 |
char *orig_text; |
82 |
twoaday |
12 |
int use_utf8; |
83 |
twoaday |
1 |
}; |
84 |
|
|
typedef struct plugin_ctx_s *plugin_ctx_t; |
85 |
|
|
|
86 |
|
|
/* Viewer context. */ |
87 |
|
|
struct viewer_ctx_s { |
88 |
twoaday |
16 |
HWND main_wnd; |
89 |
twoaday |
1 |
const char *msg; |
90 |
|
|
}; |
91 |
|
|
typedef struct viewer_ctx_s *viewer_ctx_t; |
92 |
|
|
|
93 |
|
|
|
94 |
twoaday |
11 |
/*-- GPGOE.c --*/ |
95 |
|
|
/*EXPORT*/ int gpgoe_initialize (void); |
96 |
|
|
/*EXPORT*/ int gpgoe_remove (void); |
97 |
|
|
|
98 |
twoaday |
1 |
/*-- OEProc.c --*/ |
99 |
twoaday |
16 |
extern plugin_ctx_t oe_plug; |
100 |
twoaday |
1 |
extern HINSTANCE mod_hinst_dll; |
101 |
twoaday |
16 |
extern HANDLE plugin_active; |
102 |
|
|
|
103 |
|
|
/* support for the mailer window. */ |
104 |
twoaday |
1 |
extern WNDPROC oe_proc_old; |
105 |
twoaday |
16 |
LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, |
106 |
|
|
WPARAM wparam, LPARAM lparam); |
107 |
|
|
|
108 |
|
|
/* support for the common dialogs. */ |
109 |
twoaday |
12 |
extern WNDPROC of_proc_old; |
110 |
twoaday |
16 |
LRESULT CALLBACK of_proc (HWND hwnd, UINT msg, |
111 |
|
|
WPARAM wparam, LPARAM lparam); |
112 |
twoaday |
1 |
|
113 |
twoaday |
16 |
/* support for the main window. */ |
114 |
|
|
extern WNDPROC oe_main_proc_old; |
115 |
|
|
LRESULT CALLBACK oe_main_proc (HWND hwnd, UINT msg, |
116 |
|
|
WPARAM wparam, LPARAM lparam); |
117 |
|
|
|
118 |
|
|
|
119 |
twoaday |
1 |
/*-- OECrypto.c --*/ |
120 |
|
|
gpgme_error_t oe_handle_mail (plugin_ctx_t ctx); |
121 |
twoaday |
16 |
gpgme_error_t oe_decrypt_msg (HWND main_wnd, char **r_msg); |
122 |
twoaday |
1 |
|
123 |
|
|
/*-- OEMisc.c --*/ |
124 |
twoaday |
16 |
void center_window (HWND hwndChild, HWND parent); |
125 |
twoaday |
1 |
char* utf8_to_native (const char *string); |
126 |
twoaday |
12 |
char* native_to_utf8 (const char *string); |
127 |
twoaday |
1 |
char* get_clip_text (HWND hwnd); |
128 |
|
|
int set_clip_text (HWND hwnd, const char *text, int nbytes); |
129 |
|
|
void show_error (HWND hwnd, const char *caption, |
130 |
|
|
UINT type, const char *fmt, ...); |
131 |
|
|
void* xcalloc (size_t n, size_t m); |
132 |
|
|
char* xstrdup (const char *s); |
133 |
twoaday |
12 |
void xfree (void *p); |
134 |
twoaday |
16 |
void quote_msg_text (const char *inp, char **r_outp); |
135 |
twoaday |
1 |
|
136 |
|
|
/*-- dialogs --*/ |
137 |
|
|
BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
138 |
|
|
LPARAM lparam); |
139 |
|
|
BOOL CALLBACK viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
140 |
|
|
LPARAM lparam); |
141 |
|
|
BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, |
142 |
|
|
LPARAM lparam); |
143 |
|
|
|
144 |
twoaday |
11 |
/* Opaque passphrase callback handle. */ |
145 |
twoaday |
1 |
struct pass_cb_s; |
146 |
|
|
typedef struct pass_cb_s *pass_cb_t; |
147 |
|
|
|
148 |
|
|
gpgme_error_t passphrase_cb (void *hook, |
149 |
|
|
const char *uid_hint, |
150 |
|
|
const char *passphrase_info, |
151 |
|
|
int prev_was_bad, int fd); |
152 |
|
|
void free_pass_cb (pass_cb_t cb); |
153 |
|
|
pass_cb_t new_pass_cb (HWND main); |
154 |
twoaday |
18 |
int pass_cb_cancelled (pass_cb_t cb); |
155 |
twoaday |
16 |
void free_pass_cache (void); |
156 |
twoaday |
1 |
|
157 |
twoaday |
12 |
/*-- OENLS.c --*/ |
158 |
|
|
int setup_gettext (void); |
159 |
|
|
|
160 |
twoaday |
1 |
#endif /* GPGOE_H */ |