/[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 24 by twoaday, Sat Oct 8 10:43:08 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      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);  
275    
276      DestroyMenu (hm);  /* Create a mini popup with available choices. */
277      DestroyMenu (sm);  static void
278  }  do_create_popup (HWND dlg)
279    {
280        HMENU hm, sm;
281  static void      POINT p;
282  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  
283  {      GetCursorPos (&p);
284      winpt_key_s k;      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
285      gpgme_key_t key;      sm = GetSubMenu (hm, 0);
286      char keyid[32] = {0};  
287      char status[64] = {0}, creation[64] = {0};      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
288      int n = listview_get_curr_pos (lv);      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
289    
290      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
291      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);  
292      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      DestroyMenu (hm);
293      if (!strcmp (status, "NOKEY")) {      DestroyMenu (sm);
294          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),  }
295                   _("Key Manager"), MB_INFO);  
296          return;  
297      }  /* Load the key property dialog with the selected key from @lv. */
298        static void
299      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
300          if (strlen (creation) > 0)  {
301              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);      winpt_key_s k;
302          return;      gpgme_key_t key;
303      }      char keyid[32] = {0};
304      memset (&k, 0, sizeof k);      char status[64] = {0}, creation[64] = {0};
305      k.keyid = keyid;      int n = listview_get_curr_pos (lv);
306      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,  
307                      keyprops_dlg_proc, (LPARAM)&k);      listview_get_item_text (lv, n, 1, status, DIM (status)-1);
308  }      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);
309        listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);
310          if (!strcmp (status, "NOKEY")) {
311  BOOL CALLBACK          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),
312  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)                   _("Key Manager"), MB_INFO);
313  {          return;
314      static listview_ctrl_t lv = NULL;      }
315      static struct winpt_key_s *k;      
316      char inf[384], keyid[18+1];          if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {
317      int idx = 0, id, rc;          if (strlen (creation) > 0)
318      HWND sl;              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
319                return;
320      switch( msg ) {      }
321      case WM_INITDIALOG:      memset (&k, 0, sizeof k);
322          k = (winpt_key_t) lparam;      k.keyid = keyid;
323          if (!k)      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
324              BUG (0);                      keyprops_dlg_proc, (LPARAM)&k);
325          if (k->uid)  }
326              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);  
327          SetWindowText (dlg, inf);  
328          #ifndef LANG_DE  /* Dialog box procedure to list signatures. */
329          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));  BOOL CALLBACK
330          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
331          #endif  {
332          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);      static listview_ctrl_t lv = NULL;
333          if (!check_for_missing_keys (lv))      static struct winpt_key_s *k;
334              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);      char inf[384], keyid[18+1];    
335          k->callback.ctl = lv;      int idx = 0, id, rc;
336          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);      HWND sl;
337          siglist_proc.dlg = dlg;      
338          siglist_proc.opaque = k;      switch( msg ) {
339          siglist_proc.current = (WNDPROC)subclass_dlg_proc;      case WM_INITDIALOG:
340          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          k = (winpt_key_t) lparam;
341          if (siglist_proc.old) {          if (!k)
342              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              BUG (0);
343                  msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR);          if (k->uid)
344                  BUG (0);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
345              }          SetWindowText (dlg, inf);
346          }          #ifndef LANG_DE
347          SetForegroundWindow (dlg);          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
348          center_window (dlg, NULL);          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
349          return TRUE;          #endif
350                    lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
351      case WM_DESTROY:          if (!check_for_missing_keys (lv))
352          if ( lv ) {              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
353              siglist_delete( lv );          k->callback.ctl = lv;
354              lv = NULL;          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
355          }          siglist_proc.dlg = dlg;
356          return FALSE;          siglist_proc.opaque = k;
357                    siglist_proc.current = (WNDPROC)subclass_dlg_proc;
358      case WM_SYSCOMMAND:          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
359          if (LOWORD (wparam) == SC_CLOSE) {          if (siglist_proc.old) {
360              if (k->update)              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
361                  keycache_update (0, k->keyid);                  msg_box (dlg, _("Could not set keylist window procedure."),
362              EndDialog (dlg, TRUE);                           _("Key Manager"), MB_ERR);
363          }                  BUG (0);
364          return FALSE;              }
365            }
366      case WM_NOTIFY:          SetForegroundWindow (dlg);
367          NMHDR * notify;          center_window (dlg, NULL);
368                    return TRUE;
369          notify = (NMHDR *)lparam;          
370          if( notify && notify->code == NM_DBLCLK      case WM_DESTROY:
371              && notify->idFrom == IDC_KEYSIG_LIST )          if ( lv ) {
372              do_load_keyprops (dlg, lv);              siglist_delete( lv );
373          if (notify && notify->code == NM_RCLICK &&              lv = NULL;
374              notify->idFrom == IDC_KEYSIG_LIST)          }
375              do_create_popup (dlg);          return FALSE;
376          break;          
377                case WM_SYSCOMMAND:
378      case WM_COMMAND:          if (LOWORD (wparam) == SC_CLOSE) {
379          switch ( LOWORD( wparam ) ) {              if (k->update)
380                    keycache_update (0, k->keyid);
381          case ID_SIGCTX_KEYPROPS:              EndDialog (dlg, TRUE);
382              do_load_keyprops (dlg, lv);          }
383              break;          return FALSE;
384    
385          case ID_SIGCTX_PROPS:      case WM_NOTIFY:
386              if (is_sig (lv, -1))          NMHDR *notify;
387                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,          
388                                  sigprops_dlg_proc, (LPARAM)lv);          notify = (NMHDR *)lparam;
389              break;          if (notify && notify->code == NM_DBLCLK
390                && notify->idFrom == IDC_KEYSIG_LIST)
391          case IDC_KEYSIG_RECVKEY:              do_load_keyprops (dlg, lv);
392              idx = listview_get_curr_pos (lv);          if (notify && notify->code == NM_RCLICK &&
393              if (idx == -1) {              notify->idFrom == IDC_KEYSIG_LIST)
394                  id = msg_box( dlg, _("Really receive all missing keys?"),              do_create_popup (dlg);
395                                  _("Key Manager"), MB_YESNO|MB_INFO );          if (notify && notify->code == LVN_ITEMCHANGED &&
396                  if (id == IDYES) {              ((LPNMLISTVIEW)lparam)->uNewState) {
397                      rc = recv_missing_keys (dlg, lv);              idx = listview_get_curr_pos (lv);
398                      if( !rc )              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
399                          keycache_set_reload (1);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
400                      return TRUE;                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
401                  }          }
402                  return TRUE;          break;
403              }          
404              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);      case WM_COMMAND:
405              if (strcmp (inf, "NOKEY"))          switch ( LOWORD( wparam ) ) {
406                  return FALSE;  
407              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);          case ID_SIGCTX_KEYPROPS:
408              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);              do_load_keyprops (dlg, lv);
409              if (!rc)              break;
410                  keycache_set_reload (1);  
411              return TRUE;          case ID_SIGCTX_PROPS:
412                if (is_sig (lv, -1))
413          case IDC_KEYSIG_SIGPROPS:                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
414              if (is_sig (lv, -1))                                  sigprops_dlg_proc, (LPARAM)lv);
415                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,              break;
416                                  sigprops_dlg_proc, (LPARAM)lv);  
417              return TRUE;          case IDC_KEYSIG_RECVKEY:
418                            idx = listview_get_curr_pos (lv);
419          case IDOK:              if (idx == -1) {
420              if (k->update)                  id = msg_box( dlg, _("Really receive all missing keys?"),
421                  keycache_update (0, k->keyid);                                  _("Key Manager"), MB_YESNO|MB_INFO );
422              EndDialog (dlg, TRUE);                  if (id == IDYES) {
423              return TRUE;                      rc = recv_missing_keys (dlg, lv);
424          }                      if (!rc)
425          break;                          keycache_set_reload (1);
426      }                      return TRUE;
427      return FALSE;                  }
428  } /* keysig_dlg_proc */                  return TRUE;
429                }
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.24  
changed lines
  Added in v.48

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26