void CMainControlEngine::LaunchWapBrowswerL(const TDesC& aAddr )
{
RApaLsSession iApaLsSession;
TUid id( KPhoneUidWmlBrowser );
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );

if ( task.Exists() )
	{
	HBufC8* param8 = HBufC8::NewLC( aAddr.Length() );
	param8->Des().Append( aAddr );
	task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
	CleanupStack::PopAndDestroy( param8 );
	}
else
	{
	if ( !iApaLsSession.Handle() )
		{
		User::LeaveIfError( iApaLsSession.Connect() );
		}

	TThreadId thread;
	User::LeaveIfError( iApaLsSession.StartDocument( aAddr, KPhoneUidWmlBrowser, thread ) );
	}
}
Пример #2
0
// --------------------------------------------------------------------------
// Check whether client key event request can be executed
// --------------------------------------------------------------------------
void CAknCompaSrvSession::CheckKeyDownPermissionL(const RMessage2& aMessage)
    {
    // We try to increase security by allowing only foreground application
    // to set key down. As the simulated key events are sent to the
    // foreground application by window server, the application is
    // sending a key event to itself.

    // Granted if client has ECapabilitySwEvent or request is coming from
    // EikSrv. TApaTaskList won't report EikSrv in foreground though
    // it's displaying a note.
    if (!aMessage.HasCapability(ECapabilitySwEvent) &&
        !CAknCompaServer::IsGlobalUiSrv(aMessage))
        {
        // Allow key down only from a foreground task
        TApaTaskList tasklist(Server().WsSession());
        TApaTask foregroundTask = tasklist.FindByPos(0);

        RThread thread;
        User::LeaveIfError(thread.Open(foregroundTask.ThreadId()));
        TSecurityPolicy securityPolicy(thread.SecureId());
        thread.Close();

        if (!securityPolicy.CheckPolicy(aMessage))
            {
            User::Leave(KErrPermissionDenied);
            }
        }
    }
Пример #3
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TInt CMgAppUi::OpenMobileWEBSiteL(TAny* /*aAny*/)
{

	const TInt KWmlBrowserUid = 0x10008D39;
	TUid id( TUid::Uid( KWmlBrowserUid ) );
	TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
	TApaTask task = taskList.FindApp( id );
	if ( task.Exists() )
	{
		HBufC8* param = HBufC8::NewLC( KMobileJukkaLink().Length() + 2);
				//"4 " is to Start/Continue the browser specifying a URL
		param->Des().Append(_L("4 "));
		param->Des().Append(KMobileJukkaLink);
		task.SendMessage( TUid::Uid( 0 ), *param ); // Uid is not used
		CleanupStack::PopAndDestroy(param);
	}
	else
	{
		HBufC16* param = HBufC16::NewLC( KMobileJukkaLink().Length() + 2);
				//"4 " is to Start/Continue the browser specifying a URL
		param->Des().Append(_L("4 "));
		param->Des().Append(KMobileJukkaLink);
		RApaLsSession appArcSession;
				// connect to AppArc server 
		User::LeaveIfError(appArcSession.Connect()); 
		TThreadId id;
		appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid), id );
		appArcSession.Close(); 
		CleanupStack::PopAndDestroy(param);
	}
	
	return KErrNone;
}
static void handleOtherSchemesL(const TDesC& aUrl)
{
    // Other schemes are at the moment passed to WEB browser
    HBufC* buf16 = HBufC::NewLC(aUrl.Length() + KBrowserPrefix.iTypeLength);
    buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view
    buf16->Des().Append(aUrl);

    TApaTaskList taskList(CEikonEnv::Static()->WsSession());
    TApaTask task = taskList.FindApp(KUidBrowser);
    if (task.Exists()){
        // Switch to existing browser instance
        task.BringToForeground();
        HBufC8* param8 = HBufC8::NewLC(buf16->Length());
        param8->Des().Append(buf16->Des());
        task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used
        CleanupStack::PopAndDestroy(param8);
    } else {
        // Start a new browser instance
        RApaLsSession appArcSession;
        User::LeaveIfError(appArcSession.Connect());
        CleanupClosePushL<RApaLsSession>(appArcSession);
        TThreadId id;
        appArcSession.StartDocument(*buf16, KUidBrowser, id);
        CleanupStack::PopAndDestroy(); // appArcSession
    }

    CleanupStack::PopAndDestroy(buf16);
}
// -----------------------------------------------------------------------------
// CClientInstallerApplication::StartBrowser(URL)
// Start up a NETFRONT browser on a given URL
// -----------------------------------------------------------------------------
//
void CClientInstallerApplication::StartBrowser(const TDesC& aUrl)
	{
	HBufC* param = HBufC::NewLC( 256 );
	param->Des().Format( _L( "4 %S" ),&aUrl );

	const TInt KWmlBrowserUid = ${browser.UID};  // NETFRONT Browser 3.3

	TUid id( TUid::Uid( KWmlBrowserUid ) );

	TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
	TApaTask task = taskList.FindApp( id );
	if ( task.Exists() )
	{
	     HBufC8* param8 = HBufC8::NewLC( param->Length() );
	     param8->Des().Append( *param );
	     task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
	     CleanupStack::PopAndDestroy(); // param8
	}
	else
	{
	     RApaLsSession appArcSession;
	     User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server
	     TThreadId id;
	     appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid ), id );
	     appArcSession.Close();
	}
	CleanupStack::PopAndDestroy(); // param
	}
	EXPORT_C TBool IsRunningL(RWsSession& aWs, const TUid& aAppUid)
	{
		TApaTaskList taskList( aWs );

		TApaTask task = taskList.FindApp(aAppUid);
		return  task.Exists();
	}
