1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel IRC Team *
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 ***************************************************************************/
20 #include "sessionsettings.h"
22 #include <QStringList>
24 void SessionSettings::setValue(const QString &key, const QVariant &data) {
25 setLocalValue(QString("%1/%2").arg(_sessionId, key), data);
28 QVariant SessionSettings::value(const QString &key, const QVariant &def) {
29 return localValue(QString("%1/%2").arg(_sessionId, key), def);
32 void SessionSettings::removeKey(const QString &key) {
33 removeLocalKey(QString("%1/%2").arg(_sessionId, key));
36 void SessionSettings::cleanup() {
37 QStringList sessions = localChildGroups();
39 SessionSettings s(sessionId());
40 foreach(str, sessions) {
41 // load session and check age
43 if(s.sessionAge() > 3) {
49 int SessionSettings::sessionAge() {
50 QVariant val = localValue(QString("%1/_sessionAge").arg(_sessionId), 0);
52 int i = val.toInt(&b);
56 // no int saved, delete session
57 //qDebug() << QString("deleting invalid session %1 (invalid session age found)").arg(_sessionId);
63 void SessionSettings::removeSession() {
64 QStringList keys = localChildKeys(sessionId());
65 foreach(QString k, keys) {
71 SessionSettings::SessionSettings(const QString & sessionId, const QString & group) : ClientSettings(group), _sessionId(sessionId) {
74 void SessionSettings::setSessionAge(int age) {
75 setValue(QString("_sessionAge"),age);
78 void SessionSettings::sessionAging() {
79 QStringList sessions = localChildGroups();
81 SessionSettings s(sessionId());
82 foreach(str, sessions) {
83 // load session and check age
85 s.setSessionAge(s.sessionAge()+1);