24 #include "mtppictbridgedpconst.h" |
24 #include "mtppictbridgedpconst.h" |
25 #include "mtppictbridgedppanic.h" |
25 #include "mtppictbridgedppanic.h" |
26 #include "mtppictbridgedpprocessor.h" |
26 #include "mtppictbridgedpprocessor.h" |
27 #include "cmtppictbridgeenumerator.h" |
27 #include "cmtppictbridgeenumerator.h" |
28 #include "ptpdef.h" |
28 #include "ptpdef.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "cmtppictbridgedpTraces.h" |
|
32 #endif |
|
33 |
29 |
34 |
30 LOCAL_D const TInt KArrayGranularity = 3; |
35 LOCAL_D const TInt KArrayGranularity = 3; |
31 |
36 |
32 // -------------------------------------------------------------------------- |
37 // -------------------------------------------------------------------------- |
33 // PictBridge data provider factory method. |
38 // PictBridge data provider factory method. |
57 // second phase constructor |
62 // second phase constructor |
58 // -------------------------------------------------------------------------- |
63 // -------------------------------------------------------------------------- |
59 // |
64 // |
60 void CMTPPictBridgeDataProvider::ConstructL() |
65 void CMTPPictBridgeDataProvider::ConstructL() |
61 { |
66 { |
62 __FLOG_OPEN(KMTPSubsystem, KComponent); |
67 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_CONSTRUCTL_ENTRY ); |
63 __FLOG(_L8(">> CMTPPictBridgeDataProvider::ConstructL")); |
|
64 iPictBridgeEnumeratorP = CMTPPictBridgeEnumerator::NewL(Framework(), *this); |
68 iPictBridgeEnumeratorP = CMTPPictBridgeEnumerator::NewL(Framework(), *this); |
65 iServerP = CPtpServer::NewL(Framework(), *this); |
69 iServerP = CPtpServer::NewL(Framework(), *this); |
66 __FLOG(_L8("<< CMTPPictBridgeDataProvider::ConstructL")); |
70 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_CONSTRUCTL_EXIT ); |
67 } |
71 } |
68 // -------------------------------------------------------------------------- |
72 // -------------------------------------------------------------------------- |
69 // Destructor |
73 // Destructor |
70 // -------------------------------------------------------------------------- |
74 // -------------------------------------------------------------------------- |
71 // |
75 // |
72 CMTPPictBridgeDataProvider::~CMTPPictBridgeDataProvider() |
76 CMTPPictBridgeDataProvider::~CMTPPictBridgeDataProvider() |
73 { |
77 { |
74 __FLOG(_L8(">> ~CMTPPictBridgeDataProvider")); |
78 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_CMTPPICTBRIDGEDATAPROVIDER_DES_ENTRY ); |
75 |
79 |
76 TUint count(iActiveProcessors.Count()); |
80 TUint count(iActiveProcessors.Count()); |
77 while (count--) |
81 while (count--) |
78 { |
82 { |
79 iActiveProcessors[count]->Release(); |
83 iActiveProcessors[count]->Release(); |
81 iActiveProcessors.Close(); |
85 iActiveProcessors.Close(); |
82 |
86 |
83 delete iPictBridgeEnumeratorP; |
87 delete iPictBridgeEnumeratorP; |
84 delete iServerP; |
88 delete iServerP; |
85 |
89 |
86 __FLOG(_L8("<< ~CMTPPictBridgeDataProvider")); |
90 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_CMTPPICTBRIDGEDATAPROVIDER_DES_EXIT ); |
87 __FLOG_CLOSE; |
|
88 } |
91 } |
89 |
92 |
90 // -------------------------------------------------------------------------- |
93 // -------------------------------------------------------------------------- |
91 // Cancel |
94 // Cancel |
92 // -------------------------------------------------------------------------- |
95 // -------------------------------------------------------------------------- |
93 // |
96 // |
94 void CMTPPictBridgeDataProvider::Cancel() |
97 void CMTPPictBridgeDataProvider::Cancel() |
95 { |
98 { |
96 __FLOG(_L8(">> CMTPPictBridgeDataProvider::Cancel")); |
99 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_CANCEL_ENTRY ); |
97 // nothing to cancel |
100 // nothing to cancel |
98 __FLOG(_L8("<< CMTPPictBridgeDataProvider::Cancel")); |
101 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_CANCEL_EXIT ); |
99 } |
102 } |
100 // -------------------------------------------------------------------------- |
103 // -------------------------------------------------------------------------- |
101 // |
104 // |
102 // -------------------------------------------------------------------------- |
105 // -------------------------------------------------------------------------- |
103 // |
106 // |
104 void CMTPPictBridgeDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
107 void CMTPPictBridgeDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
105 { |
108 { |
106 __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessEventL")); |
109 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSEVENTL_ENTRY ); |
107 |
110 |
108 TInt idx = LocateRequestProcessorL(aEvent, aConnection); |
111 TInt idx = LocateRequestProcessorL(aEvent, aConnection); |
109 |
112 |
110 if (idx != KErrNotFound) |
113 if (idx != KErrNotFound) |
111 { |
114 { |
112 iActiveProcessors[idx]->HandleEventL(aEvent); |
115 iActiveProcessors[idx]->HandleEventL(aEvent); |
113 } |
116 } |
114 |
117 |
115 __FLOG(_L8("<< CMTPPictBridgeDataProvider::ProcessEventL")); |
118 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSEVENTL_EXIT ); |
116 } |
119 } |
117 // -------------------------------------------------------------------------- |
120 // -------------------------------------------------------------------------- |
118 // Process notifications from the initiator |
121 // Process notifications from the initiator |
119 // -------------------------------------------------------------------------- |
122 // -------------------------------------------------------------------------- |
120 // |
123 // |
121 void CMTPPictBridgeDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
124 void CMTPPictBridgeDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
122 { |
125 { |
123 __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessNotificationL")); |
126 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSNOTIFICATIONL_ENTRY ); |
124 |
127 |
125 switch (aNotification) |
128 switch (aNotification) |
126 { |
129 { |
127 case EMTPSessionClosed: |
130 case EMTPSessionClosed: |
128 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
131 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
134 |
137 |
135 default: |
138 default: |
136 // Ignore all other notifications. |
139 // Ignore all other notifications. |
137 break; |
140 break; |
138 } |
141 } |
139 |
142 |
140 __FLOG(_L8("<< CMTPPictBridgeDataProvider::ProcessNotificationL")); |
143 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSNOTIFICATIONL_EXIT ); |
141 } |
144 } |
142 // -------------------------------------------------------------------------- |
145 // -------------------------------------------------------------------------- |
143 // Process requests from the initiator |
146 // Process requests from the initiator |
144 // -------------------------------------------------------------------------- |
147 // -------------------------------------------------------------------------- |
145 // |
148 // |
146 void CMTPPictBridgeDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
149 void CMTPPictBridgeDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
147 { |
150 { |
148 __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessRequestPhaseL")); |
151 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSREQUESTPHASEL_ENTRY ); |
149 |
152 |
150 TInt idx = LocateRequestProcessorL(aRequest, aConnection); |
153 TInt idx = LocateRequestProcessorL(aRequest, aConnection); |
151 __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPPictBridgeDpNoMatchingProcessor)); |
154 __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPPictBridgeDpNoMatchingProcessor)); |
152 MMTPRequestProcessor* processorP(iActiveProcessors[idx]); |
155 MMTPRequestProcessor* processorP(iActiveProcessors[idx]); |
153 TBool result(processorP->HandleRequestL(aRequest, aPhase)); |
156 TBool result(processorP->HandleRequestL(aRequest, aPhase)); |
155 { |
158 { |
156 processorP->Release(); |
159 processorP->Release(); |
157 iActiveProcessors.Remove(idx); |
160 iActiveProcessors.Remove(idx); |
158 } |
161 } |
159 |
162 |
160 __FLOG_VA((_L8("<< CMTPPictBridgeDataProvider::ProcessRequestPhaseL result=%d"), result)); |
163 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEDATAPROVIDER_PROCESSREQUESTPHASEL, "result=%d", result ); |
|
164 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_PROCESSREQUESTPHASEL_EXIT ); |
161 } |
165 } |
162 |
166 |
163 // -------------------------------------------------------------------------- |
167 // -------------------------------------------------------------------------- |
164 // Starts the object enumeration |
168 // Starts the object enumeration |
165 // -------------------------------------------------------------------------- |
169 // -------------------------------------------------------------------------- |
166 // |
170 // |
167 void CMTPPictBridgeDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
171 void CMTPPictBridgeDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
168 { |
172 { |
169 __FLOG(_L8(">> CMTPPictBridgeDataProvider::StartObjectEnumerationL")); |
173 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_STARTOBJECTENUMERATIONL_ENTRY ); |
170 |
174 |
171 iPictBridgeEnumeratorP->EnumerateObjectsL(aStorageId); |
175 iPictBridgeEnumeratorP->EnumerateObjectsL(aStorageId); |
172 |
176 |
173 __FLOG(_L8("<< CMTPPictBridgeDataProvider::StartObjectEnumerationL")); |
177 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_STARTOBJECTENUMERATIONL_EXIT ); |
174 } |
178 } |
175 |
179 |
176 // -------------------------------------------------------------------------- |
180 // -------------------------------------------------------------------------- |
177 // Storage enumeration is not needed, just declared complete |
181 // Storage enumeration is not needed, just declared complete |
178 // -------------------------------------------------------------------------- |
182 // -------------------------------------------------------------------------- |
179 // |
183 // |
180 void CMTPPictBridgeDataProvider::StartStorageEnumerationL() |
184 void CMTPPictBridgeDataProvider::StartStorageEnumerationL() |
181 { |
185 { |
182 __FLOG(_L8(">> CMTPPictBridgeDataProvider::StartStorageEnumerationL")); |
186 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_STARTSTORAGEENUMERATIONL_ENTRY ); |
183 iPictBridgeEnumeratorP->EnumerateStoragesL(); |
187 iPictBridgeEnumeratorP->EnumerateStoragesL(); |
184 __FLOG(_L8("<< CMTPPictBridgeDataProvider::StartStorageEnumerationL")); |
188 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_STARTSTORAGEENUMERATIONL_EXIT ); |
185 } |
189 } |
186 // -------------------------------------------------------------------------- |
190 // -------------------------------------------------------------------------- |
187 // |
191 // |
188 // -------------------------------------------------------------------------- |
192 // -------------------------------------------------------------------------- |
189 // |
193 // |
190 void CMTPPictBridgeDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
194 void CMTPPictBridgeDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
191 { |
195 { |
192 __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::Supported %d"), aCategory)); |
196 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_SUPPORTED_ENTRY ); |
|
197 OstTrace1(TRACE_NORMAL, CMTPPICTBRIDGEDATAPROVIDER_SUPPORTED, "aCategory: %d", aCategory); |
193 switch (aCategory) |
198 switch (aCategory) |
194 { |
199 { |
195 case EEvents: |
200 case EEvents: |
196 aArray.Append(EMTPEventCodeRequestObjectTransfer); |
201 aArray.Append(EMTPEventCodeRequestObjectTransfer); |
197 break; |
202 break; |
247 // CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL() |
252 // CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL() |
248 // -------------------------------------------------------------------------- |
253 // -------------------------------------------------------------------------- |
249 // |
254 // |
250 void CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL() |
255 void CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL() |
251 { |
256 { |
252 __FLOG(_L8(">> CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL")); |
257 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_NOTIFYSTORAGEENUMERATIONCOMPLETEL_ENTRY ); |
253 Framework().StorageEnumerationCompleteL(); |
258 Framework().StorageEnumerationCompleteL(); |
254 __FLOG(_L8("<< CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL")); |
259 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_NOTIFYSTORAGEENUMERATIONCOMPLETEL_EXIT ); |
255 } |
260 } |
256 |
261 |
257 // -------------------------------------------------------------------------- |
262 // -------------------------------------------------------------------------- |
258 // |
263 // |
259 // -------------------------------------------------------------------------- |
264 // -------------------------------------------------------------------------- |
260 // |
265 // |
261 #ifdef __FLOG_ACTIVE |
266 #ifdef OST_TRACE_COMPILER_IN_USE |
262 void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aErr ) |
267 void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aErr ) |
263 #else |
268 #else |
264 void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /* aErr*/ ) |
269 void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /* aErr*/ ) |
265 #endif |
270 #endif |
266 { |
271 { |
267 __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::NotifyEnumerationCompletedL storage 0x%08X status %d"), aStorageId, aErr )); |
272 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL_ENTRY ); |
|
273 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL, |
|
274 " storage 0x%08X status %d", aStorageId, (TInt32)aErr); |
268 Framework().ObjectEnumerationCompleteL(aStorageId); |
275 Framework().ObjectEnumerationCompleteL(aStorageId); |
269 __FLOG(_L8("<< CMTPPictBridgeDataProvider::NotifyEnumerationCompletedL")); |
276 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_NOTIFYENUMERATIONCOMPLETEL_EXIT ); |
270 } |
277 } |
271 |
278 |
272 |
279 |
273 // -------------------------------------------------------------------------- |
280 // -------------------------------------------------------------------------- |
274 // Find or create a request processor that can process the specified request. |
281 // Find or create a request processor that can process the specified request. |
277 // @return the idx of the found/created request processor |
284 // @return the idx of the found/created request processor |
278 // -------------------------------------------------------------------------- |
285 // -------------------------------------------------------------------------- |
279 // |
286 // |
280 TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
287 TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
281 { |
288 { |
282 __FLOG(_L8(">> CMTPPictBridgeDataProvider::LocateRequestProcessorL")); |
289 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_LOCATEREQUESTPROCESSORL_ENTRY ); |
283 |
290 |
284 TInt idx(KErrNotFound); |
291 TInt idx(KErrNotFound); |
285 TInt count(iActiveProcessors.Count()); |
292 TInt count(iActiveProcessors.Count()); |
286 for (TInt i = 0; (i < count); i++) |
293 for (TInt i = 0; (i < count); i++) |
287 { |
294 { |
312 // @return the idx of the found request processor, KErrNotFound if not found |
319 // @return the idx of the found request processor, KErrNotFound if not found |
313 // -------------------------------------------------------------------------- |
320 // -------------------------------------------------------------------------- |
314 // |
321 // |
315 TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
322 TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
316 { |
323 { |
317 __FLOG(_L8(">> CMTPPictBridgeDataProvider::LocateRequestProcessorL (event)")); |
324 OstTraceFunctionEntry0( DUP1_CMTPPICTBRIDGEDATAPROVIDER_LOCATEREQUESTPROCESSORL_ENTRY ); |
318 |
325 |
319 TInt idx(KErrNotFound); |
326 TInt idx(KErrNotFound); |
320 TInt count(iActiveProcessors.Count()); |
327 TInt count(iActiveProcessors.Count()); |
321 for (TInt i = 0; (i < count); i++) |
328 for (TInt i = 0; (i < count); i++) |
322 { |
329 { |
324 { |
331 { |
325 idx = i; |
332 idx = i; |
326 break; |
333 break; |
327 } |
334 } |
328 } |
335 } |
329 __FLOG(_L8("<< CMTPPictBridgeDataProvider::LocateRequestProcessorL (event)")); |
336 OstTraceFunctionExit0( DUP1_CMTPPICTBRIDGEDATAPROVIDER_LOCATEREQUESTPROCESSORL_EXIT ); |
330 return idx; |
337 return idx; |
331 } |
338 } |
332 |
339 |
333 // -------------------------------------------------------------------------- |
340 // -------------------------------------------------------------------------- |
334 // Cleans up outstanding request processors when a session is closed. |
341 // Cleans up outstanding request processors when a session is closed. |
335 // @param aSession notification parameter block |
342 // @param aSession notification parameter block |
336 // -------------------------------------------------------------------------- |
343 // -------------------------------------------------------------------------- |
337 // |
344 // |
338 void CMTPPictBridgeDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
345 void CMTPPictBridgeDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
339 { |
346 { |
340 __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::SessionClosedL SessionID = %d"), aSession.iMTPId)); |
347 OstTraceFunctionEntry0( CMTPPICTBRIDGEDATAPROVIDER_SESSIONCLOSEDL_ENTRY ); |
|
348 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEDATAPROVIDER_SESSIONCLOSEDL, "SessionID = %d", aSession.iMTPId ); |
341 |
349 |
342 TInt count = iActiveProcessors.Count(); |
350 TInt count = iActiveProcessors.Count(); |
343 while(count--) |
351 while(count--) |
344 { |
352 { |
345 MMTPRequestProcessor* processorP = iActiveProcessors[count]; |
353 MMTPRequestProcessor* processorP = iActiveProcessors[count]; |
350 iActiveProcessors.Remove(count); |
358 iActiveProcessors.Remove(count); |
351 } |
359 } |
352 } |
360 } |
353 |
361 |
354 iServerP->MtpSessionClosed(); |
362 iServerP->MtpSessionClosed(); |
355 __FLOG(_L8("<< CMTPPictBridgeDataProvider::SessionClosedL")); |
363 OstTraceFunctionExit0( CMTPPICTBRIDGEDATAPROVIDER_SESSIONCLOSEDL_EXIT ); |
356 } |
364 } |
357 |
365 |
358 // -------------------------------------------------------------------------- |
366 // -------------------------------------------------------------------------- |
359 // Prepares for a newly-opened session. |
367 // Prepares for a newly-opened session. |
360 // @param aSession notification parameter block |
368 // @param aSession notification parameter block |
361 // -------------------------------------------------------------------------- |
369 // -------------------------------------------------------------------------- |
362 // |
370 // |
363 #ifdef __FLOG_ACTIVE |
371 #ifdef OST_TRACE_COMPILER_IN_USE |
364 void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession ) |
372 void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession ) |
365 #else |
373 #else |
366 void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/ ) |
374 void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/ ) |
367 #endif |
375 #endif |
368 { |
376 { |
369 __FLOG_VA((_L8(" CMTPPictBridgeDataProvider::SessionOpenedL SessionID = %d"), aSession.iMTPId)); |
377 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEDATAPROVIDER_SESSIONOPENEDL, "SessionID = %d", aSession.iMTPId ); |
370 iServerP->MtpSessionOpened(); |
378 iServerP->MtpSessionOpened(); |
371 } |
379 } |
372 |
380 |
373 TUint32 CMTPPictBridgeDataProvider::DeviceDiscoveryHandle() const |
381 TUint32 CMTPPictBridgeDataProvider::DeviceDiscoveryHandle() const |
374 { |
382 { |