/[winpt]/trunk/Src/wptKeysigDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptKeysigDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by twoaday, Wed Oct 26 11:20:09 2005 UTC revision 41 by twoaday, Fri Oct 28 07:15:26 2005 UTC
# Line 1  Line 1 
1  /* wptKeysigDlg.cpp - Key signature listing  /* wptKeysigDlg.cpp - Key signature listing
2   *      Copyright (C) 2001-2005 Timo Schulz   *      Copyright (C) 2001-2005 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
6   * WinPT is free software; you can redistribute it and/or modify   * WinPT is free software; you can redistribute it and/or modify
7   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
8   * the Free Software Foundation; either version 2 of the License, or   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.   * (at your option) any later version.
10   *   *
11   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
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.
15   *   *
16   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20    
21  #include <windows.h>  #include <windows.h>
22  #include <commctrl.h>  #include <commctrl.h>
23  #include <time.h>  #include <time.h>
24    
25  #include "../resource.h"  #include "../resource.h"
26  #include "wptGPG.h"  #include "wptGPG.h"
27  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
28  #include "wptContext.h" /* for passphrase_s */  #include "wptContext.h" /* for passphrase_s */
29  #include "wptDlgs.h"  #include "wptDlgs.h"
30  #include "wptW32API.h"  #include "wptW32API.h"
31  #include "wptNLS.h"  #include "wptNLS.h"
32  #include "wptKeyList.h"  #include "wptKeyList.h"
33  #include "wptKeyserver.h"  #include "wptKeyserver.h"
34  #include "wptUTF8.h"  #include "wptUTF8.h"
35  #include "wptTypes.h"  #include "wptTypes.h"
36  #include "wptVersion.h"  #include "wptVersion.h"
37  #include "wptErrors.h"  #include "wptErrors.h"
38  #include "wptKeyEdit.h"  #include "wptKeyEdit.h"
39    
40  static subclass_s siglist_proc;  static subclass_s siglist_proc;
41    
42    
43  static int  static int
44  is_sig (listview_ctrl_t lv, int pos)  is_sig (listview_ctrl_t lv, int pos)
45  {  {
46      char tmpbuf[256];      char tmpbuf[256];
47    
48      if (pos == -1)      if (pos == -1)
49          pos = listview_get_curr_pos (lv);          pos = listview_get_curr_pos (lv);
50      if (pos == -1)      if (pos == -1)
51          return 0;          return 0;
52      listview_get_item_text (lv, pos, 0, tmpbuf, 200);      listview_get_item_text (lv, pos, 0, tmpbuf, 200);
53      if (*tmpbuf == ' ')      if (*tmpbuf == ' ')
54          return -1;          return -1;
55      return 0;      return 0;
56  }  }
57    
58    
59  /* Delete the selected signature from list view @lv. The  /* Delete the selected signature from list view @lv. The
60     key is given in @key. */     key is given in @key. */
61  static int  static int
62  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
63  {  {
64      int pos, npos, id;      int pos, npos, id;
65      int signo=0, uidno=0;      int signo=0, uidno=0;
66      GpgKeyEdit *ke;      GpgKeyEdit *ke;
67      gpgme_error_t err;      gpgme_error_t err;
68    
69      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
70      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
71          return -1;          return -1;
72      while (pos > 0 && is_sig (lv, pos)) {      while (pos > 0 && is_sig (lv, pos)) {
73          signo++;          signo++;
74          pos--;          pos--;
75      }      }
76      pos = npos;      pos = npos;
77      while (npos > 0) {      while (npos > 0) {
78          if (!is_sig (lv, npos))          if (!is_sig (lv, npos))
79              uidno++;              uidno++;
80          npos--;          npos--;
81      }      }
82      uidno++;      uidno++;
83    
84      /* XXX: do not allow to delete the self signature */      /* XXX: do not allow to delete the self signature */
85      id = log_box (_("Key Manager"), MB_YESNO,      id = log_box (_("Key Manager"), MB_YESNO,
86                    _("Are you really sure you want to delete this signature from\n"                    _("Are you really sure you want to delete this signature from\n"
87                      "  \"%s\""), key->uid);                      "  \"%s\""), key->uid);
88      if (id == IDNO)      if (id == IDNO)
89          return 0;          return 0;
90    
91      ke = new GpgKeyEdit (key->keyid);      ke = new GpgKeyEdit (key->keyid);
92      if (!ke)      if (!ke)
93          BUG (NULL);              BUG (NULL);    
94      err = ke->delUseridSignature (uidno, signo);      err = ke->delUseridSignature (uidno, signo);
95      if (err)      if (err)
96          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
97      else      else
98          listview_del_item (lv, pos);          listview_del_item (lv, pos);
99      delete ke;      delete ke;
100      key->update = 1; /*update*/      key->update = 1; /*update*/
101      return err? -1 : 0;      return err? -1 : 0;
102  }  }
103    
104    
105  /* Dialog box procedure to display the signature properties. */  /* Dialog box procedure to display the signature properties. */
106  static BOOL CALLBACK  static BOOL CALLBACK
107  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
108  {  {
109      static listview_ctrl_t lv;      static listview_ctrl_t lv;
110      char tmpbuf[256];      char tmpbuf[256];
111      int n;      int n;
112      struct {      struct {
113          unsigned int exportable:1;          unsigned int exportable:1;
114          unsigned int expired:1;          unsigned int expired:1;
115          unsigned int nrev:1;          unsigned int nrev:1;
116          unsigned int rev:1;          unsigned int rev:1;
117          const char * alg;          const char * alg;
118          int _class;          int _class;
119      } ctx;      } ctx;
120      const char *fmt_templ = _("%s %s signature");      const char *fmt_templ = _("%s %s signature");
121    
122      switch (msg) {      switch (msg) {
123      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
124          if (LOWORD (wparam) == SC_CLOSE)          if (LOWORD (wparam) == SC_CLOSE)
125              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
126          return FALSE;          return FALSE;
127    
128      case WM_INITDIALOG:      case WM_INITDIALOG:
129          lv = (listview_ctrl_t)lparam;          lv = (listview_ctrl_t)lparam;
130          if (!lv)          if (!lv)
131              dlg_fatal_error (dlg, "could not get dialog param");              dlg_fatal_error (dlg, "could not get dialog param");
132          memset (&ctx, 0, sizeof ctx);          memset (&ctx, 0, sizeof ctx);
133          n = listview_get_curr_pos (lv);          n = listview_get_curr_pos (lv);
134          listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);
135          if (!strstr (tmpbuf, "L"))          if (!strstr (tmpbuf, "L"))
136              ctx.exportable = 1;              ctx.exportable = 1;
137          ctx._class = atoi (tmpbuf);          ctx._class = atoi (tmpbuf);
138          if (ctx._class == 0)          if (ctx._class == 0)
139              ctx._class = 10;              ctx._class = 10;
140          else if (ctx._class < 10)          else if (ctx._class < 10)
141              ctx._class += 10;              ctx._class += 10;
142          listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);
143          if (strstr (tmpbuf, "DSA"))                  if (strstr (tmpbuf, "DSA"))        
144              ctx.alg = "DSA";              ctx.alg = "DSA";
145          else if (strstr (tmpbuf, "RSA"))          else if (strstr (tmpbuf, "RSA"))
146              ctx.alg = "RSA";              ctx.alg = "RSA";
147          else          else
148              ctx.alg = "ELG";              ctx.alg = "ELG";
149          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
150                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);
151          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
152          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);
153          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
154          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
155          if (ctx.exportable)          if (ctx.exportable)
156              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
157          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);
158          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);
159          tmpbuf[0] = 0;          tmpbuf[0] = 0;
160          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);
161          if (strlen (tmpbuf) == 0) {          if (strlen (tmpbuf) == 0) {
162              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
163              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
164          }          }
165          else {          else {
166              SYSTEMTIME st;              SYSTEMTIME st;
167              struct tm * tm;              struct tm * tm;
168              time_t t = time (NULL);              time_t t = time (NULL);
169    
170              memset (&st, 0, sizeof st);              memset (&st, 0, sizeof st);
171              st.wYear = atoi (tmpbuf);              st.wYear = atoi (tmpbuf);
172              st.wMonth = atoi (tmpbuf+5);              st.wMonth = atoi (tmpbuf+5);
173              st.wDay = atoi (tmpbuf+8);              st.wDay = atoi (tmpbuf+8);
174              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
175                                      GDT_VALID, &st);                                      GDT_VALID, &st);
176    
177              tm = localtime (&t);              tm = localtime (&t);
178              tm->tm_mon++;              tm->tm_mon++;
179              tm->tm_year += 1900;              tm->tm_year += 1900;
180              if (tm->tm_year > st.wYear)              if (tm->tm_year > st.wYear)
181                  ctx.expired = 1;                  ctx.expired = 1;
182              else if (tm->tm_mon > st.wMonth)              else if (tm->tm_mon > st.wMonth)
183                  ctx.expired = 1;                  ctx.expired = 1;
184              if (ctx.expired)              if (ctx.expired)
185                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
186          }          }
187          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
188          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
189          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
190          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
191          SetWindowText (dlg, _("Signature Properties"));          SetWindowText (dlg, _("Signature Properties"));
192          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
193          center_window (dlg, NULL);          center_window (dlg, NULL);
194          return TRUE;          return TRUE;
195    
196      case WM_COMMAND:      case WM_COMMAND:
197          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
198          case IDOK:          case IDOK:
199              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
200              break;              break;
201          }          }
202      }      }
203    
204      return FALSE;      return FALSE;
205  }  }
206    
207    
208  static BOOL CALLBACK  static BOOL CALLBACK
209  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
210  {  {
211      listview_ctrl_t lv;      listview_ctrl_t lv;
212      winpt_key_t key;      winpt_key_t key;
213    
214      switch (msg) {      switch (msg) {
215      case WM_KEYUP:      case WM_KEYUP:
216          int virt_key = (int)wparam;          int virt_key = (int)wparam;
217          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
218          lv = key->callback.ctl;          lv = key->callback.ctl;
219          if (virt_key == VK_SPACE) {          if (virt_key == VK_SPACE) {
220              if (is_sig (lv, -1))              if (is_sig (lv, -1))
221                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
222                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)lv);
223          }          }
224          else if (virt_key == VK_DELETE)          else if (virt_key == VK_DELETE)
225              do_delsig (dlg, lv, key);              do_delsig (dlg, lv, key);
226          break;          break;
227      }      }
228      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);
229  }  }
230    
231    
232  /* Return 1 if the list view @lv contains non-available keys. */  /* Return 1 if the list view @lv contains non-available keys. */
233  static int  static int
234  check_for_missing_keys (listview_ctrl_t lv)  check_for_missing_keys (listview_ctrl_t lv)
235  {  {
236      int i, n;      int i, n;
237      char id[128];      char id[128];
238            
239      n = listview_count_items( lv, 0 );      n = listview_count_items( lv, 0 );
240      for( i = 0; i < n; i++ ) {      for( i = 0; i < n; i++ ) {
241          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );
242          if( !strncmp( id, "NOKEY", 5 ) )          if( !strncmp( id, "NOKEY", 5 ) )
243              return 1;              return 1;
244      }      }
245            
246      return 0;      return 0;
247  }  }
248    
249    
250  /* Receive all missing keys marked in the list @lv. */  /* Receive all missing keys marked in the list @lv. */
251  static int  static int
252  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
253  {  {
254      int i, n, rc;      int i, n, rc;
255      char id[128], keyid[18+1];      char id[128], keyid[18+1];
256            
257      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
258      for( i = 0; i < n; i++ ) {      for( i = 0; i < n; i++ ) {
259          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );
260          if( !strncmp( id, "NOKEY", 5 ) ) {          if( !strncmp( id, "NOKEY", 5 ) ) {
261              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );
262              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );
263              if( rc )                            if( rc )              
264                  break;                  break;
265          }          }
266      }      }
267            
268      return rc;      return rc;
269  }  }
270    
271    
272  /* Create a mini popup with available choices. */  /* Create a mini popup with available choices. */
273  static void  static void
274  do_create_popup (HWND dlg)  do_create_popup (HWND dlg)
275  {  {
276      HMENU hm, sm;      HMENU hm, sm;
277      POINT p;      POINT p;
278    
279      GetCursorPos (&p);      GetCursorPos (&p);
280      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
281      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
282    
283      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
284      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
285    
286      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
287    
288      DestroyMenu (hm);      DestroyMenu (hm);
289      DestroyMenu (sm);      DestroyMenu (sm);
290  }  }
291    
292    
293  /* Load the key property dialog with the selected key from @lv. */  /* Load the key property dialog with the selected key from @lv. */
294  static void  static void
295  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
296  {  {
297      winpt_key_s k;      winpt_key_s k;
298      gpgme_key_t key;      gpgme_key_t key;
299      char keyid[32] = {0};      char keyid[32] = {0};
300      char status[64] = {0}, creation[64] = {0};      char status[64] = {0}, creation[64] = {0};
301      int n = listview_get_curr_pos (lv);      int n = listview_get_curr_pos (lv);
302    
303      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      listview_get_item_text (lv, n, 1, status, DIM (status)-1);
304      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);
305      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);
306      if (!strcmp (status, "NOKEY")) {      if (!strcmp (status, "NOKEY")) {
307          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),
308                   _("Key Manager"), MB_INFO);                   _("Key Manager"), MB_INFO);
309          return;          return;
310      }      }
311            
312      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {
313          if (strlen (creation) > 0)          if (strlen (creation) > 0)
314              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
315          return;          return;
316      }      }
317      memset (&k, 0, sizeof k);      memset (&k, 0, sizeof k);
318      k.keyid = keyid;      k.keyid = keyid;
319      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
320                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
321  }  }
322    
323    
324  /* Dialog box procedure to list signatures. */  /* Dialog box procedure to list signatures. */
325  BOOL CALLBACK  BOOL CALLBACK
326  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
327  {  {
328      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
329      static struct winpt_key_s *k;      static struct winpt_key_s *k;
330      char inf[384], keyid[18+1];          char inf[384], keyid[18+1];    
331      int idx = 0, id, rc;      int idx = 0, id, rc;
332      HWND sl;      HWND sl;
333            
334      switch( msg ) {      switch( msg ) {
335      case WM_INITDIALOG:      case WM_INITDIALOG:
336          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
337          if (!k)          if (!k)
338              BUG (0);              BUG (0);
339          if (k->uid)          if (k->uid)
340              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
341          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
342          #ifndef LANG_DE          #ifndef LANG_DE
343          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
344          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
345          #endif          #endif
346          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
347          if (!check_for_missing_keys (lv))          if (!check_for_missing_keys (lv))
348              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
349          k->callback.ctl = lv;          k->callback.ctl = lv;
350          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
351          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
352          siglist_proc.opaque = k;          siglist_proc.opaque = k;
353          siglist_proc.current = (WNDPROC)subclass_dlg_proc;          siglist_proc.current = (WNDPROC)subclass_dlg_proc;
354          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
355          if (siglist_proc.old) {          if (siglist_proc.old) {
356              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
357                  msg_box (dlg, _("Could not set keylist window procedure."),                  msg_box (dlg, _("Could not set keylist window procedure."),
358                           _("Key Manager"), MB_ERR);                           _("Key Manager"), MB_ERR);
359                  BUG (0);                  BUG (0);
360              }              }
361          }          }
362          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
363          center_window (dlg, NULL);          center_window (dlg, NULL);
364          return TRUE;          return TRUE;
365                    
366      case WM_DESTROY:      case WM_DESTROY:
367          if ( lv ) {          if ( lv ) {
368              siglist_delete( lv );              siglist_delete( lv );
369              lv = NULL;              lv = NULL;
370          }          }
371          return FALSE;          return FALSE;
372                    
373      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
374          if (LOWORD (wparam) == SC_CLOSE) {          if (LOWORD (wparam) == SC_CLOSE) {
375              if (k->update)              if (k->update)
376                  keycache_update (0, k->keyid);                  keycache_update (0, k->keyid);
377              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
378          }          }
379          return FALSE;          return FALSE;
380    
381      case WM_NOTIFY:      case WM_NOTIFY:
382          NMHDR * notify;          NMHDR *notify;
383                    
384          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
385          if( notify && notify->code == NM_DBLCLK          if (notify && notify->code == NM_DBLCLK
386              && notify->idFrom == IDC_KEYSIG_LIST )              && notify->idFrom == IDC_KEYSIG_LIST)
387              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
388          if (notify && notify->code == NM_RCLICK &&          if (notify && notify->code == NM_RCLICK &&
389              notify->idFrom == IDC_KEYSIG_LIST)              notify->idFrom == IDC_KEYSIG_LIST)
390              do_create_popup (dlg);              do_create_popup (dlg);
391          break;          if (notify && notify->code == LVN_ITEMCHANGED &&
392                        ((LPNMLISTVIEW)lparam)->uNewState) {
393      case WM_COMMAND:              idx = listview_get_curr_pos (lv);
394          switch ( LOWORD( wparam ) ) {              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
395                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
396          case ID_SIGCTX_KEYPROPS:                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
397              do_load_keyprops (dlg, lv);          }
398              break;          break;
399            
400          case ID_SIGCTX_PROPS:      case WM_COMMAND:
401              if (is_sig (lv, -1))          switch ( LOWORD( wparam ) ) {
402                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,  
403                                  sigprops_dlg_proc, (LPARAM)lv);          case ID_SIGCTX_KEYPROPS:
404              break;              do_load_keyprops (dlg, lv);
405                break;
406          case IDC_KEYSIG_RECVKEY:  
407              idx = listview_get_curr_pos (lv);          case ID_SIGCTX_PROPS:
408              if (idx == -1) {              if (is_sig (lv, -1))
409                  id = msg_box( dlg, _("Really receive all missing keys?"),                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
410                                  _("Key Manager"), MB_YESNO|MB_INFO );                                  sigprops_dlg_proc, (LPARAM)lv);
411                  if (id == IDYES) {              break;
412                      rc = recv_missing_keys (dlg, lv);  
413                      if( !rc )          case IDC_KEYSIG_RECVKEY:
414                          keycache_set_reload (1);              idx = listview_get_curr_pos (lv);
415                      return TRUE;              if (idx == -1) {
416                  }                  id = msg_box( dlg, _("Really receive all missing keys?"),
417                  return TRUE;                                  _("Key Manager"), MB_YESNO|MB_INFO );
418              }                  if (id == IDYES) {
419              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);                      rc = recv_missing_keys (dlg, lv);
420              if (strcmp (inf, "NOKEY"))                      if (!rc)
421                  return FALSE;                          keycache_set_reload (1);
422              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);                      return TRUE;
423              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);                  }
424              if (!rc)                  return TRUE;
425                  keycache_set_reload (1);              }
426              return TRUE;              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);
427                rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);
428          case IDC_KEYSIG_SIGPROPS:              if (!rc)
429              if (is_sig (lv, -1))                  keycache_update (0, keyid);
430                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,              return TRUE;
431                                  sigprops_dlg_proc, (LPARAM)lv);  
432              return TRUE;          case IDC_KEYSIG_SIGPROPS:
433                            if (is_sig (lv, -1))
434          case IDOK:                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
435              if (k->update)                                  sigprops_dlg_proc, (LPARAM)lv);
436                  keycache_update (0, k->keyid);              return TRUE;
437              EndDialog (dlg, TRUE);              
438              return TRUE;          case IDOK:
439          }              if (k->update)
440          break;                  keycache_update (0, k->keyid);
441      }              EndDialog (dlg, TRUE);
442      return FALSE;              return TRUE;
443            }
444            break;
445        }
446        return FALSE;
447  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.41

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26