mmsharing/mmshmanagersrv/src/musavailabilitypluginmanager.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    31 #include <e32property.h>
    31 #include <e32property.h>
    32 
    32 
    33 
    33 
    34 // CONSTANTS
    34 // CONSTANTS
    35 
    35 
    36 // Max number of digits in unsigned 32 bit integer (TInt32)
       
    37 const TUint KMaxInt32Length = 16;
       
    38 
       
    39 
       
    40 using namespace MultimediaSharing;
    36 using namespace MultimediaSharing;
    41 
    37 
    42 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    43 //
    39 //
    44 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
   177 
   173 
   178 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   179 //
   175 //
   180 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   181 //
   177 //
   182 void CMusAvailabilityPluginManager::PrepareForReceivedInviteL()
       
   183     {
       
   184     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
       
   185                  PrepareForReceivedInviteL()" )
       
   186                  
       
   187     iPlugin->PrepareForReceivedInviteL();
       
   188     
       
   189     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
       
   190                      PrepareForReceivedInviteL()" )
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 void CMusAvailabilityPluginManager::InvitationReceivedL()
   178 void CMusAvailabilityPluginManager::InvitationReceivedL()
   198     {
   179     {
   199     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   180     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   200         InvitationReceivedL()" )
   181         InvitationReceivedL()" )
   201 
   182 
   285     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   266     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   286         ManualQueryL()" )
   267         ManualQueryL()" )
   287   	MMusAvaSettings& settings = iPlugin->Settings();
   268   	MMusAvaSettings& settings = iPlugin->Settings();
   288   	
   269   	
   289     MUS_LOG( "mus: [MUSSRV]    Status available" )
   270     MUS_LOG( "mus: [MUSSRV]    Status available" )
   290     if( !iIndicator )
   271     
   291         {
   272     settings.SetManualActivation( MMusAvaSettings::EActivationAllowed );
   292         MUS_LOG( "mus: [MUSSRV]    Create indicator" )
   273     iPlugin->StartL();
   293         iIndicator = CMusIndicatorApi::NewL( *this );
   274 
   294         if( iIndicator->ConfirmationQueryL( CMusIndicatorApi::EVsRoamingActivationQuery ) )
       
   295         	{
       
   296         	settings.SetManualActivation( MMusAvaSettings::EActivationAllowed );
       
   297         	iPlugin->StartL();
       
   298         	}
       
   299         else
       
   300         	{
       
   301         	settings.SetManualActivation( MMusAvaSettings::EActivationNotAllowed );
       
   302         	}
       
   303         delete iIndicator;
       
   304         iIndicator = NULL;
       
   305         }
       
   306      else
       
   307      	{
       
   308      	if( iIndicator->ConfirmationQueryL( CMusIndicatorApi::EVsRoamingActivationQuery ) )
       
   309         	{
       
   310         	settings.SetManualActivation( MMusAvaSettings::EActivationAllowed );
       
   311         	iPlugin->StartL();
       
   312         	}
       
   313         else
       
   314         	{
       
   315         	settings.SetManualActivation( MMusAvaSettings::EActivationNotAllowed );	
       
   316         	}	
       
   317      	}
       
   318     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   275     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   319         ManualQueryL()" )  
   276         ManualQueryL()" )  
   320     }
   277     }
   321 
   278 
   322 TBool CMusAvailabilityPluginManager::PossibleToLaunch()
   279 TBool CMusAvailabilityPluginManager::PossibleToLaunch()
   347 
   304 
   348     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   305     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   349         AvailabilityChanged()" )	
   306         AvailabilityChanged()" )	
   350     }
   307     }
   351 
   308 
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314  void CMusAvailabilityPluginManager::AvailabilitiesAbleToShowIndicator()
       
   315 	{
       
   316 	    TInt err = 0;
       
   317 		TRAP( err, IndicateAvailabilityL() );
       
   318 		if ( err )
       
   319 			{
       
   320 			// Not sure about what to do. Very rare situation.
       
   321 			MUS_LOG1( "mus: [MUSSRV] AvailabilitiesAbleToShowIndicator() leave code: %d",err )
       
   322 			}
       
   323 	}
   352 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   353 //
   325 //
   354 // -----------------------------------------------------------------------------
   326 // -----------------------------------------------------------------------------
   355 //
   327 //
   356 void CMusAvailabilityPluginManager::AvailabilityError( 
   328 void CMusAvailabilityPluginManager::AvailabilityError( 
   376     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   348     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   377         AvailabilityError()" )	
   349         AvailabilityError()" )	
   378     }
   350     }
   379 
   351 
   380 // -----------------------------------------------------------------------------
   352 // -----------------------------------------------------------------------------
   381 // From MMusAvaSettingsObserver
   353 //
   382 // -----------------------------------------------------------------------------
   354 // -----------------------------------------------------------------------------
   383 //
   355 //
   384 MMusAvaSettingsObserver::TApplicationState CMusAvailabilityPluginManager::
   356 MMusAvaSettingsObserver::TApplicationState CMusAvailabilityPluginManager::
   385     ApplicationState()
   357     ApplicationState()
   386     {
   358     {
   400         ApplicationState()" )
   372         ApplicationState()" )
   401     return ret;
   373     return ret;
   402     }
   374     }
   403 
   375 
   404 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   405 // From MMusAvaSettingsObserver
   377 //
   406 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   407 //
   379 //
   408 TBool CMusAvailabilityPluginManager::OptionAllowed()
   380 TBool CMusAvailabilityPluginManager::OptionAllowed()
   409     {
   381     {
   410     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   382     MUS_LOG( "mus: [MUSSRV]  -> CMusAvailabilityPluginManager::\
   415     return iPlugin->AvailabilityState( MMusAvaObserver::EMusAvaOptionHandler )
   387     return iPlugin->AvailabilityState( MMusAvaObserver::EMusAvaOptionHandler )
   416         >= EMusAvaStatusNotExecuted;
   388         >= EMusAvaStatusNotExecuted;
   417     }
   389     }
   418 
   390 
   419 // -----------------------------------------------------------------------------
   391 // -----------------------------------------------------------------------------
   420 // From MMusAvaSettingsObserver
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 void CMusAvailabilityPluginManager::StartApplicationL( 
       
   424         MultimediaSharing::TMusUseCase aUseCase )
       
   425     {
       
   426     iObserver.StartSharingWithUseCaseL( aUseCase );        
       
   427     }
       
   428 
       
   429 // -----------------------------------------------------------------------------
       
   430 // From MMusIndicatorObserver.
   392 // From MMusIndicatorObserver.
   431 // Starts live video sharing.
   393 // Starts live video sharing.
   432 // -----------------------------------------------------------------------------
   394 // -----------------------------------------------------------------------------
   433 //
   395 //
   434 void CMusAvailabilityPluginManager::StartLiveSharingL()
   396 void CMusAvailabilityPluginManager::StartLiveSharingL()
   435     {
   397     {
   436     iObserver.StartSharingWithUseCaseL( MultimediaSharing::EMusLiveVideo );
   398     iObserver.StartLiveSharingL();
   437     }
   399     }
   438 
   400 
   439 // -----------------------------------------------------------------------------
   401 // -----------------------------------------------------------------------------
   440 // This functions cross-links TAvailabilityStatus and
   402 // This functions cross-links TAvailabilityStatus and
   441 // MultimediaSharing::TMusAvailabilityStatus
   403 // MultimediaSharing::TMusAvailabilityStatus
   611     MMusAvaSettings& settings = iPlugin->Settings();
   573     MMusAvaSettings& settings = iPlugin->Settings();
   612 
   574 
   613     // append sip address proposal
   575     // append sip address proposal
   614     iSessionParameters->AppendL( settings.SipAddressProposal() );
   576     iSessionParameters->AppendL( settings.SipAddressProposal() );
   615 
   577 
   616     TBuf<KMaxInt32Length> contactIdBuf;
   578     // Unsafe Magic number 16 is used but unsigned 32 bit integer (TInt32)
       
   579     // can't go beyond 16 digits .
       
   580     TBuf<16> contactIdBuf;
   617     contactIdBuf.Num( settings.ContactId() );
   581     contactIdBuf.Num( settings.ContactId() );
   618 
   582 
   619     // append contact id
   583     // append contact id
   620     iSessionParameters->AppendL( contactIdBuf );
   584     iSessionParameters->AppendL( contactIdBuf );
       
   585     
   621     // append video codec
   586     // append video codec
   622     HBufC* videoCodecs = VideoCodecsLC();
   587     HBufC* videoCodecs = VideoCodecsLC();
   623     iSessionParameters->AppendL( *videoCodecs );
   588     iSessionParameters->AppendL( *videoCodecs );
   624     CleanupStack::PopAndDestroy( videoCodecs );
   589     CleanupStack::PopAndDestroy( videoCodecs );
   625 
   590 
   626     TBuf<KMaxInt32Length> sipProfileIdBuf;
   591     // Unsafe Magic number 16 is used but unsigned 32 bit integer (TInt32)
       
   592     // can't go beyond 16 digits .
       
   593     TBuf<16> sipProfileIdBuf;
   627     sipProfileIdBuf.Num( settings.SipProfileId() );
   594     sipProfileIdBuf.Num( settings.SipProfileId() );
   628 
   595 
   629     MUS_LOG1("iSessionParameters -> SIP Profile ID = %d ",
   596     MUS_LOG1("iSessionParameters -> SIP Profile ID = %d ",
   630         settings.SipProfileId() )
   597         settings.SipProfileId() )
   631 
   598 
   633     iSessionParameters->AppendL( sipProfileIdBuf );
   600     iSessionParameters->AppendL( sipProfileIdBuf );
   634 
   601 
   635     HBufC* contactName = ContactNameLC();
   602     HBufC* contactName = ContactNameLC();
   636     iSessionParameters->AppendL( *contactName );
   603     iSessionParameters->AppendL( *contactName );
   637     CleanupStack::PopAndDestroy( contactName );
   604     CleanupStack::PopAndDestroy( contactName );
   638 
       
   639     TBuf<KMaxInt32Length> fastModeBuf;
       
   640     fastModeBuf.Num( settings.FastMode() );
       
   641     MUS_LOG1("iSessionParameters -> fast mode = %d ",
       
   642         settings.FastMode() )
       
   643 
       
   644     // append fast mode
       
   645     iSessionParameters->AppendL( fastModeBuf );
       
   646     
   605     
       
   606     // append call privacy indication
       
   607     MUS_LOG1("iSessionParameters -> Call Privacy = %d ",
       
   608             settings.CallPrivacy() )
       
   609     TBuf<16> callPrivacy;
       
   610     callPrivacy.Num( settings.CallPrivacy() );
       
   611     iSessionParameters->AppendL( callPrivacy );
       
   612 
       
   613 
   647     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   614     MUS_LOG( "mus: [MUSSRV]  <- CMusAvailabilityPluginManager::\
   648              UpdateSessionParametersL()" )
   615              UpdateSessionParametersL()" )
   649     }
   616     }
   650 
   617 
   651 
   618 
   793         MUS_LOG( "mus: [MUSSRV]    Status available" )
   760         MUS_LOG( "mus: [MUSSRV]    Status available" )
   794         if( !iIndicator )
   761         if( !iIndicator )
   795             {
   762             {
   796             MUS_LOG( "mus: [MUSSRV]    Create indicator" )
   763             MUS_LOG( "mus: [MUSSRV]    Create indicator" )
   797             iIndicator = CMusIndicatorApi::NewL( *this );
   764             iIndicator = CMusIndicatorApi::NewL( *this );
   798             iIndicator->IndicateAvailabilityL();
   765             }
   799             }
   766         iIndicator->IndicateAvailabilityL();
   800         iApplicationManager.SetIndicatorStatusL( ETrue );
   767         iApplicationManager.SetIndicatorStatusL( ETrue );
   801         }
   768         }
   802     else
   769     else
   803         {
   770         {
   804         MUS_LOG( "mus: [MUSSRV]    Not available" )
   771         MUS_LOG( "mus: [MUSSRV]    Not available" )