diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-09-08 17:16:07 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-09-08 17:16:07 +0000 |
commit | 9e08044e7c503cd8f79f4fb86fa2751652a2637b (patch) | |
tree | 6dbc7b3fa0c47fce919e9ccd50cef590c28d594a | |
parent | minor changes in verify-method and some doxygen documenation (diff) | |
download | gpg4usb-9e08044e7c503cd8f79f4fb86fa2751652a2637b.tar.gz gpg4usb-9e08044e7c503cd8f79f4fb86fa2751652a2637b.zip |
only use private keys to sign and print adequate message, if no private key is checked. removed hideImportAction and added parameter to showImportAction.
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@527 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | context.cpp | 13 | ||||
-rw-r--r-- | editorpage.cpp | 2 | ||||
-rw-r--r-- | editorpage.h | 56 | ||||
-rw-r--r-- | gpgwin.cpp | 8 | ||||
-rw-r--r-- | gpgwin.h | 295 | ||||
-rw-r--r-- | textedit.h | 7 | ||||
-rw-r--r-- | verifynotification.cpp | 29 | ||||
-rw-r--r-- | verifynotification.h | 108 |
8 files changed, 370 insertions, 148 deletions
diff --git a/context.cpp b/context.cpp index 733897e..efa99e7 100644 --- a/context.cpp +++ b/context.cpp @@ -326,7 +326,6 @@ bool Context::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer) return false; } - //if (err != GPG_ERR_NO_ERROR) if (! settings.value("general/rememberPassword").toBool()) { clearPasswordCache(); } @@ -543,7 +542,6 @@ void Context::decryptVerify(QByteArray in) { verify_result = gpgme_op_verify_result (mCtx); */ - } void Context::sign(const QByteArray &inBuffer, QByteArray *outBuffer) { @@ -552,11 +550,6 @@ void Context::sign(const QByteArray &inBuffer, QByteArray *outBuffer) { gpgme_data_t in, out; gpgme_sign_result_t result; - err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); - checkErr(err); - - err = gpgme_data_new (&out); - checkErr(err); /* `GPGME_SIG_MODE_NORMAL' A normal signature is made, the output includes the plaintext @@ -568,16 +561,14 @@ void Context::sign(const QByteArray &inBuffer, QByteArray *outBuffer) { `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); - - qDebug() << "sig: " << QString::fromUtf8(*outBuffer); } bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer ) { @@ -587,7 +578,7 @@ bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray gpgme_sign_result_t result; if (uidList->count() == 0) { - QMessageBox::critical(0, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(0, tr("Key Selection"), tr("No Private Key Selected")); return false; } diff --git a/editorpage.cpp b/editorpage.cpp index 2f47f11..3ee0362 100644 --- a/editorpage.cpp +++ b/editorpage.cpp @@ -21,7 +21,6 @@ #include "editorpage.h" - EditorPage::EditorPage(const QString &filePath, QWidget *parent) : QWidget(parent), fullFilePath(filePath) { @@ -40,7 +39,6 @@ const QString& EditorPage::getFilePath() const return fullFilePath; } - QPlainTextEdit* EditorPage::getTextPage() { return textPage; diff --git a/editorpage.h b/editorpage.h index c0ae255..bea8e07 100644 --- a/editorpage.h +++ b/editorpage.h @@ -30,26 +30,68 @@ class QHBoxLayout; class QString; class QLabel; +/** + * @brief Class for handling a single tab of tabwidget + * + */ class EditorPage : public QWidget { Q_OBJECT public: + /** + * @brief + * + * @param filePath Path of the file handled in this tab + * @param parent Pointer to the parent widget + */ EditorPage(const QString &filePath = "", QWidget *parent = 0); + + /** + * @details Get the filepath of the currently activated tab. + */ const QString& getFilePath() const; + + /** + * @details Set filepath of currently activated tab. + * + * @param filePath The path to be set + */ void setFilePath(const QString &filePath); + + /** + * @details Return pointer tp the textedit of the currently activated tab. + * + */ QPlainTextEdit *getTextPage(); + + /** + * @details Show additional widget at buttom of currently active tab + * + * @param widget The widget to be added + * @param className The name to handle the added widget + */ void showNotificationWidget(QWidget *widget, const char *className); + + /** + * @details Hide all widgets with the given className + * + * @param className The classname of the widgets to hide + */ void hideNoteByClass(const char *className); private: - QPlainTextEdit *textPage; - QVBoxLayout *mainLayout; - QHBoxLayout *notificationWidgetLayout; - QWidget *notificationWidget; - QMenu *verifyMenu; - QString fullFilePath; - QLabel *verifyLabel; + QPlainTextEdit *textPage; /** The textedit of the tab */ + QVBoxLayout *mainLayout; /** The layout for the tab */ + QHBoxLayout *notificationWidgetLayout; /** layout for the notification-widget */ + QWidget *notificationWidget; /** The notification widget shown at the buttom of the tab */ + QMenu *verifyMenu; /** The menu in the notifiaction widget */ + QString fullFilePath; /** The path to the file handled in the tab */ + QLabel *verifyLabel; /** The label of the verify-notification widget */ + /** + * @details bla + * + */ void setSaveState(); }; @@ -601,11 +601,13 @@ void GpgWin::importKeyFromClipboard() QClipboard *cb = QApplication::clipboard(); mCtx->importKey(cb->text(QClipboard::Clipboard).toAscii()); } + void GpgWin::importKeyFromKeyServer() { importDialog = new KeyServerImportDialog(mCtx, this); importDialog->show(); } + void GpgWin::importKeyFromFile() { QFile file; @@ -651,7 +653,7 @@ void GpgWin::encrypt() void GpgWin::sign() { - QStringList *uidList = mKeyList->getChecked(); + QStringList *uidList = mKeyList->getPrivateChecked(); QByteArray *tmp = new QByteArray(); // TODO: toUtf8() here? @@ -793,9 +795,9 @@ void GpgWin::verify() // If an unknown key is found, enable the importfromkeyserveraction if (unknownKeyFound) { - vn->showImportAction(); + vn->showImportAction(true); } else { - vn->hideImportAction(); + vn->showImportAction(false); } // Remove the last linebreak @@ -58,125 +58,272 @@ class QApplication; class QDockWidget; +/** + * @brief + * + */ class GpgWin : public QMainWindow { Q_OBJECT public: + /** + * @brief + * + */ GpgWin(); protected: + /** + * @details Close event shows a save dialog, if there are unsaved documents on exit. + * @param event + */ void closeEvent(QCloseEvent *event); public slots: + /** + * @details encrypt the text of currently active textedit-page + * with the currently checked keys + */ void encrypt(); + + /** + * @details Show a passphrase dialog and decrypt the text of currently active tab. + */ void decrypt(); + + /** + * @details Sign the text of currently active tab with the checked private keys + */ void sign(); + + /** + * @details Verify the text of currently active tab and show verify information. + * If document is signed with a key, which is not in keylist, show import missing + * key from keyserver in Menu of verifynotification. + */ void verify(); + + /** + * @details Open File-Dialog and import the keys from the choosen file + * to keylist if possible. + */ void importKeyFromFile(); + + /** + * @details Import keys from currently active tab to keylist if possible. + */ void importKeyFromEdit(); + + /** + * @details Import keys from clipboard to keylist if possible. + */ void importKeyFromClipboard(); + + /** + * @details Open an "Import key from keyserver"-dialog. + */ void importKeyFromKeyServer(); + + /** + * @details Open a dialog, in which you can choose, where keys should be imported from. + */ void importKeyDialog(); - //void deleteSelectedKeys(); + + /** + * @details Append the selected keys to currently active textedit. + */ void appendSelectedKeys(); + + /** + * @details Copy the mailaddress of selected key to clipboard. + * Method for keylists contextmenu. + */ void copyMailAddressToClipboard(); + + /** + * @details Show detail-dialog for selected key. + */ void showKeyDetails(); + + /** + * @details Open key management dialog. + */ void openKeyManagement(); + + /** + * @details Open about-dialog. + */ void about(); + + /** + * @details Open fileencrytion dialog. + */ void fileEncryption(); + + /** + * @details Open settings-dialog. + */ void openSettingsDialog(); + + /** + * @details Open online-tutorial in default browser. + */ void openTutorial(); + + /** + * @details Show a warn message in status bar, if there are files in attachment folder. + */ void checkAttachmentFolder(); + + /** + * @details Open online translation tutorial in default browser. + */ void openTranslate(); + + /** + * @details Replace double linebreaks by single linebreaks in currently active tab. + */ void cleanDoubleLinebreaks(); // void dropEvent(QDropEvent *event); private: + /** + * @details Create actions for the main-menu and the context-menu of the keylist. + */ void createActions(); + + /** + * @details create the menu of the main-window. + */ void createMenus(); + + /** + * @details Create toolbars (edit,crypt and key) + */ void createToolBars(); + + /** + * @brief + * + */ void createStatusBar(); + /** + * @brief + * + */ void createDockWindows(); + + /** + * @brief + * + */ void restoreSettings(); + + /** + * @brief + * + */ void saveSettings(); + + /** + * @details If text contains PGP-message, put a linebreak before the message, + * so that gpgme can decrypt correctly + * + * @param in Pointer to the QBytearray to check. + */ void preventNoDataErr(QByteArray *in); + + /** + * @brief + * + * @param message + */ void parseMime(QByteArray *message); + + /** + * @brief + * + * @param text + * @return \li 2, if the text is completly signed, + * \li 1, if the text is partially signed, + * \li 0, if the text is not signed at all. + */ int isSigned(const QByteArray &text); - TextEdit *edit; - QMenu *fileMenu; - QMenu *editMenu; - QMenu *cryptMenu; - QMenu *helpMenu; - QMenu *keyMenu; - QMenu *viewMenu; - QMenu *importKeyMenu; - QToolBar *cryptToolBar; - QToolBar *editToolBar; - QToolBar *keyToolBar; - QDockWidget *dock; - QDockWidget *aDock; - QDialog *genkeyDialog; - - QAction *newTabAct; - QAction *switchTabUpAct; - QAction *switchTabDownAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *printAct; - QAction *closeTabAct; - QAction *quitAct; - QAction *encryptAct; - QAction *decryptAct; - QAction *signAct; - QAction *verifyAct; - QAction *importKeyDialogAct; - QAction *importKeyFromFileAct; - QAction *importKeyFromEditAct; - QAction *importKeyFromClipboardAct; - QAction *importKeyFromKeyServerAct; - QAction *cleanDoubleLinebreaksAct; - - QAction *appendSelectedKeysAct; - QAction *copyMailAddressToClipboardAct; - QAction *showKeyDetailsAct; - QAction *openKeyManagementAct; - QAction *copyAct; - QAction *quoteAct; - QAction *cutAct; - QAction *pasteAct; - QAction *selectallAct; - QAction *undoAct; - QAction *redoAct; - QAction *aboutAct; - QAction *fileEncryptionAct; - QAction *openSettingsAct; - QAction *openTranslateAct; - QAction *openTutorialAct; - QLineEdit *nameEdit; - QLineEdit *emailEdit; - QLineEdit *commentEdit; - QLineEdit *passwordEdit; - QLineEdit *repeatpwEdit; - QSpinBox *keysizeSpinBox; - QLabel *nameLabel; - QLabel *emailLabel; - QLabel *commentLabel; - QLabel *keysizeLabel; - QLabel *passwordLabel; - QLabel *repeatpwLabel; - QLabel *errorLabel; - QLabel *statusBarIcon; - - QSettings settings; - KeyList *mKeyList; - Attachments *mAttachments; - GpgME::Context *mCtx; - QString iconPath; - KeyMgmt *keyMgmt; - KeyServerImportDialog *importDialog; + TextEdit *edit; /**< TODO */ + QMenu *fileMenu; /**< TODO */ + QMenu *editMenu; /**< TODO */ + QMenu *cryptMenu; /**< TODO */ + QMenu *helpMenu; /**< TODO */ + QMenu *keyMenu; /**< TODO */ + QMenu *viewMenu; /**< TODO */ + QMenu *importKeyMenu; /**< TODO */ + QToolBar *cryptToolBar; /**< TODO */ + QToolBar *editToolBar; /**< TODO */ + QToolBar *keyToolBar; /**< TODO */ + QDockWidget *dock; /**< TODO */ + QDockWidget *aDock; /**< TODO */ + QDialog *genkeyDialog; /**< TODO */ + + QAction *newTabAct; /**< TODO */ + QAction *switchTabUpAct; /**< TODO */ + QAction *switchTabDownAct; /**< TODO */ + QAction *openAct; /**< TODO */ + QAction *saveAct; /**< TODO */ + QAction *saveAsAct; /**< TODO */ + QAction *printAct; /**< TODO */ + QAction *closeTabAct; /**< TODO */ + QAction *quitAct; /**< TODO */ + QAction *encryptAct; /**< TODO */ + QAction *decryptAct; /**< TODO */ + QAction *signAct; /**< TODO */ + QAction *verifyAct; /**< TODO */ + QAction *importKeyDialogAct; /**< TODO */ + QAction *importKeyFromFileAct; /**< TODO */ + QAction *importKeyFromEditAct; /**< TODO */ + QAction *importKeyFromClipboardAct; /**< TODO */ + QAction *importKeyFromKeyServerAct; /**< TODO */ + QAction *cleanDoubleLinebreaksAct; /**< TODO */ + + QAction *appendSelectedKeysAct; /**< TODO */ + QAction *copyMailAddressToClipboardAct; /**< TODO */ + QAction *showKeyDetailsAct; /**< TODO */ + QAction *openKeyManagementAct; /**< TODO */ + QAction *copyAct; /**< TODO */ + QAction *quoteAct; /**< TODO */ + QAction *cutAct; /**< TODO */ + QAction *pasteAct; /**< TODO */ + QAction *selectallAct; /**< TODO */ + QAction *undoAct; /**< TODO */ + QAction *redoAct; /**< TODO */ + QAction *aboutAct; /**< TODO */ + QAction *fileEncryptionAct; /**< TODO */ + QAction *openSettingsAct; /**< TODO */ + QAction *openTranslateAct; /**< TODO */ + QAction *openTutorialAct; /**< TODO */ + QLineEdit *nameEdit; /**< TODO */ + QLineEdit *emailEdit; /**< TODO */ + QLineEdit *commentEdit; /**< TODO */ + QLineEdit *passwordEdit; /**< TODO */ + QLineEdit *repeatpwEdit; /**< TODO */ + QSpinBox *keysizeSpinBox; /**< TODO */ + QLabel *nameLabel; /**< TODO */ + QLabel *emailLabel; /**< TODO */ + QLabel *commentLabel; /**< TODO */ + QLabel *keysizeLabel; /**< TODO */ + QLabel *passwordLabel; /**< TODO */ + QLabel *repeatpwLabel; /**< TODO */ + QLabel *errorLabel; /**< TODO */ + QLabel *statusBarIcon; /**< TODO */ + + QSettings settings; /**< TODO */ + KeyList *mKeyList; /**< TODO */ + Attachments *mAttachments; /**< TODO */ + GpgME::Context *mCtx; /**< TODO */ + QString iconPath; /**< TODO */ + KeyMgmt *keyMgmt; /**< TODO */ + KeyServerImportDialog *importDialog; /**< TODO */ }; #endif // __GPGWIN_H__ @@ -41,7 +41,6 @@ class QTabWidget; /** * @brief TextEdit class - * @copyright GNU Public License 2 */ class TextEdit : public QWidget { @@ -239,13 +238,13 @@ private: */ bool maybeSaveCurrentTab(bool askToSave); - QString mIconPath; /**< TODO */ + QString mIconPath; /* TODO */ /**************************************************************************************** * Name: countPage * Description: int cotaining the number of added tabs */ - int countPage; /**< TODO */ - QTabWidget *tabWidget; /**< TODO */ + int countPage; /* TODO */ + QTabWidget *tabWidget; /* TODO */ private slots: /**************************************************************************************** diff --git a/verifynotification.cpp b/verifynotification.cpp index 2b650fb..c177497 100644 --- a/verifynotification.cpp +++ b/verifynotification.cpp @@ -1,3 +1,23 @@ +/* + * verifynotification.cpp + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ #include "verifynotification.h" @@ -62,14 +82,9 @@ void VerifyNotification::setVerifyLabel(QString text, verify_label_status verify return; } -void VerifyNotification::showImportAction() +void VerifyNotification::showImportAction(bool visible) { - importFromKeyserverAct->setVisible(true); - return; -} -void VerifyNotification::hideImportAction() -{ - importFromKeyserverAct->setVisible(false); + importFromKeyserverAct->setVisible(visible); return; } diff --git a/verifynotification.h b/verifynotification.h index 641d43e..c8cdd4c 100644 --- a/verifynotification.h +++ b/verifynotification.h @@ -1,3 +1,24 @@ +/* + * verifynotification.h + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + #ifndef VERIFYNOTIFICATION_H #define VERIFYNOTIFICATION_H @@ -11,6 +32,10 @@ class QHBoxLayout; class QMenu; class QPushButton; +/** + * @details Enumeration for the status of Verifylabel + * + */ typedef enum { VERIFY_ERROR_OK = 0, @@ -18,44 +43,40 @@ typedef enum VERIFY_ERROR_CRITICAL = 2, } verify_label_status; +/** + * @brief Class for handling the verifylabel shown at buttom of a textedit-page + * + */ class VerifyNotification : public QWidget { Q_OBJECT public: + /** + * @brief + * + * @param ctx The GPGme-Context + * @param parent The parent widget + */ explicit VerifyNotification(GpgME::Context *ctx,QWidget *parent = 0 ); - // set the text of verifynotification - /**************************************************************************************** - * Name: setVerifyLabel - * Description: set the text of verify notification - * Parameters: none - * Return Values: none - * Change on members: none - */ + /** + * @details Set the text and background-color of verify notification. + * + * @param text The text to be set. + * @param verifyLabelStatus The status of label to set the specified color. + */ void setVerifyLabel(QString text, verify_label_status verifyLabelStatus); - /**************************************************************************************** - * Name: showImportAction - * Description: show the action in detailsmenu - * Parameters: none - * Return Values: none - * Change on members: none - */ - void showImportAction(); - /**************************************************************************************** - * Name: hideImportAction - * Description: hide the action in detailsmenu - * Parameters: none - * Return Values: none - * Change on members: none - */ - void hideImportAction(); - /**************************************************************************************** - * Name: setVerifyDetailText - * Description: set the text of verify-detail dialog - * Parameters: QString containing the text - * Return Values: none - * Change on members: verifyDetailText changes to text - */ + /** + * @details Show the import from keyserver-action in detailsmenu. + * @param visible show the action, if visible is true, otherwise hide it. + */ + void showImportAction(bool visible); + + /** + * @details Set the text of verify-detail dialog. + * + * @param text The text to be set. + */ void setVerifyDetailText(QString text); /**************************************************************************************** @@ -63,24 +84,31 @@ public: * Description: List holding the keys in signature, which are not in the keylist */ QStringList *keysNotInList; - // set text shown in verifydetails dialog signals: public slots: // import missing key from keyserver + /** + * @brief + * + */ void importFromKeyserver(); // show verify details + /** + * @brief + * + */ void showVerifyDetails(); private: - QMenu *detailMenu; // Menu for te Button in verfiyNotification - QAction *importFromKeyserverAct; - QAction *showVerifyDetailsAct; - QString *verifyDetailText; // Text showed in VerifiyNotification - QPushButton *detailsButton; // Button shown in verifynotification - QLabel *verifyLabel; // Label holding the text shown in verifyNotification - GpgME::Context *mCtx; - QHBoxLayout *notificationWidgetLayout; + QMenu *detailMenu; // Menu for te Button in verfiyNotification /**< TODO */ + QAction *importFromKeyserverAct; /**< TODO */ + QAction *showVerifyDetailsAct; /**< TODO */ + QString *verifyDetailText; // Text showed in VerifiyNotification /**< TODO */ + QPushButton *detailsButton; // Button shown in verifynotification /**< TODO */ + QLabel *verifyLabel; // Label holding the text shown in verifyNotification /**< TODO */ + GpgME::Context *mCtx; /**< TODO */ + QHBoxLayout *notificationWidgetLayout; /**< TODO */ }; #endif // VERIFYNOTIFICATION_H |