aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2008-09-29 17:12:22 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2008-09-29 17:12:22 +0000
commit2c251e90452a5eca7e14eafb9c51192f3493fc9f (patch)
tree384907b829e2a56d6e31014046b75ac329ad5091
parentmoved keydelete-action from keylist to gpgwin (diff)
downloadgpg4usb-2c251e90452a5eca7e14eafb9c51192f3493fc9f.tar.gz
gpg4usb-2c251e90452a5eca7e14eafb9c51192f3493fc9f.zip
added key management window
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@177 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--context.h1
-rw-r--r--gpg4usb.pro4
-rw-r--r--gpgwin.cpp16
-rw-r--r--gpgwin.h8
-rw-r--r--keylist.cpp1
-rwxr-xr-xkeymgmt.cpp131
-rwxr-xr-xkeymgmt.h82
7 files changed, 232 insertions, 11 deletions
diff --git a/context.h b/context.h
index 81b2eb1..66023ca 100644
--- a/context.h
+++ b/context.h
@@ -58,7 +58,6 @@ public:
Context(); // Consttructor
~Context(); // Destructor
- void importKeyFromFile(QString pathToFile);
void importKey(QByteArray inBuffer);
GpgKeyList listKeys();
void deleteKeys(QList<QString> *uidList);
diff --git a/gpg4usb.pro b/gpg4usb.pro
index 935a4cd..ce24e7d 100644
--- a/gpg4usb.pro
+++ b/gpg4usb.pro
@@ -11,8 +11,8 @@ DEPENDPATH += .
INCLUDEPATH += .
# Input
-HEADERS += context.h gpgwin.h keylist.h attachments.h
-SOURCES += context.cpp gpgwin.cpp main.cpp keylist.cpp attachments.cpp
+HEADERS += context.h gpgwin.h keylist.h attachments.h keymgmt.h
+SOURCES += context.cpp gpgwin.cpp main.cpp keylist.cpp attachments.cpp keymgmt.cpp
RC_FILE = gpg4usb.rc
# For Static build on Linux: uncomment line below
#LIBS += lib/libgpgme.a -static-libgcc -Llib
diff --git a/gpgwin.cpp b/gpgwin.cpp
index aca6e4a..43d2c87 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -51,7 +51,6 @@ GpgWin::GpgWin()
createToolBars();
createStatusBar();
createDockWindows();
-
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setIconSize(QSize(32, 32));
setCurrentFile("");
@@ -150,6 +149,11 @@ void GpgWin::createActions()
importKeyFromClipboardAct->setStatusTip(tr("Import New Key From Clipboard"));
connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(importKeyFromClipboard()));
+ openKeyManagementAct = new QAction(tr("Key Management"), this);
+ openKeyManagementAct->setIcon(QIcon(iconPath + "importkey_editor.png"));
+ openKeyManagementAct->setStatusTip(tr("Open Keymanagement"));
+ connect(openKeyManagementAct, SIGNAL(triggered()), this, SLOT(openKeyManagement()));
+
importKeyDialogAct = new QAction(tr("Import Key"), this);
importKeyDialogAct->setIcon(QIcon(iconPath + "importkey_editor.png"));
importKeyDialogAct->setStatusTip(tr("Import New Key"));
@@ -166,7 +170,6 @@ void GpgWin::createActions()
deleteSelectedKeysAct = new QAction(tr("Delete Key"), this);
deleteSelectedKeysAct->setStatusTip(tr("Delete the selected keys"));
connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, SLOT(deleteSelectedKeys()));
-
}
void GpgWin::createMenus()
@@ -205,8 +208,7 @@ void GpgWin::createToolBars()
cryptToolBar->addAction(encryptAct);
cryptToolBar->addAction(decryptAct);
cryptToolBar->addAction(importKeyDialogAct);
-
-
+ cryptToolBar->addAction(openKeyManagementAct);
editToolBar = addToolBar(tr("Edit"));
editToolBar->addAction(copyAct);
@@ -443,6 +445,11 @@ void GpgWin::importKeyFromFile()
}
}
+void GpgWin::openKeyManagement() {
+ KeyMgmt *window = new KeyMgmt(myCtx, iconPath);
+ window->show();
+}
+
void GpgWin::importKeyDialog() {
QDialog *dialog = new QDialog();
@@ -490,3 +497,4 @@ void GpgWin::deleteSelectedKeys()
myCtx->deleteKeys(m_keyList->getSelected());
m_keyList->refresh();
}
+
diff --git a/gpgwin.h b/gpgwin.h
index 58c5184..909e805 100644
--- a/gpgwin.h
+++ b/gpgwin.h
@@ -21,6 +21,7 @@
#include "context.h"
#include "keylist.h"
#include "attachments.h"
+#include "keymgmt.h"
class QMainWindow;
class QPlainTextEdit;
@@ -61,13 +62,13 @@ public slots:
void importKeyFromFile();
void importKeyFromEdit();
void importKeyFromClipboard();
+ void importKeyDialog();
+ void openKeyManagement();
void print();
void about();
bool save();
bool saveAs();
void open();
- void importKeyDialog();
- //void browse();
void deleteSelectedKeys();
private:
@@ -80,8 +81,8 @@ private:
void loadFile(const QString &fileName);
void setCurrentFile(const QString &fileName);
bool maybeSave();
- QString strippedName(const QString &fullFileName);
void preventNoDataErr(QByteArray *in);
+ QString strippedName(const QString &fullFileName);
QPlainTextEdit *edit;
QMenu *fileMenu;
@@ -105,6 +106,7 @@ private:
QAction *importKeyFromFileAct;
QAction *importKeyFromEditAct;
QAction *importKeyFromClipboardAct;
+ QAction *openKeyManagementAct;
QAction *copyAct;
QAction *cutAct;
QAction *pasteAct;
diff --git a/keylist.cpp b/keylist.cpp
index e6606ec..395ae8f 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -109,7 +109,6 @@ QList<QString> *KeyList::getChecked()
QList<QString> *ret = new QList<QString>();
for (int i = 0; i < m_keyList->rowCount(); i++) {
if (m_keyList->item(i,0)->checkState() == Qt::Checked) {
- qDebug() << m_keyList->item(i,4)->text();
*ret << m_keyList->item(i,4)->text();
}
}
diff --git a/keymgmt.cpp b/keymgmt.cpp
new file mode 100755
index 0000000..d666bf1
--- /dev/null
+++ b/keymgmt.cpp
@@ -0,0 +1,131 @@
+/*
+ * keymgmt.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 <QtGui>
+
+#include "keymgmt.h"
+#include "keyutils.h"
+
+KeyMgmt::KeyMgmt(GpgME::Context *ctx, QString iconpath)
+{
+ mCtx = ctx;
+ mIconPath = iconpath;
+ resize(640, 400);
+
+ /* the list of Keys available*/
+ m_keyList = new KeyList();
+ m_keyList->setIconPath(mIconPath);
+ m_keyList->setContext(mCtx);
+ m_keyList->setColumnWidth(2,250);
+ m_keyList->setColumnWidth(3,250);
+ setCentralWidget(m_keyList);
+ createActions();
+ createMenus();
+ createToolBars();
+ setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ setIconSize(QSize(32, 32));
+
+ setWindowTitle(tr("Keymanagement"));
+ m_keyList->addMenuAction(deleteSelectedKeysAct);
+}
+
+void KeyMgmt::createActions()
+{
+ closeAct = new QAction(tr("&Close Key Management"), this);
+ closeAct->setShortcut(tr("Ctrl+Q"));
+ closeAct->setIcon(QIcon(mIconPath + "exit.png"));
+ closeAct->setStatusTip(tr("Close Key Management"));
+ connect(closeAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ importKeyFromFileAct = new QAction(tr("Import Key From &File"), this);
+ importKeyFromFileAct->setIcon(QIcon(mIconPath + "importkey_editor.png"));
+ importKeyFromFileAct->setStatusTip(tr("Import New Key From File"));
+ connect(importKeyFromFileAct, SIGNAL(triggered()), this, SLOT(importKeyFromFile()));
+
+ importKeyFromClipboardAct = new QAction(tr("Import Key From &Clipboard"), this);
+ importKeyFromClipboardAct->setIcon(QIcon(mIconPath + "importkey_editor.png"));
+ importKeyFromClipboardAct->setStatusTip(tr("Import New Key From Clipboard"));
+ connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(importKeyFromClipboard()));
+
+ deleteSelectedKeysAct = new QAction(tr("Delete Selected Key(s)"), this);
+ deleteSelectedKeysAct->setStatusTip(tr("Delete the Selected keys"));
+ connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, SLOT(deleteSelectedKeys()));
+
+ deleteCheckedKeysAct = new QAction(tr("Delete Checked Key(s)"), this);
+ deleteCheckedKeysAct->setStatusTip(tr("Delete the Checked keys"));
+ deleteCheckedKeysAct->setIcon(QIcon(mIconPath + "button_cancel.png"));
+ connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(deleteCheckedKeys()));
+}
+
+void KeyMgmt::createMenus()
+{
+ fileMenu = menuBar()->addMenu(tr("&Quit"));
+ fileMenu->addAction(closeAct);
+ keyMenu = menuBar()->addMenu(tr("&Key"));
+ keyMenu->addAction(importKeyFromFileAct);
+ keyMenu->addAction(importKeyFromClipboardAct);
+ keyMenu->addSeparator();
+ keyMenu->addAction(deleteCheckedKeysAct);
+}
+
+void KeyMgmt::createToolBars()
+{
+ QToolBar *keyToolBar = addToolBar(tr("Crypt"));
+ keyToolBar->addAction(importKeyFromFileAct);
+ keyToolBar->addAction(importKeyFromClipboardAct);
+ keyToolBar->addSeparator();
+ keyToolBar->addAction(deleteCheckedKeysAct);
+}
+
+void KeyMgmt::importKeyFromFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open Key"), "", tr("Key Files") + " (*.asc *.txt);;All Files (*.*)");
+ if (! fileName.isNull()) {
+ QFile file;
+ file.setFileName(fileName);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug() << tr("couldn't open file: ") + fileName;
+ }
+ QByteArray inBuffer = file.readAll();
+
+ mCtx->importKey(inBuffer);
+ m_keyList->refresh();
+ }
+}
+
+void KeyMgmt::importKeyFromClipboard()
+{
+ QClipboard *cb = QApplication::clipboard();
+ mCtx->importKey(cb->text(QClipboard::Clipboard).toAscii());
+ m_keyList->refresh();
+}
+
+void KeyMgmt::deleteSelectedKeys()
+{
+ mCtx->deleteKeys(m_keyList->getSelected());
+ m_keyList->refresh();
+}
+
+void KeyMgmt::deleteCheckedKeys()
+{
+ mCtx->deleteKeys(m_keyList->getChecked());
+ m_keyList->refresh();
+}
diff --git a/keymgmt.h b/keymgmt.h
new file mode 100755
index 0000000..349b62b
--- /dev/null
+++ b/keymgmt.h
@@ -0,0 +1,82 @@
+/*
+ * keymgmt.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 __KEYMGMT_H__
+#define __KEYMGMT_H__
+
+
+class QMainWindow;
+class QPlainTextEdit;
+class QWidget;
+class QVBoxLayout;
+class QGridLayout;
+class iostream;
+class QtGui;
+class QString;
+class QFileDialog;
+class QStringList;
+class QIcon;
+class QMessageBox;
+class QVBoxLayout;
+class QAction;
+class QMenu;
+class QPlainTextEdit;
+class QComboBox;
+class QPushButton;
+class QRadioButton;
+class QButtonGroup;
+class QApplication;
+
+#include "context.h"
+#include "keylist.h"
+
+class KeyMgmt : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ KeyMgmt(GpgME::Context* ctx, QString iconpath);
+
+public slots:
+ void importKeyFromFile();
+ void importKeyFromClipboard();
+ void deleteCheckedKeys();
+ void deleteSelectedKeys();
+
+private:
+ void createMenus();
+ void createActions();
+ void createToolBars();
+
+ KeyList *m_keyList;
+ QString mIconPath;
+ GpgME::Context *mCtx;
+ QMenu *fileMenu;
+ QMenu *keyMenu;
+ QAction *importKeyFromFileAct;
+ QAction *importKeyFromEditAct;
+ QAction *importKeyFromClipboardAct;
+ QAction *deleteCheckedKeysAct;
+ QAction *deleteSelectedKeysAct;
+ QAction *closeAct;
+};
+
+#endif // __KEYMGMT_H__