60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: The data source mds class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
* @author Simon Brooks, Alex Birkett
|
|
23 |
*/
|
|
24 |
|
|
25 |
/**
|
|
26 |
* @internal reviewed 10/07/2007 by M Byrne
|
|
27 |
*/
|
|
28 |
|
|
29 |
#ifndef _C_GLXDATASOURCEMDS_H_
|
|
30 |
#define _C_GLXDATASOURCEMDS_H_
|
|
31 |
|
|
32 |
// INCLUDES
|
|
33 |
#include <e32base.h>
|
|
34 |
#include <w32std.h>
|
|
35 |
#include <e32property.h>
|
|
36 |
|
|
37 |
#include <e32cmn.h>
|
|
38 |
#include <f32file.h>
|
|
39 |
|
|
40 |
#include <mdesession.h>
|
|
41 |
|
|
42 |
#include <harvesterclient.h>
|
|
43 |
#include <harvestereventenum.h>
|
|
44 |
|
|
45 |
#include <mglxtnstorage.h>
|
|
46 |
#include <mpxcollectionmessagedefs.h>
|
|
47 |
|
|
48 |
#ifdef USE_S60_TNM
|
|
49 |
#include <thumbnailmanager.h>
|
|
50 |
#include <thumbnailmanagerobserver.h>
|
|
51 |
#include <thumbnaildata.h>
|
|
52 |
#include <thumbnailobjectsource.h>
|
|
53 |
|
|
54 |
#include "mthumbnailfetchrequestobserver.h"
|
|
55 |
#endif
|
|
56 |
#include "glxdatasource.h"
|
|
57 |
|
|
58 |
// FORWARD DECLARATIONS
|
|
59 |
class CGlxRequest;
|
|
60 |
#ifndef USE_S60_TNM
|
|
61 |
class CGlxtnThumbnailCreator;
|
|
62 |
class CGlxtnThumbnailDatabase;
|
|
63 |
#endif
|
|
64 |
class CGlxDataSourceMde ;
|
|
65 |
|
|
66 |
const TUid KHarvesterPSShutdown = { 0x200009F5 } ;
|
|
67 |
const TInt KMdSShutdown = 0x00000002; // values 1 = shutdown, 0 = restart, normal state
|
|
68 |
|
|
69 |
static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
|
|
70 |
static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt);
|
|
71 |
|
|
72 |
/**
|
|
73 |
* PSCW Listener Observer interface for signaling that MDS has Shutdown/restarted
|
|
74 |
*/
|
|
75 |
class MGlxMDSShutdownObserver
|
|
76 |
{
|
|
77 |
public:
|
|
78 |
|
|
79 |
virtual void ShutdownNotification(TInt aShutdownState) = 0;
|
|
80 |
};
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Active object for observing P&S keys
|
|
84 |
*
|
|
85 |
* @since S60 v5.0
|
|
86 |
*/
|
|
87 |
class CGlxMDSShutdownObserver: public CActive
|
|
88 |
{
|
|
89 |
public:
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Two-phased constructor.
|
|
93 |
*
|
|
94 |
* @since S60 v5.0
|
|
95 |
* @return Instance of CGlxMDSShutdownObserver.
|
|
96 |
*/
|
|
97 |
static CGlxMDSShutdownObserver* NewL( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
|
|
98 |
const TInt aPropertyKey, TBool aDefineKey);
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Destructor
|
|
102 |
*
|
|
103 |
* @since S60 v5.0
|
|
104 |
*/
|
|
105 |
virtual ~CGlxMDSShutdownObserver();
|
|
106 |
|
|
107 |
protected:
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Handles an active object's request completion event.
|
|
111 |
*
|
|
112 |
* @since S60 v5.0
|
|
113 |
*/
|
|
114 |
void RunL();
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Implements cancellation of an outstanding request.
|
|
118 |
*
|
|
119 |
* @since S60 v5.0
|
|
120 |
*/
|
|
121 |
void DoCancel();
|
|
122 |
|
|
123 |
private:
|
|
124 |
|
|
125 |
/**
|
|
126 |
* C++ default constructor
|
|
127 |
*
|
|
128 |
* @since S60 v5.0
|
|
129 |
* @return Instance of CGlxMDSShutdownObserver.
|
|
130 |
*/
|
|
131 |
CGlxMDSShutdownObserver( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
|
|
132 |
const TInt iPropertyKey, TBool aDefineKey);
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Symbian 2nd phase constructor can leave.
|
|
136 |
*
|
|
137 |
* @since S60 v5.0
|
|
138 |
*/
|
|
139 |
void ConstructL();
|
|
140 |
|
|
141 |
private:
|
|
142 |
|
|
143 |
// not own
|
|
144 |
MGlxMDSShutdownObserver& iObserver;
|
|
145 |
|
|
146 |
const TUid& iKeyCategory;
|
|
147 |
RProperty iProperty;
|
|
148 |
TInt iPropertyKey;
|
|
149 |
|
|
150 |
TBool iDefineKey;
|
|
151 |
};
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
// CONSTANTS
|
|
156 |
|
|
157 |
// CLASS DECLARATION
|
|
158 |
|
|
159 |
/**
|
|
160 |
* CGlxDataSourceMde class
|
|
161 |
*
|
|
162 |
* Data Source Mde is a Meta Data Data Source.
|
|
163 |
* @lib GlxDataSourceMde.lib
|
|
164 |
* @ingroup collection_component_design
|
|
165 |
*/
|
|
166 |
class CGlxDataSourceMde : public CGlxDataSource,
|
|
167 |
public MMdESessionObserver,
|
|
168 |
public MGlxMDSShutdownObserver,
|
|
169 |
public MMdEObjectObserver,
|
|
170 |
public MMdEObjectPresentObserver,
|
|
171 |
public MMdERelationObserver,
|
|
172 |
public MMdERelationPresentObserver,
|
|
173 |
public MHarvesterEventObserver
|
|
174 |
#ifdef USE_S60_TNM
|
|
175 |
, public MThumbnailManagerObserver
|
|
176 |
#else
|
|
177 |
, public MGlxtnThumbnailStorageObserver
|
|
178 |
#endif
|
|
179 |
{
|
|
180 |
public:
|
|
181 |
static CGlxDataSourceMde* NewL();
|
|
182 |
|
|
183 |
private:
|
|
184 |
~CGlxDataSourceMde();
|
|
185 |
|
|
186 |
CGlxDataSourceMde();
|
|
187 |
|
|
188 |
void ConstructL();
|
|
189 |
|
|
190 |
public:
|
|
191 |
// from CGlxDataSource
|
|
192 |
CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest,
|
|
193 |
MGlxDataSourceRequestObserver& aObserver);
|
|
194 |
public:
|
|
195 |
// from MHarvesterEventObserver
|
|
196 |
void HarvestingUpdated(
|
|
197 |
HarvesterEventObserverType aHEObserverType,
|
|
198 |
HarvesterEventState aHarvesterEventState,
|
|
199 |
TInt aItemsLeft );
|
|
200 |
|
|
201 |
#ifdef USE_S60_TNM
|
|
202 |
public:
|
|
203 |
void FetchThumbnailL(CGlxRequest* aRequest,
|
|
204 |
MThumbnailFetchRequestObserver& aObserver);
|
|
205 |
TInt CancelFetchThumbnail();
|
|
206 |
#else
|
|
207 |
private:
|
|
208 |
// from MGlxtnThumbnailStorageObserver
|
|
209 |
/**
|
|
210 |
* Notify that a given thumbnail is available in storage.
|
|
211 |
* @param aId Media item ID.
|
|
212 |
* @param aSize Requested thumbnail size.
|
|
213 |
*/
|
|
214 |
void ThumbnailAvailable(const TGlxMediaId& aId, const TSize& aSize);
|
|
215 |
/**
|
|
216 |
* Notify that a given thumbnail is available in storage.
|
|
217 |
* @param aId Media item ID.
|
|
218 |
* @param aSize Thumbnail size.
|
|
219 |
*/
|
|
220 |
void BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError);
|
|
221 |
#endif
|
|
222 |
|
|
223 |
private:
|
|
224 |
/**
|
|
225 |
* from MMdESessionObserver
|
|
226 |
*/
|
|
227 |
void HandleSessionOpened(CMdESession& aSession, TInt aError);
|
|
228 |
|
|
229 |
void HandleSessionError(CMdESession& aSession, TInt aError);
|
|
230 |
|
|
231 |
private: // MMdEObjectObserver
|
|
232 |
/**
|
|
233 |
* See @ref MMdEObjectObserver::HandleObjectNotification
|
|
234 |
*/
|
|
235 |
void HandleObjectNotification(CMdESession& aSession,
|
|
236 |
TObserverNotificationType aType,
|
|
237 |
const RArray<TItemId>& aObjectIdArray);
|
|
238 |
|
|
239 |
private: // MMdEObjectPresentObserver
|
|
240 |
/**
|
|
241 |
* See @ref MMdEObjectPresentObserver::HandleObjectPresentNotification
|
|
242 |
*/
|
|
243 |
void HandleObjectPresentNotification(CMdESession& aSession,
|
|
244 |
TBool aPresent, const RArray<TItemId>& aObjectIdArray);
|
|
245 |
|
|
246 |
private: // MMdERelationObserver
|
|
247 |
/**
|
|
248 |
* See @ref MMdERelationObserver::HandleRelationNotification
|
|
249 |
*/
|
|
250 |
void HandleRelationNotification(CMdESession& aSession,
|
|
251 |
TObserverNotificationType aType,
|
|
252 |
const RArray<TItemId>& aRelationIdArray);
|
|
253 |
|
|
254 |
private: //MMdERelationPresentObserver
|
|
255 |
/**
|
|
256 |
* See @ref MMdERelationPresentObserver::HandleRelationPresentNotification
|
|
257 |
*/
|
|
258 |
void HandleRelationPresentNotification(CMdESession& aSession,
|
|
259 |
TBool aPresent, const RArray<TItemId>& aRelationIdArray);
|
|
260 |
|
|
261 |
#ifdef USE_S60_TNM
|
|
262 |
// from MThumbnailManagerObserver
|
|
263 |
void ThumbnailPreviewReady( MThumbnailData& aThumbnail,
|
|
264 |
TThumbnailRequestId aId );
|
|
265 |
|
|
266 |
void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
|
|
267 |
TThumbnailRequestId aId );
|
|
268 |
#endif
|
|
269 |
|
|
270 |
private:
|
|
271 |
void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize,
|
|
272 |
TInt aError);
|
|
273 |
|
|
274 |
void DoSessionInitL();
|
|
275 |
|
|
276 |
void AddMdEObserversL();
|
|
277 |
|
|
278 |
void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType,
|
|
279 |
TBool aIsObject);
|
|
280 |
|
|
281 |
void ProcessItemUpdateL();
|
|
282 |
|
|
283 |
static TInt ProcessItemUpdate(TAny* aPtr);
|
|
284 |
void CreateSessionL();
|
|
285 |
|
|
286 |
static TInt CreateSession(TAny* aPtr);
|
|
287 |
|
|
288 |
void TaskCompletedL();
|
|
289 |
|
|
290 |
void TaskStartedL();
|
|
291 |
|
|
292 |
#ifdef USE_S60_TNM
|
|
293 |
/*
|
|
294 |
* This function doesnt add up any value, added to reduce compiler warnings
|
|
295 |
*/
|
|
296 |
void ThumbnailReadyL( TInt aError, MThumbnailData& aThumbnail,
|
|
297 |
TThumbnailRequestId aId, TBool aQuality );
|
|
298 |
#endif
|
|
299 |
|
|
300 |
public:
|
|
301 |
|
|
302 |
void CreateSession();
|
|
303 |
|
|
304 |
inline CMdESession& Session() const;
|
|
305 |
|
|
306 |
#ifndef USE_S60_TNM
|
|
307 |
inline CGlxtnThumbnailCreator& ThumbnailCreator() const;
|
|
308 |
|
|
309 |
inline CGlxtnThumbnailDatabase& ThumbnailDatabase() const;
|
|
310 |
#endif
|
|
311 |
|
|
312 |
inline RFs& FileServerSession();
|
|
313 |
|
|
314 |
inline const TGlxMediaId& CameraAlbumId() const;
|
|
315 |
|
|
316 |
inline const TGlxMediaId& FavoritesId() const;
|
|
317 |
|
|
318 |
inline CMdENamespaceDef* NamespaceDef() const;
|
|
319 |
|
|
320 |
inline CMdEObjectDef& ObjectDef() const;
|
|
321 |
|
|
322 |
inline CMdEObjectDef& ImageDef() const;
|
|
323 |
|
|
324 |
inline CMdEObjectDef& VideoDef() const;
|
|
325 |
|
|
326 |
inline CMdEObjectDef& AlbumDef() const;
|
|
327 |
|
|
328 |
inline CMdEObjectDef& MediaDef() const;
|
|
329 |
inline CMdEObjectDef& TagDef() const;
|
|
330 |
|
|
331 |
inline CMdERelationDef& ContainsDef() const;
|
|
332 |
|
|
333 |
inline CMdERelationDef& ContainsLocationDef() const;
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Get the location definition.
|
|
337 |
* @return location definition.
|
|
338 |
*/
|
|
339 |
inline CMdEObjectDef& LocationDef() const;
|
|
340 |
|
|
341 |
TContainerType ContainerType(CMdEObject* aObject);
|
|
342 |
|
|
343 |
TContainerType ContainerType(CMdEObjectDef* aObjectDef);
|
|
344 |
|
|
345 |
TItemType ItemType(CMdEObject* aObject);
|
|
346 |
|
|
347 |
TBool ContainerIsLeft(CMdEObjectDef& aObjectDef);
|
|
348 |
|
|
349 |
// from MGlxMDSShutdownObserver
|
|
350 |
void ShutdownNotification(TInt aShutdownState);
|
|
351 |
|
|
352 |
private:
|
|
353 |
#ifdef USE_S60_TNM
|
|
354 |
MThumbnailFetchRequestObserver* iTnFetchObserver;
|
|
355 |
CThumbnailManager* iTnEngine;
|
|
356 |
CFbsBitmap* iTnThumbnail;
|
|
357 |
CFbsBitmap* iThumbnail;
|
|
358 |
TThumbnailRequestId iTnThumbnailCbId;
|
|
359 |
TBool iTnRequestInProgress;
|
|
360 |
TInt iTnHandle;
|
|
361 |
TGlxMediaId iMediaId;
|
|
362 |
|
|
363 |
#else
|
|
364 |
CGlxtnThumbnailCreator* iThumbnailCreator;
|
|
365 |
CGlxtnThumbnailDatabase* iThumbnailDatabase;
|
|
366 |
#endif
|
|
367 |
|
|
368 |
CMdESession* iSession;
|
|
369 |
RFs iFs;
|
|
370 |
TBool iSessionOpen;
|
|
371 |
TGlxMediaId iCameraAlbumId;
|
|
372 |
TGlxMediaId iFavoritesId;
|
|
373 |
|
|
374 |
CMdENamespaceDef* iNameSpaceDef;
|
|
375 |
CMdEObjectDef* iObjectDef;
|
|
376 |
CMdEObjectDef* iImageDef;
|
|
377 |
CMdEObjectDef* iVideoDef;
|
|
378 |
CMdEObjectDef* iAlbumDef;
|
|
379 |
CMdEObjectDef* iMediaDef;
|
|
380 |
CMdEObjectDef* iTagDef;
|
|
381 |
/**
|
|
382 |
* Location object definition.
|
|
383 |
*/
|
|
384 |
CMdEObjectDef* iLocationDef;
|
|
385 |
CMdERelationDef* iContainsDef;
|
|
386 |
CMdERelationDef* iContainsLocationDef;
|
|
387 |
|
|
388 |
RArray<TItemId> iAddedItems;
|
|
389 |
|
|
390 |
CAsyncCallBack* iUpdateCallback;
|
|
391 |
|
|
392 |
CAsyncCallBack* iCreateSessionCallback;
|
|
393 |
|
|
394 |
struct TUpdateData
|
|
395 |
{
|
|
396 |
TItemId iId;
|
|
397 |
TMPXChangeEventType iType;
|
|
398 |
TBool iIsObject;
|
|
399 |
};
|
|
400 |
|
|
401 |
RArray<TUpdateData> iUpdateData;
|
|
402 |
TBool iPauseUpdate;
|
|
403 |
TInt iDeletedCount;
|
|
404 |
|
|
405 |
RHarvesterClient iHC;
|
|
406 |
TBool iHarvestingOngoing;
|
|
407 |
|
|
408 |
CGlxMDSShutdownObserver* iMDSShutdownObserver;
|
|
409 |
|
|
410 |
#ifdef _DEBUG
|
|
411 |
TTime iStartTime;
|
|
412 |
TTime iStopTime;
|
|
413 |
#endif
|
|
414 |
};
|
|
415 |
|
|
416 |
#include "glxdatasourcemds.inl"
|
|
417 |
|
|
418 |
#endif //_C_GLXDATASOURCEMDE_H_
|