mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
changeset 48 af3740e3753f
parent 42 79c49924ae23
child 54 c5b304f4d89b
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
  1002 
  1002 
  1003         TInt c( aArray->Count() );
  1003         TInt c( aArray->Count() );
  1004         for( TInt i=0; i<c; ++i )
  1004         for( TInt i=0; i<c; ++i )
  1005             {
  1005             {
  1006             TMPXItemId id = aArray->AtL(i)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
  1006             TMPXItemId id = aArray->AtL(i)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
  1007             ids.Append( id );
  1007             ids.AppendL( id );
  1008             }
  1008             }
  1009 
  1009 
  1010         // Rest are all blank items
  1010         // Rest are all blank items
  1011         CMPXMedia* entry = CMPXMedia::NewL();
  1011         CMPXMedia* entry = CMPXMedia::NewL();
  1012         CleanupStack::PushL(entry);
  1012         CleanupStack::PushL(entry);
  1017         TInt count = iDbHandler->NumberOfItemsL(EMPXSong);
  1017         TInt count = iDbHandler->NumberOfItemsL(EMPXSong);
  1018         count-=c;
  1018         count-=c;
  1019         for( TInt i=0; i<count; ++i )
  1019         for( TInt i=0; i<count; ++i )
  1020             {
  1020             {
  1021             aArray->AppendL( *entry );
  1021             aArray->AppendL( *entry );
  1022             ids.Append( KMPXInvalidItemId );
  1022             ids.AppendL( KMPXInvalidItemId );
  1023             }
  1023             }
  1024         CleanupStack::PopAndDestroy( entry );
  1024         CleanupStack::PopAndDestroy( entry );
  1025 
  1025 
  1026         // Set the "Supportes incremental Command" flag
  1026         // Set the "Supportes incremental Command" flag
  1027         //
  1027         //
  1686                 if (levels == 3)
  1686                 if (levels == 3)
  1687                     {
  1687                     {
  1688                     // return all songs of a particular artist (currently highlighted)
  1688                     // return all songs of a particular artist (currently highlighted)
  1689                     path->Set(EMPXOpenGroupOrPlaylist);
  1689                     path->Set(EMPXOpenGroupOrPlaylist);
  1690                     ids.Reset();
  1690                     ids.Reset();
  1691                     ids.Append(aPath.Id(2));
  1691                     ids.AppendL(aPath.Id(2));
  1692                     path->AppendL(ids.Array());
  1692                     path->AppendL(ids.Array());
  1693                     path->SelectL(aPath.Id(2));
  1693                     path->SelectL(aPath.Id(2));
  1694                     path->Set(EMPXOpenPlaylistOnly);
  1694                     path->Set(EMPXOpenPlaylistOnly);
  1695 
  1695 
  1696                     // Opens all songs of an artist and create the corresponding
  1696                     // Opens all songs of an artist and create the corresponding
  4076     MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL <--");
  4076     MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL <--");
  4077 
  4077 
  4078     TInt offset = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLOffset );
  4078     TInt offset = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLOffset );
  4079     TInt numItems = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLNumItems );
  4079     TInt numItems = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLNumItems );
  4080 
  4080 
  4081     TReadDirection direction(EReadUnknown);
       
  4082 /*  Ascending and Decending reads are currently not used. We optimized for offset reads.
       
  4083     if( aCmd.IsSupported(KMPXCollectionCommandIdIncOpenLAscDsc) &&
       
  4084         aCmd.IsSupported(KMPXCollectionCommandIdIncOpenLKeyItem) )
       
  4085         {
       
  4086         direction = aCmd.ValueTObjectL<TReadDirection>(KMPXCollectionCommandIdIncOpenLAscDsc);
       
  4087         }
       
  4088 */
       
  4089     CMPXCollectionPath* path =  aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCollectionCommandIdIncOpenLPath);
  4081     CMPXCollectionPath* path =  aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCollectionCommandIdIncOpenLPath);
  4090     CleanupStack::PushL( path );
  4082     CleanupStack::PushL( path );
  4091     MPX_DEBUG_PATH( *path );
  4083     MPX_DEBUG_PATH( *path );
  4092 
  4084 
  4093     // Switch on level and item selected
  4085     // Switch on level and item selected
  4118                                         EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
  4110                                         EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
  4119 
  4111 
  4120                     // Array to read data from
  4112                     // Array to read data from
  4121                     CMPXMediaArray* array = CMPXMediaArray::NewL();
  4113                     CMPXMediaArray* array = CMPXMediaArray::NewL();
  4122                     CleanupStack::PushL( array );
  4114                     CleanupStack::PushL( array );
  4123 
  4115                     iDbHandler->GetSongsAtOffsetL( array, attrs.Array(), offset, numItems );
  4124                     // Do we have to use offset or can we use asc/dsc
       
  4125                     //
       
  4126                     if( direction == EReadUnknown )
       
  4127                         {
       
  4128                         iDbHandler->GetSongsAtOffsetL( array, attrs.Array(), offset, numItems );
       
  4129                         }
       
  4130                     else
       
  4131                         {
       
  4132                         iDbHandler->GetSongsInBlockL( array, attrs.Array(),
       
  4133                                                       aCmd.ValueText( KMPXCollectionCommandIdIncOpenLKeyItem ),
       
  4134                                                       numItems,
       
  4135                                                       direction );
       
  4136                         }
       
  4137 
       
  4138                     TInt max( path->Count() );
  4116                     TInt max( path->Count() );
  4139                     TInt count(0);
  4117                     TInt count(0);
  4140                     TInt aryCount( array->Count() );
  4118                     TInt aryCount( array->Count() );
  4141                     // Update the collection path
  4119                     // Update the collection path
  4142                     while( count<numItems && offset<max &&
  4120                     while( count<numItems && offset<max &&
  4330 void CMPXDbPlugin::SetAttributesL(
  4308 void CMPXDbPlugin::SetAttributesL(
  4331     const CMPXCollectionPath& aPath,
  4309     const CMPXCollectionPath& aPath,
  4332     RArray<TMPXAttribute>& aAttrs,
  4310     RArray<TMPXAttribute>& aAttrs,
  4333     RArray<TInt>& aSupportedIds )
  4311     RArray<TInt>& aSupportedIds )
  4334     {
  4312     {
       
  4313     CleanupClosePushL(aAttrs);
       
  4314     CleanupClosePushL(aSupportedIds);
       
  4315        
  4335     aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
  4316     aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
  4336         EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
  4317         EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
  4337         EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri) );
  4318         EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri) );
  4338 
  4319 
  4339     aSupportedIds.AppendL(KMPXMediaIdContainer);
  4320     aSupportedIds.AppendL(KMPXMediaIdContainer);
  4426         {
  4407         {
  4427         aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
  4408         aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
  4428             EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
  4409             EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
  4429         aSupportedIds.AppendL( KMPXMediaIdMusic );
  4410         aSupportedIds.AppendL( KMPXMediaIdMusic );
  4430         }
  4411         }
       
  4412     CleanupStack::Pop();
       
  4413     CleanupStack::Pop();
  4431     }
  4414     }
  4432 
  4415 
  4433 #ifdef _DEBUG
  4416 #ifdef _DEBUG
  4434 // ----------------------------------------------------------------------------
  4417 // ----------------------------------------------------------------------------
  4435 // Print change events
  4418 // Print change events