1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
22 #include "clientsettings.h"
25 #include <QStringList>
27 ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) {
32 ClientSettings::~ClientSettings() {
37 QStringList ClientSettings::sessionKeys() {
38 return Client::sessionDataKeys();
41 void ClientSettings::setSessionValue(const QString &key, const QVariant &data) {
42 Client::storeSessionData(key, data);
45 QVariant ClientSettings::sessionValue(const QString &key, const QVariant &def) {
46 return Client::retrieveSessionData(key, def);
49 /***********************************************************************************************/
51 CoreAccountSettings::CoreAccountSettings() : ClientSettings("CoreAccounts") {
56 QStringList CoreAccountSettings::knownAccounts() {
57 return localChildKeys("Accounts");
60 QString CoreAccountSettings::lastAccount() {
61 return localValue("LastAccount", "").toString();
64 void CoreAccountSettings::setLastAccount(const QString &account) {
65 setLocalValue("LastAccount", account);
68 QString CoreAccountSettings::autoConnectAccount() {
69 return localValue("AutoConnectAccount", "").toString();
72 void CoreAccountSettings::setAutoConnectAccount(const QString &account) {
73 setLocalValue("AutoConnectAccount", account);
76 void CoreAccountSettings::storeAccount(const QString name, const QVariantMap &data) {
77 setLocalValue(QString("Accounts/%2").arg(name), data);
80 QVariantMap CoreAccountSettings::retrieveAccount(const QString &name) {
81 return localValue(QString("Accounts/%2").arg(name), QVariant()).toMap();
84 void CoreAccountSettings::storeAllAccounts(const QHash<QString, QVariantMap> accounts) {
85 removeLocalKey(QString("Accounts"));
86 foreach(QString name, accounts.keys()) {
87 storeAccount(name, accounts[name]);
91 QHash<QString, QVariantMap> CoreAccountSettings::retrieveAllAccounts() {
92 QHash<QString, QVariantMap> accounts;
93 foreach(QString name, knownAccounts()) {
94 accounts[name] = retrieveAccount(name);
99 void CoreAccountSettings::removeAccount(const QString &account) {
100 removeLocalKey(QString("Accounts/%1").arg(account));