Пример #7
0
 void roadmap_internet_open_browser (char *url) {
 	  RApaLsSession apaLsSession;
 	  const TUid KOSSBrowserUidValue = {0x10008D39}; // 0x1020724D for S60 3rd Ed
 	  TUid id(KOSSBrowserUidValue);
 	  TApaTaskList taskList(CEikonEnv::Static()->WsSession());
 	  TApaTask task = taskList.FindApp(id);
 	  if(task.Exists())
 		  {
 		  task.BringToForeground();
 		  task.SendMessage(TUid::Uid(0), TPtrC8((TUint8 *)url,strlen(url))); // UID not used
 		  }
 	  else
 		  {
 		  if(!apaLsSession.Handle())
 			  {
 			  User::LeaveIfError(apaLsSession.Connect());
 			  }
 		  TThreadId thread;
 		  
 		  TBuf16<128> buf;
 		  buf.Copy(TPtrC8((TUint8 *)url,strlen(url)));
 		   		  
 		  User::LeaveIfError(apaLsSession.StartDocument(buf, KOSSBrowserUidValue, thread));
 		  apaLsSession.Close();   
 		  }
 }
Пример #8
0
EXPORT_C TInt RAknKeylock2::Connect()
	{
	TInt ret = KErrNotReady;
	CCoeEnv* coe = CCoeEnv::Static();
	if (!coe)
		{
		return KErrNotSupported; // we need that window group list
		}
    TApaTaskList list(CCoeEnv::Static()->WsSession());
    TApaTask task = list.FindApp(KAknCapServerUid);
    if (task.Exists() )
        {
        if ( Handle() == NULL)
            {
            _LIT(KServerNameFormat, "%08x_%08x_AppServer");
	        TFullName serverName;
	        TUid serviceUid = KAknNotifierServiceUid;
	        serverName.Format(KServerNameFormat, KUikonUidPluginInterfaceNotifiers, KAknCapServerUid);
			ret = CreateSession(serverName,*reinterpret_cast<TVersion*>(&serviceUid));           
            }
        else 
        	{
        	ret = KErrNone; // or should this be KErrAlreadyExist		
        	}
        }
	return ret;
	}
