/[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 42 by werner, Fri Oct 28 08:25:30 2005 UTC revision 201 by twoaday, Sat Apr 22 18:30:24 2006 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-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 17  Line 17 
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  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
21  #include <config.h>  #include <config.h>
22  #endif  #endif
23    
24  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
25  #include <commctrl.h>  #include <commctrl.h>
26  #include <time.h>  #include <time.h>
27    
28  #include "../resource.h"  #include "resource.h"
29  #include "wptGPG.h"  #include "wptGPG.h"
30  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
31  #include "wptContext.h" /* for passphrase_s */  #include "wptContext.h" /* for passphrase_s */
32  #include "wptDlgs.h"  #include "wptDlgs.h"
33  #include "wptW32API.h"  #include "wptW32API.h"
34  #include "wptNLS.h"  #include "wptNLS.h"
35  #include "wptKeyList.h"  #include "wptKeylist.h"
36  #include "wptKeyserver.h"  #include "wptKeyserver.h"
37  #include "wptUTF8.h"  #include "wptUTF8.h"
38  #include "wptTypes.h"  #include "wptTypes.h"
# Line 48  static subclass_s siglist_proc; Line 46  static subclass_s siglist_proc;
46  static int  static int
47  is_sig (listview_ctrl_t lv, int pos)  is_sig (listview_ctrl_t lv, int pos)
48  {  {
49      char tmpbuf[256];      char tmpbuf[200];
50    
51      if (pos == -1)      if (pos == -1)
52          pos = listview_get_curr_pos (lv);          pos = listview_get_curr_pos (lv);
53      if (pos == -1)      if (pos == -1)
54          return 0;          return 0;
55      listview_get_item_text (lv, pos, 0, tmpbuf, 200);      listview_get_item_text (lv, pos, SL_COL_UID, tmpbuf, sizeof (tmpbuf)-1);
56      if (*tmpbuf == ' ')      if (*tmpbuf == ' ')
57          return -1;          return -1;
58      return 0;      return 0;
# Line 66  is_sig (listview_ctrl_t lv, int pos) Line 64  is_sig (listview_ctrl_t lv, int pos)
64  static int  static int
65  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
66  {  {
     int pos, npos, id;  
     int signo=0, uidno=0;  
     GpgKeyEdit *ke;  
67      gpgme_error_t err;      gpgme_error_t err;
68        GpgKeyEdit *ke;
69        char keyid[32];
70        int pos, npos, id, is_selfsig=0;
71        int signo=0, uidno=0;
72    
73      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
74      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
75          return -1;          return -1;
76        listview_get_item_text (lv, pos, SL_COL_KEYID, keyid, sizeof (keyid)-1);
77        if (!strncmp (key->keyid, keyid+2, 8))
78            is_selfsig = 1;
79        
80      while (pos > 0 && is_sig (lv, pos)) {      while (pos > 0 && is_sig (lv, pos)) {
81          signo++;          signo++;
82          pos--;          pos--;
# Line 87  do_delsig (HWND dlg, listview_ctrl_t lv, Line 90  do_delsig (HWND dlg, listview_ctrl_t lv,
90      uidno++;      uidno++;
91    
92      /* XXX: do not allow to delete the self signature */      /* XXX: do not allow to delete the self signature */
93      id = log_box (_("Key Manager"), MB_YESNO,      id = log_box (_("Key Manager"), is_selfsig? MB_WARN_ASK : MB_QUEST_ASK,
94                    _("Are you really sure you want to delete this signature from\n"                    _("Are you really sure you want to delete this %s from\n\n"
95                      "  \"%s\""), key->uid);                    "  \"%s\""), is_selfsig? _("self signature") : _("signature"),
96                      key->uid);
97      if (id == IDNO)      if (id == IDNO)
98          return 0;          return 0;
99    
# Line 102  do_delsig (HWND dlg, listview_ctrl_t lv, Line 106  do_delsig (HWND dlg, listview_ctrl_t lv,
106      else      else
107          listview_del_item (lv, pos);          listview_del_item (lv, pos);
108      delete ke;      delete ke;
109      key->update = 1; /*update*/      if (!err)
110            key->update = 1;
111      return err? -1 : 0;      return err? -1 : 0;
112  }  }
113    
114    
115  /* Dialog box procedure to display the signature properties. */  /* Dialog box procedure to display the signature properties. */
116  static BOOL CALLBACK  BOOL CALLBACK
117  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
118  {  {
119      static listview_ctrl_t lv;      static gpgme_key_sig_t ks;
120        gpgme_key_t issuer;
121      char tmpbuf[256];      char tmpbuf[256];
     int n;  
122      struct {      struct {
123          unsigned int exportable:1;          unsigned int exportable:1;
124          unsigned int expired:1;          unsigned int expired:1;
125          unsigned int nrev:1;          unsigned int nrev:1;
126          unsigned int rev:1;          unsigned int rev:1;
127          const char * alg;          const char *alg;
128          int _class;          int _class;
129      } ctx;      } ctx;
130      const char *fmt_templ = _("%s %s signature");      const char *fmt_templ = _("%s %s signature");
# Line 131  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 136  sigprops_dlg_proc (HWND dlg, UINT msg, W
136          return FALSE;          return FALSE;
137    
138      case WM_INITDIALOG:      case WM_INITDIALOG:
139          lv = (listview_ctrl_t)lparam;          SetWindowText (dlg, _("Signature Properties"));
140          if (!lv)          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
141              dlg_fatal_error (dlg, "could not get dialog param");          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
142            SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
143            SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
144            SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class"));
145            SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
146            SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
147            SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
148            ks = (gpgme_key_sig_t)lparam;
149            if (!ks)
150                BUG (0);
151          memset (&ctx, 0, sizeof ctx);          memset (&ctx, 0, sizeof ctx);
152          n = listview_get_curr_pos (lv);          ctx._class = ks->sig_class;
         listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);  
         if (!strstr (tmpbuf, "L"))  
             ctx.exportable = 1;  
         ctx._class = atoi (tmpbuf);  
153          if (ctx._class == 0)          if (ctx._class == 0)
154              ctx._class = 10;              ctx._class = 16;    
155          else if (ctx._class < 10)          ctx._class -= 6;
156              ctx._class += 10;          if (ks->pubkey_algo == GPGME_PK_DSA)
         listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);  
         if (strstr (tmpbuf, "DSA"))          
157              ctx.alg = "DSA";              ctx.alg = "DSA";
158          else if (strstr (tmpbuf, "RSA"))          else if (ks->pubkey_algo == GPGME_PK_RSA)
159              ctx.alg = "RSA";              ctx.alg = "RSA";
160          else          else
161              ctx.alg = "ELG";              ctx.alg = "ELG";
162            ctx.exportable = ks->exportable;
163          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
164                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);
165          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
166          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          
167          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, ks->keyid+8);
168          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
169          if (ctx.exportable)          if (ctx.exportable)
170              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
171          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);          if (!get_pubkey (ks->keyid+8, &issuer)) {
172          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);              char *uid = utf8_to_native (issuer->uids->uid);
173          tmpbuf[0] = 0;              SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, uid);
174          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);              safe_free (uid);
175          if (strlen (tmpbuf) == 0) {          }
176            else
177                SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, _("  user ID not found"));
178            if (ks->expires == 0) {
179              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
180              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
181          }          }
182          else {          else {
183              SYSTEMTIME st;              SYSTEMTIME st;
184              struct tm * tm;              struct tm *tm;
185              time_t t = time (NULL);              time_t t = time (NULL);
186                time_t tmp = ks->expires;
187    
188                tm = localtime (&tmp);
189              memset (&st, 0, sizeof st);              memset (&st, 0, sizeof st);
190              st.wYear = atoi (tmpbuf);              st.wYear = tm->tm_year+1900;
191              st.wMonth = atoi (tmpbuf+5);              st.wMonth = tm->tm_mon;
192              st.wDay = atoi (tmpbuf+8);              st.wDay = tm->tm_mday;
193              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
194                                      GDT_VALID, &st);                                      GDT_VALID, &st);
195    
# Line 203  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 217  sigprops_dlg_proc (HWND dlg, UINT msg, W
217          case IDOK:          case IDOK:
218              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
219              break;              break;
220    
221            case IDCANCEL:
222                EndDialog (dlg, FALSE);
223                break;
224          }          }
225      }      }
226    
# Line 215  subclass_dlg_proc (HWND dlg, UINT msg, W Line 233  subclass_dlg_proc (HWND dlg, UINT msg, W
233  {  {
234      listview_ctrl_t lv;      listview_ctrl_t lv;
235      winpt_key_t key;      winpt_key_t key;
236        gpgme_key_sig_t ks;
237    
238      switch (msg) {      switch (msg) {
239      case WM_KEYUP:      case WM_KEYUP:
# Line 222  subclass_dlg_proc (HWND dlg, UINT msg, W Line 241  subclass_dlg_proc (HWND dlg, UINT msg, W
241          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
242          lv = key->callback.ctl;          lv = key->callback.ctl;
243          if (virt_key == VK_SPACE) {          if (virt_key == VK_SPACE) {
244              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
245                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
246                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
247                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
248                }
249          }          }
250          else if (virt_key == VK_DELETE)          else if (virt_key == VK_DELETE)
251              do_delsig (dlg, lv, key);              do_delsig (dlg, lv, key);
# Line 243  check_for_missing_keys (listview_ctrl_t Line 264  check_for_missing_keys (listview_ctrl_t
264            
265      n = listview_count_items( lv, 0 );      n = listview_count_items( lv, 0 );
266      for( i = 0; i < n; i++ ) {      for( i = 0; i < n; i++ ) {
267          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
268          if( !strncmp( id, "NOKEY", 5 ) )          if (!strncmp (id, "NOKEY", 5))
269              return 1;              return 1;
270      }      }
271            
# Line 256  check_for_missing_keys (listview_ctrl_t Line 277  check_for_missing_keys (listview_ctrl_t
277  static int  static int
278  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
279  {  {
     int i, n, rc;  
280      char id[128], keyid[18+1];      char id[128], keyid[18+1];
281        int i, n, cnt=0;
282    
283        i = msg_box (dlg, _("Really receive all missing keys?"),
284                     _("Key Manager"), MB_YESNO|MB_INFO);
285        if (i == IDNO)
286            return 0;
287            
288      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
289      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
290          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
291          if( !strncmp( id, "NOKEY", 5 ) ) {          if (!strncmp (id, "NOKEY", 5)) {
292              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );              listview_get_item_text (lv, i, SL_COL_KEYID,
293              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );                                      keyid, sizeof (keyid) -1);
294              if( rc )                            if (!hkp_recv_key (dlg, default_keyserver,
295                                   default_keyserver_port, keyid, 0, 0)) {
296                    keycache_update (0, keyid);
297                    cnt++;
298                }
299                else
300                  break;                  break;
301          }          }
302      }      }
303            return cnt;
     return rc;  
304  }  }
305    
306    
# Line 284  do_create_popup (HWND dlg) Line 314  do_create_popup (HWND dlg)
314      GetCursorPos (&p);      GetCursorPos (&p);
315      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
316      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
   
