/[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 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC revision 47 by werner, Mon Oct 31 14:04:59 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          signo++;      int pos, npos, id;
70          pos--;      int signo=0, uidno=0;
71      }      GpgKeyEdit *ke;
72      pos = npos;      gpgme_error_t err;
73      while (npos > 0) {  
74          if (!is_sig (lv, npos))      npos = pos = listview_get_curr_pos (lv);
75              uidno++;      if (!is_sig (lv, -1))
76          npos--;          return -1;
77      }      while (pos > 0 && is_sig (lv, pos)) {
78      uidno++;          signo++;
79            pos--;
80      /* XXX: do not allow to delete the self signature */      }
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      key->update = 1; /*update*/          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
102      return 0;      else
103  }          listview_del_item (lv, pos);
104        delete ke;
105        key->update = 1; /*update*/
106  static BOOL CALLBACK      return err? -1 : 0;
107  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  }
108  {  
109      static listview_ctrl_t lv;  
110      char tmpbuf[256];  /* Dialog box procedure to display the signature properties. */
111      int n;  static BOOL CALLBACK
112      struct {  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
113          unsigned int exportable:1;  {
114          unsigned int expired:1;      static listview_ctrl_t lv;
115          unsigned int nrev:1;      char tmpbuf[256];
116          unsigned int rev:1;      int n;
117          const char * alg;      struct {
118          int _class;          unsigned int exportable:1;
119      } ctx;          unsigned int expired:1;
120      const char * fmt_templ = "%s %s signature";          unsigned int nrev:1;
121            unsigned int rev:1;
122      switch (msg) {          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      case WM_KEYUP:  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
215          int virt_key = (int)wparam;  {
216          key = (winpt_key_t)siglist_proc.opaque;      listview_ctrl_t lv;
217          lv = key->callback.ctl;      winpt_key_t key;
218          if (virt_key == VK_SPACE) {  
219              if (is_sig (lv, -1))      switch (msg) {
220                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,      case WM_KEYUP:
221                                  sigprops_dlg_proc, (LPARAM)lv);          int virt_key = (int)wparam;
222          }          key = (winpt_key_t)siglist_proc.opaque;
223          else if (virt_key == VK_DELETE)          lv = key->callback.ctl;
224              do_delsig (dlg, lv, key);          if (virt_key == VK_SPACE) {
225          break;              if (is_sig (lv, -1))
226      }                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
227      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);                                  sigprops_dlg_proc, (LPARAM)lv);
228  }          }
229            else if (virt_key == VK_DELETE)
230                do_delsig (dlg, lv, key);
231  static int          break;
232  check_for_missing_keys (listview_ctrl_t lv)      }
233  {      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);
234      int i, n;  }
235      char id[128];  
236        
237      n = listview_count_items( lv, 0 );  /* Return 1 if the list view @lv contains non-available keys. */
238      for( i = 0; i < n; i++ ) {  static int
239          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );  check_for_missing_keys (listview_ctrl_t lv)
240          if( !strncmp( id, "NOKEY", 5 ) )  {
241              return 1;      int i, n;
242      }      char id[128];
243            
244      return 0;      n = listview_count_items( lv, 0 );
245  } /* check_for_missing_keys */      for( i = 0; i < n; i++ ) {
246            listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );
247            if( !strncmp( id, "NOKEY", 5 ) )
248  static int              return 1;
249  recv_missing_keys (HWND dlg, listview_ctrl_t lv)      }
250  {      
251      int i, n, rc;      return 0;
252      char id[128], keyid[18+1];  }
253        
254      n = listview_count_items (lv, 0);  
255      for( i = 0; i < n; i++ ) {  /* Receive all missing keys marked in the list @lv. */
256          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );  static int
257          if( !strncmp( id, "NOKEY", 5 ) ) {  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
258              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );  {
259              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );      int i, n, rc;
260              if( rc )                    char id[128], keyid[18+1];
261                  break;      
262          }      n = listview_count_items (lv, 0);
263      }      for( i = 0; i < n; i++ ) {
264                listview_get_item_text( lv, i, 1, id, sizeof id - 1 );
265      return rc;          if( !strncmp( id, "NOKEY", 5 ) ) {
266  } /* recv_missing_keys */              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );
267                rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );
268                if( rc )              
269  static void                  break;
270  do_create_popup (HWND dlg)          }
271  {      }
272      HMENU hm, sm;      
273      POINT p;      return rc;
274    }
275      GetCursorPos (&p);  
276      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));  
277      sm = GetSubMenu (hm, 0);  /* Create a mini popup with available choices. */
278    static void
279      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);  do_create_popup (HWND dlg)
280    {
281      DestroyMenu (hm);      HMENU hm, sm;
282      DestroyMenu (sm);      POINT p;
283  }  
284        GetCursorPos (&p);
285        hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
286  static void      sm = GetSubMenu (hm, 0);
287  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  
288  {      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
289      winpt_key_s k;      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
290      gpgme_key_t key;  
291      char keyid[32] = {0};      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
292      char status[64] = {0}, creation[64] = {0};  
293      int n = listview_get_curr_pos (lv);      DestroyMenu (hm);
294        DestroyMenu (sm);
295      listview_get_item_text (lv, n, 1, status, DIM (status)-1);  }
296      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);  
297      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);  
298      if (!strcmp (status, "NOKEY")) {  /* Load the key property dialog with the selected key from @lv. */
299          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),  static void
300                   _("Key Manager"), MB_INFO);  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
301          return;  {
302      }      winpt_key_s k;
303            gpgme_key_t key;
304      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      char keyid[32] = {0};
305          if (strlen (creation) > 0)      char status[64] = {0}, creation[64] = {0};
306              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);      int n = listview_get_curr_pos (lv);
307          return;  
308      }      listview_get_item_text (lv, n, 1, status, DIM (status)-1);
309      memset (&k, 0, sizeof k);      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);
310      k.keyid = keyid;      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);
311      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      if (!strcmp (status, "NOKEY")) {
312                      keyprops_dlg_proc, (LPARAM)&k);          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),
313  }                   _("Key Manager"), MB_INFO);
314            return;
315          }
316  BOOL CALLBACK      
317  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {
318  {          if (strlen (creation) > 0)
319      static listview_ctrl_t lv = NULL;              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
320      static struct winpt_key_s *k;          return;
321      char inf[384], keyid[18+1];          }
322      int idx = 0, id, rc;      memset (&k, 0, sizeof k);
323      HWND sl;      k.keyid = keyid;
324            DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
325      switch( msg ) {                      keyprops_dlg_proc, (LPARAM)&k);
326      case WM_INITDIALOG:  }
327          k = (winpt_key_t) lparam;  
328          if (!k)  
329              BUG (0);  /* Dialog box procedure to list signatures. */
330          if (k->uid)  BOOL CALLBACK
331              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
332          SetWindowText (dlg, inf);  {
333          #ifndef LANG_DE      static listview_ctrl_t lv = NULL;
334          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));      static struct winpt_key_s *k;
335          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));      char inf[384], keyid[18+1];    
336          #endif      int idx = 0, id, rc;
337          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);      HWND sl;
338          if (!check_for_missing_keys (lv))      
339              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);      switch( msg ) {
340          k->callback.ctl = lv;      case WM_INITDIALOG:
341          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          k = (winpt_key_t) lparam;
342          siglist_proc.dlg = dlg;          if (!k)
343          siglist_proc.opaque = k;              BUG (0);
344          siglist_proc.current = (WNDPROC)subclass_dlg_proc;          if (k->uid)
345          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
346          if (siglist_proc.old) {          SetWindowText (dlg, inf);
347              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {          #ifndef LANG_DE
348                  msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR);          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
349                  BUG (0);          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
350              }          #endif
351          }          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
352          SetForegroundWindow (dlg);          if (!check_for_missing_keys (lv))
353          center_window (dlg);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
354          return TRUE;          k->callback.ctl = lv;
355                    sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
356      case WM_DESTROY:          siglist_proc.dlg = dlg;
357          if ( lv ) {          siglist_proc.opaque = k;
358              siglist_delete( lv );          siglist_proc.current = (WNDPROC)subclass_dlg_proc;
359              lv = NULL;          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
360          }          if (siglist_proc.old) {
361          return FALSE;              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
362                            msg_box (dlg, _("Could not set keylist window procedure."),
363      case WM_SYSCOMMAND:                           _("Key Manager"), MB_ERR);
364          if (LOWORD (wparam) == SC_CLOSE) {                  BUG (0);
365              if (k->update)              }
366                  keycache_update (0, k->keyid);          }
367              EndDialog (dlg, TRUE);          SetForegroundWindow (dlg);
368          }          center_window (dlg, NULL);
369          return FALSE;          return TRUE;
370            
371      case WM_NOTIFY:      case WM_DESTROY:
372          NMHDR * notify;          if ( lv ) {
373                        siglist_delete( lv );
374          notify = (NMHDR *)lparam;              lv = NULL;
375          if( notify && notify->code == NM_DBLCLK          }
376              && notify->idFrom == IDC_KEYSIG_LIST )          return FALSE;
377              do_load_keyprops (dlg, lv);          
378          if (notify && notify->code == NM_RCLICK &&      case WM_SYSCOMMAND:
379              notify->idFrom == IDC_KEYSIG_LIST)          if (LOWORD (wparam) == SC_CLOSE) {
380              do_create_popup (dlg);              if (k->update)
381          break;                  keycache_update (0, k->keyid);
382                        EndDialog (dlg, TRUE);
383      case WM_COMMAND:          }
384          switch ( LOWORD( wparam ) ) {          return FALSE;
385    
386          case ID_SIGCTX_KEYPROPS:      case WM_NOTIFY:
387              do_load_keyprops (dlg, lv);          NMHDR *notify;
388              break;          
389            notify = (NMHDR *)lparam;
390          case ID_SIGCTX_PROPS:          if (notify && notify->code == NM_DBLCLK
391              if (is_sig (lv, -1))              && notify->idFrom == IDC_KEYSIG_LIST)
392                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,              do_load_keyprops (dlg, lv);
393                                  sigprops_dlg_proc, (LPARAM)lv);          if (notify && notify->code == NM_RCLICK &&
394              break;              notify->idFrom == IDC_KEYSIG_LIST)
395                do_create_popup (dlg);
396          case IDC_KEYSIG_RECVKEY:          if (notify && notify->code == LVN_ITEMCHANGED &&
397              idx = listview_get_curr_pos (lv);              ((LPNMLISTVIEW)lparam)->uNewState) {
398              if (idx == -1) {              idx = listview_get_curr_pos (lv);
399                  id = msg_box( dlg, _("Really receive all missing keys?"),              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
400                                  _("Key Manager"), MB_YESNO|MB_INFO );              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
401                  if (id == IDYES) {                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
402                      rc = recv_missing_keys (dlg, lv);          }
403                      if( !rc )          break;
404                          keycache_set_reload (1);          
405                      return TRUE;      case WM_COMMAND:
406                  }          switch ( LOWORD( wparam ) ) {
407                  return FALSE;  
408              }          case ID_SIGCTX_KEYPROPS:
409              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);              do_load_keyprops (dlg, lv);
410              if (strcmp (inf, "NOKEY"))              break;
411                  return FALSE;  
412              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);          case ID_SIGCTX_PROPS:
413              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);              if (is_sig (lv, -1))
414              if (!rc)                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
415                  keycache_set_reload (1);                                  sigprops_dlg_proc, (LPARAM)lv);
416              return TRUE;              break;
417    
418          case IDC_KEYSIG_SIGPROPS:          case IDC_KEYSIG_RECVKEY:
419              if (is_sig (lv, -1))              idx = listview_get_curr_pos (lv);
420                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,              if (idx == -1) {
421                                  sigprops_dlg_proc, (LPARAM)lv);                  id = msg_box( dlg, _("Really receive all missing keys?"),
422              return TRUE;                                  _("Key Manager"), MB_YESNO|MB_INFO );
423                                if (id == IDYES) {
424          case IDOK:                      rc = recv_missing_keys (dlg, lv);
425              if (k->update)                      if (!rc)
426                  keycache_update (0, k->keyid);                          keycache_set_reload (1);
427              EndDialog (dlg, TRUE);                      return TRUE;
428              return TRUE;                  }
429          }                  return TRUE;
430          break;              }
431      }              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);
432      return FALSE;              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);
433  } /* keysig_dlg_proc */              if (!rc)
434                    keycache_update (0, keyid);
435                return TRUE;
436    
437            case IDC_KEYSIG_SIGPROPS:
438                if (is_sig (lv, -1))
439                    DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
440                                    sigprops_dlg_proc, (LPARAM)lv);
441                return TRUE;
442                
443            case IDOK:
444                if (k->update)
445                    keycache_update (0, k->keyid);
446                EndDialog (dlg, TRUE);
447                return TRUE;
448            }
449            break;
450        }
451        return FALSE;
452    }

Legend:
Removed from v.22  
changed lines
  Added in v.47

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26