/[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 13 by twoaday, Mon Apr 25 07:15:30 2005 UTC revision 28 by twoaday, Thu Oct 20 12:35:59 2005 UTC
# Line 35  Line 35 
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    
40  static subclass_s siglist_proc;  static subclass_s siglist_proc;
41    
# Line 58  do_delsig (HWND dlg, listview_ctrl_t lv, Line 59  do_delsig (HWND dlg, listview_ctrl_t lv,
59  {  {
60      int pos, npos, id;      int pos, npos, id;
61      int signo=0, uidno=0;      int signo=0, uidno=0;
62      gpgme_ctx_t ctx;      GpgKeyEdit *ke;
63      gpgme_editkey_t ek;      gpgme_error_t err;
     gpgme_error_t rc;  
64    
65      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
66      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
67          return -1;          return -1;
68      while (pos > 0 && is_sig (lv, pos))      while (pos > 0 && is_sig (lv, pos)) {
     {  
69          signo++;          signo++;
70          pos--;          pos--;
71      }      }
72      pos = npos;      pos = npos;
73      while (npos > 0)      while (npos > 0) {
     {  
74          if (!is_sig (lv, npos))          if (!is_sig (lv, npos))
75              uidno++;              uidno++;
76          npos--;          npos--;
77      }      }
78      uidno++;      uidno++;
79      id = log_box(_("Key Manager"), MB_YESNO,  
80        /* XXX: do not allow to delete the self signature */
81        id = log_box (_("Key Manager"), MB_YESNO,
82                    _("Are you really sure you want to delete this signature from\n"                    _("Are you really sure you want to delete this signature from\n"
83                      "  \"%s\""), key->uid);                      "  \"%s\""), key->uid);
84      if (id == IDNO)      if (id == IDNO)
85          return 0;          return 0;
86      rc = gpgme_new (&ctx);  
87      if (rc)      ke = new GpgKeyEdit (key->keyid);
88          BUG (0);      if (!ke)
89      rc = gpgme_editkey_new (&ek);          BUG (NULL);    
90      if (rc)      err = ke->delUseridSignature (uidno, signo);
91          BUG (0);      if (err)
92      gpgme_editkey_delsig_set (ek, uidno, signo);          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
     gpgme_set_edit_ctx (ctx, ek, GPGME_EDITKEY_DELSIG);  
     rc = gpgme_op_editkey (ctx, key->keyid);  
     if (rc)  
         msg_box (dlg, gpgme_strerror (rc), _("Key Manager"), MB_ERR);  
93      else      else
94          listview_del_item (lv, pos);          listview_del_item (lv, pos);
95      gpgme_release (ctx);      delete ke;
96      gpgme_editkey_release (ek);      key->update = 1; /*update*/
97      return 0;      return 0;
98  }  }
99    
# Line 116  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 112  sigprops_dlg_proc (HWND dlg, UINT msg, W
112          const char * alg;          const char * alg;
113          int _class;          int _class;
114      } ctx;      } ctx;
115      const char * fmt_templ = "%s %s signature";      const char *fmt_templ = "%s %s signature";
116    
117      switch (msg)      switch (msg) {
     {  
118      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
119          if (LOWORD (wparam) == SC_CLOSE)          if (LOWORD (wparam) == SC_CLOSE)
120              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
# Line 189  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 184  sigprops_dlg_proc (HWND dlg, UINT msg, W
184          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
185          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
186          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
187          center_window (dlg);          center_window (dlg, NULL);
188          return TRUE;          return TRUE;
189    
190      case WM_COMMAND:      case WM_COMMAND:
# Line 210  subclass_dlg_proc (HWND dlg, UINT msg, W Line 205  subclass_dlg_proc (HWND dlg, UINT msg, W
205      listview_ctrl_t lv;      listview_ctrl_t lv;
206      winpt_key_t key;      winpt_key_t key;
207    
208      switch (msg)      switch (msg) {
     {  
209      case WM_KEYUP:      case WM_KEYUP:
210          int virt_key = (int)wparam;          int virt_key = (int)wparam;
211          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
212          lv = key->callback.ctl;          lv = key->callback.ctl;
213          if (virt_key == VK_SPACE)          if (virt_key == VK_SPACE) {
         {  
214              if (is_sig (lv, -1))              if (is_sig (lv, -1))
215                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
216                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)lv);
# Line 238  check_for_missing_keys (listview_ctrl_t Line 231  check_for_missing_keys (listview_ctrl_t
231            
232      n = listview_count_items( lv, 0 );      n = listview_count_items( lv, 0 );
233      for( i = 0; i < n; i++ ) {      for( i = 0; i < n; i++ ) {
234          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );
235          if( !strncmp( id, "NOKEY", 5 ) )          if( !strncmp( id, "NOKEY", 5 ) )
236              return 1;              return 1;
237      }      }
# Line 278  do_create_popup (HWND dlg) Line 271  do_create_popup (HWND dlg)
271      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
272      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
273    
274        set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
275        set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
276    
277      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
278    
279      DestroyMenu (hm);      DestroyMenu (hm);
# Line 314  do_load_keyprops (HWND dlg, listview_ctr Line 310  do_load_keyprops (HWND dlg, listview_ctr
310                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
311  }  }
312    
313      
314  BOOL CALLBACK  BOOL CALLBACK
315  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
316  {  {
317      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
318      struct winpt_key_s *k;      static struct winpt_key_s *k;
319      char inf[384], keyid[18+1];          char inf[384], keyid[18+1];    
320      int idx = 0, id, rc;      int idx = 0, id, rc;
321      HWND sl;      HWND sl;
# Line 329  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 325  keysig_dlg_proc (HWND dlg, UINT msg, WPA
325          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
326          if (!k)          if (!k)
327              BUG (0);              BUG (0);
328          if( k->uid )          if (k->uid)
329              _snprintf( inf, sizeof inf - 1, _("Signature List for \"%s\""), k->uid );              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
330          SetWindowText( dlg, inf );          SetWindowText (dlg, inf);
331          #ifndef LANG_DE          #ifndef LANG_DE
332          SetDlgItemText( dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key") );          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
333          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
334          #endif          #endif
335          lv = siglist_load( GetDlgItem( dlg, IDC_KEYSIG_LIST ), k->keyid );          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
336          if( !check_for_missing_keys( lv ) )          if (!check_for_missing_keys (lv))
337              EnableWindow( GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE );              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);
338          k->callback.ctl = lv;          k->callback.ctl = lv;
339          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
340          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
341          siglist_proc.opaque = k;          siglist_proc.opaque = k;
342          siglist_proc.current = (WNDPROC)subclass_dlg_proc;          siglist_proc.current = (WNDPROC)subclass_dlg_proc;
343          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
344          if (siglist_proc.old)          if (siglist_proc.old) {
345          {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
             if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  
             {  
346                  msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR);                  msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR);
347                  BUG (0);                  BUG (0);
348              }              }
349          }          }
350          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
351          center_window (dlg);          center_window (dlg, NULL);
352          return TRUE;          return TRUE;
353                    
354      case WM_DESTROY:      case WM_DESTROY:
# Line 365  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 359  keysig_dlg_proc (HWND dlg, UINT msg, WPA
359          return FALSE;          return FALSE;
360                    
361      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
362          if( LOWORD ( wparam ) == SC_CLOSE )          if (LOWORD (wparam) == SC_CLOSE) {
363              EndDialog( dlg, TRUE );              if (k->update)
364                    keycache_update (0, k->keyid);
365                EndDialog (dlg, TRUE);
366            }
367          return FALSE;          return FALSE;
368    
369      case WM_NOTIFY:      case WM_NOTIFY:
# Line 395  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 392  keysig_dlg_proc (HWND dlg, UINT msg, WPA
392              break;              break;
393    
394          case IDC_KEYSIG_RECVKEY:          case IDC_KEYSIG_RECVKEY:
395              idx = listview_get_curr_pos( lv );              idx = listview_get_curr_pos (lv);
396              if( idx == -1 ) {              if (idx == -1) {
397                  id = msg_box( dlg, _("Really receive all missing keys?"),                  id = msg_box( dlg, _("Really receive all missing keys?"),
398                                  _("Key Manager"), MB_YESNO|MB_INFO );                                  _("Key Manager"), MB_YESNO|MB_INFO );
399                  if( id == IDYES ) {                  if (id == IDYES) {
400                      rc = recv_missing_keys( dlg, lv );                      rc = recv_missing_keys (dlg, lv);
401                      if( !rc )                      if( !rc )
402                          keycache_set_reload( 1 );                          keycache_set_reload (1);
403                      return TRUE;                      return TRUE;
404                  }                  }
405                  return FALSE;                  return TRUE;
406              }              }
407              listview_get_item_text (lv, idx, 4, keyid, sizeof keyid - 1);              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
408                if (strcmp (inf, "NOKEY"))
409                    return FALSE;
410                listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);
411              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);
412              if (!rc)              if (!rc)
413                  keycache_set_reload (1);                  keycache_set_reload (1);
# Line 420  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 420  keysig_dlg_proc (HWND dlg, UINT msg, WPA
420              return TRUE;              return TRUE;
421                            
422          case IDOK:          case IDOK:
423                if (k->update)
424                    keycache_update (0, k->keyid);
425              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
426              return TRUE;              return TRUE;
427          }          }

Legend:
Removed from v.13  
changed lines
  Added in v.28

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26