317      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
318      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
   
319      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
   
320      DestroyMenu (hm);      DestroyMenu (hm);
321      DestroyMenu (sm);      DestroyMenu (sm);
322  }  }
323    
324    
325    /* Fetch a single key and extract the keyid from the listview
326       entry at the pos @idx. */
327    static int
328    recv_single_key (HWND dlg, listview_ctrl_t lv, int idx)
329    {
330        char keyid[32];
331        int rc;
332    
333        listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1);      
334        rc = hkp_recv_key (dlg, default_keyserver,
335                           default_keyserver_port, keyid, 0, 0);
336                    
337        if (!rc)
338            keycache_update (0, keyid);
339        return rc;
340    }
341    
342    
343  /* Load the key property dialog with the selected key from @lv. */  /* Load the key property dialog with the selected key from @lv. */
344  static void  static void
345  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
# Line 305  do_load_keyprops (HWND dlg, listview_ctr Line 350  do_load_keyprops (HWND dlg, listview_ctr
350      char status[64] = {0}, creation[64] = {0};      char status[64] = {0}, creation[64] = {0};
351      int n = listview_get_curr_pos (lv);      int n = listview_get_curr_pos (lv);
352    
353      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1);
354      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1);
355      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1);
356      if (!strcmp (status, "NOKEY")) {      if (!strcmp (status, "NOKEY")) {
357          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),          int id = msg_box (dlg, _("Key not found in keyring, do you want to fetch it from the keyserver?"),
358                   _("Key Manager"), MB_INFO);                            _("Key Manager"), MB_QUEST_ASK);
359          return;          if (id == IDNO)
360                return;
361            if (recv_single_key (dlg, lv, n))              
362                return;
363      }      }
364            
365      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {
# Line 332  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 380  keysig_dlg_proc (HWND dlg, UINT msg, WPA
380  {  {
381      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
382      static struct winpt_key_s *k;      static struct winpt_key_s *k;
383      char inf[384], keyid[18+1];          gpgme_key_sig_t ks;
     int idx = 0, id, rc;  
384      HWND sl;      HWND sl;
385        char inf[384], *utf8_uid;
386        int idx = 0;    
387            
388      switch( msg ) {      switch (msg) {
389      case WM_INITDIALOG:      case WM_INITDIALOG:
390          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
391          if (!k)          if (!k)
392              BUG (0);              BUG (0);
393          if (k->uid)          if (k->uid) {
394              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);              utf8_uid = utf8_to_native (k->uid);
395                _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), utf8_uid);
396                safe_free (utf8_uid);
397            }
398          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
         #ifndef LANG_DE  
399          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
400          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
401          #endif  
402          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
403          if (!check_for_missing_keys (lv))          if (!check_for_missing_keys (lv))
404              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
405            EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), FALSE);
406          k->callback.ctl = lv;          k->callback.ctl = lv;
407          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
408          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
# Line 359  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 411  keysig_dlg_proc (HWND dlg, UINT msg, WPA
411          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
412          if (siglist_proc.old) {          if (siglist_proc.old) {
413              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
414                  msg_box (dlg, _("Could not set keylist window procedure."),                  msg_box (dlg, "Could not set keylist window procedure.",
415                           _("Key Manager"), MB_ERR);                           _("Key Manager"), MB_ERR);
416                  BUG (0);                  BUG (0);
417              }              }
# Line 369  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 421  keysig_dlg_proc (HWND dlg, UINT msg, WPA
421          return TRUE;          return TRUE;
422                    
423      case WM_DESTROY:      case WM_DESTROY:
424          if ( lv ) {          if (lv) {
425              siglist_delete( lv );              siglist_delete (lv);
426              lv = NULL;              lv = NULL;
427          }          }
428          return FALSE;          return FALSE;
429                    
430      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
431          if (LOWORD (wparam) == SC_CLOSE) {          if (LOWORD (wparam) == SC_CLOSE)
             if (k->update)  
                 keycache_update (0, k->keyid);  
432              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
         }  
