0b1b3d54c4331b07613c746c918b0723bd84631f
[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
63   void storeAccountData(AccountId id, const QVariantMap &data);
64   QVariantMap retrieveAccountData(AccountId);
65   void removeAccount(AccountId);
66
67   void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
68   QHash<int, BufferId> jumpKeyMap();
69
70 protected:
71   void setAccountValue(const QString &key, const QVariant &data);
72   QVariant accountValue(const QString &key, const QVariant &def = QVariant());
73
74 private:
75   QString _subgroup;
76 };
77
78 // ========================================
79 //  NotificationSettings
80 // ========================================
81 class NotificationSettings : public ClientSettings {
82 public:
83   enum HighlightNickType {
84     NoNick = 0x00,
85     CurrentNick= 0x01,
86     AllNicks = 0x02
87   };
88
89   NotificationSettings();
90
91   inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
92   inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
93   inline void remove(const QString &key) { removeLocalKey(key); }
94
95   void setHighlightList(const QVariantList &highlightList);
96   QVariantList highlightList();
97
98   void setHighlightNick(HighlightNickType);
99   HighlightNickType highlightNick();
100
101   void setNicksCaseSensitive(bool);
102   bool nicksCaseSensitive();
103 };
104
105
106 // ========================================
107 //  KnownHostsSettings
108 // ========================================
109 class KnownHostsSettings : public ClientSettings {
110 public:
111   KnownHostsSettings();
112
113   QByteArray knownDigest(const QHostAddress &address);
114   void saveKnownHost(const QHostAddress &address, const QByteArray &certDigest);
115   bool isKnownHost(const QHostAddress &address, const QByteArray &certDigest);
116
117 #ifdef HAVE_SSL
118   QByteArray knownDigest(const QSslSocket *socket);
119   void saveKnownHost(const QSslSocket *socket);
120   bool isKnownHost(const QSslSocket *socket);
121 #endif
122 };
123
124 // ========================================
125 // TabCompletionSettings
126 // ========================================
127
128 class TabCompletionSettings : public ClientSettings {
129 public:
130   enum SortMode {
131     Alphabetical,
132     LastActivity
133   };
134
135   TabCompletionSettings();
136
137   void setCompletionSuffix(const QString &);
138   QString completionSuffix();
139
140   void setSortMode(SortMode);
141   SortMode sortMode();
142
143   void setCaseSensitivity(Qt::CaseSensitivity);
144   Qt::CaseSensitivity caseSensitivity();
145
146   void setUseLastSpokenTo(bool);
147   bool useLastSpokenTo();
148
149 };
150
151 #endif