Prevent ChatView from scrolling up 1px on buffer switch, fixes #544
[quassel.git] / src / client / clientsettings.h
index 919084e..aa0f0d6 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  *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _CLIENTSETTINGS_H_
-#define _CLIENTSETTINGS_H_
+#ifndef CLIENTSETTINGS_H
+#define CLIENTSETTINGS_H
 
 #include "settings.h"
-#include "types.h"
 
-class ClientSettings : public Settings {
+#include "types.h"
 
-  public:
-    virtual ~ClientSettings();
+class QHostAddress;
+class QSslSocket;
 
-  protected:
-    ClientSettings(QString group = "General");
+class ClientSettings : public Settings {
+public:
+  virtual ~ClientSettings();
 
+protected:
+  ClientSettings(QString group = "General");
 };
 
+// ========================================
+//  CoreAccountSettings
+// ========================================
+
 // Deriving from CoreAccountSettings:
 // MySettings() : CoreAccountSettings("MyGroup") {};
 // Then use accountValue() / setAccountValue() to retrieve/store data associated to the currently
@@ -42,30 +48,77 @@ class ClientSettings : public Settings {
 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
 
 class CoreAccountSettings : public ClientSettings {
+public:
+  // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
+  CoreAccountSettings(const QString &subgroup = "General");
+
+  virtual void notify(const QString &key, QObject *receiver, const char *slot);
+
+  QList<AccountId> knownAccounts();
+  AccountId lastAccount();
+  void setLastAccount(AccountId);
+  AccountId autoConnectAccount();
+  void setAutoConnectAccount(AccountId);
+
+  void storeAccountData(AccountId id, const QVariantMap &data);
+  QVariantMap retrieveAccountData(AccountId);
+  void removeAccount(AccountId);
+
+  void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
+  QHash<int, BufferId> jumpKeyMap();
 
-  public:
-    // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
-    CoreAccountSettings(const QString &subgroup = "General");
+protected:
+  void setAccountValue(const QString &key, const QVariant &data);
+  QVariant accountValue(const QString &key, const QVariant &def = QVariant());
 
-    QList<AccountId> knownAccounts();
-    AccountId lastAccount();
-    void setLastAccount(AccountId);
-    AccountId autoConnectAccount();
-    void setAutoConnectAccount(AccountId);
+private:
+  QString _subgroup;
+};
+
+// ========================================
+//  NotificationSettings
+// ========================================
+class NotificationSettings : public ClientSettings {
+public:
+  enum HighlightNickType {
+    NoNick = 0x00,
+    CurrentNick= 0x01,
+    AllNicks = 0x02
+  };
+
+  NotificationSettings();
 
-    void storeAccountData(AccountId id, const QVariantMap &data);
-    QVariantMap retrieveAccountData(AccountId);
-    void removeAccount(AccountId);
+  inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
+  inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
+  inline void remove(const QString &key) { removeLocalKey(key); }
 
-    void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
-    QHash<int, BufferId> jumpKeyMap();
+  void setHighlightList(const QVariantList &highlightList);
+  QVariantList highlightList();
 
-  protected:
-    void setAccountValue(const QString &key, const QVariant &data);
-    QVariant accountValue(const QString &key, const QVariant &def = QVariant());
+  void setHighlightNick(HighlightNickType);
+  HighlightNickType highlightNick();
+
+  void setNicksCaseSensitive(bool);
+  bool nicksCaseSensitive();
+};
 
-  private:
-    QString _subgroup;
+
+// ========================================
+//  KnownHostsSettings
+// ========================================
+class KnownHostsSettings : public ClientSettings {
+public:
+  KnownHostsSettings();
+
+  QByteArray knownDigest(const QHostAddress &address);
+  void saveKnownHost(const QHostAddress &address, const QByteArray &certDigest);
+  bool isKnownHost(const QHostAddress &address, const QByteArray &certDigest);
+
+#ifdef HAVE_SSL
+  QByteArray knownDigest(const QSslSocket *socket);
+  void saveKnownHost(const QSslSocket *socket);
+  bool isKnownHost(const QSslSocket *socket);
+#endif
 };
 
 #endif