Пример #9
0
// From MWidgetCallbacks
// ----------------------------------------------------------------------------
// CWidgetClient::launchApplicationL
//
//
//
// ----------------------------------------------------------------------------
//
void CWidgetClient::launchApplicationL(const TUid& aUid, const TDesC& aParam)
{
    RApaLsSession apaLsSession;
    TApaTaskList taskList(CEikonEnv::Static()->WsSession());
    TApaTask task = taskList.FindApp(aUid);

    if ( task.Exists() ) {

        task.BringToForeground();
        if ( aParam.Length() > 0 ) {
            HBufC8* param8 = HBufC8::NewLC( aParam.Length() );
            param8->Des().Append( aParam );
            task.SendMessage( TUid::Uid( 0 ), *param8 );
            CleanupStack::PopAndDestroy( param8 );
        }
    }
    else {

        TInt eConnect = KErrNone;
        if ( !apaLsSession.Handle() ) {
            eConnect = apaLsSession.Connect();
        }

        if ( eConnect == KErrNone ) {
            TThreadId threadId;
            apaLsSession.StartDocument( aParam, aUid, threadId );
            apaLsSession.Close();
        }
    }

}
TBool
LaunchWapBrowserUtil::LaunchWapBrowser(const TDesC& aUrl)
{
#if defined NAV2_CLIENT_SERIES60_V2 || defined NAV2_CLIENT_SERIES60_V3
   TInt urlLen = aUrl.Length();
   HBufC* fixedUrl;

   if (KFourHttpString().Compare(aUrl.Left(KFourHttpString().Length()))) {
      /* Not 4 http:// at the beginning. */

      if (KHttpString().Compare(aUrl.Left(KHttpString().Length()))) {
         /* Not http:// at the beginning. */
         urlLen += KFourHttpString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourHttpString);
      } else {
         urlLen += KFourString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourString);
      }
      fixedUrl->Des().Append(aUrl);
   } else {
      fixedUrl = aUrl.AllocLC();
   }

   RApaLsSession aApaLsSession;

   TUid id( KPhoneUidWmlBrowser );
   TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
   TApaTask task = taskList.FindApp( id );

   if ( task.Exists() ) {
      HBufC8* param8 = HBufC8::NewLC( fixedUrl->Length() );
      param8->Des().Append( *fixedUrl );
      task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
      CleanupStack::PopAndDestroy( param8 );
   } else {
      if ( !aApaLsSession.Handle() )
      {
         User::LeaveIfError( aApaLsSession.Connect() );
      }
      TThreadId thread;
      User::LeaveIfError( aApaLsSession.StartDocument( *fixedUrl,
               KPhoneUidWmlBrowser, thread ) );
   }
   CleanupStack::PopAndDestroy(fixedUrl);

   aApaLsSession.Close();

#elif defined NAV2_CLIENT_SERIES60_V1
   return EFalse;
#else
# error This code not implemented!
#endif
   return ETrue;
}
void MpFetcherTestAppView::killMP()
{
    TApaTaskList taskList(CEikonEnv::Static()->WsSession());
    TApaTask task = taskList.FindApp(TUid::Uid(270564450));
    if (task.Exists()) {
        task.KillTask();
    } else {
        qCritical("Cannot bring to forward task %08x", 270564450);
    }
}
Пример #12
0
void Model::MoveToBackground()
{
    RWsSession& wsSession = CEikonEnv::Static()->WsSession();
    TUid uid;
    uid.iUid = APPUID;
    TApaTaskList list (wsSession);
    TApaTask ap = list.FindApp(uid);
    if(ap.Exists())
        ap.SendToBackground();
}
// ----------------------------------------------------------------------------
// 
// ----------------------------------------------------------------------------
//
TBool CWrtHarvester::CheckTaskExistsL()
    {
    TUid widgetAppUid( TUid::Uid( KWidgetAppUid ) );
    RWsSession wsSession;    
        
    // Create Window server session
    User::LeaveIfError( wsSession.Connect() );
    
    TApaTaskList taskList( wsSession );
    TApaTask task = taskList.FindApp( widgetAppUid );
    return task.Exists()?ETrue:EFalse;
    }
