|
1 //* |
|
2 * Copyright (c) 2002 - 2007 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: Implementation of collection test plugin interface |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32cmn.h> |
|
20 #include <mpxcmn.h> |
|
21 #include <mpxcollectionpluginobserver.h> |
|
22 #include <mpxmedia.h> |
|
23 #include <mpxmediaarray.h> |
|
24 #include <mpxcommonframeworkdefs.h> |
|
25 #include <mpxmediamusicdefs.h> |
|
26 #include <mpxmediadrmdefs.h> |
|
27 #include <mpxmediacontainerdefs.h> |
|
28 #include <mpxmessagecontainerdefs.h> |
|
29 #include <mpxcommandgeneraldefs.h> |
|
30 #include <mpxcollectioncommanddefs.h> |
|
31 #include <stringloader.h> |
|
32 #include <flogger.h> |
|
33 #include "testcommonpluginuids.h" |
|
34 #include "testcollectionplugin.h" |
|
35 |
|
36 // CONSTANTS |
|
37 _LIT(KFolder, "mpxt"); |
|
38 _LIT(KFile, "CFwCollection.txt"); |
|
39 |
|
40 #define LOG1(a) RFileLogger::Write(KFolder, KFile, EFileLoggingModeAppend, a) |
|
41 #define LOG2(a,b) RFileLogger::WriteFormat(KFolder, KFile, EFileLoggingModeAppend, a, b) |
|
42 #define LOG3(a,b,c) RFileLogger::WriteFormat(KFolder, KFile, EFileLoggingModeAppend, a, b, c) |
|
43 #define LOG4(a,b,c,d) RFileLogger::WriteFormat(KFolder, KFile, EFileLoggingModeAppend, a, b, c,d) |
|
44 |
|
45 |
|
46 // =========================================== LOCAL FUNCTIONS ============================================== |
|
47 // print out (index, id) for each level and the first 15 ids at top level |
|
48 LOCAL_C void LogPath( const CMPXCollectionPath& aPath )\ |
|
49 { |
|
50 TInt levels = aPath.Levels(); |
|
51 TInt count = aPath.Count(); |
|
52 LOG3(_L("Collection Path debug: levels= %d, count = %d"), levels, count); |
|
53 for (TInt i=0; i<levels;++i) |
|
54 { |
|
55 LOG4(_L("Collection Path debug: Level[%d] = (index %d, id 0x%08x)"), i, |
|
56 aPath.Index(i), |
|
57 aPath.Id(i) ); |
|
58 } |
|
59 if (count > 0) |
|
60 { |
|
61 TInt index = aPath.Index(); |
|
62 CMPXCollectionPath* dpath = const_cast<CMPXCollectionPath*>(&aPath); |
|
63 dpath->SetToFirst(); |
|
64 TInt c = 0; |
|
65 do |
|
66 { |
|
67 LOG3(_L("Collection Path debug top level: item %d = id 0x%08x"), c, dpath->Id()); |
|
68 } while (++(*dpath) && ++c < 15 ); |
|
69 dpath->Set(index); |
|
70 } |
|
71 } |
|
72 |
|
73 |
|
74 // =========================================== MEMBER FUNCTIONS ============================================= |
|
75 // ---------------------------------------------------------------------------------------------------------- |
|
76 // Two-phased constructor. |
|
77 // ---------------------------------------------------------------------------------------------------------- |
|
78 // |
|
79 CTestCollectionPlugin* CTestCollectionPlugin::NewL (TAny* /*aInitParams*/) |
|
80 { |
|
81 CTestCollectionPlugin* self = new (ELeave) CTestCollectionPlugin(); |
|
82 CleanupStack::PushL (self); |
|
83 self->ConstructL (); |
|
84 CleanupStack::Pop (self); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------------------------------------- |
|
89 // Destructor. |
|
90 // ---------------------------------------------------------------------------------------------------------- |
|
91 // |
|
92 CTestCollectionPlugin::~CTestCollectionPlugin () |
|
93 { |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------------------------------------- |
|
97 // Constructor. |
|
98 // ---------------------------------------------------------------------------------------------------------- |
|
99 // |
|
100 CTestCollectionPlugin::CTestCollectionPlugin () |
|
101 { |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------------------------------------------------------- |
|
105 // Symbian 2nd phase constructor can leave. |
|
106 // ---------------------------------------------------------------------------------------------------------- |
|
107 // |
|
108 void CTestCollectionPlugin::ConstructL () |
|
109 { |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------------------------------------- |
|
113 // Navigates to the given path |
|
114 // ---------------------------------------------------------------------------------------------------------- |
|
115 // |
|
116 void CTestCollectionPlugin::OpenL(const CMPXCollectionPath& aPath, |
|
117 const TArray<TMPXAttribute>& aAttrs, |
|
118 CMPXFilter* aFilter) |
|
119 { |
|
120 LOG1(_L("CTestCollectionPlugin::OpenL")); |
|
121 LogPath( aPath ); |
|
122 TMPXOpenMode openMode = aPath.OpenNextMode(); |
|
123 TInt idIndex = aPath.Levels() - 1; |
|
124 LOG2(_L("TMPXOpendMode=%d"), openMode); |
|
125 LOG2(_L("aFilter=%x"), aFilter); |
|
126 |
|
127 RArray<TInt> supportedIds; |
|
128 CleanupClosePushL(supportedIds); |
|
129 supportedIds.AppendL(KMPXMediaIdContainer); |
|
130 supportedIds.AppendL(KMPXMediaIdGeneral); |
|
131 |
|
132 CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array()); |
|
133 CleanupStack::PopAndDestroy(&supportedIds); |
|
134 CleanupStack::PushL(entries); |
|
135 entries->SetTObjectValueL<TMPXItemId>(TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralId), aPath.Id(idIndex)); |
|
136 |
|
137 if(aPath.Levels() == 1) |
|
138 { |
|
139 // Plugin's root level |
|
140 RArray<TInt> ids; |
|
141 CleanupClosePushL( ids ); |
|
142 ids.Append( 11 ); |
|
143 ids.Append( 12 ); |
|
144 ids.Append( 13 ); |
|
145 ids.Append( 990 ); // for Playback Framework Test |
|
146 RArray<TMPXAttribute> attrs; |
|
147 CleanupClosePushL( attrs ); |
|
148 attrs.Append( KMPXMediaGeneralId ); |
|
149 attrs.Append( KMPXMediaGeneralUri ); |
|
150 attrs.Append( KMPXMediaGeneralTitle ); |
|
151 |
|
152 CMPXMediaArray* array=CMPXMediaArray::NewL(); |
|
153 CleanupStack::PushL( array ); |
|
154 |
|
155 const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; |
|
156 AddMediaL(*array, ids, tempRef); |
|
157 FilterMediaArray(*array, aFilter); |
|
158 |
|
159 entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); |
|
160 entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); |
|
161 |
|
162 iObs->HandleOpen (entries, KErrNone); |
|
163 CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids |
|
164 } |
|
165 else if(aPath.Levels() == 2) |
|
166 { |
|
167 // Opening plugin's root menu |
|
168 TInt topLevId = aPath.Id(1); |
|
169 RArray<TInt> ids; |
|
170 CleanupClosePushL( ids ); |
|
171 RArray<TMPXAttribute> attrs; |
|
172 CleanupClosePushL( attrs ); |
|
173 CMPXMediaArray* array=CMPXMediaArray::NewL(); |
|
174 CleanupStack::PushL( array ); |
|
175 |
|
176 attrs.Append( KMPXMediaGeneralId ); |
|
177 attrs.Append( KMPXMediaGeneralUri ); |
|
178 attrs.Append( KMPXMediaGeneralTitle ); |
|
179 if(topLevId == 11) |
|
180 { |
|
181 ids.Append( 211 ); |
|
182 ids.Append( 212 ); |
|
183 ids.Append( 213 ); |
|
184 } |
|
185 else if(topLevId == 12) |
|
186 { |
|
187 ids.Append( 221 ); |
|
188 } |
|
189 else if(topLevId == 13) |
|
190 { |
|
191 ids.Append( 231 ); |
|
192 ids.Append( 232 ); |
|
193 } |
|
194 else if(topLevId == 990) |
|
195 { |
|
196 ids.Append( 9901 ); |
|
197 ids.Append( 9902 ); |
|
198 ids.Append( 9903 ); |
|
199 ids.Append( 9904 ); |
|
200 ids.Append( 9905 ); |
|
201 ids.Append( 9906 ); |
|
202 ids.Append( 9907 ); |
|
203 } |
|
204 const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; |
|
205 AddMediaL(*array, ids, tempRef); |
|
206 FilterMediaArray(*array, aFilter); |
|
207 |
|
208 entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); |
|
209 entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); |
|
210 |
|
211 iObs->HandleOpen (entries, KErrNone); |
|
212 CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids |
|
213 } |
|
214 else if(aPath.Levels() == 3) |
|
215 { |
|
216 // Opening plugin's 2nd |
|
217 TInt secLevId = aPath.Id(2); |
|
218 |
|
219 RArray<TInt> ids; |
|
220 CleanupClosePushL( ids ); |
|
221 RArray<TMPXAttribute> attrs; |
|
222 CleanupClosePushL( attrs ); |
|
223 CMPXMediaArray* array=CMPXMediaArray::NewL(); |
|
224 CleanupStack::PushL( array ); |
|
225 |
|
226 attrs.Append( KMPXMediaGeneralId ); |
|
227 attrs.Append( KMPXMediaGeneralUri ); |
|
228 attrs.Append( KMPXMediaGeneralTitle ); |
|
229 switch( secLevId ) |
|
230 { |
|
231 case 211: |
|
232 ids.Append( 3111 ); |
|
233 break; |
|
234 case 212: |
|
235 ids.Append( 3121 ); |
|
236 break; |
|
237 case 213: |
|
238 ids.Append( 3131 ); |
|
239 break; |
|
240 case 221: |
|
241 // Empty |
|
242 break; |
|
243 case 231: |
|
244 ids.Append( 3311 ); |
|
245 break; |
|
246 case 232: |
|
247 ids.Append( 3321 ); |
|
248 break; |
|
249 }; |
|
250 const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; |
|
251 AddMediaL(*array, ids, tempRef); |
|
252 FilterMediaArray(*array, aFilter); |
|
253 |
|
254 entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); |
|
255 entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); |
|
256 |
|
257 iObs->HandleOpen (entries, KErrNone); |
|
258 CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids |
|
259 } |
|
260 else |
|
261 { |
|
262 User::Leave( KErrNotFound ); |
|
263 } |
|
264 CleanupStack::PopAndDestroy( entries ); |
|
265 } |
|
266 |
|
267 // ---------------------------------------------------------------------------------------------------------- |
|
268 // Get the extended properties of the current file (async) |
|
269 // ---------------------------------------------------------------------------------------------------------- |
|
270 // |
|
271 void CTestCollectionPlugin::MediaL (const CMPXCollectionPath& aPath, |
|
272 const TArray<TMPXAttribute>& aAttrs, |
|
273 const TArray<TCapability>& aCaps, |
|
274 CMPXAttributeSpecs* aSpecs) |
|
275 { |
|
276 LOG1(_L("CTestCollectionPlugin::MediaL")); |
|
277 LogPath( aPath ); |
|
278 TMPXOpenMode openMode = aPath.OpenNextMode(); |
|
279 //TInt idIndex = aPath.Levels() - 1; |
|
280 LOG2(_L("TMPXOpendMode=%d"), openMode); |
|
281 LOG2(_L("aAttrs.Count()=%d"), aAttrs.Count()); |
|
282 LOG2(_L("aCaps.Count()=%d"), aCaps.Count()); |
|
283 LOG2(_L("aSpecs=0x%x"), aSpecs); |
|
284 |
|
285 switch( (TInt)aPath.Id(1) ) |
|
286 { |
|
287 case 14: // Test0146 |
|
288 { |
|
289 iObs->HandleMedia(NULL, KErrNone); |
|
290 break; |
|
291 } |
|
292 case 15: // Test0147 |
|
293 { |
|
294 CMPXMedia* media = CMPXMedia::NewL(); |
|
295 CleanupStack::PushL( media ); |
|
296 iObs->HandleMedia(media, KErrNone); |
|
297 CleanupStack::PopAndDestroy( media ); |
|
298 break; |
|
299 } |
|
300 case 16: // Test0148 |
|
301 { |
|
302 CMPXMedia* media = CMPXMedia::NewL(); |
|
303 CleanupStack::PushL( media ); |
|
304 iObs->HandleMedia(media, KErrNotFound); |
|
305 CleanupStack::PopAndDestroy( media ); |
|
306 break; |
|
307 } |
|
308 case 17: // Test0149 |
|
309 { |
|
310 CMPXMedia* media = CMPXMedia::NewL(); |
|
311 CleanupStack::PushL( media ); |
|
312 (*media) = *aSpecs; |
|
313 iObs->HandleMedia(media, KErrNone); |
|
314 CleanupStack::PopAndDestroy( media ); |
|
315 break; |
|
316 } |
|
317 case 990: // Test data for playback framework teests |
|
318 { |
|
319 CMPXMedia* media = CMPXMedia::NewL(); |
|
320 CleanupStack::PushL( media ); |
|
321 |
|
322 switch( (TInt)aPath.Id(2) ) |
|
323 { |
|
324 case 9901: |
|
325 AddAttrbuteL(*media, 9901, _L("song9901"), _L("\\song9901.ts"), aAttrs); |
|
326 AddAttributePlaybackFwTestL(*media, 9901, aAttrs); |
|
327 break; |
|
328 case 9902: |
|
329 AddAttrbuteL(*media, 9902, _L("song9902"), _L("\\song9902.ts"), aAttrs); |
|
330 AddAttributePlaybackFwTestL(*media, 9902, aAttrs); |
|
331 break; |
|
332 case 9903: |
|
333 AddAttrbuteL(*media, 9903, _L("song9903"), _L("\\song9903.ts"), aAttrs); |
|
334 AddAttributePlaybackFwTestL(*media, 9903, aAttrs); |
|
335 break; |
|
336 case 9904: |
|
337 AddAttrbuteL(*media, 9904, _L("song9904"), _L("\\song9904.ts"), aAttrs); |
|
338 AddAttributePlaybackFwTestL(*media, 9904, aAttrs); |
|
339 break; |
|
340 case 9905: |
|
341 AddAttrbuteL(*media, 9905, _L("song9905"), _L("\\song9905.ts"), aAttrs); |
|
342 AddAttributePlaybackFwTestL(*media, 9905, aAttrs); |
|
343 break; |
|
344 case 9906: |
|
345 AddAttrbuteL(*media, 9906, _L("song9906"), _L("\\song9906.ts"), aAttrs); |
|
346 AddAttributePlaybackFwTestL(*media, 9906, aAttrs); |
|
347 break; |
|
348 case 9907: |
|
349 AddAttrbuteL(*media, 9907, _L("song9907"), _L("\\song9907.ts"), aAttrs); |
|
350 AddAttributePlaybackFwTestL(*media, 9907, aAttrs); |
|
351 break; |
|
352 }; |
|
353 iObs->HandleMedia(media, KErrNone); |
|
354 CleanupStack::PopAndDestroy( media ); |
|
355 break; |
|
356 } |
|
357 default: |
|
358 User::Leave( KErrNotFound ); |
|
359 }; |
|
360 } |
|
361 |
|
362 // ---------------------------------------------------------------------------------------------------------- |
|
363 // Cancel outstanding request |
|
364 // ---------------------------------------------------------------------------------------------------------- |
|
365 // |
|
366 void CTestCollectionPlugin::CancelRequest() |
|
367 { |
|
368 LOG1(_L("CTestCollectionPlugin::CancelRequest")); |
|
369 } |
|
370 |
|
371 // ---------------------------------------------------------------------------------------------------------- |
|
372 // Executes the given command on the collection |
|
373 // ---------------------------------------------------------------------------------------------------------- |
|
374 // |
|
375 void CTestCollectionPlugin::CommandL(TMPXCollectionCommand aCmd, TInt aArg ) |
|
376 { |
|
377 LOG1(_L("CTestCollectionPlugin::CommandL")); |
|
378 LOG3(_L("TMPXCollectionCommand=%d; aArg=%d"), aCmd, aArg); |
|
379 switch( aCmd ) |
|
380 { |
|
381 case EMcCmdClose: |
|
382 LOG1( _L("McCmdClose command received")); |
|
383 break; |
|
384 case EMcCmdRefresh: |
|
385 LOG1( _L("EMcCmdRefresh command received")); |
|
386 break; |
|
387 case EMcCmdRemoveAll: |
|
388 LOG1( _L("EMcCmdRemoveAll command received")); |
|
389 break; |
|
390 case EMcCloseCollection: |
|
391 LOG1( _L("EMcCloseCollection command received")); |
|
392 break; |
|
393 case EMcReOpenCollection: |
|
394 LOG1( _L("EMcReOpenCollection command received")); |
|
395 break; |
|
396 case EMcRefreshStarted: |
|
397 LOG1( _L("EMcRefreshStarted command received")); |
|
398 break; |
|
399 case EMcRefreshEnded: |
|
400 LOG1( _L("EMcRefreshEnded command received")); |
|
401 break; |
|
402 case EMcCmdReCreateDB: |
|
403 LOG1( _L("EMcCmdReCreateDB command received")); |
|
404 break; |
|
405 case EMcCmdSelect: |
|
406 LOG1( _L("EMcCmdSelect command received")); |
|
407 break; |
|
408 case EMcCmdDbCorrupted: |
|
409 LOG1( _L("EMcCmdDbCorrupted command received")); |
|
410 break; |
|
411 case EMcCmdCollectionInit: |
|
412 LOG1( _L("EMcCmdCollectionInit command received")); |
|
413 break; |
|
414 case EMcCmdCollectionResyn: |
|
415 LOG1( _L("EMcCmdCollectionResyn command received")); |
|
416 break; |
|
417 default: |
|
418 break; |
|
419 }; |
|
420 } |
|
421 |
|
422 // ---------------------------------------------------------------------------------------------------------- |
|
423 // Executes the given command on the collection |
|
424 // ---------------------------------------------------------------------------------------------------------- |
|
425 // |
|
426 void CTestCollectionPlugin::CommandL(CMPXCommand& aCmd) |
|
427 { |
|
428 LOG1(_L("CTestCollectionPlugin::CommandL")); |
|
429 const TDesC& title = aCmd.ValueText( KMPXMediaGeneralTitle ); |
|
430 TMPXCommandId cmdId = aCmd.ValueTObjectL<TMPXCommandId>(KMPXCommandGeneralId); |
|
431 LOG2(_L("CommandId = %d"), cmdId); |
|
432 |
|
433 if(title == _L("CollectionPluginTest0175") ) |
|
434 { |
|
435 } |
|
436 else if(title == _L("CollectionPluginTest0176") ) |
|
437 { |
|
438 iObs->HandleCommandComplete(NULL, KErrNone); |
|
439 } |
|
440 else if(title == _L("CollectionPluginTest0177") ) |
|
441 { |
|
442 iObs->HandleCommandComplete(NULL, KErrGeneral); |
|
443 } |
|
444 else if(title == _L("CollectionPluginTest0183") ) |
|
445 { |
|
446 } |
|
447 else if(title == _L("CollectionPluginTest0184") ) |
|
448 { |
|
449 CMPXCommand* newCmd = CMPXCommand::NewL(); |
|
450 CleanupStack::PushL( newCmd ); |
|
451 *newCmd = aCmd; |
|
452 iObs->HandleCommandComplete(newCmd, KErrNone); |
|
453 CleanupStack::PopAndDestroy( newCmd ); |
|
454 } |
|
455 else |
|
456 { |
|
457 TBool syncOp(EFalse); |
|
458 if( aCmd.IsSupported(KMPXCommandGeneralDoSync) ) |
|
459 { |
|
460 syncOp = *aCmd.Value<TBool>(KMPXCommandGeneralDoSync); |
|
461 } |
|
462 |
|
463 switch( cmdId ) |
|
464 { |
|
465 case KMPXCommandIdCollectionRetrieveUriForDeletion: |
|
466 { // TODO |
|
467 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionRetrieveUriForDeletion")); |
|
468 //DoRetrieveUriForDeletionL(aCmd); |
|
469 break; |
|
470 } |
|
471 case KMPXCommandIdCollectionRemove: |
|
472 { |
|
473 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionRemove")); |
|
474 //DoRemovePathL(aCmd); |
|
475 break; |
|
476 } |
|
477 case KMPXCommandIdCollectionRemoveMedia: |
|
478 { |
|
479 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionRemoveMedia")); |
|
480 //DoRemoveMediaL(aCmd); |
|
481 break; |
|
482 } |
|
483 case KMPXCommandIdCollectionCleanupDeletedMedias: |
|
484 { |
|
485 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionCleanupDeletedMedias")); |
|
486 //DoCleanupDeletedMediasL(aCmd); |
|
487 break; |
|
488 } |
|
489 case KMPXCommandIdCollectionAdd: |
|
490 { |
|
491 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectioAdd")); |
|
492 |
|
493 CMPXMedia& media = *aCmd.Value<CMPXMedia>(KMPXCommandColAddMedia); |
|
494 AddL(media); |
|
495 break; |
|
496 } |
|
497 case KMPXCommandIdCollectionSet: |
|
498 { |
|
499 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionSet")); |
|
500 |
|
501 CMPXMedia& media = *aCmd.Value<CMPXMedia>(KMPXCommandColSetMedia); |
|
502 SetL( media ); |
|
503 break; |
|
504 } |
|
505 case KMPXCommandIdCollectionCompleteDelete: |
|
506 { |
|
507 LOG1(_L("CTestCollectionPlugin::CommandL - KMPXCommandIdCollectionCompleteDelete")); |
|
508 //DoHandleDeleteCompleteL( aCmd ); |
|
509 break; |
|
510 } |
|
511 default: |
|
512 { |
|
513 User::Panic(_L("CTestCollectionPlugin::CommandL panic"), 1); // magic number |
|
514 } |
|
515 } |
|
516 if (!syncOp) |
|
517 { |
|
518 iObs->HandleCommandComplete( NULL, KErrNone ); |
|
519 } |
|
520 } |
|
521 } |
|
522 |
|
523 // ---------------------------------------------------------------------------------------------------------- |
|
524 // Adds an item (song or playlist) to the collection |
|
525 // ---------------------------------------------------------------------------------------------------------- |
|
526 // |
|
527 void CTestCollectionPlugin::AddL (const CMPXMedia& aMedia) |
|
528 { |
|
529 LOG1(_L("CTestCollectionPlugin::AddL")); |
|
530 CMPXMessage* message = CMPXMessage::NewL(); |
|
531 CleanupStack::PushL( message ); |
|
532 |
|
533 const TDesC& title = aMedia.ValueText( KMPXMediaGeneralTitle ); |
|
534 |
|
535 if(title == _L("CollectionPluginTest0078") ) |
|
536 { |
|
537 FillItemChangeMessageL(*message, 78, EMPXItemInserted, EMPXOther); |
|
538 } |
|
539 else if(title == _L("CollectionPluginTest0079")) |
|
540 { |
|
541 FillItemChangeMessageL(*message, 79, EMPXItemInserted, EMPXSong); |
|
542 } |
|
543 else if(title == _L("CollectionPluginTest0080")) |
|
544 { |
|
545 FillItemChangeMessageL(*message, 80, EMPXItemInserted, EMPXPlaylist); |
|
546 } |
|
547 else |
|
548 { |
|
549 User::Panic(_L("CTestCollectionPlugin::AddL panic"), 1); // magic number |
|
550 } |
|
551 iObs->HandleMessage( *message ); |
|
552 CleanupStack::PopAndDestroy( message ); |
|
553 } |
|
554 |
|
555 // ---------------------------------------------------------------------------------------------------------- |
|
556 // Remove an item from the collection database using the given path |
|
557 // ---------------------------------------------------------------------------------------------------------- |
|
558 // |
|
559 void CTestCollectionPlugin::RemoveL (const CMPXCollectionPath& aPath) |
|
560 { |
|
561 LOG1(_L("CTestCollectionPlugin::RemoveL")); |
|
562 LogPath( aPath ); |
|
563 CDesCArrayFlat* fp = new (ELeave) CDesCArrayFlat(8); |
|
564 CleanupStack::PushL( fp ); |
|
565 switch( aPath.Levels() ) |
|
566 { |
|
567 case 2: |
|
568 if(aPath.Id() == 14) |
|
569 { // Test0091 |
|
570 iObs->HandleRemove( *fp, KErrNotFound ); |
|
571 } |
|
572 break; |
|
573 case 3: |
|
574 if(aPath.Id() == 212) |
|
575 { // Test0090 |
|
576 fp->AppendL( _L("\\song3121.ts") ); |
|
577 fp->AppendL( _L("\\song3122.ts") ); |
|
578 fp->AppendL( _L("\\song3123.tp") ); |
|
579 iObs->HandleRemove( *fp, KErrNone ); |
|
580 } |
|
581 break; |
|
582 case 4: |
|
583 if(aPath.Id() == 3111) |
|
584 { // Test0088 |
|
585 fp->AppendL( _L("\\song3111.ts") ); |
|
586 iObs->HandleRemove( *fp, KErrNone ); |
|
587 } |
|
588 break; |
|
589 default: |
|
590 User::Panic(_L("CTestCollectionPlugin::RemoveL panic"), 1); // magic number |
|
591 } |
|
592 CleanupStack::PopAndDestroy( fp ); |
|
593 } |
|
594 |
|
595 // ---------------------------------------------------------------------------------------------------------- |
|
596 // Remove an item from the collection database using the given media properties |
|
597 // ---------------------------------------------------------------------------------------------------------- |
|
598 // |
|
599 void CTestCollectionPlugin::RemoveL (const CMPXMedia& aMedia) |
|
600 { |
|
601 LOG1(_L("CTestCollectionPlugin::RemoveL")); |
|
602 const TDesC& title = aMedia.ValueText( KMPXMediaGeneralTitle ); |
|
603 |
|
604 // a list of change event messages a result of the item being removed |
|
605 CMPXMessageArray* itemChangedMessages = CMPXMessageArray::NewL(); |
|
606 CleanupStack::PushL(itemChangedMessages); |
|
607 |
|
608 if(title == _L("CollectionPluginTest0099") ) |
|
609 { |
|
610 CMPXMessage* message = CMPXMessage::NewL(); |
|
611 CleanupStack::PushL(message); |
|
612 FillItemChangeMessageL(*message, 99, EMPXItemDeleted, EMPXSong); |
|
613 itemChangedMessages->AppendL( *message ); |
|
614 CleanupStack::PopAndDestroy(message); |
|
615 } |
|
616 else if(title == _L("CollectionPluginTest0100") ) |
|
617 { |
|
618 CMPXMessage* message = CMPXMessage::NewL(); |
|
619 CleanupStack::PushL(message); |
|
620 FillItemChangeMessageL(*message, 100, EMPXItemDeleted, EMPXSong); |
|
621 itemChangedMessages->AppendL( *message ); |
|
622 CleanupStack::PopAndDestroy(message); |
|
623 message = NULL; |
|
624 message = CMPXMessage::NewL(); |
|
625 CleanupStack::PushL(message); |
|
626 FillItemChangeMessageL(*message, 100, EMPXItemDeleted, EMPXSong); |
|
627 itemChangedMessages->AppendL( *message ); |
|
628 CleanupStack::PopAndDestroy(message); |
|
629 } |
|
630 else |
|
631 { |
|
632 User::Panic(_L("CTestCollectionPlugin::RemoveL panic"), 1); // magic number |
|
633 } |
|
634 |
|
635 CMPXMessage* message = CMPXMessage::NewL(); |
|
636 CleanupStack::PushL(message); |
|
637 |
|
638 message->SetTObjectValueL<TMPXMessageId>( |
|
639 TMPXAttribute(KMPXMessageContentIdGeneral, EMPXMessageGeneralId), KMPXMessageIdItemChanged); |
|
640 message->SetCObjectValueL( |
|
641 TMPXAttribute(KMPXMessageIdContainer, EMPXMessageArrayContents), itemChangedMessages); |
|
642 message->SetTObjectValueL( |
|
643 TMPXAttribute(KMPXMessageIdContainer, EMPXMessageArrayCount), itemChangedMessages->Count()); |
|
644 |
|
645 iObs->HandleMessage( *message ); |
|
646 CleanupStack::PopAndDestroy(2, itemChangedMessages); // message, itemChangedMessages |
|
647 } |
|
648 |
|
649 // ---------------------------------------------------------------------------------------------------------- |
|
650 // Sets/updates the media for an item in the collection |
|
651 // ---------------------------------------------------------------------------------------------------------- |
|
652 // |
|
653 void CTestCollectionPlugin::SetL (const CMPXMedia& aMedia) |
|
654 { |
|
655 LOG1(_L("CTestCollectionPlugin::SetL")); |
|
656 const TDesC& title = aMedia.ValueText( KMPXMediaGeneralTitle ); |
|
657 |
|
658 // a list of change event messages a result of the item being removed |
|
659 CMPXMessageArray* itemChangedMessages = CMPXMessageArray::NewL(); |
|
660 CleanupStack::PushL(itemChangedMessages); |
|
661 |
|
662 if(title == _L("CollectionPluginTest0108") ) |
|
663 { |
|
664 CMPXMessage* message = CMPXMessage::NewL(); |
|
665 CleanupStack::PushL(message); |
|
666 FillItemChangeMessageL(*message, 108, EMPXItemModified, EMPXSong); |
|
667 itemChangedMessages->AppendL( *message ); |
|
668 CleanupStack::PopAndDestroy(message); |
|
669 } |
|
670 else if(title == _L("CollectionPluginTest0109") ) |
|
671 { |
|
672 CMPXMessage* message = CMPXMessage::NewL(); |
|
673 CleanupStack::PushL(message); |
|
674 FillItemChangeMessageL(*message, 109, EMPXItemModified, EMPXSong); |
|
675 itemChangedMessages->AppendL( *message ); |
|
676 CleanupStack::PopAndDestroy(message); |
|
677 message = NULL; |
|
678 message = CMPXMessage::NewL(); |
|
679 CleanupStack::PushL(message); |
|
680 FillItemChangeMessageL(*message, 109, EMPXItemModified, EMPXSong); |
|
681 itemChangedMessages->AppendL( *message ); |
|
682 CleanupStack::PopAndDestroy(message); |
|
683 } |
|
684 else if(title == _L("CollectionPluginTest0119") ) |
|
685 { |
|
686 CMPXMessage* message = CMPXMessage::NewL(); |
|
687 CleanupStack::PushL(message); |
|
688 FillItemChangeMessageL(*message, 119, EMPXItemModified, EMPXSong); |
|
689 itemChangedMessages->AppendL( *message ); |
|
690 CleanupStack::PopAndDestroy(message); |
|
691 } |
|
692 else if(title == _L("CollectionPluginTest0120") ) |
|
693 { |
|
694 CMPXMessage* message = CMPXMessage::NewL(); |
|
695 CleanupStack::PushL(message); |
|
696 FillItemChangeMessageL(*message, 120, EMPXItemModified, EMPXSong); |
|
697 itemChangedMessages->AppendL( *message ); |
|
698 CleanupStack::PopAndDestroy(message); |
|
699 message = NULL; |
|
700 message = CMPXMessage::NewL(); |
|
701 CleanupStack::PushL(message); |
|
702 FillItemChangeMessageL(*message, 120, EMPXItemModified, EMPXSong); |
|
703 itemChangedMessages->AppendL( *message ); |
|
704 CleanupStack::PopAndDestroy(message); |
|
705 } |
|
706 else |
|
707 { |
|
708 // Playback Framework may call this function |
|
709 //User::Panic(_L("CTestCollectionPlugin::SetL panic"), 1); // magic number |
|
710 } |
|
711 |
|
712 CMPXMessage* message = CMPXMessage::NewL(); |
|
713 CleanupStack::PushL(message); |
|
714 |
|
715 message->SetTObjectValueL<TMPXMessageId>( |
|
716 TMPXAttribute(KMPXMessageContentIdGeneral, EMPXMessageGeneralId), KMPXMessageIdItemChanged); |
|
717 message->SetCObjectValueL( |
|
718 TMPXAttribute(KMPXMessageIdContainer, EMPXMessageArrayContents), itemChangedMessages); |
|
719 message->SetTObjectValueL( |
|
720 TMPXAttribute(KMPXMessageIdContainer, EMPXMessageArrayCount), itemChangedMessages->Count()); |
|
721 |
|
722 iObs->HandleMessage( *message ); |
|
723 CleanupStack::PopAndDestroy(2, itemChangedMessages); // message, itemChangedMessages |
|
724 } |
|
725 |
|
726 // ---------------------------------------------------------------------------------------------------------- |
|
727 // Find the items matching the media specifications |
|
728 // ---------------------------------------------------------------------------------------------------------- |
|
729 // |
|
730 void CTestCollectionPlugin::FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs) |
|
731 { |
|
732 LOG1(_L("CTestCollectionPlugin::FindAllL")); |
|
733 const TDesC& title = aCriteria.ValueText( KMPXMediaGeneralTitle ); |
|
734 if(title == _L("CollectionPluginTest0128") || |
|
735 title == _L("CollectionPluginTest0129") ) |
|
736 { |
|
737 // Return exact copy |
|
738 CMPXMedia* media = CMPXMedia::NewL(); |
|
739 (*media) = aCriteria; |
|
740 CleanupStack::PushL( media ); |
|
741 media->SetTObjectValueL<TInt>(KMPXMediaGeneralSize, aAttrs.Count()); |
|
742 iObs->HandleFindAll(media, KErrNone); |
|
743 CleanupStack::PopAndDestroy( media ); |
|
744 } |
|
745 else if(title == _L("CollectionPluginTest0130") ) |
|
746 { |
|
747 // Return error |
|
748 CMPXMedia* media = CMPXMedia::NewL(); |
|
749 (*media) = aCriteria; |
|
750 CleanupStack::PushL( media ); |
|
751 media->SetTObjectValueL<TInt>(KMPXMediaGeneralSize, aAttrs.Count()); |
|
752 iObs->HandleFindAll(media, KErrArgument); |
|
753 CleanupStack::PopAndDestroy( media ); |
|
754 } |
|
755 else |
|
756 { |
|
757 User::Panic(_L("CTestCollectionPlugin::FindAllL panic"), 1); // magic number |
|
758 } |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------------------------------------------------------- |
|
762 // Find the items matching the media specifications |
|
763 // ---------------------------------------------------------------------------------------------------------- |
|
764 // |
|
765 CMPXMedia* CTestCollectionPlugin::FindAllSyncL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs) |
|
766 { |
|
767 LOG1(_L("CTestCollectionPlugin::FindAllSyncL")); |
|
768 const TDesC& title = aCriteria.ValueText( KMPXMediaGeneralTitle ); |
|
769 CMPXMedia* media = NULL; |
|
770 if(title == _L("CollectionPluginTest0138") || |
|
771 title == _L("CollectionPluginTest0139")) |
|
772 { |
|
773 // Return exact copy |
|
774 media = CMPXMedia::NewL(); |
|
775 CleanupStack::PushL( media ); |
|
776 (*media) = aCriteria; |
|
777 media->SetTObjectValueL<TInt>(KMPXMediaGeneralSize, aAttrs.Count()); |
|
778 CleanupStack::Pop( media ); |
|
779 } |
|
780 else if(title == _L("CollectionPluginTest0140") ) |
|
781 { |
|
782 media = NULL; |
|
783 } |
|
784 else |
|
785 { |
|
786 User::Panic(_L("CTestCollectionPlugin::FindAllL panic"), 1); // magic number |
|
787 } |
|
788 return media; |
|
789 } |
|
790 |
|
791 // ---------------------------------------------------------------------------------------------------------- |
|
792 // Get the list of supported capabilities |
|
793 // ---------------------------------------------------------------------------------------------------------- |
|
794 // |
|
795 TCollectionCapability CTestCollectionPlugin::GetCapabilities() |
|
796 { |
|
797 LOG1(_L("CTestCollectionPlugin::GetCapabilities - EMcNotModifiable")); |
|
798 return EMcNotModifiable; |
|
799 } |
|
800 |
|
801 // ---------------------------------------------------------------------------------------------------------- |
|
802 // Add specify attribute to Media |
|
803 // ---------------------------------------------------------------------------------------------------------- |
|
804 // |
|
805 void CTestCollectionPlugin::AddMediaL(CMPXMediaArray& aMediaArray, |
|
806 const RArray<TInt> aIdArray, |
|
807 const TArray<TMPXAttribute>& aAttrs) |
|
808 { |
|
809 TInt idCnt = aIdArray.Count(); |
|
810 for(TInt i = 0; i < idCnt; i++) |
|
811 { |
|
812 CMPXMedia* media = CMPXMedia::NewL(); |
|
813 CleanupStack::PushL( media ); |
|
814 switch( aIdArray[i] ) |
|
815 { |
|
816 case 11: |
|
817 AddAttrbuteL(*media, 11, _L("level11"), KNullDesC, aAttrs); |
|
818 break; |
|
819 case 12: |
|
820 AddAttrbuteL(*media, 12, _L("level12"), KNullDesC, aAttrs); |
|
821 break; |
|
822 case 13: |
|
823 AddAttrbuteL(*media, 13, _L("level13"), KNullDesC, aAttrs); |
|
824 break; |
|
825 case 211: |
|
826 AddAttrbuteL(*media, 211, _L("level211"), KNullDesC, aAttrs); |
|
827 break; |
|
828 case 212: |
|
829 AddAttrbuteL(*media, 212, _L("level212"), KNullDesC, aAttrs); |
|
830 break; |
|
831 case 213: |
|
832 AddAttrbuteL(*media, 213, _L("level213"), KNullDesC, aAttrs); |
|
833 break; |
|
834 case 221: |
|
835 AddAttrbuteL(*media, 221, _L("level221"), KNullDesC, aAttrs); |
|
836 break; |
|
837 case 231: |
|
838 AddAttrbuteL(*media, 231, _L("level231"), KNullDesC, aAttrs); |
|
839 break; |
|
840 case 232: |
|
841 AddAttrbuteL(*media, 232, _L("level232"), KNullDesC, aAttrs); |
|
842 break; |
|
843 case 3111: |
|
844 AddAttrbuteL(*media, 3111, _L("song3111"), _L("\\song3111.ts"), aAttrs); |
|
845 break; |
|
846 case 3121: |
|
847 AddAttrbuteL(*media, 3121, _L("song3121"), _L("\\song3121.ts"), aAttrs); |
|
848 break; |
|
849 case 3131: |
|
850 AddAttrbuteL(*media, 3131, _L("playlist3131"), _L("\\playlist3131.tp"), aAttrs); |
|
851 break; |
|
852 case 3311: |
|
853 AddAttrbuteL(*media, 3311, _L("song3311"), _L("\\song3311.ts"), aAttrs); |
|
854 break; |
|
855 case 3321: |
|
856 AddAttrbuteL(*media, 3321, _L("playlist3321"), _L("\\playlist3321.tp"), aAttrs); |
|
857 break; |
|
858 case 990: |
|
859 AddAttrbuteL(*media, 990, _L("level990"), KNullDesC, aAttrs); |
|
860 break; |
|
861 case 9901: |
|
862 AddAttrbuteL(*media, 9901, _L("song9901"), _L("\\song9901.ts"), aAttrs); |
|
863 AddAttributePlaybackFwTestL(*media, 9901, aAttrs); |
|
864 break; |
|
865 case 9902: |
|
866 AddAttrbuteL(*media, 9902, _L("song9902"), _L("\\song9902.ts"), aAttrs); |
|
867 AddAttributePlaybackFwTestL(*media, 9902, aAttrs); |
|
868 break; |
|
869 case 9903: |
|
870 AddAttrbuteL(*media, 9903, _L("song9903"), _L("\\song9903.ts"), aAttrs); |
|
871 AddAttributePlaybackFwTestL(*media, 9903, aAttrs); |
|
872 break; |
|
873 case 9904: |
|
874 AddAttrbuteL(*media, 9904, _L("song9904"), _L("\\song9904.ts"), aAttrs); |
|
875 AddAttributePlaybackFwTestL(*media, 9904, aAttrs); |
|
876 break; |
|
877 case 9905: |
|
878 AddAttrbuteL(*media, 9905, _L("song9905"), _L("\\song9905.ts"), aAttrs); |
|
879 AddAttributePlaybackFwTestL(*media, 9905, aAttrs); |
|
880 break; |
|
881 case 9906: |
|
882 AddAttrbuteL(*media, 9906, _L("song9906"), _L("\\song9906.ts"), aAttrs); |
|
883 AddAttributePlaybackFwTestL(*media, 9906, aAttrs); |
|
884 break; |
|
885 case 9907: |
|
886 AddAttrbuteL(*media, 9907, _L("song9907"), _L("\\song9907.ts"), aAttrs); |
|
887 AddAttributePlaybackFwTestL(*media, 9907, aAttrs); |
|
888 break; |
|
889 }; |
|
890 aMediaArray.AppendL( media ); |
|
891 CleanupStack::Pop( media ); |
|
892 } |
|
893 } |
|
894 |
|
895 |
|
896 // ---------------------------------------------------------------------------------------------------------- |
|
897 // Add specify attribute to Media |
|
898 // ---------------------------------------------------------------------------------------------------------- |
|
899 // |
|
900 void CTestCollectionPlugin::AddAttrbuteL(CMPXMedia& aMedia, |
|
901 const TInt aId, |
|
902 const TDesC& aTitle, |
|
903 const TDesC& aUri, |
|
904 const TArray<TMPXAttribute>& aAttrs) |
|
905 { |
|
906 TInt attrCnt = aAttrs.Count(); |
|
907 for(TInt i = 0; i < attrCnt; i++) |
|
908 { |
|
909 if(aAttrs[i].ContentId() == KMPXMediaIdGeneral) |
|
910 { |
|
911 TInt attrId = aAttrs[i].AttributeId(); |
|
912 if(attrId & EMPXMediaGeneralId) |
|
913 { |
|
914 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aId); |
|
915 } |
|
916 if(attrId & EMPXMediaGeneralTitle) |
|
917 { |
|
918 aMedia.SetTextValueL(KMPXMediaGeneralTitle, aTitle); |
|
919 |
|
920 } |
|
921 if(attrId & EMPXMediaGeneralUri) |
|
922 { |
|
923 aMedia.SetTextValueL(KMPXMediaGeneralUri, aUri); |
|
924 } |
|
925 } |
|
926 } |
|
927 } |
|
928 |
|
929 // ---------------------------------------------------------------------------------------------------------- |
|
930 // Add specify attribute to Media specific for Playback framework |
|
931 // test cases |
|
932 // ---------------------------------------------------------------------------------------------------------- |
|
933 // |
|
934 void CTestCollectionPlugin::AddAttributePlaybackFwTestL(CMPXMedia& aMedia, |
|
935 const TInt aId, |
|
936 const TArray<TMPXAttribute>& aAttrs) |
|
937 { |
|
938 TInt attrCnt = aAttrs.Count(); |
|
939 for(TInt i = 0; i < attrCnt; i++) |
|
940 { |
|
941 TInt attrId = aAttrs[i].AttributeId(); |
|
942 if(aAttrs[i].ContentId() == KMPXMediaIdGeneral) |
|
943 { |
|
944 if(attrId & EMPXMediaGeneralType) |
|
945 { |
|
946 AddAttributeGeneralTypeL(aMedia, aId); |
|
947 } |
|
948 if(attrId & EMPXMediaGeneralCategory) |
|
949 { |
|
950 AddAttributeGeneralCategoryL(aMedia, aId); |
|
951 } |
|
952 if(attrId & EMPXMediaGeneralDuration) |
|
953 { |
|
954 AddAttributeGeneralDurationL(aMedia, aId); |
|
955 } |
|
956 if(attrId & EMPXMediaGeneralLastPlaybackPosition) |
|
957 { |
|
958 AddAttributeGeneralLastPlaybackPositionL(aMedia, aId); |
|
959 } |
|
960 } |
|
961 else if(aAttrs[i].ContentId() == KMPXMediaIdMusic) |
|
962 { |
|
963 if(attrId & EMPXMediaMusicArtist) |
|
964 { |
|
965 AddAttributeMusicArtistL(aMedia, aId); |
|
966 } |
|
967 } |
|
968 else if(aAttrs[i].ContentId() == KMPXMediaIdDrm) |
|
969 { |
|
970 if(attrId & EMPXMediaDrmType) |
|
971 { |
|
972 AddAttributeDrmTypeL(aMedia, aId); |
|
973 } |
|
974 if(attrId & EMPXMediaDrmProtected) |
|
975 { |
|
976 AddAttributeDrmProtectedL(aMedia, aId); |
|
977 } |
|
978 if(attrId & EMPXMediaDrmRightsStatus) |
|
979 { |
|
980 AddAttributeDrmRightsStatusL(aMedia, aId); |
|
981 } |
|
982 } |
|
983 } |
|
984 } |
|
985 |
|
986 // ---------------------------------------------------------------------------------------------------------- |
|
987 // Filter out media in aMediaArray which match aFilter |
|
988 // ---------------------------------------------------------------------------------------------------------- |
|
989 // |
|
990 void CTestCollectionPlugin::FilterMediaArray(CMPXMediaArray& aMediaArray, CMPXFilter* aFilter) |
|
991 { |
|
992 if(aFilter ) |
|
993 { |
|
994 TArray<TMPXAttribute> filterAttr = aFilter->Attributes(); |
|
995 TInt arrCnt = aMediaArray.Count(); |
|
996 for(TInt i = arrCnt-1; i >= 0; i--) // Remove from the back |
|
997 { |
|
998 CMPXMedia* media = aMediaArray[i]; |
|
999 for(TInt ii = 0; ii < filterAttr.Count(); ii++) |
|
1000 { |
|
1001 TMPXAttribute attr = filterAttr[ii]; |
|
1002 if( media->IsSupported( attr ) ) |
|
1003 { |
|
1004 TBool match = EFalse; |
|
1005 if(attr == KMPXMediaGeneralId) |
|
1006 { |
|
1007 TInt filterId = *aFilter->Value<TInt>( attr ); |
|
1008 TInt mediaId = *media->Value<TInt>( attr ); |
|
1009 if(filterId == mediaId) |
|
1010 match = ETrue; |
|
1011 } |
|
1012 else if(attr == KMPXMediaGeneralTitle || attr == KMPXMediaGeneralUri) |
|
1013 { |
|
1014 const TDesC& filterText = aFilter->ValueText( attr ); |
|
1015 const TDesC& mediaText = media->ValueText( attr ); |
|
1016 if(filterText == mediaText) |
|
1017 match = ETrue; |
|
1018 } |
|
1019 if( match ) |
|
1020 { |
|
1021 aMediaArray.Remove( i ); |
|
1022 break; |
|
1023 } |
|
1024 } |
|
1025 } |
|
1026 } |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 // ---------------------------------------------------------------------------------------------------------- |
|
1031 // Fill up media with change message |
|
1032 // ---------------------------------------------------------------------------------------------------------- |
|
1033 // |
|
1034 void CTestCollectionPlugin::FillItemChangeMessageL(CMPXMessage& aMessage, |
|
1035 TMPXItemId aId, |
|
1036 TMPXChangeEventType aChangeType, |
|
1037 TMPXGeneralCategory aCategory) |
|
1038 { |
|
1039 LOG1( _L("Preparing HandleMessage callback") ); |
|
1040 aMessage.SetTObjectValueL<TMPXMessageId>( |
|
1041 TMPXAttribute(KMPXMessageContentIdGeneral, EMPXMessageGeneralId), KMPXMessageIdItemChanged); |
|
1042 |
|
1043 aMessage.SetTObjectValueL<TUid>( |
|
1044 TMPXAttribute(KMPXMessageIdItemChanged, EMPXMessageCollectionId), TUid::Uid(KCollectionTestPluginImpId)); |
|
1045 |
|
1046 aMessage.SetTObjectValueL<TMPXChangeEventType>( |
|
1047 TMPXAttribute(KMPXMessageIdItemChanged, EMPXMessageChangeEventType), aChangeType); |
|
1048 |
|
1049 aMessage.SetTObjectValueL<TMPXGeneralCategory>( |
|
1050 TMPXAttribute(KMPXMessageIdItemChanged, EMPXMessageMediaGeneralCategory), aCategory); |
|
1051 |
|
1052 aMessage.SetTObjectValueL<TMPXItemId>( |
|
1053 TMPXAttribute(KMPXMessageIdItemChanged, EMPXMessageMediaGeneralId), aId); |
|
1054 } |
|
1055 |
|
1056 |
|
1057 // ---------------------------------------------------------------------------------------------------------- |
|
1058 // Adding specific attribute |
|
1059 // ---------------------------------------------------------------------------------------------------------- |
|
1060 // |
|
1061 void CTestCollectionPlugin::AddAttributeGeneralTypeL(CMPXMedia& aMedia, const TInt aId) |
|
1062 { |
|
1063 switch( aId ) |
|
1064 { |
|
1065 case 9901: |
|
1066 case 9902: |
|
1067 case 9903: |
|
1068 case 9904: |
|
1069 case 9905: |
|
1070 case 9906: |
|
1071 case 9907: |
|
1072 aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem); |
|
1073 break; |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 // ---------------------------------------------------------------------------------------------------------- |
|
1078 // Adding specific attribute |
|
1079 // ---------------------------------------------------------------------------------------------------------- |
|
1080 // |
|
1081 void CTestCollectionPlugin::AddAttributeGeneralCategoryL(CMPXMedia& aMedia, const TInt aId) |
|
1082 { |
|
1083 switch( aId ) |
|
1084 { |
|
1085 case 9901: |
|
1086 case 9902: |
|
1087 case 9903: |
|
1088 case 9904: |
|
1089 case 9905: |
|
1090 case 9906: |
|
1091 case 9907: |
|
1092 aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong); |
|
1093 break; |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 // ---------------------------------------------------------------------------------------------------------- |
|
1098 // Adding specific attribute |
|
1099 // ---------------------------------------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CTestCollectionPlugin::AddAttributeGeneralDurationL(CMPXMedia& aMedia, const TInt aId) |
|
1102 { |
|
1103 switch( aId ) |
|
1104 { |
|
1105 case 9901: |
|
1106 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 0); // 0sec |
|
1107 break; |
|
1108 case 9902: |
|
1109 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 1000); // 1sec |
|
1110 break; |
|
1111 case 9903: |
|
1112 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 2000); // 2sec |
|
1113 break; |
|
1114 case 9904: |
|
1115 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 5000); // 5sec |
|
1116 break; |
|
1117 case 9905: |
|
1118 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 10000); // 10sec |
|
1119 break; |
|
1120 case 9906: |
|
1121 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 20000); // 20sec |
|
1122 break; |
|
1123 case 9907: |
|
1124 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 15000); // 15sec |
|
1125 break; |
|
1126 } |
|
1127 } |
|
1128 |
|
1129 // ---------------------------------------------------------------------------------------------------------- |
|
1130 // Adding specific attribute |
|
1131 // ---------------------------------------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CTestCollectionPlugin::AddAttributeGeneralLastPlaybackPositionL(CMPXMedia& aMedia, const TInt aId) |
|
1134 { |
|
1135 switch( aId ) |
|
1136 { |
|
1137 case 9901: |
|
1138 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 0); // 0sec |
|
1139 break; |
|
1140 case 9902: |
|
1141 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 0); // 0sec |
|
1142 break; |
|
1143 case 9903: |
|
1144 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 1000); // 1sec |
|
1145 break; |
|
1146 case 9904: |
|
1147 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 2500); // 2.5sec |
|
1148 break; |
|
1149 case 9905: |
|
1150 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 0); // 0sec |
|
1151 break; |
|
1152 case 9906: |
|
1153 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 0); // 0sec |
|
1154 break; |
|
1155 case 9907: |
|
1156 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralLastPlaybackPosition, 0); // 0sec |
|
1157 break; |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // ---------------------------------------------------------------------------------------------------------- |
|
1162 // Adding specific attribute |
|
1163 // ---------------------------------------------------------------------------------------------------------- |
|
1164 // |
|
1165 void CTestCollectionPlugin::AddAttributeMusicArtistL(CMPXMedia& aMedia, const TInt aId) |
|
1166 { |
|
1167 switch( aId ) |
|
1168 { |
|
1169 case 9901: |
|
1170 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9901")); |
|
1171 break; |
|
1172 case 9902: |
|
1173 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9902")); |
|
1174 break; |
|
1175 case 9903: |
|
1176 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9903")); |
|
1177 break; |
|
1178 case 9904: |
|
1179 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9904")); |
|
1180 break; |
|
1181 case 9905: |
|
1182 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9905")); |
|
1183 break; |
|
1184 case 9906: |
|
1185 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9906")); |
|
1186 break; |
|
1187 case 9907: |
|
1188 aMedia.SetTextValueL(KMPXMediaMusicArtist, _L("artist9907")); |
|
1189 break; |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 // ---------------------------------------------------------------------------------------------------------- |
|
1194 // Adding specific attribute |
|
1195 // ---------------------------------------------------------------------------------------------------------- |
|
1196 // |
|
1197 void CTestCollectionPlugin::AddAttributeDrmTypeL(CMPXMedia& aMedia, const TInt aId) |
|
1198 { |
|
1199 switch( aId ) |
|
1200 { |
|
1201 case 9901: |
|
1202 // Specify nothing |
|
1203 break; |
|
1204 case 9902: |
|
1205 // Specify nothing |
|
1206 break; |
|
1207 case 9903: |
|
1208 aMedia.SetTObjectValueL<TInt>(KMPXMediaDrmType, EMPXDrmTypeOMA); |
|
1209 break; |
|
1210 case 9904: |
|
1211 aMedia.SetTObjectValueL<TInt>(KMPXMediaDrmType, EMPXDrmTypeWMA); |
|
1212 break; |
|
1213 case 9905: |
|
1214 // Specify nothing |
|
1215 break; |
|
1216 case 9906: |
|
1217 // Specify nothing |
|
1218 break; |
|
1219 case 9907: |
|
1220 // Specify nothing |
|
1221 break; |
|
1222 } |
|
1223 } |
|
1224 |
|
1225 // ---------------------------------------------------------------------------------------------------------- |
|
1226 // Adding specific attribute |
|
1227 // ---------------------------------------------------------------------------------------------------------- |
|
1228 // |
|
1229 void CTestCollectionPlugin::AddAttributeDrmProtectedL(CMPXMedia& aMedia, const TInt aId) |
|
1230 { |
|
1231 switch( aId ) |
|
1232 { |
|
1233 case 9901: |
|
1234 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
1235 break; |
|
1236 case 9902: |
|
1237 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
1238 break; |
|
1239 case 9903: |
|
1240 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
1241 break; |
|
1242 case 9904: |
|
1243 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
1244 break; |
|
1245 case 9905: |
|
1246 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
1247 break; |
|
1248 case 9906: |
|
1249 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
1250 break; |
|
1251 case 9907: |
|
1252 aMedia.SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
1253 break; |
|
1254 } |
|
1255 } |
|
1256 |
|
1257 // ---------------------------------------------------------------------------------------------------------- |
|
1258 // Adding specific attribute |
|
1259 // ---------------------------------------------------------------------------------------------------------- |
|
1260 // |
|
1261 void CTestCollectionPlugin::AddAttributeDrmRightsStatusL(CMPXMedia& aMedia, const TInt aId) |
|
1262 { |
|
1263 switch( aId ) |
|
1264 { |
|
1265 case 9901: |
|
1266 // Specify nothing |
|
1267 break; |
|
1268 case 9902: |
|
1269 aMedia.SetTObjectValueL<TInt>(KMPXMediaDrmRightsStatus, EMPXDrmRightsFull); |
|
1270 break; |
|
1271 case 9903: |
|
1272 aMedia.SetTObjectValueL<TInt>(KMPXMediaDrmRightsStatus, EMPXDrmRightsExpired); |
|
1273 break; |
|
1274 case 9904: |
|
1275 aMedia.SetTObjectValueL<TInt>(KMPXMediaDrmRightsStatus, EMPXDrmRightsPreview); |
|
1276 break; |
|
1277 case 9905: |
|
1278 // Specify nothing |
|
1279 break; |
|
1280 case 9906: |
|
1281 // Specify nothing |
|
1282 break; |
|
1283 case 9907: |
|
1284 // Specify nothing |
|
1285 break; |
|
1286 } |
|
1287 } |
|
1288 |
|
1289 // End of file |