433          return FALSE;          return FALSE;
434    
435      case WM_NOTIFY:      case WM_NOTIFY:
436          NMHDR *notify;          NMHDR *notify;
437                    
438          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
439          if (notify && notify->code == NM_DBLCLK          if (!notify)
440                return FALSE;
441            if (notify->code == NM_DBLCLK
442              && notify->idFrom == IDC_KEYSIG_LIST)              && notify->idFrom == IDC_KEYSIG_LIST)
443              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
444          if (notify && notify->code == NM_RCLICK &&          if (notify->code == NM_RCLICK &&
445              notify->idFrom == IDC_KEYSIG_LIST)              notify->idFrom == IDC_KEYSIG_LIST &&
446                is_sig (lv, -1))
447              do_create_popup (dlg);              do_create_popup (dlg);
448          if (notify && notify->code == LVN_ITEMCHANGED &&          if (notify->code == LVN_ITEMCHANGED &&
449              ((LPNMLISTVIEW)lparam)->uNewState) {              ((LPNMLISTVIEW)lparam)->uNewState) {
450              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
451              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);              listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1);
452              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
453                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
454                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS),
455                              is_sig (lv, -1)? TRUE : FALSE);
456            }
457            if (notify->code == LVN_COLUMNCLICK) {
458                NMLISTVIEW *nft = (LPNMLISTVIEW) lparam;
459                int sortby = 0;
460                switch (nft->iSubItem) {
461                //case 0:  sortby = KEY_SORT_USERID; break;
462                case 1: sortby = KEY_SORT_VALIDITY; break;
463                case 2: sortby = SIG_SORT_CLASS; break;
464                case 3: sortby = KEY_SORT_CREATED; break;
465                case 4: sortby = KEY_SORT_KEYID; break;
466                case 5: sortby = SIG_SORT_EXPIRE; break;
467                case 6: sortby = KEY_SORT_ALGO; break;
468                default: return TRUE;
469                }
470                siglist_sort (lv, sortby);
471          }          }
472          break;          break;
473                    
474      case WM_COMMAND:      case WM_COMMAND:
475          switch ( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
   
476          case ID_SIGCTX_KEYPROPS:          case ID_SIGCTX_KEYPROPS:
477              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
478              break;              break;
479    
480          case ID_SIGCTX_PROPS:          case ID_SIGCTX_PROPS:
481              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
482                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
483                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
484                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
485                }
486              break;              break;
487    
488          case IDC_KEYSIG_RECVKEY:          case IDC_KEYSIG_RECVKEY:
489              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
490              if (idx == -1) {              if (idx == -1)
491                  id = msg_box( dlg, _("Really receive all missing keys?"),                  recv_missing_keys (dlg, lv);
492                                  _("Key Manager"), MB_YESNO|MB_INFO );              else
493                  if (id == IDYES) {                  recv_single_key (dlg, lv, idx);
                     rc = recv_missing_keys (dlg, lv);  
                     if (!rc)  
                         keycache_set_reload (1);  
                     return TRUE;  
                 }  
                 return TRUE;  
             }  
             listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);  
             rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);  
             if (!rc)  
                 keycache_update (0, keyid);  
494              return TRUE;              return TRUE;
495    
496          case IDC_KEYSIG_SIGPROPS:          case IDC_KEYSIG_SIGPROPS:
497              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
498                    ks = ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
499                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
500                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
501                }
502              return TRUE;              return TRUE;
503                            
504          case IDOK:          case IDOK:
             if (k->update)  
                 keycache_update (0, k->keyid);  
505              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
506              return TRUE;              return TRUE;
507          }          }

Legend:
Removed from v.42  
changed lines
  Added in v.201

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26