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

Legend:
Removed from v.13  
changed lines
  Added in v.36

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26