diff -r 73a1feb507fb -r bc78a40cd63c mmsharing/mmshmanagersrv/src/musapplicationmanager.cpp --- a/mmsharing/mmshmanagersrv/src/musapplicationmanager.cpp Tue Aug 31 15:12:07 2010 +0300 +++ b/mmsharing/mmshmanagersrv/src/musapplicationmanager.cpp Wed Sep 01 12:31:01 2010 +0100 @@ -23,23 +23,15 @@ #include "musmanagerservercommon.h" #include "mussessionproperties.h" #include "musuid.hrh" -#include "mussettings.h" -/* PS keys related to NMusSessionInformationApi defined here */ -#include "mussesseioninformationapi.h" -#include "muscleanupresetanddestroy.h" -#include "lcengine.h" #include #include +//#include #include #include -#include -#include - // CONSTANTS -_LIT8( KDefaultEngineName, "MultimediaSharing" ); -_LIT( KMusUiProcessName, "musui.exe" ); + // ----------------------------------------------------------------------------- // CMusApplicationManager::NewL @@ -87,6 +79,9 @@ MUS_LOG( "mus: [MUSSRV] -> \ CMusApplicationManager::~CMusApplicationManager()" ); + iApaSession.Close(); + iWsSession.Close(); + MUS_LOG( "mus: [MUSSRV] <- \ CMusApplicationManager::~CMusApplicationManager()" ); } @@ -100,7 +95,8 @@ { MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::ConstructL()" ); - SetPropertyL( NMusSessionApi::KFastMode, MusSettingsKeys::EFastModeOff ); + User::LeaveIfError( iApaSession.Connect() ); + User::LeaveIfError( iWsSession.Connect() ); MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::ConstructL()" ); } @@ -122,10 +118,7 @@ TBool CMusApplicationManager::ApplicationRunning() { MUS_LOG( "mus: [MUSSRV] <> CMusApplicationManager::ApplicationRunning()" ); - - TFindProcess findProcess( KMusUiProcessName ); - TFullName name; - return ( findProcess.Next( name ) == KErrNone ); + return GetApaTask().Exists(); } @@ -143,15 +136,13 @@ } else { - MUS_LOG( "mus: [MUSSRV] Starting app" ); + TUid appUid; + appUid.iUid = KMusUiUid; - RProcess process; - CleanupClosePushL( process ); - HBufC* args = CreateCommandLineArgsLC(); - User::LeaveIfError( process.Create( KMusUiProcessName, *args ) ); - process.Resume(); - CleanupStack::PopAndDestroy( args ); - CleanupStack::PopAndDestroy( &process ); + TThreadId aThreadId; + + User::LeaveIfError( + iApaSession.StartDocument( KNullDesC, appUid, aThreadId) ); } MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::StartApplicationL()" ); @@ -166,7 +157,8 @@ { MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::StopApplicationL()" ); - if( ApplicationRunning() ) + TApaTask task = GetApaTask(); + if( task.Exists() ) { SetPropertyL( NMusSessionApi::KStatus, MultimediaSharing::EMultimediaSharingNotAvailable ); @@ -184,7 +176,12 @@ { MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::ShowApplicationL()" ); - // TODO: How to bring a QT application to foreground? + // does a task for multimediasharing exist? + TApaTask task = GetApaTask(); + if( task.Exists() ) + { + task.BringToForeground(); + } MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::ShowApplicationL()" ); } @@ -202,21 +199,10 @@ MUS_LOG2( "mus: [MUSSRV] -> \ CMusApplicationManager::WriteSessionPropertiesL( %d, %d )", ( TInt ) aUseCase, ( TInt ) aStatus ); - TRAPD( error, - if ( aUseCase == MultimediaSharing::EMusLiveVideo && - MultimediaSharingSettings::VideoDirectionL() == - MusSettingsKeys::ETwoWayVideo ) - { - MUS_LOG( "mus: [MUSSRV] UseCase MultimediaSharing::EMusTwoWayVideo" ); - aUseCase = MultimediaSharing::EMusTwoWayVideo; - } - ) - if ( error == KErrNoMemory ) - { - User::Leave( error ); - } + // set use case property - SetPropertyL( NMusSessionApi::KUseCase, ( TInt ) aUseCase ); + SetPropertyL( NMusSessionApi::KUseCase, + ( TInt ) aUseCase ); WriteSessionPropertiesL( aStatus, aSessionParameters ); @@ -271,24 +257,14 @@ SetPropertyL( NMusSessionApi::KContactName, aSessionParameters.MdcaPoint( KContactName ) ); - // fast mode - TInt fastMode; - User::LeaveIfError( RProperty::Get( NMusSessionApi::KCategoryUid, - NMusSessionApi::KFastMode, - fastMode ) ); - if ( fastMode != MusSettingsKeys::EFastModeDisabled ) - { - lex.Assign( aSessionParameters.MdcaPoint( KFastMode ) ); - lex.Val( val ); - SetPropertyL( NMusSessionApi::KFastMode, val ); - } - else - { - MUS_LOG( "mus: [MUSSRV] fast mode disabled, do not update it" ); - } + // set status property + SetStatusL( aStatus ); - // set status property - SetStatusL( aStatus ); + // set privacy property + lex.Assign( aSessionParameters.MdcaPoint( KPrivacyStatus ) ); + lex.Val( val ); + + SetPropertyL( NMusSessionApi::KPrivacyStatus, val ); MUS_LOG( "mus: [MUSSRV] <- \ CMusApplicationManager::WriteSessionPropertiesL()" ); @@ -392,97 +368,15 @@ MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::SetPropertyL()" ); } -// ----------------------------------------------------------------------------- -// Reads the callprovider description from the PS key -// return aProvider will have the proper callprovider name. + // ----------------------------------------------------------------------------- // -void CMusApplicationManager::CallProviderL(TDes8& aProvider) - { - MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::CallProviderL"); - const TInt KMusMgrMaxPluginNameLen = 256; - TBuf pluginName; - - User::LeaveIfError(RProperty::Get( - NMusSessionInformationApi::KCategoryUid, - NMusSessionInformationApi::KMUSCallProvider, - pluginName )); - User::LeaveIfError( - CnvUtfConverter::ConvertFromUnicodeToUtf8( aProvider, pluginName )); - - MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::CallProviderL"); - } - -// ----------------------------------------------------------------------------- -// Resolves name of the ecom plugin which implements the livecomms engine api -// by using the callprovider // ----------------------------------------------------------------------------- // -void CMusApplicationManager::ResolvePluginNameL(TDes8& aPluginName) +TApaTask CMusApplicationManager::GetApaTask() { - MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::ResolvePluginNameL"); - - TBuf8 providerName ; - - // Read the call provider name - CallProviderL( providerName ); - - RImplInfoPtrArray pluginArray; - MusCleanupResetAndDestroy::PushL( pluginArray ); - - TEComResolverParams resolverParams; - - resolverParams.SetDataType ( providerName ); - resolverParams.SetWildcardMatch (ETrue); - - // Use default plugin even if listing fails - TRAPD( err, - REComSession::ListImplementationsL(KLcEngineInterfaceUid, resolverParams, pluginArray) ); - MUS_LOG1( "mus: [MUSSRV] List implementations compl:%d", err ); - if ( err == KErrNoMemory ) - { - User::Leave( err ); - } - - if( pluginArray.Count() > 0 ) - { - CImplementationInformation* info = pluginArray[ 0 ]; - __ASSERT_ALWAYS( aPluginName.MaxLength() >= info->DataType().Length(), - User::Leave( KErrArgument ) ); - aPluginName.Copy( info->DataType() ); - } - else - { - __ASSERT_ALWAYS( aPluginName.MaxLength() >= KDefaultEngineName().Length(), - User::Leave( KErrArgument ) ); - aPluginName.Copy( KDefaultEngineName() ); - } - CleanupStack::PopAndDestroy();//pluginArray - MUS_LOG( "mus: [MUSSRV] <- CMusApplicationManager::ResolvePluginNameL"); + MUS_LOG( "mus: [MUSSRV] <> CMusApplicationManager::GetApaTask()" ); + TUid appUid; + appUid.iUid = KMusUiUid; + return TApaTaskList( iWsSession ).FindApp( appUid ); } - -// ----------------------------------------------------------------------------- -// Creates command line used when starting application. -// ----------------------------------------------------------------------------- -// -HBufC* CMusApplicationManager::CreateCommandLineArgsLC() - { - MUS_LOG( "mus: [MUSSRV] -> CMusApplicationManager::CreateCommandLineLC"); - - TBuf8 pluginNameUtf8; - ResolvePluginNameL( pluginNameUtf8 ); - - MUS_LOG_TDESC8( "mus: [MUSSRV] Plugin name:", pluginNameUtf8 ); - - HBufC* commandLineArgs = HBufC::NewLC( KMusMgrMaxPluginNameLen ); - TPtr commandLineArgsPtr( commandLineArgs->Des() ); - User::LeaveIfError( - CnvUtfConverter::ConvertToUnicodeFromUtf8( - commandLineArgsPtr, pluginNameUtf8 ) ); - - MUS_LOG_TDESC( "mus: [MUSSRV] <- command line args:", commandLineArgsPtr ); - - return commandLineArgs; - } - -// End of File