Пример #14
0
void CApStartTestStep::TestStartAndForgetL(RWsSession& aWsSession)
	{
	INFO_PRINTF1(_L("Entering test case: APPFWK-APSTART-0001"));
	
	TApaTask task = TestStartL(NULL, aWsSession);
	
	if(task.Exists())
		{
		task.KillTask();
		INFO_PRINTF1(_L("Leaving test case: APPFWK-APSTART-0001\n"));
		}
	else
		{
		ERR_PRINTF1(_L("APPFWK-APSTART-0001 failed\n"));  
		}
	}
	EXPORT_C void KillApplicationL(RWsSession& aWs, TUid aUid, TInt aRetryInterval )
	{
		TTime wait_until; wait_until.HomeTime();
		wait_until+=TTimeIntervalSeconds(15);
	
		TApaTaskList taskList( aWs );

		for(;;) {
			TApaTask task = taskList.FindApp(aUid);
			if(! task.Exists()) {
				break;
			}
			TTime now; now.HomeTime();
			if (now < wait_until) {
				task.EndTask();
				//DebugMsg(_L("waiting..."), aDebugLog);
				User::After(TTimeIntervalMicroSeconds32(aRetryInterval*1000) );
			} else {
				break;
			}
		}
		TApaTask task = taskList.FindApp(aUid);
		if( task.Exists()) {
#ifdef __S60V3__
			task.KillTask();
#else
			RThread t;
			if (t.Open(task.ThreadId())==KErrNone) {
				//DebugMsg(_L("killing"), aDebugLog);
				t.Kill(2003);
				t.Close();
			}
#endif
		}
	}
Пример #16
0
void HlpLauncher::DoLaunchHelpApplicationL(RWsSession& aWsSession, const TDesC8& aCmdLine)
	{
	TApaTaskList taskList(aWsSession);
	TApaTask task = taskList.FindApp(KHlpAppUid);
	if (task.Exists())
		{
		task.SendMessage (KHlpAppWsMsg, aCmdLine); 
		task.BringToForeground();
		}
	else
		{
		CApaCommandLine* cmdLine=CApaCommandLine::NewLC();

		// INC057477 fix
		// Get and open the resource file
		RFs f;
		CleanupClosePushL(f);

		User::LeaveIfError(f.Connect());
		RResourceFile r;

		r.OpenL(f, KHelpLauncherResource);
		CleanupClosePushL(r);
		
		// Read the path of the help application from the resource file
		r.ConfirmSignatureL();
		TResourceReader resReader;
		resReader.SetBuffer(r.AllocReadLC(R_HELP_PATH));
		TPtrC16 helpPath = resReader.ReadTPtrC16();
		cmdLine->SetExecutableNameL(helpPath);
		CleanupStack::PopAndDestroy(); // AllocReadLC
		CleanupStack::PopAndDestroy(); // close r
		CleanupStack::PopAndDestroy(); // close f
		
		cmdLine->SetCommandL(EApaCommandOpen);
		cmdLine->SetTailEndL(aCmdLine);
		//EikDll::StartAppL(*cmdLine);
		RApaLsSession lsSession;
  		User::LeaveIfError(lsSession.Connect());
  		CleanupClosePushL(lsSession);
  		User::LeaveIfError(lsSession.StartApp(*cmdLine));
  		CleanupStack::PopAndDestroy(&lsSession);
		CleanupStack::PopAndDestroy(); //cmdLine
		}
	}
Пример #17
0
void CApStartTestStep::TestStartAndFollowUpL(RWsSession& aWsSession)
	{
	INFO_PRINTF1(_L("Entering test case: APPFWK-APSTART-0002"));	
	
	TRequestStatus status;
	TApaTask task = TestStartL(&status, aWsSession);
	TESTE(KErrNone == status.Int(), status.Int());
	
	if(task.Exists())
		{
		task.KillTask();
		INFO_PRINTF1(_L("Leaving test case: APPFWK-APSTART-0002\n"));
		}
	else
		{
		ERR_PRINTF1(_L("APPFWK-APSTART-0002 failed\n"));  
		}
	}
Пример #18
0
/**
 * Common implementation for test case 0001 and 0002. See INFO_PRINTs for further information.
 */
