27 #include "cmtprequestprocessor.h" |
27 #include "cmtprequestprocessor.h" |
28 #include "mtpfiledpconst.h" |
28 #include "mtpfiledpconst.h" |
29 #include "mtpfiledppanic.h" |
29 #include "mtpfiledppanic.h" |
30 #include "mtpfiledpprocessor.h" |
30 #include "mtpfiledpprocessor.h" |
31 #include "cmtpdataprovidercontroller.h" |
31 #include "cmtpdataprovidercontroller.h" |
|
32 #include "OstTraceDefinitions.h" |
|
33 #ifdef OST_TRACE_COMPILER_IN_USE |
|
34 #include "cmtpfiledpTraces.h" |
|
35 #endif |
|
36 |
32 |
37 |
33 // Class constants |
38 // Class constants |
34 static const TInt KArrayGranularity = 3; |
39 static const TInt KArrayGranularity = 3; |
35 static const TInt KActiveEnumeration = 0; |
40 static const TInt KActiveEnumeration = 0; |
36 __FLOG_STMT(_LIT8(KComponent,"CMTPFileDataProvider");) |
|
37 |
41 |
38 /** |
42 /** |
39 File data provider factory method. |
43 File data provider factory method. |
40 @return A pointer to a file data provider object. Ownership IS transfered. |
44 @return A pointer to a file data provider object. Ownership IS transfered. |
41 @leave One of the system wide error codes, if a processing failure occurs. |
45 @leave One of the system wide error codes, if a processing failure occurs. |
52 /** |
56 /** |
53 Destructor |
57 Destructor |
54 */ |
58 */ |
55 CMTPFileDataProvider::~CMTPFileDataProvider() |
59 CMTPFileDataProvider::~CMTPFileDataProvider() |
56 { |
60 { |
57 __FLOG(_L8("~CMTPFileDataProvider - Entry")); |
61 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_CMTPFILEDATAPROVIDER_DES_ENTRY ); |
58 iPendingEnumerations.Close(); |
62 iPendingEnumerations.Close(); |
59 TUint count(iActiveProcessors.Count()); |
63 TUint count(iActiveProcessors.Count()); |
60 while (count--) |
64 while (count--) |
61 { |
65 { |
62 iActiveProcessors[count]->Release(); |
66 iActiveProcessors[count]->Release(); |
65 iDpSingletons.Close(); |
69 iDpSingletons.Close(); |
66 iFileDPSingletons.Close(); |
70 iFileDPSingletons.Close(); |
67 iSingletons.Close(); |
71 iSingletons.Close(); |
68 delete iFileEnumerator; |
72 delete iFileEnumerator; |
69 delete iExclusionMgr; |
73 delete iExclusionMgr; |
70 __FLOG(_L8("~CMTPFileDataProvider - Exit")); |
74 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_CMTPFILEDATAPROVIDER_DES_EXIT ); |
71 __FLOG_CLOSE; |
|
72 } |
75 } |
73 |
76 |
74 void CMTPFileDataProvider::Cancel() |
77 void CMTPFileDataProvider::Cancel() |
75 { |
78 { |
76 __FLOG(_L8("Cancel - Entry")); |
79 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_CANCEL_ENTRY ); |
77 iFileEnumerator->Cancel(); |
80 iFileEnumerator->Cancel(); |
78 __FLOG(_L8("Cancel - Exit")); |
81 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_CANCEL_EXIT ); |
79 } |
82 } |
80 |
83 |
81 void CMTPFileDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
84 void CMTPFileDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
82 { |
85 { |
83 __FLOG(_L8("ProcessEventL - Entry")); |
86 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_PROCESSEVENTL_ENTRY ); |
84 TInt idx(LocateRequestProcessorL(aEvent, aConnection)); |
87 TInt idx(LocateRequestProcessorL(aEvent, aConnection)); |
85 |
88 |
86 if (idx != KErrNotFound) |
89 if (idx != KErrNotFound) |
87 { |
90 { |
88 iActiveProcessors[idx]->HandleEventL(aEvent); |
91 iActiveProcessors[idx]->HandleEventL(aEvent); |
89 } |
92 } |
90 __FLOG(_L8("ProcessEventL - Exit")); |
93 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_PROCESSEVENTL_EXIT ); |
91 } |
94 } |
92 |
95 |
93 void CMTPFileDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
96 void CMTPFileDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
94 { |
97 { |
95 __FLOG(_L8("ProcessNotificationL - Entry")); |
98 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_PROCESSNOTIFICATIONL_ENTRY ); |
96 switch (aNotification) |
99 switch (aNotification) |
97 { |
100 { |
98 case EMTPSessionClosed: |
101 case EMTPSessionClosed: |
99 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
102 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
100 break; |
103 break; |
105 |
108 |
106 default: |
109 default: |
107 // Ignore all other notifications. |
110 // Ignore all other notifications. |
108 break; |
111 break; |
109 } |
112 } |
110 __FLOG(_L8("ProcessNotificationL - Exit")); |
113 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_PROCESSNOTIFICATIONL_EXIT ); |
111 } |
114 } |
112 |
115 |
113 void CMTPFileDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
116 void CMTPFileDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
114 { |
117 { |
115 __FLOG(_L8("ProcessRequestPhaseL - Entry")); |
118 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_PROCESSREQUESTPHASEL_ENTRY ); |
116 TInt idx(LocateRequestProcessorL(aRequest, aConnection)); |
119 TInt idx(LocateRequestProcessorL(aRequest, aConnection)); |
117 __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPFileDpNoMatchingProcessor)); |
120 __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPFileDpNoMatchingProcessor)); |
118 MMTPRequestProcessor* processor(iActiveProcessors[idx]); |
121 MMTPRequestProcessor* processor(iActiveProcessors[idx]); |
119 iActiveProcessor = idx; |
122 iActiveProcessor = idx; |
120 iActiveProcessorRemoved = EFalse; |
123 iActiveProcessorRemoved = EFalse; |
128 processor->Release(); |
131 processor->Release(); |
129 iActiveProcessors.Remove(idx); |
132 iActiveProcessors.Remove(idx); |
130 } |
133 } |
131 iActiveProcessor = -1; |
134 iActiveProcessor = -1; |
132 |
135 |
133 __FLOG(_L8("ProcessRequestPhaseL - Exit")); |
136 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_PROCESSREQUESTPHASEL_EXIT ); |
134 } |
137 } |
135 |
138 |
136 void CMTPFileDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
139 void CMTPFileDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
137 { |
140 { |
138 __FLOG(_L8("StartObjectEnumerationL - Entry")); |
141 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_STARTOBJECTENUMERATIONL_ENTRY ); |
139 iPendingEnumerations.AppendL(aStorageId); |
142 iPendingEnumerations.AppendL(aStorageId); |
140 CMTPDataProviderController& dpController(iSingletons.DpController()); |
143 CMTPDataProviderController& dpController(iSingletons.DpController()); |
141 //must read this NeedEnumeratingPhase2 before this function return |
144 //must read this NeedEnumeratingPhase2 before this function return |
142 TBool bScanAll = dpController.NeedEnumeratingPhase2(); |
145 TBool bScanAll = dpController.NeedEnumeratingPhase2(); |
143 iFileEnumerator->StartL(iPendingEnumerations[KActiveEnumeration], bScanAll); |
146 iFileEnumerator->StartL(iPendingEnumerations[KActiveEnumeration], bScanAll); |
144 __FLOG(_L8("StartObjectEnumerationL - Exit")); |
147 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_STARTOBJECTENUMERATIONL_EXIT ); |
145 } |
148 } |
146 |
149 |
147 void CMTPFileDataProvider::StartStorageEnumerationL() |
150 void CMTPFileDataProvider::StartStorageEnumerationL() |
148 { |
151 { |
149 __FLOG(_L8("StartStorageEnumerationL - Entry")); |
152 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_STARTSTORAGEENUMERATIONL_ENTRY ); |
150 iExclusionMgr->AppendFormatExclusionListL(); |
153 iExclusionMgr->AppendFormatExclusionListL(); |
151 iDpSingletons.MTPUtility().FormatExtensionMapping(); |
154 iDpSingletons.MTPUtility().FormatExtensionMapping(); |
152 Framework().StorageEnumerationCompleteL(); |
155 Framework().StorageEnumerationCompleteL(); |
153 __FLOG(_L8("StartStorageEnumerationL - Exit")); |
156 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_STARTSTORAGEENUMERATIONL_EXIT ); |
154 } |
157 } |
155 |
158 |
156 void CMTPFileDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
159 void CMTPFileDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
157 { |
160 { |
158 __FLOG(_L8("Supported - Entry")); |
161 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_SUPPORTED_ENTRY ); |
159 switch (aCategory) |
162 switch (aCategory) |
160 { |
163 { |
161 case EEvents: |
164 case EEvents: |
162 break; |
165 break; |
163 |
166 |
202 default: |
205 default: |
203 |
206 |
204 // Unrecognised category, leave aArray unmodified. |
207 // Unrecognised category, leave aArray unmodified. |
205 break; |
208 break; |
206 } |
209 } |
207 __FLOG(_L8("Supported - Exit")); |
210 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_SUPPORTED_EXIT ); |
208 } |
211 } |
209 |
212 |
210 #ifdef __FLOG_ACTIVE |
|
211 void CMTPFileDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError) |
213 void CMTPFileDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError) |
212 #else |
214 { |
213 void CMTPFileDataProvider::NotifyEnumerationCompleteL(TUint32 /*aStorageId*/, TInt /*aError*/) |
215 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL_ENTRY ); |
214 #endif // __FLOG_ACTIVE |
216 OstTraceExt2( TRACE_NORMAL, CMTPFILEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL, |
215 { |
217 "Enumeration of storage 0x%08X completed with error status %d", aStorageId, (TInt32)aError); |
216 __FLOG(_L8("HandleEnumerationCompletedL - Entry")); |
|
217 __FLOG_VA((_L8("Enumeration of storage 0x%08X completed with error status %d"), aStorageId, aError)); |
|
218 __ASSERT_DEBUG((aStorageId == iPendingEnumerations[KActiveEnumeration]), User::Invariant()); |
218 __ASSERT_DEBUG((aStorageId == iPendingEnumerations[KActiveEnumeration]), User::Invariant()); |
219 |
219 |
220 Framework().ObjectEnumerationCompleteL(iPendingEnumerations[KActiveEnumeration]); |
220 Framework().ObjectEnumerationCompleteL(iPendingEnumerations[KActiveEnumeration]); |
221 iPendingEnumerations.Remove(KActiveEnumeration); |
221 iPendingEnumerations.Remove(KActiveEnumeration); |
222 __FLOG(_L8("HandleEnumerationCompletedL - Exit")); |
222 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL_EXIT ); |
223 } |
223 } |
224 |
224 |
225 /** |
225 /** |
226 Standard C++ constructor |
226 Standard C++ constructor |
227 */ |
227 */ |
237 /** |
237 /** |
238 Second-phase constructor. |
238 Second-phase constructor. |
239 */ |
239 */ |
240 void CMTPFileDataProvider::ConstructL() |
240 void CMTPFileDataProvider::ConstructL() |
241 { |
241 { |
242 __FLOG_OPEN(KMTPSubsystem, KComponent); |
242 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_CONSTRUCTL_ENTRY ); |
243 __FLOG(_L8("ConstructL - Entry")); |
|
244 iDpSingletons.OpenL(Framework()); |
243 iDpSingletons.OpenL(Framework()); |
245 iFileDPSingletons.OpenL(Framework()); |
244 iFileDPSingletons.OpenL(Framework()); |
246 iSingletons.OpenL(); |
245 iSingletons.OpenL(); |
247 |
246 |
248 iExclusionMgr = CMTPFileDpExclusionMgr::NewL(Framework()); |
247 iExclusionMgr = CMTPFileDpExclusionMgr::NewL(Framework()); |
249 iDpSingletons.SetExclusionMgrL(*iExclusionMgr); |
248 iDpSingletons.SetExclusionMgrL(*iExclusionMgr); |
250 |
249 |
251 TUint processLimit = iFileDPSingletons.FrameworkConfig().UintValueL(CMTPFileDpConfigMgr::EEnumerationIterationLength); |
250 TUint processLimit = iFileDPSingletons.FrameworkConfig().UintValueL(CMTPFileDpConfigMgr::EEnumerationIterationLength); |
252 iFileEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, processLimit); |
251 iFileEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, processLimit); |
253 __FLOG(_L8("ConstructL - Exit")); |
252 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_CONSTRUCTL_EXIT ); |
254 } |
253 } |
255 |
254 |
256 /** |
255 /** |
257 Find or create a request processor that can process the specified request. |
256 Find or create a request processor that can process the specified request. |
258 @param aRequest The request to be processed |
257 @param aRequest The request to be processed |
259 @param aConnection The connection from which the request comes |
258 @param aConnection The connection from which the request comes |
260 @return the idx of the found/created request processor |
259 @return the idx of the found/created request processor |
261 */ |
260 */ |
262 TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
261 TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
263 { |
262 { |
264 __FLOG(_L8("LocateRequestProcessorL - Entry")); |
263 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_LOCATEREQUESTPROCESSORL_ENTRY ); |
265 TInt idx(KErrNotFound); |
264 TInt idx(KErrNotFound); |
266 TInt count(iActiveProcessors.Count()); |
265 TInt count(iActiveProcessors.Count()); |
267 for (TInt i(0); (i < count); i++) |
266 for (TInt i(0); (i < count); i++) |
268 { |
267 { |
269 if (iActiveProcessors[i]->Match(aRequest, aConnection)) |
268 if (iActiveProcessors[i]->Match(aRequest, aConnection)) |
292 @param aConnection The connection from which the request comes |
291 @param aConnection The connection from which the request comes |
293 @return the idx of the found request processor, KErrNotFound if not found |
292 @return the idx of the found request processor, KErrNotFound if not found |
294 */ |
293 */ |
295 TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
294 TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
296 { |
295 { |
297 __FLOG(_L8("LocateRequestProcessorL - Entry")); |
296 OstTraceFunctionEntry0( DUP1_CMTPFILEDATAPROVIDER_LOCATEREQUESTPROCESSORL_ENTRY ); |
298 TInt idx(KErrNotFound); |
297 TInt idx(KErrNotFound); |
299 TInt count(iActiveProcessors.Count()); |
298 TInt count(iActiveProcessors.Count()); |
300 for (TInt i(0); (i < count); i++) |
299 for (TInt i(0); (i < count); i++) |
301 { |
300 { |
302 if (iActiveProcessors[i]->Match(aEvent, aConnection)) |
301 if (iActiveProcessors[i]->Match(aEvent, aConnection)) |
303 { |
302 { |
304 idx = i; |
303 idx = i; |
305 break; |
304 break; |
306 } |
305 } |
307 } |
306 } |
308 __FLOG(_L8("LocateRequestProcessorL - Exit")); |
307 OstTraceFunctionExit0( DUP1_CMTPFILEDATAPROVIDER_LOCATEREQUESTPROCESSORL_EXIT ); |
309 return idx; |
308 return idx; |
310 } |
309 } |
311 |
310 |
312 /** |
311 /** |
313 Cleans up outstanding request processors when a session is closed. |
312 Cleans up outstanding request processors when a session is closed. |
314 @param aSession notification parameter block |
313 @param aSession notification parameter block |
315 */ |
314 */ |
316 void CMTPFileDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
315 void CMTPFileDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
317 { |
316 { |
318 __FLOG(_L8("SessionClosedL - Entry")); |
317 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_SESSIONCLOSEDL_ENTRY ); |
319 TInt count = iActiveProcessors.Count(); |
318 TInt count = iActiveProcessors.Count(); |
320 while(count--) |
319 while(count--) |
321 { |
320 { |
322 MMTPRequestProcessor* processor = iActiveProcessors[count]; |
321 MMTPRequestProcessor* processor = iActiveProcessors[count]; |
323 TUint32 sessionId = processor->SessionId(); |
322 TUint32 sessionId = processor->SessionId(); |
332 { |
331 { |
333 processor->Release(); |
332 processor->Release(); |
334 } |
333 } |
335 } |
334 } |
336 } |
335 } |
337 __FLOG(_L8("SessionClosedL - Exit")); |
336 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_SESSIONCLOSEDL_EXIT ); |
338 } |
337 } |
339 |
338 |
340 /** |
339 /** |
341 Prepares for a newly-opened session. |
340 Prepares for a newly-opened session. |
342 @param aSession notification parameter block |
341 @param aSession notification parameter block |
343 */ |
342 */ |
344 #ifdef __FLOG_ACTIVE |
343 #ifdef OST_TRACE_COMPILER_IN_USE |
345 void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession) |
344 void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession) |
346 #else |
345 #else |
347 void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/) |
346 void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/) |
348 #endif |
347 #endif |
349 { |
348 { |
350 __FLOG(_L8("SessionOpenedL - Entry")); |
349 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_SESSIONOPENEDL_ENTRY ); |
351 __FLOG_VA((_L8("SessionID = %d"), aSession.iMTPId)); |
350 OstTrace1( TRACE_NORMAL, CMTPFILEDATAPROVIDER_SESSIONOPENEDL, "SessionID = %d", aSession.iMTPId ); |
352 __FLOG(_L8("SessionOpenedL - Exit")); |
351 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_SESSIONOPENEDL_EXIT ); |
353 } |
352 } |
354 |
353 |
355 /** |
354 /** |
356 * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, |
355 * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, |
357 * but it does not really own the format 0x3002. |
356 * but it does not really own the format 0x3002. |
358 * |
357 * |
359 * Check whether the Pictbridgedp exists or not. |
358 * Check whether the Pictbridgedp exists or not. |
360 */ |
359 */ |
361 TBool CMTPFileDataProvider::PictbridgeDpExistL() const |
360 TBool CMTPFileDataProvider::PictbridgeDpExistL() const |
362 { |
361 { |
363 __FLOG(_L8("PictbridgeDpExistL - Entry")); |
362 OstTraceFunctionEntry0( CMTPFILEDATAPROVIDER_PICTBRIDGEDPEXISTL_ENTRY ); |
364 |
363 |
365 RImplInfoPtrArray implementations; |
364 RImplInfoPtrArray implementations; |
366 TCleanupItem cleanup(ImplementationsCleanup, reinterpret_cast<TAny*>(&implementations)); |
365 TCleanupItem cleanup(ImplementationsCleanup, reinterpret_cast<TAny*>(&implementations)); |
367 CleanupStack::PushL(cleanup); |
366 CleanupStack::PushL(cleanup); |
368 REComSession::ListImplementationsL(KMTPDataProviderPluginInterfaceUid, implementations); |
367 REComSession::ListImplementationsL(KMTPDataProviderPluginInterfaceUid, implementations); |
377 ret = ETrue; |
376 ret = ETrue; |
378 break; |
377 break; |
379 } |
378 } |
380 } |
379 } |
381 CleanupStack::PopAndDestroy(&implementations); |
380 CleanupStack::PopAndDestroy(&implementations); |
382 |
381 |
383 __FLOG_VA((_L8("return value ret = %d"), ret)); |
382 OstTrace1( TRACE_NORMAL, CMTPFILEDATAPROVIDER_PICTBRIDGEDPEXISTL, "return value ret = %d", ret ); |
384 __FLOG(_L8("PictbridgeDpExistL - Exit")); |
383 OstTraceFunctionExit0( CMTPFILEDATAPROVIDER_PICTBRIDGEDPEXISTL_EXIT ); |
385 return ret; |
384 return ret; |
386 } |
385 } |
387 |
386 |
388 /** |
387 /** |
389 * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, |
388 * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, |