/[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 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC revision 32 by twoaday, Mon Oct 24 08:03:48 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 53  is_sig (listview_ctrl_t lv, int pos) Line 54  is_sig (listview_ctrl_t lv, int pos)
54  }  }
55    
56    
57    /* Delete the selected signature from list view @lv. The
58       key is given in @key. */
59  static int  static int
60  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
61  {  {
62      int pos, npos, id;      int pos, npos, id;
63      int signo=0, uidno=0;      int signo=0, uidno=0;
64      gpgme_ctx_t ctx;      GpgKeyEdit *ke;
65      gpgme_editkey_t ek;      gpgme_error_t err;
     gpgme_error_t rc;  
66    
67      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
68      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
# Line 78  do_delsig (HWND dlg, listview_ctrl_t lv, Line 80  do_delsig (HWND dlg, listview_ctrl_t lv,
80      uidno++;      uidno++;
81    
82      /* XXX: do not allow to delete the self signature */      /* XXX: do not allow to delete the self signature */
83      id = log_box(_("Key Manager"), MB_YESNO,      id = log_box (_("Key Manager"), MB_YESNO,
84                    _("Are you really sure you want to delete this signature from\n"                    _("Are you really sure you want to delete this signature from\n"
85                      "  \"%s\""), key->uid);                      "  \"%s\""), key->uid);
86      if (id == IDNO)      if (id == IDNO)
87          return 0;          return 0;
88      rc = gpgme_new (&ctx);  
89      if (rc)      ke = new GpgKeyEdit (key->keyid);
90          BUG (0);      if (!ke)
91      rc = gpgme_editkey_new (&ek);          BUG (NULL);    
92      if (rc)      err = ke->delUseridSignature (uidno, signo);
93          BUG (0);      if (err)
94      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);  
95      else      else
96          listview_del_item (lv, pos);          listview_del_item (lv, pos);
97      gpgme_release (ctx);      delete ke;
     gpgme_editkey_release (ek);  
98      key->update = 1; /*update*/      key->update = 1; /*update*/
99      return 0;      return err? -1 : 0;
100  }  }
101    
102    
103    /* Dialog box procedure to display the signature properties. */
104  static BOOL CALLBACK  static BOOL CALLBACK
105  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
106  {  {
# Line 117  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 115  sigprops_dlg_proc (HWND dlg, UINT msg, W
115          const char * alg;          const char * alg;
116          int _class;          int _class;
117      } ctx;      } ctx;
118      const char * fmt_templ = "%s %s signature";      const char *fmt_templ = _("%s %s signature");
119    
120      switch (msg) {      switch (msg) {
121      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
# Line 146  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 144  sigprops_dlg_proc (HWND dlg, UINT msg, W
144              ctx.alg = "RSA";              ctx.alg = "RSA";
145          else          else
146              ctx.alg = "ELG";              ctx.alg = "ELG";
147          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
148                     ctx.exportable? "Exportable" : "Non-exportable", ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);
149          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
150          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);
151          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
# Line 188  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 186  sigprops_dlg_proc (HWND dlg, UINT msg, W
186          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
187          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
188          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
189            SetWindowText (dlg, _("Signature Properties"));
190          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
191          center_window (dlg);          center_window (dlg, NULL);
192          return TRUE;          return TRUE;
193    
194      case WM_COMMAND:      case WM_COMMAND:
# Line 228  subclass_dlg_proc (HWND dlg, UINT msg, W Line 227  subclass_dlg_proc (HWND dlg, UINT msg, W
227  }  }
228    
229    
230    /* Return 1 if the list view @lv contains non-available keys. */
231  static int  static int
232  check_for_missing_keys (listview_ctrl_t lv)  check_for_missing_keys (listview_ctrl_t lv)
233  {  {
# Line 242  check_for_missing_keys (listview_ctrl_t Line 242  check_for_missing_keys (listview_ctrl_t
242      }      }
243            
244      return 0;      return 0;
245  } /* check_for_missing_keys */  }
246    
247    
248    /* Receive all missing keys marked in the list @lv. */
249  static int  static int
250  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
251  {  {
# Line 263  recv_missing_keys (HWND dlg, listview_ct Line 264  recv_missing_keys (HWND dlg, listview_ct
264      }      }
265            
266      return rc;      return rc;
267  } /* recv_missing_keys */  }
268    
269    
270    /* Create a mini popup with available choices. */
271  static void  static void
272  do_create_popup (HWND dlg)  do_create_popup (HWND dlg)
273  {  {
# Line 276  do_create_popup (HWND dlg) Line 278  do_create_popup (HWND dlg)
278      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
279      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
280    
281        set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
282        set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
283    
284      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
285    
286      DestroyMenu (hm);      DestroyMenu (hm);
# Line 283  do_create_popup (HWND dlg) Line 288  do_create_popup (HWND dlg)
288  }  }
289    
290    
291    /* Load the key property dialog with the selected key from @lv. */
292  static void  static void
293  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
294  {  {
# Line 312  do_load_keyprops (HWND dlg, listview_ctr Line 318  do_load_keyprops (HWND dlg, listview_ctr
318                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
319  }  }
320    
321      
322    /* Dialog box procedure to list signatures. */
323  BOOL CALLBACK  BOOL CALLBACK
324  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
325  {  {
# Line 345  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 352  keysig_dlg_proc (HWND dlg, UINT msg, WPA
352          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
353          if (siglist_proc.old) {          if (siglist_proc.old) {
354              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
355                  msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR);                  msg_box (dlg, _("Could not set keylist window procedure."),
356                             _("Key Manager"), MB_ERR);
357                  BUG (0);                  BUG (0);
358              }              }
359          }          }
360          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
361          center_window (dlg);          center_window (dlg, NULL);
362          return TRUE;          return TRUE;
363                    
364      case WM_DESTROY:      case WM_DESTROY:
# Line 404  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 412  keysig_dlg_proc (HWND dlg, UINT msg, WPA
412                          keycache_set_reload (1);                          keycache_set_reload (1);
413                      return TRUE;                      return TRUE;
414                  }                  }
415                  return FALSE;                  return TRUE;
416              }              }
417              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
418              if (strcmp (inf, "NOKEY"))              if (strcmp (inf, "NOKEY"))
# Line 430  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 438  keysig_dlg_proc (HWND dlg, UINT msg, WPA
438          break;          break;
439      }      }
440      return FALSE;      return FALSE;
441  } /* keysig_dlg_proc */  }

Legend:
Removed from v.22  
changed lines
  Added in v.32

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26