aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-07-12 22:28:23 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-07-12 22:28:23 +0000
commit02062e44674ba88ea5ab62c806abb879d520ee43 (patch)
treeb43cf5fdfe7a2c1da4bcf652467966c9db64805e
parentupdated TODO (diff)
downloadgpg4usb-02062e44674ba88ea5ab62c806abb879d520ee43.tar.gz
gpg4usb-02062e44674ba88ea5ab62c806abb879d520ee43.zip
make sign undoable,change return value checkErr to int
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@495 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--context.cpp12
-rw-r--r--context.h4
-rw-r--r--gpgwin.cpp9
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);
diff --git a/context.h b/context.h
index 28abc24..df32ace 100644
--- a/context.h
+++ b/context.h
@@ -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,
diff --git a/gpgwin.cpp b/gpgwin.cpp
index 5c66324..0028c38 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -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();
}
}