1 /***************************************************************************
2 * Copyright (C) 2005-2014 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "coreidentity.h"
23 #include "signalproxy.h"
25 INIT_SYNCABLE_OBJECT(CoreIdentity)
26 CoreIdentity::CoreIdentity(IdentityId id, QObject *parent)
27 : Identity(id, parent)
33 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
34 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
39 CoreIdentity::CoreIdentity(const Identity &other, QObject *parent)
40 : Identity(other, parent)
46 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
47 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
52 CoreIdentity::CoreIdentity(const CoreIdentity &other, QObject *parent)
53 : Identity(other, parent)
55 , _sslKey(other._sslKey),
56 _sslCert(other._sslCert),
61 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
62 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
67 void CoreIdentity::synchronize(SignalProxy *proxy)
69 proxy->synchronize(this);
71 proxy->synchronize(&_certManager);
77 void CoreIdentity::setSslKey(const QByteArray &encoded)
79 QSslKey key(encoded, QSsl::Rsa);
81 key = QSslKey(encoded, QSsl::Dsa);
86 void CoreIdentity::setSslCert(const QByteArray &encoded)
88 setSslCert(QSslCertificate(encoded));
94 CoreIdentity &CoreIdentity::operator=(const CoreIdentity &identity)
96 Identity::operator=(identity);
98 _sslKey = identity._sslKey;
99 _sslCert = identity._sslCert;
106 // ========================================
108 // ========================================
109 INIT_SYNCABLE_OBJECT(CoreCertManager)
110 CoreCertManager::CoreCertManager(CoreIdentity &identity)
111 : CertManager(identity.id()),
114 setAllowClientUpdates(true);
118 void CoreCertManager::setId(IdentityId id)
120 renameObject(QString::number(id.toInt()));
124 void CoreCertManager::setSslKey(const QByteArray &encoded)
126 identity.setSslKey(encoded);
127 CertManager::setSslKey(encoded);
131 void CoreCertManager::setSslCert(const QByteArray &encoded)
133 identity.setSslCert(encoded);
134 CertManager::setSslCert(encoded);