aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-09-27 19:25:31 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-09-27 19:25:31 +0000
commit0b84b5f31fd6be36c2c13598cde0d7c4d44ab5fe (patch)
tree9034f4adc514272ac5f16a01c9ee472b484ba0cd
parentupdated todo (diff)
downloadgpg4usb-0b84b5f31fd6be36c2c13598cde0d7c4d44ab5fe.tar.gz
gpg4usb-0b84b5f31fd6be36c2c13598cde0d7c4d44ab5fe.zip
more error handling for encryption in context.cpp
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@378 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--context.cpp38
-rw-r--r--gpgwin.cpp28
2 files changed, 48 insertions, 18 deletions
diff --git a/context.cpp b/context.cpp
index 5a9cb67..b2dfef9 100644
--- a/context.cpp
+++ b/context.cpp
@@ -261,25 +261,33 @@ bool Context::encrypt(QStringList *uidList, const QByteArray &inBuffer, QByteArr
recipients[uidList->count()] = NULL;
//If the last parameter isnt 0, a private copy of data is made
- err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1);
- checkErr(err);
- err = gpgme_data_new(&out);
- checkErr(err);
-
- err = gpgme_op_encrypt(mCtx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
- checkErr(err);
-
- err = readToBuffer(out, outBuffer);
- checkErr(err);
-
+ if (mCtx) {
+ err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1);
+ checkErr(err);
+ if (!err) {
+ err = gpgme_data_new(&out);
+ checkErr(err);
+ if (!err) {
+ err = gpgme_op_encrypt(mCtx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
+ checkErr(err);
+ if (!err) {
+ err = readToBuffer(out, outBuffer);
+ checkErr(err);
+ }
+ }
+ }
+ }
/* unref all keys */
for (int i = 0; i <= uidList->count(); i++) {
gpgme_key_unref(recipients[i]);
}
- gpgme_data_release(in);
- gpgme_data_release(out);
-
- return true;
+ if (in) {
+ gpgme_data_release(in);
+ }
+ if (out) {
+ gpgme_data_release(out);
+ }
+ return (err == GPG_ERR_NO_ERROR);
}
/** Decrypt QByteAarray, return QByteArray
diff --git a/gpgwin.cpp b/gpgwin.cpp
index 53d5d1e..d9d740d 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -324,7 +324,31 @@ void GpgWin::createToolBars()
void GpgWin::createStatusBar()
{
- statusBar()->showMessage(tr("Ready"));
+ QWidget *langBox = new QWidget();
+ QHBoxLayout *vbox2 = new QHBoxLayout();
+
+ langBox->setLayout(vbox2);
+
+// langBox->addMenuAction(appendSelectedKeysAct);
+
+
+ statusBar()->showMessage(tr("Ready"),2000);
+ statusBar()->setContentsMargins(0,0,0,0);
+ QLabel *label;
+ QPixmap *pixmap;
+ QMenu *menu;
+ pixmap = new QPixmap(iconPath + "statusbar_txt3.png");
+ label = new QLabel(statusBar());
+ label->setPixmap(*pixmap);
+ langBox->setLayout(vbox2);
+ menu = new QMenu(label);
+ QMenu *filemenu;
+ filemenu= menu->addMenu(tr("&File"));
+ label->setStatusTip("Es liegen Dateien im Attachments-Ordner");
+ label->setWhatsThis("Attachment vorhanden");
+
+ statusBar()->insertPermanentWidget(0,label,0);
+ statusBar()->setFixedHeight(30);
}
void GpgWin::createDockWindows()
@@ -346,8 +370,6 @@ void GpgWin::createDockWindows()
// hide till attachmendt is decrypted
viewMenu->addAction(aDock->toggleViewAction());
aDock->hide();
-
-
}
void GpgWin::closeEvent(QCloseEvent *event)