Finalizing changes to the identities interface -> breaking protocol
[quassel.git] / src / core / coreidentity.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #ifndef COREIDENTITY_H
22 #define COREIDENTITY_H
23
24 #include "identity.h"
25
26 #include <QSslKey>
27 #include <QSslCertificate>
28
29 class CoreCertManager;
30 class CoreSession;
31 class SignalProxy;
32
33 class CoreIdentity : public Identity {
34   Q_OBJECT
35
36 public:
37   CoreIdentity(IdentityId id, SignalProxy *proxy, CoreSession *parent);
38   CoreIdentity(const Identity &other, SignalProxy *proxy, CoreSession *parent);
39
40   inline const QSslKey &sslKey() const { return _sslKey; }
41   inline void setSslKey(const QSslKey &key) { _sslKey = key; }
42   void setSslKey(const QByteArray &encoded);
43   inline const QSslCertificate &sslCert() const { return _sslCert; }
44   inline void setSslCert(const QSslCertificate &cert) { _sslCert = cert; }
45   void setSslCert(const QByteArray &encoded);
46
47 public slots:
48   virtual void update(const QVariantMap &properties);
49   void save();
50
51 private:
52   QSslKey _sslKey;
53   QSslCertificate _sslCert;
54
55   CoreCertManager *_certManager;
56   CoreSession *_coreSession;
57 };
58
59
60 // ========================================
61 //  CoreCertManager
62 // ========================================
63 class CoreCertManager : public CertManager {
64   Q_OBJECT
65
66 public:
67   CoreCertManager(CoreIdentity *identity);
68
69   inline CoreIdentity *identity() const { return _identity; }
70   virtual inline const QSslKey &sslKey() const { return identity()->sslKey(); }
71   virtual inline const QSslCertificate &sslCert() const { return identity()->sslCert(); }
72
73 public slots:
74   virtual void setSslKey(const QByteArray &encoded);
75   virtual void setSslCert(const QByteArray &encoded);
76
77   void setId(IdentityId id);
78
79 private:
80   CoreIdentity *_identity;
81 };
82
83 #endif //COREIDENTITY_H