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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26