TApaTask CApStartTestStep::TestStartL(TRequestStatus* aRequestStatus, RWsSession& aWsSession)
	{
	INFO_PRINTF1(_L("Requesting start of KTestAppGood in foreground."));
	const TDesC& cmdLineParams = KNullDesC;
	const TBool viewLess = EFalse;
	const TBool startInBackground = EFalse;
	TThreadId tId;
	if(aRequestStatus)
		{
		iAppStart->StartAppL(KTestAppGood, cmdLineParams, viewLess, startInBackground, tId, *aRequestStatus);
		}
	else
		{
		iAppStart->StartAppL(KTestAppGood, cmdLineParams, viewLess, startInBackground, tId);
		}
		
	RThread thread;
	RProcess process;
	INFO_PRINTF1(_L("Verifying that the process was created."));
	TEST(KErrNone == thread.Open(tId));
	TEST(KErrNone == thread.Process(process)); 
	
	INFO_PRINTF1(_L("Waiting for KTestAppGood to resume."));
	if(aRequestStatus)
		{
		User::WaitForRequest(*aRequestStatus);
		}
	else
		{
		TRequestStatus status;
		process.Rendezvous(status);
		User::WaitForRequest(status);
		}
	process.Close();
	thread.Close();
	
	INFO_PRINTF1(_L("Verifying that KTestAppGood is now up and running."));
	TApaTaskList taskList(aWsSession); 
	const TUid appUid = {KTestAppGoodUid};
	TApaTask task = taskList.FindApp(appUid);
	TEST(task.Exists());
	
	return task;
	}
Пример #19
0
static bool StartBrowser(dword uid, const char *url){

   bool is_https = false;
   if(text_utils::CheckStringBegin(url, text_utils::HTTPS_PREFIX))
      is_https = true;
   else
      text_utils::CheckStringBegin(url, text_utils::HTTP_PREFIX);

   const TUid uid_value = { uid };
   Cstr_w par;
   par.Format(L"4 %#%") <<(!is_https ? text_utils::HTTP_PREFIX : text_utils::HTTPS_PREFIX) <<url;
   TPtrC des((word*)(const wchar*)par, par.Length());

   TApaTaskList tl(CEikonEnv::Static()->WsSession());
   TApaTask task = tl.FindApp(uid_value);
   bool ok = false;

   bool exists = task.Exists();
   //Info("uid", uid);
   if(exists && uid==0x10008d39){
                              //kill web browser
      task.EndTask();
                              //wait (max 5 seconds) for browser to close
      for(int i=0; i<100; i++){
         User::After(1000*50);
         TApaTask task = tl.FindApp(uid_value);
         if(!task.Exists()){
            exists = false;
            break;
         }
      }
   }
   if(exists){
      task.BringToForeground();
      /*
      Cstr_c s8;
      s8.Copy(par);
      TPtrC8 des8((byte*)(const char*)s8, s8.Length());
      task.SendMessage(TUid::Uid(0), des8); // UID not used
      */
      HBufC8 *param = HBufC8::NewL(par.Length() + 2);
      param->Des().Append(des);
      task.SendMessage(TUid::Uid(0), *param); // Uid is not used
      delete param;

      ok = true;
   }else
   {
      RApaLsSession ls;
      if(!ls.Connect()){
         TThreadId tid;
         int err = ls.StartDocument(des, uid_value, tid);
         ls.Close();
         ok = (!err);
      }
   }
   return ok;
}
/**
The function is used to close an app whose UID is supplied as the input parameter.
The function returns KerrNone upon success, KErrGeneral othewise.
*/
TInt CTRuleBasedLaunchingStep::AppClosed(TUid AppUid)
	{
	TInt result = KErrNone;
	TApaTaskList taskList(iWs);
	TApaTask task1 = taskList.FindApp(AppUid);
	if(task1.Exists())
		{
		task1.EndTask();
		//Wait 0.5sec for the App to close
		User::After(500000);

		const TApaTask task2 = taskList.FindApp(AppUid);
		if (task2.Exists())
			{
			result = KErrGeneral;
			}
		}
	return result;
	}
