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 /***********************************************************************************************/
39 CoreAccountSettings::CoreAccountSettings() : ClientSettings("CoreAccounts") {
44 QStringList CoreAccountSettings::knownAccounts() {
45 return localChildKeys("Accounts");
48 QString CoreAccountSettings::lastAccount() {
49 return localValue("LastAccount", "").toString();
52 void CoreAccountSettings::setLastAccount(const QString &account) {
53 setLocalValue("LastAccount", account);
56 QString CoreAccountSettings::autoConnectAccount() {
57 return localValue("AutoConnectAccount", "").toString();
60 void CoreAccountSettings::setAutoConnectAccount(const QString &account) {
61 setLocalValue("AutoConnectAccount", account);
64 void CoreAccountSettings::storeAccount(const QString name, const QVariantMap &data) {
65 setLocalValue(QString("Accounts/%2").arg(name), data);
68 QVariantMap CoreAccountSettings::retrieveAccount(const QString &name) {
69 return localValue(QString("Accounts/%2").arg(name), QVariant()).toMap();
72 void CoreAccountSettings::storeAllAccounts(const QHash<QString, QVariantMap> accounts) {
73 removeLocalKey(QString("Accounts"));
74 foreach(QString name, accounts.keys()) {
75 storeAccount(name, accounts[name]);
79 QHash<QString, QVariantMap> CoreAccountSettings::retrieveAllAccounts() {
80 QHash<QString, QVariantMap> accounts;
81 foreach(QString name, knownAccounts()) {
82 accounts[name] = retrieveAccount(name);
87 void CoreAccountSettings::removeAccount(const QString &account) {
88 removeLocalKey(QString("Accounts/%1").arg(account));