|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QVALUESPACE_P_H |
|
43 #define QVALUESPACE_P_H |
|
44 |
|
45 #include "qmobilityglobal.h" |
|
46 #include "qvaluespace.h" |
|
47 |
|
48 #include <QObject> |
|
49 #include <QUuid> |
|
50 |
|
51 QTM_BEGIN_NAMESPACE |
|
52 |
|
53 class QValueSpacePublisher; |
|
54 |
|
55 QString qCanonicalPath(const QString &path); |
|
56 |
|
57 class Q_AUTOTEST_EXPORT QAbstractValueSpaceLayer : public QObject |
|
58 { |
|
59 Q_OBJECT |
|
60 |
|
61 public: |
|
62 typedef quintptr Handle; |
|
63 static const Handle InvalidHandle = ~Handle(0); |
|
64 |
|
65 virtual QString name() = 0; |
|
66 |
|
67 enum Type { Server, Client }; |
|
68 |
|
69 virtual bool startup(Type type) = 0; |
|
70 |
|
71 virtual QUuid id() = 0; |
|
72 virtual unsigned int order() = 0; |
|
73 |
|
74 enum Properties { Publish = 0x00000001 }; |
|
75 |
|
76 virtual Handle item(Handle parent, const QString &subPath) = 0; |
|
77 virtual void removeHandle(Handle handle) = 0; |
|
78 virtual void setProperty(Handle handle, Properties properties) = 0; |
|
79 |
|
80 virtual bool value(Handle handle, QVariant *data) = 0; |
|
81 virtual bool value(Handle handle, const QString &subPath, QVariant *data) = 0; |
|
82 virtual QSet<QString> children(Handle handle) = 0; |
|
83 |
|
84 virtual QValueSpace::LayerOptions layerOptions() const = 0; |
|
85 |
|
86 /* QValueSpaceSubscriber functions */ |
|
87 virtual bool supportsInterestNotification() const = 0; |
|
88 virtual bool notifyInterest(Handle handle, bool interested) = 0; |
|
89 |
|
90 /* QValueSpacePublisher functions */ |
|
91 virtual bool setValue(QValueSpacePublisher *creator, Handle handle, |
|
92 const QString &subPath, const QVariant &value) = 0; |
|
93 virtual bool removeValue(QValueSpacePublisher *creator, Handle handle, |
|
94 const QString &subPath) = 0; |
|
95 virtual bool removeSubTree(QValueSpacePublisher *creator, Handle handle) = 0; |
|
96 virtual void addWatch(QValueSpacePublisher *creator, Handle handle) = 0; |
|
97 virtual void removeWatches(QValueSpacePublisher *creator, Handle parent) = 0; |
|
98 virtual void sync() = 0; |
|
99 |
|
100 protected: |
|
101 /* QValueSpacePublisher functions */ |
|
102 void emitInterestChanged(QValueSpacePublisher *publisher, const QString &attribute, |
|
103 bool interested); |
|
104 |
|
105 signals: |
|
106 void handleChanged(quintptr); |
|
107 }; |
|
108 |
|
109 namespace QValueSpace { |
|
110 typedef QAbstractValueSpaceLayer *(*LayerCreateFunc)(); |
|
111 Q_AUTOTEST_EXPORT void installLayer(LayerCreateFunc func); |
|
112 Q_AUTOTEST_EXPORT void installLayer(QAbstractValueSpaceLayer *layer); |
|
113 |
|
114 struct AutoInstall { |
|
115 AutoInstall(LayerCreateFunc func) { installLayer(func); } |
|
116 }; |
|
117 } |
|
118 |
|
119 #define QVALUESPACE_AUTO_INSTALL_LAYER(name) \ |
|
120 QAbstractValueSpaceLayer * _qvaluespaceauto_layercreate_ ## name() \ |
|
121 { \ |
|
122 return name::instance(); \ |
|
123 } \ |
|
124 static QValueSpace::AutoInstall _qvaluespaceauto_ ## name(_qvaluespaceauto_layercreate_ ## name); |
|
125 |
|
126 QTM_END_NAMESPACE |
|
127 |
|
128 #endif // QVALUESPACE_P_H |