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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26