diff -r 9d806967057c -r 7f0462e8c3da contentstorage/handlersrc/caapphandlerplugin.cpp --- a/contentstorage/handlersrc/caapphandlerplugin.cpp Tue Mar 23 23:42:03 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: ?Description - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "caapphandlerplugin.h" -#include "cainnerentry.h" -#include "cauninstalloperation.h" - -#include "cautils.h" -#include "cadef.h" - -// ======== MEMBER FUNCTIONS ======== - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCaAppHandlerPlugin::~CCaAppHandlerPlugin() - { - delete iUninstallOperation; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCaAppHandlerPlugin* CCaAppHandlerPlugin::NewL() - { - CCaAppHandlerPlugin* handler = new ( ELeave ) CCaAppHandlerPlugin(); - CleanupStack::PushL( handler ); - handler->ConstructL(); - CleanupStack::Pop( handler ); - return handler; - } - -// --------------------------------------------------------- -// CCaAppHandlerPlugin::CCaAppHandlerPlugin -// --------------------------------------------------------- -// -CCaAppHandlerPlugin::CCaAppHandlerPlugin() - { - iEikEnv = CEikonEnv::Static(); - iUninstallOperation = NULL; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCaAppHandlerPlugin::ConstructL() - { - BaseConstructL(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TBool CCaAppHandlerPlugin::SupportsType( const TDesC& aType ) - { - if( !aType.Compare( KCaTypeApp() ) || !aType.Compare( KCaTypeWidget() ) ) - { - return ETrue; - } - return EFalse; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCaAppHandlerPlugin::HandleCommandL( CCaInnerEntry& aEntry, - const TDesC8& aCommand ) - { - if( aCommand == KCaCmdOpen() && aEntry.GetEntryTypeName() - == KCaTypeApp() ) - { - TInt viewId( -1 ); - TBuf viewIdValue; - if( aEntry.FindAttribute( KCaAttrView(), viewIdValue ) ) - { - if( MenuUtils::GetTUint( viewIdValue, (TUint& ) viewId ) - != KErrNone ) - { - User::Leave( KErrCorrupt ); - } - } - LaunchApplicationL( TUid::Uid( aEntry.GetUid() ), KNullDesC8(), - viewId ); - } - else if( aCommand == KCaCmdClose() && aEntry.GetEntryTypeName() - == KCaTypeApp() ) - { - CloseApplicationL( aEntry ); - } - else if( aCommand == KCaCmdRemove() - && ( aEntry.GetEntryTypeName() == KCaTypeApp() - || aEntry.GetEntryTypeName() == KCaTypeWidget() ) ) - { - if( iUninstallOperation && iUninstallOperation->IsActive() ) - { - User::Leave( KErrInUse ); - } - delete iUninstallOperation; - iUninstallOperation = NULL; - iUninstallOperation = CCaUninstallOperation::NewL( aEntry ); - } - else - { - User::Leave( KErrNotSupported ); - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCaAppHandlerPlugin::LaunchApplicationL( const TUid aUid, - const TDesC8 &aParam, TInt aViewId ) - { - if( aViewId > 0 && iEikEnv ) - { - TUid viewId = TUid::Uid( aViewId ); - TVwsViewId view( aUid, viewId ); - iEikEnv->EikAppUi()->ActivateViewL( view ); - } - else - { - RWsSession wsSession; - User::LeaveIfError( wsSession.Connect() ); - CleanupClosePushL ( wsSession ); - - CAknTaskList* taskList = CAknTaskList::NewL( wsSession ); - TApaTask task = taskList->FindRootApp( aUid ); - delete taskList; - - if( task.Exists() ) - { - task.BringToForeground(); - } - else - { - TApaAppInfo appInfo; - TApaAppCapabilityBuf capabilityBuf; - RApaLsSession appArcSession; - User::LeaveIfError( appArcSession.Connect() ); - CleanupClosePushL ( appArcSession ); - - User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) ); - User::LeaveIfError( appArcSession.GetAppCapability( - capabilityBuf, aUid ) ); - - TApaAppCapability& caps = capabilityBuf(); - TFileName appName = appInfo.iFullName; - CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL( appName ); - - if( caps.iLaunchInBackground ) - { - cmdLine->SetCommandL( EApaCommandBackground ); - } - else - { - cmdLine->SetCommandL( EApaCommandRun ); - } - - cmdLine->SetTailEndL( aParam ); - - User::LeaveIfError( appArcSession.StartApp( *cmdLine ) ); - - CleanupStack::PopAndDestroy( cmdLine ); - CleanupStack::PopAndDestroy( &appArcSession ); - } - CleanupStack::PopAndDestroy( &wsSession ); - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCaAppHandlerPlugin::CloseApplicationL( CCaInnerEntry& aEntry ) - { - RWsSession wsSession; - User::LeaveIfError( wsSession.Connect() ); - CleanupClosePushL ( wsSession ); - - if( ( aEntry.GetFlags() & ERunning ) && - ( !( aEntry.GetFlags() & ESystem ) ) ) - { - RBuf value; - CleanupClosePushL( value ); - value.CreateL( KCaMaxAttrValueLen ); - if( aEntry.FindAttribute( KCaAttrWindowGroupId, value )) - { - TInt wgId( KErrNotFound ); - TLex16 parser(value); - if ( KErrNone == parser.Val( wgId ) && wgId > 0 ) - { - TWsEvent event; - event.SetTimeNow(); - event.SetType( KAknShutOrHideApp ); - wsSession.SendEventToWindowGroup( wgId, event ); - } - } - CleanupStack::PopAndDestroy( &value ); - } - - CleanupStack::PopAndDestroy( &wsSession ); - } -