Make all CoreAccountSettingsPage config accessible via CoreAccountSettings
[quassel.git] / src / client / clientsettings.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 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 CLIENTSETTINGS_H
22 #define CLIENTSETTINGS_H
23
24 #include "settings.h"
25
26 #include "types.h"
27
28 class QHostAddress;
29 class QSslSocket;
30
31 class ClientSettings : public Settings {
32 public:
33   virtual ~ClientSettings();
34
35 protected:
36   ClientSettings(QString group = "General");
37 };
38
39 // ========================================
40 //  CoreAccountSettings
41 // ========================================
42
43 // Deriving from CoreAccountSettings:
44 // MySettings() : CoreAccountSettings("MyGroup") {};
45 // Then use accountValue() / setAccountValue() to retrieve/store data associated to the currently
46 // connected account. This is stored in CoreAccounts/$ACCID/MyGroup/$KEY) then.
47 //
48 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
49
50 class CoreAccountSettings : public ClientSettings {
51 public:
52   // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
53   CoreAccountSettings(const QString &subgroup = "General");
54
55   virtual void notify(const QString &key, QObject *receiver, const char *slot);
56
57   QList<AccountId> knownAccounts();
58   AccountId lastAccount();
59   void setLastAccount(AccountId);
60   AccountId autoConnectAccount();
61   void setAutoConnectAccount(AccountId);
62   bool autoConnectOnStartup();
63   void setAutoConnectOnStartup(bool);
64   bool autoConnectToFixedAccount();
65   void setAutoConnectToFixedAccount(bool);
66
67   void storeAccountData(AccountId id, const QVariantMap &data);
68   QVariantMap retrieveAccountData(AccountId);
69   void removeAccount(AccountId);
70
71   void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
72   QHash<int, BufferId> jumpKeyMap();
73
74 protected:
75   void setAccountValue(const QString &key, const QVariant &data);
76   QVariant accountValue(const QString &key, const QVariant &def = QVariant());
77
78 private:
79   QString _subgroup;
80 };
81
82 // ========================================
83 //  NotificationSettings
84 // ========================================
85 class NotificationSettings : public ClientSettings {
86 public:
87   enum HighlightNickType {
88     NoNick = 0x00,
89     CurrentNick= 0x01,
90     AllNicks = 0x02
91   };
92
93   NotificationSettings();
94
95   inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
96   inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
97   inline void remove(const QString &key) { removeLocalKey(key); }
98
99   void setHighlightList(const QVariantList &highlightList);
100   QVariantList highlightList();
101
102   void setHighlightNick(HighlightNickType);
103   HighlightNickType highlightNick();
104
105   void setNicksCaseSensitive(bool);
106   bool nicksCaseSensitive();
107 };
108
109
110 // ========================================
111 //  KnownHostsSettings
112 // ========================================
113 class KnownHostsSettings : public ClientSettings {
114 public:
115   KnownHostsSettings();
116
117   QByteArray knownDigest(const QHostAddress &address);
118   void saveKnownHost(const QHostAddress &address, const QByteArray &certDigest);
119   bool isKnownHost(const QHostAddress &address, const QByteArray &certDigest);
120
121 #ifdef HAVE_SSL
122   QByteArray knownDigest(const QSslSocket *socket);
123   void saveKnownHost(const QSslSocket *socket);
124   bool isKnownHost(const QSslSocket *socket);
125 #endif
126 };
127
128 // ========================================
129 // TabCompletionSettings
130 // ========================================
131
132 class TabCompletionSettings : public ClientSettings {
133 public:
134   enum SortMode {
135     Alphabetical,
136     LastActivity
137   };
138
139   TabCompletionSettings();
140
141   void setCompletionSuffix(const QString &);
142   QString completionSuffix();
143
144   void setSortMode(SortMode);
145   SortMode sortMode();
146
147   void setCaseSensitivity(Qt::CaseSensitivity);
148   Qt::CaseSensitivity caseSensitivity();
149
150   void setUseLastSpokenTo(bool);
151   bool useLastSpokenTo();
152
153 };
154
155 // ========================================
156 // ItemViewSettings
157 // ========================================
158 class ItemViewSettings : public ClientSettings {
159   public:
160     ItemViewSettings(const QString& group = "ItemViews");
161
162     bool displayTopicInTooltip();
163     bool mouseWheelChangesBuffer();
164 };
165
166 #endif