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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26