sessionData--
[quassel.git] / src / client / clientsettings.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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 #include "client.h"
22 #include "clientsettings.h"
23 #include "global.h"
24
25 #include <QStringList>
26
27 ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) {
28
29
30 }
31
32 ClientSettings::~ClientSettings() {
33
34
35 }
36
37 /***********************************************************************************************/
38
39 CoreAccountSettings::CoreAccountSettings() : ClientSettings("CoreAccounts") {
40
41
42 }
43
44 QStringList CoreAccountSettings::knownAccounts() {
45   return localChildKeys("Accounts");
46 }
47
48 QString CoreAccountSettings::lastAccount() {
49   return localValue("LastAccount", "").toString();
50 }
51
52 void CoreAccountSettings::setLastAccount(const QString &account) {
53   setLocalValue("LastAccount", account);
54 }
55
56 QString CoreAccountSettings::autoConnectAccount() {
57   return localValue("AutoConnectAccount", "").toString();
58 }
59
60 void CoreAccountSettings::setAutoConnectAccount(const QString &account) {
61   setLocalValue("AutoConnectAccount", account);
62 }
63
64 void CoreAccountSettings::storeAccount(const QString name, const QVariantMap &data) {
65   setLocalValue(QString("Accounts/%2").arg(name), data);
66 }
67
68 QVariantMap CoreAccountSettings::retrieveAccount(const QString &name) {
69   return localValue(QString("Accounts/%2").arg(name), QVariant()).toMap();
70 }
71
72 void CoreAccountSettings::storeAllAccounts(const QHash<QString, QVariantMap> accounts) {
73   removeLocalKey(QString("Accounts"));
74   foreach(QString name, accounts.keys()) {
75     storeAccount(name, accounts[name]);
76   }
77 }
78
79 QHash<QString, QVariantMap> CoreAccountSettings::retrieveAllAccounts() {
80   QHash<QString, QVariantMap> accounts;
81   foreach(QString name, knownAccounts()) {
82     accounts[name] = retrieveAccount(name);
83   }
84   return accounts;
85 }
86
87 void CoreAccountSettings::removeAccount(const QString &account) {
88   removeLocalKey(QString("Accounts/%1").arg(account));
89 }
90
91