[Winpt-commits] r306 - trunk/Src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 23 15:07:25 CET 2007
Author: twoaday
Date: 2007-03-23 15:07:24 +0100 (Fri, 23 Mar 2007)
New Revision: 306
Modified:
trunk/Src/ChangeLog
trunk/Src/wptCardDlg.cpp
trunk/Src/wptCardEdit.cpp
trunk/Src/wptKeyEditDlgs.cpp
Log:
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2007-03-23 11:32:28 UTC (rev 305)
+++ trunk/Src/ChangeLog 2007-03-23 14:07:24 UTC (rev 306)
@@ -1,3 +1,8 @@
+2007-03-23 Timo Schulz <twoaday at gmx.net>
+
+ * wptCardDlg.cpp (card_keygen_dlg_proc): Use dynamic
+ variables to avoid heap operations.
+
2007-03-21 Timo Schulz <twoaday at gmx.net>
* wptKeyManager.cpp (gpg_keylist_to_pattern): Return allocated
Modified: trunk/Src/wptCardDlg.cpp
===================================================================
--- trunk/Src/wptCardDlg.cpp 2007-03-23 11:32:28 UTC (rev 305)
+++ trunk/Src/wptCardDlg.cpp 2007-03-23 14:07:24 UTC (rev 306)
@@ -1,5 +1,5 @@
/* wptCardDlg.cpp - Smart Card support
- * Copyright (C) 2003-2006 Timo Schulz
+ * Copyright (C) 2003-2007 Timo Schulz
* Copyright (C) 2005 g10 Code GmbH
*
* This file is part of WinPT.
@@ -14,7 +14,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -115,18 +114,6 @@
}
-static GpgCardEdit*
-create_GpgCardEdit (void)
-{
- GpgCardEdit *ce;
-
- ce = new GpgCardEdit ();
- if (!ce)
- BUG (0);
- return ce;
-}
-
-
/* Check if there is a card in the reader and analyze the
returned information.
Return value: card context or NULL on error. */
@@ -134,24 +121,23 @@
gpg_card_load (void)
{
gpgme_error_t err;
- GpgCardEdit *ce;
+ GpgCardEdit ce;
gpg_card_t card = NULL;
struct card_cb_s cb = {0};
- ce = create_GpgCardEdit ();
memset (&cb, 0, sizeof (cb));
- ce->setCallback (card_callback, &cb);
- err = ce->getCardStatus (&card);
+ ce.setCallback (card_callback, &cb);
+ err = ce.getCardStatus (&card);
if (err) {
msg_box (NULL, gpgme_strerror (err), _("Card Manager"), MB_ERR);
- goto leave;
+ return card;
}
if (!card->aid ||
strncmp (card->aid, OPENPGP_APPID, strlen (OPENPGP_APPID))) {
msg_box (NULL, winpt_strerror (WPTERR_NOPGPCARD), "WinPT", MB_ERR);
gpg_card_release (card);
- card = NULL;
+ return NULL;
}
else {
struct winpt_key_s key;
@@ -164,8 +150,6 @@
}
}
-leave:
- delete ce;
return card;
}
@@ -301,7 +285,7 @@
{0}
};
gpgme_error_t err;
- GpgCardEdit *ce;
+ GpgCardEdit ce;
char buf[256], tmp[128];
int errc=0, use_arg2 = 0;
int i, id, n=0;
@@ -338,8 +322,7 @@
return 0;
}
- ce = create_GpgCardEdit ();
- ce->setAdminPIN (cb->apin);
+ ce.setAdminPIN (cb->apin);
for( i=0; idctl[i].id; i++ ) {
if( idctl[i].changed ) {
GetDlgItemText( dlg, idctl[i].id, buf, sizeof (buf)-1 );
@@ -366,7 +349,7 @@
}
else
use_arg2 = 0;
- err = ce->doCmd (idctl[i].cmd, buf, use_arg2? tmp : NULL);
+ err = ce.doCmd (idctl[i].cmd, buf, use_arg2? tmp : NULL);
if (err) {
log_box (_("Card Edit"), MB_ERR,
_("Could not modify card attribute: %s"),
@@ -386,7 +369,6 @@
SetDlgItemText( dlg, IDC_CEDIT_LANG2, "" );
SetDlgItemText( dlg, IDC_CEDIT_SEX2, "" );
}
- delete ce;
return errc;
}
@@ -563,7 +545,6 @@
card_keygen_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
gpgme_error_t err;
- GpgCardEdit *ce;
char name[128], email[128], comment[128];
char pass[128];
int card_flags = GPG_CARDFLAG_NONE;
@@ -653,7 +634,6 @@
free_pincb (&pincb);
return TRUE;
}
- ce = create_GpgCardEdit ();
expires = !IsDlgButtonChecked (dlg, IDC_CKEYGEN_NEVER);
if (expires) {
@@ -664,7 +644,6 @@
msg_box (dlg, _("The date you have chosen has already passed."),
_("Card Edit"), MB_ERR);
free_pincb (&pincb);
- delete ce;
return TRUE;
}
GetSystemTime (&ct);
@@ -676,21 +655,25 @@
card_flags |= GPG_CARDFLAG_REPLACE;
if (IsDlgButtonChecked (dlg, IDC_CKEYGEN_BACKUP))
card_flags |= GPG_CARDFLAG_BAKENC;
- ce->setKeygenPassphrase (pass);
- ce->setPIN (pincb.upin);
- ce->setAdminPIN (pincb.apin);
- SetCursor (LoadCursor (NULL, IDC_WAIT));
- err = ce->genKey (card_flags, name, email, n? comment: NULL,
- expires? valid : 0, NULL);
- SetCursor (LoadCursor (NULL, IDC_ARROW));
+ {
+ GpgCardEdit ce;
+
+ ce.setKeygenPassphrase (pass);
+ ce.setPIN (pincb.upin);
+ ce.setAdminPIN (pincb.apin);
+ SetCursor (LoadCursor (NULL, IDC_WAIT));
+ err = ce.genKey (card_flags, name, email, n? comment: NULL,
+ expires? valid : 0, NULL);
+ SetCursor (LoadCursor (NULL, IDC_ARROW));
+ }
+
if (gpgme_err_code (err) == GPG_ERR_CANCELED)
msg_box (dlg, _("Operation was canceled. It seems that there are "
"existing\nkeys on the cards. You need to mark the "
"'Overwrite' flag."), _("Card Edit"), MB_INFO);
- else
- if (err)
+ else if (err)
msg_box (dlg, "The operation does not succeed.\n"
"Please make sure you entered the right PIN's."
, _("Card Edit"), MB_ERR);
@@ -699,7 +682,6 @@
_("Card Edit"), MB_OK);
wipememory (pass, sizeof (pass));
free_pincb (&pincb);
- delete ce;
EndDialog (dlg, TRUE);
return TRUE;
@@ -746,7 +728,6 @@
{
static int hide = 1;
gpgme_error_t err;
- GpgCardEdit *ce;
char pold[128], pnew[128], pnew2[128];
int which = 0;
DWORD n;
@@ -802,14 +783,18 @@
return TRUE;
}
- ce = create_GpgCardEdit ();
- if (which == CARD_ADMIN_PIN)
- ce->setAdminPIN (pold);
- else
- ce->setPIN (pold);
- ce->setNewPIN (pnew);
- err = ce->changePIN (which == CARD_ADMIN_PIN? GPG_EDITCARD_CHAPIN :
- GPG_EDITCARD_CHUPIN);
+ {
+ GpgCardEdit ce;
+
+ if (which == CARD_ADMIN_PIN)
+ ce.setAdminPIN (pold);
+ else
+ ce.setPIN (pold);
+ ce.setNewPIN (pnew);
+ err = ce.changePIN (which == CARD_ADMIN_PIN?
+ GPG_EDITCARD_CHAPIN :
+ GPG_EDITCARD_CHUPIN);
+ }
if (err)
msg_box (dlg, gpgme_strerror (err), _("Card Edit"), MB_ERR);
else {
@@ -822,7 +807,6 @@
wipememory (pold, sizeof (pold));
wipememory (pnew, sizeof (pnew));
wipememory (pnew2, sizeof (pnew2));
- delete ce;
break;
case IDCANCEL:
Modified: trunk/Src/wptCardEdit.cpp
===================================================================
--- trunk/Src/wptCardEdit.cpp 2007-03-23 11:32:28 UTC (rev 305)
+++ trunk/Src/wptCardEdit.cpp 2007-03-23 14:07:24 UTC (rev 306)
@@ -1,5 +1,5 @@
-/* wptCardEdit.cpp - OpenPGP editing interface
- * Copyright (C) 2005, 2006 Timo Schulz
+/* wptCardEdit.cpp - OpenPGP card editing interface
+ * Copyright (C) 2005, 2006, 2007 Timo Schulz
*
* This file is part of WinPT.
*
@@ -12,12 +12,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinPT; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -32,6 +27,7 @@
#include "wptTypes.h"
#include "wptW32API.h"
+
/* Create a new Smartcard context. */
static gpgme_error_t
gpg_card_new (gpg_card_t *ret_card)
@@ -73,7 +69,6 @@
safe_free (card->url);
safe_free (card->card_type);
safe_free (card);
-
}
@@ -90,7 +85,6 @@
dat = get_locale_date (long_ts, timebuf, DIM (timebuf)-1);
if (!dat)
return strdup ("");
-
return strdup (dat);
}
@@ -334,7 +328,9 @@
if (n == IDCANCEL) {
s = "c\n";
ce->setResult (GPG_CARDRES_CANCEL);
- WriteFile ((HANDLE)fd, s, strlen (s), &n, NULL);
+ if (!WriteFile ((HANDLE)fd, s, strlen (s), &n, NULL))
+ log_debug ("list_handler: WriteFile() failed ec=%d\r\n",
+ (int)GetLastError ());
wait_card = 0;
}
}
Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp 2007-03-23 11:32:28 UTC (rev 305)
+++ trunk/Src/wptKeyEditDlgs.cpp 2007-03-23 14:07:24 UTC (rev 306)
@@ -1,5 +1,5 @@
/* wptKeyEditDlgs.cpp - GPG key edit dialogs
- * Copyright (C) 2002-2006 Timo Schulz
+ * Copyright (C) 2002-2007 Timo Schulz
*
* This file is part of WinPT.
*
@@ -12,10 +12,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinPT; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -138,7 +134,7 @@
struct keygen_cb_s {
int bits;
int algo;
- DWORD expire;
+ DWORD expire; /* date of expiration or '0' for infinite valid. */
char *fpr;
char *name;
char *comment;
@@ -266,14 +262,13 @@
do_find_userid (const char *keyid, const char *email,
const char *name, gpg_uid_info_t *r_inf)
{
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
gpgme_error_t err;
gpg_uid_info_t inf, ui;
int pos = -1;
- ke = create_GpgKeyEdit (keyid);
- err = ke->getUseridInfo (&inf);
- delete ke;
+ ke.setKeyID (keyid);
+ err = ke.getUseridInfo (&inf);
if (err) {
log_box (_("user ID"), MB_ERR,
_("Could not get key information for: \"%s\":\n%s"),
@@ -337,7 +332,6 @@
keyedit_addphoto_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
static keyedit_cb_t cb;
- GpgKeyEdit *ke;
gpgme_error_t err;
const char *s;
char file[128];
@@ -384,13 +378,17 @@
if (id == IDNO)
return TRUE;
}
- ke = create_GpgKeyEdit (cb->keyid);
- if (cb->pass)
- ke->setPassphrase (cb->pass);
- else
- ke->setNoPassphrase (true);
- err = ke->addPhotoid (file);
- delete ke;
+
+ {
+ GpgKeyEdit ke;
+
+ ke.setKeyID (cb->keyid);
+ if (cb->pass)
+ ke.setPassphrase (cb->pass);
+ else
+ ke.setNoPassphrase (true);
+ err = ke.addPhotoid (file);
+ }
if (err) {
msg_box (dlg, gpgme_strerror (err), _("Add Photo"), MB_ERR);
return FALSE;
@@ -419,7 +417,6 @@
{
static keyedit_cb_t cb;
gpgme_error_t err;
- GpgKeyEdit *ke;
char *uid=NULL;
switch (msg) {
@@ -446,13 +443,17 @@
return FALSE;
}
- ke = create_GpgKeyEdit (cb->keyid);
- if (cb->pass)
- ke->setPassphrase (cb->pass);
- else
- ke->setNoPassphrase (true);
- err = ke->addDesignatedRevoker (uid);
- delete ke;
+ {
+ GpgKeyEdit ke;
+
+ ke.setKeyID (cb->keyid);
+ if (cb->pass)
+ ke.setPassphrase (cb->pass);
+ else
+ ke.setNoPassphrase (true);
+ err = ke.addDesignatedRevoker (uid);
+ }
+
safe_free (uid);
if (err) {
msg_box (dlg, gpgme_strerror (err), _("Add Revoker"), MB_ERR);
@@ -483,7 +484,6 @@
static keyedit_cb_t ctx;
keygen_cb_t keygen;
gpgme_error_t err;
- GpgKeyEdit *ke;
char *utf8_name = NULL;
char *utf8_comment = NULL;
char email[128];
@@ -534,12 +534,16 @@
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment);
- ke = create_GpgKeyEdit (ctx->keyid);
- if (ctx->is_protected)
- ke->setPassphrase (ctx->pass);
- else
- ke->setNoPassphrase (true);
- err = ke->addUserid (utf8_name, utf8_comment, email);
+ {
+ GpgKeyEdit ke;
+
+ ke.setKeyID (ctx->keyid);
+ if (ctx->is_protected)
+ ke.setPassphrase (ctx->pass);
+ else
+ ke.setNoPassphrase (true);
+ err = ke.addUserid (utf8_name, utf8_comment, email);
+ }
if (err)
msg_box (dlg, gpgme_strerror (err), _("UserID"), MB_ERR);
else {
@@ -550,7 +554,6 @@
keygen->comment = utf8_comment;
keygen->email = m_strdup (email);
}
- delete ke;
EndDialog (dlg, TRUE);
return TRUE;
@@ -617,7 +620,6 @@
{
static keyedit_cb_t ctx;
keygen_cb_t keygen;
- GpgKeyEdit *ke;
gpgme_error_t err;
SYSTEMTIME st;
HWND hwnd;
@@ -702,15 +704,18 @@
if (valid > 0)
keygen->expire = time (NULL) + valid*24*60*60;
- ke = create_GpgKeyEdit (ctx->keyid);
- ke->setCallback (keygen_cb, NULL);
- if (ctx->is_protected)
- ke->setPassphrase (ctx->pass);
- else
- ke->setNoPassphrase (true);
- keygen_cb_dlg_create ();
-
- err = ke->addSubkey ((gpgme_pubkey_algo_t)index, size, valid);
+ {
+ GpgKeyEdit ke;
+
+ ke.setKeyID (ctx->keyid);
+ ke.setCallback (keygen_cb, NULL);
+ if (ctx->is_protected)
+ ke.setPassphrase (ctx->pass);
+ else
+ ke.setNoPassphrase (true);
+ keygen_cb_dlg_create ();
+ err = ke.addSubkey ((gpgme_pubkey_algo_t)index, size, valid);
+ }
keygen->fpr = get_subkey_keyid (ctx->keyid);
keygen_cb_dlg_destroy (1);
if (err)
@@ -720,7 +725,6 @@
_("GnuPG Status"), MB_OK);
ctx->finished = 1;
}
- delete ke;
EndDialog (dlg, TRUE);
return TRUE;
@@ -848,7 +852,7 @@
BOOL
keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg)
{
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
gpgme_error_t err;
struct URL_ctx_s *url;
char *pass = NULL;
@@ -865,12 +869,12 @@
return FALSE;
}
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->setPreferredKeyserver (-1, url->url);
+ ke.setNoPassphrase (true);
+ err = ke.setPreferredKeyserver (-1, url->url);
if (!err)
msg_box (dlg, _("Preferred keyserver successfully set."),
_("Key Edit"), MB_OK);
@@ -878,7 +882,6 @@
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);
sfree_if_alloc (pass);
- delete ke;
delete url;
return err == 0? 0 : WPTERR_GENERAL;
}
@@ -1002,7 +1005,7 @@
keyedit_change_passwd (winpt_key_t k, HWND dlg)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
char *old_pass = NULL;
char *new_pass = NULL;
int cancel = 0;
@@ -1044,18 +1047,18 @@
}
}
- ke = create_GpgKeyEdit (k->keyid);
- ke->setPassphrase (k->is_protected? old_pass : NULL);
+ ke.setKeyID (k->keyid);
+ ke.setPassphrase (k->is_protected? old_pass : NULL);
if (!k->is_protected)
- ke->setNoPassphrase (true);
- err = ke->changePassphrase (new_pass, 1);
+ ke.setNoPassphrase (true);
+ err = ke.changePassphrase (new_pass, 1);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Change Password"), MB_ERR);
else
msg_box (dlg, _("Passphrase successfully changed."), _("GnuPG status"), MB_OK);
sfree_if_alloc (old_pass);
sfree_if_alloc (new_pass);
- delete ke;
+
return TRUE;
}
@@ -1284,7 +1287,7 @@
{
gpgme_error_t err;
gpgme_subkey_t subk;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
int pos, id;
const char *warn;
char tmp[64];
@@ -1325,8 +1328,8 @@
if (id == IDNO)
return FALSE;
- ke = create_GpgKeyEdit (k->keyid);
- err = ke->delKey (pos);
+ ke.setKeyID (k->keyid);
+ err = ke.delKey (pos);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Delete Subkey"), MB_ERR);
else {
@@ -1334,7 +1337,6 @@
k->update = 1;
status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status"));
}
- delete ke;
return err? FALSE : TRUE;
}
@@ -1345,7 +1347,7 @@
do_editkey_expire (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
date_s udd = {0};
char buf[256], * pass = NULL;
time_t exp;
@@ -1391,12 +1393,13 @@
return FALSE;
}
exp = w32_mktime (&udd.st);
- ke = create_GpgKeyEdit (k->keyid);
+
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->setKeyExpireDate (pos, exp, false);
+ ke.setNoPassphrase (true);
+ err = ke.setKeyExpireDate (pos, exp, false);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Expire Subkey"), MB_ERR);
else {
@@ -1407,7 +1410,6 @@
_("GnuPG status"), MB_OK);
}
sfree_if_alloc (pass);
- delete ke;
return TRUE;
}
@@ -1419,7 +1421,7 @@
do_editkey_revoke (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
char buf[256];
char *pass = NULL;
int j, cancel = 0;
@@ -1453,12 +1455,12 @@
return FALSE;
}
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->revokeSubkey (j, 0, NULL);
+ ke.setNoPassphrase (true);
+ err = ke.revokeSubkey (j, 0, NULL);
if (err)
msg_box( dlg, gpgme_strerror (err), _("Revoke Subkey"), MB_ERR);
else {
@@ -1467,7 +1469,6 @@
msg_box( dlg, _("Subkey successfully revoked."), _("GnuPG Status"), MB_OK );
}
sfree_if_alloc (pass);
- delete ke;
return TRUE;
}
@@ -1478,7 +1479,7 @@
do_editkey_revuid (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
char buf[128], email[128];
char inf[512];
char *pass = NULL;
@@ -1523,12 +1524,12 @@
if (id == -1)
BUG (NULL);
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->revokeUserid (id);
+ ke.setNoPassphrase (true);
+ err = ke.revokeUserid (id);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Revoke User ID"), MB_ERR);
else {
@@ -1537,7 +1538,6 @@
status_box (dlg, _("User ID successfully revoked"), _("GnuPG Status"));
}
sfree_if_alloc (pass);
- delete ke;
return err? FALSE : TRUE;
}
@@ -1546,7 +1546,7 @@
do_editkey_setpref (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
gpg_uid_info_t uidinf = NULL;
char buf[256], *pass = NULL, *prefs = NULL;
int pos, id, cancel=0, flags=0;
@@ -1574,12 +1574,12 @@
return FALSE;
}
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->setUseridPreferences (id, prefs);
+ ke.setNoPassphrase (true);
+ err = ke.setUseridPreferences (id, prefs);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Set user ID preferences"), MB_ERR);
else {
@@ -1589,7 +1589,6 @@
sfree_if_alloc (pass);
free_if_alloc (prefs);
- delete ke;
return err? FALSE: TRUE;
}
@@ -1598,7 +1597,7 @@
do_editkey_primary (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
int j, id, cancel=0;
char valid[32];
char buf[256], *pass = NULL;
@@ -1622,12 +1621,12 @@
return FALSE;
}
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (k->is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- err = ke->setPrimaryUserid (id);
+ ke.setNoPassphrase (true);
+ err = ke.setPrimaryUserid (id);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Primary"), MB_ERR);
else {
@@ -1636,7 +1635,6 @@
}
sfree_if_alloc (pass);
- delete ke;
return err? FALSE : TRUE;
}
@@ -1789,7 +1787,7 @@
do_editkey_deluid (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
char email[128], name[128];
char inf[384];
int pos, id = 0;
@@ -1823,8 +1821,8 @@
if (id == -1)
BUG (NULL);
- ke = create_GpgKeyEdit (k->keyid);
- err = ke->delUserid (id);
+ ke.setKeyID (k->keyid);
+ err = ke.delUserid (id);
if (err)
msg_box (dlg, gpgme_strerror (err), _("Delete User ID"), MB_ERR);
else {
@@ -1832,7 +1830,6 @@
k->update = 1;
status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status"));
}
- delete ke;
return err? FALSE : TRUE;
}
@@ -1914,17 +1911,16 @@
do_editkey_minimize (winpt_key_t k, HWND dlg)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
- ke = create_GpgKeyEdit (k->keyid);
- err = ke->minimizeKey ();
+ ke.setKeyID (k->keyid);
+ err = ke.minimizeKey ();
if (err)
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);
else {
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK);
k->update = 1;
}
- delete ke;
}
@@ -1932,17 +1928,16 @@
do_editkey_clean (winpt_key_t k, HWND dlg)
{
gpgme_error_t err;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
- ke = create_GpgKeyEdit (k->keyid);
- err = ke->cleanKey ();
+ ke.setKeyID (k->keyid);
+ err = ke.cleanKey ();
if (err)
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);
else {
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK);
k->update = 1;
}
- delete ke;
}
@@ -1965,7 +1960,7 @@
{
gpgme_error_t err;
winpt_key_s signer;
- GpgKeyEdit *ke;
+ GpgKeyEdit ke;
char *pass = NULL;
char *defkey;
char email[64], name[128], valid[32];
@@ -2002,13 +1997,13 @@
if (cancel)
return FALSE;
}
- ke = create_GpgKeyEdit (k->keyid);
+ ke.setKeyID (k->keyid);
if (signer.is_protected)
- ke->setPassphrase (pass);
+ ke.setPassphrase (pass);
else
- ke->setNoPassphrase (true);
- ke->setLocalUser (signer.ctx);
- err = ke->signUserid (uid_index,
+ ke.setNoPassphrase (true);
+ ke.setLocalUser (signer.ctx);
+ err = ke.signUserid (uid_index,
mode == CMD_SIGN? GPG_EDITKEY_SIGN : GPG_EDITKEY_LSIGN,
0, NULL);
if (!err) {
@@ -2017,7 +2012,7 @@
}
else
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);
- delete ke;
+
sfree_if_alloc (pass);
return !err? TRUE : FALSE;
}
More information about the Winpt-commits
mailing list