1 |
/* wptSignEncDlg.cpp - Sign & encrypt dialog |
/* wptSignEncDlg.cpp - Sign & encrypt dialog |
2 |
* Copyright (C) 2000-2006 Timo Schulz |
* Copyright (C) 2000-2006, 2009 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
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 General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
15 |
*/ |
*/ |
16 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
17 |
#include <config.h> |
#include <config.h> |
59 |
gpgme_set_armor (ctx, 1); |
gpgme_set_armor (ctx, 1); |
60 |
gpgme_set_textmode (ctx, 1); |
gpgme_set_textmode (ctx, 1); |
61 |
|
|
62 |
err = gpg_data_new_from_clipboard (&plain, 0); |
err = gpg_data_utf8_new_from_clipboard (&plain, 0, NULL); |
63 |
if (err) |
if (err) |
64 |
goto leave; |
goto leave; |
65 |
err = gpgme_data_new (&ciph); |
err = gpgme_data_new (&ciph); |
75 |
if (err) |
if (err) |
76 |
goto leave; |
goto leave; |
77 |
|
|
78 |
gpg_data_release_and_set_clipboard (ciph, 1); |
gpg_data_release_to_clipboard (ciph, 1); |
79 |
ciph = NULL; |
ciph = NULL; |
80 |
|
|
81 |
leave: |
leave: |
91 |
BOOL CALLBACK |
BOOL CALLBACK |
92 |
clip_signenc_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_signenc_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
93 |
{ |
{ |
94 |
static listview_ctrl_t lv = NULL; |
static keylist_ctrl_t kl = NULL; |
95 |
static keylist_t list = NULL; |
static keylist_t list = NULL; |
96 |
|
static int keys_sortby = 0; |
97 |
gpg_keycache_t kc; |
gpg_keycache_t kc; |
98 |
gpgme_key_t *rset; |
gpgme_key_t *rset; |
99 |
gpgme_error_t err; |
gpgme_error_t err; |
108 |
SetWindowText (dlg, _("Sign & Encrypt")); |
SetWindowText (dlg, _("Sign & Encrypt")); |
109 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
110 |
kc = keycache_get_ctx (KEYCACHE_PUB); |
kc = keycache_get_ctx (KEYCACHE_PUB); |
111 |
lv = keylist_load (GetDlgItem (dlg, IDC_SIGNENC_KEYLIST), |
kl = keylist_load (GetDlgItem (dlg, IDC_SIGNENC_KEYLIST), |
112 |
kc, NULL, KEYLIST_ENCRYPT_MIN, KEY_SORT_USERID); |
kc, NULL, KEYLIST_ENCRYPT_MIN, KEY_SORT_USERID); |
113 |
seclist_init (dlg, IDC_SIGNENC_SECLIST, KEYLIST_FLAG_SHORT, &list); |
seclist_init (dlg, IDC_SIGNENC_SECLIST, KEYLIST_FLAG_SHORT, &list); |
114 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
120 |
|
|
121 |
case WM_DESTROY: |
case WM_DESTROY: |
122 |
seclist_destroy (&list); |
seclist_destroy (&list); |
123 |
if (lv) { |
if (kl) { |
124 |
keylist_delete (lv); |
keylist_delete (kl); |
125 |
lv = NULL; |
kl = NULL; |
126 |
} |
} |
127 |
return FALSE; |
return FALSE; |
128 |
|
|
129 |
case WM_NOTIFY: |
case WM_NOTIFY: |
130 |
|
int ret; |
131 |
|
ret = keylist_listview_notify (dlg, kl->keys, |
132 |
|
IDC_SIGNENC_KEYLIST, lparam); |
133 |
|
if (ret != 0) { |
134 |
|
SetWindowLong (dlg, DWL_MSGRESULT, ret); |
135 |
|
return TRUE; |
136 |
|
} |
137 |
|
|
138 |
NMHDR *notify; |
NMHDR *notify; |
139 |
notify = (NMHDR *)lparam; |
notify = (NMHDR *)lparam; |
140 |
if (notify && notify->code == NM_DBLCLK |
if (notify && notify->code == NM_DBLCLK |
141 |
&& notify->idFrom == IDC_SIGNENC_KEYLIST) |
&& notify->idFrom == IDC_SIGNENC_KEYLIST) |
142 |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDOK, 0), 0); |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDOK, 0), 0); |
143 |
|
|
144 |
|
if (notify && notify->code == LVN_COLUMNCLICK && |
145 |
|
notify->idFrom == IDC_SIGNENC_KEYLIST) { |
146 |
|
NMLISTVIEW *p = (LPNMLISTVIEW) lparam; |
147 |
|
int sortby = 0; |
148 |
|
|
149 |
|
switch (p->iSubItem) { |
150 |
|
case 0: sortby = KEY_SORT_USERID; break; |
151 |
|
case 1: sortby = KEY_SORT_KEYID; break; |
152 |
|
case 2: sortby = KEY_SORT_LEN; break; |
153 |
|
case 4: sortby = KEY_SORT_VALIDITY; break; |
154 |
|
default: sortby = KEY_SORT_USERID; break; |
155 |
|
} |
156 |
|
if ((keys_sortby & ~KEYLIST_SORT_DESC) == sortby) |
157 |
|
keys_sortby ^= KEYLIST_SORT_DESC; |
158 |
|
else |
159 |
|
keys_sortby = sortby; |
160 |
|
keylist_sort (kl, keys_sortby); |
161 |
|
} |
162 |
return TRUE; |
return TRUE; |
163 |
|
|
164 |
case WM_COMMAND: |
case WM_COMMAND: |
169 |
} |
} |
170 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
171 |
case IDOK: |
case IDOK: |
172 |
rset = keylist_get_recipients (lv, &force_trust, &n); |
rset = keylist_get_recipients (kl, &force_trust, &n); |
173 |
if (!n) { |
if (!n) { |
174 |
msg_box (dlg, _("You must select at least one key."), |
msg_box (dlg, _("You must select at least one key."), |
175 |
_("Sign & Encrypt"), MB_ERR); |
_("Sign & Encrypt"), MB_ERR); |