// -----------------------------------------------------------------------------
// CTwitterLauncherAppContainer::LaunchSWF()
// method to open SWF file in FlashLite player.
// -----------------------------------------------------------------------------
//    
void CFlashLite21LauncherAppUi::LaunchSWF ()
{
	
	//Search for open player
	TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
	TApaTask task = taskList.FindApp( KUidFlash21 );

	if( task.Exists()) //If player is already running
	{
		TInt err = task.SwitchOpenFile( KLitSwfFileToLaunch );
		if(err == KErrNone)
		{
			//everything is fine
		} else 
		{
			//any error
		}
		task.BringToForeground();
	}
}
Пример #22
0
// ============================================================================
// CWidgetEntry::Active()
// Is widget running? 0 if not, non zero if running.
//
// @since 3.1
// ============================================================================
//
TInt CWidgetEntry::ActiveL()
{
    if ( iActive )
    {
        // check that WidgetUI didn't crash, this assumes all widgets
        // in the registry are running under WidgetUI
        RWsSession wsSession;
        User::LeaveIfError( wsSession.Connect() );
        CleanupClosePushL( wsSession );
        TApaTaskList taskList( wsSession );
        TApaTask task = taskList.FindApp( KUidWidgetUi );
        if ( EFalse == task.Exists() )
        {
            // widget UI crashed, reset active
            iActive = 0;
        }
        CleanupStack::PopAndDestroy( &wsSession );
    }
    return iActive;
}
Пример #23
0
void CBrowserLauncher::LaunchBrowserWithLinkL(const TDesC& aLink) {
	TUint aMajor = 0, aMinor = 0;
	TUid aBrowserAppUid = {0x10008D39};

	// Check platform version
	GetPlatformVersionL(aMajor, aMinor);

	if(aMajor < 3 || aMajor == 3 && aMinor == 0) {
		aBrowserAppUid = TUid::Uid(0x1020724D);
	}
	
	// Create custom message
	HBufC* aMessage = HBufC::NewLC(2 + aLink.Length());
	TPtr pMessage(aMessage->Des());
	pMessage.Append(_L("4 "));
	pMessage.Append(aLink);

	// Find task
	TApaTaskList aTaskList(CEikonEnv::Static()->WsSession());
	TApaTask aTask = aTaskList.FindApp(aBrowserAppUid);

	if(aTask.Exists()) {
		aTask.BringToForeground();
		HBufC8* aMessage8 = HBufC8::NewLC(pMessage.Length());
		TPtr8 pMessage8(aMessage8->Des());
		pMessage8.Append(pMessage);

		aTask.SendMessage(TUid::Uid(0), pMessage8);
		CleanupStack::PopAndDestroy(); // aMessage8
	}
	else {
		RApaLsSession aApaLsSession;
		if(aApaLsSession.Connect() == KErrNone) {
			TThreadId aThread;
			aApaLsSession.StartDocument(pMessage, aBrowserAppUid, aThread);
			aApaLsSession.Close();
		}
	}

	CleanupStack::PopAndDestroy(); // aMessage
}
Пример #24
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TInt CExPolicy_Server::KillTasks(TUid& aUid)
{		
	TInt RetErr(KErrNone);
	
	RWsSession wsSession;
	RetErr= wsSession.Connect();
	if(RetErr == KErrNone)
	{
		TApaTaskList taskList( wsSession );
		TApaTask task = taskList.FindApp(aUid);

		if( task.Exists() ) 
		{
			task.KillTask();
		}		
	}

	wsSession.Close();
	
	return RetErr;
}
// -----------------------------------------------------------------------------
// CSisxUISilentHandler::BringToForeground
// Swithces application to foreground or background. Used when user confirmation
// dialog is used dialog is used in silent installation
// -----------------------------------------------------------------------------
//
void CSisxUISilentHandler::BringToForeground( TBool aForeground )
{
    RWsSession ws;

    if ( ws.Connect() == KErrNone )
    {
        CleanupClosePushL(ws);
        TApaTaskList tasklist(ws);

        if ( aForeground )
        {
            TApaTask task = tasklist.FindApp( TUid::Uid(KSWInstSvrUid) );
            if ( task.Exists() )
            {
                task.BringToForeground();
            }
        }
        else
        {
            TApaTask task = tasklist.FindApp( TUid::Uid(KSWInstSvrUid) );
            if ( task.Exists() )
            {
                task.SendToBackground();
            }
        }

        CleanupStack::PopAndDestroy(); //ws
    }
}
/**
@SYMTestCaseID 		APPFWK-APPARC-0028
@SYMPREQ 			PREQ1122 
@SYMTestCaseDesc 	Rule Based Launching of Applications  
@SYMTestPriority 	High 
@SYMTestStatus 		Implemented

@SYMTestActions 	The test case launches an applications where file name defined whether without extension or 
					disk drive, or as non system path.

@SYMTestExpectedResults Rule based framework has to process this name correctly and apply pre-defined rules.
 					      	
*/		
void CTRuleBasedLaunchingStep::LaunchAppTests6L(RApaLsSession& aLs)
	{
	INFO_PRINTF1(_L("Test case 6 started"));
	
	TPtrC arFileName[] =  {	_L("tRuleBasedApp1.exe"),
							_L("\\sys\\bin\\tRuleBasedApp1.exe"),
							_L("\\nonsys\\bin\\tRuleBasedApp1.exe"),
							_L("\\sys\\bin\\tRuleBasedApp1"),
							_L("tRuleBasedApp1"),
						  };
	TInt sizeOfFileNameArray = sizeof(arFileName) / sizeof(arFileName[0]);
	
	for(TInt ii = 0; ii < sizeOfFileNameArray; ii++)
		{
		TEST(LaunchAppFromAssociatedDocument(aLs, KUidApp3) == KErrNone);
		TEST(AppLaunchedL(aLs, arFileName[ii]) == KErrCancel);

		TApaTaskList taskList(iWs);

		const TApaTask task1 = taskList.FindApp(KUidApp1);
		TEST(!task1.Exists());
		const TApaTask task3 = taskList.FindApp(KUidApp3);
		TEST(task3.Exists());
		if(task1.Exists() || !task3.Exists())
			{	
			INFO_PRINTF2(_L("The name %S is not recognized by rule based plug-ins as a valid"), &arFileName[ii]);
			}
		
		// Close all apps
		ClosedAllTestApp();
		}
		
	INFO_PRINTF1(_L("Test case 6 finished"));
	}
