source: SMSSender/frontend/persistence/restrictedmainstorage.h @ 319:1ec456878bcb

separation-frontend-backend
Last change on this file since 319:1ec456878bcb was 319:1ec456878bcb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adjusts header guards to follow common pattern based on the filename.
File size: 3.2 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2014, gorrión. See http://smssender.gorrion.ch
4
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 3 of the License, or
8 (at your option) any later version.
9
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.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef FRONTEND_PERSISTENCE_RESTRICTEDMAINSTORAGE_H
19#define FRONTEND_PERSISTENCE_RESTRICTEDMAINSTORAGE_H
20
21#include <QSharedPointer>
22#include <QString>
23
24#ifdef FRONTEND_GUI
25#include <QtGui/QImage>
26#include <QtGui/QKeySequence>
27#endif
28
29#include "common/global.h"
30#include "common/persistence/imainstorage.h"
31
32namespace Persistence {
33
34/**
35 * Class for main storage access which is rooted to a namespace prefix.
36 */
37class RestrictedMainStorage : public IMainStorage {
38public:
39    RestrictedMainStorage(IMainStorage *storage, const QString &namespacePrefix);
40
41public: /* IStorage */
42    QVariant     readValue(const QString &nmespace, const QString &key, const QVariant &defaultValue = QVariant());
43    bool         readBool(const QString &nmespace, const QString &key, bool defaultValue = false);
44    int          readInt(const QString &nmespace, const QString &key, int defaultValue = 0);
45    QString      readString(const QString &nmespace, const QString &key, const QString &defaultValue = QString());
46    QString      readEncryptedString(const QString &nmespace, const QString &key, const QString &password, const QString &defaultValue = "");
47
48    void writeValue(const QString &nmespace, const QString &key, const QVariant &value);
49    void writeBool(const QString &nmespace, const QString &key, bool value);
50    void writeInt(const QString &nmespace, const QString &key, int value);
51    void writeString(const QString &nmespace, const QString &key, const QString &value);
52    void writeEncryptedString(const QString &nmespace, const QString &key, const QString &password, const QString &value);
53
54    void removeValue(const QString &nmespace, const QString &key);
55    void removeValues(const QString &nmespace);
56
57#ifdef FRONTEND_GUI
58    QImage readImage(const QString &nmespace, const QString &key, const QImage &defaultValue = QImage());
59    QKeySequence readShortcut(const QString &nmespace, const QString &key, const QKeySequence &defaultValue = QKeySequence());
60    void writeImage(const QString &nmespace, const QString &key, const QImage &image);
61    void writeShortcut(const QString &nmespace, const QString &key, const QKeySequence &shortcut);
62#endif
63
64protected:
65    void init(const QSqlDatabase &db);
66    QSqlDatabase database();
67
68    QString buildNamespace(const QString &suffix) const;
69
70    IMainStorage * const m_storage;
71
72private:
73    const QString m_namespacePrefix;
74};
75
76} // namespace Persistence
77
78#endif // FRONTEND_PERSISTENCE_RESTRICTEDMAINSTORAGE_H
Note: See TracBrowser for help on using the repository browser.