|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 DATABASEMANAGER_S60_H_ |
|
43 #define DATABASEMANAGER_S60_H_ |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include "qmobilityglobal.h" |
|
57 #include <QObject> |
|
58 #include <QList> |
|
59 |
|
60 #include <servicemetadata_p.h> |
|
61 #include "dberror_p.h" |
|
62 #include <e32base.h> |
|
63 |
|
64 |
|
65 QT_BEGIN_HEADER |
|
66 QTM_BEGIN_NAMESPACE |
|
67 |
|
68 class CDatabaseManagerServerThread; |
|
69 class QServiceFilter; |
|
70 typedef TPckgBuf<TInt> TError; |
|
71 |
|
72 class QServiceInterfaceDescriptor; |
|
73 |
|
74 class RDatabaseManagerSession : public RSessionBase |
|
75 { |
|
76 public: |
|
77 enum DbScope{UserScope, SystemScope, UserOnlyScope}; |
|
78 RDatabaseManagerSession(); |
|
79 |
|
80 public: |
|
81 TInt Connect(); |
|
82 void Close(); |
|
83 TVersion Version() const; |
|
84 |
|
85 bool RegisterService(ServiceMetaDataResults& aService); |
|
86 bool UnregisterService(const QString& aServiceName); |
|
87 |
|
88 QList<QServiceInterfaceDescriptor> Interfaces(const QServiceFilter& aFilter); |
|
89 QStringList ServiceNames(const QString& aInterfaceName); |
|
90 |
|
91 QServiceInterfaceDescriptor InterfaceDefault(const QString& aInterfaceName); |
|
92 bool SetInterfaceDefault(const QString& aServiceName, const QString& aInterfaceName); |
|
93 bool SetInterfaceDefault(const QServiceInterfaceDescriptor& aInterface); |
|
94 |
|
95 DBError LastError(); |
|
96 |
|
97 void SetChangeNotificationsEnabled(bool aEnabled); |
|
98 |
|
99 void NotifyServiceSignal(TRequestStatus& aStatus); |
|
100 void CancelNotifyServiceSignal() const; |
|
101 |
|
102 public: |
|
103 TBuf<255> iServiceName; |
|
104 TPckgBuf<TInt> iState; |
|
105 |
|
106 private: |
|
107 TInt StartServer(); |
|
108 |
|
109 private: |
|
110 TIpcArgs iArgs; |
|
111 TError iError; |
|
112 #ifdef __WINS__ |
|
113 CDatabaseManagerServerThread* iServerThread; |
|
114 #endif |
|
115 }; |
|
116 |
|
117 class DatabaseManagerSignalMonitor; |
|
118 |
|
119 class Q_AUTOTEST_EXPORT DatabaseManager : public QObject |
|
120 { |
|
121 Q_OBJECT |
|
122 |
|
123 public: |
|
124 enum DbScope{UserScope, SystemScope, UserOnlyScope}; |
|
125 DatabaseManager(void); |
|
126 virtual ~DatabaseManager(); |
|
127 |
|
128 bool registerService(ServiceMetaDataResults &service, DbScope scope); |
|
129 bool unregisterService(const QString &serviceName, DbScope scope); |
|
130 |
|
131 QList<QServiceInterfaceDescriptor> getInterfaces(const QServiceFilter &filter, DbScope scope); |
|
132 QStringList getServiceNames(const QString &interfaceName, DbScope scope); |
|
133 |
|
134 QServiceInterfaceDescriptor interfaceDefault(const QString &interfaceName, DbScope scope); |
|
135 bool setInterfaceDefault(const QString &serviceName, const QString &interfaceName, DbScope scope); |
|
136 bool setInterfaceDefault(const QServiceInterfaceDescriptor &interface, DbScope scope); |
|
137 |
|
138 DBError lastError(); |
|
139 |
|
140 void setChangeNotificationsEnabled(DbScope scope, bool enabled); |
|
141 |
|
142 signals: |
|
143 void serviceAdded(const QString &serviceName, DatabaseManager::DbScope scope); |
|
144 void serviceRemoved(const QString &serviceName, DatabaseManager::DbScope scope); |
|
145 |
|
146 private: |
|
147 enum State{EAdded, ERemoved}; |
|
148 void notifyServiceSignal(); |
|
149 |
|
150 private: |
|
151 friend class DatabaseManagerSignalMonitor; |
|
152 DatabaseManagerSignalMonitor* iDatabaseManagerSignalMonitor; |
|
153 RDatabaseManagerSession iSession; |
|
154 QServiceInterfaceDescriptor latestDescriptor(const QList<QServiceInterfaceDescriptor> &descriptors); |
|
155 }; |
|
156 |
|
157 #ifdef __WINS__ |
|
158 QTM_END_NAMESPACE |
|
159 #include "databasemanagerserver_global.h" |
|
160 #include <QThread> |
|
161 QTM_BEGIN_NAMESPACE |
|
162 class DATABASEMANAGERSERVER_EXPORT CDatabaseManagerServerThread : public QThread |
|
163 { |
|
164 public: |
|
165 CDatabaseManagerServerThread(); |
|
166 |
|
167 protected: |
|
168 void run(); |
|
169 }; |
|
170 #endif |
|
171 |
|
172 class DatabaseManagerSignalMonitor : public CActive |
|
173 { |
|
174 public: |
|
175 DatabaseManagerSignalMonitor(DatabaseManager& databaseManager, RDatabaseManagerSession& databaseManagerSession); |
|
176 ~DatabaseManagerSignalMonitor(); |
|
177 |
|
178 protected: |
|
179 void issueNotifyServiceSignal(); |
|
180 |
|
181 protected: // From CActive |
|
182 void DoCancel(); |
|
183 void RunL(); |
|
184 private: |
|
185 DatabaseManager& iDatabaseManager; |
|
186 RDatabaseManagerSession& iDatabaseManagerSession; |
|
187 }; |
|
188 |
|
189 QTM_END_NAMESPACE |
|
190 QT_END_HEADER |
|
191 |
|
192 #endif |