contentcontrolsrv/hsccclient/hsccapiclient/src/hsccapiclient.cpp
changeset 2 b7904b40483f
parent 0 79c6a41cd166
child 18 bd874ee5e5e2
equal deleted inserted replaced
1:844b978f8d5e 2:b7904b40483f
   711     
   711     
   712     return err;
   712     return err;
   713     }
   713     }
   714 
   714 
   715 // -----------------------------------------------------------------------------
   715 // -----------------------------------------------------------------------------
       
   716 // CHsCcApiClient::ActiveViewL
       
   717 // -----------------------------------------------------------------------------
       
   718 //
       
   719 TInt CHsCcApiClient::ActiveViewL( CHsContentInfo& aInfo )
       
   720     {
       
   721     TInt err( KErrNone );
       
   722 
       
   723     // Create ActiveViewReq API request
       
   724     CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
       
   725     CleanupStack::PushL( reqMsg );
       
   726     reqMsg->SetMsgId( EHsCcActiveViewReq );
       
   727     reqMsg->SetTrId( 0 );
       
   728     reqMsg->SetData( KNullDesC8() );
       
   729     
       
   730     // Marshal API request
       
   731     HBufC8* msgBuf = reqMsg->MarshalL();
       
   732     CleanupStack::PushL( msgBuf );
       
   733     TPtr8 msgPtr( NULL, 0 );
       
   734     msgPtr.Set( msgBuf->Des() );
       
   735  
       
   736     // Send API request
       
   737     // Sender and receiver address not defined -> message is routed
       
   738     // according to the provider id
       
   739     TPckgBuf<TUint32> provider( ECcHomescreen );
       
   740     TPckgBuf<TUint32> sender;
       
   741     TPckgBuf<TUint32> receiver;
       
   742     err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
       
   743     
       
   744     if ( !err )
       
   745         {
       
   746         // Internalize AppListResp API response
       
   747         CCcSrvMsg* respMsg = CCcSrvMsg::NewL();
       
   748         CleanupStack::PushL( respMsg );
       
   749         RDesReadStream respStream( msgPtr );
       
   750         CleanupClosePushL( respStream );
       
   751         respMsg->InternalizeHeaderL( respStream );
       
   752         CleanupStack::PopAndDestroy( &respStream );
       
   753         err = respMsg->Status();
       
   754         if ( !err )
       
   755             {
       
   756             if ( respMsg->DataSize() )
       
   757                 {
       
   758                 // Get API response data
       
   759                 HBufC8* dataBuf = HBufC8::NewL( respMsg->DataSize() );
       
   760                 CleanupStack::PushL( dataBuf );
       
   761                 TPtr8 dataPtr( NULL, 0 );
       
   762                 dataPtr.Set( dataBuf->Des() );
       
   763                 TPckgBuf<TUint32> trId( respMsg->TrId() );
       
   764                 err = iSession.GetMsgData( trId, dataPtr );
       
   765                 if ( !err )
       
   766                     {
       
   767                     // Internalize API response data
       
   768                     RDesReadStream dataStream( dataPtr );
       
   769                     CleanupClosePushL( dataStream );
       
   770                     aInfo.InternalizeL( dataStream );                    
       
   771                     CleanupStack::PopAndDestroy( &dataStream );
       
   772                     }
       
   773                 CleanupStack::PopAndDestroy( dataBuf );
       
   774                 }
       
   775             }
       
   776         CleanupStack::PopAndDestroy( respMsg );
       
   777         }
       
   778 
       
   779     // Cleanup
       
   780     CleanupStack::PopAndDestroy( msgBuf );
       
   781     CleanupStack::PopAndDestroy( reqMsg );
       
   782     
       
   783     return err;
       
   784     }
       
   785 
       
   786 // -----------------------------------------------------------------------------
       
   787 // CHsCcApiClient::ActiveAppL
       
   788 // -----------------------------------------------------------------------------
       
   789 //
       
   790 TInt CHsCcApiClient::ActiveAppL( CHsContentInfo& aInfo )
       
   791     {
       
   792     TInt err( KErrNone );
       
   793 
       
   794     // Create ActiveViewReq API request
       
   795     CCcSrvMsg* reqMsg = CCcSrvMsg::NewL();
       
   796     CleanupStack::PushL( reqMsg );
       
   797     reqMsg->SetMsgId( EHsCcActiveAppReq );
       
   798     reqMsg->SetTrId( 0 );
       
   799     reqMsg->SetData( KNullDesC8() );
       
   800     
       
   801     // Marshal API request
       
   802     HBufC8* msgBuf = reqMsg->MarshalL();
       
   803     CleanupStack::PushL( msgBuf );
       
   804     TPtr8 msgPtr( NULL, 0 );
       
   805     msgPtr.Set( msgBuf->Des() );
       
   806  
       
   807     // Send API request
       
   808     // Sender and receiver address not defined -> message is routed
       
   809     // according to the provider id
       
   810     TPckgBuf<TUint32> provider( ECcHomescreen );
       
   811     TPckgBuf<TUint32> sender;
       
   812     TPckgBuf<TUint32> receiver;
       
   813     err = iSession.Send( ECcApiReq, provider, sender, receiver, msgPtr );
       
   814     
       
   815     if ( !err )
       
   816         {
       
   817         // Internalize AppListResp API response
       
   818         CCcSrvMsg* respMsg = CCcSrvMsg::NewL();
       
   819         CleanupStack::PushL( respMsg );
       
   820         RDesReadStream respStream( msgPtr );
       
   821         CleanupClosePushL( respStream );
       
   822         respMsg->InternalizeHeaderL( respStream );
       
   823         CleanupStack::PopAndDestroy( &respStream );
       
   824         err = respMsg->Status();
       
   825         if ( !err )
       
   826             {
       
   827             if ( respMsg->DataSize() )
       
   828                 {
       
   829                 // Get API response data
       
   830                 HBufC8* dataBuf = HBufC8::NewL( respMsg->DataSize() );
       
   831                 CleanupStack::PushL( dataBuf );
       
   832                 TPtr8 dataPtr( NULL, 0 );
       
   833                 dataPtr.Set( dataBuf->Des() );
       
   834                 TPckgBuf<TUint32> trId( respMsg->TrId() );
       
   835                 err = iSession.GetMsgData( trId, dataPtr );
       
   836                 if ( !err )
       
   837                     {
       
   838                     // Internalize API response data
       
   839                     RDesReadStream dataStream( dataPtr );
       
   840                     CleanupClosePushL( dataStream );
       
   841                     aInfo.InternalizeL( dataStream );                    
       
   842                     CleanupStack::PopAndDestroy( &dataStream );
       
   843                     }
       
   844                 CleanupStack::PopAndDestroy( dataBuf );
       
   845                 }
       
   846             }
       
   847         CleanupStack::PopAndDestroy( respMsg );
       
   848         }
       
   849 
       
   850     // Cleanup
       
   851     CleanupStack::PopAndDestroy( msgBuf );
       
   852     CleanupStack::PopAndDestroy( reqMsg );
       
   853     
       
   854     return err;
       
   855     }
       
   856 
       
   857 // -----------------------------------------------------------------------------
   716 // CHsCcApiClient::WaitForApiNtfL()
   858 // CHsCcApiClient::WaitForApiNtfL()
   717 // -----------------------------------------------------------------------------
   859 // -----------------------------------------------------------------------------
   718 //
   860 //
   719 void CHsCcApiClient::WaitForApiNtfL()
   861 void CHsCcApiClient::WaitForApiNtfL()
   720     {
   862     {