mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
branchRCL_3
changeset 15 171e07ac910f
parent 14 943ff5625028
child 17 c8156a91d13c
equal deleted inserted replaced
14:943ff5625028 15:171e07ac910f
    62 _LIT(KMPlayerDbPluginMbmFile, "mpxdbhgplugin.mif");
    62 _LIT(KMPlayerDbPluginMbmFile, "mpxdbhgplugin.mif");
    63 const TInt KFirstFetchCount = 400;
    63 const TInt KFirstFetchCount = 400;
    64 
    64 
    65 const TUid KCRUIDMusicPlayerFeatures = { 0x101FFCD0 };
    65 const TUid KCRUIDMusicPlayerFeatures = { 0x101FFCD0 };
    66 const TInt KMusicPlayerFeatures = 1;
    66 const TInt KMusicPlayerFeatures = 1;
    67 const TInt KDisablePodcasting = 0x80;
    67 const TInt KDisablePodcasting = 0x08;
    68 
    68 
    69 const TInt KIncrementalDeleteCount = 400;
    69 const TInt KIncrementalDeleteCount = 400;
    70 
    70 
    71 const TInt KSQLErrGeneral = -311; // SQL General error. Don't want to include sql header here
    71 const TInt KSQLErrGeneral = -311; // SQL General error. Don't want to include sql header here
    72 // ============================ MEMBER FUNCTIONS ==============================
    72 // ============================ MEMBER FUNCTIONS ==============================
   790 
   790 
   791     TInt count(0);
   791     TInt count(0);
   792     TInt levels(aPath.Levels());
   792     TInt levels(aPath.Levels());
   793     TBool isASong(EFalse);
   793     TBool isASong(EFalse);
   794 
   794 
   795     aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
   795 
   796 
   796 	if ( 1 == levels )
   797     if (1 == levels)
   797 	    {
   798         {
   798 
   799         // return the "main menu"
   799 	    // Redirecting all open requests at level 1 to open albums 
   800         count = iMusicLibraryMenuTitles->Count();
   800 	    // due to UI changes that removed the library menu collection level.
   801         RArray<TMPXItemId> ids;
   801         TInt acount = array->Count();
   802         CleanupClosePushL(ids);
   802         MPX_DEBUG2(" array count11 [%d]", acount);
   803 
   803         
   804         // due to ui changes, the order of main menu is changed
   804  		CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
   805         // since multiple clients hardcode indexes to each entry,
   805 		CleanupStack::PushL( path );
   806         // the enum cannot be changed, instead we will have to
   806 		
   807         // manually change the display order to minimize the impact to
   807 		path->AppendL(3); // Albums
   808         // external clients
   808 		TInt whatLevel = path->Levels();
   809 
   809 
   810         // change from:
   810 		MPX_DEBUG_PATH(*path);
   811         // all songs, playlist, artist, album, (podcast), genre, composer
   811 		
   812         // to:
   812 		aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, path->Id(whatLevel - 1) );
   813         // artist, album, playlist, all songs, (podcast), genre, composer
   813 		
   814         for (TInt i = EBrowseArtist; i <= EBrowseAlbum; ++i)
   814       // Create a media which hold the pointer to the returned path
   815             {
   815         if (aEntries.IsSupported(KMPXMediaGeneralValue))
   816             MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(i), EMPXGroup,
   816             {
   817                 CategoryForBrowseType(static_cast<TMCBrowseType>(i)), iMusicLibraryMenuIds[i]);
   817             MPX_DEBUG1(" pointer to the returned path ");
   818             ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[i]));
   818             CMPXMedia* pMedia = CMPXMedia::NewL();
   819             }
   819             CleanupStack::PushL(pMedia);
   820         MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(1), EMPXGroup,
   820             pMedia->SetTObjectValueL<TInt>(KMPXMediaGeneralValue,
   821             CategoryForBrowseType(static_cast<TMCBrowseType>(1)), iMusicLibraryMenuIds[1]);
   821                                           aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue));
   822         ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[1]));
   822             array->AppendL(*pMedia);
   823         MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(0), EMPXGroup,
   823             CleanupStack::PopAndDestroy(pMedia);
   824             CategoryForBrowseType(static_cast<TMCBrowseType>(0)), iMusicLibraryMenuIds[0]);
   824             }
   825         ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[0]));
   825 		
   826 
   826 	
   827 #ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
   827         RArray<TMPXAttribute> openAttrs;
   828         if( !iDisablePodcasting )
   828         CleanupClosePushL(openAttrs);
   829             {
   829 
   830             MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(EBrowsePodcasts), EMPXGroup,
   830         RArray<TInt> supportedIds;
   831                 CategoryForBrowseType(static_cast<TMCBrowseType>(EBrowsePodcasts)), iMusicLibraryMenuIds[EBrowsePodcasts]);
   831         CleanupClosePushL(supportedIds);
   832             ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[EBrowsePodcasts]));
   832 
   833             }
   833         SetAttributesL(*path, openAttrs, supportedIds);
   834 #endif // __ENABLE_PODCAST_IN_MUSIC_MENU
   834         openAttrs.AppendL(KMPXMediaArrayContents);
   835 
   835         
   836         // Genre and composer
   836         CleanupStack::PopAndDestroy(&supportedIds);
   837         for (TInt i = ( EBrowseGenre ); i < count; ++i)
   837 		
   838             {
   838 		if( iAllSongsValid )
   839             MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(i), EMPXGroup,
   839 		    {
   840                 CategoryForBrowseType(static_cast<TMCBrowseType>(i)), iMusicLibraryMenuIds[i]);
   840 		    isASong = DoOpenBrowseAlbumL( *path, openAttrs.Array(), aEntries, array );
   841             ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[i]));
   841 		    }
   842             }
   842 		CleanupStack::PopAndDestroy(&openAttrs);
   843 
   843 		CleanupStack::PopAndDestroy( path );
   844         TInt pPath = aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue);
   844 
   845         MPX_ASSERT(pPath);
   845         //Remove the first media
   846         ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
   846         if ( array->Count() &&
   847         CleanupStack::PopAndDestroy(&ids);
   847             (*array)[0]->IsSupported(KMPXMediaGeneralValue))
   848         SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXCollection, *iMusicMenuTitle);
   848             {
   849         aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
   849             array->Remove(0);
   850             KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
   850             }
   851         }
   851 	    }
   852     else if (levels >= 2)
   852     else if (levels >= 2)
   853         {
   853         {
       
   854 	    aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
   854         // Create a media which hold the pointer to the returned path
   855         // Create a media which hold the pointer to the returned path
   855         if (aEntries.IsSupported(KMPXMediaGeneralValue))
   856         if (aEntries.IsSupported(KMPXMediaGeneralValue))
   856             {
   857             {
   857             CMPXMedia* pMedia = CMPXMedia::NewL();
   858             CMPXMedia* pMedia = CMPXMedia::NewL();
   858             CleanupStack::PushL(pMedia);
   859             CleanupStack::PushL(pMedia);
  3818     // Callback to engine to signal completion
  3819     // Callback to engine to signal completion
  3819     // NOTE: Collection server immediately completes the async message when
  3820     // NOTE: Collection server immediately completes the async message when
  3820     // Cancel is called, no need to callback to observer
  3821     // Cancel is called, no need to callback to observer
  3821     if (aErr != KErrCancel)
  3822     if (aErr != KErrCancel)
  3822         {
  3823         {
  3823         iObs->HandleCommandComplete(NULL, aErr);
  3824         if( iActiveTask->GetTask() == KMPXCommandIdCollectionAdd )
       
  3825             {
       
  3826             iObs->HandleCommandComplete( &iActiveTask->GetCommand(), aErr );
       
  3827             }
       
  3828         else
       
  3829             {
       
  3830             iObs->HandleCommandComplete(NULL, aErr);
       
  3831             }
  3824         }
  3832         }
  3825 
  3833 
  3826     if( iDbHandler->InTransaction() )
  3834     if( iDbHandler->InTransaction() )
  3827         {
  3835         {
  3828         // Commit if cancelled
  3836         // Commit if cancelled