|
1 /* |
|
2 * Copyright (c) 2006 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 podcast collection DB Plugin interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32cmn.h> |
|
21 #include <PCRes.rsg> |
|
22 #include <bautils.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 |
|
25 #include <mpxpodcastdbplugin.mbg> |
|
26 #include <mpxcmn.h> |
|
27 #include <mpxcollectionpluginobserver.h> |
|
28 #include <mpxmediacontainerdefs.h> |
|
29 #include <mpxmediamusicdefs.h> |
|
30 #include <mpxmediaaudiodefs.h> |
|
31 #include <mpxmediacollectiondetaildefs.h> |
|
32 #include <mpxcommandgeneraldefs.h> |
|
33 #include <mpxmessagecontainerdefs.h> |
|
34 #include <mpxcollectioncommanddefs.h> |
|
35 #include <mpxmedia.h> |
|
36 #include <mpxmediaarray.h> |
|
37 #include <mpxdrmmediautility.h> |
|
38 #include <mpxmediadrmdefs.h> |
|
39 #include <mpxlog.h> |
|
40 #ifdef RD_MULTIPLE_DRIVE |
|
41 #include <driveinfo.h> |
|
42 #endif //RD_MULTIPLE_DRIVE |
|
43 |
|
44 #include "mpxdbcommondef.h" |
|
45 #include "mpxresource.h" |
|
46 #include "mpxdbcommonstd.h" |
|
47 #include "mpxdbcommonutil.h" |
|
48 |
|
49 #include "mpxpodcastcollectiondbstd.h" |
|
50 #include "mpxpodcastdbhandler.h" |
|
51 #include "mpxdbutil.h" |
|
52 #include "mpxpodcastcollectiondbdef.h" |
|
53 #include "mpxpodcastcollectiondb.hrh" |
|
54 #include "mpxpodcastdbplugin.h" |
|
55 |
|
56 // CONSTANTS |
|
57 _LIT(KMPlayerDbPluginMbmFile, "mpxpodcastdbplugin.mif"); |
|
58 const TInt KIncrementalDeleteCount = 400; |
|
59 |
|
60 // ============================ MEMBER FUNCTIONS ============================== |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // Two-phased constructor. |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 CMPXPodcastDbPlugin* CMPXPodcastDbPlugin::NewL( |
|
67 TAny* /* aInitParams */) |
|
68 { |
|
69 MPX_FUNC("CMPXPodcastDbPlugin::NewL"); |
|
70 |
|
71 CMPXPodcastDbPlugin* self = new (ELeave) CMPXPodcastDbPlugin(); |
|
72 CleanupStack::PushL(self); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // Destructor. |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 CMPXPodcastDbPlugin::~CMPXPodcastDbPlugin() |
|
83 { |
|
84 MPX_FUNC("CMPXPodcastDbPlugin::~CMPXPodcastDbPlugin"); |
|
85 |
|
86 iSelections.Reset(); |
|
87 iSelections.Close(); |
|
88 iFs.Close(); |
|
89 delete iDbHandler; |
|
90 delete iDrmMediaUtility; |
|
91 if (iResource) |
|
92 { |
|
93 iResource->Release(); |
|
94 } |
|
95 iPodcastLibraryMainMenuItemIds.Close(); |
|
96 delete iPodcastLibraryMainMenuItemTitles; |
|
97 delete iPodcastLibraryTitles; |
|
98 iPodcastPublishDateIds.Close(); |
|
99 delete iPodcastTitlePublishDateCat; |
|
100 iPodcastEpisodeViewPublishDateIds.Close(); |
|
101 delete iPodcastEpisodeViewPublishDateTitle; |
|
102 delete iTitleMyPodcast; |
|
103 delete iTitleAllEpisodes; |
|
104 delete iTitlePubDate; |
|
105 delete iTitleTitles; |
|
106 delete iTitleAdded; |
|
107 delete iTitleUnplayed; |
|
108 |
|
109 if (iActiveTask) |
|
110 { |
|
111 iActiveTask->Cancel(); |
|
112 delete iActiveTask; |
|
113 } |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 // Constructor. |
|
118 // ---------------------------------------------------------------------------- |
|
119 // |
|
120 CMPXPodcastDbPlugin::CMPXPodcastDbPlugin() |
|
121 { |
|
122 MPX_FUNC("CMPXPodcastDbPlugin::CMPXPodcastDbPlugin"); |
|
123 } |
|
124 |
|
125 // ---------------------------------------------------------------------------- |
|
126 // Symbian 2nd phase constructor can leave. |
|
127 // ---------------------------------------------------------------------------- |
|
128 // |
|
129 void CMPXPodcastDbPlugin::ConstructL () |
|
130 { |
|
131 MPX_FUNC("CMPXPodcastDbPlugin::ConstructL"); |
|
132 iFirstDeleteStep = ETrue; |
|
133 User::LeaveIfError(iFs.Connect()); |
|
134 iDrmMediaUtility = CMPXDrmMediaUtility::NewL(); |
|
135 |
|
136 TParse parse; |
|
137 parse.Set( KMPXCollectionDbResourceFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
138 TFileName resFile(parse.FullName()); |
|
139 User::LeaveIfError(MPXUser::CompleteWithDllPath(resFile)); |
|
140 BaflUtils::NearestLanguageFile(iFs, resFile); |
|
141 iResource = CMPXResource::NewL(resFile); |
|
142 |
|
143 iDbHandler = CMPXPodcastDbHandler::NewL(iFs, *iResource); |
|
144 |
|
145 iPodcastLibraryMainMenuItemTitles = iResource->ReadMenuArrayL(R_MC_MENU_ITEMS_ARRAY, |
|
146 iPodcastLibraryMainMenuItemIds); |
|
147 iPodcastTitlePublishDateCat = iResource->ReadMenuArrayL(R_MPX_QTN_NMP_PUBLISH_DATE_ARRAY, |
|
148 iPodcastPublishDateIds); |
|
149 iPodcastEpisodeViewPublishDateTitle = iResource->ReadMenuArrayL( |
|
150 R_MPX_QTN_NMP_EPISODES_TITLE_PUBLISHED_DATE_ARRAY, iPodcastEpisodeViewPublishDateIds); |
|
151 iTitleMyPodcast = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_MY_PODCAST); |
|
152 iTitleAllEpisodes = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_ALL_EPISODES); |
|
153 iTitlePubDate = iResource->ReadHBufCL(R_MPX_QTN_MUS_TITLE_PUBLISH_DATE); |
|
154 iTitleTitles = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_PODCASTS); |
|
155 iTitleAdded = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_RECENTLY_ADDED); |
|
156 iTitleUnplayed = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_UNPLAYED); |
|
157 iPodcastLibraryTitles = iResource->ReadMenuArrayL(R_MC_MENU_TITLES_ARRAY, |
|
158 iPodcastLibraryMainMenuItemIds); |
|
159 |
|
160 iActiveTask = CMPXDbActiveTask::NewL(*this); |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // Navigates to the given path |
|
165 // ---------------------------------------------------------------------------- |
|
166 // |
|
167 void CMPXPodcastDbPlugin::OpenL( |
|
168 const CMPXCollectionPath& aPath, |
|
169 const TArray<TMPXAttribute>& aAttrs, |
|
170 CMPXFilter* /*aFilter*/) |
|
171 { |
|
172 MPX_FUNC("CMPXPodcastDbPlugin::OpenL"); |
|
173 MPX_DEBUG_PATH (aPath); |
|
174 |
|
175 RArray<TMPXAttribute> openAttrs; |
|
176 CleanupClosePushL(openAttrs); |
|
177 |
|
178 RArray<TInt> supportedIds; |
|
179 CleanupClosePushL(supportedIds); |
|
180 |
|
181 SetAttributesL(aPath, openAttrs, supportedIds); |
|
182 |
|
183 CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array()); |
|
184 CleanupStack::PopAndDestroy(&supportedIds); |
|
185 CleanupStack::PushL(entries); |
|
186 |
|
187 TInt error(KErrNone); |
|
188 TBool isEpisode(EFalse); |
|
189 CMPXCollectionPath* newPath(NULL); |
|
190 |
|
191 TBool openingForPlayback(EFalse); |
|
192 |
|
193 if(aAttrs.Count() == 1 && |
|
194 aAttrs[0].ContentId() == KMPXMediaIdPodcast) |
|
195 { |
|
196 if(aAttrs[0].AttributeId() & EMPXMediaPodcastSetIsPlayingTrue) |
|
197 { |
|
198 openingForPlayback = ETrue; |
|
199 } |
|
200 } |
|
201 |
|
202 // Make sure we handle the correct open mode |
|
203 // |
|
204 TMPXOpenMode openmode = aPath.OpenNextMode(); |
|
205 switch (openmode) |
|
206 { |
|
207 case EMPXOpenGroupOrPlaylist: |
|
208 { |
|
209 MPX_TRAP(error, isEpisode = DoOpenL ( |
|
210 aPath, openAttrs.Array(), *entries, openingForPlayback)); |
|
211 break; |
|
212 } |
|
213 |
|
214 case EMPXOpenPlaylistOnly: |
|
215 { |
|
216 if( aPath.Count() > 0 ) |
|
217 { |
|
218 // Try to open |
|
219 MPX_TRAP(error, newPath = DoOpenPlaylistL(aPath, openAttrs.Array(), openingForPlayback)); |
|
220 CleanupStack::PushL(newPath); |
|
221 isEpisode = ETrue; |
|
222 } |
|
223 else // no items, so open in normal mode |
|
224 { |
|
225 MPX_TRAP(error, isEpisode = DoOpenL ( |
|
226 aPath, openAttrs.Array(), *entries, openingForPlayback)); |
|
227 } |
|
228 break; |
|
229 } |
|
230 default: |
|
231 // do nothing |
|
232 break; |
|
233 } |
|
234 |
|
235 if (isEpisode) |
|
236 { |
|
237 if (openmode == EMPXOpenGroupOrPlaylist) |
|
238 { |
|
239 iObs->HandleOpen(const_cast<CMPXCollectionPath*>(&aPath), error); |
|
240 } |
|
241 else // openmode == EMPXOpenPlaylistOnly |
|
242 { |
|
243 iObs->HandleOpen(newPath, error); |
|
244 } |
|
245 } |
|
246 else |
|
247 { |
|
248 MPX_DEBUG_PATH (aPath); |
|
249 |
|
250 entries->SetCObjectValueL(KMPXMediaGeneralContainerPath, |
|
251 const_cast<CMPXCollectionPath*>(&aPath)); |
|
252 iObs->HandleOpen(entries, error); |
|
253 } |
|
254 |
|
255 if (newPath) |
|
256 { |
|
257 CleanupStack::PopAndDestroy(newPath); |
|
258 } |
|
259 |
|
260 CleanupStack::PopAndDestroy(entries); |
|
261 CleanupStack::PopAndDestroy(&openAttrs); |
|
262 } |
|
263 |
|
264 // ---------------------------------------------------------------------------- |
|
265 // Get the extended properties of the current file (async) |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CMPXPodcastDbPlugin::MediaL( |
|
269 const CMPXCollectionPath& aPath, |
|
270 const TArray<TMPXAttribute>& aAttrs, |
|
271 const TArray<TCapability>& /*aCaps*/, |
|
272 CMPXAttributeSpecs* /*aSpecs*/) |
|
273 { |
|
274 MPX_FUNC("CMPXPodcastDbPlugin::MediaL"); |
|
275 MPX_DEBUG_PATH(aPath); |
|
276 |
|
277 RArray<TInt> supportedIds; |
|
278 CleanupClosePushL(supportedIds); |
|
279 if (aPath.Selection().Count()) |
|
280 { |
|
281 // it's a container if there are multiple selection, else it's not a container |
|
282 supportedIds.AppendL(KMPXMediaIdContainer); |
|
283 } |
|
284 MPXDbCommonUtil::FillInSupportedUIDsL (aAttrs, supportedIds); |
|
285 CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array()); |
|
286 CleanupStack::PopAndDestroy(&supportedIds); |
|
287 CleanupStack::PushL(entries); |
|
288 |
|
289 DoMediaL(aPath, aAttrs, *entries); |
|
290 |
|
291 // Also fetch collection details |
|
292 DoHandleOtherMediaAttributesL(aAttrs, aPath, *entries); |
|
293 |
|
294 iObs->HandleMedia(entries, KErrNone); |
|
295 CleanupStack::PopAndDestroy(entries); |
|
296 } |
|
297 |
|
298 // ---------------------------------------------------------------------------- |
|
299 // Cancel outstanding request |
|
300 // ---------------------------------------------------------------------------- |
|
301 // |
|
302 void CMPXPodcastDbPlugin::CancelRequest() |
|
303 { |
|
304 MPX_FUNC("CMPXPodcastDbPlugin::CancelRequest"); |
|
305 iActiveTask->Cancel(); |
|
306 } |
|
307 |
|
308 // ---------------------------------------------------------------------------- |
|
309 // Executes the given command on the collection |
|
310 // ---------------------------------------------------------------------------- |
|
311 // |
|
312 void CMPXPodcastDbPlugin::CommandL( |
|
313 TMPXCollectionCommand aCmd, |
|
314 TInt aArg /* = 0 */) |
|
315 { |
|
316 MPX_FUNC("CMPXPodcastDbPlugin::CommandL"); |
|
317 |
|
318 switch (aCmd) |
|
319 { |
|
320 case EMcCmdRemoveAll: |
|
321 { |
|
322 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcCmdRemoveAll"); |
|
323 // Remove EVERYthing from the collection |
|
324 iDbHandler->RemoveEntireCollectionL(); |
|
325 break; |
|
326 } |
|
327 case EMcCmdClose: |
|
328 case EMcCloseCollection: |
|
329 { |
|
330 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcCloseCollection"); |
|
331 // Close the specified database |
|
332 #ifdef RD_MULTIPLE_DRIVE |
|
333 MPX_DEBUG1("Multiple drives closing databases"); |
|
334 if ( aArg <0) |
|
335 { |
|
336 DriveInfo::TDriveArray driveArray; |
|
337 User::LeaveIfError ( DriveInfo::GetUserVisibleDrives ( iFs, driveArray)); |
|
338 TInt count( driveArray.Count ()); |
|
339 for (TInt i=0; i<count; ++i) |
|
340 { |
|
341 MPX_DEBUG2("At drive %i", driveArray[i]); |
|
342 if ((driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
|
343 { |
|
344 MPX_DEBUG2("Closing database %i", driveArray[i]); |
|
345 TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) ); |
|
346 } |
|
347 } |
|
348 } |
|
349 else |
|
350 { |
|
351 iDbHandler->CloseDatabaseL (aArg); |
|
352 } |
|
353 #else |
|
354 iDbHandler->CloseDatabaseL(aArg); |
|
355 #endif // RD_MULTIPLE_DRIVE |
|
356 break; |
|
357 } |
|
358 case EMcReOpenCollection: |
|
359 { |
|
360 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcReOpenCollection"); |
|
361 // Open the specified database |
|
362 #ifdef RD_MULTIPLE_DRIVE |
|
363 MPX_DEBUG1("Multiple drives opening databases"); |
|
364 DriveInfo::TDriveArray driveArray; |
|
365 User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) ); |
|
366 TInt count( driveArray.Count() ); |
|
367 for( TInt i=0; i<count; ++i ) |
|
368 { |
|
369 MPX_DEBUG2("At drive %i", driveArray[i]); |
|
370 if (( driveArray[i] != EDriveC ) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
|
371 { |
|
372 TUint driveStatus(0); |
|
373 User::LeaveIfError( DriveInfo::GetDriveStatus( |
|
374 iFs, driveArray[i], driveStatus ) ); |
|
375 if( driveStatus & DriveInfo::EDrivePresent ) |
|
376 { |
|
377 MPX_DEBUG2("Opening database %i", driveArray[i]); |
|
378 TRAP_IGNORE( iDbHandler->OpenDatabaseL( driveArray[i] ) ); |
|
379 } |
|
380 } |
|
381 } |
|
382 #else |
|
383 iDbHandler->OpenDatabaseL(aArg); |
|
384 #endif // RD_MULTIPLE_DRIVE |
|
385 break; |
|
386 } |
|
387 case EMcRefreshStarted: |
|
388 { |
|
389 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcRefreshStarted"); |
|
390 iDbHandler->RefreshStartL(); |
|
391 iRefreshing = ETrue; |
|
392 break; |
|
393 } |
|
394 case EMcRefreshEnded: |
|
395 { |
|
396 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcRefreshEnded"); |
|
397 // ask the handler to finalize the transaction |
|
398 iDbHandler->RefreshEndL(); |
|
399 iRefreshing = EFalse; |
|
400 break; |
|
401 } |
|
402 case EMcCmdReCreateDB: |
|
403 { |
|
404 // Recreate all databases |
|
405 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcCmdReCreateDB"); |
|
406 iDbHandler->ReCreateDatabasesL(); |
|
407 break; |
|
408 } |
|
409 case EMcCmdDbCorrupted: |
|
410 { |
|
411 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - EMcCmdDbCorrupted"); |
|
412 iDbHandler->SetDBCorruptedL(ETrue); |
|
413 break; |
|
414 } |
|
415 case EMcCmdCollectionInit: |
|
416 case EMcCmdRefresh: |
|
417 case EMcCmdCollectionResyn: |
|
418 { |
|
419 // deprecated |
|
420 break; |
|
421 } |
|
422 case EMcCmdMtpStart: |
|
423 iMtpInUse = ETrue; |
|
424 break; |
|
425 case EMcCmdMtpEnd: |
|
426 iMtpInUse = EFalse; |
|
427 break; |
|
428 default: |
|
429 { |
|
430 User::Leave(KErrNotSupported); |
|
431 } |
|
432 } |
|
433 } |
|
434 |
|
435 // ---------------------------------------------------------------------------- |
|
436 // Executes the given command on the collection |
|
437 // ---------------------------------------------------------------------------- |
|
438 // |
|
439 void CMPXPodcastDbPlugin::CommandL( |
|
440 CMPXCommand& aCmd) |
|
441 { |
|
442 MPX_FUNC("CMPXPodcastDbPlugin::CommandL"); |
|
443 |
|
444 if (!aCmd.IsSupported(KMPXCommandGeneralId)) |
|
445 { |
|
446 User::Leave(KErrArgument); |
|
447 } |
|
448 |
|
449 TMPXCommandId commandId = aCmd.ValueTObjectL<TMPXCommandId>(KMPXCommandGeneralId); |
|
450 |
|
451 TBool syncOp(EFalse); |
|
452 if( aCmd.IsSupported(KMPXCommandGeneralDoSync) ) |
|
453 { |
|
454 syncOp = aCmd.ValueTObjectL<TBool>(KMPXCommandGeneralDoSync); |
|
455 } |
|
456 |
|
457 // Handle this operation synchronously or asynchronously |
|
458 if( !syncOp ) |
|
459 { |
|
460 iActiveTask->StartL(commandId, aCmd); |
|
461 } |
|
462 else // Sync operation |
|
463 { |
|
464 switch (commandId) |
|
465 { |
|
466 case KMPXCommandIdCollectionRetrieveUriForDeletion: |
|
467 { |
|
468 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionRetrieveUriForDeletion"); |
|
469 DoRetrieveUriForDeletionL(aCmd); |
|
470 break; |
|
471 } |
|
472 case KMPXCommandIdCollectionRemove: |
|
473 { |
|
474 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionRemove"); |
|
475 if (iFirstDeleteStep ) |
|
476 { |
|
477 iFirstDeleteStep = EFalse; |
|
478 } |
|
479 DoRemovePathL(aCmd); |
|
480 break; |
|
481 } |
|
482 case KMPXCommandIdCollectionRemoveMedia: |
|
483 { |
|
484 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionRemoveMedia"); |
|
485 DoRemoveMediaL(aCmd); |
|
486 break; |
|
487 } |
|
488 case KMPXCommandIdCollectionCleanupDeletedMedias: |
|
489 { |
|
490 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionCleanupDeletedMedias"); |
|
491 CleanupDeletedRecordsL(aCmd); |
|
492 break; |
|
493 } |
|
494 case KMPXCommandIdCollectionAdd: |
|
495 { |
|
496 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectioAdd"); |
|
497 CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColAddMedia); |
|
498 User::LeaveIfNull( media ); |
|
499 TInt id = DoAddL(*media); |
|
500 aCmd.SetTObjectValueL<TMPXItemId>(KMPXCommandColAddRtnId, id); |
|
501 break; |
|
502 } |
|
503 case KMPXCommandIdCollectionSet: |
|
504 { |
|
505 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionSet"); |
|
506 CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColSetMedia); |
|
507 User::LeaveIfNull( media ); |
|
508 DoSetL(*media); |
|
509 break; |
|
510 } |
|
511 case KMPXCommandIdCollectionCompleteDelete: |
|
512 { |
|
513 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdCollectionCompleteDelete"); |
|
514 DoHandleDeleteCompleteL(aCmd); |
|
515 break; |
|
516 } |
|
517 case KMPXCommandIdUpdateRefreshTime: |
|
518 { |
|
519 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime"); |
|
520 TTime curTime; |
|
521 curTime.HomeTime(); |
|
522 iDbHandler->SetLastRefreshedTimeL(curTime); |
|
523 break; |
|
524 } |
|
525 case KMPXCommandCollectionGetCount: |
|
526 { |
|
527 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandCollectionGetCount"); |
|
528 DoGetCollectionCountL(aCmd); |
|
529 break; |
|
530 } |
|
531 case KMPXCommandCollectionGetURIs: |
|
532 { |
|
533 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandCollectionGetURIs"); |
|
534 DoGetCollectionUriL(aCmd); |
|
535 break; |
|
536 } |
|
537 default: |
|
538 { |
|
539 User::Leave(KErrNotSupported); |
|
540 } |
|
541 } |
|
542 } |
|
543 } |
|
544 |
|
545 // ---------------------------------------------------------------------------- |
|
546 // Adds a podcast to the collection |
|
547 // ---------------------------------------------------------------------------- |
|
548 // |
|
549 void CMPXPodcastDbPlugin::AddL( |
|
550 const CMPXMedia& aMedia) |
|
551 { |
|
552 MPX_FUNC("CMPXPodcastDbPlugin::AddL"); |
|
553 DoAddL(aMedia); |
|
554 } |
|
555 |
|
556 // ---------------------------------------------------------------------------- |
|
557 // Remove an item from the collection database using the given path |
|
558 // ---------------------------------------------------------------------------- |
|
559 // |
|
560 void CMPXPodcastDbPlugin::RemoveL( |
|
561 const CMPXCollectionPath& aPath) |
|
562 { |
|
563 MPX_FUNC("CMPXPodcastDbPlugin::RemoveL(by path)"); |
|
564 MPX_DEBUG_PATH(aPath); |
|
565 |
|
566 CMPXMessageArray* msgAry = CMPXMessageArray::NewL(); |
|
567 CleanupStack::PushL( msgAry ); |
|
568 |
|
569 // Return file path for deleted item(s) |
|
570 CDesCArray* fp = DoRemoveL(aPath,*msgAry); |
|
571 |
|
572 iObs->HandleRemove(*fp, KErrNone); |
|
573 delete fp; |
|
574 |
|
575 // Send Change Messages |
|
576 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
577 DoHandleChangeL(msgAry); |
|
578 CleanupStack::PopAndDestroy( msgAry ); |
|
579 } |
|
580 |
|
581 // ---------------------------------------------------------------------------- |
|
582 // Remove an item from the collection database using the given media properties |
|
583 // ---------------------------------------------------------------------------- |
|
584 // |
|
585 void CMPXPodcastDbPlugin::RemoveL( |
|
586 const CMPXMedia& aMedia) |
|
587 { |
|
588 MPX_FUNC("CMPXPodcastDbPlugin::RemoveL(by media)"); |
|
589 DoRemoveL(aMedia, EFalse); |
|
590 } |
|
591 |
|
592 // ---------------------------------------------------------------------------- |
|
593 // Sets/updates the media for an item in the collection |
|
594 // DEPRECATED for week 18 |
|
595 // ---------------------------------------------------------------------------- |
|
596 // |
|
597 void CMPXPodcastDbPlugin::SetL( |
|
598 const CMPXMedia& aMedia) |
|
599 { |
|
600 MPX_FUNC("CMPXPodcastDbPlugin::SetL"); |
|
601 DoSetL(aMedia); |
|
602 } |
|
603 |
|
604 // ---------------------------------------------------------------------------- |
|
605 // Find the items matching the media specifications |
|
606 // ---------------------------------------------------------------------------- |
|
607 // |
|
608 void CMPXPodcastDbPlugin::FindAllL( |
|
609 const CMPXMedia& aCriteria, |
|
610 const TArray<TMPXAttribute>& aAttrs) |
|
611 { |
|
612 MPX_FUNC("CMPXPodcastDbPlugin::FindAllL"); |
|
613 |
|
614 CMPXMedia* entries = FindAllSyncL(aCriteria, aAttrs); |
|
615 |
|
616 // notify client. if FindAllL leaves, framework will notify client of the error |
|
617 iObs->HandleFindAll(entries, KErrNone); |
|
618 delete entries; |
|
619 } |
|
620 |
|
621 // ---------------------------------------------------------------------------- |
|
622 // Find the items matching the media specifications |
|
623 // ---------------------------------------------------------------------------- |
|
624 // |
|
625 CMPXMedia* CMPXPodcastDbPlugin::FindAllSyncL( |
|
626 const CMPXMedia& aCriteria, |
|
627 const TArray<TMPXAttribute>& aAttrs) |
|
628 { |
|
629 MPX_FUNC("CMPXPodcastDbPlugin::FindAllSyncL"); |
|
630 |
|
631 CMPXMedia* entries = iDbHandler->FindAllLC(aCriteria, aAttrs); |
|
632 CleanupStack::Pop(entries); |
|
633 |
|
634 return entries; |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // Get the list of supported capabilities |
|
639 // ---------------------------------------------------------------------------- |
|
640 // |
|
641 TCollectionCapability CMPXPodcastDbPlugin::GetCapabilities() |
|
642 { |
|
643 // This one supports simple search |
|
644 return EMcSearch; |
|
645 } |
|
646 |
|
647 // ---------------------------------------------------------------------------- |
|
648 // Get the list of supported capabilities |
|
649 // ---------------------------------------------------------------------------- |
|
650 // |
|
651 TBool CMPXPodcastDbPlugin::HandleStepL() |
|
652 { |
|
653 MPX_FUNC("CMPXPodcastDbPlugin::HandleStepL"); |
|
654 |
|
655 TBool done(ETrue); |
|
656 |
|
657 switch (iActiveTask->GetTask()) |
|
658 { |
|
659 case KMPXCommandIdCollectionSet: |
|
660 { |
|
661 done = DoSetAsyncL(); |
|
662 break; |
|
663 } |
|
664 case KMPXCommandIdCollectionAdd: |
|
665 { |
|
666 done = DoAddAsyncL(); |
|
667 break; |
|
668 } |
|
669 case KMPXCommandIdCollectionRemove: |
|
670 { |
|
671 DoRemovePathL(iActiveTask->GetCommand()); |
|
672 done = ETrue; |
|
673 break; |
|
674 } |
|
675 case KMPXCommandIdCollectionRemoveMedia: |
|
676 { |
|
677 DoRemoveMediaL(iActiveTask->GetCommand()); |
|
678 done = ETrue; |
|
679 break; |
|
680 } |
|
681 case KMPXCommandIdCollectionRetrieveUriForDeletion: |
|
682 { |
|
683 DoRetrieveUriForDeletionL(iActiveTask->GetCommand()); |
|
684 done = ETrue; |
|
685 break; |
|
686 } |
|
687 case KMPXCommandIdCollectionCleanupDeletedMedias: |
|
688 { |
|
689 CleanupDeletedRecordsL(iActiveTask->GetCommand()); |
|
690 done = ETrue; |
|
691 break; |
|
692 } |
|
693 case KMPXCommandIdCollectionCompleteDelete: |
|
694 { |
|
695 DoHandleDeleteCompleteL( iActiveTask->GetCommand() ); |
|
696 break; |
|
697 } |
|
698 case KMPXCommandIdUpdateRefreshTime: |
|
699 { |
|
700 MPX_DEBUG1("CMPXPodcastDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime"); |
|
701 TTime curTime; |
|
702 curTime.HomeTime(); |
|
703 iDbHandler->SetLastRefreshedTimeL(curTime); |
|
704 break; |
|
705 } |
|
706 default: |
|
707 { |
|
708 // Should never happen! |
|
709 ASSERT(0); |
|
710 break; |
|
711 } |
|
712 } |
|
713 return done; |
|
714 } |
|
715 |
|
716 // ---------------------------------------------------------------------------- |
|
717 // Handler for async operations completed |
|
718 // ---------------------------------------------------------------------------- |
|
719 // |
|
720 void CMPXPodcastDbPlugin::HandleOperationCompleted( |
|
721 TInt aErr) |
|
722 { |
|
723 MPX_FUNC("CMPXPodcastDbPlugin::HandleOperationCompleted"); |
|
724 TRAP_IGNORE(DoHandleOperationCompletedL(aErr)); |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------------------------------- |
|
728 // Process the OpenL command |
|
729 // ---------------------------------------------------------------------------- |
|
730 // |
|
731 TBool CMPXPodcastDbPlugin::DoOpenL( |
|
732 const CMPXCollectionPath& aPath, |
|
733 const TArray<TMPXAttribute>& aAttrs, |
|
734 CMPXMedia& aEntries, |
|
735 TBool aFlagToSignalToBePlayed) |
|
736 { |
|
737 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenL"); |
|
738 |
|
739 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
740 CleanupStack::PushL(array); |
|
741 |
|
742 TInt count(0); |
|
743 TInt levels(aPath.Levels()); |
|
744 TBool isEpisode(EFalse); |
|
745 |
|
746 aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1)); |
|
747 |
|
748 if (1 == levels) |
|
749 { |
|
750 isEpisode = DoOpenBrowseTitleL(aPath, aAttrs, aEntries, *array); |
|
751 } |
|
752 else if (levels >= 2) |
|
753 { |
|
754 isEpisode = DoOpenBrowseTitleL(aPath, aAttrs, aEntries, *array); |
|
755 } |
|
756 else |
|
757 { |
|
758 User::Leave(KErrNotSupported); |
|
759 } |
|
760 |
|
761 if(isEpisode && |
|
762 aFlagToSignalToBePlayed) |
|
763 { |
|
764 // opening an episode to be played so set the IsPlaying flag to |
|
765 // prevent this episode from being picked up as Not Yet Played |
|
766 // (need to do this because setting last playback position causes |
|
767 // visible change and the playlist to update) |
|
768 if(array->Count() == 1) |
|
769 { |
|
770 // ignore the error because if there is a problem |
|
771 // updating the media file, the error will show up |
|
772 // when opening the track for playing and be handled |
|
773 // properly by the playback engine and skipped |
|
774 TRAP_IGNORE(iDbHandler->SetIsPlayingL(*((*array)[0]), ETrue)); |
|
775 } |
|
776 } |
|
777 |
|
778 aEntries.SetCObjectValueL(KMPXMediaArrayContents, array); |
|
779 aEntries.SetTObjectValueL(KMPXMediaArrayCount, array->Count()); |
|
780 |
|
781 CleanupStack::PopAndDestroy(array); |
|
782 |
|
783 return isEpisode; |
|
784 } |
|
785 |
|
786 // ---------------------------------------------------------------------------- |
|
787 // Handles OpenL called for EBrowseAll |
|
788 // ---------------------------------------------------------------------------- |
|
789 // |
|
790 TBool CMPXPodcastDbPlugin::DoOpenBrowseAllL( |
|
791 const CMPXCollectionPath& aPath, |
|
792 const TArray<TMPXAttribute>& aAttrs, |
|
793 CMPXMedia& aEntries, |
|
794 CMPXMediaArray& aArray) |
|
795 { |
|
796 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenBrowseAllL"); |
|
797 |
|
798 TInt levels(aPath.Levels()); |
|
799 switch (levels) |
|
800 { |
|
801 // All Episodes |
|
802 case 2: |
|
803 { |
|
804 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseAllL_All); |
|
805 |
|
806 iDbHandler->GetAllEpisodesL(aAttrs, aArray); |
|
807 SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPodcastGroup, EMPXAll, |
|
808 *iTitleAllEpisodes, aArray.Count()); |
|
809 |
|
810 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseAllL_All); |
|
811 break; |
|
812 } |
|
813 |
|
814 // An episode in all episodes |
|
815 case 3: |
|
816 { |
|
817 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseAllL_Episode); |
|
818 |
|
819 iDbHandler->GetEpisodeL(aPath.Id(levels - 1), aAttrs, aArray); |
|
820 |
|
821 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseAllL_Episode); |
|
822 break; |
|
823 } |
|
824 |
|
825 default: |
|
826 { |
|
827 MPX_DEBUG2("CMPXPodcastDbPlugin_DoOpenBrowseAllL: Invalid levels[%d]", levels); |
|
828 User::Leave(KErrNotSupported); |
|
829 } |
|
830 } |
|
831 |
|
832 return (levels == 3); |
|
833 } |
|
834 |
|
835 // ---------------------------------------------------------------------------- |
|
836 // Handles OpenL called for EBrowsePubDate |
|
837 // ---------------------------------------------------------------------------- |
|
838 // |
|
839 TBool CMPXPodcastDbPlugin::DoOpenBrowsePubDateL( |
|
840 const CMPXCollectionPath& aPath, |
|
841 const TArray<TMPXAttribute>& aAttrs, |
|
842 CMPXMedia& aEntries, |
|
843 CMPXMediaArray& aArray) |
|
844 { |
|
845 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenBrowsePubDateL"); |
|
846 |
|
847 TBool isEpisode(EFalse); |
|
848 TInt levels(aPath.Levels()); |
|
849 |
|
850 switch (levels) |
|
851 { |
|
852 // All By Publish Date Categories |
|
853 case 2: |
|
854 { |
|
855 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_All); |
|
856 |
|
857 TInt numEpisodes(iDbHandler->GetEpisodesMatchingPublishPlaylistL(KPublishAllPlaylistUID, aAttrs, |
|
858 EFalse, aArray)); |
|
859 SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPodcastGroup, EMPXPubDate, |
|
860 *iTitlePubDate); |
|
861 aEntries.SetTObjectValueL(KMPXMediaGeneralNonPermissibleActions, EMPXCache ); |
|
862 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_All); |
|
863 break; |
|
864 } |
|
865 // All episodes within a specific By Publish Date category |
|
866 case 3: |
|
867 { |
|
868 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_Playlist); |
|
869 iNumberOfEpisodesInCurrentPublishDateCategory = |
|
870 iDbHandler->GetEpisodesMatchingPublishPlaylistL( |
|
871 (aPath.Id(levels - 1).iId2 & 0x00FFFFFF) + KPublishTodayPlaylistUID, // offset by KPublishTodayPlaylistUID |
|
872 aAttrs, EFalse, aArray); |
|
873 |
|
874 SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPodcastItem, EMPXEpisode, |
|
875 iPodcastEpisodeViewPublishDateTitle->MdcaPoint(aPath.Id(levels - 1).iId2 & 0x00FFFFFF), |
|
876 iNumberOfEpisodesInCurrentPublishDateCategory); |
|
877 |
|
878 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_Playlist); |
|
879 break; |
|
880 } |
|
881 // An episode |
|
882 case 4: |
|
883 { |
|
884 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_Episode); |
|
885 |
|
886 iDbHandler->GetEpisodeL(aPath.Id(levels - 1), aAttrs, aArray); |
|
887 isEpisode = ETrue; |
|
888 |
|
889 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowsePubDateL_Episode); |
|
890 break; |
|
891 } |
|
892 default: |
|
893 { |
|
894 MPX_DEBUG2("CMPXPodcastDbPlugin_DoOpenBrowsePubDateL: Invalid levels[%d]", levels); |
|
895 User::Leave(KErrNotSupported); |
|
896 } |
|
897 } |
|
898 return isEpisode; |
|
899 } |
|
900 |
|
901 // ---------------------------------------------------------------------------- |
|
902 // Handles OpenL called for EBrowseTitle |
|
903 // ---------------------------------------------------------------------------- |
|
904 // |
|
905 TBool CMPXPodcastDbPlugin::DoOpenBrowseTitleL( |
|
906 const CMPXCollectionPath& aPath, |
|
907 const TArray<TMPXAttribute>& aAttrs, |
|
908 CMPXMedia& aEntries, |
|
909 CMPXMediaArray& aArray) |
|
910 { |
|
911 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenBrowseTitleL"); |
|
912 |
|
913 TBool isEpisode(EFalse); |
|
914 TInt levels(aPath.Levels()); |
|
915 |
|
916 switch (levels) |
|
917 { |
|
918 // All Titles |
|
919 case 1: |
|
920 { |
|
921 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_All); |
|
922 |
|
923 iDbHandler->GetAllPodcastTitlesL(aAttrs, aArray); |
|
924 |
|
925 SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPodcastGroup, EMPXTitle, |
|
926 *iTitleTitles); |
|
927 |
|
928 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_All); |
|
929 break; |
|
930 } |
|
931 // All episodes in a title |
|
932 case 2: |
|
933 { |
|
934 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_Title); |
|
935 |
|
936 iDbHandler->GetEpisodesMatchingTitleL(aPath.Id(levels - 1).iId2, |
|
937 aAttrs, aArray); |
|
938 |
|
939 HBufC* title = iDbHandler->GetTitleNameMatchingIdL(aPath.Id(levels - 1)); |
|
940 CleanupStack::PushL(title); |
|
941 SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPodcastItem, EMPXEpisode, |
|
942 *title, aArray.Count()); |
|
943 CleanupStack::PopAndDestroy(title); |
|
944 |
|
945 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_Title); |
|
946 break; |
|
947 } |
|
948 // An episode within a title |
|
949 case 3: |
|
950 { |
|
951 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_Episode); |
|
952 iDbHandler->GetEpisodeL(aPath.Id(levels - 1), aAttrs, aArray); |
|
953 isEpisode = ETrue; |
|
954 |
|
955 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseTitleL_Episode); |
|
956 break; |
|
957 } |
|
958 |
|
959 default: |
|
960 { |
|
961 MPX_DEBUG2("CMPXPodcastDbPlugin_DoOpenBrowseTitleL: Invalid levels[%d]", levels); |
|
962 User::Leave(KErrNotSupported); |
|
963 } |
|
964 } |
|
965 |
|
966 return isEpisode; |
|
967 } |
|
968 |
|
969 // ---------------------------------------------------------------------------- |
|
970 // Handles OpenL called for EBrowseRecentlyAdded |
|
971 // ---------------------------------------------------------------------------- |
|
972 // |
|
973 TBool CMPXPodcastDbPlugin::DoOpenBrowseRecentlyAddedL( |
|
974 const CMPXCollectionPath& aPath, |
|
975 const TArray<TMPXAttribute>& aAttrs, |
|
976 CMPXMedia& aEntries, |
|
977 CMPXMediaArray& aArray) |
|
978 { |
|
979 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenBrowseRecentlyAddedL"); |
|
980 |
|
981 TBool isEpisode(EFalse); |
|
982 TInt levels(aPath.Levels()); |
|
983 |
|
984 switch (levels) |
|
985 { |
|
986 case 2: |
|
987 { |
|
988 // All recently added episodes |
|
989 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseRecentlyAddedL_All); |
|
990 |
|
991 TInt indexOfCurrentlyPlayingItem(KErrNotFound); |
|
992 iDbHandler->GetEpisodesMatchingPlaylistL(KRecentlyAddedPlaylistUID, |
|
993 aAttrs, aArray, indexOfCurrentlyPlayingItem); |
|
994 SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPodcastGroup, EMPXRecentlyAdded, |
|
995 *iTitleAdded, aArray.Count()); |
|
996 aEntries.SetTObjectValueL(KMPXMediaPodcastCurrentlyPlayingIndex, |
|
997 indexOfCurrentlyPlayingItem); |
|
998 // Fix for Autoplaylist, set the permission to not writable and cacheable |
|
999 aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>( |
|
1000 KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache)); |
|
1001 |
|
1002 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseRecentlyAddedL_All); |
|
1003 break; |
|
1004 } |
|
1005 // An episode in the recently added episodes list |
|
1006 case 3: |
|
1007 { |
|
1008 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseRecentlyAddedL_Episode); |
|
1009 iDbHandler->GetEpisodeL(aPath.Id(levels - 1), aAttrs, aArray); |
|
1010 isEpisode = ETrue; |
|
1011 |
|
1012 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseRecentlyAddedL_Episode); |
|
1013 break; |
|
1014 } |
|
1015 default: |
|
1016 { |
|
1017 MPX_DEBUG2("CMPXPodcastDbPlugin_DoOpenBrowseRecentlyAddedL: Invalid levels[%d]", levels); |
|
1018 User::Leave(KErrNotSupported); |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 return isEpisode; |
|
1023 } |
|
1024 |
|
1025 // ---------------------------------------------------------------------------- |
|
1026 // Handles OpenL called for EBrowseNotPlayed |
|
1027 // ---------------------------------------------------------------------------- |
|
1028 // |
|
1029 TBool CMPXPodcastDbPlugin::DoOpenBrowseNotPlayedL( |
|
1030 const CMPXCollectionPath& aPath, |
|
1031 const TArray<TMPXAttribute>& aAttrs, |
|
1032 CMPXMedia& aEntries, |
|
1033 CMPXMediaArray& aArray) |
|
1034 { |
|
1035 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenBrowseNotPlayedL"); |
|
1036 |
|
1037 TBool isEpisode(EFalse); |
|
1038 TInt levels(aPath.Levels()); |
|
1039 |
|
1040 switch (levels) |
|
1041 { |
|
1042 case 2: |
|
1043 { |
|
1044 // All episodes that haven't been played |
|
1045 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseNotPlayedL_All); |
|
1046 |
|
1047 TInt indexOfCurrentlyPlayingItem(KErrNotFound); |
|
1048 iDbHandler->GetEpisodesMatchingPlaylistL(KNotPlayedPlaylistUID, aAttrs, aArray, |
|
1049 indexOfCurrentlyPlayingItem); |
|
1050 SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPodcastGroup, EMPXNotYetPlayed, |
|
1051 *iTitleUnplayed, aArray.Count()); |
|
1052 aEntries.SetTObjectValueL(KMPXMediaPodcastCurrentlyPlayingIndex, |
|
1053 indexOfCurrentlyPlayingItem); |
|
1054 // Fix for Autoplaylist, set the permission to not writable and cacheable |
|
1055 aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>( |
|
1056 KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache)); |
|
1057 |
|
1058 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseNotPlayedL_All); |
|
1059 break; |
|
1060 } |
|
1061 // An episode in the recently added episodes list |
|
1062 case 3: |
|
1063 { |
|
1064 MPX_PERF_START(CMPXPodcastDbPlugin_DoOpenBrowseNotPlayedL_Episode); |
|
1065 iDbHandler->GetEpisodeL(aPath.Id(levels - 1), aAttrs, aArray); |
|
1066 isEpisode = ETrue; |
|
1067 |
|
1068 MPX_PERF_END(CMPXPodcastDbPlugin_DoOpenBrowseNotPlayedL_Episode); |
|
1069 break; |
|
1070 } |
|
1071 default: |
|
1072 { |
|
1073 MPX_DEBUG2("CMPXPodcastDbPlugin_DoOpenBrowseNotPlayedL: Invalid levels[%d]", levels); |
|
1074 User::Leave(KErrNotSupported); |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 return isEpisode; |
|
1079 } |
|
1080 |
|
1081 // ---------------------------------------------------------------------------- |
|
1082 // Process the OpenL method with open mode EMPXOpenPlaylistOnly |
|
1083 // ---------------------------------------------------------------------------- |
|
1084 // |
|
1085 CMPXCollectionPath* CMPXPodcastDbPlugin::DoOpenPlaylistL( |
|
1086 const CMPXCollectionPath& aPath, |
|
1087 const TArray<TMPXAttribute>& aAttrs, |
|
1088 TBool aFlagToSignalToBePlayed) |
|
1089 { |
|
1090 MPX_FUNC("CMPXPodcastDbPlugin::DoOpenPlaylistL"); |
|
1091 |
|
1092 RArray<TMPXItemId> ids; |
|
1093 CleanupClosePushL(ids); |
|
1094 |
|
1095 CMPXMedia* entries = CMPXMedia::NewL(); |
|
1096 CleanupStack::PushL(entries); |
|
1097 |
|
1098 CMPXCollectionPath* path = CMPXCollectionPath::NewL( aPath ); |
|
1099 CleanupStack::PushL( path ); |
|
1100 |
|
1101 // Go through the browse path |
|
1102 TInt levels(aPath.Levels()); |
|
1103 if (levels == 2) |
|
1104 { |
|
1105 // Create a new collection path |
|
1106 CleanupStack::PopAndDestroy(path); |
|
1107 path = CMPXCollectionPath::NewL(); |
|
1108 CleanupStack::PushL(path); |
|
1109 |
|
1110 // Always return all episodes here |
|
1111 // |
|
1112 ids.Reset(); |
|
1113 ids.AppendL( KDBPluginUid ); |
|
1114 path->AppendL(ids.Array()); |
|
1115 path->SelectL((TMPXItemId)KDBPluginUid); |
|
1116 |
|
1117 ids.Reset(); |
|
1118 ids.AppendL(EBrowseAll); |
|
1119 path->AppendL(ids.Array()); |
|
1120 path->SelectL((TMPXItemId) EBrowseAll); |
|
1121 path->Set(EMPXOpenPlaylistOnly); |
|
1122 |
|
1123 // Get all item IDs |
|
1124 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
1125 CleanupStack::PushL(array); |
|
1126 |
|
1127 DoOpenBrowseAllL(*path, aAttrs, *entries, *array); |
|
1128 |
|
1129 entries->SetCObjectValueL(KMPXMediaArrayContents, array); |
|
1130 entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count()); |
|
1131 |
|
1132 CleanupStack::PopAndDestroy(array); |
|
1133 |
|
1134 DoAppendLevelL(*path, *entries); |
|
1135 } |
|
1136 else if (levels > 2) |
|
1137 { |
|
1138 TInt selectedId(aPath.Id(1)); |
|
1139 switch (selectedId) |
|
1140 { |
|
1141 case EBrowseAll: |
|
1142 { |
|
1143 path->Set(EMPXOpenPlaylistOnly); |
|
1144 if(aFlagToSignalToBePlayed) |
|
1145 { |
|
1146 // Set the episode ID to be played |
|
1147 entries->SetTObjectValueL( KMPXMediaGeneralId, aPath.Id(2) ); |
|
1148 |
|
1149 // ignore the error because if there is a problem |
|
1150 // updating the media file, the error will show up |
|
1151 // when opening the track for playing and be handled |
|
1152 // properly by the playback engine and skipped |
|
1153 TRAP_IGNORE(iDbHandler->SetIsPlayingL(*entries, ETrue)); |
|
1154 } |
|
1155 break; |
|
1156 } |
|
1157 case EBrowseTitle: |
|
1158 case EBrowsePubDate: |
|
1159 case EBrowseRecentlyAdded: |
|
1160 case EBrowseNotPlayed: |
|
1161 { |
|
1162 if (!DoOpenL(aPath, aAttrs, *entries, aFlagToSignalToBePlayed)) |
|
1163 { |
|
1164 path->Set(EMPXOpenPlaylistOnly); |
|
1165 // If it is not at a episode level |
|
1166 // Append all entries to create collection path |
|
1167 // |
|
1168 DoAppendLevelL(*path, *entries); |
|
1169 } |
|
1170 break; |
|
1171 } |
|
1172 default: |
|
1173 { |
|
1174 User::Leave(KErrNotSupported); |
|
1175 } |
|
1176 } |
|
1177 } |
|
1178 else // levels < 2 |
|
1179 { |
|
1180 User::Leave(KErrNotSupported); |
|
1181 } |
|
1182 |
|
1183 // Cleanup |
|
1184 CleanupStack::Pop(path); |
|
1185 CleanupStack::PopAndDestroy(entries); |
|
1186 CleanupStack::PopAndDestroy(&ids); |
|
1187 |
|
1188 return path; |
|
1189 } |
|
1190 |
|
1191 // ---------------------------------------------------------------------------- |
|
1192 // Process the MediaL command |
|
1193 // ---------------------------------------------------------------------------- |
|
1194 // |
|
1195 void CMPXPodcastDbPlugin::DoMediaL( |
|
1196 const CMPXCollectionPath& aPath, |
|
1197 const TArray<TMPXAttribute>& aAttrs, |
|
1198 CMPXMedia& aEntries) |
|
1199 { |
|
1200 MPX_FUNC("CMPXPodcastDbPlugin::DoMediaL"); |
|
1201 |
|
1202 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
1203 CleanupStack::PushL(array); |
|
1204 |
|
1205 DoTitlesMediaL(aPath, aAttrs, aEntries, *array); |
|
1206 |
|
1207 if (array->Count() > 0) |
|
1208 { |
|
1209 aEntries.SetCObjectValueL(KMPXMediaArrayContents, array); |
|
1210 aEntries.SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count()); |
|
1211 } |
|
1212 CleanupStack::PopAndDestroy(array); |
|
1213 } |
|
1214 |
|
1215 // ---------------------------------------------------------------------------- |
|
1216 // Find the collection media for root level |
|
1217 // ---------------------------------------------------------------------------- |
|
1218 // |
|
1219 void CMPXPodcastDbPlugin::DoRootMediaL( |
|
1220 const TArray<TMPXAttribute>& aAttrs, |
|
1221 CMPXMedia& aMedia) |
|
1222 { |
|
1223 MPX_FUNC("CMPXPodcastDbPlugin::DoRootMediaL"); |
|
1224 #ifndef __ENABLE_PODCAST_IN_MUSIC_MENU |
|
1225 aMedia.SetTObjectValueL<TMPXGeneralNonPermissibleActions> ( |
|
1226 KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache) ); |
|
1227 #endif // __ENABLE_PODCAST_IN_MUSIC_MENU |
|
1228 TInt count(aAttrs.Count()); |
|
1229 for (TInt i = 0; i < count; ++i) |
|
1230 { |
|
1231 if (aAttrs[i].ContentId() == KMPXMediaIdGeneral) |
|
1232 { |
|
1233 TUint att = aAttrs[i].AttributeId(); |
|
1234 |
|
1235 if (att & EMPXMediaGeneralTitle) |
|
1236 { |
|
1237 // set the collection plugin name |
|
1238 HBufC* title(iResource->ReadHBufCL(R_MPX_QTN_MUS_PODCASTS)); |
|
1239 CleanupStack::PushL(title); |
|
1240 aMedia.SetTextValueL(KMPXMediaGeneralTitle, *title); |
|
1241 CleanupStack::PopAndDestroy(title); |
|
1242 } |
|
1243 if (att & EMPXMediaGeneralSubTitle) |
|
1244 { |
|
1245 TInt numEpisodes(iDbHandler->NumberOfItemsL(EMPXEpisode)); |
|
1246 |
|
1247 HBufC* text(iResource->ReadHBufCL((numEpisodes == 1) ? |
|
1248 R_MPX_QTN_MUS_PODCAST_ONE_EPISODE : R_MPX_QTN_MUS_PODCAST_NUM_EPISODES)); |
|
1249 CleanupStack::PushL(text); |
|
1250 aMedia.SetTextValueL(KMPXMediaGeneralSubTitle, *text); |
|
1251 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, numEpisodes); |
|
1252 CleanupStack::PopAndDestroy(text); |
|
1253 } |
|
1254 if (att & EMPXMediaGeneralIcon) |
|
1255 { |
|
1256 // set the collection plugin icon |
|
1257 TIconInfo icon; |
|
1258 icon.bmpfile = KMPlayerDbPluginMbmFile; |
|
1259 icon.bitmapId = EMbmMpxpodcastdbpluginQgn_graf_mup_dlst_podcast; |
|
1260 icon.maskId = EMbmMpxpodcastdbpluginQgn_graf_mup_dlst_podcast_mask; |
|
1261 aMedia.SetTObjectValueL<TIconInfo>(KMPXMediaGeneralIcon, icon ); |
|
1262 } |
|
1263 } // if |
|
1264 } // for |
|
1265 } |
|
1266 |
|
1267 // ---------------------------------------------------------------------------- |
|
1268 // Find the collection media for all episodes category |
|
1269 // ---------------------------------------------------------------------------- |
|
1270 // |
|
1271 void CMPXPodcastDbPlugin::DoAllEpisodesMediaL( |
|
1272 const CMPXCollectionPath& aPath, |
|
1273 const TArray<TMPXAttribute>& aAttrs, |
|
1274 CMPXMedia& aEntries, |
|
1275 CMPXMediaArray& aMediaArray) |
|
1276 { |
|
1277 MPX_FUNC("CMPXPodcastDbPlugin::DoAllEpisodesMediaL"); |
|
1278 |
|
1279 TInt levels(aPath.Levels()); |
|
1280 switch (levels) |
|
1281 { |
|
1282 // All episodes |
|
1283 case 2: |
|
1284 { |
|
1285 MPX_PERF_START(CMPXPodcastDbPlugin_DoAllEpisodesMediaL_All); |
|
1286 DoRootCategoryMediaL(aAttrs, aPath.Id(1), EMPXAll, aEntries); |
|
1287 MPX_PERF_END(CMPXPodcastDbPlugin_DoAllEpisodesMediaL_All); |
|
1288 break; |
|
1289 } |
|
1290 // An episode in all episodes |
|
1291 case 3: |
|
1292 { |
|
1293 MPX_PERF_START(CMPXPodcastDbPlugin_DoAllEpisodesMediaL_Episode); |
|
1294 GetEpisodeInfoL(aPath, aAttrs, aEntries, aMediaArray); |
|
1295 MPX_PERF_END(CMPXPodcastDbPlugin_DoAllEpisodesMediaL_Episode); |
|
1296 break; |
|
1297 } |
|
1298 default: |
|
1299 { |
|
1300 MPX_DEBUG2("CMPXPodcastDbPlugin_DoAllEpisodesMediaL: Invalid levels[%d]", levels); |
|
1301 User::Leave(KErrNotSupported); |
|
1302 } |
|
1303 } // end switch(levels) |
|
1304 } |
|
1305 |
|
1306 // ---------------------------------------------------------------------------- |
|
1307 // Find the collection media for by publish date category |
|
1308 // ---------------------------------------------------------------------------- |
|
1309 // |
|
1310 void CMPXPodcastDbPlugin::DoByPublishDateMediaL( |
|
1311 const CMPXCollectionPath& aPath, |
|
1312 const TArray<TMPXAttribute>& aAttrs, |
|
1313 CMPXMedia& aEntries, |
|
1314 CMPXMediaArray& aMediaArray) |
|
1315 { |
|
1316 MPX_FUNC("CMPXPodcastDbPlugin::DoByPublishDateMediaL"); |
|
1317 |
|
1318 TInt levels(aPath.Levels()); |
|
1319 TInt idIndex(levels - 1); |
|
1320 |
|
1321 // All By Publish Date Categories |
|
1322 if (levels == 2) |
|
1323 { |
|
1324 MPX_PERF_START(CMPXPodcastDbPlugin_DoByPublishDateMediaL_All); |
|
1325 DoRootCategoryMediaL(aAttrs, aPath.Id(1), EMPXPubDate, aEntries); |
|
1326 MPX_PERF_END(CMPXPodcastDbPlugin_DoByPublishDateMediaL_All); |
|
1327 } |
|
1328 else if (levels == 3) // by publish date category selected |
|
1329 { |
|
1330 MPX_PERF_START(CMPXPodcastDbPlugin_DoByPublishDateMediaL_Category); |
|
1331 const TDesC& title = iPodcastEpisodeViewPublishDateTitle->MdcaPoint( |
|
1332 aPath.Id(idIndex).iId2 & 0x00FFFFFF); |
|
1333 aEntries.SetTextValueL(KMPXMediaGeneralTitle, title); |
|
1334 MPX_PERF_END(CMPXPodcastDbPlugin_DoByPublishDateMediaL_Category); |
|
1335 } |
|
1336 else if (levels == 4) // an episode within the category |
|
1337 { |
|
1338 MPX_PERF_START(CMPXPodcastDbPlugin_DoByPublishDateMediaL_Episode); |
|
1339 GetEpisodeInfoL(aPath, aAttrs, aEntries, aMediaArray); |
|
1340 MPX_PERF_END(CMPXPodcastDbPlugin_DoByPublishDateMediaL_Episode); |
|
1341 } |
|
1342 else |
|
1343 { |
|
1344 MPX_DEBUG2("CMPXPodcastDbPlugin_DoByPublishDateMediaL: Invalid levels[%d]", levels); |
|
1345 User::Leave(KErrNotSupported); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 // ---------------------------------------------------------------------------- |
|
1350 // Find the collection media for titles category |
|
1351 // ---------------------------------------------------------------------------- |
|
1352 // |
|
1353 void CMPXPodcastDbPlugin::DoTitlesMediaL( |
|
1354 const CMPXCollectionPath& aPath, |
|
1355 const TArray<TMPXAttribute>& aAttrs, |
|
1356 CMPXMedia& aEntries, |
|
1357 CMPXMediaArray& aMediaArray) |
|
1358 { |
|
1359 MPX_FUNC("CMPXPodcastDbPlugin::DoTitlesMediaL"); |
|
1360 |
|
1361 TInt levels(aPath.Levels()); |
|
1362 TInt idIndex(levels - 1); |
|
1363 |
|
1364 // All Titles Categories |
|
1365 if (levels == 1) |
|
1366 { |
|
1367 MPX_PERF_START(CMPXPodcastDbPlugin_DoTitlesMediaL_All); |
|
1368 DoRootCategoryMediaL(aAttrs, aPath.Id(1), EMPXTitle, aEntries); |
|
1369 MPX_PERF_END(CMPXPodcastDbPlugin_DoTitlesMediaL_All); |
|
1370 } |
|
1371 else if (levels == 2) // All episodes within selected title |
|
1372 { |
|
1373 MPX_PERF_START (CMPXPodcastDbPlugin_DoTitlesMediaL_Title); |
|
1374 iDbHandler->GetAllPodcastTitlesL(aAttrs, aMediaArray); |
|
1375 HBufC* title = iDbHandler->GetTitleNameMatchingIdL(aPath.Id(idIndex)); |
|
1376 CleanupStack::PushL(title); |
|
1377 aEntries.SetTextValueL(KMPXMediaGeneralTitle, *title); |
|
1378 CleanupStack::PopAndDestroy(title); |
|
1379 MPX_PERF_END (CMPXPodcastDbPlugin_DoTitlesMediaL_Title); |
|
1380 } |
|
1381 else if (levels == 3) // an episode within a selected title |
|
1382 { |
|
1383 MPX_PERF_START(CMPXPodcastDbPlugin_DoTitlesMediaL_Episode); |
|
1384 GetEpisodeInfoL (aPath, aAttrs, aEntries, aMediaArray); |
|
1385 MPX_PERF_END(CMPXPodcastDbPlugin_DoTitlesMediaL_Episode); |
|
1386 } |
|
1387 else |
|
1388 { |
|
1389 MPX_DEBUG2("CMPXPodcastDbPlugin_DoTitlesMediaL: Invalid levels[%d]", levels); |
|
1390 User::Leave(KErrNotSupported); |
|
1391 } |
|
1392 } |
|
1393 |
|
1394 // ---------------------------------------------------------------------------- |
|
1395 // Find the collection media for recently added |
|
1396 // ---------------------------------------------------------------------------- |
|
1397 // |
|
1398 void CMPXPodcastDbPlugin::DoRecentlyAddedMediaL( |
|
1399 const CMPXCollectionPath& aPath, |
|
1400 const TArray<TMPXAttribute>& aAttrs, |
|
1401 CMPXMedia& aEntries, |
|
1402 CMPXMediaArray& aMediaArray) |
|
1403 { |
|
1404 MPX_FUNC("CMPXPodcastDbPlugin::DoRecentlyAddedMediaL"); |
|
1405 |
|
1406 switch (aPath.Levels()) |
|
1407 { |
|
1408 // All episodes |
|
1409 case 2: |
|
1410 { |
|
1411 MPX_PERF_START(CMPXPodcastDbPlugin_DoRecentlyAddedMediaL_All); |
|
1412 DoRootCategoryMediaL(aAttrs, aPath.Id(1), EMPXRecentlyAdded, aEntries); |
|
1413 MPX_PERF_END(CMPXPodcastDbPlugin_DoRecentlyAddedMediaL_All); |
|
1414 break; |
|
1415 } |
|
1416 |
|
1417 // An episode that was recently added |
|
1418 case 3: |
|
1419 { |
|
1420 MPX_PERF_START(CMPXPodcastDbPlugin_DoRecentlyAddedMediaL_Episode); |
|
1421 GetEpisodeInfoL(aPath, aAttrs, aEntries, aMediaArray); |
|
1422 MPX_PERF_END(CMPXPodcastDbPlugin_DoRecentlyAddedMediaL_Episode); |
|
1423 break; |
|
1424 } |
|
1425 |
|
1426 default: |
|
1427 { |
|
1428 MPX_DEBUG2("CMPXPodcastDbPlugin_DoRecentlyAddedMediaL: Invalid levels[%d]", aPath.Levels()); |
|
1429 User::Leave(KErrNotSupported); |
|
1430 } |
|
1431 } // end switch(levels) |
|
1432 } |
|
1433 |
|
1434 // ---------------------------------------------------------------------------- |
|
1435 // Find the collection media for recently added |
|
1436 // ---------------------------------------------------------------------------- |
|
1437 // |
|
1438 void CMPXPodcastDbPlugin::DoNotYetPlayedMediaL( |
|
1439 const CMPXCollectionPath& aPath, |
|
1440 const TArray<TMPXAttribute>& aAttrs, |
|
1441 CMPXMedia& aEntries, |
|
1442 CMPXMediaArray& aMediaArray) |
|
1443 { |
|
1444 MPX_FUNC("CMPXPodcastDbPlugin::DoNotYetPlayedMediaL"); |
|
1445 |
|
1446 switch (aPath.Levels()) |
|
1447 { |
|
1448 // All episodes |
|
1449 case 2: |
|
1450 { |
|
1451 MPX_PERF_START(CMPXPodcastDbPlugin_DoNotYetPlayedMediaL_All); |
|
1452 DoRootCategoryMediaL(aAttrs, aPath.Id(1), EMPXNotYetPlayed, aEntries); |
|
1453 MPX_PERF_END(CMPXPodcastDbPlugin_DoNotYetPlayedMediaL_All); |
|
1454 break; |
|
1455 } |
|
1456 |
|
1457 // An episode that was never played |
|
1458 case 3: |
|
1459 { |
|
1460 MPX_PERF_START(CMPXPodcastDbPlugin_DoNotYetPlayedMediaL_Episode); |
|
1461 MPX_TRAPD(err, GetEpisodeInfoL(aPath, aAttrs, aEntries, aMediaArray)); |
|
1462 |
|
1463 if (err != KErrNotFound) |
|
1464 { |
|
1465 // it's o.k if the episode isn't found because the episode |
|
1466 // might have finished playing and is no longer |
|
1467 // part of the "Not yet played" playlist |
|
1468 User::LeaveIfError(err); |
|
1469 } |
|
1470 |
|
1471 MPX_PERF_END(CMPXPodcastDbPlugin_DoNotYetPlayedMediaL_Episode); |
|
1472 break; |
|
1473 } |
|
1474 |
|
1475 default: |
|
1476 { |
|
1477 MPX_DEBUG2("CMPXPodcastDbPlugin_DoNotYetPlayedMediaL: Invalid levels[%d]", aPath.Levels()); |
|
1478 User::Leave(KErrNotSupported); |
|
1479 } |
|
1480 } // end switch(levels) |
|
1481 } |
|
1482 |
|
1483 // ---------------------------------------------------------------------------- |
|
1484 // Find the collection media for the root menu |
|
1485 // ---------------------------------------------------------------------------- |
|
1486 // |
|
1487 void CMPXPodcastDbPlugin::DoRootCategoryMediaL( |
|
1488 const TArray<TMPXAttribute>& aAttrs, |
|
1489 TMPXItemId aRootCategoryId, |
|
1490 TMPXPodcastCategory aCategory, |
|
1491 CMPXMedia& aEntries) |
|
1492 { |
|
1493 MPX_FUNC("CMPXPodcastDbPlugin::DoRootCategoryMediaL"); |
|
1494 |
|
1495 TInt count(aAttrs.Count()); |
|
1496 for (TInt i = 0; i < count; ++i) |
|
1497 { |
|
1498 if (aAttrs[i].ContentId() == KMPXMediaIdGeneral) |
|
1499 { |
|
1500 TUint att(aAttrs[i].AttributeId()); |
|
1501 |
|
1502 if (att & EMPXMediaGeneralId) |
|
1503 { |
|
1504 aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
|
1505 aRootCategoryId); |
|
1506 } |
|
1507 if (att & EMPXMediaGeneralTitle) |
|
1508 { |
|
1509 aEntries.SetTextValueL(KMPXMediaGeneralTitle, |
|
1510 iPodcastLibraryTitles->MdcaPoint(BrowseTypeForCategory(aCategory))); |
|
1511 } |
|
1512 } // end if |
|
1513 } // end for |
|
1514 |
|
1515 aEntries.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
|
1516 aEntries.SetTObjectValueL<TMPXPodcastCategory>(KMPXMediaGeneralCategory, aCategory); |
|
1517 } |
|
1518 |
|
1519 // ---------------------------------------------------------------------------- |
|
1520 // Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm |
|
1521 // ---------------------------------------------------------------------------- |
|
1522 // |
|
1523 void CMPXPodcastDbPlugin::DoSetMediaDrmL( |
|
1524 CMPXMedia& aMedia, |
|
1525 TUint aDrmAttributes, |
|
1526 const TDesC& aLocation) |
|
1527 { |
|
1528 MPX_FUNC("CMPXPodcastDbPlugin::DoSetMediaDrmL"); |
|
1529 |
|
1530 iDrmMediaUtility->InitL(aLocation); |
|
1531 CleanupClosePushL(*iDrmMediaUtility); |
|
1532 const CMPXMedia* drmMedia(iDrmMediaUtility->GetMediaL(aDrmAttributes)); |
|
1533 |
|
1534 // Only get attributes if it's a DRM file |
|
1535 if (drmMedia) |
|
1536 { |
|
1537 if ((aDrmAttributes & EMPXMediaDrmType) && |
|
1538 drmMedia->IsSupported(KMPXMediaDrmType)) |
|
1539 { |
|
1540 aMedia.SetTObjectValueL(KMPXMediaDrmType, |
|
1541 drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmType)); |
|
1542 } |
|
1543 if ((aDrmAttributes & EMPXMediaDrmRightsStatus) && |
|
1544 drmMedia->IsSupported(KMPXMediaDrmRightsStatus)) |
|
1545 { |
|
1546 aMedia.SetTObjectValueL(KMPXMediaDrmRightsStatus, |
|
1547 drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsStatus)); |
|
1548 } |
|
1549 if ((aDrmAttributes & EMPXMediaDrmRightsType) && |
|
1550 drmMedia->IsSupported(KMPXMediaDrmRightsType)) |
|
1551 { |
|
1552 aMedia.SetTObjectValueL(KMPXMediaDrmRightsType, |
|
1553 drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsType)); |
|
1554 } |
|
1555 if ((aDrmAttributes & EMPXMediaDrmCount) && |
|
1556 drmMedia->IsSupported(KMPXMediaDrmCount)) |
|
1557 { |
|
1558 aMedia.SetTObjectValueL(KMPXMediaDrmCount, |
|
1559 drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmCount)); |
|
1560 } |
|
1561 if ((aDrmAttributes & EMPXMediaDrmProtected) && |
|
1562 drmMedia->IsSupported(KMPXMediaDrmProtected)) |
|
1563 { |
|
1564 aMedia.SetTObjectValueL(KMPXMediaDrmProtected, |
|
1565 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmProtected)); |
|
1566 } |
|
1567 if ((aDrmAttributes & EMPXMediaDrmSendingAllowed) && |
|
1568 drmMedia->IsSupported(KMPXMediaDrmSendingAllowed)) |
|
1569 { |
|
1570 aMedia.SetTObjectValueL(KMPXMediaDrmSendingAllowed, |
|
1571 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmSendingAllowed)); |
|
1572 } |
|
1573 if ((aDrmAttributes & EMPXMediaDrmCanSetAutomated) && |
|
1574 drmMedia->IsSupported(KMPXMediaDrmCanSetAutomated)) |
|
1575 { |
|
1576 aMedia.SetTObjectValueL(KMPXMediaDrmCanSetAutomated, |
|
1577 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmCanSetAutomated)); |
|
1578 } |
|
1579 if ((aDrmAttributes & EMPXMediaDrmHasInfoUrl) && |
|
1580 drmMedia->IsSupported(KMPXMediaDrmHasInfoUrl)) |
|
1581 { |
|
1582 aMedia.SetTObjectValueL(KMPXMediaDrmHasInfoUrl, |
|
1583 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasInfoUrl)); |
|
1584 } |
|
1585 if ((aDrmAttributes & EMPXMediaDrmHasPreviewUrl) && |
|
1586 drmMedia->IsSupported(KMPXMediaDrmHasPreviewUrl)) |
|
1587 { |
|
1588 aMedia.SetTObjectValueL(KMPXMediaDrmHasPreviewUrl, |
|
1589 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasPreviewUrl)); |
|
1590 } |
|
1591 if ((aDrmAttributes & EMPXMediaDrmAboutToExpire) && |
|
1592 drmMedia->IsSupported(KMPXMediaDrmAboutToExpire)) |
|
1593 { |
|
1594 aMedia.SetTObjectValueL( KMPXMediaDrmAboutToExpire, |
|
1595 drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmAboutToExpire)); |
|
1596 } |
|
1597 if ((aDrmAttributes & EMPXMediaDrmStartTime) && |
|
1598 drmMedia->IsSupported(KMPXMediaDrmStartTime)) |
|
1599 { |
|
1600 aMedia.SetTObjectValueL(KMPXMediaDrmStartTime, |
|
1601 drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmStartTime)); |
|
1602 } |
|
1603 if ((aDrmAttributes & EMPXMediaDrmEndTime) && |
|
1604 drmMedia->IsSupported(KMPXMediaDrmEndTime)) |
|
1605 { |
|
1606 aMedia.SetTObjectValueL( KMPXMediaDrmEndTime, |
|
1607 drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmEndTime)); |
|
1608 } |
|
1609 if ((aDrmAttributes & EMPXMediaDrmIntervalStartTime) && |
|
1610 drmMedia->IsSupported(KMPXMediaDrmIntervalStartTime)) |
|
1611 { |
|
1612 aMedia.SetTObjectValueL( KMPXMediaDrmIntervalStartTime, |
|
1613 drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmIntervalStartTime)); |
|
1614 } |
|
1615 if ((aDrmAttributes & EMPXMediaDrmAccumulatedTime) && |
|
1616 drmMedia->IsSupported(KMPXMediaDrmAccumulatedTime)) |
|
1617 { |
|
1618 aMedia.SetTObjectValueL(KMPXMediaDrmAccumulatedTime, |
|
1619 drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmAccumulatedTime)); |
|
1620 } |
|
1621 if ((aDrmAttributes & EMPXMediaDrmInterval) && |
|
1622 drmMedia->IsSupported(KMPXMediaDrmInterval)) |
|
1623 { |
|
1624 aMedia.SetTObjectValueL( KMPXMediaDrmInterval, |
|
1625 drmMedia->ValueTObjectL<TTimeIntervalSeconds>(KMPXMediaDrmInterval)); |
|
1626 } |
|
1627 } |
|
1628 |
|
1629 CleanupStack::PopAndDestroy(iDrmMediaUtility); |
|
1630 } |
|
1631 |
|
1632 // ---------------------------------------------------------------------------- |
|
1633 // Add media objects to the array with attributes from episode details |
|
1634 // ---------------------------------------------------------------------------- |
|
1635 // |
|
1636 void CMPXPodcastDbPlugin::GetEpisodeInfoL( |
|
1637 const CMPXCollectionPath& aPath, |
|
1638 const TArray<TMPXAttribute>& aAttrs, |
|
1639 CMPXMedia& aEntry, |
|
1640 CMPXMediaArray& aMediaArray) |
|
1641 { |
|
1642 MPX_FUNC("CMPXPodcastDbPlugin::GetEpisodeInfoL"); |
|
1643 |
|
1644 RArray<TInt> supportedIds; |
|
1645 CleanupClosePushL(supportedIds); |
|
1646 MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds); |
|
1647 |
|
1648 RArray<TMPXItemId> selections; |
|
1649 CleanupClosePushL(selections); |
|
1650 aPath.SelectionL(selections); |
|
1651 |
|
1652 TInt countSelection(aPath.Selection().Count()); |
|
1653 if (countSelection) |
|
1654 { |
|
1655 for (TInt selectionIndex = 0; selectionIndex < countSelection; ++selectionIndex) |
|
1656 { |
|
1657 CMPXMedia* newEntry = CMPXMedia::NewL(supportedIds.Array()); |
|
1658 CleanupStack::PushL(newEntry); |
|
1659 |
|
1660 DoGetEpisodeInfoL(aAttrs, selections[selectionIndex].iId2, *newEntry); |
|
1661 |
|
1662 aMediaArray.AppendL(*newEntry); |
|
1663 CleanupStack::PopAndDestroy(newEntry); |
|
1664 } |
|
1665 } |
|
1666 else |
|
1667 { |
|
1668 // No selection, get the attributes for the one song |
|
1669 DoGetEpisodeInfoL(aAttrs, aPath.Id(aPath.Levels() - 1).iId2, aEntry); |
|
1670 } |
|
1671 |
|
1672 CleanupStack::PopAndDestroy(&selections); |
|
1673 CleanupStack::PopAndDestroy(&supportedIds); |
|
1674 } |
|
1675 |
|
1676 // ---------------------------------------------------------------------------- |
|
1677 // Retrieves the attributes for a media object. |
|
1678 // ---------------------------------------------------------------------------- |
|
1679 // |
|
1680 void CMPXPodcastDbPlugin::DoGetEpisodeInfoL( |
|
1681 const TArray<TMPXAttribute>& aAttrs, |
|
1682 TInt aEntryId, |
|
1683 CMPXMedia& aEntry) |
|
1684 { |
|
1685 MPX_FUNC("CMPXPodcastDbPlugin::DoGetEpisodeInfoL"); |
|
1686 |
|
1687 iDbHandler->GetEpisodeL(aEntryId, aAttrs, aEntry); |
|
1688 |
|
1689 const TDesC& location(aEntry.ValueText(KMPXMediaGeneralUri)); |
|
1690 |
|
1691 // Check DRM Only if we have a location |
|
1692 if (location != KNullDesC) |
|
1693 { |
|
1694 TUint drmAttributes(0); |
|
1695 |
|
1696 // Compact the attribute set |
|
1697 TInt count(aAttrs.Count()); |
|
1698 for (TInt i = 0; i < count; ++i) |
|
1699 { |
|
1700 if (aAttrs[i].ContentId() == KMPXMediaIdDrm) |
|
1701 { |
|
1702 drmAttributes |= aAttrs[i].AttributeId(); |
|
1703 } |
|
1704 } |
|
1705 |
|
1706 // Set the correct attributes to media, only if requested |
|
1707 if (drmAttributes) |
|
1708 { |
|
1709 DoSetMediaDrmL(aEntry, drmAttributes, location); |
|
1710 } |
|
1711 } |
|
1712 } |
|
1713 |
|
1714 // ---------------------------------------------------------------------------- |
|
1715 // Retrieve the collection details |
|
1716 // ---------------------------------------------------------------------------- |
|
1717 // |
|
1718 void CMPXPodcastDbPlugin::DoHandleOtherMediaAttributesL( |
|
1719 const TArray<TMPXAttribute>& aAttrs, |
|
1720 const CMPXCollectionPath& aPath, |
|
1721 CMPXMedia& aMedia) |
|
1722 { |
|
1723 MPX_FUNC("CMPXPodcastDbPlugin::DoHandleOtherMediaAttributesL"); |
|
1724 |
|
1725 TInt count(aAttrs.Count()); |
|
1726 for (TInt i = 0; i < count; ++i) |
|
1727 { |
|
1728 if (aAttrs[i].ContentId() == KMPXMediaIdCollectionDetails) |
|
1729 { |
|
1730 TUint att(aAttrs[i].AttributeId()); |
|
1731 |
|
1732 if (att & EMPXMediaColDetailNumberOfItems) |
|
1733 { |
|
1734 aMedia.SetTObjectValueL(KMPXMediaColDetailNumberOfItems, |
|
1735 iDbHandler->NumberOfItemsL(EMPXEpisode) ); |
|
1736 } |
|
1737 if (att & EMPXMediaColDetailDuration) |
|
1738 { |
|
1739 aMedia.SetTObjectValueL(KMPXMediaColDetailDuration, |
|
1740 DoDurationL( aMedia, EMPXEpisode ) ); |
|
1741 } |
|
1742 if (att & EMPXMediaColTotalSize) |
|
1743 { |
|
1744 TInt totalSize(0); |
|
1745 // todo |
|
1746 aMedia.SetTObjectValueL(KMPXMediaColDetailTotalSize, totalSize ); |
|
1747 } |
|
1748 if (att & EMPXMediaLastRefreshed) |
|
1749 { |
|
1750 TTime lastRefreshed = iDbHandler->GetLastRefreshedTimeL(); |
|
1751 aMedia.SetTObjectValueL(KMPXMediaColDetailLastRefreshed, |
|
1752 lastRefreshed.Int64() ); |
|
1753 } |
|
1754 if (att & EMPXMediaColDetailDBCreated) |
|
1755 { |
|
1756 aMedia.SetTObjectValueL(KMPXMediaColDetailDBCreated, |
|
1757 iDbHandler->DatabaseCreated()); |
|
1758 } |
|
1759 if (att & EMPXMediaColDetailDBCorrupted) |
|
1760 { |
|
1761 aMedia.SetTObjectValueL(KMPXMediaColDetailDBCorrupted, |
|
1762 iDbHandler->IsDBCorruptedL()); |
|
1763 } |
|
1764 } |
|
1765 else if (aAttrs[i] == KMPXMediaGeneralPath) |
|
1766 { |
|
1767 aMedia.SetCObjectValueL(KMPXMediaGeneralPath, |
|
1768 const_cast<CMPXCollectionPath*>(&aPath)); |
|
1769 } |
|
1770 } |
|
1771 } |
|
1772 |
|
1773 // ---------------------------------------------------------------------------- |
|
1774 // Remove an item from the collection database using the given path |
|
1775 // ---------------------------------------------------------------------------- |
|
1776 // |
|
1777 CDesCArray* CMPXPodcastDbPlugin::DoRemoveL( |
|
1778 const CMPXCollectionPath& aPath, |
|
1779 CMPXMessageArray& aChangeMsgArray) |
|
1780 { |
|
1781 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveL"); |
|
1782 |
|
1783 if (aPath.Levels() <= 0) |
|
1784 { |
|
1785 User::Leave(KErrNotSupported); |
|
1786 } |
|
1787 |
|
1788 // Return file path for deleted item(s) |
|
1789 // |
|
1790 CDesCArray* fp = new(ELeave) CDesCArrayFlat(1); |
|
1791 CleanupStack::PushL(fp); |
|
1792 |
|
1793 // Ids of the selected items |
|
1794 RArray<TMPXItemId> selections; |
|
1795 CleanupClosePushL(selections); |
|
1796 aPath.SelectionL(selections); |
|
1797 |
|
1798 DoRemoveFromCategoriesL(aPath, selections.Array(), EMPXAlbum, *fp, aChangeMsgArray); |
|
1799 |
|
1800 MPX_DEBUG2("CMPXPodcastDbPlugin::DoRemoveL itemId[%d]", aPath.Id (aPath.Levels() - 1).iId2); |
|
1801 |
|
1802 CleanupStack::PopAndDestroy(&selections); |
|
1803 CleanupStack::Pop(fp); |
|
1804 |
|
1805 return fp; |
|
1806 } |
|
1807 |
|
1808 // ---------------------------------------------------------------------------- |
|
1809 // Remove media by path through a command |
|
1810 // ---------------------------------------------------------------------------- |
|
1811 // |
|
1812 void CMPXPodcastDbPlugin::DoRemoveL( |
|
1813 const CMPXMedia& aMedia, |
|
1814 TBool aDeleteRecord) |
|
1815 { |
|
1816 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveL(by command)"); |
|
1817 |
|
1818 // Return deleted file paths to caller |
|
1819 CDesCArray* fp = new(ELeave) CDesCArrayFlat(1); |
|
1820 CleanupStack::PushL(fp); |
|
1821 |
|
1822 // a list of change event messages a result of the item being removed |
|
1823 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
|
1824 CleanupStack::PushL(itemChangedMessages); |
|
1825 |
|
1826 TUint32 podcastEpisodeId(0); |
|
1827 |
|
1828 // Removing a container of items |
|
1829 // |
|
1830 if (aMedia.IsSupported(KMPXMediaArrayContents)) |
|
1831 { |
|
1832 MPX_DEBUG1("CMPXPodcastDbPlugin::RemoveL -- Removing a container of items"); |
|
1833 const CMPXMediaArray* media = (aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents)); |
|
1834 if( !media ) |
|
1835 { |
|
1836 User::Leave( KErrNoMemory ); |
|
1837 } |
|
1838 const TInt mediaCount(media->Count()); |
|
1839 for (TInt i = 0; i < mediaCount; ++i) |
|
1840 { |
|
1841 CMPXMedia* entry = media->AtL(i); |
|
1842 if( entry->IsSupported(KMPXMediaGeneralId)) |
|
1843 { |
|
1844 podcastEpisodeId = entry->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1845 } |
|
1846 else if (entry->IsSupported(KMPXMediaGeneralUri)) |
|
1847 { |
|
1848 podcastEpisodeId = iDbHandler->GetEpisodeIdMatchingUriL( |
|
1849 entry->ValueText(KMPXMediaGeneralUri)); |
|
1850 } |
|
1851 else |
|
1852 { |
|
1853 // Unable to process this item |
|
1854 continue; |
|
1855 } |
|
1856 |
|
1857 iDbHandler->RemoveEpisodeL(podcastEpisodeId, *fp, *itemChangedMessages, |
|
1858 aDeleteRecord); |
|
1859 } |
|
1860 } |
|
1861 // Removing an item with known item id |
|
1862 // |
|
1863 else if (aMedia.IsSupported(KMPXMediaGeneralId)) |
|
1864 { |
|
1865 MPX_DEBUG1("CMPXPodcastDbPlugin::RemoveL -- Removing an item by item id"); |
|
1866 podcastEpisodeId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1867 |
|
1868 if ((podcastEpisodeId >> 28) != EMPXPlaylist) |
|
1869 { |
|
1870 iDbHandler->RemoveEpisodeL(podcastEpisodeId, *fp, |
|
1871 *itemChangedMessages, aDeleteRecord); |
|
1872 } |
|
1873 else |
|
1874 { |
|
1875 MPX_DEBUG1("CMPXPodcastDbPlugin::RemoveL -- Playlists not supported within podcast collection"); |
|
1876 User::Leave(KErrNotSupported); |
|
1877 } |
|
1878 } |
|
1879 // Removing an item with known uri |
|
1880 // |
|
1881 else if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
|
1882 { |
|
1883 MPX_DEBUG1("CMPXPodcastDbPlugin::RemoveL -- Removing an item by uri"); |
|
1884 podcastEpisodeId = iDbHandler->GetEpisodeIdMatchingUriL( |
|
1885 aMedia.ValueText(KMPXMediaGeneralUri)); |
|
1886 iDbHandler->RemoveEpisodeL(podcastEpisodeId, *fp, *itemChangedMessages, |
|
1887 aDeleteRecord); |
|
1888 } |
|
1889 else |
|
1890 { |
|
1891 MPX_DEBUG1("CMPXPodcastDbPlugin::RemoveL -- Unknown item for removal"); |
|
1892 User::Leave(KErrNotSupported); |
|
1893 } |
|
1894 |
|
1895 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
1896 DoHandleChangeL(itemChangedMessages); |
|
1897 |
|
1898 CleanupStack::PopAndDestroy(itemChangedMessages); |
|
1899 CleanupStack::PopAndDestroy(fp); |
|
1900 } |
|
1901 |
|
1902 // ---------------------------------------------------------------------------- |
|
1903 // Remove an item from the collection database using the given media properties |
|
1904 // ---------------------------------------------------------------------------- |
|
1905 // |
|
1906 void CMPXPodcastDbPlugin::DoRemovePathL( |
|
1907 CMPXCommand& aCmd) |
|
1908 { |
|
1909 MPX_FUNC("CMPXPodcastDbPlugin::DoRemovePathL(by command)"); |
|
1910 |
|
1911 TInt removeError(KErrNone); |
|
1912 TBool removeCompleted(ETrue); |
|
1913 |
|
1914 if (!aCmd.IsSupported(KMPXCommandCollectionRemovePath) || |
|
1915 !aCmd.IsSupported(KMPXCommandCollectionRemoveMediaCount)) |
|
1916 { |
|
1917 removeError = KErrArgument; |
|
1918 } |
|
1919 else |
|
1920 { |
|
1921 CMPXCollectionPath* path = |
|
1922 aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCommandCollectionRemovePath); |
|
1923 CleanupStack::PushL(path); |
|
1924 |
|
1925 // in order to support cancel delete for a category, we need to adjust path. If |
|
1926 // the path ends in a category, retrieve all episodes under the selected category |
|
1927 // and append a new level with all episodes under the selected category |
|
1928 DoAppendLevelL(*path); |
|
1929 |
|
1930 CMPXCollectionPath* iterationPath = CMPXCollectionPath::NewL(*path); |
|
1931 CleanupStack::PushL(iterationPath); |
|
1932 iterationPath->ClearSelection(); |
|
1933 |
|
1934 // indices of the selected items |
|
1935 TArray<TInt> selectionIndices = path->Selection(); |
|
1936 TInt count(selectionIndices.Count()); |
|
1937 |
|
1938 // number of medias to remove in this iteration |
|
1939 TInt removeCount = (aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionRemoveMediaCount)); |
|
1940 |
|
1941 // remove all in one shut if removeCount is 0 or negative |
|
1942 if (removeCount <= 0) |
|
1943 { |
|
1944 removeCount = count; |
|
1945 } |
|
1946 |
|
1947 // If the given path contains multiple selections, remove the first n selected media |
|
1948 // and update the path so that client can use this path to call remove iteratively |
|
1949 // until all selections are processed |
|
1950 // |
|
1951 if (count) |
|
1952 { |
|
1953 for (TInt i = 0; i < removeCount; ++i) |
|
1954 { |
|
1955 TInt index(selectionIndices[i]); |
|
1956 |
|
1957 MPX_DEBUG4(" path: selected item [index %d] [selectioncount %d] [remove count %d]", index, count, removeCount); |
|
1958 |
|
1959 iterationPath->SelectL(index); |
|
1960 path->Remove(index); |
|
1961 } |
|
1962 |
|
1963 aCmd.SetCObjectValueL(KMPXCommandCollectionRemovePath, path); |
|
1964 |
|
1965 // indicate to the client that subsequent remove command is required |
|
1966 if ((count - removeCount) > 0) |
|
1967 { |
|
1968 removeCompleted = EFalse; |
|
1969 } |
|
1970 } |
|
1971 |
|
1972 // Remove the media specified by the path |
|
1973 CDesCArray* fp(NULL); |
|
1974 TBool supressMsgs(EFalse); |
|
1975 CMPXMessageArray* msgAry(NULL); |
|
1976 if (aCmd.IsSupported(KMPXCommandCollectionRemoveSuppressMsgs) && |
|
1977 aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveSuppressMsgs) ) |
|
1978 { |
|
1979 // Msgs are stored in the command |
|
1980 supressMsgs = ETrue; |
|
1981 CMPXMessageArray* msgs( aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionChangeMsgs) ); |
|
1982 User::LeaveIfNull( msgs ); |
|
1983 fp = DoRemoveL(*iterationPath, *msgs ); |
|
1984 } |
|
1985 else |
|
1986 { |
|
1987 // Msgs will be sent after delete |
|
1988 msgAry = CMPXMessageArray::NewL(); |
|
1989 CleanupStack::PushL( msgAry ); |
|
1990 fp = DoRemoveL(*iterationPath, *msgAry); |
|
1991 } |
|
1992 |
|
1993 CleanupStack::PushL(fp); |
|
1994 if (fp->MdcaCount() > removeCount) |
|
1995 { |
|
1996 removeError = KErrCorrupt; |
|
1997 } |
|
1998 CleanupStack::PopAndDestroy(fp); |
|
1999 |
|
2000 if (!supressMsgs) |
|
2001 { |
|
2002 // Send Change Messages |
|
2003 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
2004 DoHandleChangeL(msgAry); |
|
2005 CleanupStack::PopAndDestroy(msgAry); |
|
2006 } |
|
2007 |
|
2008 // Cleanup |
|
2009 CleanupStack::PopAndDestroy(iterationPath); |
|
2010 CleanupStack::PopAndDestroy(path); |
|
2011 } |
|
2012 |
|
2013 // mandatory return parameters |
|
2014 aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveError, removeError); |
|
2015 aCmd.SetTObjectValueL<TBool>(KMPXCommandCollectionRemoveCompleted, removeCompleted); |
|
2016 } |
|
2017 |
|
2018 // ---------------------------------------------------------------------------- |
|
2019 // Remove media by CMPXMedia through a command |
|
2020 // ---------------------------------------------------------------------------- |
|
2021 // |
|
2022 void CMPXPodcastDbPlugin::DoRemoveMediaL( |
|
2023 CMPXCommand& aCmd) |
|
2024 { |
|
2025 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveMediaL(by command)"); |
|
2026 |
|
2027 TInt error(KErrArgument); |
|
2028 |
|
2029 if (aCmd.IsSupported(KMPXCommandCollectionRemoveMedia)) |
|
2030 { |
|
2031 CMPXMedia* media = aCmd.ValueCObjectL<CMPXMedia>(KMPXCommandCollectionRemoveMedia); |
|
2032 CleanupStack::PushL(media); |
|
2033 |
|
2034 MPX_TRAP(error, DoRemoveL(*media, |
|
2035 aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveMediaDeleteRecord))); |
|
2036 |
|
2037 CleanupStack::PopAndDestroy(media); |
|
2038 } |
|
2039 |
|
2040 aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveMediaError, error); |
|
2041 } |
|
2042 |
|
2043 // ---------------------------------------------------------------------------- |
|
2044 // Remove a media/media items from All Episodes view |
|
2045 // ---------------------------------------------------------------------------- |
|
2046 // |
|
2047 void CMPXPodcastDbPlugin::DoRemoveFromAllEpisodesL( |
|
2048 const CMPXCollectionPath& aPath, |
|
2049 const TArray<TMPXItemId>& aSelections, |
|
2050 CDesCArray& aUriArray, |
|
2051 CMPXMessageArray& aItemChangedMessages) |
|
2052 { |
|
2053 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveFromAllEpisodesL"); |
|
2054 |
|
2055 switch (aPath.Levels()) |
|
2056 { |
|
2057 case 2: |
|
2058 { |
|
2059 // when the collection is removed, it's intended not to delete the files |
|
2060 iDbHandler->RemoveEntireCollectionL(); |
|
2061 } |
|
2062 break; |
|
2063 |
|
2064 case 3: |
|
2065 { |
|
2066 TInt count(aSelections.Count()); |
|
2067 if (count) |
|
2068 { |
|
2069 for (TInt i = 0; i < count; ++i) |
|
2070 { |
|
2071 iDbHandler->RemoveEpisodeL (aSelections[i], aUriArray, |
|
2072 aItemChangedMessages); |
|
2073 } // end for |
|
2074 } |
|
2075 else |
|
2076 { |
|
2077 iDbHandler->RemoveEpisodeL(aPath.Id(aPath.Levels() - 1), aUriArray, |
|
2078 aItemChangedMessages); |
|
2079 } |
|
2080 } |
|
2081 break; |
|
2082 |
|
2083 default: |
|
2084 { |
|
2085 MPX_DEBUG2("CMPXPodcastDbPlugin_DoRemoveFromAllEpisodesL: Invalid levels[%d]", aPath.Levels()); |
|
2086 User::Leave(KErrNotSupported); |
|
2087 } |
|
2088 } |
|
2089 } |
|
2090 |
|
2091 // ---------------------------------------------------------------------------- |
|
2092 // Remove a media/media items from By Publish Date view |
|
2093 // ---------------------------------------------------------------------------- |
|
2094 // |
|
2095 void CMPXPodcastDbPlugin::DoRemoveFromPublishDateL( |
|
2096 const CMPXCollectionPath& aPath, |
|
2097 const TArray<TMPXItemId>& aSelections, |
|
2098 CDesCArray& aUriArray, |
|
2099 CMPXMessageArray& aItemChangedMessages) |
|
2100 { |
|
2101 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveFromPublishDateL"); |
|
2102 |
|
2103 TInt levels(aPath.Levels()); |
|
2104 |
|
2105 if (levels == 2) |
|
2106 { |
|
2107 // when the collection is removed, it's intended no to delete the files |
|
2108 iDbHandler->RemoveEntireCollectionL(); |
|
2109 } |
|
2110 else |
|
2111 { |
|
2112 TInt count(aSelections.Count()); |
|
2113 if (count) |
|
2114 { |
|
2115 for (TInt i = 0; i < count; ++i) |
|
2116 { |
|
2117 RemoveFromPublishDateL(aPath, aSelections[i].iId2, aUriArray, aItemChangedMessages); |
|
2118 } |
|
2119 } |
|
2120 else |
|
2121 { |
|
2122 RemoveFromPublishDateL(aPath, aPath.Id(levels - 1).iId2, aUriArray, aItemChangedMessages); |
|
2123 } |
|
2124 } |
|
2125 |
|
2126 MPX_DEBUG2("CMPXPodcastDbPlugin__RemoveL__EBrowsePubDate: levels[%d]", aPath.Levels()); |
|
2127 } |
|
2128 |
|
2129 // ---------------------------------------------------------------------------- |
|
2130 // Remove a media item from By Publish Date view |
|
2131 // ---------------------------------------------------------------------------- |
|
2132 // |
|
2133 void CMPXPodcastDbPlugin::RemoveFromPublishDateL( |
|
2134 const CMPXCollectionPath& aPath, |
|
2135 TInt aItemId, |
|
2136 CDesCArray& aUriArray, |
|
2137 CMPXMessageArray& aItemChangedMessages) |
|
2138 { |
|
2139 MPX_FUNC("CMPXPodcastDbPlugin::RemoveFromPublishDateL"); |
|
2140 |
|
2141 switch (aPath.Levels()) |
|
2142 { |
|
2143 case 3: |
|
2144 { |
|
2145 iDbHandler->RemoveEpisodesMatchingPublishDateCategoryL(aItemId, aUriArray, |
|
2146 aItemChangedMessages); |
|
2147 break; |
|
2148 } |
|
2149 case 4: |
|
2150 { |
|
2151 iDbHandler->RemoveEpisodeL(aItemId, aUriArray, |
|
2152 aItemChangedMessages); |
|
2153 break; |
|
2154 } |
|
2155 default: |
|
2156 { |
|
2157 User::Leave(KErrArgument); |
|
2158 } |
|
2159 } |
|
2160 } |
|
2161 |
|
2162 // ---------------------------------------------------------------------------- |
|
2163 // Remove a media/media items from Titles/Genre etc.. view |
|
2164 // ---------------------------------------------------------------------------- |
|
2165 // |
|
2166 void CMPXPodcastDbPlugin::DoRemoveFromCategoriesL( |
|
2167 const CMPXCollectionPath& aPath, |
|
2168 const TArray<TMPXItemId>& aSelections, |
|
2169 TMPXGeneralCategory aCategory, |
|
2170 CDesCArray& aUriArray, |
|
2171 CMPXMessageArray& aItemChangedMessages) |
|
2172 { |
|
2173 MPX_FUNC("CMPXPodcastDbPlugin::DoRemoveFromCategoriesL"); |
|
2174 |
|
2175 TInt levels(aPath.Levels()); |
|
2176 if (levels == 1) |
|
2177 { |
|
2178 // when the collection is removed, it's intended no to delete the files |
|
2179 iDbHandler->RemoveEntireCollectionL(); |
|
2180 } |
|
2181 else |
|
2182 { |
|
2183 TInt count(aSelections.Count()); |
|
2184 if (count) |
|
2185 { |
|
2186 for (TInt i = 0; i < count; ++i) |
|
2187 { |
|
2188 RemoveFromCategoriesL(aPath, aSelections[i], aCategory, aUriArray, |
|
2189 aItemChangedMessages); |
|
2190 } |
|
2191 } |
|
2192 |
|
2193 else |
|
2194 { |
|
2195 RemoveFromCategoriesL(aPath, aPath.Id (aPath.Levels() - 1), aCategory, aUriArray, |
|
2196 aItemChangedMessages); |
|
2197 } |
|
2198 } |
|
2199 |
|
2200 MPX_DEBUG2("CMPXPodcastDbPlugin_DoRemoveFromCategoriesL: levels[%d]", aPath.Levels()); |
|
2201 } |
|
2202 |
|
2203 // ---------------------------------------------------------------------------- |
|
2204 // Remove a media item from Albums/Genres/Composers view |
|
2205 // ---------------------------------------------------------------------------- |
|
2206 // |
|
2207 void CMPXPodcastDbPlugin::RemoveFromCategoriesL( |
|
2208 const CMPXCollectionPath& aPath, |
|
2209 TInt aItemId, |
|
2210 TMPXGeneralCategory aCategory, |
|
2211 CDesCArray& aUriArray, |
|
2212 CMPXMessageArray& aItemChangedMessages) |
|
2213 { |
|
2214 MPX_FUNC("CMPXPodcastDbPlugin::RemoveFromCategoriesL"); |
|
2215 |
|
2216 switch (aPath.Levels()) |
|
2217 { |
|
2218 case 2: |
|
2219 { |
|
2220 iDbHandler->RemoveEpisodesMatchingCategoryL(aCategory, aItemId, |
|
2221 aUriArray, aItemChangedMessages); |
|
2222 break; |
|
2223 } |
|
2224 case 3: |
|
2225 { |
|
2226 iDbHandler->RemoveEpisodeL(aItemId, aUriArray, aItemChangedMessages); |
|
2227 break; |
|
2228 } |
|
2229 default: |
|
2230 { |
|
2231 User::Leave(KErrArgument); |
|
2232 } |
|
2233 } |
|
2234 } |
|
2235 |
|
2236 // ---------------------------------------------------------------------------- |
|
2237 // Retrieve URIs associated with this file path for file deletion |
|
2238 // ---------------------------------------------------------------------------- |
|
2239 // |
|
2240 void CMPXPodcastDbPlugin::DoRetrieveUriForDeletionL( |
|
2241 CMPXCommand& aCmd) |
|
2242 { |
|
2243 MPX_FUNC("CMPXPodcastDbPlugin::DoRetrieveUriForDeletionL"); |
|
2244 |
|
2245 // initialize mandatory return parameters |
|
2246 aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrNone); |
|
2247 |
|
2248 if (!aCmd.IsSupported(KMPXCommandCollectionRetrievePath)) |
|
2249 { |
|
2250 aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrArgument); |
|
2251 } |
|
2252 else |
|
2253 { |
|
2254 CMPXCollectionPath* path = aCmd.ValueCObjectL<CMPXCollectionPath>( |
|
2255 KMPXCommandCollectionRetrievePath); |
|
2256 CleanupStack::PushL(path); |
|
2257 |
|
2258 if (iFirstDeleteStep ) |
|
2259 { |
|
2260 iSelections.Reset( ); |
|
2261 // in order to support cancel delete for a category, we need to adjust path. If |
|
2262 // the path ends in a category, retrieve all songs under the selected category |
|
2263 // and append a new level with all songs under the selected category |
|
2264 DoAppendLevelL(*path ); |
|
2265 |
|
2266 // Ids of the selected items |
|
2267 path->SelectionL(iSelections ); |
|
2268 |
|
2269 // single selection |
|
2270 if (iSelections.Count()== 0 ) |
|
2271 { |
|
2272 iSelections.AppendL(path->Id (path->Levels()- 1 ) ); |
|
2273 } |
|
2274 } |
|
2275 CDesCArray* fp = new(ELeave) CDesCArrayFlat(4); |
|
2276 CleanupStack::PushL(fp); |
|
2277 |
|
2278 TInt count = iSelections.Count(); |
|
2279 TInt itemCount = count > KIncrementalDeleteCount ? KIncrementalDeleteCount : count; |
|
2280 for (TInt i = 0; i < itemCount; ++i) |
|
2281 { |
|
2282 HBufC* uri = iDbHandler->GetUriMatchingIdL(iSelections[0]); |
|
2283 CleanupStack::PushL(uri); |
|
2284 fp->AppendL(*uri); |
|
2285 CleanupStack::PopAndDestroy(uri); |
|
2286 iSelections.Remove(0); |
|
2287 |
|
2288 } |
|
2289 aCmd.SetNoNewLCObjectL (KMPXCommandCollectionRetrieveMediaUriArray, fp); |
|
2290 if (iFirstDeleteStep) |
|
2291 { |
|
2292 aCmd.SetCObjectValueL(KMPXCommandCollectionRetrievePath, path); |
|
2293 } |
|
2294 CleanupStack::PopAndDestroy(fp); |
|
2295 CleanupStack::PopAndDestroy(path); |
|
2296 } |
|
2297 } |
|
2298 |
|
2299 // ---------------------------------------------------------------------------- |
|
2300 // Cleanup deleted medias |
|
2301 // ---------------------------------------------------------------------------- |
|
2302 // |
|
2303 void CMPXPodcastDbPlugin::CleanupDeletedRecordsL( |
|
2304 CMPXCommand& aCmd) |
|
2305 { |
|
2306 MPX_FUNC("CMPXPodcastDbPlugin::CleanupDeletedRecordsL"); |
|
2307 |
|
2308 MPX_TRAPD(error, iDbHandler->CleanupDeletedRecordsL()); |
|
2309 aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionCleanupError, error); |
|
2310 } |
|
2311 |
|
2312 // ---------------------------------------------------------------------------- |
|
2313 // Retrieve the duration |
|
2314 // ---------------------------------------------------------------------------- |
|
2315 // |
|
2316 TInt CMPXPodcastDbPlugin::DoDurationL( |
|
2317 CMPXMedia& aMedia, |
|
2318 TMPXPodcastCategory aCategory, |
|
2319 TMPXItemId aId) |
|
2320 { |
|
2321 MPX_FUNC("CMPXPodcastDbPlugin::DoDurationL"); |
|
2322 |
|
2323 TInt duration(0); |
|
2324 switch (aCategory) |
|
2325 { |
|
2326 case EMPXEpisode: |
|
2327 { |
|
2328 duration = iDbHandler->GetAllEpisodesDurationL(); |
|
2329 break; |
|
2330 } |
|
2331 case EMPXTitle: |
|
2332 { |
|
2333 duration = iDbHandler->GetTitleDurationL(aId.iId2); |
|
2334 break; |
|
2335 } |
|
2336 case EMPXNotYetPlayed: |
|
2337 { |
|
2338 duration = iDbHandler->GetNotPlayedDurationL(); |
|
2339 break; |
|
2340 } |
|
2341 case EMPXRecentlyAdded: |
|
2342 { |
|
2343 duration = iDbHandler->GetRecentlyAddedDurationL(); |
|
2344 break; |
|
2345 } |
|
2346 default: |
|
2347 { |
|
2348 User::Leave(KErrNotSupported); |
|
2349 } |
|
2350 } |
|
2351 |
|
2352 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration); |
|
2353 return duration; |
|
2354 } |
|
2355 |
|
2356 // ---------------------------------------------------------------------------- |
|
2357 // Append a level to a collection path and set selection to the first level |
|
2358 // ---------------------------------------------------------------------------- |
|
2359 // |
|
2360 TInt CMPXPodcastDbPlugin::DoAppendLevelL( |
|
2361 CMPXCollectionPath& aPath, |
|
2362 CMPXMedia& aMedia) |
|
2363 { |
|
2364 MPX_FUNC("CMPXPodcastDbPlugin::DoAppendLevelL"); |
|
2365 |
|
2366 RArray<TMPXItemId> ids; |
|
2367 CleanupClosePushL(ids); |
|
2368 |
|
2369 // Extract media array, and get all item ids |
|
2370 // |
|
2371 const CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
2372 if( !mediaArray ) |
|
2373 { |
|
2374 User::Leave(KErrNoMemory); |
|
2375 } |
|
2376 TInt count(mediaArray->Count()); |
|
2377 |
|
2378 if (count >= 0) |
|
2379 { |
|
2380 for (TInt i = 0; i < count; ++i) |
|
2381 { |
|
2382 TMPXItemId id = mediaArray->AtL(i)->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
2383 ids.AppendL(id); |
|
2384 } |
|
2385 |
|
2386 // Put item id array into the path and select the first one |
|
2387 aPath.AppendL(ids.Array()); |
|
2388 if (count > 0) |
|
2389 { |
|
2390 aPath.Set(0); |
|
2391 } |
|
2392 } |
|
2393 |
|
2394 CleanupStack::PopAndDestroy(&ids); |
|
2395 return count; |
|
2396 } |
|
2397 |
|
2398 // ---------------------------------------------------------------------------- |
|
2399 // Append a level to a collection path and set selection to all episodes under the selected category/categories |
|
2400 // ---------------------------------------------------------------------------- |
|
2401 // |
|
2402 void CMPXPodcastDbPlugin::DoAppendLevelL( |
|
2403 CMPXCollectionPath& aPath) |
|
2404 { |
|
2405 MPX_FUNC("CMPXPodcastDbPlugin::DoAppendLevelL"); |
|
2406 |
|
2407 TMPXItemId contextId(aPath.Id(1)); |
|
2408 TInt levels(aPath.Levels()); |
|
2409 |
|
2410 if (contextId == EBrowseAll) |
|
2411 { |
|
2412 return; |
|
2413 } |
|
2414 else if (levels == 2) |
|
2415 { |
|
2416 // retrieve episodes in the selected category |
|
2417 CMPXMediaArray* episodes = CMPXMediaArray::NewL(); |
|
2418 CleanupStack::PushL(episodes); |
|
2419 |
|
2420 RArray<TMPXAttribute> attributes; |
|
2421 CleanupClosePushL(attributes); |
|
2422 attributes.AppendL(KMPXMediaGeneralId); |
|
2423 |
|
2424 // Ids of the selected items |
|
2425 RArray<TMPXItemId> selections; |
|
2426 CleanupClosePushL(selections); |
|
2427 aPath.SelectionL(selections); |
|
2428 |
|
2429 // single selection |
|
2430 if (selections.Count() == 0) |
|
2431 { |
|
2432 selections.AppendL(aPath.Id(aPath.Levels() - 1)); |
|
2433 } |
|
2434 |
|
2435 TInt count(selections.Count()); |
|
2436 |
|
2437 for (TInt i = 0; i < count; ++i) |
|
2438 { |
|
2439 iDbHandler->GetEpisodesMatchingTitleL(selections[i], attributes.Array(), *episodes); |
|
2440 } |
|
2441 |
|
2442 CleanupStack::PopAndDestroy(2, &attributes); // selections & attributes |
|
2443 |
|
2444 // transform from CMPXMediaArray to RArray |
|
2445 RArray<TMPXItemId> episodeIds; |
|
2446 CleanupClosePushL(episodeIds); |
|
2447 |
|
2448 TInt episodeCount(episodes->Count()); |
|
2449 for (TInt i = 0; i < episodeCount; ++i) |
|
2450 { |
|
2451 CMPXMedia* episode = (*episodes)[i]; |
|
2452 |
|
2453 if (episode->IsSupported(KMPXMediaGeneralId)) |
|
2454 { |
|
2455 episodeIds.AppendL(episode->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
2456 } |
|
2457 } |
|
2458 |
|
2459 // modify the collection path. append another level with all episodes under the selected |
|
2460 // category/categories selected |
|
2461 episodeCount = episodeIds.Count(); |
|
2462 |
|
2463 if (episodeCount) |
|
2464 { |
|
2465 aPath.ClearSelection(); |
|
2466 aPath.AppendL(episodeIds.Array()); |
|
2467 |
|
2468 // select all |
|
2469 for (TInt i = 0; i < episodeCount; ++i) |
|
2470 { |
|
2471 aPath.SelectL(episodeIds[i]); |
|
2472 } |
|
2473 } |
|
2474 |
|
2475 CleanupStack::PopAndDestroy(2, episodes); // episodeIds & episodes |
|
2476 } |
|
2477 else |
|
2478 { |
|
2479 // else do nothing |
|
2480 } |
|
2481 } |
|
2482 |
|
2483 // ---------------------------------------------------------------------------- |
|
2484 // Execute an Add task step |
|
2485 // ---------------------------------------------------------------------------- |
|
2486 // |
|
2487 TBool CMPXPodcastDbPlugin::DoAddAsyncL() |
|
2488 { |
|
2489 MPX_FUNC("CMPXPodcastDbPlugin::DoAddAsyncL"); |
|
2490 |
|
2491 TBool done(EFalse); |
|
2492 CMPXMedia* task = iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColAddMedia); |
|
2493 User::LeaveIfNull(task); |
|
2494 |
|
2495 CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages(); |
|
2496 |
|
2497 if (!task->IsSupported(KMPXMediaGeneralType)) |
|
2498 { |
|
2499 User::Leave(KErrArgument); |
|
2500 } |
|
2501 |
|
2502 // Group of items or a single item |
|
2503 // |
|
2504 if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
|
2505 { |
|
2506 if(!task->IsSupported(KMPXMediaArrayContents)) |
|
2507 { |
|
2508 User::Leave(KErrArgument); |
|
2509 } |
|
2510 |
|
2511 CMPXMediaArray* ary = task->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
2512 User::LeaveIfNull( ary ); |
|
2513 |
|
2514 TInt step( iActiveTask->GetStep() ); |
|
2515 DoAddItemL(*ary->AtL(step), msgArray); |
|
2516 |
|
2517 if (++step == ary->Count()) |
|
2518 { |
|
2519 done = ETrue; |
|
2520 } |
|
2521 } |
|
2522 else // type == EMPXItem |
|
2523 { |
|
2524 TUint32 item = DoAddItemL( *task, msgArray ); |
|
2525 iActiveTask->GetCommand().SetTObjectValueL<TMPXItemId>( KMPXCommandColAddRtnId, item ); |
|
2526 done = ETrue; |
|
2527 } |
|
2528 |
|
2529 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
2530 return done; |
|
2531 } |
|
2532 |
|
2533 // ---------------------------------------------------------------------------- |
|
2534 // Add an item to the collection |
|
2535 // ---------------------------------------------------------------------------- |
|
2536 // |
|
2537 TUint32 CMPXPodcastDbPlugin::DoAddL( |
|
2538 const CMPXMedia& aMedia) |
|
2539 { |
|
2540 MPX_FUNC("CMPXPodcastDbPlugin::DoAddL"); |
|
2541 |
|
2542 TUint32 itemId(0); |
|
2543 CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL(); |
|
2544 CleanupStack::PushL( changeMsgAry ); |
|
2545 |
|
2546 if (!aMedia.IsSupported(KMPXMediaGeneralType)) |
|
2547 { |
|
2548 User::Leave(KErrArgument); |
|
2549 } |
|
2550 |
|
2551 // Group of items |
|
2552 // |
|
2553 if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
|
2554 { |
|
2555 CMPXMediaArray* ary = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
2556 User::LeaveIfNull( ary ); |
|
2557 |
|
2558 TInt count(ary->Count()); |
|
2559 for (TInt i = 0; i < count; ++i) |
|
2560 { |
|
2561 DoAddItemL(*ary->AtL(i), *changeMsgAry); |
|
2562 } |
|
2563 } |
|
2564 else // single item |
|
2565 { |
|
2566 itemId = DoAddItemL(aMedia, *changeMsgAry); |
|
2567 } |
|
2568 |
|
2569 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
2570 DoHandleChangeL(changeMsgAry); |
|
2571 CleanupStack::PopAndDestroy(changeMsgAry); |
|
2572 |
|
2573 return itemId; |
|
2574 } |
|
2575 |
|
2576 // ---------------------------------------------------------------------------- |
|
2577 // Add an item to the collection |
|
2578 // ---------------------------------------------------------------------------- |
|
2579 // |
|
2580 TUint32 CMPXPodcastDbPlugin::DoAddItemL( |
|
2581 const CMPXMedia& aMedia, |
|
2582 CMPXMessageArray& aMessageArray) |
|
2583 { |
|
2584 MPX_FUNC("CMPXPodcastDbPlugin::DoAddItemL"); |
|
2585 |
|
2586 TInt itemId(0); |
|
2587 |
|
2588 if (!aMedia.IsSupported(KMPXMediaGeneralCategory)) |
|
2589 { |
|
2590 User::Leave(KErrArgument); |
|
2591 } |
|
2592 |
|
2593 switch ( aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory)) |
|
2594 { |
|
2595 case EMPXPodcast: |
|
2596 case EMPXSong: |
|
2597 { |
|
2598 itemId = iDbHandler->AddEpisodeL(aMedia); |
|
2599 MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemInserted, |
|
2600 EMPXPodcast, KDBPluginUid); |
|
2601 break; |
|
2602 } |
|
2603 default: |
|
2604 { |
|
2605 User::Leave(KErrNotSupported); |
|
2606 } |
|
2607 } |
|
2608 |
|
2609 return itemId; |
|
2610 } |
|
2611 // ---------------------------------------------------------------------------- |
|
2612 // Sets/updates the media for an item in the collection |
|
2613 // ---------------------------------------------------------------------------- |
|
2614 // |
|
2615 void CMPXPodcastDbPlugin::DoSetL( |
|
2616 const CMPXMedia& aMedia) |
|
2617 { |
|
2618 MPX_FUNC("CMPXPodcastDbPlugin::DoSetL"); |
|
2619 |
|
2620 if (!aMedia.IsSupported(KMPXMediaGeneralType) || |
|
2621 !aMedia.IsSupported(KMPXMediaGeneralCategory)) |
|
2622 { |
|
2623 User::Leave(KErrArgument); |
|
2624 } |
|
2625 |
|
2626 CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile); |
|
2627 |
|
2628 switch ( aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory)) |
|
2629 { |
|
2630 case EMPXPodcast: |
|
2631 case EMPXSong: |
|
2632 { |
|
2633 // a list of changed messages as a result of the episode being updated |
|
2634 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
|
2635 CleanupStack::PushL(itemChangedMessages); |
|
2636 |
|
2637 if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
|
2638 { |
|
2639 if (!aMedia.IsSupported(KMPXMediaArrayContents)) |
|
2640 { |
|
2641 User::Leave(KErrArgument); |
|
2642 } |
|
2643 |
|
2644 CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
2645 User::LeaveIfNull( array ); |
|
2646 |
|
2647 TInt count(array->Count()); |
|
2648 for (TInt i = 0; i < count; ++i) |
|
2649 { |
|
2650 visibleChange = (CMPXDbActiveTask::TChangeVisibility)(visibleChange | |
|
2651 iDbHandler->UpdateEpisodeL(*array->AtL(i), *itemChangedMessages)); |
|
2652 } |
|
2653 } |
|
2654 else |
|
2655 { |
|
2656 visibleChange = iDbHandler->UpdateEpisodeL(aMedia, |
|
2657 *itemChangedMessages); |
|
2658 } |
|
2659 |
|
2660 if (visibleChange) |
|
2661 { |
|
2662 iActiveTask->SetVisibleChange(visibleChange); |
|
2663 DoHandleChangeL(itemChangedMessages); |
|
2664 } |
|
2665 |
|
2666 CleanupStack::PopAndDestroy(itemChangedMessages); |
|
2667 } |
|
2668 break; |
|
2669 |
|
2670 default: |
|
2671 { |
|
2672 User::Leave(KErrNotSupported); |
|
2673 } |
|
2674 break; |
|
2675 } |
|
2676 } |
|
2677 |
|
2678 // ---------------------------------------------------------------------------- |
|
2679 // Execute a task step for async set |
|
2680 // ---------------------------------------------------------------------------- |
|
2681 // |
|
2682 TBool CMPXPodcastDbPlugin::DoSetAsyncL() |
|
2683 { |
|
2684 MPX_FUNC("CMPXPodcastDbPlugin::DoSetAsyncL"); |
|
2685 |
|
2686 TBool done(EFalse); |
|
2687 CMPXMedia* task = (iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColSetMedia)); |
|
2688 User::LeaveIfNull( task ); |
|
2689 |
|
2690 CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages(); |
|
2691 CMPXDbActiveTask::TChangeVisibility visibleChange(iActiveTask->GetVisibleChange()); |
|
2692 |
|
2693 // Multiple steps can be in a transaction for faster response |
|
2694 if( iDbHandler && !iDbHandler->InTransaction() ) |
|
2695 { |
|
2696 iDbHandler->BeginTransactionL(); |
|
2697 } |
|
2698 |
|
2699 if (!task->IsSupported(KMPXMediaGeneralType)) |
|
2700 { |
|
2701 User::Leave(KErrArgument); |
|
2702 } |
|
2703 |
|
2704 if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
|
2705 { |
|
2706 if (!task->IsSupported(KMPXMediaArrayContents)) |
|
2707 { |
|
2708 User::Leave(KErrArgument); |
|
2709 } |
|
2710 |
|
2711 // Multiple items |
|
2712 CMPXMediaArray* array = task->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
2713 User::LeaveIfNull( array ); |
|
2714 |
|
2715 TInt step = iActiveTask->GetStep(); |
|
2716 visibleChange = (CMPXDbActiveTask::TChangeVisibility)( visibleChange | iDbHandler->UpdateEpisodeL(*array->AtL(step), msgArray)); |
|
2717 |
|
2718 if (++step == array->Count()) |
|
2719 { |
|
2720 done = ETrue; |
|
2721 } |
|
2722 } |
|
2723 else // Single item |
|
2724 { |
|
2725 if(iDbHandler) |
|
2726 { |
|
2727 visibleChange = iDbHandler->UpdateEpisodeL(*task, msgArray); |
|
2728 done = ETrue; |
|
2729 } |
|
2730 } |
|
2731 iActiveTask->SetVisibleChange(visibleChange); |
|
2732 return done; |
|
2733 } |
|
2734 |
|
2735 // ---------------------------------------------------------------------------- |
|
2736 // Handle change events |
|
2737 // ---------------------------------------------------------------------------- |
|
2738 // |
|
2739 void CMPXPodcastDbPlugin::HandleChangeL( |
|
2740 const CMPXMessage& aMessage) |
|
2741 { |
|
2742 MPX_FUNC("CMPXPodcastDbPlugin::HandleChange"); |
|
2743 |
|
2744 // check if message is filled |
|
2745 if (aMessage.IsSupported(KMPXMessageGeneralId)) |
|
2746 { |
|
2747 #ifdef _DEBUG |
|
2748 PrintMessagesL(aMessage); |
|
2749 #endif // _DEBUG |
|
2750 if(iRefreshing) |
|
2751 { |
|
2752 if (aMessage.IsSupported(KMPXMessageArrayContents)) |
|
2753 { |
|
2754 const CMPXMessageArray* messageArray = aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents); |
|
2755 if(messageArray) |
|
2756 { |
|
2757 CMPXMessage& message = *((*messageArray)[0]); |
|
2758 TMPXChangeEventType changeType( message.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) ); |
|
2759 TMPXGeneralCategory cat(message.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory)); |
|
2760 if(changeType == EMPXItemInserted && (cat == EMPXPodcast || cat == EMPXSong || cat == EMPXPlaylist)) |
|
2761 { |
|
2762 iObs->HandleMessage(aMessage); |
|
2763 } |
|
2764 } |
|
2765 } |
|
2766 else |
|
2767 { |
|
2768 TMPXChangeEventType changeType( aMessage.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) ); |
|
2769 TMPXGeneralCategory cat(aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory)); |
|
2770 if(changeType == EMPXItemInserted && (cat == EMPXPodcast || cat == EMPXSong || cat == EMPXPlaylist)) |
|
2771 { |
|
2772 iObs->HandleMessage(aMessage); |
|
2773 } |
|
2774 } |
|
2775 } |
|
2776 else |
|
2777 { |
|
2778 if(!iMtpInUse) |
|
2779 { |
|
2780 iObs->HandleMessage(aMessage); |
|
2781 } |
|
2782 } |
|
2783 } |
|
2784 } |
|
2785 |
|
2786 // ---------------------------------------------------------------------------- |
|
2787 // Construct a CMPXMedia and call HandleChange |
|
2788 // ---------------------------------------------------------------------------- |
|
2789 // |
|
2790 void CMPXPodcastDbPlugin::DoHandleChangeL( |
|
2791 CMPXMessageArray* aItemChangedMessages) |
|
2792 { |
|
2793 MPX_FUNC("CMPXPodcastDbPlugin::DoHandleChangeL"); |
|
2794 |
|
2795 TMPXCommandId cmdId = iActiveTask->GetTask(); |
|
2796 if((iActiveTask->GetVisibleChange() & CMPXDbActiveTask::EAllVisible) |
|
2797 && (cmdId == KMPXCommandIdCollectionSet || |
|
2798 cmdId == KMPXCommandIdCollectionAdd || |
|
2799 cmdId == KMPXCommandIdCollectionRemove || |
|
2800 cmdId == KMPXCommandIdCollectionRemoveMedia || |
|
2801 cmdId == KMPXCommandIdCollectionCompleteDelete )) |
|
2802 { |
|
2803 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, EBrowseAll, |
|
2804 EMPXItemModified, EMPXCollection, KDBPluginUid); |
|
2805 } |
|
2806 |
|
2807 // group change messages and send to collection client context |
|
2808 CMPXMessage* message = CMPXMessage::NewL(); |
|
2809 CleanupStack::PushL(message); |
|
2810 |
|
2811 message->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KMPXMessageIdItemChanged); |
|
2812 message->SetCObjectValueL(KMPXMessageArrayContents, aItemChangedMessages); |
|
2813 message->SetTObjectValueL<TInt>(KMPXMessageArrayCount, aItemChangedMessages->Count()); |
|
2814 |
|
2815 HandleChangeL(*message); |
|
2816 |
|
2817 CleanupStack::PopAndDestroy(message); |
|
2818 } |
|
2819 |
|
2820 // ---------------------------------------------------------------------------- |
|
2821 // Handle out of disk events during db merging |
|
2822 // ---------------------------------------------------------------------------- |
|
2823 // |
|
2824 void CMPXPodcastDbPlugin::HandleOutOfDiskMessageL() |
|
2825 { |
|
2826 MPX_FUNC("CMPXPodcastDbPlugin::HandleOutOfDiskMessageL"); |
|
2827 |
|
2828 if (iObs) |
|
2829 { |
|
2830 // Create the msg |
|
2831 CMPXMessage* msg = CMPXMessage::NewL(); |
|
2832 CleanupStack::PushL( msg ); |
|
2833 |
|
2834 // Setup the message parameters |
|
2835 msg->SetTObjectValueL<TInt>(KMPXMessageGeneralId, KMPXCustomMessageId); |
|
2836 msg->SetTObjectValueL<TInt>(KMPXCustomMessageCollectionId, KDBPluginUid); |
|
2837 msg->SetTObjectValueL<TInt>(KMPXCustomMessageEventType, EMcsOpen); |
|
2838 msg->SetTObjectValueL<TInt>(KMPXCustomMessageErrorCode, KErrDiskFull); |
|
2839 |
|
2840 // Callback and Cleanup |
|
2841 iObs->HandleMessage(*msg); |
|
2842 CleanupStack::PopAndDestroy(msg); |
|
2843 } |
|
2844 } |
|
2845 |
|
2846 // ---------------------------------------------------------------------------- |
|
2847 // Handle completion of operation |
|
2848 // ---------------------------------------------------------------------------- |
|
2849 // |
|
2850 void CMPXPodcastDbPlugin::DoHandleOperationCompletedL( |
|
2851 TInt aErr) |
|
2852 { |
|
2853 MPX_FUNC("CMPXPodcastDbPlugin::DoHandleOperationCompletedL"); |
|
2854 |
|
2855 if( iDbHandler && iDbHandler->InTransaction() ) |
|
2856 { |
|
2857 // Commit if cancelled |
|
2858 TInt err(aErr); |
|
2859 if( err == KErrCancel ) |
|
2860 { |
|
2861 err = KErrNone; |
|
2862 } |
|
2863 iDbHandler->EndTransactionL( err ); |
|
2864 } |
|
2865 |
|
2866 // Broadcase change messages |
|
2867 // |
|
2868 if (iActiveTask->GetVisibleChange()) |
|
2869 { |
|
2870 DoHandleChangeL(&iActiveTask->GetChangeMessages()); |
|
2871 } |
|
2872 |
|
2873 // Callback to engine to signal completion |
|
2874 // NOTE: Collection server immediately completes the async message when |
|
2875 // Cancel is called, no need to callback to observer |
|
2876 if (aErr != KErrCancel) |
|
2877 { |
|
2878 iObs->HandleCommandComplete(NULL, aErr); |
|
2879 } |
|
2880 } |
|
2881 |
|
2882 |
|
2883 // ---------------------------------------------------------------------------------------------------------- |
|
2884 // Complete a delete operation |
|
2885 // ---------------------------------------------------------------------------------------------------------- |
|
2886 // |
|
2887 void CMPXPodcastDbPlugin::DoHandleDeleteCompleteL( |
|
2888 CMPXCommand& aCmd) |
|
2889 { |
|
2890 MPX_FUNC("CMPXPodcastDbPlugin::DoHandleDeleteCompleteL"); |
|
2891 iFirstDeleteStep = ETrue; |
|
2892 iSelections.Reset(); |
|
2893 // Change messages |
|
2894 if (aCmd.IsSupported(KMPXCommandCollectionDeleteMsgArray)) |
|
2895 { |
|
2896 CMPXMessageArray* msgs = aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionDeleteMsgArray); |
|
2897 User::LeaveIfNull( msgs ); |
|
2898 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
|
2899 DoHandleChangeL(msgs); |
|
2900 } |
|
2901 } |
|
2902 |
|
2903 // ---------------------------------------------------------------------------- |
|
2904 // Maps a given browse type to a category ID. |
|
2905 // ---------------------------------------------------------------------------- |
|
2906 // |
|
2907 TMPXPodcastCategory CMPXPodcastDbPlugin::CategoryForBrowseType( |
|
2908 TMCBrowseType aBrowseType) |
|
2909 { |
|
2910 MPX_FUNC("CMPXPodcastDbPlugin::CategoryForBrowseType"); |
|
2911 |
|
2912 TMPXPodcastCategory cat(EMPXUnknown); |
|
2913 |
|
2914 switch (aBrowseType) |
|
2915 { |
|
2916 case EBrowseAll: |
|
2917 { |
|
2918 cat = EMPXAll; |
|
2919 break; |
|
2920 } |
|
2921 case EBrowseTitle: |
|
2922 { |
|
2923 cat = EMPXTitle; |
|
2924 break; |
|
2925 } |
|
2926 case EBrowsePubDate: |
|
2927 { |
|
2928 cat = EMPXPubDate; |
|
2929 break; |
|
2930 } |
|
2931 case EBrowseRecentlyAdded: |
|
2932 { |
|
2933 cat = EMPXRecentlyAdded; |
|
2934 break; |
|
2935 } |
|
2936 case EBrowseNotPlayed: |
|
2937 { |
|
2938 cat = EMPXNotYetPlayed; |
|
2939 break; |
|
2940 } |
|
2941 default: |
|
2942 { |
|
2943 // do nothing |
|
2944 break; |
|
2945 } |
|
2946 } |
|
2947 |
|
2948 return cat; |
|
2949 } |
|
2950 |
|
2951 // ---------------------------------------------------------------------------- |
|
2952 // Maps a given category ID to a browse type. |
|
2953 // ---------------------------------------------------------------------------- |
|
2954 // |
|
2955 TMCBrowseType CMPXPodcastDbPlugin::BrowseTypeForCategory( |
|
2956 TMPXPodcastCategory aCategory) |
|
2957 { |
|
2958 MPX_FUNC("CMPXPodcastDbPlugin::BrowseTypeForCategory"); |
|
2959 |
|
2960 TMCBrowseType browseType(EBrowseNotPlayed); |
|
2961 |
|
2962 switch (aCategory) |
|
2963 { |
|
2964 case EMPXAll: |
|
2965 { |
|
2966 browseType = EBrowseAll; |
|
2967 break; |
|
2968 } |
|
2969 case EMPXTitle: |
|
2970 { |
|
2971 browseType = EBrowseTitle; |
|
2972 break; |
|
2973 } |
|
2974 case EMPXPubDate: |
|
2975 { |
|
2976 browseType = EBrowsePubDate; |
|
2977 break; |
|
2978 } |
|
2979 case EMPXRecentlyAdded: |
|
2980 { |
|
2981 browseType = EBrowseRecentlyAdded; |
|
2982 break; |
|
2983 } |
|
2984 default: |
|
2985 { |
|
2986 // do nothing |
|
2987 break; |
|
2988 } |
|
2989 } |
|
2990 |
|
2991 return browseType; |
|
2992 } |
|
2993 |
|
2994 // ---------------------------------------------------------------------------- |
|
2995 // Sets the type, category and title attributes in the specified media instance |
|
2996 // ---------------------------------------------------------------------------- |
|
2997 // |
|
2998 void CMPXPodcastDbPlugin::SetMediaGeneralAttributesL( |
|
2999 CMPXMedia& aMedia, |
|
3000 TMPXGeneralType aGeneralType, |
|
3001 TMPXPodcastType aType, |
|
3002 TMPXPodcastCategory aCategory, |
|
3003 const TDesC& aTitle, |
|
3004 TInt aCount /* = -1 */) |
|
3005 { |
|
3006 MPX_FUNC("CMPXPodcastDbPlugin::SetMediaGeneralAttributesL"); |
|
3007 |
|
3008 aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, aGeneralType); |
|
3009 aMedia.SetTObjectValueL<TMPXPodcastType>(KMPXMediaPodcastType, aType); |
|
3010 aMedia.SetTObjectValueL<TMPXPodcastCategory>(KMPXMediaPodcastCategoryGroup, aCategory); |
|
3011 aMedia.SetTextValueL(KMPXMediaGeneralTitle, aTitle); |
|
3012 |
|
3013 if (aCount >= 0) |
|
3014 { |
|
3015 aMedia.SetTObjectValueL(KMPXMediaGeneralCount, aCount); |
|
3016 } |
|
3017 } |
|
3018 |
|
3019 // ---------------------------------------------------------------------------- |
|
3020 // Sets the type, category and title attributes in the specified media instance |
|
3021 // ---------------------------------------------------------------------------- |
|
3022 // |
|
3023 void CMPXPodcastDbPlugin::SetMediaGeneralAttributesL( |
|
3024 CMPXMedia& aMedia, |
|
3025 TMPXGeneralType aGeneralType, |
|
3026 TMPXPodcastType aType, |
|
3027 TMPXPodcastCategory aCategory, |
|
3028 TInt aId, |
|
3029 TInt aCount /* = -1 */) |
|
3030 { |
|
3031 MPX_FUNC("CMPXPodcastDbPlugin::SetMediaGeneralAttributesL"); |
|
3032 |
|
3033 HBufC* title = iDbHandler->GetTitleNameMatchingIdL(aId); |
|
3034 CleanupStack::PushL(title); |
|
3035 SetMediaGeneralAttributesL(aMedia, aGeneralType, aType, aCategory, *title, aCount); |
|
3036 CleanupStack::PopAndDestroy(title); |
|
3037 } |
|
3038 |
|
3039 // ---------------------------------------------------------------------------------------------------------- |
|
3040 // Get total podcast count for a database |
|
3041 // ---------------------------------------------------------------------------------------------------------- |
|
3042 // |
|
3043 void CMPXPodcastDbPlugin::DoGetCollectionCountL( const CMPXCommand& aCmd ) |
|
3044 { |
|
3045 MPX_FUNC("CMPXPodcastDbPlugin::DoGetCollectionCountL"); |
|
3046 //as there is only one table containing uri data, KMPXCommandCollectionCountTable is ignored |
|
3047 if (!aCmd.IsSupported(KMPXCommandCollectionCountDrive)) |
|
3048 { |
|
3049 User::Leave(KErrArgument); |
|
3050 } |
|
3051 |
|
3052 TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionCountDrive); |
|
3053 TInt count = (TInt)iDbHandler->GetTotalCountL(drive); |
|
3054 ((CMPXMedia&)aCmd).SetTObjectValueL<TInt>(KMPXCommandCollectionCountValue, count); |
|
3055 } |
|
3056 |
|
3057 // ---------------------------------------------------------------------------------------------------------- |
|
3058 // Get URIs for all podcasts in a database |
|
3059 // ---------------------------------------------------------------------------------------------------------- |
|
3060 // |
|
3061 void CMPXPodcastDbPlugin::DoGetCollectionUriL( const CMPXCommand& aCmd ) |
|
3062 { |
|
3063 MPX_FUNC("CMPXPodcastDbPlugin::DoGetCollectionCountL"); |
|
3064 //as there is only one table containing uri data, KMPXCommandCollectionCountTable is ignored |
|
3065 if (!aCmd.IsSupported(KMPXCommandCollectionURIDrive) || |
|
3066 !aCmd.IsSupported(KMPXCommandCollectionURIFromID) || |
|
3067 !aCmd.IsSupported(KMPXCommandCollectionURIRecords) ) |
|
3068 { |
|
3069 User::Leave(KErrArgument); |
|
3070 } |
|
3071 |
|
3072 TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIDrive); |
|
3073 TInt fromID = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIFromID); |
|
3074 TInt recnum = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIRecords); |
|
3075 |
|
3076 CDesCArray* uris = new(ELeave) CDesCArrayFlat(4); |
|
3077 CleanupStack::PushL(uris); |
|
3078 TInt lastID = 0; |
|
3079 |
|
3080 iDbHandler->GetPodcastUriArrayL(drive, fromID, recnum, *uris, lastID); |
|
3081 |
|
3082 ((CMPXMedia&)aCmd).SetNoNewLCObjectL(KMPXCommandCollectionURIList, uris); |
|
3083 ((CMPXMedia&)aCmd).SetTObjectValueL(KMPXCommandCollectionURILastID, lastID); |
|
3084 CleanupStack::PopAndDestroy(uris); |
|
3085 } |
|
3086 |
|
3087 void CMPXPodcastDbPlugin::SetAttributesL( |
|
3088 const CMPXCollectionPath& aPath, |
|
3089 RArray<TMPXAttribute>& aAttrs, |
|
3090 RArray<TInt>& aSupportedIds ) |
|
3091 { |
|
3092 aAttrs.AppendL(TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralTitle | |
|
3093 EMPXMediaGeneralDuration | EMPXMediaGeneralSize | |
|
3094 EMPXMediaGeneralType | EMPXMediaGeneralCategory | EMPXMediaGeneralId | |
|
3095 EMPXMediaGeneralUri | EMPXMediaGeneralFlags | EMPXMediaGeneralCount | |
|
3096 EMPXMediaGeneralPlayCount | EMPXMediaGeneralLastPlaybackPosition | |
|
3097 EMPXMediaGeneralCollectionId | EMPXMediaGeneralDate)); |
|
3098 |
|
3099 aAttrs.AppendL(TMPXAttribute(KMPXMediaIdPodcast, |
|
3100 EMPXMediaPodcastType | EMPXMediaPodcastCategoryGroup | EMPXMediaPodcastIsPlaying)); |
|
3101 |
|
3102 aSupportedIds.AppendL(KMPXMediaIdContainer); |
|
3103 aSupportedIds.AppendL(KMPXMediaIdGeneral); |
|
3104 aSupportedIds.AppendL(KMPXMediaIdPodcast); |
|
3105 |
|
3106 TInt levels(aPath.Levels()); |
|
3107 if ( 1 < levels ) |
|
3108 { |
|
3109 // All episodes in a title |
|
3110 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) ); |
|
3111 aSupportedIds.AppendL( KMPXMediaIdMusic ); |
|
3112 } |
|
3113 } |
|
3114 |
|
3115 #ifdef _DEBUG |
|
3116 |
|
3117 // ---------------------------------------------------------------------------- |
|
3118 // Print change events |
|
3119 // ---------------------------------------------------------------------------- |
|
3120 // |
|
3121 void CMPXPodcastDbPlugin::PrintMessagesL( |
|
3122 const CMPXMessage& aMessage) |
|
3123 { |
|
3124 MPX_FUNC("CMPXPodcastDbPlugin::PrintMessages"); |
|
3125 |
|
3126 if (aMessage.IsSupported(KMPXMessageArrayContents)) |
|
3127 { |
|
3128 const CMPXMessageArray* messageArray = |
|
3129 aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents); |
|
3130 if( !messageArray ) |
|
3131 { |
|
3132 User::Leave( KErrNoMemory ); |
|
3133 } |
|
3134 |
|
3135 TInt count(messageArray->Count()); |
|
3136 MPX_DEBUG2("%d messages:", count); |
|
3137 |
|
3138 for (TInt i = 0; i < count; ++i) |
|
3139 { |
|
3140 PrintMessage(*((*messageArray)[i])); |
|
3141 } |
|
3142 } |
|
3143 else |
|
3144 { |
|
3145 PrintMessage(aMessage); |
|
3146 } |
|
3147 } |
|
3148 |
|
3149 // ---------------------------------------------------------------------------- |
|
3150 // Print one change event |
|
3151 // ---------------------------------------------------------------------------- |
|
3152 // |
|
3153 void CMPXPodcastDbPlugin::PrintMessage( |
|
3154 const CMPXMessage& aMessage) |
|
3155 { |
|
3156 MPX_FUNC("CMPXPodcastDbPlugin::PrintMessage"); |
|
3157 |
|
3158 if (aMessage.IsSupported(KMPXMessageGeneralId)) |
|
3159 { |
|
3160 TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageGeneralId); |
|
3161 MPX_DEBUG3(" message id[0x%x, 0x%x]", id.iId1, id.iId2); |
|
3162 } |
|
3163 |
|
3164 if (aMessage.IsSupported(KMPXMessageCollectionId)) |
|
3165 { |
|
3166 TUid uid = aMessage.ValueTObjectL<TUid>(KMPXMessageCollectionId); |
|
3167 MPX_DEBUG2(" uid [0x%x]", uid.iUid); |
|
3168 } |
|
3169 |
|
3170 if (aMessage.IsSupported(KMPXMessageChangeEventType)) |
|
3171 { |
|
3172 MPX_DEBUG2(" change event type [%d]", |
|
3173 aMessage.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType)); |
|
3174 } |
|
3175 |
|
3176 if (aMessage.IsSupported(KMPXMessageMediaGeneralCategory)) |
|
3177 { |
|
3178 MPX_DEBUG2(" category [%d]", |
|
3179 aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory)); |
|
3180 } |
|
3181 |
|
3182 if (aMessage.IsSupported(KMPXMessageMediaGeneralId)) |
|
3183 { |
|
3184 TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
|
3185 MPX_DEBUG3(" media id[0x%x, 0x%x]", id.iId1, id.iId2); |
|
3186 } |
|
3187 |
|
3188 if (aMessage.IsSupported(KMPXMessageMediaDeprecatedId)) |
|
3189 { |
|
3190 TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
|
3191 MPX_DEBUG3(" deprecated id [0x%x, 0x%x]", id.iId1, id.iId2); |
|
3192 } |
|
3193 } |
|
3194 |
|
3195 #endif// _DEBUG |
|
3196 |
|
3197 // End of file |