diff -r 1e962b12a8db -r d2f833ab7940 contentstorage/cahandler/app/src/caapphandler.cpp --- a/contentstorage/cahandler/app/src/caapphandler.cpp Tue Jun 01 11:30:17 2010 +0300 +++ b/contentstorage/cahandler/app/src/caapphandler.cpp Fri Jun 11 16:13:51 2010 +0300 @@ -49,12 +49,16 @@ static const char caCmdClose[] = "close"; static const char caAttrWindowGroupId[] = "window_group_id"; static const char caAttrComponentId[] = "component_id"; -static const char caCmdRemove[] = "remove"; -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// +/*! + * Command handler for application entries. + * + * \lib caclient.lib + */ + +/*! + * Constructor. + */ CaAppHandler::CaAppHandler(QObject *parent): iEikEnv(CEikonEnv::Static()), iUsifUninstallOperation(NULL) @@ -62,15 +66,20 @@ Q_UNUSED(parent); } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// +/*! + * Destructor. + */ CaAppHandler::~CaAppHandler() { delete iUsifUninstallOperation; } +/*! + * Execute a given command. + * \param entry a reference to a CaEntry instance. + * \param command a given command. + * \retval an error code. + */ int CaAppHandler::execute(const CaEntry &entry, const QString &command) { int result(KErrGeneral); @@ -104,99 +113,93 @@ return result; } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CaAppHandler::launchApplicationL(const TUid aUid, TInt aViewId) +/*! + * Launch application + * \param uid UID of the application to launch. + * \param viewId id of the view the application is to start in. + */ +void CaAppHandler::launchApplicationL(const TUid uid, TInt viewId) { - if( aViewId > 0 && iEikEnv ) - { - TUid viewId = TUid::Uid( aViewId ); - TVwsViewId view( aUid, viewId ); + if (viewId > 0 && iEikEnv) { + TVwsViewId view(uid, TUid::Uid(viewId)); iEikEnv->EikAppUi()->ActivateViewL( view ); - } - else - { + } else { RWsSession wsSession; - User::LeaveIfError( wsSession.Connect() ); - CleanupClosePushL( wsSession ); + User::LeaveIfError(wsSession.Connect()); + CleanupClosePushL(wsSession); - CCaTaskList* taskList = CCaTaskList::NewLC( wsSession ); - TApaTask task = taskList->FindRootApp( aUid ); - CleanupStack::PopAndDestroy( taskList ); + CCaTaskList* taskList = CCaTaskList::NewLC(wsSession); + TApaTask task = taskList->FindRootApp(uid); + CleanupStack::PopAndDestroy(taskList); - if( task.Exists() ) - { + if (task.Exists()) { task.BringToForeground(); - } - else - { + } else { // TApaAppInfo size is greater then 1024 bytes // so its instances should not be created on the stack. - TApaAppInfo* appInfo = new( ELeave ) TApaAppInfo; - CleanupStack::PushL( appInfo ); + TApaAppInfo* appInfo = new(ELeave) TApaAppInfo; + CleanupStack::PushL(appInfo); TApaAppCapabilityBuf capabilityBuf; RApaLsSession appArcSession; - User::LeaveIfError( appArcSession.Connect() ); - CleanupClosePushL( appArcSession ); + User::LeaveIfError(appArcSession.Connect()); + CleanupClosePushL(appArcSession); - User::LeaveIfError( appArcSession.GetAppInfo( *appInfo, aUid ) ); - User::LeaveIfError( appArcSession.GetAppCapability( - capabilityBuf, aUid ) ); + User::LeaveIfError(appArcSession.GetAppInfo(*appInfo, uid)); + User::LeaveIfError(appArcSession.GetAppCapability( + capabilityBuf, uid)); TApaAppCapability &caps = capabilityBuf(); CApaCommandLine *cmdLine = CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL( appInfo->iFullName ); + cmdLine->SetExecutableNameL(appInfo->iFullName); + + if (caps.iLaunchInBackground) { + cmdLine->SetCommandL(EApaCommandBackground); + } else { + cmdLine->SetCommandL(EApaCommandRun); + } - if( caps.iLaunchInBackground ) - { - cmdLine->SetCommandL( EApaCommandBackground ); - } - else - { - cmdLine->SetCommandL( EApaCommandRun ); - } + cmdLine->SetTailEndL(KNullDesC8); + + User::LeaveIfError(appArcSession.StartApp(*cmdLine)); - cmdLine->SetTailEndL( KNullDesC8 ); - - User::LeaveIfError( appArcSession.StartApp( *cmdLine ) ); - - CleanupStack::PopAndDestroy( cmdLine ); - CleanupStack::PopAndDestroy( &appArcSession ); - CleanupStack::PopAndDestroy( appInfo ); + CleanupStack::PopAndDestroy(cmdLine); + CleanupStack::PopAndDestroy(&appArcSession); + CleanupStack::PopAndDestroy(appInfo); } CleanupStack::PopAndDestroy( &wsSession ); } } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// +/*! + * Closes application. + * \param flags an entry flags. + * \param windowGroupId window group id. + * \retval an error code. + */ int CaAppHandler::closeApplication(const EntryFlags &flags, int windowGroupId) { int result(KErrNone); - if (flags.testFlag(RunningEntryFlag) - && !( flags.testFlag(SystemEntryFlag)) - && windowGroupId > 0) { + if (flags.testFlag(RunningEntryFlag) && windowGroupId > 0) { RWsSession wsSession; result = wsSession.Connect(); if (result==KErrNone) { TWsEvent event; event.SetTimeNow(); - event.SetType( KAknShutOrHideApp ); - wsSession.SendEventToWindowGroup( windowGroupId, event ); + event.SetType(KAknShutOrHideApp); + wsSession.SendEventToWindowGroup(windowGroupId, event); } wsSession.Close(); } return result; } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// +/*! + * Uninstall application. + * \param flags flags of the application which is to uninstall. + * \param typeName type name of the entry. + * \param componentId component id. + * \retval an error code. + */ int CaAppHandler::handleRemove(const EntryFlags &flags, const QString &typeName, const QString &componentId) @@ -227,17 +230,17 @@ return result; } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CaAppHandler::startUsifUninstallL(TInt aComponentId) +/*! + * Start uninstall operation via usif. + * \param componentId component id. + */ +void CaAppHandler::startUsifUninstallL(TInt componentId) { if (iUsifUninstallOperation && iUsifUninstallOperation->IsActive()) { User::Leave( KErrInUse ); } delete iUsifUninstallOperation; iUsifUninstallOperation = NULL; - iUsifUninstallOperation = CCaUsifUninstallOperation::NewL(aComponentId); + iUsifUninstallOperation = CCaUsifUninstallOperation::NewL(componentId); }