1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 * @internal reviewed 11/07/2007 by M Byrne |
|
22 */ |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include "glxdatasourcemde.h" |
|
27 |
|
28 #include <fbs.h> |
|
29 #include <glxbackgroundtnmessagedefs.h> |
|
30 #include <glxcollectionmessagedefs.h> |
|
31 #include <glxcommandrequest.h> |
|
32 #include <glxgetrequest.h> |
|
33 #include <glxidlistrequest.h> |
|
34 #include <glxlog.h> |
|
35 #include <glxrequest.h> |
|
36 #include <glxthumbnailrequest.h> |
|
37 #include <glxtndatabase.h> |
|
38 #include <glxtnthumbnailcreator.h> |
|
39 #include <mdeobjectcondition.h> |
|
40 #include <mderelationcondition.h> |
|
41 #include <mderelationdef.h> |
|
42 #include <mpxmediageneraldefs.h> |
|
43 #include <mpxmessagegeneraldefs.h> |
|
44 |
|
45 #include "glxdatasourcetaskmde.h" |
|
46 #include "glxdatasourcetaskmdeattribute.h" |
|
47 #include "glxdatasourcetaskmdecommand.h" |
|
48 #include "glxdatasourcetaskmdeidlist.h" |
|
49 #include "glxdatasourcetaskmdethumbnail.h" |
|
50 |
|
51 _LIT(KGlxMdeDataSourceThumbnailDatabase, "glxmdstn"); |
|
52 |
|
53 _LIT(KObjectDefLocation, "Location"); |
|
54 _LIT(KObjectDefNameAlbum, "Album"); |
|
55 _LIT(KObjectDefNameImage, "Image"); |
|
56 _LIT(KObjectDefNameMedia, "MediaObject"); |
|
57 _LIT(KObjectDefNameObject, "Object"); |
|
58 _LIT(KObjectDefNameTag, "Tag"); |
|
59 _LIT(KObjectDefNameVideo, "Video"); |
|
60 _LIT(KPropertyDefNameCreationDate, "CreationDate"); |
|
61 _LIT(KPropertyDefNameLastModifiedDate, "LastModifiedDate"); |
|
62 _LIT(KPropertyDefNameSize, "Size"); |
|
63 _LIT(KPropertyDefNameTitle, "Title"); |
|
64 _LIT(KRelationDefNameContains, "Contains"); |
|
65 |
|
66 _LIT(KObjectDefNameMonth, "MediaObject");/// @todo nasty hack remove and use base object |
|
67 |
|
68 _LIT(KGlxMdeCameraAlbumUri, "Camera album"); |
|
69 _LIT(KGlxMdeFavoritesUri, "Favorites"); |
|
70 |
|
71 #undef __USING_INTELLIGENT_UPDATE_FILTERING |
|
72 |
|
73 // ============================ MEMBER FUNCTIONS ============================== |
|
74 |
|
75 CGlxDataSourceMde* CGlxDataSourceMde::NewL() |
|
76 { |
|
77 GLX_LOG_ENTRY_EXIT("CGlxDataSourceMde* CGlxDataSourceMde::NewL()"); |
|
78 CGlxDataSourceMde* ds = new (ELeave) CGlxDataSourceMde(); |
|
79 CleanupStack::PushL(ds); |
|
80 ds->ConstructL(); |
|
81 CleanupStack::Pop(ds); |
|
82 return ds; |
|
83 } |
|
84 |
|
85 CGlxDataSourceMde::~CGlxDataSourceMde() |
|
86 { |
|
87 GLX_LOG_ENTRY_EXIT("CGlxDataSourceMde::~CGlxDataSourceMde()"); |
|
88 delete iSession; |
|
89 if (iThumbnailCreator) |
|
90 { |
|
91 iThumbnailCreator->Close(iThumbnailDatabase); |
|
92 } |
|
93 delete iThumbnailDatabase; |
|
94 iFs.Close(); |
|
95 RFbsSession::Disconnect(); |
|
96 iMonthArray.Close(); |
|
97 iMonthList.Close(); |
|
98 iUpdateData.Close(); |
|
99 delete iUpdateCallback; |
|
100 delete iCreateSessionCallback; |
|
101 } |
|
102 |
|
103 CGlxDataSourceMde::CGlxDataSourceMde() |
|
104 { |
|
105 GLX_LOG_ENTRY_EXIT("CGlxDataSourceMde::CGlxDataSourceMde()"); |
|
106 } |
|
107 |
|
108 void CGlxDataSourceMde::ConstructL() |
|
109 { |
|
110 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::ConstructL()"); |
|
111 iDataSourceReady = EFalse; |
|
112 User::LeaveIfError(iFs.Connect()); |
|
113 iSession = CMdESession::NewL( *this ); |
|
114 |
|
115 User::LeaveIfError(RFbsSession::Connect()); |
|
116 iThumbnailCreator = CGlxtnThumbnailCreator::InstanceL(); |
|
117 iThumbnailDatabase = CGlxtnThumbnailDatabase::NewL( |
|
118 KGlxMdeDataSourceThumbnailDatabase, this); |
|
119 iCreateSessionCallback = new ( ELeave ) |
|
120 CAsyncCallBack( TCallBack( CreateSession, this ), CActive::EPriorityHigh ); |
|
121 iUpdateCallback = new ( ELeave ) |
|
122 CAsyncCallBack( TCallBack( ProcessItemUpdate, this ), CActive::EPriorityLow ); |
|
123 iUpdateData.Reserve(100); // ignore if it fails |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // from MMdESessionObserver |
|
128 // CMPXCollectionMdEPlugin::HandleSessionOpened |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 void CGlxDataSourceMde::HandleSessionOpened( CMdESession& aSession, TInt aError ) |
|
132 { |
|
133 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleSessionOpened(CMdESession& aSession, TInt aError)"); |
|
134 if( KErrNone != aError ) |
|
135 { |
|
136 HandleSessionError(aSession, aError); |
|
137 } |
|
138 TRAPD(err, DoSessionInitL()); |
|
139 if( KErrNone != err ) |
|
140 { |
|
141 HandleSessionError(aSession, err); |
|
142 } |
|
143 |
|
144 iSessionOpen = ETrue; |
|
145 iDataSourceReady = ETrue; |
|
146 TryStartTask(ETrue); |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // from MMdESessionObserver |
|
151 // CMPXCollectionMdEPlugin::HandleSessionError |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/ ) |
|
155 { |
|
156 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/)"); |
|
157 iSession = NULL; |
|
158 iDataSourceReady = EFalse; |
|
159 iSessionOpen = EFalse; |
|
160 iCreateSessionCallback->CallBack(); |
|
161 } |
|
162 |
|
163 |
|
164 CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver) |
|
165 { |
|
166 GLX_LOG_ENTRY_EXIT("CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver)"); |
|
167 if(dynamic_cast<CGlxCommandRequest*>(aRequest)) |
|
168 { |
|
169 CleanupStack::PushL(aRequest); |
|
170 CGlxDataSourceTaskMdeCommand* task = new (ELeave) CGlxDataSourceTaskMdeCommand(static_cast<CGlxCommandRequest*>(aRequest), aObserver, this); |
|
171 CleanupStack::Pop(aRequest); // now owned by task |
|
172 CleanupStack::PushL(task); |
|
173 task->ConstructL(); |
|
174 CleanupStack::Pop(task); |
|
175 return task; |
|
176 } |
|
177 else if (dynamic_cast< CGlxGetRequest *>(aRequest)) |
|
178 { |
|
179 CleanupStack::PushL(aRequest); |
|
180 CGlxDataSourceTaskMdeAttribute* task = new (ELeave) CGlxDataSourceTaskMdeAttribute(static_cast<CGlxGetRequest*>(aRequest), aObserver, this); |
|
181 CleanupStack::Pop(aRequest); // now owned by task |
|
182 CleanupStack::PushL(task); |
|
183 task->ConstructL(); |
|
184 CleanupStack::Pop(task); |
|
185 return task; |
|
186 } |
|
187 else if (dynamic_cast< CGlxIdListRequest *>(aRequest)) |
|
188 { |
|
189 CleanupStack::PushL(aRequest); |
|
190 CGlxDataSourceTaskMdeIdList* task = new (ELeave) CGlxDataSourceTaskMdeIdList(static_cast<CGlxIdListRequest*>(aRequest), aObserver, this); |
|
191 CleanupStack::Pop(aRequest); // now owned by task |
|
192 CleanupStack::PushL(task); |
|
193 task->ConstructL(); |
|
194 CleanupStack::Pop(task); |
|
195 return task; |
|
196 } |
|
197 else if (dynamic_cast< CGlxThumbnailRequest *>(aRequest)) |
|
198 { |
|
199 CleanupStack::PushL(aRequest); |
|
200 CGlxDataSourceTaskMdeThumbnail* task = new (ELeave) CGlxDataSourceTaskMdeThumbnail(static_cast<CGlxThumbnailRequest*>(aRequest), aObserver, this); |
|
201 CleanupStack::Pop(aRequest); // now owned by task |
|
202 CleanupStack::PushL(task); |
|
203 task->ConstructL(); |
|
204 CleanupStack::Pop(task); |
|
205 return task; |
|
206 } |
|
207 else |
|
208 { |
|
209 User::Leave(KErrNotSupported); |
|
210 return NULL; // stops compiler warning |
|
211 } |
|
212 } |
|
213 |
|
214 void CGlxDataSourceMde::ThumbnailAvailable(const TGlxMediaId& /*aId*/, const TSize& /*aSize*/) |
|
215 { |
|
216 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::ThumbnailAvailable()"); |
|
217 // no implementation |
|
218 } |
|
219 |
|
220 void CGlxDataSourceMde::BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError) |
|
221 { |
|
222 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::BackgroundThumbnailError()"); |
|
223 TSize size(0, 0); |
|
224 TRAP_IGNORE(BackgroundThumbnailMessageL(aId, size, aError)); |
|
225 } |
|
226 |
|
227 void CGlxDataSourceMde::BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError) |
|
228 { |
|
229 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::BackgroundThumbnailMessageL()"); |
|
230 CMPXMessage* message = CMPXMessage::NewL(); |
|
231 CleanupStack::PushL(message); |
|
232 message->SetTObjectValueL(KMPXMessageGeneralId, KGlxMessageIdBackgroundThumbnail); |
|
233 message->SetTObjectValueL<TMPXItemId>(KGlxBackgroundThumbnailMediaId, aId.Value()); |
|
234 message->SetTObjectValueL(KGlxBackgroundThumbnailSize, aSize); |
|
235 message->SetTObjectValueL(KGlxBackgroundThumbnailError, aError); |
|
236 BroadcastMessage(*message); |
|
237 CleanupStack::PopAndDestroy(message); |
|
238 } |
|
239 |
|
240 void CGlxDataSourceMde::DoSessionInitL() |
|
241 { |
|
242 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::DoSessionInitL()"); |
|
243 /// @todo check schema version number |
|
244 iNameSpaceDef = iSession->GetDefaultNamespaceDefL(); |
|
245 if ( !iNameSpaceDef ) |
|
246 { |
|
247 User::Leave(KErrCorrupt); |
|
248 } |
|
249 |
|
250 CMdEObject* cameraAlbum = iSession->GetObjectL(KGlxMdeCameraAlbumUri); |
|
251 if ( !cameraAlbum ) |
|
252 { |
|
253 User::Leave(KErrCorrupt); |
|
254 } |
|
255 iCameraAlbumId = (TGlxMediaId)cameraAlbum->Id(); |
|
256 delete cameraAlbum; |
|
257 |
|
258 CMdEObject* favorites = iSession->GetObjectL(KGlxMdeFavoritesUri); |
|
259 if ( !favorites ) |
|
260 { |
|
261 User::Leave(KErrCorrupt); |
|
262 } |
|
263 iFavoritesId = (TGlxMediaId)favorites->Id(); |
|
264 delete favorites; |
|
265 |
|
266 iContainsDef = iNameSpaceDef->GetRelationDefL(KRelationDefNameContains); |
|
267 |
|
268 iObjectDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameObject); |
|
269 iImageDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameImage); |
|
270 iVideoDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameVideo); |
|
271 iMediaDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameMedia); |
|
272 iAlbumDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameAlbum); |
|
273 iTagDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameTag); |
|
274 iMonthDef = iNameSpaceDef->GetObjectDefL(KObjectDefNameMonth); |
|
275 iLocationDef = iNameSpaceDef->GetObjectDefL(KObjectDefLocation); |
|
276 |
|
277 AddMdEObserversL(); |
|
278 |
|
279 PrepareMonthsL(); |
|
280 } |
|
281 |
|
282 void CGlxDataSourceMde::AddMdEObserversL() |
|
283 { |
|
284 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::AddMdEObserversL()"); |
|
285 iSession->AddRelationObserverL(*this); |
|
286 iSession->AddRelationPresentObserverL(*this); |
|
287 |
|
288 iSession->AddObjectObserverL(*this); |
|
289 iSession->AddObjectPresentObserverL(*this); |
|
290 } |
|
291 |
|
292 void CGlxDataSourceMde::HandleObjectAdded(CMdESession& /*aSession*/, const RArray<TItemId>& aObjectIdArray) |
|
293 { |
|
294 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleObjectAdded()"); |
|
295 ProcessUpdateArray(aObjectIdArray, EMPXItemInserted, ETrue); |
|
296 } |
|
297 |
|
298 void CGlxDataSourceMde::HandleObjectModified(CMdESession& /*aSession*/, const RArray<TItemId>& aObjectIdArray) |
|
299 { |
|
300 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleObjectModified()"); |
|
301 ProcessUpdateArray(aObjectIdArray, EMPXItemModified, ETrue); |
|
302 } |
|
303 |
|
304 void CGlxDataSourceMde::HandleObjectRemoved(CMdESession& /*aSession*/, const RArray<TItemId>& aObjectIdArray) |
|
305 { |
|
306 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleObjectRemoved()"); |
|
307 ProcessUpdateArray(aObjectIdArray, EMPXItemDeleted, ETrue); |
|
308 } |
|
309 |
|
310 void CGlxDataSourceMde::HandleObjectPresent(CMdESession& /*aSession*/, const RArray<TItemId>& aObjectIdArray) |
|
311 { |
|
312 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleObjectPresent()"); |
|
313 ProcessUpdateArray(aObjectIdArray, EMPXItemInserted, ETrue); |
|
314 } |
|
315 void CGlxDataSourceMde::HandleObjectNotPresent(CMdESession& /*aSession*/, const RArray<TItemId>& aObjectIdArray) |
|
316 { |
|
317 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleObjectNotPresent()"); |
|
318 ProcessUpdateArray(aObjectIdArray, EMPXItemDeleted, ETrue); |
|
319 } |
|
320 void CGlxDataSourceMde::HandleRelationAdded(CMdESession& /*aSession*/, const RArray<TItemId>& aRelationIdArray) |
|
321 { |
|
322 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleRelationAdded()"); |
|
323 ProcessUpdateArray(aRelationIdArray, EMPXItemInserted, EFalse); |
|
324 } |
|
325 void CGlxDataSourceMde::HandleRelationRemoved(CMdESession& /*aSession*/, const RArray<TItemId>& aRelationIdArray) |
|
326 { |
|
327 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleRelationRemoved()"); |
|
328 ProcessUpdateArray(aRelationIdArray, EMPXItemDeleted, EFalse); |
|
329 } |
|
330 void CGlxDataSourceMde::HandleRelationModified(CMdESession& /*aSession*/, const RArray<TItemId>& /*aRelationIdArray*/) |
|
331 { |
|
332 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleRelationModified()"); |
|
333 // not used until ordinals are required |
|
334 } |
|
335 void CGlxDataSourceMde::HandleRelationPresent(CMdESession& /*aSession*/, const RArray<TItemId>& aRelationIdArray) |
|
336 { |
|
337 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleRelationPresent()"); |
|
338 ProcessUpdateArray(aRelationIdArray, EMPXItemInserted, EFalse); |
|
339 } |
|
340 void CGlxDataSourceMde::HandleRelationNotPresent(CMdESession& /*aSession*/, const RArray<TItemId>& aRelationIdArray) |
|
341 { |
|
342 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::HandleRelationNotPresent()"); |
|
343 ProcessUpdateArray(aRelationIdArray, EMPXItemDeleted, EFalse); |
|
344 } |
|
345 void CGlxDataSourceMde::ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType, TBool aIsObject) |
|
346 { |
|
347 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::ProcessUpdateArray()"); |
|
348 // only need one message so process first item |
|
349 TUpdateData update; |
|
350 update.iId = aArray[0]; |
|
351 update.iType = aType; |
|
352 update.iIsObject = aIsObject; |
|
353 if( iUpdateData.Count() ) |
|
354 { |
|
355 if( ( iUpdateData[0].iType == aType ) && ( iUpdateData[0].iIsObject ) ) |
|
356 { |
|
357 return; |
|
358 } |
|
359 } |
|
360 if( iUpdateData.Append(update) == KErrNone ) // if we can't allocate space for the update, ignore it |
|
361 { |
|
362 iUpdateCallback->CallBack(); |
|
363 } |
|
364 } |
|
365 TInt CGlxDataSourceMde::CreateSession(TAny* aPtr) |
|
366 { |
|
367 GLX_LOG_ENTRY_EXIT("TInt CGlxDataSourceMde::CreateSession(TAny* aPtr)"); |
|
368 CGlxDataSourceMde* self |
|
369 = reinterpret_cast<CGlxDataSourceMde*>( aPtr ); |
|
370 TRAP_IGNORE(self->CreateSessionL()); |
|
371 return 0; |
|
372 } |
|
373 |
|
374 void CGlxDataSourceMde::CreateSessionL() |
|
375 { |
|
376 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::CreateSessionL()"); |
|
377 iSession = CMdESession::NewL( *this ); |
|
378 } |
|
379 |
|
380 |
|
381 TInt CGlxDataSourceMde::ProcessItemUpdate(TAny* aPtr) |
|
382 { |
|
383 GLX_LOG_ENTRY_EXIT("TInt CGlxDataSourceMde::ProcessItemUpdate(TAny* aPtr)"); |
|
384 CGlxDataSourceMde* self |
|
385 = reinterpret_cast<CGlxDataSourceMde*>( aPtr ); |
|
386 TRAP_IGNORE(self->ProcessItemUpdateL()); |
|
387 return 0; |
|
388 } |
|
389 |
|
390 void CGlxDataSourceMde::ProcessItemUpdateL() |
|
391 { |
|
392 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::ProcessItemUpdateL()"); |
|
393 if ( !iUpdateData.Count() || iPauseUpdate ) |
|
394 { |
|
395 return; |
|
396 } |
|
397 |
|
398 CMPXMessage* message = CMPXMessage::NewL(); |
|
399 CleanupStack::PushL(message); |
|
400 message->SetTObjectValueL<TInt>(KMPXMessageGeneralId, KMPXMessageIdItemChanged); |
|
401 message->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, iUpdateData[0].iType); |
|
402 TMPXGeneralCategory category = EMPXNoCategory; |
|
403 TMPXItemId id = iUpdateData[0].iId; |
|
404 |
|
405 GLX_LOG_INFO2("CGlxDataSourceMde::ProcessItemUpdateL() cat%d, item id %d", category, id.iId1); |
|
406 #ifdef __USING_INTELLIGENT_UPDATE_FILTERING |
|
407 if ( !iUpdateData[0].iIsObject ) |
|
408 { |
|
409 TMPXGeneralCategory containerCategory = EMPXNoCategory; |
|
410 TMPXItemId containerId; |
|
411 |
|
412 CMdERelation* relation = iSession->GetRelationL(id); |
|
413 if( relation ) |
|
414 { |
|
415 TItemId rightId = relation->RightObjectId(); |
|
416 TItemId leftId = relation->LeftObjectId(); |
|
417 delete relation; |
|
418 |
|
419 CMdEObject* contObject = iSession->GetObjectL(leftId); |
|
420 __ASSERT_DEBUG(contObject, Panic(EGlxPanicIllegalState)); |
|
421 TContainerType container = ContainerType(contObject); |
|
422 delete contObject; |
|
423 __ASSERT_DEBUG(( EContainerTypeTag != container), Panic(EGlxPanicIllegalState)); |
|
424 if( EContainerTypeNotAContainer == container ) |
|
425 { |
|
426 CMdEObject* rightObject = iSession->GetObjectL(rightId); |
|
427 __ASSERT_DEBUG(rightObject, Panic(EGlxPanicIllegalState)); |
|
428 TContainerType rightContainer = ContainerType(rightObject); |
|
429 delete rightObject; |
|
430 __ASSERT_DEBUG(( EContainerTypeAlbum != rightContainer), Panic(EGlxPanicIllegalState)); |
|
431 if( EContainerTypeTag == rightContainer ) |
|
432 { |
|
433 id = leftId; |
|
434 containerId = rightId; |
|
435 containerCategory = EMPXTag; |
|
436 } |
|
437 else if( EContainerTypeNotAContainer == rightContainer ) |
|
438 { |
|
439 User::Leave(KErrNotSupported); // Not a gallery relation. |
|
440 } |
|
441 } |
|
442 else if( EContainerTypeAlbum == container) |
|
443 { |
|
444 id = rightId; |
|
445 containerId = leftId; |
|
446 containerCategory = EMPXAlbum; |
|
447 } |
|
448 message->SetTObjectValueL<TMPXGeneralCategory>(KGlxCollectionMessageContainerCategory, containerCategory); |
|
449 message->SetTObjectValueL<TMPXItemId>(KGlxCollectionMessageContainerId, containerId); |
|
450 } |
|
451 else |
|
452 { |
|
453 // use id 0 to identify to ML that we don't know what was deleted |
|
454 id = 0; |
|
455 } |
|
456 } |
|
457 |
|
458 if ( id != 0 ) |
|
459 { |
|
460 CMdEObject* object = iSession->GetObjectL(id); |
|
461 if( object ) |
|
462 { |
|
463 TContainerType container = ContainerType(object); |
|
464 if( EContainerTypeAlbum == container) |
|
465 { |
|
466 category = EMPXAlbum; |
|
467 } |
|
468 else if( EContainerTypeTag == container) |
|
469 { |
|
470 category = EMPXTag; |
|
471 } |
|
472 else |
|
473 { |
|
474 TItemType item = ItemType(object); |
|
475 if( EItemTypeImage == item) |
|
476 { |
|
477 category = EMPXImage; |
|
478 } |
|
479 else if( EItemTypeVideo == item) |
|
480 { |
|
481 category = EMPXVideo; |
|
482 } |
|
483 } |
|
484 delete object; |
|
485 } |
|
486 } |
|
487 #endif // __USING_INTELLIGENT_UPDATE_FILTERING |
|
488 message->SetTObjectValueL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory, category); |
|
489 message->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, id); |
|
490 BroadcastMessage(*message); |
|
491 CleanupStack::PopAndDestroy(message); |
|
492 iUpdateData.Remove(0); |
|
493 } |
|
494 |
|
495 CGlxDataSource::TContainerType CGlxDataSourceMde::ContainerType(CMdEObject* aObject) |
|
496 { |
|
497 GLX_LOG_ENTRY_EXIT("TContainerType CGlxDataSourceMde::ContainerType()"); |
|
498 TContainerType containerType = EContainerTypeNotAContainer; |
|
499 |
|
500 if( 0 == aObject->Def().Compare(*iAlbumDef) ) |
|
501 { |
|
502 containerType = EContainerTypeAlbum; |
|
503 } |
|
504 else if( 0 == aObject->Def().Compare(*iTagDef) ) |
|
505 { |
|
506 containerType = EContainerTypeTag; |
|
507 } |
|
508 else if( 0 == aObject->Def().Compare(*iMonthDef) ) |
|
509 { |
|
510 containerType = EContainerTypeMonth; |
|
511 } |
|
512 |
|
513 return containerType; |
|
514 } |
|
515 |
|
516 CGlxDataSource::TContainerType CGlxDataSourceMde::ContainerType(CMdEObjectDef* aObjectDef) |
|
517 { |
|
518 GLX_LOG_ENTRY_EXIT("TContainerType CGlxDataSourceMde::ContainerType()"); |
|
519 TContainerType containerType = EContainerTypeNotAContainer; |
|
520 |
|
521 if( 0 == aObjectDef->Compare(*iAlbumDef) ) |
|
522 { |
|
523 containerType = EContainerTypeAlbum; |
|
524 } |
|
525 else if( 0 == aObjectDef->Compare(*iTagDef) ) |
|
526 { |
|
527 containerType = EContainerTypeTag; |
|
528 } |
|
529 else if( 0 == aObjectDef->Compare(*iMonthDef) ) |
|
530 { |
|
531 containerType = EContainerTypeMonth; |
|
532 } |
|
533 |
|
534 return containerType; |
|
535 } |
|
536 CGlxDataSource::TItemType CGlxDataSourceMde::ItemType(CMdEObject* aObject) |
|
537 { |
|
538 GLX_LOG_ENTRY_EXIT("TItemType CGlxDataSourceMde::ItemType()"); |
|
539 TItemType itemType = EItemTypeNotAnItem; |
|
540 |
|
541 if( 0 == aObject->Def().Compare(*iImageDef) ) |
|
542 { |
|
543 itemType = EItemTypeImage; |
|
544 } |
|
545 else if(0 == aObject->Def().Compare(*iVideoDef) ) |
|
546 { |
|
547 itemType = EItemTypeVideo; |
|
548 } |
|
549 |
|
550 return itemType; |
|
551 } |
|
552 void CGlxDataSourceMde::PrepareMonthsL() |
|
553 { |
|
554 GLX_LOG_ENTRY_EXIT("void CGlxDataSourceMde::PrepareMonthsL()"); |
|
555 TTime month(0); |
|
556 iFirstMonth = month; |
|
557 } |
|
558 const TGlxMediaId CGlxDataSourceMde::GetMonthIdL(const TTime& aMonth) |
|
559 { |
|
560 GLX_LOG_ENTRY_EXIT("TGlxMediaId CGlxDataSourceMde::GetMonthIdL()"); |
|
561 TTime monthStart = iFirstMonth + aMonth.MonthsFrom(iFirstMonth); |
|
562 const TTimeIntervalMonths KGlxOneMonth = 1; |
|
563 const TTimeIntervalMicroSeconds KGlxOneMicrosecond = 1; |
|
564 |
|
565 TGlxMediaId monthId; |
|
566 TInt monthIndex = iMonthArray.Find(monthStart); |
|
567 if( monthIndex != KErrNotFound ) |
|
568 { |
|
569 monthId = iMonthList[monthIndex]; |
|
570 } |
|
571 else |
|
572 { |
|
573 _LIT(KGlxMonthTitleFormat, "%F%Y%M%D:"); |
|
574 const TInt KGlxMonthTitleLength = 12; |
|
575 TBuf<KGlxMonthTitleLength> title; |
|
576 monthStart.FormatL(title, KGlxMonthTitleFormat); |
|
577 |
|
578 CMdEObject* month = iSession->GetObjectL(title); |
|
579 if( month ) |
|
580 { |
|
581 monthId = (TGlxMediaId)month->Id(); |
|
582 iMonthArray.AppendL(monthStart); |
|
583 iMonthList.AppendL(monthId); |
|
584 delete month; |
|
585 } |
|
586 else |
|
587 { |
|
588 TTime monthEnd = monthStart + KGlxOneMonth - KGlxOneMicrosecond; |
|
589 month = iSession->NewObjectLC(*iMonthDef, title); |
|
590 |
|
591 // A title property def of type text is required. |
|
592 CMdEPropertyDef* titlePropertyDef = iObjectDef->GetPropertyDefL(KPropertyDefNameTitle); |
|
593 if (!titlePropertyDef || titlePropertyDef->PropertyType() != EPropertyText) |
|
594 { |
|
595 User::Leave(KErrCorrupt); |
|
596 } |
|
597 // Set the object title. |
|
598 month->AddTextPropertyL (*titlePropertyDef, title); |
|
599 |
|
600 // A size property is required. |
|
601 CMdEPropertyDef* sizePropertyDef = iObjectDef->GetPropertyDefL(KPropertyDefNameSize); |
|
602 if (!sizePropertyDef || sizePropertyDef->PropertyType() != EPropertyUint32) |
|
603 { |
|
604 User::Leave(KErrCorrupt); |
|
605 } |
|
606 month->AddUint32PropertyL(*sizePropertyDef,0); |
|
607 |
|
608 |
|
609 // A creation date property is required. |
|
610 CMdEPropertyDef* creationDateDef = iObjectDef->GetPropertyDefL(KPropertyDefNameCreationDate); |
|
611 if (!creationDateDef || creationDateDef->PropertyType() != EPropertyTime) |
|
612 { |
|
613 User::Leave(KErrCorrupt); |
|
614 } |
|
615 month->AddTimePropertyL(*creationDateDef, monthStart); |
|
616 |
|
617 // A last modified date property is required. |
|
618 CMdEPropertyDef* lmDateDef = iObjectDef->GetPropertyDefL(KPropertyDefNameLastModifiedDate); |
|
619 if (!lmDateDef || lmDateDef->PropertyType() != EPropertyTime) |
|
620 { |
|
621 User::Leave(KErrCorrupt); |
|
622 } |
|
623 |
|
624 month->AddTimePropertyL(*lmDateDef, monthEnd); |
|
625 |
|
626 monthId = (TGlxMediaId)iSession->AddObjectL(*month); |
|
627 CleanupStack::PopAndDestroy(month); |
|
628 iMonthArray.AppendL(monthStart); |
|
629 iMonthList.AppendL(monthId); |
|
630 } |
|
631 } |
|
632 return monthId; |
|
633 } |
|
634 TBool CGlxDataSourceMde::SameMonth(const TTime& aOldDate, const TTime& aNewDate) |
|
635 { |
|
636 GLX_LOG_ENTRY_EXIT("TBool CGlxDataSourceMde::SameMonth(const TTime& aOldDate, const TTime& aNewDate)"); |
|
637 return ( aOldDate.MonthsFrom(iFirstMonth) == aNewDate.MonthsFrom(iFirstMonth) ); |
|
638 } |
|
639 |
|
640 TBool CGlxDataSourceMde::ContainerIsLeft(CMdEObjectDef& aObjectDef) |
|
641 { |
|
642 GLX_LOG_ENTRY_EXIT("TBool CGlxDataSourceMde::ContainerIsLeft(CMdEObjectDef& aObjectDef)"); |
|
643 TBool containerLeft = EFalse; |
|
644 if ( 0 == aObjectDef.Compare(AlbumDef()) ) |
|
645 { |
|
646 containerLeft = ETrue; |
|
647 } |
|
648 return containerLeft; |
|
649 } |
|
650 |
|
651 void CGlxDataSourceMde::TaskCompletedL() |
|
652 { |
|
653 iPauseUpdate = EFalse; |
|
654 iUpdateCallback->CallBack(); |
|
655 } |
|
656 |
|
657 void CGlxDataSourceMde::TaskStartedL() |
|
658 { |
|
659 iPauseUpdate = ETrue; |
|
660 } |
|
661 |
|