1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "coreidentity.h"
23 #include "coresession.h"
24 #include "coreusersettings.h"
25 #include "signalproxy.h"
27 CoreIdentity::CoreIdentity(IdentityId id, SignalProxy *proxy, CoreSession *parent)
28 : Identity(id, parent),
29 _certManager(new CoreCertManager(this)),
32 proxy->synchronize(_certManager);
33 connect(this, SIGNAL(idSet(IdentityId)), _certManager, SLOT(setId(IdentityId)));
36 CoreIdentity::CoreIdentity(const Identity &other, SignalProxy *proxy, CoreSession *parent)
37 : Identity(other, parent),
38 _certManager(new CoreCertManager(this)),
41 proxy->synchronize(_certManager);
42 connect(this, SIGNAL(idSet(IdentityId)), _certManager, SLOT(setId(IdentityId)));
45 void CoreIdentity::update(const QVariantMap &properties) {
46 SyncableObject::update(properties);
50 void CoreIdentity::save() {
51 CoreUserSettings s(_coreSession->user());
52 s.storeIdentity(*this);
55 void CoreIdentity::setSslKey(const QByteArray &encoded) {
56 QSslKey key(encoded, QSsl::Rsa);
58 key = QSslKey(encoded, QSsl::Dsa);
62 void CoreIdentity::setSslCert(const QByteArray &encoded) {
63 setSslCert(QSslCertificate(encoded));
67 // ========================================
69 // ========================================
70 CoreCertManager::CoreCertManager(CoreIdentity *identity)
71 : CertManager(identity->id(), identity),
74 setAllowClientUpdates(true);
77 void CoreCertManager::setSslKey(const QByteArray &encoded) {
78 identity()->setSslKey(encoded);
79 CertManager::setSslKey(encoded);
82 void CoreCertManager::setSslCert(const QByteArray &encoded) {
83 identity()->setSslCert(encoded);
84 CertManager::setSslCert(encoded);
87 void CoreCertManager::setId(IdentityId id) {
88 renameObject(QString::number(id.toInt()));