From 1607bfc3101e08fe0aeeaa3b50af6ddc9a4f9e3c Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 6 Jan 2008 00:57:42 +0000 Subject: [PATCH] Changed the new layout of the settings files around a bit. SessionData is now part of [CoreUser], which is much nicer than what we had before. --- Quassel.kdevelop.filelist | 2 ++ src/common/identity.h | 2 ++ src/core/core.cpp | 4 +-- src/core/core.pri | 4 +-- src/core/coresession.cpp | 32 +++++++------------ ...ssionsettings.cpp => coreusersettings.cpp} | 25 ++++++++------- .../{sessionsettings.h => coreusersettings.h} | 23 +++++++------ 7 files changed, 45 insertions(+), 47 deletions(-) rename src/core/{sessionsettings.cpp => coreusersettings.cpp} (67%) rename src/core/{sessionsettings.h => coreusersettings.h} (80%) diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index 08acd959..7ab1c813 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -83,6 +83,8 @@ src/core/coresession.cpp src/core/coresession.h src/core/coresettings.cpp src/core/coresettings.h +src/core/coreusersettings.cpp +src/core/coreusersettings.h src/core/ctcphandler.cpp src/core/ctcphandler.h src/core/ircserverhandler.cpp diff --git a/src/common/identity.h b/src/common/identity.h index 5db1a9a0..66d7153e 100644 --- a/src/common/identity.h +++ b/src/common/identity.h @@ -74,6 +74,8 @@ class Identity : public QObject { void awayReasonSet(const QString &awayReason); void returnMessageSet(const QString &returnMessage); + void updatedRemotely(); + private: bool _initialized; IdentityId _identityId; diff --git a/src/core/core.cpp b/src/core/core.cpp index 7aae1155..4f97c3a6 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -64,8 +64,8 @@ void Core::init() { ncs.setValue("Core/DatabaseSettings", os.value("Core/DatabaseSettings")); os.beginGroup("SessionData"); foreach(QString group, os.childGroups()) { - ncs.setValue(QString("SessionData/%1/Identities").arg(group), os.value(QString("%1/Identities").arg(group))); - ncs.setValue(QString("SessionData/%1/Networks").arg(group), os.value(QString("%1/Networks").arg(group))); + ncs.setValue(QString("CoreUser/%1/SessionData/Identities").arg(group), os.value(QString("%1/Identities").arg(group))); + ncs.setValue(QString("CoreUser/%1/SessionData/Networks").arg(group), os.value(QString("%1/Networks").arg(group))); } os.endGroup(); diff --git a/src/core/core.pri b/src/core/core.pri index 6664e2d2..033d2b41 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -1,6 +1,6 @@ DEPMOD = common QT_MOD = core network sql script SRCS = core.cpp coresession.cpp coresettings.cpp server.cpp sqlitestorage.cpp storage.cpp basichandler.cpp \ - ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp sessionsettings.cpp + ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp coreusersettings.cpp HDRS = core.h coresession.h coresettings.h server.h sqlitestorage.h storage.h basichandler.h \ - ircserverhandler.h userinputhandler.h ctcphandler.h sessionsettings.h + ircserverhandler.h userinputhandler.h ctcphandler.h coreusersettings.h diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 866f85bb..cffb3757 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -30,7 +30,7 @@ #include "identity.h" #include "util.h" -#include "sessionsettings.h" +#include "coreusersettings.h" #include @@ -44,22 +44,12 @@ CoreSession::CoreSession(UserId uid, Storage *_storage, QObject *parent) SignalProxy *p = signalProxy(); - SessionSettings s(user); - sessionData = s.sessionData(); qDebug() << sessionData; - /* - QSettings s; // FIXME don't use QSettings anymore - mutex.lock(); - s.beginGroup(QString("SessionData/%1").arg(user)); - foreach(QString key, s.allKeys()) { qDebug() << key; - sessionData[key] = s.value(key); - } - s.endGroup(); - mutex.unlock(); // FIXME remove - */ - /* temporarily disabled - s.beginGroup(QString("Identities/%1").arg(user)); - foreach(QString id, s.childKeys()) { - Identity *i = new Identity(s.value(id).value(), this); + CoreUserSettings s(user); + sessionData = s.sessionData(); +/* + CoreSettings cs; + foreach(QString id, cs.localChildKeys(QString("Identities/%1").arg(user))) { + Identity *i = new Identity(cs.localValue(QString("Identities/%1/%2").arg(user).arg(id)).value(), this); if(i->id() < 1) { qDebug() << QString("Invalid identity!"); continue; @@ -142,7 +132,7 @@ void CoreSession::restoreState(const QVariant &previousState) { void CoreSession::storeSessionData(const QString &key, const QVariant &data) { - SessionSettings s(user); + CoreUserSettings s(user); mutex.lock(); s.setSessionValue(key, data); sessionData[key] = data; @@ -320,11 +310,11 @@ void CoreSession::createOrUpdateIdentity(const Identity &id) { // update _identities[id.id()]->update(id); } - Q_ASSERT(false); // FIX QSettings first! - QSettings s; // FIXME don't use QSettings +/* + CoreSettings s; s.beginGroup(QString("Identities/%1").arg(user)); s.setValue(QString::number(id.id()), QVariant::fromValue(*_identities[id.id()])); - s.endGroup(); + s.endGroup();*/ } void CoreSession::removeIdentity(IdentityId id) { diff --git a/src/core/sessionsettings.cpp b/src/core/coreusersettings.cpp similarity index 67% rename from src/core/sessionsettings.cpp rename to src/core/coreusersettings.cpp index 8858e4a4..49a98374 100644 --- a/src/core/sessionsettings.cpp +++ b/src/core/coreusersettings.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-08 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,28 +18,29 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "sessionsettings.h" +#include "coreusersettings.h" -#include -#include +CoreUserSettings::CoreUserSettings(UserId uid) : CoreSettings(QString("CoreUser/%1").arg(uid)), user(uid) { -SessionSettings::SessionSettings(UserId uid) : CoreSettings("SessionData"), user(uid) { } -QVariantMap SessionSettings::sessionData() { + + + +QVariantMap CoreUserSettings::sessionData() { QVariantMap res; - foreach(QString key, localChildKeys(QString("%1").arg(user))) { - res[key] = localValue(QString("%1/%2").arg(user).arg(key)); + foreach(QString key, localChildKeys(QString("SessionData"))) { + res[key] = localValue(QString("SessionData/%1").arg(key)); } return res; } -void SessionSettings::setSessionValue(const QString &key, const QVariant &data) { - setLocalValue(QString("%1/%2").arg(user).arg(key), data); +void CoreUserSettings::setSessionValue(const QString &key, const QVariant &data) { + setLocalValue(QString("SessionData/%1").arg(key), data); } -QVariant SessionSettings::sessionValue(const QString &key, const QVariant &def) { - return localValue(QString("%1/%2").arg(user).arg(key), def); +QVariant CoreUserSettings::sessionValue(const QString &key, const QVariant &def) { + return localValue(QString("SessionData/%1").arg(key), def); } diff --git a/src/core/sessionsettings.h b/src/core/coreusersettings.h similarity index 80% rename from src/core/sessionsettings.h rename to src/core/coreusersettings.h index ac18c171..4a8621d8 100644 --- a/src/core/sessionsettings.h +++ b/src/core/coreusersettings.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-08 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,23 +18,26 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _SESSIONSETTINGS_H_ -#define _SESSIONSETTINGS_H_ +#ifndef _COREUSERSETTINGS_H_ +#define _COREUSERSETTINGS_H_ #include "coresettings.h" +#include "identity.h" #include "types.h" #include -// this class should only be used from CoreSession! -//! This class stores and retrieves data from permanent storage for the use in SessionData. -/** \Note Data stored here is not propagated into the actual SessionData! - */ -class SessionSettings : public CoreSettings { +class CoreUserSettings : public CoreSettings { - private: - explicit SessionSettings(UserId user); + public: + CoreUserSettings(UserId user); + + void setIdentity(const Identity &identity); + Identity identity(IdentityId id); + + private: + // this stuff should only be accessed by CoreSession! QVariantMap sessionData(); QVariant sessionValue(const QString &key, const QVariant &def = QVariant()); void setSessionValue(const QString &key, const QVariant &value); -- 2.20.1