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

Legend:
Removed from v.2  
changed lines
  Added in v.41

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26