69 __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Entry")); |
69 __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Entry")); |
70 __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Exit")); |
70 __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Exit")); |
71 __FLOG_CLOSE; |
71 __FLOG_CLOSE; |
72 } |
72 } |
73 |
73 |
74 void CMTPImageDpMdeObserver::CreateMetadataL(const CMdEObject& aMdeObject, CMTPObjectMetaData& aMetaData) |
74 void CMTPImageDpMdeObserver::CreateMetadataL(const TParsePtrC& aParse, TMTPFormatCode aFormat, TUint32 aParentHandle, CMTPObjectMetaData& aMetaData) |
75 { |
75 { |
76 const TDesC& uri = aMdeObject.Uri(); |
76 TInt32 storageId = MTPImageDpUtilits::FindStorage(iFramework, aParse.FullName()); |
77 TParsePtrC parse(uri); |
77 |
78 TMTPFormatCode format = iDataProvider.FindFormatL(parse.Ext().Mid(1)); |
78 __FLOG_VA((_L16("Addition - New Image:%S"), &aParse.FullName())); |
79 TInt32 storageId = MTPImageDpUtilits::FindStorage(iFramework, uri); |
|
80 TUint32 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, uri); |
|
81 |
|
82 aMetaData.SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId()); |
79 aMetaData.SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId()); |
83 aMetaData.SetUint(CMTPObjectMetaData::EFormatCode, format); |
80 aMetaData.SetUint(CMTPObjectMetaData::EFormatCode, aFormat); |
84 aMetaData.SetUint(CMTPObjectMetaData::EStorageId, storageId); |
81 aMetaData.SetUint(CMTPObjectMetaData::EStorageId, storageId); |
85 aMetaData.SetDesCL(CMTPObjectMetaData::ESuid, uri); |
82 aMetaData.SetDesCL(CMTPObjectMetaData::ESuid, aParse.FullName()); |
86 aMetaData.SetUint(CMTPObjectMetaData::EParentHandle, parentHandle); |
83 aMetaData.SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle); |
87 aMetaData.SetDesCL(CMTPObjectMetaData::EName, parse.Name()); |
84 aMetaData.SetDesCL(CMTPObjectMetaData::EName, aParse.Name()); |
88 |
85 |
89 //Increate the new pictures variable |
86 //Increate the new pictures variable |
90 ++iNewPics; |
87 ++iNewPics; |
91 } |
88 } |
92 |
89 |
93 void CMTPImageDpMdeObserver::ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType /*aType*/) |
90 void CMTPImageDpMdeObserver::ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType /*aType*/) |
94 { |
91 { |
95 __FLOG_VA((_L8("CMTPImageDpMdeObserver::ProcessMdeNotificationL Start"))); |
92 __FLOG_VA((_L8("CMTPImageDpMdeObserver::ProcessMdeNotificationL Start"))); |
107 if (mdeObject == NULL) |
104 if (mdeObject == NULL) |
108 { |
105 { |
109 continue; |
106 continue; |
110 } |
107 } |
111 CleanupStack::PushL(mdeObject); |
108 CleanupStack::PushL(mdeObject); |
112 |
109 __FLOG_VA((_L16("Addition - ObjectId:%u, URI:%S"), aObjectIdArray[i], &mdeObject->Uri())); |
113 TUint32 handle = iFramework.ObjectMgr().HandleL(mdeObject->Uri()); |
110 |
114 if (handle == KMTPHandleNone) |
111 //filter out all image files other jpeg files |
|
112 TParsePtrC parse(mdeObject->Uri()); |
|
113 TMTPFormatCode format = iDataProvider.FindFormat(parse.Ext().Mid(1)); |
|
114 if (format != EMTPFormatCodeUndefined) |
115 { |
115 { |
116 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); |
116 TUint32 handle = iFramework.ObjectMgr().HandleL(mdeObject->Uri()); |
117 CreateMetadataL(*mdeObject, *object); |
117 if (handle == KMTPHandleNone) |
118 iFramework.ObjectMgr().InsertObjectL(*object); |
118 { |
119 __FLOG_VA((_L16("Addition - Handle:%u, ObjectId:%u, URI:%S"), object->Uint(CMTPObjectMetaData::EHandle), aObjectIdArray[i], &mdeObject->Uri())); |
119 /** |
120 |
120 * Try to find parent handle of new image file |
121 TMTPTypeEvent event; |
121 * if we can't find parent handle we should issue a notification to framework, let framework to enumerate new folder if need |
122 event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded); |
122 */ |
123 event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll); |
123 TUint32 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, parse.FullName()); |
124 event.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone); |
124 if (parentHandle == KMTPHandleNone) |
125 |
125 { |
126 TUint32 handle = object->Uint(CMTPObjectMetaData::EHandle); |
126 __FLOG_VA((_L16("Notify framework - URI:%S"), &mdeObject->Uri())); |
127 event.SetUint32(TMTPTypeEvent::EEventParameter1, handle); |
127 TMTPNotificationParamsFolderChange param = {mdeObject->Uri()}; |
128 iFramework.SendEventL(event); |
128 iFramework.NotifyFrameworkL(EMTPAddFolder, ¶m); |
129 __FLOG_VA((_L8("ProcessMdeNotificationL - EMTPEventCodeObjectAdd, object handle:%u"), handle)); |
129 |
130 |
130 //try to get parent handle if framework complete it's tasks |
131 CleanupStack::PopAndDestroy(object);//object |
131 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, parse.FullName()); |
|
132 __FLOG_VA((_L16("Framework enumeration parent handle:%u"), parentHandle)); |
|
133 } |
|
134 |
|
135 if (parentHandle != KMTPHandleNone) |
|
136 { |
|
137 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); |
|
138 CreateMetadataL(parse, format, parentHandle, *object); |
|
139 iFramework.ObjectMgr().InsertObjectL(*object); |
|
140 __FLOG_VA((_L16("Addition - New Handle:%u"), object->Uint(CMTPObjectMetaData::EHandle))); |
|
141 |
|
142 TMTPTypeEvent event; |
|
143 event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded); |
|
144 event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll); |
|
145 event.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone); |
|
146 |
|
147 TUint32 handle = object->Uint(CMTPObjectMetaData::EHandle); |
|
148 event.SetUint32(TMTPTypeEvent::EEventParameter1, handle); |
|
149 iFramework.SendEventL(event); |
|
150 __FLOG_VA((_L8("ProcessMdeNotificationL - EMTPEventCodeObjectAdd, object handle:%u"), handle)); |
|
151 CleanupStack::PopAndDestroy(object);//object |
|
152 } |
|
153 } |
132 } |
154 } |
133 |
155 |
134 CleanupStack::PopAndDestroy(mdeObject);//mdeObject |
156 CleanupStack::PopAndDestroy(mdeObject);//mdeObject |
135 } |
157 } |
136 |
158 |
186 CMdENamespaceDef& def = mdeSession.GetDefaultNamespaceDefL(); |
208 CMdENamespaceDef& def = mdeSession.GetDefaultNamespaceDefL(); |
187 CMdEObjectDef& imageObjDef = def.GetObjectDefL(MdeConstants::Image::KImageObject); |
209 CMdEObjectDef& imageObjDef = def.GetObjectDefL(MdeConstants::Image::KImageObject); |
188 |
210 |
189 //Only subscribe add observer |
211 //Only subscribe add observer |
190 CMdELogicCondition* addCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd); |
212 CMdELogicCondition* addCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd); |
191 CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty); |
213 CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty); |
192 addCondition->AddPropertyConditionL(itemTypePropDef, ETextPropertyConditionCompareEndsWith, _L("jpeg")); |
214 addCondition->AddObjectConditionL(imageObjDef); |
193 mdeSession.AddObjectObserverL(*this, addCondition, ENotifyAdd); |
215 mdeSession.AddObjectObserverL(*this, addCondition, ENotifyAdd); |
194 CleanupStack::Pop(addCondition); |
216 CleanupStack::Pop(addCondition); |
195 |
217 |
196 iSubscribed = ETrue; |
218 iSubscribed = ETrue; |
197 } |
219 } |