From 81f36890cb3e5afb432fe7894687345099dd6823 Mon Sep 17 00:00:00 2001 From: ubbo Date: Fri, 14 Oct 2011 19:40:51 +0000 Subject: return false in sign method if user canceld password input to prevent text-loss, remove unused method git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@547 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- context.cpp | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'context.cpp') diff --git a/context.cpp b/context.cpp index 7ba5fb9..812c529 100644 --- a/context.cpp +++ b/context.cpp @@ -544,33 +544,6 @@ gpgme_signature_t Context::verify(QByteArray inBuffer) { */ //} -void Context::sign(const QByteArray &inBuffer, QByteArray *outBuffer) { - - gpgme_error_t err; - gpgme_data_t in=NULL, out=NULL; - gpgme_sign_result_t result; - -/* - `GPGME_SIG_MODE_NORMAL' - A normal signature is made, the output includes the plaintext - and the signature. - - `GPGME_SIG_MODE_DETACH' - A detached signature is made. - - `GPGME_SIG_MODE_CLEAR' - A clear text signature is made. The ASCII armor and text - mode settings of the context are ignored. -*/ - - //err = gpgme_op_sign (mCtx, in, out, GPGME_SIG_MODE_NORMAL); - err = gpgme_op_sign (mCtx, in, out, GPGME_SIG_MODE_CLEAR); - checkErr(err); - result = gpgme_op_sign_result (mCtx); - - err = readToBuffer(out, outBuffer); -} - bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer ) { gpgme_error_t err; @@ -605,10 +578,34 @@ bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray err = gpgme_data_new (&out); checkErr(err); + /* + `GPGME_SIG_MODE_NORMAL' + A normal signature is made, the output includes the plaintext + and the signature. + + `GPGME_SIG_MODE_DETACH' + A detached signature is made. + + `GPGME_SIG_MODE_CLEAR' + A clear text signature is made. The ASCII armor and text + mode settings of the context are ignored. + */ + err = gpgme_op_sign (mCtx, in, out, GPGME_SIG_MODE_CLEAR); checkErr (err); + + if (err == GPG_ERR_CANCELED) { + return false; + } + + if (err != GPG_ERR_NO_ERROR) { + QMessageBox::critical(0, tr("Error signing:"), gpgme_strerror(err)); + return false; + } + result = gpgme_op_sign_result (mCtx); err = readToBuffer(out, outBuffer); + checkErr (err); gpgme_data_release(in); gpgme_data_release(out); -- cgit