|
1 /* |
|
2 * Copyright (c) 2009 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: Test observer to act as dummy mtp framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ctestobserver.h" |
|
20 #include "cmmmtpdataprovidertestmodule.h" |
|
21 #include "cmmmtpdataprovidertester.h" |
|
22 #include <mtp/tmtptypeevent.h> |
|
23 #include <mtp/tmtptyperesponse.h> |
|
24 #include <mtp/mtpprotocolconstants.h> |
|
25 #include <mtp/mmtpdataprovider.h> |
|
26 #include <mtp/cmtptypeobjectinfo.h> |
|
27 #include <mtp/cmtptypestring.h> |
|
28 #include <mtp/cmtptypeobjectproplist.h> |
|
29 #include <mtp/cmtptypefile.h> |
|
30 #include <barsc.h> |
|
31 #include <barsread.h> |
|
32 #include <stiflogger.h> |
|
33 #include <settingserverclient.h> |
|
34 #include <mpxmedia.h> |
|
35 #include "logging.h" |
|
36 |
|
37 #ifdef LOGGER |
|
38 #undef LOGGER |
|
39 #endif |
|
40 #define LOGGER iLog |
|
41 |
|
42 _LIT( KResFileName, "Z:\\resource\\mmmtpdataprovidertester.rsc" ); |
|
43 |
|
44 const TInt KDataProviderId = 1; |
|
45 |
|
46 CTestObserver::CTestObserver( CMmMtpDataProviderTestModule* aTestModule ) |
|
47 : iObjectEnumerationComplete( EFalse ), |
|
48 iStorageEnumerationComplete( EFalse ), |
|
49 iTestModule( aTestModule ) |
|
50 { |
|
51 // no implementation required |
|
52 } |
|
53 |
|
54 CTestObserver::~CTestObserver() |
|
55 { |
|
56 PRINTF0( ">CTestObserver::~CTestObserver" ); |
|
57 iFsSession.Close(); |
|
58 delete iStorageManager; |
|
59 delete iTestObjManager; |
|
60 delete iActiveSchedulerWait; |
|
61 PRINTF0( "<CTestObserver::~CTestObserver" ); |
|
62 delete iLog; |
|
63 } |
|
64 |
|
65 CTestObserver* CTestObserver::NewLC( CMmMtpDataProviderTestModule* aTestModule ) |
|
66 { |
|
67 CTestObserver* self = new ( ELeave ) CTestObserver( aTestModule ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 CTestObserver* CTestObserver::NewL( CMmMtpDataProviderTestModule* aTestModule ) |
|
74 { |
|
75 CTestObserver* self = CTestObserver::NewLC( aTestModule ); |
|
76 CleanupStack::Pop(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 void CTestObserver::ConstructL() |
|
81 { |
|
82 TFileName logFileName; |
|
83 logFileName.Copy( KMtpDataProviderTestModuleLogFile ); |
|
84 |
|
85 iLog = CStifLogger::NewL( KMtpDataProviderTestModuleLogPath, |
|
86 logFileName, |
|
87 CStifLogger::ETxt, |
|
88 TRACE_TARGET, |
|
89 ETrue, ETrue, ETrue, EFalse, ETrue ); |
|
90 |
|
91 PRINTF0( ">CTestObserver::ConstructL" ); |
|
92 iStorageManager = CTestStorageMgr::NewL(); |
|
93 iTestObjManager = CTestObjectManager::NewL(); |
|
94 iFsSession.Connect(); |
|
95 iActiveSchedulerWait = new ( ELeave ) CActiveSchedulerWait(); |
|
96 |
|
97 RResourceFile resFile; |
|
98 CleanupClosePushL( resFile ); |
|
99 |
|
100 resFile.OpenL( Fs(), KResFileName ); |
|
101 const TInt KDefaultResourceId( 1 ); |
|
102 HBufC8* resBuffer( resFile.AllocReadLC( KDefaultResourceId ) ); |
|
103 TResourceReader resReader; |
|
104 resReader.SetBuffer( resBuffer ); |
|
105 |
|
106 // WORD type |
|
107 TInt temp; |
|
108 HBufC* tempBuf; |
|
109 temp = resReader.ReadUint16(); // read and discard type |
|
110 temp = resReader.ReadInt8(); // read and discard version |
|
111 temp = resReader.ReadInt8(); // read and discard enumeration persistent flag |
|
112 temp = resReader.ReadUint16(); // read and discard supported modes |
|
113 |
|
114 tempBuf = resReader.ReadHBufCL(); // read server name |
|
115 delete tempBuf; |
|
116 tempBuf = resReader.ReadHBufCL(); // read server image name |
|
117 delete tempBuf; |
|
118 |
|
119 // LLINK opaque_resource |
|
120 iResourceId = resReader.ReadUint32(); |
|
121 __TRACE( KPrint, ( _L( "Resource id = 0x%x" ), iResourceId ) ); |
|
122 temp = resReader.ReadUint8(); // read and discard enumeration phase |
|
123 temp = temp; // prevent warning |
|
124 CleanupStack::PopAndDestroy( resBuffer ); |
|
125 CleanupStack::PopAndDestroy( &resFile ); |
|
126 |
|
127 PRINTF0( "<CTestObserver::ConstructL" ); |
|
128 } |
|
129 |
|
130 TUint CTestObserver::DataProviderId() const |
|
131 { |
|
132 TUint id = KDataProviderId; |
|
133 PRINTF1( "<>CTestObserver::DataProviderId id = %d", id ); |
|
134 return id; |
|
135 } |
|
136 |
|
137 TMTPOperationalMode CTestObserver::Mode() const |
|
138 { |
|
139 TMTPOperationalMode mode = EModeMTP; |
|
140 PRINTF1( "<>CTestObserver::Mode mode = %d", mode ); |
|
141 return EModeMTP; |
|
142 } |
|
143 |
|
144 void CTestObserver::ReceiveDataL( MMTPType& aData, |
|
145 const TMTPTypeRequest& aRequest, MMTPConnection& /*aConnection*/ ) |
|
146 { |
|
147 TInt requestCode = aRequest.Uint16( TMTPTypeRequest::ERequestOperationCode ); |
|
148 TInt sessionId = aRequest.Uint32( TMTPTypeRequest::ERequestSessionID ); |
|
149 |
|
150 PRINTF2( ">CTestObserver::ReceiveDataL request = 0x%x session = %d", requestCode, sessionId ); |
|
151 |
|
152 SetPhaseL( EDataIToRPhase ); |
|
153 |
|
154 TUint type = aData.Type(); |
|
155 PRINTV1( "Type of data: 0x%x", type ); |
|
156 if ( type == EMTPTypeUndefined ) |
|
157 { |
|
158 PRINTN0( "Null data received, executing dummy data phase" ); |
|
159 return; |
|
160 } |
|
161 |
|
162 switch ( requestCode ) |
|
163 { |
|
164 case EMTPOpCodeSendObjectInfo: |
|
165 { |
|
166 PRINTN0( "Receiving data for SendObjectInfo" ); |
|
167 if ( type != EMTPTypeObjectInfoDataset ) |
|
168 { |
|
169 PRINTE2( "Wrong data type received: 0x%x != 0x%x", type, EMTPTypeObjectInfoDataset ); |
|
170 User::Leave( KErrArgument ); |
|
171 } |
|
172 iTestModule->iPluginTester->SendObjectInfoReceiveData( |
|
173 static_cast <CMTPTypeObjectInfo*>( &aData ) ); |
|
174 } |
|
175 break; |
|
176 case EMTPOpCodeSendObject: |
|
177 { |
|
178 PRINTN0( "Receiving data for SendObject" ); |
|
179 if ( type != EMTPTypeFile ) |
|
180 { |
|
181 PRINTE2( "Wrong data type received: 0x%x != 0x%x", type, |
|
182 EMTPTypeFile ); |
|
183 User::Leave( KErrArgument ); |
|
184 } |
|
185 iTestModule->iPluginTester->SendObjectReceiveDataL( |
|
186 static_cast<CMTPTypeFile*>( &aData ) ); |
|
187 } |
|
188 break; |
|
189 case EMTPOpCodeSetObjectPropList: |
|
190 { |
|
191 PRINTN0( "Receiving data for SetObjectPropList" ); |
|
192 if ( type != EMTPTypeObjectPropListDataset ) |
|
193 { |
|
194 PRINTE2( "Wrong data type received: 0x%x != 0x%x", type, EMTPTypeObjectPropListDataset ); |
|
195 User::Leave( KErrArgument ); |
|
196 } |
|
197 iTestModule->iPluginTester->SetObjectPropListReceiveDataL( |
|
198 static_cast <CMTPTypeObjectPropList* >( &aData ) ); |
|
199 } |
|
200 break; |
|
201 case EMTPOpCodeSetObjectPropValue: |
|
202 { |
|
203 PRINTN0( "Receiving data for SetObjectPropValue" ); |
|
204 iTestModule->iPluginTester->SetObjectPropValueReceiveDataL( |
|
205 aRequest, &aData ); |
|
206 } |
|
207 break; |
|
208 } |
|
209 PRINTF0( "<CTestObserver::ReceiveDataL" ); |
|
210 } |
|
211 |
|
212 void CTestObserver::SendDataL(const MMTPType& aData, |
|
213 const TMTPTypeRequest& aRequest, MMTPConnection& /*aConnection*/) |
|
214 { |
|
215 TUint16 operationCode = aRequest.Uint16( TMTPTypeRequest::ERequestOperationCode ); |
|
216 PRINTF1( ">CTestObserver::SendDataL operation = 0x%x", operationCode ); |
|
217 SetPhaseL( EDataRToIPhase ); |
|
218 iMMTPTypeData = &aData; |
|
219 switch ( operationCode ) |
|
220 { |
|
221 case EMTPOpCodeGetObjectPropList: |
|
222 if ( iPendingOperation == EGetObjectPropList ) |
|
223 { |
|
224 PRINTN0( "GetObjectPropList async operation finished successfully" ); |
|
225 iAsyncResult = KErrNone; |
|
226 } |
|
227 else |
|
228 { |
|
229 PRINTE0( "GetObjectPropList async operation finished in incorrect state" ); |
|
230 iAsyncResult = KErrNotReady; |
|
231 } |
|
232 if ( iActiveSchedulerWait->IsStarted() ) |
|
233 { |
|
234 iActiveSchedulerWait->AsyncStop(); |
|
235 } |
|
236 iPendingOperation = EIdleOperation; |
|
237 break; |
|
238 } |
|
239 PRINTF0( "<CTestObserver::SendDataL" ); |
|
240 } |
|
241 |
|
242 void CTestObserver::SendEventL( |
|
243 const TMTPTypeEvent& aEvent, MMTPConnection& /*aConnection*/ ) |
|
244 { |
|
245 TUint16 eventCode = aEvent.Uint16( TMTPTypeEvent::EEventCode ); |
|
246 TUint32 sessionId = aEvent.Uint32( TMTPTypeEvent::EEventSessionID ); |
|
247 PRINTF2( "<>CTestObserver::SendEventL event = 0x%x session = %d", eventCode, sessionId ); |
|
248 PRINTE0( "NOT IMPLEMENTED" ); |
|
249 } |
|
250 |
|
251 void CTestObserver::SendEventL( const TMTPTypeEvent& aEvent ) |
|
252 { |
|
253 TUint16 eventCode = aEvent.Uint16( TMTPTypeEvent::EEventCode ); |
|
254 TUint32 sessionId = aEvent.Uint32( TMTPTypeEvent::EEventSessionID ); |
|
255 PRINTF2( "<>CTestObserver::SendEventL event = 0x%x session = %d", eventCode, sessionId ); |
|
256 PRINTE0( "NOT IMPLEMENTED" ); |
|
257 } |
|
258 |
|
259 void CTestObserver::SendResponseL( |
|
260 const TMTPTypeResponse& aResponse, |
|
261 const TMTPTypeRequest& aRequest, |
|
262 MMTPConnection& /*aConnection*/ ) |
|
263 { |
|
264 TUint16 response = aResponse.Uint16( TMTPTypeResponse::EResponseCode ); |
|
265 TUint16 operationCode = aRequest.Uint16( TMTPTypeRequest::ERequestOperationCode ); |
|
266 PRINTF2( ">CTestObserver::SendResponseL response = 0x%x operation = 0x%x", response, operationCode ); |
|
267 TInt result = KErrNone; |
|
268 if ( iPhase == ECompletingPhase ) |
|
269 { |
|
270 PRINTN1( "Response 0x%x received while already in completing phase", response ); |
|
271 } |
|
272 else |
|
273 { |
|
274 SetPhaseL( ECompletingPhase ); |
|
275 TMTPTypeResponse::CopyL( aResponse, iResponse ); |
|
276 iResponseCode = response; |
|
277 switch ( operationCode ) |
|
278 { |
|
279 case EMTPOpCodeGetObjectPropList: |
|
280 if ( iPendingOperation == EGetObjectPropList ) |
|
281 { |
|
282 PRINTN0( "GetObjectPropList async operation aborted" ); |
|
283 iAsyncResult = KErrAbort; |
|
284 if ( iActiveSchedulerWait->IsStarted() ) |
|
285 { |
|
286 iActiveSchedulerWait->AsyncStop(); |
|
287 } |
|
288 iPendingOperation = EIdleOperation; |
|
289 } |
|
290 break; |
|
291 case EMTPOpCodeSetObjectPropList: |
|
292 if ( iPendingOperation == ESetObjectPropList ) |
|
293 { |
|
294 PRINTN0( "SetObjectPropList async operation finished successfully" ); |
|
295 iAsyncResult = KErrNone; |
|
296 } |
|
297 else |
|
298 { |
|
299 PRINTE0( "SetObjectPropList async operation finished in incorrect state" ); |
|
300 iAsyncResult = KErrNotReady; |
|
301 } |
|
302 if ( iActiveSchedulerWait->IsStarted() ) |
|
303 { |
|
304 iActiveSchedulerWait->AsyncStop(); |
|
305 } |
|
306 iPendingOperation = EIdleOperation; |
|
307 break; |
|
308 case EMTPOpCodeDeleteObject: |
|
309 if ( iPendingOperation == EDeleteObject ) |
|
310 { |
|
311 PRINTN0( "DeleteObject async operation finished successfully" ); |
|
312 iAsyncResult = KErrNone; |
|
313 } |
|
314 else |
|
315 { |
|
316 PRINTE0( "DeleteObject async operation finished in incorrect state" ); |
|
317 iAsyncResult = KErrNotReady; |
|
318 } |
|
319 if ( iActiveSchedulerWait->IsStarted() ) |
|
320 { |
|
321 iActiveSchedulerWait->AsyncStop(); |
|
322 } |
|
323 iPendingOperation = EIdleOperation; |
|
324 break; |
|
325 } |
|
326 } |
|
327 PRINTF0( "<CTestObserver::SendResponseL" ); |
|
328 } |
|
329 |
|
330 void CTestObserver::TransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, |
|
331 MMTPConnection& /*aConnection*/) |
|
332 { |
|
333 PRINTF0( "<>CTestObserver::TransactionCompleteL" ); |
|
334 SetPhaseL( EIdlePhase ); |
|
335 } |
|
336 |
|
337 void CTestObserver::RouteRequestRegisterL(const TMTPTypeRequest& /*aRequest*/, |
|
338 MMTPConnection& /*aConnection*/) |
|
339 { |
|
340 PRINTF0( "<>CTestObserver::RouteRequestRegisterL" ); |
|
341 } |
|
342 |
|
343 void CTestObserver::RouteRequestUnregisterL(const TMTPTypeRequest& /*aRequest*/, |
|
344 MMTPConnection& /*aConnection*/) |
|
345 { |
|
346 PRINTF0( "<>CTestObserver::RouteRequestUnregisterL" ); |
|
347 } |
|
348 |
|
349 void CTestObserver::ObjectEnumerationCompleteL( TUint32 aStorageId ) |
|
350 { |
|
351 PRINTF1( ">CTestObserver::ObjectEnumerationCompleteL aStorageId = 0x%x", aStorageId ); |
|
352 |
|
353 if ( iPendingOperation == EObjectEnumeration ) |
|
354 { |
|
355 if ( iActiveSchedulerWait->IsStarted() ) |
|
356 { |
|
357 iActiveSchedulerWait->AsyncStop(); |
|
358 } |
|
359 iAsyncResult = KErrNone; |
|
360 iObjectEnumerationComplete = ETrue; |
|
361 iPendingOperation = EIdleOperation; |
|
362 } |
|
363 else |
|
364 { |
|
365 PRINTE0( "Unexpected pending operation" ); |
|
366 iObjectEnumerationComplete = EFalse; |
|
367 iAsyncResult = KErrNotReady; |
|
368 } |
|
369 PRINTF0( "<CTestObserver::ObjectEnumerationCompleteL" ); |
|
370 } |
|
371 |
|
372 void CTestObserver::StorageEnumerationCompleteL() |
|
373 { |
|
374 PRINTF0( ">CTestObserver::StorageEnumerationCompleteL" ); |
|
375 if ( iPendingOperation == EStorageEnumeration ) |
|
376 { |
|
377 if ( iActiveSchedulerWait->IsStarted() ) |
|
378 { |
|
379 iActiveSchedulerWait->AsyncStop(); |
|
380 } |
|
381 iAsyncResult = KErrNone; |
|
382 iStorageEnumerationComplete = ETrue; |
|
383 iPendingOperation = EIdleOperation; |
|
384 } |
|
385 else |
|
386 { |
|
387 PRINTE0( "Unexpected pending operation" ); |
|
388 iStorageEnumerationComplete = EFalse; |
|
389 iAsyncResult = KErrNotReady; |
|
390 } |
|
391 PRINTF0( "<CTestObserver::StorageEnumerationCompleteL" ); |
|
392 } |
|
393 |
|
394 TBool CTestObserver::ObjectEnumerationComplete() const |
|
395 { |
|
396 PRINTF1( "<>CTestObserver::ObjectEnumerationComplete = %d", iObjectEnumerationComplete ); |
|
397 return iObjectEnumerationComplete; |
|
398 } |
|
399 |
|
400 TInt CTestObserver::ObjectEnumerationError() const |
|
401 { |
|
402 PRINTF1( "<>CTestObserver::ObjectEnumerationError = %d", iObjectEnumerationError ); |
|
403 return iObjectEnumerationError; |
|
404 } |
|
405 |
|
406 TBool CTestObserver::StorageEnumerationComplete() const |
|
407 { |
|
408 PRINTF1( "<>CTestObserver::ObjectEnumerationError = %d", iStorageEnumerationComplete ); |
|
409 return iStorageEnumerationComplete; |
|
410 } |
|
411 |
|
412 // sets the phase member variable and leaves if state transition is illegal |
|
413 TMTPTransactionPhase CTestObserver::SetPhaseL( TMTPTransactionPhase aPhase ) |
|
414 { |
|
415 PRINTF1( ">CTestObserver::SetPhaseL aPhase = 0x%x", aPhase ) |
|
416 TMTPTransactionPhase result = iPhase; |
|
417 switch ( aPhase ) |
|
418 { |
|
419 case EUndefined: |
|
420 iPhase = aPhase; |
|
421 result = iPhase; |
|
422 break; |
|
423 case EIdlePhase: |
|
424 if ( iPhase == ECompletingPhase ) |
|
425 { |
|
426 iPhase = aPhase; |
|
427 result = iPhase; |
|
428 } |
|
429 else |
|
430 { |
|
431 PRINTE0( "Illegal attempt to switch to idle phase" ); |
|
432 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
433 User::Leave( KErrNotReady ); |
|
434 } |
|
435 break; |
|
436 case ERequestPhase: |
|
437 if ( iPhase == EUndefined ) |
|
438 { |
|
439 iPhase = aPhase; |
|
440 result = iPhase; |
|
441 } |
|
442 else |
|
443 { |
|
444 PRINTE0( "Illegal attempt to switch to request phase" ); |
|
445 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
446 User::Leave( KErrNotReady ); |
|
447 } |
|
448 break; |
|
449 case EResponsePhase: |
|
450 switch ( iPhase ) |
|
451 { |
|
452 case ECompletingPhase: |
|
453 PRINTN0( "Attempted to switch back to response phase from completing phase" ); |
|
454 // while already in completing phase, must not change internal state |
|
455 result = aPhase; |
|
456 break; |
|
457 case ERequestPhase: |
|
458 case EDataIToRPhase: |
|
459 case EDataRToIPhase: |
|
460 iPhase = aPhase; |
|
461 result = iPhase; |
|
462 break; |
|
463 default: |
|
464 PRINTE0( "Illegal attempt to switch to response phase" ); |
|
465 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
466 User::Leave( KErrNotReady ); |
|
467 break; |
|
468 } |
|
469 break; |
|
470 case ECompletingPhase: |
|
471 switch ( iPhase ) |
|
472 { |
|
473 case ECompletingPhase: |
|
474 // allow switch but print notice |
|
475 PRINTN0( "Attempted to switch to completing phase while already in completing phase" ); |
|
476 result = iPhase; |
|
477 break; |
|
478 case EIdlePhase: |
|
479 // some operations do automatically the completing phase |
|
480 // allow switch but don't change internal phase |
|
481 PRINTN0( "Attempted to switch to completing phase while already in idle phase" ); |
|
482 result = aPhase; |
|
483 break; |
|
484 case ERequestPhase: |
|
485 case EDataIToRPhase: |
|
486 case EDataRToIPhase: |
|
487 case EResponsePhase: |
|
488 iPhase = aPhase; |
|
489 result = iPhase; |
|
490 break; |
|
491 default: |
|
492 PRINTE0( "Illegal attempt to switch to completing phase" ); |
|
493 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
494 User::Leave( KErrNotReady ); |
|
495 break; |
|
496 } |
|
497 break; |
|
498 case EDataIToRPhase: |
|
499 if ( iPhase == ERequestPhase ) |
|
500 { |
|
501 iPhase = aPhase; |
|
502 result = iPhase; |
|
503 } |
|
504 else |
|
505 { |
|
506 PRINTE0( "Illegal attempt to switch to data i to r phase" ); |
|
507 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
508 User::Leave( KErrNotReady ); |
|
509 } |
|
510 break; |
|
511 case EDataRToIPhase: |
|
512 if ( iPhase == ERequestPhase ) |
|
513 { |
|
514 iPhase = aPhase; |
|
515 result = iPhase; |
|
516 } |
|
517 else |
|
518 { |
|
519 PRINTE0( "Illegal attempt to switch to data r to i phase" ); |
|
520 PRINTE1( "Current phase: 0x%x", iPhase ); |
|
521 User::Leave( KErrNotReady ); |
|
522 } |
|
523 break; |
|
524 default: |
|
525 PRINTE0( "Attempting to switch to illegal phase" ); |
|
526 PRINTE1( "Tried to change to phase: 0x%x", aPhase ); |
|
527 User::Leave( KErrArgument ); |
|
528 break; |
|
529 } |
|
530 PRINTF1( "<CTestObserver::SetPhaseL result = %d", result ); |
|
531 return result; |
|
532 } |
|
533 |
|
534 const MMTPDataProviderConfig& CTestObserver::DataProviderConfig() const |
|
535 { |
|
536 PRINTF0( "<>CTestObserver::DataProviderConfig" ); |
|
537 return *this; |
|
538 } |
|
539 |
|
540 const MMTPFrameworkConfig& CTestObserver::FrameworkConfig() const |
|
541 { |
|
542 PRINTF0( "<>CTestObserver::FrameworkConfig" ); |
|
543 PRINTE0( "NOT IMPLEMENTED" ); |
|
544 } |
|
545 |
|
546 |
|
547 MMTPObjectMgr& CTestObserver::ObjectMgr() const |
|
548 { |
|
549 PRINTF0( "<>CTestObserver::ObjectMgr" ); |
|
550 return *iTestObjManager; |
|
551 } |
|
552 |
|
553 MMTPReferenceMgr& CTestObserver::ReferenceMgr() const |
|
554 { |
|
555 PRINTF0( "<>CTestObserver::ReferenceMgr()" ); |
|
556 PRINTE0( "NOT IMPLEMENTED" ); |
|
557 } |
|
558 |
|
559 MMTPStorageMgr& CTestObserver::StorageMgr() const |
|
560 { |
|
561 PRINTF0( "<>CTestObserver::StorageMgr" ); |
|
562 return *iStorageManager; |
|
563 } |
|
564 |
|
565 |
|
566 RFs& CTestObserver::Fs() const |
|
567 { |
|
568 PRINTF0( "<>CTestObserver::Fs()" ); |
|
569 return const_cast<RFs&>(iFsSession); |
|
570 } |
|
571 |
|
572 void CTestObserver::SetPendingOperation( TAsyncOperation aOperation ) |
|
573 { |
|
574 PRINTF1( "<>CTestObserver::SetPendingOperation aOperation = %d", aOperation ); |
|
575 iPendingOperation = aOperation; |
|
576 } |
|
577 |
|
578 TInt CTestObserver::WaitForPendingOperation() |
|
579 { |
|
580 PRINTF0( ">CTestObserver::WaitForPendingOperation" ); |
|
581 if ( iPendingOperation != EIdleOperation ) |
|
582 { |
|
583 if ( iActiveSchedulerWait->IsStarted() ) |
|
584 { |
|
585 PRINTE0( "Active scheduler wait already started" ); |
|
586 iAsyncResult = KErrNotReady; |
|
587 } |
|
588 else |
|
589 { |
|
590 iActiveSchedulerWait->Start(); |
|
591 } |
|
592 } |
|
593 else |
|
594 { |
|
595 PRINTN0( "Pending operation already finished" ); |
|
596 } |
|
597 PRINTF1( "<CTestObserver::WaitForPendingOperation result = %d", iAsyncResult ); |
|
598 return iAsyncResult; |
|
599 } |
|
600 |
|
601 TInt CTestObserver::GetPendingResult() |
|
602 { |
|
603 PRINTF1( "<>CTestObserver::GetPendingResult = %d", iAsyncResult ); |
|
604 return iAsyncResult; |
|
605 } |
|
606 |
|
607 void CTestObserver::HandleAbstractMediaExportCompletedL( CMPXMedia* /*aMedia*/, TInt /*aErr*/ ) |
|
608 { |
|
609 PRINTF0( "<>CTestObserver::GetPendingResult" ); |
|
610 PRINTE0( "NOT IMPLEMENTED" ); |
|
611 } |
|
612 |
|
613 void CTestObserver::HandleAbstractMediaImportCompletedL( CMPXMedia* aMedia, TInt aErr ) |
|
614 { |
|
615 PRINTF0( ">CTestObserver::HandleAbstractMediaImportCompletedL" ); |
|
616 if ( iPendingOperation == EHarvesterImportAbstractMedia ) |
|
617 { |
|
618 // TODO: add check function for the harvest results using this media object |
|
619 if ( aMedia != NULL ) |
|
620 { |
|
621 delete aMedia; |
|
622 } |
|
623 iAsyncResult = aErr; |
|
624 } |
|
625 else |
|
626 { |
|
627 PRINTE0( "HarvesterImportPlaylist async operation finished in incorrect state" ); |
|
628 iAsyncResult = KErrNotReady; |
|
629 } |
|
630 if ( iActiveSchedulerWait->IsStarted() ) |
|
631 { |
|
632 iActiveSchedulerWait->AsyncStop(); |
|
633 } |
|
634 PRINTF0( "<CTestObserver::HandleAbstractMediaImportCompletedL" ); |
|
635 } |
|
636 |
|
637 void CTestObserver::HandleFileAddCompletedL( CMPXMedia* aMedia, TInt aErr ) |
|
638 { |
|
639 PRINTF1( ">CTestObserver::HandleFileAddCompletedL aErr = %d", aErr ); |
|
640 if ( iPendingOperation == EHarvesterAddObject ) |
|
641 { |
|
642 // TODO: add check function for the harvest results using this media object |
|
643 if ( aMedia != NULL ) |
|
644 { |
|
645 delete aMedia; |
|
646 } |
|
647 iAsyncResult = aErr; |
|
648 } |
|
649 else |
|
650 { |
|
651 PRINTE0( "HarvesterAddObject async operation finished in incorrect state" ); |
|
652 iAsyncResult = KErrNotReady; |
|
653 } |
|
654 if ( iActiveSchedulerWait->IsStarted() ) |
|
655 { |
|
656 iActiveSchedulerWait->AsyncStop(); |
|
657 } |
|
658 PRINTF0( "<CTestObserver::HandleFileAddCompletedL" ); |
|
659 } |
|
660 |
|
661 void CTestObserver::HandleDeleteCompletedL( TInt aErr ) |
|
662 { |
|
663 PRINTF1( ">CTestObserver::HandleDeleteCompletedL aErr = %d", aErr ); |
|
664 if ( iPendingOperation == EHarvesterDeleteObject ) |
|
665 { |
|
666 iAsyncResult = aErr; |
|
667 } |
|
668 else |
|
669 { |
|
670 PRINTE0( "HarvesterDeleteObject async operation finished in incorrect state" ); |
|
671 iAsyncResult = KErrNotReady; |
|
672 } |
|
673 if ( iActiveSchedulerWait->IsStarted() ) |
|
674 { |
|
675 iActiveSchedulerWait->AsyncStop(); |
|
676 } |
|
677 PRINTF0( "<CTestObserver::HandleDeleteCompletedL" ); |
|
678 } |
|
679 |
|
680 void CTestObserver::HandleFileImportCompletedL( CMPXMedia* /*aMedia*/, TInt /*aErr*/ ) |
|
681 { |
|
682 PRINTF0( "<>CTestObserver::HandleFileImportCompletedL" ); |
|
683 PRINTE0( "NOT IMPLEMENTED" ); |
|
684 } |
|
685 |
|
686 void CTestObserver::HandleFileGetMediaCompletedL( CMPXMedia* /*aMedia*/, TInt /*aErr*/ ) |
|
687 { |
|
688 PRINTF0( "<>CTestObserver::HandleFileGetMediaCompletedL" ); |
|
689 PRINTE0( "NOT IMPLEMENTED" ); |
|
690 } |
|
691 |
|
692 TUint CTestObserver::UintValue( MMTPDataProviderConfig::TParameter aParam ) const |
|
693 { |
|
694 PRINTF1( ">CTestObserver::UintValue aParam = %d", aParam ); |
|
695 TUint result = 0; |
|
696 switch ( aParam ) |
|
697 { |
|
698 case EOpaqueResource: |
|
699 result = iResourceId; |
|
700 break; |
|
701 default: |
|
702 PRINTE1( "UintValue called with unexpected param: 0x%x", aParam ); |
|
703 } |
|
704 PRINTF1( "<CTestObserver::UintValue result = %d", result ); |
|
705 return result; |
|
706 } |
|
707 |
|
708 TBool CTestObserver::BoolValue( MMTPDataProviderConfig::TParameter aParam ) const |
|
709 { |
|
710 PRINTF1( ">CTestObserver::BoolValue aParam = %d", aParam ); |
|
711 TBool result = EFalse; |
|
712 PRINTF1( "<CTestObserver::BoolValue result = %d", result ); |
|
713 return result; |
|
714 } |
|
715 |
|
716 const TDesC& CTestObserver::DesCValue( MMTPDataProviderConfig::TParameter aParam ) const |
|
717 { |
|
718 PRINTF1( ">CTestObserver::DesCValue aParam = %d", aParam ); |
|
719 const TDesC* nullValue( &KNullDesC ); |
|
720 const TDesC* resValue( &KResFileName ); |
|
721 switch ( aParam ) |
|
722 { |
|
723 case EResourceFileName: |
|
724 PRINTF1( "<CTestObserver::DesCValue result = %S", resValue ); |
|
725 return *resValue; |
|
726 default: |
|
727 PRINTE1( "DesCValue called with unexpected param: 0x%x", aParam ); |
|
728 User::Leave( KErrArgument ); |
|
729 } |
|
730 } |
|
731 |
|
732 const TDesC8& CTestObserver::DesC8Value( MMTPDataProviderConfig::TParameter aParam ) const |
|
733 { |
|
734 PRINTF1( "<>CTestObserver::DesC8Value aParam = %d", aParam ); |
|
735 return KNullDesC8; |
|
736 } |
|
737 |
|
738 void CTestObserver::GetArrayValue( MMTPDataProviderConfig::TParameter aParam, RArray<TUint>& aArray ) const |
|
739 { |
|
740 PRINTF1( ">CTestObserver::GetArrayValue aParam = %d", aParam ); |
|
741 switch (aParam) |
|
742 { |
|
743 case ESupportedModes: |
|
744 { |
|
745 PRINTV0( "Appending MTP mode" ); |
|
746 aArray.Append(EModeMTP); |
|
747 break; |
|
748 } |
|
749 default: |
|
750 PRINTE1( "GetArrayValue called with unexpected param: 0x%x", aParam ); |
|
751 User::Leave( KErrArgument ); |
|
752 } |
|
753 PRINTF0( "<CTestObserver::GetArrayValue" ); |
|
754 } |