|
1 /* |
|
2 * Copyright (c) 2007-2009 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: Metadata engine Harverster Server client session* |
|
15 */ |
|
16 |
|
17 #ifndef __MDEHARVESTERSESSION_H__ |
|
18 #define __MDEHARVESTERSESSION_H__ |
|
19 |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <badesca.h> |
|
23 |
|
24 #include <mdesession.h> |
|
25 |
|
26 #include "mdscommoninternal.h" |
|
27 |
|
28 class CMdESessionImpl; |
|
29 class CMdCSerializationBuffer; |
|
30 |
|
31 NONSHARABLE_CLASS(TGetPendingPgckWrapper) |
|
32 { |
|
33 private: |
|
34 TDefId iObjectDefId; |
|
35 |
|
36 public: |
|
37 |
|
38 TPckgC<TDefId> iObjectDefIdPckg; |
|
39 TPckg<TInt> iIdCountPckg; |
|
40 |
|
41 TGetPendingPgckWrapper(TDefId aObjectDefId, TInt& aIdCount) : |
|
42 iObjectDefId(aObjectDefId), iObjectDefIdPckg(iObjectDefId), |
|
43 iIdCountPckg(aIdCount) |
|
44 { |
|
45 } |
|
46 |
|
47 TInt GetIdCount() |
|
48 { |
|
49 return iIdCountPckg(); |
|
50 } |
|
51 }; |
|
52 |
|
53 /** |
|
54 * Metadata Engine Harvester Server session. |
|
55 */ |
|
56 NONSHARABLE_CLASS(CMdEHarvesterSession) : public CBase |
|
57 { |
|
58 public: |
|
59 /* Constructors and destructor. */ |
|
60 |
|
61 /** |
|
62 * Opens a new metadata engine harvester server session. |
|
63 * |
|
64 * @param aObserver observer to notify when opening the session has been |
|
65 * completed |
|
66 * |
|
67 * @return metadata engine session |
|
68 */ |
|
69 IMPORT_C static CMdEHarvesterSession* NewL(CMdESession& aSession); |
|
70 |
|
71 /** |
|
72 * Opens a new metadata engine harvester server session and leaves the |
|
73 * session in the cleanup stack. |
|
74 * |
|
75 * @param aObserver observer to notify when opening the session has been |
|
76 * completed |
|
77 * |
|
78 * @return metadata engine session |
|
79 */ |
|
80 IMPORT_C static CMdEHarvesterSession* NewLC(CMdESession& aSession); |
|
81 |
|
82 /** |
|
83 * Destructor. |
|
84 */ |
|
85 ~CMdEHarvesterSession(); |
|
86 |
|
87 IMPORT_C void SetSession( CMdESession& aSession ); |
|
88 |
|
89 IMPORT_C CMdESession& SessionRef(); |
|
90 |
|
91 // DEPRICATED |
|
92 IMPORT_C CMdESession* Session(); |
|
93 |
|
94 /** |
|
95 * Add memory card with given media ID and current time. If memory card |
|
96 * already exist only time is updated to current time. |
|
97 * |
|
98 * @param memory card's media ID |
|
99 */ |
|
100 IMPORT_C void AddMemoryCard(TUint32 aMediaId); |
|
101 |
|
102 /** |
|
103 * Get latest memory card's media ID. |
|
104 * @param returned memory card's media ID |
|
105 * @return EFalse if there is no any memory cards added |
|
106 */ |
|
107 IMPORT_C TBool GetMemoryCard(TUint32& aMediaId); |
|
108 |
|
109 /** |
|
110 * Check if there is memory card with given media ID already in DB. |
|
111 * |
|
112 * @param memory card's media ID |
|
113 * @param returned boolean if memory card exists or not |
|
114 * |
|
115 * @return EFalse if there was error |
|
116 * |
|
117 * @depricated |
|
118 */ |
|
119 IMPORT_C TBool CheckMemoryCard(TUint32 aMediaId, TBool& aExist); |
|
120 |
|
121 /** |
|
122 * Set media's media ID, drive and present state. |
|
123 * |
|
124 * @param aMediaId media's media ID |
|
125 * @param aDrive media's drive |
|
126 * @param aPresentState media's present state |
|
127 */ |
|
128 IMPORT_C void SetMediaL(TUint32 aMediaId, TChar aDrive, |
|
129 TBool aPresentState); |
|
130 |
|
131 /** |
|
132 * Get media's drive and present state by media ID. |
|
133 * |
|
134 * @param aMediaId media's media ID |
|
135 * @param aDrive returned media's drive |
|
136 * @param aPresentState returned media's present state |
|
137 * @return EFalse if there is no media with matching media ID in DB |
|
138 */ |
|
139 IMPORT_C TBool GetMediaL(TUint32 aMediaId, TChar& aDrive, |
|
140 TBool& aPresentState); |
|
141 |
|
142 /** |
|
143 * Get present medias' media IDs and drives. |
|
144 * |
|
145 * @param aMedias returned present medias' media IDs and drives |
|
146 */ |
|
147 IMPORT_C void GetPresentMediasL(RArray<TMdEMediaInfo>& aMedias); |
|
148 |
|
149 /** |
|
150 * Set file to present state. |
|
151 * |
|
152 * @param aMediaId file's media ID |
|
153 * @param aUri file's URI |
|
154 * @param aFileInfo file's modified date and byte size |
|
155 * |
|
156 * @return ETrue if file existed and changing to present state was |
|
157 * successful |
|
158 * |
|
159 * @depricated |
|
160 */ |
|
161 IMPORT_C TBool SetFileToPresent(TUint32 aMediaId, const TDesC& aUri, |
|
162 TMdSFileInfo& aFileInfo); |
|
163 |
|
164 /** |
|
165 * Set files to present state. |
|
166 * |
|
167 * @param aMediaId file's media ID |
|
168 * @param aUris files' URIs |
|
169 * @param aFileInfos files' modified dates and byte sizes |
|
170 * @param aResults Values from TFilePresentStates |
|
171 */ |
|
172 IMPORT_C void SetFilesToPresentL(TUint32 aMediaId, |
|
173 const RArray<TPtrC>& aUris, |
|
174 const RArray<TMdSFileInfo>& aFileInfos, |
|
175 RArray<TFilePresentStates>& aResults); |
|
176 |
|
177 /** |
|
178 * Set all files, which media ID is given, to not present or start up not |
|
179 * present state. |
|
180 * |
|
181 * @param aMediaId memory card's media ID |
|
182 * @deprecated |
|
183 */ |
|
184 IMPORT_C void SetFilesToNotPresent(TUint32 aMediaId); |
|
185 |
|
186 /** |
|
187 * Remove all objects, which are in not present state, with given media ID |
|
188 * |
|
189 * @param aMediaId memory card's media ID |
|
190 * @deprecated |
|
191 */ |
|
192 IMPORT_C void RemoveFilesNotPresent(TUint32 aMediaId); |
|
193 |
|
194 /** |
|
195 * Set all files, which media ID is given, to not present state. |
|
196 * If aMediaId is 0, call is silently ignored. |
|
197 * |
|
198 * @param aMediaId memory card's media ID |
|
199 * @param aStartUp is start up or normal mount |
|
200 */ |
|
201 IMPORT_C void SetFilesToNotPresent(TUint32 aMediaId, TBool aStartUp); |
|
202 |
|
203 /** |
|
204 * Remove all objects, which are in not present state, with given media ID. |
|
205 * |
|
206 * @param aMediaId memory card's media ID |
|
207 * @param aStartUp is start up or normal mount |
|
208 */ |
|
209 IMPORT_C void RemoveFilesNotPresent(TUint32 aMediaId, TBool aStartUp); |
|
210 |
|
211 /** |
|
212 * Create global harvester prioritization chunk and set it to MdE Server. |
|
213 * There can be only one chunk and observer at once. If MdE Server already |
|
214 * contains active observer, old observer completes with KErrAbort, chunk |
|
215 * is always changed to this new one. Observer is added using |
|
216 * DoAddHarvestingPrioritizationObserver. |
|
217 * |
|
218 * @param aSize the size of global chunk that will receive object |
|
219 * URIs which need to be prioritize |
|
220 */ |
|
221 IMPORT_C void SetHarvestingPrioritizationChunkL( TInt aSize ); |
|
222 |
|
223 /** |
|
224 * Add harvester prioritization observer to MdE Server. There can be |
|
225 * only one chunk and observer at once. If MdE Server already contains |
|
226 * active observer, aStatus completes with KErrAlreadyExists. When MdE |
|
227 * Server needs prioritize object, aStatus completes with KErrNone. |
|
228 * |
|
229 * @param aStatus the asynchronous response status which is changed |
|
230 * when there is object URIs to be prioritize |
|
231 */ |
|
232 IMPORT_C void AddHarvestingPrioritizationObserver(TRequestStatus& aStatus); |
|
233 |
|
234 /** |
|
235 * Cancel harvester prioritization observer from MdE Server. |
|
236 * |
|
237 * @return If MdE Server doesn't have outstanding observer method |
|
238 * returns KErrNotFound, otherwise KErrNone is returned. |
|
239 */ |
|
240 IMPORT_C TInt CancelHarvestingPrioritizationObserver(); |
|
241 |
|
242 /** |
|
243 * Return harvester prioritization URI count. Data is valid only after |
|
244 * AddHarvestingPrioritizationObserver aStatus is completed. |
|
245 * |
|
246 * @return harvester prioritization URI count |
|
247 */ |
|
248 IMPORT_C TInt HarvestingPrioritizationUriCountL(); |
|
249 |
|
250 /** |
|
251 * Return harvester prioritization URI from index aIndex. Data is valid |
|
252 * only after AddHarvestingPrioritizationObserver aStatus is completed. |
|
253 * |
|
254 * @return harvester prioritization URI, ownership is transfered to caller |
|
255 */ |
|
256 IMPORT_C HBufC* HarvestingPrioritizationUriL( TInt aIndex ); |
|
257 |
|
258 /** |
|
259 * Objects are left locked automatically after those are added to DB. Only |
|
260 * properties and freetexts can be modified after those objects are added |
|
261 * to DB. Objects' locking must be removed by commiting those to DB or |
|
262 * canceling object. |
|
263 * |
|
264 * @param aObjects Array of object to be auto locked after adding |
|
265 */ |
|
266 IMPORT_C void AutoLockL( RPointerArray<CMdEObject>& aObjects ); |
|
267 |
|
268 /** |
|
269 * Change path of objects. |
|
270 * |
|
271 * @param aOldPath old path |
|
272 * @param aNewPath new path |
|
273 * @param aStatus the asynchronous response status which is changed when |
|
274 * URIs are changed |
|
275 */ |
|
276 IMPORT_C void ChangePath( const TDesC& aOldPath, const TDesC& aNewPath, |
|
277 TRequestStatus& aStatus ); |
|
278 |
|
279 /** |
|
280 * Update current C-drive media id to all objects in DB that have the old media id. |
|
281 */ |
|
282 void ChangeCDriveMediaId(); |
|
283 |
|
284 /** |
|
285 * Set "binary composing to file" pending flag to objects |
|
286 * |
|
287 * @param aObjectId object IDs |
|
288 */ |
|
289 IMPORT_C void SetPendingL( const RArray<TItemId>& aObjectIds ); |
|
290 |
|
291 /** |
|
292 * Reset "binary composing to file" pending flag from objects |
|
293 * |
|
294 * @param aObjectId object IDs |
|
295 */ |
|
296 IMPORT_C void ResetPendingL( const RArray<TItemId>& aObjectIds ); |
|
297 |
|
298 /** |
|
299 * Get count of objects with "binary composing to file" pending flag |
|
300 * |
|
301 * @param aObjectDef object definition which limits what objects are |
|
302 * returned or NULL when all objects are returned |
|
303 * |
|
304 * @return count of objects |
|
305 */ |
|
306 IMPORT_C TInt GetPendingCount( const CMdEObjectDef* aObjectDef ); |
|
307 |
|
308 /** |
|
309 * Get objects with "binary composing to file" pending flag |
|
310 * |
|
311 * @param aObjectDef object definition which limits what objects are |
|
312 * returned or NULL when all objects are returned |
|
313 * @param aObjectIdCount count of returned object IDs |
|
314 * @param aObjectIdBuffer serialized buffer of returned object IDs |
|
315 * |
|
316 * @return If returned value is > 0, buffer is not large enough for |
|
317 * objects ID from DB, otherwise error code is returned. |
|
318 */ |
|
319 IMPORT_C TInt GetPending( |
|
320 const CMdEObjectDef* aObjectDef, TInt& aObjectIdCount, |
|
321 CMdCSerializationBuffer& aObjectIdBuffer ); |
|
322 |
|
323 /** |
|
324 * Reset DB |
|
325 * only for internal use (works in DEBUG ONLY!!) |
|
326 */ |
|
327 IMPORT_C void ResetDBL(); |
|
328 |
|
329 private: |
|
330 CMdESessionImpl* iSession; |
|
331 |
|
332 RChunk iHarvestingPrioritizationChunk; |
|
333 |
|
334 CMdCSerializationBuffer* iHarvestingPrioritizationSerializationBuffer; |
|
335 |
|
336 protected: |
|
337 |
|
338 /* Constructors. */ |
|
339 |
|
340 /** |
|
341 * Constructor. |
|
342 */ |
|
343 CMdEHarvesterSession(CMdESession& aSession); |
|
344 |
|
345 /** |
|
346 * Second-phase constructor. |
|
347 */ |
|
348 void ConstructL(); |
|
349 }; |
|
350 |
|
351 #endif // __MDEHARVESTERSESSION_H__ |