mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp
changeset 25 3ec52facab4d
parent 22 ecf06a08d4d9
child 45 612c4815aebe
equal deleted inserted replaced
22:ecf06a08d4d9 25:3ec52facab4d
    20 #include <e32cmn.h>
    20 #include <e32cmn.h>
    21 #include <PCRes.rsg>
    21 #include <PCRes.rsg>
    22 #include <bautils.h>
    22 #include <bautils.h>
    23 #include <data_caging_path_literals.hrh>
    23 #include <data_caging_path_literals.hrh>
    24 
    24 
    25 //#include <mpxpodcastdbplugin.mbg>
       
    26 #include <mpxcmn.h>
    25 #include <mpxcmn.h>
    27 #include <mpxcollectionpluginobserver.h>
    26 #include <mpxcollectionpluginobserver.h>
    28 #include <mpxmediacontainerdefs.h>
    27 #include <mpxmediacontainerdefs.h>
    29 #include <mpxmediamusicdefs.h>
    28 #include <mpxmediamusicdefs.h>
    30 #include <mpxmediaaudiodefs.h>
    29 #include <mpxmediaaudiodefs.h>
   336                 User::LeaveIfError ( DriveInfo::GetUserVisibleDrives ( iFs, driveArray));
   335                 User::LeaveIfError ( DriveInfo::GetUserVisibleDrives ( iFs, driveArray));
   337                 TInt count( driveArray.Count ());
   336                 TInt count( driveArray.Count ());
   338                 for (TInt i=0; i<count; ++i)
   337                 for (TInt i=0; i<count; ++i)
   339                     {
   338                     {
   340                     MPX_DEBUG2("At drive %i", driveArray[i]);
   339                     MPX_DEBUG2("At drive %i", driveArray[i]);
   341                     if ((driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i]))))
   340                     if ((driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
   342                         {
   341                         {
   343                         MPX_DEBUG2("Closing database %i", driveArray[i]);
   342                         MPX_DEBUG2("Closing database %i", driveArray[i]);
   344                         TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) );
   343                         TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) );
   345                         }
   344                         }
   346                     }
   345                     }
   364             User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) );
   363             User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) );
   365             TInt count( driveArray.Count() );
   364             TInt count( driveArray.Count() );
   366             for( TInt i=0; i<count; ++i )
   365             for( TInt i=0; i<count; ++i )
   367                 {
   366                 {
   368                 MPX_DEBUG2("At drive %i", driveArray[i]);
   367                 MPX_DEBUG2("At drive %i", driveArray[i]);
   369                 if (( driveArray[i] != EDriveC ) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i]))))
   368                 if (( driveArray[i] != EDriveC ) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
   370                     {
   369                     {
   371                     TUint driveStatus(0);
   370                     TUint driveStatus(0);
   372                     User::LeaveIfError( DriveInfo::GetDriveStatus(
   371                     User::LeaveIfError( DriveInfo::GetDriveStatus(
   373                         iFs, driveArray[i], driveStatus ) );
   372                         iFs, driveArray[i], driveStatus ) );
   374                     if( driveStatus & DriveInfo::EDrivePresent )
   373                     if( driveStatus & DriveInfo::EDrivePresent )
   736     MPX_FUNC("CMPXPodcastDbPlugin::DoOpenL");
   735     MPX_FUNC("CMPXPodcastDbPlugin::DoOpenL");
   737 
   736 
   738     CMPXMediaArray* array = CMPXMediaArray::NewL();
   737     CMPXMediaArray* array = CMPXMediaArray::NewL();
   739     CleanupStack::PushL(array);
   738     CleanupStack::PushL(array);
   740 
   739 
   741 //    TInt count(0);
       
   742     TInt levels(aPath.Levels());
   740     TInt levels(aPath.Levels());
   743     TBool isEpisode(EFalse);
   741     TBool isEpisode(EFalse);
   744 
   742 
   745     aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
   743     aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
   746 
   744 
  2283             HBufC* uri = iDbHandler->GetUriMatchingIdL(iSelections[0]);
  2281             HBufC* uri = iDbHandler->GetUriMatchingIdL(iSelections[0]);
  2284             CleanupStack::PushL(uri);
  2282             CleanupStack::PushL(uri);
  2285             fp->AppendL(*uri);
  2283             fp->AppendL(*uri);
  2286             CleanupStack::PopAndDestroy(uri);
  2284             CleanupStack::PopAndDestroy(uri);
  2287             iSelections.Remove(0);
  2285             iSelections.Remove(0);
  2288 
  2286             
  2289             }
  2287             }
  2290         aCmd.SetNoNewLCObjectL (KMPXCommandCollectionRetrieveMediaUriArray, fp);
  2288         aCmd.SetNoNewLCObjectL (KMPXCommandCollectionRetrieveMediaUriArray, fp);
  2291         if (iFirstDeleteStep)
  2289         if (iFirstDeleteStep)
  2292             {
  2290             {
  2293             aCmd.SetCObjectValueL(KMPXCommandCollectionRetrievePath, path);
  2291             aCmd.SetCObjectValueL(KMPXCommandCollectionRetrievePath, path);
  2721             done = ETrue;
  2719             done = ETrue;
  2722             }
  2720             }
  2723         }
  2721         }
  2724     else // Single item
  2722     else // Single item
  2725         {
  2723         {
  2726         if ( iDbHandler )
  2724         if(iDbHandler)
  2727             {
  2725             {		
  2728             visibleChange = iDbHandler->UpdateEpisodeL(*task, msgArray);
  2726             visibleChange = iDbHandler->UpdateEpisodeL(*task, msgArray);
  2729             done = ETrue;
  2727             done = ETrue;
  2730             }
  2728             }
  2731         }
  2729         }
  2732     iActiveTask->SetVisibleChange(visibleChange);
  2730     iActiveTask->SetVisibleChange(visibleChange);
  2861             {
  2859             {
  2862             err = KErrNone;
  2860             err = KErrNone;
  2863             }
  2861             }
  2864         iDbHandler->EndTransactionL( err );
  2862         iDbHandler->EndTransactionL( err );
  2865         }
  2863         }
  2866 
  2864     
  2867     // Broadcase change messages
  2865     // Broadcase change messages
  2868     //
  2866     //
  2869     if (iActiveTask->GetVisibleChange())
  2867     if (iActiveTask->GetVisibleChange())
  2870         {
  2868         {
  2871         DoHandleChangeL(&iActiveTask->GetChangeMessages());
  2869         DoHandleChangeL(&iActiveTask->GetChangeMessages());
  2875     // NOTE: Collection server immediately completes the async message when
  2873     // NOTE: Collection server immediately completes the async message when
  2876     // Cancel is called, no need to callback to observer
  2874     // Cancel is called, no need to callback to observer
  2877     if (aErr != KErrCancel)
  2875     if (aErr != KErrCancel)
  2878         {
  2876         {
  2879         iObs->HandleCommandComplete(NULL, aErr);
  2877         iObs->HandleCommandComplete(NULL, aErr);
  2880         }
  2878         }    
  2881     }
  2879     }
  2882 
  2880      
  2883 
  2881 
  2884 // ----------------------------------------------------------------------------------------------------------
  2882 // ----------------------------------------------------------------------------------------------------------
  2885 // Complete a delete operation
  2883 // Complete a delete operation
  2886 // ----------------------------------------------------------------------------------------------------------
  2884 // ----------------------------------------------------------------------------------------------------------
  2887 //
  2885 //
  3094         EMPXMediaGeneralDuration | EMPXMediaGeneralSize |
  3092         EMPXMediaGeneralDuration | EMPXMediaGeneralSize |
  3095         EMPXMediaGeneralType | EMPXMediaGeneralCategory | EMPXMediaGeneralId |
  3093         EMPXMediaGeneralType | EMPXMediaGeneralCategory | EMPXMediaGeneralId |
  3096         EMPXMediaGeneralUri | EMPXMediaGeneralFlags | EMPXMediaGeneralCount |
  3094         EMPXMediaGeneralUri | EMPXMediaGeneralFlags | EMPXMediaGeneralCount |
  3097         EMPXMediaGeneralPlayCount | EMPXMediaGeneralLastPlaybackPosition |
  3095         EMPXMediaGeneralPlayCount | EMPXMediaGeneralLastPlaybackPosition |
  3098         EMPXMediaGeneralCollectionId | EMPXMediaGeneralDate));
  3096         EMPXMediaGeneralCollectionId | EMPXMediaGeneralDate));
  3099 
  3097     
  3100     aAttrs.AppendL(TMPXAttribute(KMPXMediaIdPodcast,
  3098     aAttrs.AppendL(TMPXAttribute(KMPXMediaIdPodcast,
  3101         EMPXMediaPodcastType | EMPXMediaPodcastCategoryGroup | EMPXMediaPodcastIsPlaying));
  3099         EMPXMediaPodcastType | EMPXMediaPodcastCategoryGroup | EMPXMediaPodcastIsPlaying));
  3102 
  3100 
  3103     aSupportedIds.AppendL(KMPXMediaIdContainer);
  3101     aSupportedIds.AppendL(KMPXMediaIdContainer);
  3104     aSupportedIds.AppendL(KMPXMediaIdGeneral);
  3102     aSupportedIds.AppendL(KMPXMediaIdGeneral);