Checking whether a initSetMethod exists before bluntly invoking it. (fixes a new...
[quassel.git] / src / common / identity.h
index bd1eaa5..6345046 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -21,6 +21,7 @@
 #ifndef IDENTITY_H
 #define IDENTITY_H
 
+#include <QByteArray>
 #include <QDataStream>
 #include <QMetaType>
 #include <QString>
@@ -30,6 +31,7 @@
 #include "syncableobject.h"
 
 class Identity : public SyncableObject {
+  SYNCABLE_OBJECT
   Q_OBJECT
 
   Q_PROPERTY(IdentityId identityId READ id WRITE setId STORED false)
@@ -55,10 +57,12 @@ 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);
-  bool operator!=(const Identity &other);
+  bool operator==(const Identity &other) const;
+  bool operator!=(const Identity &other) const;
 
   inline bool isValid() const { return id().isValid(); }
 
@@ -103,28 +107,28 @@ public slots:
   void setPartReason(const QString &reason);
   void setQuitReason(const QString &reason);
 
-  void update(const Identity &other);
+  void copyFrom(const Identity &other);
 
 signals:
   void idSet(IdentityId id);
-  void identityNameSet(const QString &name);
-  void realNameSet(const QString &realName);
+//   void identityNameSet(const QString &name);
+//   void realNameSet(const QString &realName);
   void nicksSet(const QStringList &nicks);
-  void awayNickSet(const QString &awayNick);
-  void awayNickEnabledSet(bool);
-  void awayReasonSet(const QString &awayReason);
-  void awayReasonEnabledSet(bool);
-  void autoAwayEnabledSet(bool);
-  void autoAwayTimeSet(int);
-  void autoAwayReasonSet(const QString &);
-  void autoAwayReasonEnabledSet(bool);
-  void detachAwayEnabledSet(bool);
-  void detachAwayReasonSet(const QString &);
-  void detachAwayReasonEnabledSet(bool);
-  void identSet(const QString &);
-  void kickReasonSet(const QString &);
-  void partReasonSet(const QString &);
-  void quitReasonSet(const QString &);
+//   void awayNickSet(const QString &awayNick);
+//   void awayNickEnabledSet(bool);
+//   void awayReasonSet(const QString &awayReason);
+//   void awayReasonEnabledSet(bool);
+//   void autoAwayEnabledSet(bool);
+//   void autoAwayTimeSet(int);
+//   void autoAwayReasonSet(const QString &);
+//   void autoAwayReasonEnabledSet(bool);
+//   void detachAwayEnabledSet(bool);
+//   void detachAwayReasonSet(const QString &);
+//   void detachAwayReasonEnabledSet(bool);
+//   void identSet(const QString &);
+//   void kickReasonSet(const QString &);
+//   void partReasonSet(const QString &);
+//   void quitReasonSet(const QString &);
 
 private:
   IdentityId _identityId;
@@ -144,6 +148,8 @@ private:
   QString _ident, _kickReason, _partReason, _quitReason;
 
   void init();
+  QString defaultNick();
+  QString defaultRealName();
 
   friend QDataStream &operator>>(QDataStream &in, Identity &identity);
 };
@@ -153,4 +159,30 @@ QDataStream &operator>>(QDataStream &in, Identity &identity);
 
 Q_DECLARE_METATYPE(Identity)
 
-#endif
+#ifdef HAVE_SSL
+#include <QSslKey>
+#include <QSslCertificate>
+
+class CertManager : public SyncableObject {
+  SYNCABLE_OBJECT
+  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) { SYNC(ARG(encoded)) }
+  inline virtual void setSslCert(const QByteArray &encoded) { SYNC(ARG(encoded)) }
+};
+
+#endif // HAVE_SSL
+
+#endif // IDENTITY_H