diff options
-rw-r--r-- | context.cpp | 12 | ||||
-rw-r--r-- | context.h | 4 | ||||
-rw-r--r-- | gpgwin.cpp | 9 |
3 files changed, 18 insertions, 7 deletions
diff --git a/context.cpp b/context.cpp index 52593bf..f54417d 100644 --- a/context.cpp +++ b/context.cpp @@ -447,20 +447,22 @@ void Context::clearPasswordCache() } // error-handling -void Context::checkErr(gpgme_error_t err, QString comment) const +int Context::checkErr(gpgme_error_t err, QString comment) const { //if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { if (err != GPG_ERR_NO_ERROR) { qDebug() << "[Error " << comment << "] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); } + return err; } -void Context::checkErr(gpgme_error_t err) const +int Context::checkErr(gpgme_error_t err) const { //if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { if (err != GPG_ERR_NO_ERROR) { qDebug() << "[Error] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); } + return err; } @@ -508,7 +510,11 @@ int Context::verify(QByteArray inBuffer) { checkErr(err); err = gpgme_op_verify (mCtx, in, NULL, in); - checkErr(err); + error = checkErr(err); + + if (error != 0) { + return 1; + } result = gpgme_op_verify_result (mCtx); @@ -86,8 +86,8 @@ private: QByteArray mPasswordCache; QSettings settings; bool debug; - void checkErr(gpgme_error_t err) const; - void checkErr(gpgme_error_t err, QString comment) const; + int checkErr(gpgme_error_t err) const; + int checkErr(gpgme_error_t err, QString comment) const; static gpgme_error_t passphraseCb(void *hook, const char *uid_hint, const char *passphrase_info, @@ -690,9 +690,14 @@ void GpgWin::sign() QStringList *uidList = mKeyList->getChecked(); QByteArray *tmp = new QByteArray(); - if (mCtx->sign(uidList, edit->curTextPage()->toPlainText().toUtf8(), tmp)) { + if (mCtx->sign(uidList, edit->curTextPage()->toPlainText().toUtf8(), tmp)) { QString *tmp2 = new QString(*tmp); - edit->curTextPage()->setPlainText(*tmp2); + // beginEditBlock and endEditBlock() let operation look like single undo/redo operation + QTextCursor cursor(edit->curTextPage()->document()); + cursor.beginEditBlock(); + edit->curTextPage()->selectAll(); + edit->curTextPage()->insertPlainText(*tmp2); + cursor.endEditBlock(); } } |