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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26