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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26