summaryrefslogtreecommitdiffstats
path: root/common/configstore.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-11 08:39:43 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-11 08:39:43 +0200
commit68fcd3e123e9c0e345d95728d0c8742e53be940a (patch)
treee4e79abf7f3f2262871675a12f37d38f60fad71e /common/configstore.h
parent9f5e4a488360c2c0232a12b65e9d1c8366c0bc8b (diff)
downloadsink-68fcd3e123e9c0e345d95728d0c8742e53be940a.tar.gz
sink-68fcd3e123e9c0e345d95728d0c8742e53be940a.zip
Use ConfigStore for accounts
Diffstat (limited to 'common/configstore.h')
-rw-r--r--common/configstore.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/common/configstore.h b/common/configstore.h
new file mode 100644
index 0000000..2f51f63
--- /dev/null
+++ b/common/configstore.h
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include "sink_export.h"
23#include <QList>
24#include <QByteArray>
25#include <QVariant>
26#include <QMap>
27#include <QSettings>
28#include <QSharedPointer>
29
30class SINK_EXPORT ConfigStore
31{
32public:
33 ConfigStore(const QByteArray &identifier);
34
35 /**
36 * Returns all entries with their type.
37 */
38 QMap<QByteArray, QByteArray> getEntries();
39
40 /**
41 * Create an entry with a type.
42 */
43 void add(const QByteArray &identifier, const QByteArray &type);
44
45 /**
46 * Remove an entry.
47 */
48 void remove(const QByteArray &identifier);
49
50 /**
51 * Remove all entries
52 */
53 void clear();
54
55 /**
56 * Modify the configuration of an entry.
57 */
58 void modify(const QByteArray &identifier, const QMap<QByteArray, QVariant> &configuration);
59
60 /**
61 * Get the configuration of an entry.
62 */
63 QMap<QByteArray, QVariant> get(const QByteArray &identifier);
64
65private:
66 QByteArray mIdentifier;
67 QSharedPointer<QSettings> mConfig;
68};