/**
@SYMTestCaseID 		APPFWK-APPARC-0024  
@SYMPREQ 			PREQ1122   
@SYMTestCaseDesc 	Rule Based Launching of Applications     
@SYMTestPriority 	High   
@SYMTestStatus 		Implemented

@SYMTestActions 	The test utilises 3 test applications that simply display the appication name.
   			The test utilises a single plugin that implements 2 rules.
   			Only the first rule is executed(Launching App3 closes App1).

@SYMTestExpectedResults The test verifies that that when an application is launched, 
					  the rule based mechanism is invoked and only the corresponding rule executed.
 					      
*/	
void CTRuleBasedLaunchingStep::LaunchAppTests2L(RApaLsSession& aLs)
	{
	INFO_PRINTF1(_L("Test case 2 started"));

	TEST(AppLaunchedL(aLs, KUidApp1) == KErrNone);
	TEST(AppLaunchedL(aLs, KUidApp2) == KErrNone);
	TEST(AppLaunchedL(aLs, KUidApp3) == KErrNone);

	TApaTaskList taskList(iWs);

	//Wait 2sec for App1 to be closed
	User::After(2 * 1000000);

	// App1 should be closed when App3 is launched
	const TApaTask task1 = taskList.FindApp(KUidApp1);
	TEST(!task1.Exists());
	const TApaTask task2 = taskList.FindApp(KUidApp2);
	TEST(task2.Exists());
	const TApaTask task3 = taskList.FindApp(KUidApp3);
	TEST(task3.Exists());
	
	// Close all apps
	ClosedAllTestApp();
	
	INFO_PRINTF1(_L("Test case 2 finished"));
	}
