[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeutils/kgpg
From: Rolf Eike Beer <kde () opensource ! sf-tec ! de>
Date: 2009-05-03 23:22:51
Message-ID: 1241392971.583413.7067.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 963131 by dakon:
port downloading keys from keyserver to transactions
M +3 -1 CMakeLists.txt
M +34 -15 keyservers.cpp
M +2 -2 keyservers.h
M +13 -9 keysmanager.cpp
M +1 -1 keysmanager.h
M +0 -93 kgpginterface.cpp
M +0 -37 kgpginterface.h
AM transactions/kgpgkeyservergettransaction.cpp [License: GPL (v2+)]
AM transactions/kgpgkeyservergettransaction.h [License: GPL (v2+)]
AM transactions/kgpgkeyservertransaction.cpp [License: GPL (v2+)]
AM transactions/kgpgkeyservertransaction.h [License: GPL (v2+)]
--- trunk/KDE/kdeutils/kgpg/CMakeLists.txt #963130:963131
@@ -5,7 +5,7 @@
add_subdirectory( icons )
add_subdirectory( core )
-include_directories( ${KDEPIMLIBS_INCLUDE_DIR} core editor model transactions )
+include_directories( ${KDEPIMLIBS_INCLUDE_DIR} core editor model transactions \
${CMAKE_INSTALL_PREFIX}/include)
set(core_SRCS
core/convert.cpp
@@ -41,6 +41,8 @@
transactions/kgpggeneratekey.cpp
transactions/kgpgdelkey.cpp
transactions/kgpgimport.cpp
+ transactions/kgpgkeyservertransaction.cpp
+ transactions/kgpgkeyservergettransaction.cpp
)
set(kgpg_SRCS ${core_SRCS} ${kgpg_editor_SRCS} ${kgpg_model_SRCS} \
${kgpg_transaction_SRCS}
--- trunk/KDE/kdeutils/kgpg/keyservers.cpp #963130:963131
@@ -35,6 +35,7 @@
#include "detailedconsole.h"
#include "convert.h"
#include "gpgproc.h"
+#include "kgpgkeyservergettransaction.h"
using namespace KgpgCore;
@@ -104,7 +105,7 @@
delete page;
}
-void KeyServer::refreshKeys(QStringList keys)
+void KeyServer::refreshKeys(const QStringList &keys)
{
QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
@@ -114,14 +115,13 @@
if (KGpgSettings::useProxy())
proxy = qgetenv("http_proxy");
- KgpgInterface *interface = new KgpgInterface();
- connect(interface, SIGNAL(downloadKeysFinished(QList<int>, QStringList, bool, \
QString, KgpgInterface*)), SLOT(slotDownloadKeysFinished(QList<int>, QStringList, \
bool, QString, KgpgInterface*)));
- connect(interface, SIGNAL(downloadKeysAborted(KgpgInterface*)), \
SLOT(slotAbort(KgpgInterface*))); + KGpgRefreshKeys *proc = new KGpgRefreshKeys(this, \
keyserv, keys, proxy); + connect(proc, SIGNAL(done(int)), \
SLOT(slotDownloadKeysFinished(int)));
m_importpop = new ConnectionDialog(this);
- connect(m_importpop, SIGNAL(cancelClicked()), interface, \
SLOT(downloadKeysAbort())); + connect(m_importpop, SIGNAL(cancelClicked()), proc, \
SLOT(slotAbort()));
- interface->downloadKeys(keys, keyserv, true, proxy);
+ proc->start();
}
void KeyServer::slotImport()
@@ -136,26 +136,45 @@
QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
- KgpgInterface *interface = new KgpgInterface();
- connect(interface, SIGNAL(downloadKeysFinished(QList<int>, QStringList, bool, \
QString, KgpgInterface*)), SLOT(slotDownloadKeysFinished(QList<int>, QStringList, \
bool, QString, KgpgInterface*)));
- connect(interface, SIGNAL(downloadKeysAborted(KgpgInterface*)), \
SLOT(slotAbort(KgpgInterface*))); + KGpgReceiveKeys *proc = new KGpgReceiveKeys(this, \
page->kCBimportks->currentText(), page->kLEimportid->text().simplified().split(' '), \
page->kLEproxyI->text()); + connect(proc, SIGNAL(done(int)), \
SLOT(slotDownloadKeysFinished(int)));
m_importpop = new ConnectionDialog(this);
- connect(m_importpop, SIGNAL(cancelClicked()), interface, \
SLOT(downloadKeysAbort())); + connect(m_importpop, SIGNAL(cancelClicked()), proc, \
SLOT(slotAbort()));
- interface->downloadKeys(page->kLEimportid->text().simplified().split(' '), \
page->kCBimportks->currentText(), false, page->kLEproxyI->text()); + proc->start();
}
-void KeyServer::slotDownloadKeysFinished(QList<int> result, QStringList keys, bool \
imported, QString log, KgpgInterface *interface) +void \
KeyServer::slotDownloadKeysFinished(int resultcode) {
delete m_importpop;
m_importpop = 0;
- interface->deleteLater();
QApplication::restoreOverrideCursor();
+ KGpgKeyserverGetTransaction *t = qobject_cast<KGpgKeyserverGetTransaction \
*>(sender()); + const QStringList log(t->getLog());
+
+ t->deleteLater();
+
+ if (resultcode == KGpgTransaction::TS_USER_ABORTED)
+ return;
+
+ QStringList keys;
+ QList<int> result;
+
+ foreach (const QString msg, log) {
+ if (msg.startsWith("[GNUPG:] IMPORT_OK ")) {
+ keys.append(msg.section(' ', 3));
+ } else if (msg.startsWith("[GNUPG:] IMPORT_RES ")) {
+ QStringList importresult(msg.mid(20).split(' '));
+ foreach (const QString n, importresult)
+ result.append(n.toInt());
+ }
+ }
+
QString resultmessage;
- if (imported) {
+ if ((resultcode == KGpgTransaction::TS_OK) && (result.count() >= 13)) {
if (result[0] != 0)
resultmessage += i18np("<qt>%1 key processed.<br/></qt>", "<qt>%1 keys \
processed.<br/></qt>", result[0]); if (result[4] != 0)
@@ -189,7 +208,7 @@
if (!keys.empty())
emit importFinished(keys);
- (void) new KgpgDetailedInfo(0, resultmessage, log, keys);
+ (void) new KgpgDetailedInfo(0, resultmessage, log.join(QString('\n')), keys);
}
void KeyServer::slotAbort(KgpgInterface *interface)
--- trunk/KDE/kdeutils/kgpg/keyservers.h #963130:963131
@@ -67,7 +67,7 @@
explicit KeyServer(QWidget *parent = 0, KGpgItemModel *model = 0, const bool \
autoclose = false); ~KeyServer();
- void refreshKeys(QStringList keys);
+ void refreshKeys(const QStringList &keys);
/**
* Returns the server list.
@@ -99,7 +99,7 @@
void handleQuit();
private slots:
- void slotDownloadKeysFinished(QList<int> results, QStringList keys, bool imported, \
QString log, KgpgInterface *interface); + void slotDownloadKeysFinished(int \
resultcode); void slotUploadKeysFinished(QString message, KgpgInterface *interface);
void slotSearchRead(GPGProc *p);
--- trunk/KDE/kdeutils/kgpg/keysmanager.cpp #963130:963131
@@ -99,10 +99,11 @@
#include "kgpgdelkey.h"
#include "kgpgimport.h"
#include "detailedconsole.h"
-#include "../../../extragear/libs/libknotificationitem/knotificationitem.h"
+#include "knotificationitem-1/knotificationitem.h"
#include "selectpublickeydialog.h"
#include "kgpgtextinterface.h"
#include "kgpgview.h"
+#include "kgpgkeyservergettransaction.h"
using namespace KgpgCore;
@@ -2030,22 +2031,25 @@
bool KeysManager::importRemoteKey(const QString &keyIDs)
{
- KgpgInterface *iface = new KgpgInterface();
-
- QStringList kservers = KeyServer::getServerList();
+ QStringList kservers(KeyServer::getServerList());
if (kservers.isEmpty())
return false;
- connect(iface, SIGNAL(downloadKeysFinished(QList<int>, QStringList, bool, QString, \
KgpgInterface*)), SLOT(importRemoteFinished(QList<int>, QStringList, bool, QString, \
KgpgInterface*)));
- iface->downloadKeys(keyIDs.split(' '), kservers.first(), false, \
qgetenv("http_proxy")); + KGpgReceiveKeys *proc = new KGpgReceiveKeys(this, \
kservers.first(), keyIDs.simplified().split(' '), qgetenv("http_proxy")); \
+ connect(proc, SIGNAL(done(int)), SLOT(importRemoteFinished(int)));
+ proc->start();
+
return true;
}
-void KeysManager::importRemoteFinished(QList<int>, QStringList, bool, QString, \
KgpgInterface *iface) +void KeysManager::importRemoteFinished(int result)
{
- iface->deleteLater();
- imodel->refreshKeys();
+ sender()->deleteLater();
+
+ // FIXME: only refresh when keys were changed
+ if (result == KGpgTransaction::TS_OK)
+ imodel->refreshKeys();
}
void KeysManager::importsignkey(const QStringList &importKeyId)
--- trunk/KDE/kdeutils/kgpg/keysmanager.h #963130:963131
@@ -205,7 +205,7 @@
void secretKeyDeleted(int);
void getMissingSigs(QSet<QString> &missingKeys, const KGpgExpandableNode *nd);
void slotEditDone(int exitcode);
- void importRemoteFinished(QList<int>, QStringList, bool, QString, KgpgInterface \
*iface); + void importRemoteFinished(int result);
void slotRefreshKeys(KgpgInterface *iface, const QStringList &keys);
void slotDelKeyDone(int ret);
void slotImportDone(int ret);
--- trunk/KDE/kdeutils/kgpg/kgpginterface.cpp #963130:963131
@@ -961,99 +961,6 @@
emit loadPhotoFinished(m_pixmap, this);
}
-void KgpgInterface::downloadKeys(const QStringList &keys, const QString &keyserver, \
const bool &refresh, const QString &proxy)
-{
- m_downloadkeys.clear();
- m_downloadkeys_log.clear();
-
- m_downloadprocess = new GPGProc(this);
- *m_downloadprocess << "--command-fd=0" << "--status-fd=1";
-
- m_downloadprocess->setOutputChannelMode(KProcess::MergedChannels);
-
- if (proxy.isEmpty()) {
- *m_downloadprocess << "--keyserver-options" << "no-honor-http-proxy";
- } else {
- *m_downloadprocess << "--keyserver-options" << "honor-http-proxy";
- m_downloadprocess->setEnvironment(QStringList("http_proxy=" + proxy));
- }
-
- *m_downloadprocess << "--keyserver" << keyserver;
- if (refresh)
- *m_downloadprocess << "--refresh-keys";
- else
- *m_downloadprocess << "--recv-keys";
- *m_downloadprocess << keys;
-
- connect(m_downloadprocess, SIGNAL(processExited(GPGProc *)), \
SLOT(downloadKeysFin(GPGProc *)));
- connect(m_downloadprocess, SIGNAL(readReady(GPGProc *)), \
SLOT(downloadKeysProcess(GPGProc *)));
- m_downloadprocess->start();
-}
-
-void KgpgInterface::downloadKeysAbort()
-{
- if (m_downloadprocess && (m_downloadprocess->state() == QProcess::Running)) {
- disconnect(m_downloadprocess, 0, 0, 0);
- m_downloadprocess->kill();
-
- delete m_downloadprocess;
- m_downloadprocess = 0;
-
- emit downloadKeysAborted(this);
- }
-}
-
-void KgpgInterface::downloadKeysProcess(GPGProc *p)
-{
- QString line;
-
- while (p->readln(line, true) >= 0) {
- if (line.startsWith("[GNUPG:]")) {
- m_downloadkeys += line + '\n';
- } else if (line.startsWith("gpgkeys: ")) {
- m_downloadkeys_log += line.mid(9) + '\n';
- } else {
- m_downloadkeys_log += line + '\n';
- }
- }
-}
-
-void KgpgInterface::downloadKeysFin(GPGProc *p)
-{
- p->deleteLater();
- m_downloadprocess = 0;
-
- QStringList importedkeys;
- QString parsedoutput = m_downloadkeys;
- while (parsedoutput.contains("IMPORTED")) {
- parsedoutput.remove(0, parsedoutput.indexOf("IMPORTED") + 8);
- importedkeys += parsedoutput.section('\n', 0, 0).simplified();
- }
-
- while (parsedoutput.contains("IMPORT_OK")) {
- parsedoutput.remove(0, parsedoutput.indexOf("IMPORT_OK") + 9);
- importedkeys += parsedoutput.section('\n', 0, 0).simplified().right(16);
- }
-
- QList<int> result;
- bool key = false;
- if (m_downloadkeys.contains("IMPORT_RES")) {
- const QStringList nbs(m_downloadkeys.section("IMPORT_RES", -1, \
-1).simplified().split(' '));
-
- foreach (const QString nb, nbs) {
- int r = nb.toInt();
- result.append(r);
- if (r != 0)
- key = true;
- }
- } else {
- for (int i = 0; i < 14; i++)
- result.append(0);
- }
-
- emit downloadKeysFinished(result, importedkeys, key, m_downloadkeys_log, this);
-}
-
void KgpgInterface::uploadKeys(const QStringList &keys, const QString &keyserver, \
const QString &attributes, const QString &proxy) {
m_uploadkeys_log.clear();
--- trunk/KDE/kdeutils/kgpg/kgpginterface.h #963130:963131
@@ -226,43 +226,6 @@
/*******************************************************/
-/************** download keys from keys server **************/
-signals:
- /*
- 0 : keys processed
- 1 : keys without id
- 2 : keys imported
- 3 : RSA keys
- 4 : unchanged
- 5 : Uid imported
- 6 : Subkey imported
- 7 : Sign imported
- 8 : Revocation imported
- 9 : secret keys processed
- 10 : secret keys imported
- 11 : secret keys unchanged
- 12 : secret keys not imported
- */
- void downloadKeysFinished(QList<int>, QStringList, bool, QString, \
KgpgInterface*);
- void downloadKeysAborted(KgpgInterface*);
-
-public slots:
- void downloadKeys(const QStringList &keys, const QString &keyserver, const bool \
&refresh, const QString &proxy = "");
- void downloadKeysAbort();
-
-private slots:
- void downloadKeysProcess(GPGProc *p);
- void downloadKeysFin(GPGProc *p);
-
-private:
- GPGProc *m_downloadprocess;
- QString m_downloadkeys;
- QString m_downloadkeys_log;
-
-/***********************************************************/
-
-
-
/************** upload keys to keys server **************/
signals:
void uploadKeysFinished(QString, KgpgInterface*);
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservergettransaction.cpp #property \
svn:eol-style + native
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservergettransaction.cpp #property \
svn:mime-type + text/x-c++src
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservergettransaction.h #property \
svn:eol-style + native
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservergettransaction.h #property \
svn:mime-type + text/x-chdr
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservertransaction.cpp #property \
svn:eol-style + native
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservertransaction.cpp #property \
svn:mime-type + text/x-c++src
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservertransaction.h #property \
svn:eol-style + native
** trunk/KDE/kdeutils/kgpg/transactions/kgpgkeyservertransaction.h #property \
svn:mime-type + text/x-chdr
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic