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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26