aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/qtkeychain/plaintextstore_p.h
blob: 7ec05aaca17230411a3fe3b72cec9bbd086a3bac (plain)
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
/******************************************************************************
 *   Copyright (C) 2011-2015 Frank Osterfeld <frank.osterfeld@gmail.com>      *
 *   Copyright (C) 2016 Mathias Hasselmann <mathias.hasselmann@kdab.com>      *
 *                                                                            *
 * 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. For licensing and distribution        *
 * details, check the accompanying file 'COPYING'.                            *
 *****************************************************************************/

#ifndef QTKEYCHAIN_PLAINTEXTSTORE_P_H
#define QTKEYCHAIN_PLAINTEXTSTORE_P_H

#include "keychain_p.h"

namespace QKeychain {

class PlainTextStore {
    Q_DECLARE_TR_FUNCTIONS(QKeychain::PlainTextStore)

public:
    explicit PlainTextStore(const QString &service, QSettings *settings);

    Error error() const { return m_error; }
    QString errorString() const { return m_errorString; }

    bool contains(const QString &key) const;

    QByteArray readData(const QString &key);
    JobPrivate::Mode readMode(const QString &key);

    void write(const QString &key, const QByteArray &data, JobPrivate::Mode mode);
    void remove(const QString &key);

private:
    void setError(Error error, const QString &errorString);
    QVariant read(const QString &key);

    const QScopedPointer<QSettings> m_localSettings;
    QSettings *const m_actualSettings;
    QString m_errorString;
    Error m_error;
};

}

#endif // QTKEYCHAIN_PLAINTEXTSTORE_P_H