File: coreusersettings.cpp

package info (click to toggle)
quassel 1:0.13.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 25,640 kB
  • sloc: cpp: 66,953; perl: 15,837; ansic: 4,418; sql: 1,225; sh: 328; xml: 263; python: 224; makefile: 24
file content (91 lines) | stat: -rw-r--r-- 3,069 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/***************************************************************************
 *   Copyright (C) 2005-2019 by the Quassel Project                        *
 *   devel@quassel-irc.org                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) version 3.                                           *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include "coreusersettings.h"

CoreUserSettings::CoreUserSettings(UserId uid) : CoreSettings(QString("CoreUser/%1").arg(uid.toInt())), user(uid)
{
}


Identity CoreUserSettings::identity(IdentityId id)
{
    QVariant v = localValue(QString("Identities/%1").arg(id.toInt()));
    if (v.canConvert<Identity>()) {
        return v.value<Identity>();
    }
    return Identity();
}


QList<IdentityId> CoreUserSettings::identityIds()
{
    QList<IdentityId> res;
    foreach(QString id, localChildKeys("Identities")) {
        res << id.toInt();
    }
    return res;
}


void CoreUserSettings::storeIdentity(const Identity &identity)
{
    setLocalValue(QString("Identities/%1").arg(identity.id().toInt()), QVariant::fromValue(identity));
}


void CoreUserSettings::removeIdentity(IdentityId id)
{
    removeLocalKey(QString("Identities/%1").arg(id.toInt()));
}


void CoreUserSettings::setSessionState(const QVariant &data)
{
    setLocalValue("SessionState", data);
}


QVariant CoreUserSettings::sessionState(const QVariant &def)
{
    return localValue("SessionState", def);
}


QVariantMap CoreUserSettings::sessionData()
{
    QVariantMap res;
    foreach(QString key, localChildKeys(QString("SessionData"))) {
        res[key] = localValue(QString("SessionData/%1").arg(key));
    }
    return res;
}


void CoreUserSettings::setSessionValue(const QString &key, const QVariant &data)
{
    setLocalValue(QString("SessionData/%1").arg(key), data);
}


QVariant CoreUserSettings::sessionValue(const QString &key, const QVariant &def)
{
    return localValue(QString("SessionData/%1").arg(key), def);
}