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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26