blob: ff37e1e6cdc050f954cb4b567eb0a2111fb064c2 (
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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Copyright (C) 2008 Nokia Corporation.
*
* Contact: Marius Vollmer <marius.vollmer@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef INFOBACKEND_H
#define INFOBACKEND_H
#include <QVariant>
#include <QStringList>
#include <QObject>
#include "contextproviderinfo.h"
#include "contexttypeinfo.h"
#define BACKEND_COMPATIBILITY_NAMESPACE "http://contextkit.freedesktop.org/Provider"
class InfoBackend : public QObject
{
Q_OBJECT
public:
static InfoBackend* instance(const QString &backendName = "");
static void destroyInstance();
/// Returns the name of the backend, ie: 'xml'.
virtual QString name() const = 0;
/// Returns the list of all the keys in the registry.
virtual QStringList listKeys() const = 0;
/// Returns the type information for the given \a key.
virtual ContextTypeInfo typeInfoForKey(QString key) const = 0;
/// Returns the documentation for the given \a key name.
virtual QString docForKey(QString key) const = 0;
/// Returns true if the given key exists.
virtual bool keyDeclared(QString key) const = 0;
/// Returns true if the given key is deprecated.
virtual bool keyDeprecated(QString key) const = 0;
/// Returns a list of providers for the given key.
virtual const QList<ContextProviderInfo> providersForKey(QString key) const = 0;
Q_SIGNALS:
/// Emitted when key list changes. ContextRegistryInfo listens on that.
void keysChanged(const QStringList& currentKeys);
/// Emitted when new keys are added. ContextRegistryInfo listens on that.
void keysAdded(const QStringList& newKeys);
/// Emitted when keys are removed. ContextRegistryInfo listens on that.
void keysRemoved(const QStringList& removedKeys);
/// Emitted when key data/info changes. ContextPropertyInfo instances listen on that.
void keyChanged(const QString& key);
/// Emitted when the key list changes. ContextRegistryInfo listens on that.
void listChanged();
protected:
virtual void connectNotify(const char *signal);
virtual void disconnectNotify(const char *signal);
private:
int connectCount; ///< Number of connections to signals. Used to optimized signal emission when 0.
InfoBackend(QObject *parent = 0);
/// Private constructor. Do not use.
InfoBackend(const InfoBackend&);
void checkAndEmitKeysAdded(const QStringList ¤tKeys, const QStringList &oldKeys);
void checkAndEmitKeysRemoved(const QStringList ¤tKeys, const QStringList &oldKeys);
void checkAndEmitKeyChanged(const QStringList ¤tKeys, const QStringList &oldKeys);
/// Private operator. Do not use.
InfoBackend& operator=(const InfoBackend&);
static InfoBackend* backendInstance; ///< Holds a pointer to the instance of the singelton.
friend class InfoXmlBackend;
friend class InfoCdbBackend;
friend class InfoTestBackend;
friend class InfoXmlBackendUnitTest;
friend class InfoCdbBackendUnitTest;
friend class InfoBackendUnitTest;
};
#endif // INFOBACKEND_H
|