Providing proper defaults for nick and realname on Mac OS using CoreServices
[quassel.git] / src / common / identity.h
index bd1eaa5..3e9a560 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>
@@ -55,10 +56,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,7 +106,7 @@ 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);
@@ -144,6 +147,8 @@ private:
   QString _ident, _kickReason, _partReason, _quitReason;
 
   void init();
+  QString defaultNick();
+  QString defaultRealName();
 
   friend QDataStream &operator>>(QDataStream &in, Identity &identity);
 };
@@ -153,4 +158,33 @@ QDataStream &operator>>(QDataStream &in, Identity &identity);
 
 Q_DECLARE_METATYPE(Identity)
 
-#endif
+#ifdef HAVE_SSL
+#include <QSslKey>
+#include <QSslCertificate>
+
+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