diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-05-01 22:16:02 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-05-01 22:16:02 +0000 |
commit | 7c874c55c8242baaa770c46718a5c66b3bf8284a (patch) | |
tree | 2dd2fcff16431e86408b63b460ef5766529e1150 | |
parent | verify file working now (diff) | |
download | gpg4usb-7c874c55c8242baaa770c46718a5c66b3bf8284a.tar.gz gpg4usb-7c874c55c8242baaa770c46718a5c66b3bf8284a.zip |
show error if file could not be read, don't crash on invalid data for verify
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@911 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rwxr-xr-x | fileencryptiondialog.cpp | 21 | ||||
-rwxr-xr-x | fileencryptiondialog.h | 1 | ||||
-rw-r--r-- | verifydetailsdialog.cpp | 13 |
3 files changed, 25 insertions, 10 deletions
diff --git a/fileencryptiondialog.cpp b/fileencryptiondialog.cpp index bc4352f..88f73a8 100755 --- a/fileencryptiondialog.cpp +++ b/fileencryptiondialog.cpp @@ -29,14 +29,16 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k mCtx = ctx; if (mAction == Decrypt) { setWindowTitle(tr("Decrypt File")); + resize(500, 200); } else if (mAction == Encrypt) { setWindowTitle(tr("Encrypt File")); - resize(500, 300); + resize(500, 400); } else if (mAction == Sign) { setWindowTitle(tr("Sign File")); - resize(500, 300); + resize(500, 400); } else if (mAction == Verify) { setWindowTitle(tr("Verify File")); + resize(500, 200); } setModal(true); @@ -60,8 +62,6 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k QLabel *fl2 = new QLabel(tr("Output")); fl2->setBuddy(outputFileEdit); - - QGridLayout *gLayout = new QGridLayout(); gLayout->addWidget(fl1, 0, 0); gLayout->addWidget(inputFileEdit, 0, 1); @@ -91,10 +91,13 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k mKeyList->setColumnWidth(3, 150); mKeyList->setChecked(&keyList); - QVBoxLayout *vbox2 = new QVBoxLayout(); + statusLabel = new QLabel(); + statusLabel->setStyleSheet("QLabel {color: red;}"); + QVBoxLayout *vbox2 = new QVBoxLayout(); vbox2->addWidget(groupBox1); vbox2->addWidget(mKeyList); + vbox2->addWidget(statusLabel); vbox2->addWidget(buttonBox); vbox2->addStretch(0); setLayout(vbox2); @@ -175,7 +178,9 @@ void FileEncryptionDialog::executeAction() QFile infile; infile.setFileName(inputFileEdit->text()); if (!infile.open(QIODevice::ReadOnly)) { - qDebug() << tr("Couldn't Open file: ") + inputFileEdit->text(); + statusLabel->setText( tr("Couldn't open file")); + inputFileEdit->setStyleSheet("QLineEdit { background: yellow }"); + return; } QByteArray inBuffer = infile.readAll(); @@ -196,7 +201,9 @@ void FileEncryptionDialog::executeAction() QFile signfile; signfile.setFileName(signFileEdit->text()); if (!signfile.open(QIODevice::ReadOnly)) { - qDebug() << tr("Couldn't Open file: ") + signFileEdit->text(); + statusLabel->setText( tr("Couldn't open file")); + signFileEdit->setStyleSheet("QLineEdit { background: yellow }"); + return; } QByteArray signBuffer = signfile.readAll(); new VerifyDetailsDialog(this, mCtx, mKeyList, &inBuffer, &signBuffer); diff --git a/fileencryptiondialog.h b/fileencryptiondialog.h index 73e191b..593fe9e 100755 --- a/fileencryptiondialog.h +++ b/fileencryptiondialog.h @@ -110,6 +110,7 @@ private: QLineEdit *inputFileEdit; /**< TODO */ QLineEdit *signFileEdit; /**< TODO */ DialogAction mAction; /**< TODO */ + QLabel *statusLabel; /**< TODO */ protected: GpgME::GpgContext *mCtx; /**< TODO */ KeyList *mKeyList; /**< TODO */ diff --git a/verifydetailsdialog.cpp b/verifydetailsdialog.cpp index 5fcedc8..55fb567 100644 --- a/verifydetailsdialog.cpp +++ b/verifydetailsdialog.cpp @@ -50,6 +50,10 @@ void VerifyDetailsDialog::refresh() QVBoxLayout *mVboxLayout = new QVBoxLayout(mVbox); mainLayout->addWidget(mVbox); + // Button Box for close button + buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); + // Get signature information of current text //QByteArray text = mTextpage->toPlainText().toUtf8(); //mCtx->preventNoDataErr(&text); @@ -60,6 +64,12 @@ void VerifyDetailsDialog::refresh() sign = mCtx->verify(mInputData); } + if(sign==0) { + mVboxLayout->addWidget(new QLabel(tr("No valid input found"))); + mVboxLayout->addWidget(buttonBox); + return; + } + // Get timestamp of signature of current text QDateTime timestamp; timestamp.setTime_t(sign->timestamp); @@ -91,8 +101,5 @@ void VerifyDetailsDialog::refresh() mVboxLayout->addWidget(sbox); } - // Button Box for close button - buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); mVboxLayout->addWidget(buttonBox); } |