1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Used by sessions for handling data related requests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CPDATA_MANAGER_H |
|
20 #define C_CPDATA_MANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "cpstorage.h" |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 #ifdef CONTENT_PUBLISHER_DEBUG |
|
27 class CCPDebug; |
|
28 #endif |
|
29 class CLiwMap; |
|
30 class CCPLiwMap; |
|
31 class CCpStorage; |
|
32 class CCPServerSession; |
|
33 class CCPNotificationHandler; |
|
34 class TLiwVariant; |
|
35 |
|
36 /** |
|
37 * Content publisher data manager. |
|
38 * |
|
39 * Used to add, modify and remove data and actions. |
|
40 * @since S60 v5.0 |
|
41 */ |
|
42 class CCPDataManager : public CBase, MCPChangeNotifier |
|
43 { |
|
44 public: |
|
45 // exported |
|
46 |
|
47 /** |
|
48 * C++ destructor |
|
49 */ |
|
50 ~CCPDataManager(); |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 */ |
|
55 static CCPDataManager* NewL( TBool aTBool = EFalse ); |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 */ |
|
60 static CCPDataManager* NewLC( TBool aTBool = EFalse ); |
|
61 |
|
62 /** |
|
63 * Add a new data to database |
|
64 * |
|
65 * @param aData Data to be added. |
|
66 * @return Id of a newly created data item |
|
67 */ |
|
68 TUint AddDataL( CCPLiwMap& aMap ); |
|
69 |
|
70 /** |
|
71 * Fetches data from database |
|
72 * @param aInParamList filter and sorting criteria |
|
73 * @param aOutParamList results |
|
74 */ |
|
75 void GetListL( const CCPLiwMap& aMa, CLiwGenericParamList& aOutParamList ); |
|
76 /** |
|
77 * Fetches action from database |
|
78 * @param aInParamList filter and sorting criteria |
|
79 * @param aOutParamList results |
|
80 * @param aNotificationList change info list (for notifications) |
|
81 * @return KErrNotFound if data was not found |
|
82 */ |
|
83 TInt GetActionL( const CCPLiwMap& aMa, |
|
84 CLiwGenericParamList& aOutParamList, |
|
85 CLiwDefaultList* aNotificationList = NULL ); |
|
86 |
|
87 /** |
|
88 * Fetches all activated publishers |
|
89 * @param aInParamList filter and sorting criteria |
|
90 * @param aOutParamList results |
|
91 */ |
|
92 void GetActivePublishersL( CLiwGenericParamList* aResultList ); |
|
93 |
|
94 /** |
|
95 * Removes data from database |
|
96 * @param aInParamList filter criteria |
|
97 */ |
|
98 void RemoveDataL( const CCPLiwMap& aMa ); |
|
99 |
|
100 /** |
|
101 * Adds observer to database |
|
102 * @param new observer |
|
103 */ |
|
104 void AddObserverL( CCPNotificationHandler* aNotificationHandler ); |
|
105 |
|
106 /** |
|
107 * Removes observer from database |
|
108 * @param aNotificationHandler observer to remove |
|
109 */ |
|
110 void RemoveObserver( CCPNotificationHandler* aNotificationHandler ); |
|
111 |
|
112 // from MCPChangeNotifier |
|
113 /** |
|
114 * @param Map containing change information |
|
115 * @return |
|
116 */ |
|
117 void HandleChangeL( CLiwDefaultList* aListOfMaps ); |
|
118 |
|
119 /** |
|
120 * Close database |
|
121 * @return |
|
122 */ |
|
123 void CloseDatabase(); |
|
124 /** |
|
125 * Open database |
|
126 * @return |
|
127 */ |
|
128 void OpenDatabaseL(); |
|
129 |
|
130 private: |
|
131 // methods |
|
132 |
|
133 /** |
|
134 * Standard C++ constructor. |
|
135 */ |
|
136 CCPDataManager(); |
|
137 |
|
138 /** |
|
139 * Standard 2nd phase constructor. |
|
140 */ |
|
141 void ConstructL( TBool aTBool ); |
|
142 |
|
143 /** |
|
144 * Fetches action bound to provided trigger. |
|
145 * |
|
146 * @param aOutParamList of all actions |
|
147 * @param aMap for found action |
|
148 * @param aTrigger |
|
149 */ |
|
150 void ExtractTriggerL( CLiwGenericParamList& aOutParamList, |
|
151 const CLiwDefaultMap* aMap, const TDesC8& aTrigger ); |
|
152 /** |
|
153 * Sends notifications to observers stored in iNotificationsArray |
|
154 * |
|
155 * @param List of change information |
|
156 * @param index od data item |
|
157 */ |
|
158 void SendNotificationL( CLiwDefaultList* aListOfMaps, TInt aIndex ); |
|
159 |
|
160 /** |
|
161 * Exctracts action from input parameters |
|
162 * |
|
163 * @param aParam for data |
|
164 * @param aAction for action |
|
165 */ |
|
166 void ExtractActionL( const TLiwGenericParam* aParam, RBuf8& aAction ); |
|
167 |
|
168 /** |
|
169 * Fills aOutParamList with parameters for action. |
|
170 * |
|
171 * @param aOutParamList parsed list of items |
|
172 * @param aParamList list of items from data base |
|
173 * @param aActionTrigger action trigger |
|
174 */ |
|
175 void FillActionParamListL( |
|
176 CLiwGenericParamList & aOutParamList, |
|
177 const TLiwGenericParam* aParam, |
|
178 RBuf8 & aActionTrigger); |
|
179 |
|
180 /** |
|
181 * Creates map for GetList request - publisher, content_type |
|
182 * and content_id are copied from aMap to returned map |
|
183 * @param aMap - input map |
|
184 * @return input map for GetList request |
|
185 */ |
|
186 CCPLiwMap* CreateMapForGetlistLC( const CCPLiwMap& aMap ); |
|
187 |
|
188 |
|
189 /** |
|
190 * Gets Flag for specified item from DB and returns activate |
|
191 * info |
|
192 * @param aMap - input map |
|
193 * @return activate flag |
|
194 */ |
|
195 TBool GetActivateInfoL( const CCPLiwMap* aMap ); |
|
196 |
|
197 /** |
|
198 * Builds change info list |
|
199 * @param aMap - map containing parameters needed to build change info list |
|
200 * @param aParam - param from getlist result |
|
201 * @param aChangeInfoList - output list containing change info list sent |
|
202 * as notification |
|
203 */ |
|
204 void BuildChangeInfoL( |
|
205 const CCPLiwMap* aMap, |
|
206 const TLiwGenericParam* aParam, |
|
207 CLiwDefaultList* aChangeInfoList ); |
|
208 /** |
|
209 * Builds change info list when query to database returned nothing |
|
210 * @param aMap - map containing parameters needed to build change info list |
|
211 * @param aChangeInfoList - output list containing change info list sent |
|
212 * as notification |
|
213 */ |
|
214 void BuildDefaultChangeInfoL( |
|
215 const CCPLiwMap* aMap, |
|
216 CLiwDefaultList* aChangeInfoList ); |
|
217 |
|
218 |
|
219 /** |
|
220 * Copies variant from in to out map if entry with provided key exists |
|
221 * @param aKey a key |
|
222 * @param aInMap input map |
|
223 * @param aOutMap output map |
|
224 */ |
|
225 void CopyVariantL(const TDesC8& aKey, const CLiwMap* aInMap, |
|
226 CLiwDefaultMap* aOutMap ); |
|
227 |
|
228 /** |
|
229 * Copies variant from in map for key KActionTrigger to out map with key KActionTrigger16 |
|
230 * and formated type(from TDesC8 to TDesC) |
|
231 * @param aInMap input map |
|
232 * @param aOutMap output map |
|
233 */ |
|
234 void CopyActionTrigger16L( const CLiwMap* aInMap, |
|
235 CLiwDefaultMap* aOutMap ); |
|
236 |
|
237 private: |
|
238 // data |
|
239 |
|
240 /* |
|
241 * Storage database |
|
242 * Own. |
|
243 */ |
|
244 CCpStorage* iStorage; |
|
245 |
|
246 /* |
|
247 * Array of registered notification handlers. |
|
248 * Own. |
|
249 */ |
|
250 RPointerArray<CCPNotificationHandler> iNotificationsArray; |
|
251 |
|
252 #ifdef CONTENT_PUBLISHER_DEBUG |
|
253 CCPDebug* iDebug; |
|
254 #endif |
|
255 }; |
|
256 |
|
257 #endif // C_CPDATA_MANAGER_H |
|
258 // end of file |
|