/[winpt]/trunk/Src/wptKeysigDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptKeysigDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26