From ac21cc48d22f0cf58a98b74754fa94564a8e3f45 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sat, 20 Dec 2008 18:49:00 +0100 Subject: [PATCH] Finalizing changes to the identities interface -> breaking protocol --- src/client/CMakeLists.txt | 2 + src/client/client.cpp | 17 +- src/client/client.h | 7 +- src/client/clientidentity.cpp | 99 ++ src/client/clientidentity.h | 81 ++ src/common/identity.cpp | 5 +- src/common/identity.h | 34 +- src/common/signalproxy.cpp | 2 +- src/common/syncableobject.cpp | 8 + src/common/syncableobject.h | 7 +- src/core/CMakeLists.txt | 2 + src/core/SQL/upgradeSchema.sh | 9 +- src/core/coreidentity.cpp | 89 ++ src/core/coreidentity.h | 83 ++ src/core/corenetwork.cpp | 6 +- src/core/corenetwork.h | 4 +- src/core/coresession.cpp | 82 +- src/core/coresession.h | 13 +- src/core/ircserverhandler.cpp | 2 +- src/core/userinputhandler.cpp | 2 +- .../settingspages/identitiessettingspage.cpp | 165 ++- .../settingspages/identitiessettingspage.h | 134 +- .../settingspages/identitiessettingspage.ui | 1272 ++++++++++------- src/uisupport/networkmodelactionprovider.cpp | 2 +- version.inc | 6 +- 25 files changed, 1470 insertions(+), 663 deletions(-) create mode 100644 src/client/clientidentity.cpp create mode 100644 src/client/clientidentity.h create mode 100644 src/core/coreidentity.cpp create mode 100644 src/core/coreidentity.h diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index f10489fb..f0005085 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -13,6 +13,7 @@ set(SOURCES buffersettings.cpp client.cpp clientbacklogmanager.cpp + clientidentity.cpp clientirclisthelper.cpp clientsettings.cpp clientsyncer.cpp @@ -31,6 +32,7 @@ set(MOC_HDRS client.h clientbacklogmanager.h clientcoreinfo.h + clientidentity.h clientirclisthelper.h clientsyncer.h irclistmodel.h diff --git a/src/client/client.cpp b/src/client/client.cpp index 575314c1..310e8e49 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -28,7 +28,7 @@ #include "bufferviewmanager.h" #include "clientbacklogmanager.h" #include "clientirclisthelper.h" -#include "identity.h" +#include "clientidentity.h" #include "ircchannel.h" #include "ircuser.h" #include "message.h" @@ -110,7 +110,7 @@ void Client::init() { p->attachSignal(this, SIGNAL(sendInput(BufferInfo, QString))); p->attachSignal(this, SIGNAL(requestNetworkStates())); - p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &)), SIGNAL(createIdentity(const Identity &))); + p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &, const QVariantMap &)), SIGNAL(createIdentity(const Identity &, const QVariantMap &))); p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId))); p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &))); p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId))); @@ -214,13 +214,16 @@ QList Client::identityIds() { return instance()->_identities.keys(); } -const Identity * Client::identity(IdentityId id) { +const Identity *Client::identity(IdentityId id) { if(instance()->_identities.contains(id)) return instance()->_identities[id]; else return 0; } -void Client::createIdentity(const Identity &id) { - emit instance()->requestCreateIdentity(id); +void Client::createIdentity(const CertIdentity &id) { + QVariantMap additional; + additional["KeyPem"] = id.sslKey().toPem(); + additional["CertPem"] = id.sslCert().toPem(); + emit instance()->requestCreateIdentity(id, additional); } void Client::updateIdentity(IdentityId id, const QVariantMap &ser) { @@ -346,10 +349,10 @@ void Client::disconnectedFromCore() { } Q_ASSERT(_networks.isEmpty()); - QHash::iterator idIter = _identities.begin(); + QHash::iterator idIter = _identities.begin(); while(idIter != _identities.end()) { + emit identityRemoved(idIter.key()); Identity *id = idIter.value(); - emit identityRemoved(id->id()); idIter = _identities.erase(idIter); id->deleteLater(); } diff --git a/src/client/client.h b/src/client/client.h index 40949ac5..610e732f 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -34,6 +34,7 @@ class MessageModel; class AbstractMessageProcessor; class Identity; +class CertIdentity; class Network; class AbstractUi; @@ -68,14 +69,14 @@ public: static const Network * network(NetworkId); static QList identityIds(); - static const Identity * identity(IdentityId); + static const Identity *identity(IdentityId); //! Request creation of an identity with the given data. /** The request will be sent to the core, and will be propagated back to all the clients * with a new valid IdentityId. * \param identity The identity template for the new identity. It does not need to have a valid ID. */ - static void createIdentity(const Identity &identity); + static void createIdentity(const CertIdentity &identity); //! Request update of an identity with the given data. /** The request will be sent to the core, and will be propagated back to all the clients. @@ -141,7 +142,7 @@ signals: void identityRemoved(IdentityId id); //! Sent to the core when an identity shall be created. Should not be used elsewhere. - void requestCreateIdentity(const Identity &); + void requestCreateIdentity(const Identity &, const QVariantMap &); //! Sent to the core when an identity shall be removed. Should not be used elsewhere. void requestRemoveIdentity(IdentityId); diff --git a/src/client/clientidentity.cpp b/src/client/clientidentity.cpp new file mode 100644 index 00000000..1d93d64b --- /dev/null +++ b/src/client/clientidentity.cpp @@ -0,0 +1,99 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * 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) version 3. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "clientidentity.h" + +#include "client.h" +#include "signalproxy.h" + +CertIdentity::CertIdentity(IdentityId id, QObject *parent) + : Identity(id, parent), + _certManager(0), + _isDirty(false) +{ +} + +CertIdentity::CertIdentity(const Identity &other, QObject *parent) + : Identity(other, parent), + _certManager(0), + _isDirty(false) +{ +} + +CertIdentity::CertIdentity(const CertIdentity &other, QObject *parent) + : Identity(other, parent), + _certManager(0), + _isDirty(other._isDirty), + _sslKey(other._sslKey), + _sslCert(other._sslCert) +{ +} + +void CertIdentity::enableEditSsl(bool enable) { + if(!enable || _certManager) + return; + + _certManager = new ClientCertManager(id(), this); + if(isValid()) { // this means we are not a newly created Identity but have a proper Id + Client::signalProxy()->synchronize(_certManager); + connect(_certManager, SIGNAL(updated(const QVariantMap &)), this, SLOT(markClean())); + connect(_certManager, SIGNAL(initDone()), this, SLOT(markClean())); + } +} + +void CertIdentity::setSslKey(const QSslKey &key) { + if(key.toPem() == _sslKey.toPem()) + return; + _sslKey = key; + _isDirty = true; +} + +void CertIdentity::setSslCert(const QSslCertificate &cert) { + if(cert.toPem() == _sslCert.toPem()) + return; + _sslCert = cert; + _isDirty = true; +} + +void CertIdentity::requestUpdateSslSettings() { + if(!_certManager) + return; + + _certManager->requestUpdate(_certManager->toVariantMap()); +} + +void CertIdentity::markClean() { + _isDirty = false; + emit sslSettingsUpdated(); +} + +// ======================================== +// ClientCertManager +// ======================================== +void ClientCertManager::setSslKey(const QByteArray &encoded) { + QSslKey key(encoded, QSsl::Rsa); + if(key.isNull()) + key = QSslKey(encoded, QSsl::Dsa); + _certIdentity->setSslKey(key); +} + +void ClientCertManager::setSslCert(const QByteArray &encoded) { + _certIdentity->setSslCert(QSslCertificate(encoded)); +} diff --git a/src/client/clientidentity.h b/src/client/clientidentity.h new file mode 100644 index 00000000..680ac956 --- /dev/null +++ b/src/client/clientidentity.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * 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) version 3. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef CLIENTIDENTITY_H +#define CLIENTIDENTITY_H + +#include "identity.h" + +class ClientCertManager; + +class CertIdentity : public Identity { + Q_OBJECT + +public: + CertIdentity(IdentityId id = 0, QObject *parent = 0); + CertIdentity(const Identity &other, QObject *parent = 0); + CertIdentity(const CertIdentity &other, QObject *parent = 0); + + void enableEditSsl(bool enable = true); + inline bool isDirty() const { return _isDirty; } + + inline const QSslKey &sslKey() const { return _sslKey; } + inline const QSslCertificate &sslCert() const { return _sslCert; } + + void setSslKey(const QSslKey &key); + void setSslCert(const QSslCertificate &cert); + +public slots: + void requestUpdateSslSettings(); + +signals: + void sslSettingsUpdated(); + +private slots: + void markClean(); + +private: + ClientCertManager *_certManager; + bool _isDirty; + QSslKey _sslKey; + QSslCertificate _sslCert; +}; + +// ======================================== +// ClientCertManager +// ======================================== +class ClientCertManager : public CertManager { + Q_OBJECT + +public: + ClientCertManager(IdentityId id, CertIdentity *parent) : CertManager(id, parent), _certIdentity(parent) {} + + virtual inline const QSslKey &sslKey() const { return _certIdentity->sslKey(); } + virtual inline const QSslCertificate &sslCert() const { return _certIdentity->sslCert(); } + +public slots: + virtual void setSslKey(const QByteArray &encoded); + virtual void setSslCert(const QByteArray &encoded); + +private: + CertIdentity *_certIdentity; +}; + +#endif //CLIENTIDENTITY_H diff --git a/src/common/identity.cpp b/src/common/identity.cpp index eff50215..da10fb0d 100644 --- a/src/common/identity.cpp +++ b/src/common/identity.cpp @@ -86,10 +86,10 @@ void Identity::setToDefaults() { /*** setters ***/ -// NOTE: DO NOT USE ON SYNCHRONIZED OBJECTS! void Identity::setId(IdentityId _id) { _identityId = _id; - setObjectName(QString::number(id().toInt())); + emit idSet(_id); + renameObject(QString::number(id().toInt())); } void Identity::setIdentityName(const QString &identityName) { @@ -228,3 +228,4 @@ QDataStream &operator>>(QDataStream &in, Identity &id) { id.fromVariantMap(i); return in; } + diff --git a/src/common/identity.h b/src/common/identity.h index bd1eaa50..a71e0eeb 100644 --- a/src/common/identity.h +++ b/src/common/identity.h @@ -21,6 +21,7 @@ #ifndef IDENTITY_H #define IDENTITY_H +#include #include #include #include @@ -55,6 +56,8 @@ class Identity : public SyncableObject { public: Identity(IdentityId id = 0, QObject *parent = 0); Identity(const Identity &other, QObject *parent = 0); + inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; } + void setToDefaults(); bool operator==(const Identity &other); @@ -153,4 +156,33 @@ QDataStream &operator>>(QDataStream &in, Identity &identity); Q_DECLARE_METATYPE(Identity) -#endif +#ifdef HAVE_SSL +#include +#include + +class CertManager : public SyncableObject { + Q_OBJECT + Q_PROPERTY(QByteArray sslKey READ sslKeyPem WRITE setSslKey STORED false) + Q_PROPERTY(QByteArray sslCert READ sslCertPem WRITE setSslCert STORED false) + +public: + CertManager(IdentityId id, QObject *parent = 0) : SyncableObject(QString::number(id.toInt()), parent) {} + inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; } + + virtual const QSslKey &sslKey() const = 0; + inline QByteArray sslKeyPem() const { return sslKey().toPem(); } + virtual const QSslCertificate &sslCert() const = 0; + inline QByteArray sslCertPem() const { return sslCert().toPem(); } + +public slots: + inline virtual void setSslKey(const QByteArray &encoded) { emit sslKeySet(encoded); } + inline virtual void setSslCert(const QByteArray &encoded) { emit sslCertSet(encoded); } + +signals: + void sslKeySet(const QByteArray &); + void sslCertSet(const QByteArray &); +}; + +#endif // HAVE_SSL + +#endif // IDENTITY_H diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index c551c246..58b9eda2 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -407,7 +407,7 @@ void SignalProxy::removePeerBySender() { void SignalProxy::objectRenamed(const QString &newname, const QString &oldname) { SyncableObject *syncObject = qobject_cast(sender()); - const QMetaObject *meta = syncObject->metaObject(); + const QMetaObject *meta = syncObject->syncMetaObject(); const QByteArray className(meta->className()); objectRenamed(className, newname, oldname); diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index 248ccc9f..96b159b0 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -34,6 +34,14 @@ SyncableObject::SyncableObject(QObject *parent) { } +SyncableObject::SyncableObject(const QString &objectName, QObject *parent) + : QObject(parent), + _initialized(false), + _allowClientUpdates(false) +{ + setObjectName(objectName); +} + SyncableObject::SyncableObject(const SyncableObject &other, QObject *parent) : QObject(parent), _initialized(other._initialized), diff --git a/src/common/syncableobject.h b/src/common/syncableobject.h index 482470a5..dfe3887d 100644 --- a/src/common/syncableobject.h +++ b/src/common/syncableobject.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _SYNCABLEOBJECT_H_ -#define _SYNCABLEOBJECT_H_ +#ifndef SYNCABLEOBJECT_H +#define SYNCABLEOBJECT_H #include #include @@ -31,6 +31,7 @@ class SyncableObject : public QObject { public: SyncableObject(QObject *parent = 0); + SyncableObject(const QString &objectName, QObject *parent = 0); SyncableObject(const SyncableObject &other, QObject *parent = 0); //! Stores the object's state into a QVariantMap. @@ -61,7 +62,7 @@ public: public slots: virtual void setInitialized(); void requestUpdate(const QVariantMap &properties); - void update(const QVariantMap &properties); + virtual void update(const QVariantMap &properties); protected: void renameObject(const QString &newName); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 77525fb4..c4cd518c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -16,6 +16,7 @@ set(SOURCES corebufferviewconfig.cpp corebufferviewmanager.cpp corecoreinfo.cpp + coreidentity.cpp coreircchannel.cpp coreirclisthelper.cpp corenetwork.cpp @@ -39,6 +40,7 @@ set(MOC_HDRS corebufferviewconfig.h corebufferviewmanager.h corecoreinfo.h + coreidentity.h coreircchannel.h coreirclisthelper.h corenetwork.h diff --git a/src/core/SQL/upgradeSchema.sh b/src/core/SQL/upgradeSchema.sh index 0fcb651b..e67331d9 100755 --- a/src/core/SQL/upgradeSchema.sh +++ b/src/core/SQL/upgradeSchema.sh @@ -12,7 +12,7 @@ fi cd $TARGET_DIR -CURRENT_VERSION=`ls | sort -n | tail -n1` +CURRENT_VERSION=$(ls | sort -n | tail -n1) if [ ! $CURRENT_VERSION ]; then echo "no previous schema found to upgrade from" @@ -22,6 +22,7 @@ fi ((NEW_VERSION=$CURRENT_VERSION + 1)) mkdir $NEW_VERSION -svn add $NEW_VERSION -find $CURRENT_VERSION -depth 1 \! -name "upgrade_*" \! -name ".*" -exec svn mv {} $NEW_VERSION \; -svn cp ${CURRENT_VERSION}/upgrade_999_version.sql $NEW_VERSION +git add $NEW_VERSION +find $CURRENT_VERSION -depth 1 \! -name "upgrade_*" \! -name ".*" -exec git mv {} $NEW_VERSION \; +cp ${CURRENT_VERSION}/upgrade_999_version.sql $NEW_VERSION +git add ${NEW_VERSION}/upgrade_999_version.sql diff --git a/src/core/coreidentity.cpp b/src/core/coreidentity.cpp new file mode 100644 index 00000000..dfad2e96 --- /dev/null +++ b/src/core/coreidentity.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * 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) version 3. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "coreidentity.h" + +#include "coresession.h" +#include "coreusersettings.h" +#include "signalproxy.h" + +CoreIdentity::CoreIdentity(IdentityId id, SignalProxy *proxy, CoreSession *parent) + : Identity(id, parent), + _certManager(new CoreCertManager(this)), + _coreSession(parent) +{ + proxy->synchronize(_certManager); + connect(this, SIGNAL(idSet(IdentityId)), _certManager, SLOT(setId(IdentityId))); +} + +CoreIdentity::CoreIdentity(const Identity &other, SignalProxy *proxy, CoreSession *parent) + : Identity(other, parent), + _certManager(new CoreCertManager(this)), + _coreSession(parent) +{ + proxy->synchronize(_certManager); + connect(this, SIGNAL(idSet(IdentityId)), _certManager, SLOT(setId(IdentityId))); +} + +void CoreIdentity::update(const QVariantMap &properties) { + SyncableObject::update(properties); + save(); +} + +void CoreIdentity::save() { + CoreUserSettings s(_coreSession->user()); + s.storeIdentity(*this); +} + +void CoreIdentity::setSslKey(const QByteArray &encoded) { + QSslKey key(encoded, QSsl::Rsa); + if(key.isNull()) + key = QSslKey(encoded, QSsl::Dsa); + setSslKey(key); +} + +void CoreIdentity::setSslCert(const QByteArray &encoded) { + setSslCert(QSslCertificate(encoded)); +} + + +// ======================================== +// CoreCertManager +// ======================================== +CoreCertManager::CoreCertManager(CoreIdentity *identity) + : CertManager(identity->id(), identity), + _identity(identity) +{ + setAllowClientUpdates(true); +} + +void CoreCertManager::setSslKey(const QByteArray &encoded) { + identity()->setSslKey(encoded); + CertManager::setSslKey(encoded); +} + +void CoreCertManager::setSslCert(const QByteArray &encoded) { + identity()->setSslCert(encoded); + CertManager::setSslCert(encoded); +} + +void CoreCertManager::setId(IdentityId id) { + renameObject(QString::number(id.toInt())); +} diff --git a/src/core/coreidentity.h b/src/core/coreidentity.h new file mode 100644 index 00000000..f22ea441 --- /dev/null +++ b/src/core/coreidentity.h @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * 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) version 3. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef COREIDENTITY_H +#define COREIDENTITY_H + +#include "identity.h" + +#include +#include + +class CoreCertManager; +class CoreSession; +class SignalProxy; + +class CoreIdentity : public Identity { + Q_OBJECT + +public: + CoreIdentity(IdentityId id, SignalProxy *proxy, CoreSession *parent); + CoreIdentity(const Identity &other, SignalProxy *proxy, CoreSession *parent); + + inline const QSslKey &sslKey() const { return _sslKey; } + inline void setSslKey(const QSslKey &key) { _sslKey = key; } + void setSslKey(const QByteArray &encoded); + inline const QSslCertificate &sslCert() const { return _sslCert; } + inline void setSslCert(const QSslCertificate &cert) { _sslCert = cert; } + void setSslCert(const QByteArray &encoded); + +public slots: + virtual void update(const QVariantMap &properties); + void save(); + +private: + QSslKey _sslKey; + QSslCertificate _sslCert; + + CoreCertManager *_certManager; + CoreSession *_coreSession; +}; + + +// ======================================== +// CoreCertManager +// ======================================== +class CoreCertManager : public CertManager { + Q_OBJECT + +public: + CoreCertManager(CoreIdentity *identity); + + inline CoreIdentity *identity() const { return _identity; } + virtual inline const QSslKey &sslKey() const { return identity()->sslKey(); } + virtual inline const QSslCertificate &sslCert() const { return identity()->sslCert(); } + +public slots: + virtual void setSslKey(const QByteArray &encoded); + virtual void setSslCert(const QByteArray &encoded); + + void setId(IdentityId id); + +private: + CoreIdentity *_identity; +}; + +#endif //COREIDENTITY_H diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index b3cbfc09..8911cb0e 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -23,7 +23,7 @@ #include "core.h" #include "coresession.h" -#include "identity.h" +#include "coreidentity.h" #include "ircserverhandler.h" #include "userinputhandler.h" @@ -133,7 +133,7 @@ void CoreNetwork::connectToIrc(bool reconnecting) { qWarning() << "Server list empty, ignoring connect request!"; return; } - Identity *identity = identityPtr(); + CoreIdentity *identity = identityPtr(); if(!identity) { qWarning() << "Invalid identity configures, ignoring connect request!"; return; @@ -285,7 +285,7 @@ void CoreNetwork::socketInitialized() { return; #endif - Identity *identity = identityPtr(); + CoreIdentity *identity = identityPtr(); if(!identity) { qCritical() << "Identity invalid!"; disconnectFromIrc(); diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 8cbe9b81..a0b7fee8 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -35,7 +35,7 @@ #include "coresession.h" -class Identity; +class CoreIdentity; class IrcServerHandler; class UserInputHandler; class CtcpHandler; @@ -48,7 +48,7 @@ public: ~CoreNetwork(); inline virtual const QMetaObject *syncMetaObject() const { return &Network::staticMetaObject; } - inline Identity *identityPtr() const { return coreSession()->identity(identity()); } + inline CoreIdentity *identityPtr() const { return coreSession()->identity(identity()); } inline CoreSession *coreSession() const { return _coreSession; } inline IrcServerHandler *ircServerHandler() const { return _ircServerHandler; } diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 2e9184c5..2649824a 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -30,10 +30,10 @@ #include "coreirclisthelper.h" #include "storage.h" +#include "coreidentity.h" #include "corenetwork.h" #include "ircuser.h" #include "ircchannel.h" -#include "identity.h" #include "util.h" #include "coreusersettings.h" @@ -64,7 +64,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->attachSignal(this, SIGNAL(identityCreated(const Identity &))); p->attachSignal(this, SIGNAL(identityRemoved(IdentityId))); - p->attachSlot(SIGNAL(createIdentity(const Identity &)), this, SLOT(createIdentity(const Identity &))); + p->attachSlot(SIGNAL(createIdentity(const Identity &, const QVariantMap &)), this, SLOT(createIdentity(const Identity &, const QVariantMap &))); p->attachSlot(SIGNAL(removeIdentity(IdentityId)), this, SLOT(removeIdentity(IdentityId))); p->attachSignal(this, SIGNAL(networkCreated(NetworkId))); @@ -117,7 +117,7 @@ CoreNetwork *CoreSession::network(NetworkId id) const { return 0; } -Identity *CoreSession::identity(IdentityId id) const { +CoreIdentity *CoreSession::identity(IdentityId id) const { if(_identities.contains(id)) return _identities[id]; return 0; } @@ -126,27 +126,13 @@ void CoreSession::loadSettings() { CoreUserSettings s(user()); foreach(IdentityId id, s.identityIds()) { - Identity *i = new Identity(s.identity(id), this); - if(!i->isValid()) { - qWarning() << "Invalid identity! Removing..."; - s.removeIdentity(id); - delete i; - continue; - } - if(_identities.contains(i->id())) { - qWarning() << "Duplicate identity, ignoring!"; - delete i; - continue; - } - connect(i, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &))); - _identities[i->id()] = i; - signalProxy()->synchronize(i); + createIdentity(s.identity(id)); } if(!_identities.count()) { - Identity i(1); - i.setToDefaults(); - i.setIdentityName(tr("Default Identity")); - createIdentity(i); + Identity identity; + identity.setToDefaults(); + identity.setIdentityName(tr("Default Identity")); + createIdentity(identity); } foreach(NetworkInfo info, Core::networks(user())) { @@ -279,21 +265,35 @@ void CoreSession::scriptRequest(QString script) { /*** Identity Handling ***/ -void CoreSession::createIdentity(const Identity &id) { - // find free ID - int i; - for(i = 1; i <= _identities.count(); i++) { - if(!_identities.keys().contains(i)) break; +void CoreSession::createIdentity(const Identity &identity, const QVariantMap &additional) { + if(_identities.contains(identity.id())) { + qWarning() << "duplicate Identity:" << identity.id(); + return; } - //qDebug() << "found free id" << i; - Identity *newId = new Identity(id, this); - newId->setId(i); - _identities[i] = newId; - signalProxy()->synchronize(newId); - CoreUserSettings s(user()); - s.storeIdentity(*newId); - connect(newId, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &))); - emit identityCreated(*newId); + + int id = identity.id().toInt(); + bool newId = !identity.isValid(); + CoreIdentity *coreIdentity = new CoreIdentity(identity, signalProxy(), this); + if(additional.contains("KeyPem")) + coreIdentity->setSslKey(additional["KeyPem"].toByteArray()); + if(additional.contains("CertPem")) + coreIdentity->setSslCert(additional["CertPem"].toByteArray()); + if(newId) { + // find free ID + for(id = 1; id <= _identities.count(); id++) { + if(!_identities.keys().contains(id)) + break; + } + coreIdentity->setId(id); + coreIdentity->save(); + } + + _identities[id] = coreIdentity; + qDebug() << id << coreIdentity->id(); + signalProxy()->synchronize(coreIdentity); + + if(newId) + emit identityCreated(*coreIdentity); } void CoreSession::removeIdentity(IdentityId id) { @@ -306,16 +306,6 @@ void CoreSession::removeIdentity(IdentityId id) { } } -void CoreSession::identityUpdated(const QVariantMap &data) { - IdentityId id = data.value("identityId", 0).value(); - if(!id.isValid() || !_identities.contains(id)) { - qWarning() << "Update request for unknown identity received!"; - return; - } - CoreUserSettings s(user()); - s.storeIdentity(*_identities.value(id)); -} - /*** Network Handling ***/ void CoreSession::createNetwork(const NetworkInfo &info_) { diff --git a/src/core/coresession.h b/src/core/coresession.h index 8fa8725b..f8ada9a7 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -33,6 +33,7 @@ class CoreBacklogManager; class CoreBufferViewManager; class CoreIrcListHelper; class Identity; +class CoreIdentity; class NetworkConnection; class CoreNetwork; struct NetworkInfo; @@ -51,7 +52,7 @@ public: inline UserId user() const { return _user; } CoreNetwork *network(NetworkId) const; NetworkConnection *networkConnection(NetworkId) const; - Identity *identity(IdentityId) const; + CoreIdentity *identity(IdentityId) const; QVariant sessionState(); @@ -77,7 +78,7 @@ public slots: //! Create an identity and propagate the changes to the clients. /** \param identity The identity to be created. */ - void createIdentity(const Identity &identity); + void createIdentity(const Identity &identity, const QVariantMap &additional = QVariantMap()); //! Remove identity and propagate that fact to the clients. /** \param identity The identity to be removed. @@ -89,8 +90,8 @@ public slots: */ void createNetwork(const NetworkInfo &info); - //! Remove identity and propagate that fact to the clients. - /** \param identity The identity to be removed. + //! Remove network and propagate that fact to the clients. + /** \param network The id of the network to be removed. */ void removeNetwork(NetworkId network); @@ -145,8 +146,6 @@ private slots: void destroyNetwork(NetworkId); - void identityUpdated(const QVariantMap &); - void storeBufferLastSeenMsg(BufferId buffer, const MsgId &msgId); void scriptRequest(QString script); @@ -165,7 +164,7 @@ private: // QHash _connections; QHash _networks; // QHash _networksToRemove; - QHash _identities; + QHash _identities; BufferSyncer *_bufferSyncer; CoreBacklogManager *_backlogManager; diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 06f968cb..5c0684a2 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -23,7 +23,7 @@ #include "coresession.h" #include "coreirclisthelper.h" -#include "identity.h" +#include "coreidentity.h" #include "ctcphandler.h" #include "ircuser.h" diff --git a/src/core/userinputhandler.cpp b/src/core/userinputhandler.cpp index 8e6896fe..15c89b2a 100644 --- a/src/core/userinputhandler.cpp +++ b/src/core/userinputhandler.cpp @@ -22,7 +22,7 @@ #include "util.h" #include "ctcphandler.h" -#include "identity.h" +#include "coreidentity.h" #include "ircuser.h" #include diff --git a/src/qtui/settingspages/identitiessettingspage.cpp b/src/qtui/settingspages/identitiessettingspage.cpp index 8dd9c0d9..e51fa7aa 100644 --- a/src/qtui/settingspages/identitiessettingspage.cpp +++ b/src/qtui/settingspages/identitiessettingspage.cpp @@ -18,16 +18,22 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "identitiessettingspage.h" + #include +#include +#include #include - -#include "identitiessettingspage.h" +#include #include "client.h" #include "iconloader.h" +#include "signalproxy.h" IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent) - : SettingsPage(tr("General"), tr("Identities"), parent) { + : SettingsPage(tr("General"), tr("Identities"), parent), + _editSsl(false) +{ ui.setupUi(this); ui.renameIdentity->setIcon(BarIcon("edit-rename")); @@ -69,6 +75,12 @@ IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent) connect(ui.nicknameList, SIGNAL(itemSelectionChanged()), this, SLOT(setWidgetStates())); +#ifdef HAVE_SSL + ui.keyAndCertSettings->setCurrentIndex(1); +#else + ui.keyAndCertSettings->setCurrentIndex(0); +#endif + // we would need this if we enabled drag and drop in the nicklist... //connect(ui.nicknameList, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(setWidgetStates())); //connect(ui.nicknameList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(nicklistHasChanged())); @@ -99,18 +111,18 @@ void IdentitiesSettingsPage::coreConnectionStateChanged(bool state) { void IdentitiesSettingsPage::save() { setEnabled(false); - QList toCreate, toUpdate; + QList toCreate, toUpdate; // we need to remove our temporarily created identities. // these are going to be re-added after the core has propagated them back... - QHash::iterator i = identities.begin(); + QHash::iterator i = identities.begin(); while(i != identities.end()) { if((*i)->id() < 0) { - Identity *temp = *i; + CertIdentity *temp = *i; i = identities.erase(i); toCreate.append(temp); ui.identityList->removeItem(ui.identityList->findData(temp->id().toInt())); } else { - if(**i != *Client::identity((*i)->id())) { + if(**i != *Client::identity((*i)->id()) || (*i)->isDirty()) { toUpdate.append(*i); } ++i; @@ -158,10 +170,11 @@ bool IdentitiesSettingsPage::testHasChanged() { } else { if(currentId != 0) { changedIdentities.removeAll(currentId); - Identity temp(currentId, this); + CertIdentity temp(currentId, this); saveToIdentity(&temp); temp.setIdentityName(identities[currentId]->identityName()); - if(temp != *Client::identity(currentId)) changedIdentities.append(currentId); + if(temp != *Client::identity(currentId) || temp.isDirty()) + changedIdentities.append(currentId); } return changedIdentities.count(); } @@ -188,7 +201,10 @@ bool IdentitiesSettingsPage::aboutToSave() { } void IdentitiesSettingsPage::clientIdentityCreated(IdentityId id) { - insertIdentity(new Identity(*Client::identity(id), this)); + CertIdentity *identity = new CertIdentity(*Client::identity(id), this); + identity->enableEditSsl(_editSsl); + insertIdentity(identity); + connect(identity, SIGNAL(sslSettingsUpdated()), this, SLOT(clientIdentityUpdated())); connect(Client::identity(id), SIGNAL(updatedRemotely()), this, SLOT(clientIdentityUpdated())); } @@ -202,10 +218,16 @@ void IdentitiesSettingsPage::clientIdentityUpdated() { qWarning() << "Unknown identity to update:" << clientIdentity->identityName(); return; } - Identity *identity = identities[clientIdentity->id()]; - if(identity->identityName() != clientIdentity->identityName()) renameIdentity(identity->id(), clientIdentity->identityName()); + + CertIdentity *identity = identities[clientIdentity->id()]; + + if(identity->identityName() != clientIdentity->identityName()) + renameIdentity(identity->id(), clientIdentity->identityName()); + identity->update(*clientIdentity); - if(identity->id() == currentId) displayIdentity(identity, true); + + if(identity->id() == currentId) + displayIdentity(identity, true); } void IdentitiesSettingsPage::clientIdentityRemoved(IdentityId id) { @@ -216,7 +238,7 @@ void IdentitiesSettingsPage::clientIdentityRemoved(IdentityId id) { } } -void IdentitiesSettingsPage::insertIdentity(Identity *identity) { +void IdentitiesSettingsPage::insertIdentity(CertIdentity *identity) { IdentityId id = identity->id(); identities[id] = identity; if(id == 1) { @@ -264,7 +286,7 @@ void IdentitiesSettingsPage::on_identityList_currentIndexChanged(int index) { } } -void IdentitiesSettingsPage::displayIdentity(Identity *id, bool dontsave) { +void IdentitiesSettingsPage::displayIdentity(CertIdentity *id, bool dontsave) { if(currentId != 0 && !dontsave && identities.contains(currentId)) { saveToIdentity(identities[currentId]); } @@ -292,10 +314,12 @@ void IdentitiesSettingsPage::displayIdentity(Identity *id, bool dontsave) { ui.kickReason->setText(id->kickReason()); ui.partReason->setText(id->partReason()); ui.quitReason->setText(id->quitReason()); + showKeyState(id->sslKey()); + showCertState(id->sslCert()); } } -void IdentitiesSettingsPage::saveToIdentity(Identity *id) { +void IdentitiesSettingsPage::saveToIdentity(CertIdentity *id) { id->setRealName(ui.realName->text()); QStringList nicks; for(int i = 0; i < ui.nicknameList->count(); i++) { @@ -317,6 +341,8 @@ void IdentitiesSettingsPage::saveToIdentity(Identity *id) { id->setKickReason(ui.kickReason->text()); id->setPartReason(ui.partReason->text()); id->setQuitReason(ui.quitReason->text()); + id->setSslKey(QSslKey(ui.keyTypeLabel->property("sslKey").toByteArray(), (QSsl::KeyAlgorithm)(ui.keyTypeLabel->property("sslKeyType").toInt()))); + id->setSslCert(QSslCertificate(ui.certOrgLabel->property("sslCert").toByteArray())); } void IdentitiesSettingsPage::on_addIdentity_clicked() { @@ -328,7 +354,8 @@ void IdentitiesSettingsPage::on_addIdentity_clicked() { if(!identities.keys().contains(-id.toInt())) break; } id = -id.toInt(); - Identity *newId = new Identity(id, this); + CertIdentity *newId = new CertIdentity(id, this); + newId->enableEditSsl(_editSsl); if(dlg.duplicateId() != 0) { // duplicate newId->update(*identities[dlg.duplicateId()]); @@ -421,9 +448,101 @@ void IdentitiesSettingsPage::on_nickDown_clicked() { } } +void IdentitiesSettingsPage::on_continueUnsecured_clicked() { + _editSsl = true; + + QHash::iterator idIter; + for(idIter = identities.begin(); idIter != identities.end(); idIter++) { + idIter.value()->enableEditSsl(); + } + + ui.keyAndCertSettings->setCurrentIndex(2); +} + +void IdentitiesSettingsPage::on_clearOrLoadKeyButton_clicked() { + QSslKey key; + + if(ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty()) { + QString keyFileName = QFileDialog::getOpenFileName(this, tr("Load a Key"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + QFile keyFile(keyFileName); + keyFile.open(QIODevice::ReadOnly); + QByteArray keyRaw = keyFile.read(2 << 20); + keyFile.close(); + + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 2; j++) { + key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i); + if(!key.isNull()) + goto showKey; + } + } + } + + showKey: + showKeyState(key); + widgetHasChanged(); +} + +void IdentitiesSettingsPage::showKeyState(const QSslKey &key) { + if(key.isNull()) { + ui.keyTypeLabel->setText(tr("No Key loaded")); + ui.clearOrLoadKeyButton->setText(tr("Load")); + } else { + switch(key.algorithm()) { + case QSsl::Rsa: + ui.keyTypeLabel->setText(tr("RSA")); + break; + case QSsl::Dsa: + ui.keyTypeLabel->setText(tr("DSA")); + break; + default: + ui.keyTypeLabel->setText(tr("No Key Loaded")); + } + ui.clearOrLoadKeyButton->setText(tr("Clear")); + } + ui.keyTypeLabel->setProperty("sslKey", key.toPem()); + ui.keyTypeLabel->setProperty("sslKeyType", (int)key.algorithm()); +} + +void IdentitiesSettingsPage::on_clearOrLoadCertButton_clicked() { + QSslCertificate cert; + + if(ui.certOrgLabel->property("sslCert").toByteArray().isEmpty()) { + QString certFileName = QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + QFile certFile(certFileName); + certFile.open(QIODevice::ReadOnly); + QByteArray certRaw = certFile.read(2 << 20); + certFile.close(); + + for(int i = 0; i < 2; i++) { + cert = QSslCertificate(certRaw, (QSsl::EncodingFormat)i); + if(cert.isValid()) + break; + } + } + + showCertState(cert); + widgetHasChanged(); +} + +void IdentitiesSettingsPage::showCertState(const QSslCertificate &cert) { + if(!cert.isValid()) { + ui.certOrgLabel->setText(tr("No Certificate loaded")); + ui.certCNameLabel->setText(tr("No Certificate loaded")); + ui.clearOrLoadCertButton->setText(tr("Load")); + } else { + ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); + ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); + ui.clearOrLoadCertButton->setText(tr("Clear")); + } + ui.certOrgLabel->setProperty("sslCert", cert.toPem()); + } + /*****************************************************************************************/ -CreateIdentityDlg::CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent) : QDialog(parent) { +CreateIdentityDlg::CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent) + : QDialog(parent) +{ ui.setupUi(this); ui.identityList->setModel(model); // now we use the identity list of the main page... Trolltech <3 @@ -449,8 +568,9 @@ void CreateIdentityDlg::on_identityName_textChanged(const QString &text) { /*********************************************************************************************/ -SaveIdentitiesDlg::SaveIdentitiesDlg(const QList &toCreate, const QList &toUpdate, const QList &toRemove, QWidget *parent) - : QDialog(parent) { //, toCreate(tocreate), toUpdate(toupdate), toRemove(toremove) { +SaveIdentitiesDlg::SaveIdentitiesDlg(const QList &toCreate, const QList &toUpdate, const QList &toRemove, QWidget *parent) + : QDialog(parent) +{ ui.setupUi(this); ui.abort->setIcon(SmallIcon("dialog-cancel")); @@ -463,10 +583,10 @@ SaveIdentitiesDlg::SaveIdentitiesDlg(const QList &toCreate, const QL connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(clientEvent())); connect(Client::instance(), SIGNAL(identityRemoved(IdentityId)), this, SLOT(clientEvent())); - foreach(Identity *id, toCreate) { + foreach(CertIdentity *id, toCreate) { Client::createIdentity(*id); } - foreach(Identity *id, toUpdate) { + foreach(CertIdentity *id, toUpdate) { const Identity *cid = Client::identity(id->id()); if(!cid) { qWarning() << "Invalid client identity!"; @@ -475,6 +595,7 @@ SaveIdentitiesDlg::SaveIdentitiesDlg(const QList &toCreate, const QL } connect(cid, SIGNAL(updatedRemotely()), this, SLOT(clientEvent())); Client::updateIdentity(id->id(), id->toVariantMap()); + id->requestUpdateSslSettings(); } foreach(IdentityId id, toRemove) { Client::removeIdentity(id); diff --git a/src/qtui/settingspages/identitiessettingspage.h b/src/qtui/settingspages/identitiessettingspage.h index c0c862bc..9b750e27 100644 --- a/src/qtui/settingspages/identitiessettingspage.h +++ b/src/qtui/settingspages/identitiessettingspage.h @@ -18,10 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _IDENTITIESSETTINGSPAGE_H_ -#define _IDENTITIESSETTINGSPAGE_H_ +#ifndef IDENTITIESSETTINGSPAGE_H +#define IDENTITIESSETTINGSPAGE_H -#include "identity.h" +#include "clientidentity.h" #include "settingspage.h" #include "ui_identitiessettingspage.h" @@ -34,105 +34,109 @@ class QAbstractItemModel; class IdentitiesSettingsPage : public SettingsPage { Q_OBJECT - public: - IdentitiesSettingsPage(QWidget *parent = 0); +public: + IdentitiesSettingsPage(QWidget *parent = 0); - bool aboutToSave(); + bool aboutToSave(); - public slots: - void save(); - void load(); +public slots: + void save(); + void load(); - private slots: - void coreConnectionStateChanged(bool); - void clientIdentityCreated(IdentityId); - void clientIdentityUpdated(); - void clientIdentityRemoved(IdentityId); +private slots: + void coreConnectionStateChanged(bool); + void clientIdentityCreated(IdentityId); + void clientIdentityUpdated(); + void clientIdentityRemoved(IdentityId); - void on_identityList_currentIndexChanged(int index); + void on_identityList_currentIndexChanged(int index); - void on_addIdentity_clicked(); - void on_deleteIdentity_clicked(); - void on_renameIdentity_clicked(); + void on_addIdentity_clicked(); + void on_deleteIdentity_clicked(); + void on_renameIdentity_clicked(); - void on_addNick_clicked(); - void on_deleteNick_clicked(); - void on_renameNick_clicked(); - void on_nickUp_clicked(); - void on_nickDown_clicked(); + void on_addNick_clicked(); + void on_deleteNick_clicked(); + void on_renameNick_clicked(); + void on_nickUp_clicked(); + void on_nickDown_clicked(); - void widgetHasChanged(); - void setWidgetStates(); + void on_continueUnsecured_clicked(); + void on_clearOrLoadKeyButton_clicked(); + void on_clearOrLoadCertButton_clicked(); + void widgetHasChanged(); + void setWidgetStates(); - private: - Ui::IdentitiesSettingsPage ui; +private: + Ui::IdentitiesSettingsPage ui; - QHash identities; - IdentityId currentId; + QHash identities; + IdentityId currentId; - QList changedIdentities; // for setting the widget changed state - QList deletedIdentities; + QList changedIdentities; // for setting the widget changed state + QList deletedIdentities; - void insertIdentity(Identity *identity); - void removeIdentity(Identity *identity); - void renameIdentity(IdentityId id, const QString &newName); - void displayIdentity(Identity *, bool dontsave = false); - void saveToIdentity(Identity *); + bool _editSsl; - bool testHasChanged(); + void insertIdentity(CertIdentity *identity); + void removeIdentity(Identity *identity); + void renameIdentity(IdentityId id, const QString &newName); + void displayIdentity(CertIdentity *, bool dontsave = false); + void saveToIdentity(CertIdentity *); + + void showKeyState(const QSslKey &key); + void showCertState(const QSslCertificate &cert); + + bool testHasChanged(); }; class CreateIdentityDlg : public QDialog { Q_OBJECT - public: - CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0); +public: + CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0); - QString identityName() const; - IdentityId duplicateId() const; + QString identityName() const; + IdentityId duplicateId() const; - private slots: - void on_identityName_textChanged(const QString &text); +private slots: + void on_identityName_textChanged(const QString &text); - private: - Ui::CreateIdentityDlg ui; +private: + Ui::CreateIdentityDlg ui; }; class SaveIdentitiesDlg : public QDialog { Q_OBJECT - public: - SaveIdentitiesDlg(const QList &toCreate, const QList &toUpdate, const QList &toRemove, QWidget *parent = 0); - - private slots: - void clientEvent(); - - private: - Ui::SaveIdentitiesDlg ui; +public: + SaveIdentitiesDlg(const QList &toCreate, const QList &toUpdate, const QList &toRemove, QWidget *parent = 0); - //QList toCreate, toUpdate; - //QList toRemove; +private slots: + void clientEvent(); - int numevents, rcvevents; +private: + Ui::SaveIdentitiesDlg ui; + int numevents, rcvevents; }; class NickEditDlg : public QDialog { Q_OBJECT - public: - NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0); +public: + NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0); - QString nick() const; + QString nick() const; - private slots: - void on_nickEdit_textChanged(const QString &); +private slots: + void on_nickEdit_textChanged(const QString &); - private: - Ui::NickEditDlg ui; +private: + Ui::NickEditDlg ui; - QString oldNick; - QStringList existing; + QString oldNick; + QStringList existing; }; diff --git a/src/qtui/settingspages/identitiessettingspage.ui b/src/qtui/settingspages/identitiessettingspage.ui index d88df569..cb88372d 100644 --- a/src/qtui/settingspages/identitiessettingspage.ui +++ b/src/qtui/settingspages/identitiessettingspage.ui @@ -5,594 +5,884 @@ 0 0 - 602 - 450 + 430 + 492 - + - + - + + + QComboBox::InsertAtBottom + + + true + + + + + + + Rename Identity + + + ... + + + + :/22x22/actions/oxygen/22x22/actions/edit-rename.png:/22x22/actions/oxygen/22x22/actions/edit-rename.png + + + + 22 + 22 + + + + + + + + Add Identity + + + Add... + + + + :/22x22/actions/oxygen/22x22/actions/list-add-user.png:/22x22/actions/oxygen/22x22/actions/list-add-user.png + + + + 22 + 22 + + + + Qt::ToolButtonIconOnly + + + + + + + Remove Identity + + + ... + + + + :/22x22/actions/oxygen/22x22/actions/list-remove-user.png:/22x22/actions/oxygen/22x22/actions/list-remove-user.png + + + + 22 + 22 + + + + + + + + + + 0 + + + + + 0 + 0 + 400 + 399 + + + + General + + - - - QComboBox::InsertAtBottom + + + + + Real Name: + + + + + + + The "Real Name" is shown in /whois. + + + + + + + + + Nicknames - - true + + + + + + 1 + 0 + + + + true + + + false + + + QAbstractItemView::NoDragDrop + + + QAbstractItemView::SelectRows + + + + + + + + + + 0 + 0 + + + + Add Nickname + + + &Add... + + + + :/16x16/actions/oxygen/16x16/actions/list-add.png:/16x16/actions/oxygen/16x16/actions/list-add.png + + + + 16 + 16 + + + + + + + + + 0 + 0 + + + + Remove Nickname + + + Remove + + + + :/16x16/actions/oxygen/16x16/actions/edit-delete.png:/16x16/actions/oxygen/16x16/actions/edit-delete.png + + + + + + + + 0 + 0 + + + + Rename Identity + + + Re&name... + + + + :/16x16/actions/oxygen/16x16/actions/edit-rename.png:/16x16/actions/oxygen/16x16/actions/edit-rename.png + + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + Move upwards in list + + + ... + + + + :/16x16/actions/oxygen/16x16/actions/go-up.png:/16x16/actions/oxygen/16x16/actions/go-up.png + + + + + + + Move downwards in list + + + ... + + + + :/16x16/actions/oxygen/16x16/actions/go-down.png:/16x16/actions/oxygen/16x16/actions/go-down.png + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + Qt::Vertical + + + + 124 + 76 + + + + + + + + + + + + + + + 0 + 0 + 400 + 399 + + + + A&way + + + + + + Default Away Settings + + + + + + + false + + + Nick to be used when being away + + + + + + + Default away reason + + + Away Reason + + + + + + + false + + + Default away reason + + + + + + + false + + + Nick to be used when being away + + + Away Nick + + + + + + - + - Rename Identity + Set away when all clients have detached from the core - - ... + + Away On Detach - - - :/22x22/actions/oxygen/22x22/actions/edit-rename.png:/22x22/actions/oxygen/22x22/actions/edit-rename.png + + true - - - 22 - 22 - + + false + + + + + + + Override default away reason for auto-away on detach + + + Away Reason + + + + + + + false + + + Override default away reason for auto-away on detach + + + + + + - - - Add Identity + + + false - - Add... + + Not implemented yet - - - :/22x22/actions/oxygen/22x22/actions/list-add-user.png:/22x22/actions/oxygen/22x22/actions/list-add-user.png + + Away On Idle - - - 22 - 22 - + + true - - Qt::ToolButtonIconOnly + + false + + + + + + + Set away after + + + + + + + + + + minutes of being idle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Away Reason + + + + + + + false + + + + + + - - - Remove Identity - - - ... + + + Qt::Vertical - - - :/22x22/actions/oxygen/22x22/actions/list-remove-user.png:/22x22/actions/oxygen/22x22/actions/list-remove-user.png - - + - 22 - 22 + 20 + 40 - + - - - - - 0 - - - - - 0 - 0 - 570 - 355 - - - - General - - + + + + + 0 + 0 + 400 + 399 + + + + Advanced + + + + - - - - - Real Name: - - - - - - - The "Real Name" is shown in /whois. - - - - + + + Ident: + + - - - Nicknames + + + The "ident" is part of your hostmask and, together with your host, uniquely identifies you within the IRC network. - - - - - - 1 - 0 - - - - true - - - false + + + + + + + + Messages + + + + + + + + Part Reason: - - QAbstractItemView::NoDragDrop + + + + + + + + + + + + Quit Reason: - - QAbstractItemView::SelectRows + + + + + + + + + Kick Reason: - - + + + + + + + + + + + + 0 + + + 0 + + + + + 0 + + + + + + + - - - - 0 - 0 - - - - Add Nickname - + - &Add... + You need an SSL Capable Client to edit your Cores SSL Key and Certificate - - - :/16x16/actions/oxygen/16x16/actions/list-add.png:/16x16/actions/oxygen/16x16/actions/list-add.png + + Qt::AlignCenter - - - 16 - 16 - + + true + + + + + + + + + 0 + + + + + + + - - - - 0 - 0 - - - - Remove Nickname - + - Remove - - - - :/16x16/actions/oxygen/16x16/actions/edit-delete.png:/16x16/actions/oxygen/16x16/actions/edit-delete.png - - - - - - - - 0 - 0 - - - - Rename Identity + Warning: you are not connected with a secured connection to the Quassel Core! +Proceeding will cause an unencrypted transfer of your SSL Key and SSL Certificate! - - Re&name... + + Qt::AlignCenter - - - :/16x16/actions/oxygen/16x16/actions/edit-rename.png:/16x16/actions/oxygen/16x16/actions/edit-rename.png + + true - + - + Qt::Horizontal - 0 + 40 20 - - - Move upwards in list - + - ... - - - - :/16x16/actions/oxygen/16x16/actions/go-up.png:/16x16/actions/oxygen/16x16/actions/go-up.png + continue - - - Move downwards in list + + + Qt::Horizontal + + + 40 + 20 + + + + + + + + + + + + + + + 0 + 0 + 360 + 173 + + + + + 0 + + + 0 + + + + + + + + Use SSL Key + + + false + + + false + + + + + + - ... + Key Type: - - - :/16x16/actions/oxygen/16x16/actions/go-down.png:/16x16/actions/oxygen/16x16/actions/go-down.png + + + + + + No Key loaded - + Qt::Horizontal - 0 + 40 20 + + + + Load + + + - - - - Qt::Vertical - - - - 124 - 76 - - - - - - - - - - - - - - 0 - 0 - 570 - 355 - - - - A&way - - - - - - Default Away Settings - - - - - - - - false - - - Nick to be used when being away - - - - - - - Default away reason - - - Away Reason - - - - - - - false - - - Default away reason - - - - - - - false - - - Nick to be used when being away - - - Away Nick - - - - - - - - - - - - Set away when all clients have detached from the core - - - Away On Detach - - - true - - - false - - - - - - - - Override default away reason for auto-away on detach - - - Away Reason - - - - - - - false - - - Override default away reason for auto-away on detach - - - - - - - - - - - - false - - - Not implemented yet - - - Away On Idle - - - true - - - false - - - - - - - - Set away after - - - - - - + + + + + + Use SSL Certificate + + + + 0 + - - - minutes of being idle + + + 0 - + + + + 8 + + + + + Organisation: + + + + + + + No Certificate loaded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 8 + + + + + CommonName: + + + + + + + No Certificate loaded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Away Reason - - - - - - - false - - + + + + + Load + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - 0 - 570 - 355 - - - - Advanced - - - - - - - - Ident: - - - - - - - The "ident" is part of your hostmask and, together with your host, uniquely identifies you within the IRC network. - - - - - - Messages - - - - - - - - Part Reason: - - - - - - - - - - - - - Quit Reason: - - - - - - - - - - Kick Reason: - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + @@ -663,12 +953,12 @@ setEnabled(bool) - 126 - 327 + 157 + 382 - 315 - 328 + 454 + 382 @@ -679,12 +969,12 @@ setEnabled(bool) - 33 - 214 + 64 + 256 - 204 - 218 + 343 + 256 diff --git a/src/uisupport/networkmodelactionprovider.cpp b/src/uisupport/networkmodelactionprovider.cpp index 12fd2e4b..e490992b 100644 --- a/src/uisupport/networkmodelactionprovider.cpp +++ b/src/uisupport/networkmodelactionprovider.cpp @@ -27,7 +27,7 @@ #include "buffermodel.h" #include "buffersettings.h" #include "iconloader.h" -#include "identity.h" +#include "clientidentity.h" #include "network.h" #include "util.h" diff --git a/version.inc b/version.inc index f445fd7b..431b92e0 100644 --- a/version.inc +++ b/version.inc @@ -1,9 +1,9 @@ //! This is the fallback version number in case we can't autogenerate one baseVersion = "0.3.1"; -protocolVersion = 8; //< Version of the client/core protocol -coreNeedsProtocol = 8; //< Minimum protocol version the core needs -clientNeedsProtocol = 8; //< Minimum protocol version the client needs +protocolVersion = 9; //< Version of the client/core protocol +coreNeedsProtocol = 9; //< Minimum protocol version the core needs +clientNeedsProtocol = 9; //< Minimum protocol version the client needs distCommittish = $Format:%H$ distCommitDate = $Format:%at$ -- 2.20.1