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

Diff of /trunk/Src/wptKeysigDlg.cpp

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

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

Legend:
Removed from v.24  
changed lines
  Added in v.128

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26