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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26