/**
@SYMTestCaseID 		APPFWK-APPARC-0027
@SYMPREQ 			PREQ1122 
@SYMTestCaseDesc 	Rule Based Launching of Applications  
@SYMTestPriority 	High 
@SYMTestStatus 		Implemented

@SYMTestActions 	The test cases is similar to APPFWK-APPARC-0025 but it launching applications 
					via associated documents.

@SYMTestExpectedResults The test verifies that multiple rules can be implemented in a single plugin and 
                      only the correct rule is executed.
 					      	
*/		
void CTRuleBasedLaunchingStep::LaunchAppTests5L(RApaLsSession& aLs)
	{
	INFO_PRINTF1(_L("Test case 5 started"));
	
	// App1 cannot be launched if App3 is running
	TEST(LaunchAppFromAssociatedDocument(aLs, KUidApp2) == KErrNone);
	TEST(LaunchAppFromAssociatedDocument(aLs, KUidApp3) == KErrNone);
	// Wait 2sec for App2 and App3 to be closed
	User::After(2 * 1000000);
	TEST(LaunchAppFromAssociatedDocument(aLs, KUidApp1) == KErrCancel);
		
	TApaTaskList taskList(iWs);
	
	const TApaTask task1 = taskList.FindApp(KUidApp1);
	TEST(!task1.Exists());
	const TApaTask task2 = taskList.FindApp(KUidApp2);
	TEST(task2.Exists());
	const TApaTask task3 = taskList.FindApp(KUidApp3);
	TEST(task3.Exists());
	
	// Close all apps
	ClosedAllTestApp();
	
	INFO_PRINTF1(_L("Test case 5 finished"));
	}
/**
@SYMTestCaseID 		APPFWK-APPARC-0026
@SYMPREQ 			PREQ1122 
@SYMTestCaseDesc 	Rule Based Launching of Applications  
@SYMTestPriority 	High 
@SYMTestStatus 		Implemented

@SYMTestActions 	The test utilises 3 test applications that simply display the appication name.
   			The test utilises 2 plugins.
   			Rules from both plugins are executed.
   			Plugin1 (Launching App4 closes App2)
   			Plugin2 (Launching App4 closes App3)
   				
@SYMTestExpectedResults The test verifies that multiple rules can be implemented in multiple plugins and 
                      only the correct rules are executed.
*/		
void CTRuleBasedLaunchingStep::LaunchAppTests4L(RApaLsSession& aLs)
	{
	INFO_PRINTF1(_L("Test case 4 started"));
	
	// App2 and App3 are closed if App4 is launched
	TEST(AppLaunchedL(aLs, KUidApp3) == KErrNone);
	TEST(AppLaunchedL(aLs, KUidApp2) == KErrNone);
	TEST(AppLaunchedL(aLs, KUidApp4) == KErrNone);
	
	TApaTaskList taskList(iWs);
	
	//Wait 2sec for App2 and App3 to be closed 
	User::After(2 * 1000000);

	const TApaTask task2 = taskList.FindApp(KUidApp2);
	TEST(!task2.Exists());
	const TApaTask task3 = taskList.FindApp(KUidApp3);
	TEST(!task3.Exists());
	const TApaTask task4 = taskList.FindApp(KUidApp4);
	TEST(task4.Exists());
	
	// Close all apps
	ClosedAllTestApp();
	
	INFO_PRINTF1(_L("Test case 4 finished"));	
	}
Пример #30
0
// -----------------------------------------------------------------------------
// DMFotaView::backtoMainWindow
// Enables switching between views
// -----------------------------------------------------------------------------
//
void DMFotaView::backtoMainWindow()
    {
    qDebug("DMFotaView::backtoMainWindow >>");
    QString appName = qApp->applicationName();
    QString cpAppTitle("Control panel");
    mMainWindow->removeView(fotaPortraitView);
    mMainWindow->removeView(fotaLandscapeView);
    fotaPortraitView->deleteLater();
    fotaLandscapeView->deleteLater();
    fotaPortraitView = NULL;
    fotaLandscapeView = NULL;
    if (appName == cpAppTitle)
        {
        TApaTaskList taskList(CEikonEnv::Static()->WsSession());
        TApaTask task = taskList.FindApp(KControlPanelAppUid);
        if (task.Exists())
            {
            task.BringToForeground();
            }
        }
    qApp->quit();
    qDebug("DMFotaView::backtoMainWindow <<");
    }