fmradio/fmradio/src/fmradiomusicstorehandler.cpp
branchRCL_3
changeset 18 1a6714c53019
parent 15 04aa446da81c
equal deleted inserted replaced
17:e4d7a31227b8 18:1a6714c53019
    42 const TUint32 KMPXMusicStoreUID = 0x3;
    42 const TUint32 KMPXMusicStoreUID = 0x3;
    43 const TUint32 KOperatorMusicStore = 0x4;
    43 const TUint32 KOperatorMusicStore = 0x4;
    44 const TUint32 KOperatorMusicStoreType = 0x5;
    44 const TUint32 KOperatorMusicStoreType = 0x5;
    45 const TUint32 KOperatorMusicStoreDisplayName = 0x6;
    45 const TUint32 KOperatorMusicStoreDisplayName = 0x6;
    46 const TUint32 KOperatorMusicStoreNativeUid = 0x7;
    46 const TUint32 KOperatorMusicStoreNativeUid = 0x7;
       
    47 const TUint32 KOperatorMusicStoreJavaName = 0x8;
    47 const TUint32 KOperatorMusicStoreWebPage = 0x9;
    48 const TUint32 KOperatorMusicStoreWebPage = 0x9;
    48 const TUint32 KOperatorMusicStoreURI = 0xA;
    49 const TUint32 KOperatorMusicStoreURI = 0xA;
    49 const TInt TUInt32HexLength = 8;
    50 const TInt TUInt32HexLength = 8;
    50 
    51 
    51 // ----------------------------------------------------
    52 // ----------------------------------------------------
   217                 }
   218                 }
   218             CleanupStack::PopAndDestroy( &operatorUidDes );
   219             CleanupStack::PopAndDestroy( &operatorUidDes );
   219             break;
   220             break;
   220             }
   221             }
   221         case EFMRadioJavaApp:
   222         case EFMRadioJavaApp:
   222             // Java application not supported currently
   223             {
   223             break;
   224             TApaAppInfo appInfo;
       
   225             RBuf operatorJavaAppName;
       
   226             operatorJavaAppName.CleanupClosePushL();
       
   227             operatorJavaAppName.CreateL( appInfo.iCaption.MaxLength() ); // caption length should be enough
       
   228             
       
   229             TInt err = aRepository.Get( KOperatorMusicStoreJavaName, operatorJavaAppName );
       
   230 
       
   231             if ( !err )
       
   232                 {
       
   233                 _LIT( KFakeName, ".fakeapp" );
       
   234                 RApaLsSession apaSession;
       
   235                 User::LeaveIfError( apaSession.Connect() );
       
   236                 CleanupClosePushL( apaSession );
       
   237                 User::LeaveIfError( apaSession.GetAllApps() );
       
   238     
       
   239                 while ( apaSession.GetNextApp( appInfo ) == KErrNone )
       
   240                     {
       
   241                     if ( appInfo.iFullName.Right( 8 ).Compare( KFakeName ) == 0)
       
   242                         {
       
   243                         TApaAppCaption appname;
       
   244                         appname = appInfo.iCaption;
       
   245                         if ( !appInfo.iCaption.Compare( operatorJavaAppName ) )
       
   246                             {
       
   247                             FTRACE(FPrint(_L("CFMRadioMusicStoreHandler::InitializeParametersL( Operator Java UID found, name: %S)"), &operatorJavaAppName ));
       
   248                             iOperatorJavaMusicStoreUID = appInfo.iUid;
       
   249                             }
       
   250                         }
       
   251                     }
       
   252                 CleanupStack::PopAndDestroy( &apaSession ); // close apaSession
       
   253                 }
       
   254             CleanupStack::PopAndDestroy( &operatorJavaAppName );
       
   255             break;
       
   256             }
   224         case EFMRadioWebsite:
   257         case EFMRadioWebsite:
   225             {
   258             {
   226             const TInt initialSize = 5;
   259             const TInt initialSize = 5;
   227             TInt realLength = KErrNotFound;
   260             TInt realLength = KErrNotFound;
   228             iOperatorStoreWebsite.Create( initialSize );
   261             iOperatorStoreWebsite.Create( initialSize );
   471         }
   504         }
   472 
   505 
   473     RBuf searchString;
   506     RBuf searchString;
   474     searchString.CleanupClosePushL();
   507     searchString.CleanupClosePushL();
   475 
   508 
   476     TBool isHandled = ETrue;
   509     TBool isHandled = EFalse;
   477     switch( aCommandId )
   510     switch( aCommandId )
   478         {
   511         {
   479         case EFMRadioMusicStoreGoogle:
   512         case EFMRadioMusicStoreGoogle:
   480         case EFMRadioMusicStoreWikipedia:
   513         case EFMRadioMusicStoreWikipedia:
   481         case EFMRadioMusicStoreAmg:
   514         case EFMRadioMusicStoreAmg:
   482         case EFMRadioMusicStoreMusicPortl:
   515         case EFMRadioMusicStoreMusicPortl:
   483             isHandled = EFalse;
       
   484             break;
   516             break;
   485         case EFMRadioMusicStoreNokiaMusicShop:
   517         case EFMRadioMusicStoreNokiaMusicShop:
       
   518             isHandled = ETrue;
   486             searchString.Assign( NokiaMusicShopSearchL( aTitle, aArtist, aAlbum ) );
   519             searchString.Assign( NokiaMusicShopSearchL( aTitle, aArtist, aAlbum ) );
   487             break;
   520             break;
   488         case EFMRadioMusicStoreOperator:
   521         case EFMRadioMusicStoreOperator:
   489             if ( iOperatorStoreWebsite.Length() != 0 )
   522             if ( iOperatorStoreWebsite.Length() != 0 )
   490                 {
   523                 {
       
   524                 isHandled = ETrue;
   491                 searchString.CreateL( iOperatorStoreWebsite );
   525                 searchString.CreateL( iOperatorStoreWebsite );
   492                 }
   526                 }
   493             else if ( iOperatorStoreNativeUID )
   527             else if ( iOperatorStoreNativeUID )
   494                 {
   528                 {
       
   529                 isHandled = ETrue;
   495                 // It is assumed that both Nokia Music Shop and operator specific music store use
   530                 // It is assumed that both Nokia Music Shop and operator specific music store use
   496                 // same kind of interface to communicate
   531                 // same kind of interface to communicate
   497                 searchString.Assign( NokiaMusicShopSearchL( aTitle, aArtist, aAlbum ) );
   532                 searchString.Assign( NokiaMusicShopSearchL( aTitle, aArtist, aAlbum ) );
   498                 }
   533                 }
       
   534             else if ( iOperatorJavaMusicStoreUID.iUid )
       
   535                 {
       
   536                 isHandled = ETrue;
       
   537                 }
   499             else
   538             else
   500                 {
   539                 {
   501                 isHandled = EFalse;
       
   502                 }
   540                 }
   503             break;
   541             break;
   504         default:
   542         default:
   505             FTRACE( FPrint( _L("CFMRadioMusicStoreHandler::LaunchMusicStoreL - Unknown id = %d"), aCommandId ) );
   543             FTRACE( FPrint( _L("CFMRadioMusicStoreHandler::LaunchMusicStoreL - Unknown id = %d"), aCommandId ) );
   506             isHandled = EFalse;
       
   507             break;
   544             break;
   508         }
   545         }
   509 
   546 
   510     if ( isHandled )
   547     if ( isHandled )
   511         {
   548         {
   522                 break;
   559                 break;
   523             default:
   560             default:
   524                 LaunchWebPageL( searchString );
   561                 LaunchWebPageL( searchString );
   525                 break;
   562                 break;
   526             }
   563             }
   527         CleanupStack::PopAndDestroy( &searchString );
   564         }
   528         }
   565     CleanupStack::PopAndDestroy( &searchString );
   529     }
   566     }
   530 
   567 
   531 // -----------------------------------------------------------------------------
   568 // -----------------------------------------------------------------------------
   532 // CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL
   569 // CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL
   533 // -----------------------------------------------------------------------------
   570 // -----------------------------------------------------------------------------
   534 //
   571 //
   535 void CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL( const TDesC& aSearchString )
   572 void CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL( const TDesC& aSearchString )
   536     {
   573     {
       
   574     FTRACE(FPrint(_L("CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL('%S')"), &aSearchString));
   537     if ( iOperatorStoreWebsite.Length() != 0 )
   575     if ( iOperatorStoreWebsite.Length() != 0 )
   538         {
   576         {
       
   577         FTRACE(FPrint(_L("CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL Website") ));
   539         LaunchWebPageL( aSearchString );
   578         LaunchWebPageL( aSearchString );
   540         }
   579         }
   541     else if ( iOperatorStoreNativeUID )
   580     else if ( iOperatorStoreNativeUID )
   542         {
   581         {
   543         // It is assumed that both Nokia Music Shop and operator specific music store use
   582         // It is assumed that both Nokia Music Shop and operator specific music store use
   544         // same kind of interface to communicate
   583         // same kind of interface to communicate
       
   584         FTRACE(FPrint(_L("CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL Operator Native UID") ));
   545         TUid musicshopUid( TUid::Uid( iOperatorStoreNativeUID ) );
   585         TUid musicshopUid( TUid::Uid( iOperatorStoreNativeUID ) );
   546         LaunchMusicShopL( musicshopUid, aSearchString );
   586         LaunchMusicShopL( musicshopUid, aSearchString );
       
   587         }
       
   588     else if ( iOperatorJavaMusicStoreUID.iUid )
       
   589         {
       
   590         FTRACE(FPrint(_L("CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL Operator Java UID") ));
       
   591         TThreadId threadId;
       
   592         RApaLsSession apaSession;
       
   593         User::LeaveIfError( apaSession.Connect() );
       
   594         CleanupClosePushL( apaSession );
       
   595         apaSession.StartDocument( KNullDesC, iOperatorJavaMusicStoreUID, threadId );
       
   596         CleanupStack::PopAndDestroy( &apaSession ); // close apaSession
   547         }
   597         }
   548     else
   598     else
   549         {
   599         {
   550         //NOP
   600         //NOP
   551         }
   601         }