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

Legend:
Removed from v.32  
changed lines
  Added in v.65

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26