63 _LIT(KObjectDefNameImage, "Image"); |
63 _LIT(KObjectDefNameImage, "Image"); |
64 _LIT(KObjectDefNameMedia, "MediaObject"); |
64 _LIT(KObjectDefNameMedia, "MediaObject"); |
65 _LIT(KObjectDefNameObject, "Object"); |
65 _LIT(KObjectDefNameObject, "Object"); |
66 _LIT(KObjectDefNameTag, "Tag"); |
66 _LIT(KObjectDefNameTag, "Tag"); |
67 _LIT(KObjectDefNameVideo, "Video"); |
67 _LIT(KObjectDefNameVideo, "Video"); |
68 _LIT(KPropertyDefNameCreationDate, "CreationDate"); |
|
69 _LIT(KPropertyDefNameLastModifiedDate, "LastModifiedDate"); |
|
70 _LIT(KPropertyDefNameSize, "Size"); |
|
71 _LIT(KPropertyDefNameTitle, "Title"); |
|
72 _LIT(KRelationDefNameContains, "Contains"); |
68 _LIT(KRelationDefNameContains, "Contains"); |
73 _LIT(KRelationDefNameContainsLocation, "ContainsLocation"); |
69 _LIT(KRelationDefNameContainsLocation, "ContainsLocation"); |
74 |
|
75 _LIT(KObjectDefNameMonth, "MediaObject");/// @todo nasty hack remove and use base object |
|
76 |
70 |
77 _LIT(KGlxMdeCameraAlbumUri, "defaultalbum_captured"); |
71 _LIT(KGlxMdeCameraAlbumUri, "defaultalbum_captured"); |
78 _LIT(KGlxMdeFavoritesUri, "defaultalbum_favourites"); |
72 _LIT(KGlxMdeFavoritesUri, "defaultalbum_favourites"); |
79 |
73 |
80 #undef __USING_INTELLIGENT_UPDATE_FILTERING |
74 #undef __USING_INTELLIGENT_UPDATE_FILTERING |
324 if( KErrNone != aError ) |
316 if( KErrNone != aError ) |
325 { |
317 { |
326 HandleSessionError(aSession, aError); |
318 HandleSessionError(aSession, aError); |
327 } |
319 } |
328 TRAPD(err, DoSessionInitL()); |
320 TRAPD(err, DoSessionInitL()); |
329 if( KErrNone != err ) |
321 if (KErrNone == err) |
|
322 { |
|
323 iSessionOpen = ETrue; |
|
324 iDataSourceReady = ETrue; |
|
325 TryStartTask(ETrue); |
|
326 } |
|
327 else |
330 { |
328 { |
331 HandleSessionError(aSession, err); |
329 HandleSessionError(aSession, err); |
332 } |
330 } |
333 |
|
334 iSessionOpen = ETrue; |
|
335 iDataSourceReady = ETrue; |
|
336 TryStartTask(ETrue); |
|
337 } |
331 } |
338 |
332 |
339 // ---------------------------------------------------------------------------- |
333 // ---------------------------------------------------------------------------- |
340 // from MMdESessionObserver |
334 // from MMdESessionObserver |
341 // CMPXCollectionMdEPlugin::HandleSessionError |
335 // CMPXCollectionMdEPlugin::HandleSessionError |
497 iImageDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameImage); |
491 iImageDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameImage); |
498 iVideoDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameVideo); |
492 iVideoDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameVideo); |
499 iMediaDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameMedia); |
493 iMediaDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameMedia); |
500 iAlbumDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameAlbum); |
494 iAlbumDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameAlbum); |
501 iTagDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameTag); |
495 iTagDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameTag); |
502 iMonthDef = &iNameSpaceDef->GetObjectDefL(KObjectDefNameMonth); |
|
503 iLocationDef = &iNameSpaceDef->GetObjectDefL(KObjectDefLocation); |
496 iLocationDef = &iNameSpaceDef->GetObjectDefL(KObjectDefLocation); |
504 |
497 |
505 AddMdEObserversL(); |
498 AddMdEObserversL(); |
506 |
|
507 PrepareMonthsL(); |
|
508 } |
499 } |
509 |
500 |
510 // --------------------------------------------------------------------------- |
501 // --------------------------------------------------------------------------- |
511 // AddMdEObserversL |
502 // AddMdEObserversL |
512 // --------------------------------------------------------------------------- |
503 // --------------------------------------------------------------------------- |
907 { |
890 { |
908 itemType = EItemTypeVideo; |
891 itemType = EItemTypeVideo; |
909 } |
892 } |
910 |
893 |
911 return itemType; |
894 return itemType; |
912 } |
895 } |
913 |
|
914 // --------------------------------------------------------------------------- |
|
915 // PrepareMonthsL() |
|
916 // --------------------------------------------------------------------------- |
|
917 // |
|
918 void CGlxDataSourceMde::PrepareMonthsL() |
|
919 { |
|
920 TRACER("CGlxDataSourceMde::PrepareMonthsL()"); |
|
921 TTime month(0); |
|
922 iFirstMonth = month; |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // GetMonthIdL() |
|
927 // --------------------------------------------------------------------------- |
|
928 // |
|
929 const TGlxMediaId CGlxDataSourceMde::GetMonthIdL(const TTime& aMonth) |
|
930 { |
|
931 TRACER("CGlxDataSourceMde::GetMonthIdL()"); |
|
932 TTime monthStart = iFirstMonth + aMonth.MonthsFrom(iFirstMonth); |
|
933 const TTimeIntervalMonths KGlxOneMonth = 1; |
|
934 const TTimeIntervalMicroSeconds KGlxOneMicrosecond = 1; |
|
935 |
|
936 TGlxMediaId monthId; |
|
937 TInt monthIndex = iMonthArray.Find(monthStart); |
|
938 if( monthIndex != KErrNotFound ) |
|
939 { |
|
940 monthId = iMonthList[monthIndex]; |
|
941 } |
|
942 else |
|
943 { |
|
944 _LIT(KGlxMonthTitleFormat, "%F%Y%M%D:"); |
|
945 const TInt KGlxMonthTitleLength = 12; |
|
946 TBuf<KGlxMonthTitleLength> title; |
|
947 monthStart.FormatL(title, KGlxMonthTitleFormat); |
|
948 |
|
949 CMdEObject* month = iSession->GetObjectL(title); |
|
950 if( month ) |
|
951 { |
|
952 monthId = (TGlxMediaId)month->Id(); |
|
953 iMonthArray.AppendL(monthStart); |
|
954 iMonthList.AppendL(monthId); |
|
955 delete month; |
|
956 } |
|
957 else |
|
958 { |
|
959 TTime monthEnd = monthStart + KGlxOneMonth - KGlxOneMicrosecond; |
|
960 month = iSession->NewObjectLC(*iMonthDef, title); |
|
961 |
|
962 // A title property def of type text is required. |
|
963 CMdEPropertyDef& titlePropertyDef = iObjectDef->GetPropertyDefL( |
|
964 KPropertyDefNameTitle); |
|
965 if (titlePropertyDef.PropertyType() != EPropertyText) |
|
966 { |
|
967 User::Leave(KErrCorrupt); |
|
968 } |
|
969 // Set the object title. |
|
970 month->AddTextPropertyL (titlePropertyDef, title); |
|
971 |
|
972 // A size property is required. |
|
973 CMdEPropertyDef& sizePropertyDef = iObjectDef->GetPropertyDefL( |
|
974 KPropertyDefNameSize); |
|
975 if (sizePropertyDef.PropertyType() != EPropertyUint32) |
|
976 { |
|
977 User::Leave(KErrCorrupt); |
|
978 } |
|
979 month->AddUint32PropertyL(sizePropertyDef,0); |
|
980 |
|
981 |
|
982 // A creation date property is required. |
|
983 CMdEPropertyDef& creationDateDef = iObjectDef->GetPropertyDefL( |
|
984 KPropertyDefNameCreationDate); |
|
985 if (creationDateDef.PropertyType() != EPropertyTime) |
|
986 { |
|
987 User::Leave(KErrCorrupt); |
|
988 } |
|
989 month->AddTimePropertyL(creationDateDef, monthStart); |
|
990 |
|
991 // A last modified date property is required. |
|
992 CMdEPropertyDef& lmDateDef = iObjectDef->GetPropertyDefL( |
|
993 KPropertyDefNameLastModifiedDate); |
|
994 if (lmDateDef.PropertyType() != EPropertyTime) |
|
995 { |
|
996 User::Leave(KErrCorrupt); |
|
997 } |
|
998 |
|
999 month->AddTimePropertyL(lmDateDef, monthEnd); |
|
1000 |
|
1001 monthId = (TGlxMediaId)iSession->AddObjectL(*month); |
|
1002 CleanupStack::PopAndDestroy(month); |
|
1003 iMonthArray.AppendL(monthStart); |
|
1004 iMonthList.AppendL(monthId); |
|
1005 } |
|
1006 } |
|
1007 return monthId; |
|
1008 } |
|
1009 |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // SameMonth |
|
1012 // --------------------------------------------------------------------------- |
|
1013 // |
|
1014 TBool CGlxDataSourceMde::SameMonth(const TTime& aOldDate, const TTime& aNewDate) |
|
1015 { |
|
1016 TRACER("CGlxDataSourceMde::SameMonth(const TTime& aOldDate, const TTime& aNewDate)") |
|
1017 return ( aOldDate.MonthsFrom(iFirstMonth) == aNewDate.MonthsFrom(iFirstMonth) ); |
|
1018 } |
|
1019 |
896 |
1020 // --------------------------------------------------------------------------- |
897 // --------------------------------------------------------------------------- |
1021 // ContainerIsLeft |
898 // ContainerIsLeft |
1022 // --------------------------------------------------------------------------- |
899 // --------------------------------------------------------------------------- |
1023 // |
900 // |