예제 #1
0
void CTcAppLauncher::RunL()
	{
	// Fatal error occurred, report
	User::LeaveIfError( iStatus.Int() );

	if( iDismissDialog )
		{
		TKeyEvent event;
		event.iCode = EKeyDevice3;
		RWsSession wsSession;
		User::LeaveIfError( wsSession.Connect() );
		wsSession.SimulateKeyEvent( event );
		wsSession.Close();
		}

	RApaLsSession apparc;
	User::LeaveIfError( apparc.Connect() );
	CleanupClosePushL( apparc );

	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
	cmdLine->SetExecutableNameL( iAppName );
	cmdLine->SetCommandL( EApaCommandRun );

	User::LeaveIfError( apparc.StartApp( *cmdLine ) );
	CleanupStack::PopAndDestroy( 2 );

	// Write log entry
	LOG( _L("[APPLAUNCHER] Client restarted.") );
	delete this;
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StartProcessByFullNameL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StartProcessByFullNameL ( const TDesC8& aName )
{
    RDEBUG("CTerminalControlServer::StartProcessByFullNameL");

    // 8bit to 16bit string
    //
    HBufC* fileNameBuf = HBufC::NewLC( aName.Length() );
    TPtr   fileName(fileNameBuf->Des());
    fileName.Copy( aName );

    // Connect to application architecture server
    //
    RApaLsSession apaLs;
    User::LeaveIfError( apaLs.Connect() );
    CleanupClosePushL( apaLs );

    // Create command line for process
    //
    CApaCommandLine* cmd = CApaCommandLine::NewLC();

    cmd->SetExecutableNameL( fileName );
    cmd->SetDocumentNameL( KNullDesC() );
    cmd->SetCommandL( EApaCommandRun );

    // Start application
    //
    User::LeaveIfError( apaLs.StartApp( *cmd ) );

    CleanupStack::PopAndDestroy( cmd );
    CleanupStack::PopAndDestroy( &apaLs );
    CleanupStack::PopAndDestroy( fileNameBuf );
}
예제 #3
0
// ---------------------------------------------------------------------------
// Launches the app server.
// ---------------------------------------------------------------------------
// 
EXPORT_C void RAlfClientBase::LaunchAppL( 
    TUid aAppUid, 
    TUint aServerDifferentiator, 
    TThreadId& aThreadId )
	{
	RApaLsSession apa;
	User::LeaveIfError( apa.Connect() );
	CleanupClosePushL( apa );
	
	TApaAppInfo info;
	User::LeaveIfError( apa.GetAppInfo( info, aAppUid ) );

	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
	cmdLine->SetExecutableNameL( info.iFullName );
	cmdLine->SetServerRequiredL( aServerDifferentiator );
    // Set the command to start the server in background
    cmdLine->SetCommandL( EApaCommandBackground );        

	TRequestStatus status;	
	TInt err = apa.StartApp( *cmdLine, aThreadId, &status );
    
    User::LeaveIfError( err );
    
    User::WaitForRequest(status);
    
    User::LeaveIfError( status.Int() );
    
	CleanupStack::PopAndDestroy( cmdLine );
	CleanupStack::PopAndDestroy( &apa );
	}
예제 #4
0
/*!
  return always true, and handle the error in ruby.
  error return is "failed with uid:0x12345678" where 0x12345678 is replaced with given uid
*/
bool LaunchFixture::execute(void * objectInstance, QString actionName, QHash<QString, QString> parameters, QString & stdOut)
{
    bool result = true;

    //TasLogger::logger()->debug("> LaunchFixture::execute:" + actionName);

    if(actionName == "launch_with_uid"){
        bool ok;
        QString temp = parameters.value("UID");
        //TasLogger::logger()->debug("> LaunchFixture::UID: '" + temp + "'");
        TUint uid_i = temp.toUInt(&ok, 0);
        //TasLogger::logger()->debug("  ok: " + QString::number(ok) + " uid: " + QString::number(uid_i));
        TUid uid = TUid::Uid(uid_i);
        //T R A P D starts
        TRAPD(trapErr,
            RApaLsSession session;
            TInt err = session.Connect();
            User::LeaveIfError(err);
            //TasLogger::logger()->debug("  session " );

            CleanupClosePushL(session);
            TApaAppInfo info;
            err = session.GetAppInfo(info,uid);
            User::LeaveIfError(err);
            //TasLogger::logger()->debug("  appinfo " );

            CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
            cmdLine->SetExecutableNameL(info.iFullName);
            cmdLine->SetCommandL(EApaCommandRun);
            User::LeaveIfError(session.StartApp(*cmdLine));
            //TasLogger::logger()->debug("  command line " );
            stdOut.append(QString((QChar*) info.iFullName.Ptr(), info.iFullName.Length()));
            CleanupStack::PopAndDestroy(2);
        );
예제 #5
0
bool OpenFileBySystem(C_application_base &app, const wchar *filename, dword app_uid){

   Cstr_w full_path;
   C_file::GetFullPath(filename, full_path);
   TPtrC fn((word*)(const wchar*)full_path);

   int err = 0;
   {
      RApaLsSession ls;
      ls.Connect();
#if !defined __SYMBIAN_3RD__
      //if(!app_uid)
      {
         TThreadId tid;
         err = 1;
         if(!app_uid){
            TRAPD(te, err = ls.StartDocument(fn, tid));
         }else{
            TUid uid;
            uid.iUid = app_uid;
            TRAPD(te, err = ls.StartDocument(fn, uid, tid));
         }
      }//else
//#endif
#else
      {
         TUid uid;
         if(app_uid){
            uid.iUid = app_uid;
            err = 0;
         }else{
#if defined __SYMBIAN_3RD__
            TDataType dt;
            err = ls.AppForDocument(fn, uid, dt);
#endif
         }
         if(!err){
            TApaAppInfo ai;
            err = ls.GetAppInfo(ai, uid);
            if(!err){
               //User::Panic(ai.iFullName, 0);
               CApaCommandLine *cmd = CApaCommandLine::NewL();
#ifdef __SYMBIAN_3RD__
               cmd->SetExecutableNameL(ai.iFullName);
#else
               cmd->SetLibraryNameL(ai.iFullName);
#endif
               cmd->SetDocumentNameL(fn);
               cmd->SetCommandL(EApaCommandOpen);
               err = ls.StartApp(*cmd);
               delete cmd;
            }
         }
      }
#endif
      ls.Close();
   }
   return (!err);
}
/**
The function is used to launch an application using full file name as param.
*/
TInt CTRuleBasedLaunchingStep::AppLaunchedL(RApaLsSession& aLs, const TDesC& aAppFullFileName)
	{	
	CApaCommandLine* cmdLn = CApaCommandLine::NewLC();     
	cmdLn->SetExecutableNameL(aAppFullFileName);
	TInt result = aLs.StartApp(*cmdLn);
	//Wait 0.5sec for App to start
	User::After(500000);
	CleanupStack::PopAndDestroy(cmdLn);
	return result;
	}
void applistModel::ExecuteAction(QVariant variant)
{
    LS("applistModel::ExecuteAction =>>");
    QString fullName = variant.toString();

    CApaCommandLine* cmdLine = CApaCommandLine::NewL();
    TBuf<256> fn(fullName.utf16());
    cmdLine->SetExecutableNameL(fn);
    cmdLine->SetCommandL(EApaCommandRun);
    //TODO: StartApp returns faillure code. handle it to show error
    m_session.StartApp(*cmdLine);
    delete cmdLine;

    LS("applistModel::ExecuteAction <<");
}
/**
The function is used to launch an app whose UID is supplied as its second input parameter.
The function returns KErrNone upon success, KErrGeneral otherwise.
*/
TInt CTRuleBasedLaunchingStep::AppLaunchedL(RApaLsSession& aLs, const TUid& aAppUid)
	{	
	TApaAppInfo info; 
	TFileName fileName;
	aLs.GetAppInfo(info,aAppUid);
	//Wait 0.5sec for function to complete
	User::After(500000);
	fileName = info.iFullName; 
	CApaCommandLine* cmdLn = CApaCommandLine::NewLC();     
	cmdLn->SetExecutableNameL(fileName);
	TInt result = aLs.StartApp(*cmdLn);
	//Wait 0.5sec for App to start
	User::After(500000);
	CleanupStack::PopAndDestroy(cmdLn);
	return result;
	}
예제 #9
0
/** Process command parameters */
TBool CGLPlanetsAppUi::ProcessCommandParametersL(CApaCommandLine &aCommandLine)
	{
	TPtrC backgroundColor = aCommandLine.ExecutableName();
	iGLPlanets = CGLPlanets::NewL(iAppView->Window(), backgroundColor, this, KParentQueueName());
	iGLPlanets->Start();
	return CEikAppUi::ProcessCommandParametersL(aCommandLine);
	}
/** Process command parameters */
TBool CMultipleSurfacesAppUi::ProcessCommandParametersL(CApaCommandLine &aCommandLine)
	{
	TPtrC childQueueName = aCommandLine.ExecutableName();	
	iMultipleSurfaces = CMultipleSurfaces::NewL(CCoeEnv::Static()->WsSession(),
	        CCoeEnv::Static()->RootWin(), childQueueName, this, KParentQueueName());
	iMultipleSurfaces->Start();
	return CEikAppUi::ProcessCommandParametersL(aCommandLine);
	}
예제 #11
0
void RAlfClientBase::StartAsyncL(TRequestStatus* aStatus)
    {
    ASSERT(iApa==0 && iCmdLine == 0);
    // Start the server application
    TName serverName;
    TUint differentiator( 0 );
    
    differentiator = KAlfAppServerInterfaceUid3;
    ConstructServerName( 
        serverName, 
        TUid::Uid(KAlfAppServerInterfaceUid3) , 
        differentiator );
    
    TFindServer serverFinder(serverName);
    TFullName fullName;
    if (serverFinder.Next(fullName) == KErrNone)
        {
        User::Leave(KErrAlreadyExists);
        }
        
    TThreadId threadId;
    // we don't have proper destructor and thus we don't take
    // "normal" ownership on our members...
    
    // assign to member after poping from cleanup stack - codescanner now happy
  RApaLsSession*  apa = new (ELeave) RApaLsSession;
	CleanupStack::PushL(apa);
	User::LeaveIfError( apa->Connect() );
	CleanupClosePushL( *apa );
	
	TApaAppInfo info;
	User::LeaveIfError( apa->GetAppInfo( info, TUid::Uid(KAlfAppServerInterfaceUid3) ) );

	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
	cmdLine->SetExecutableNameL( info.iFullName );
	cmdLine->SetServerRequiredL( differentiator );
    // Set the command to start the server in background
    cmdLine->SetCommandL( EApaCommandBackground );        

	User::LeaveIfError(apa->StartApp( *cmdLine, threadId, aStatus ));

    CleanupStack::Pop(3);
    iCmdLine=cmdLine;
    iApa = apa;
    }
예제 #12
0
TInt RTestApaLsSession::TestExeRecognizerL(const CApaCommandLine& aCommandLine)
	{
	TThreadId dummyThreadId;
	TPckg<TThreadId> threadId(dummyThreadId);
	const TInt opcode=EAppListServStartAppWithoutReturningThreadId;
	TIpcArgs ipcArgs;
	aCommandLine.GetIpcArgsLC(ipcArgs);
	ipcArgs.Set(CApaCommandLine::EIpcFirstFreeSlot, &threadId);
	User::LeaveIfError(SendReceive(opcode, ipcArgs));
	CleanupStack::PopAndDestroy(); // the TIpcArgs
	return KErrNone;
	}
예제 #13
0
/** 
Set up the CApaCommandLine object which will be used to start the app.
*/
void CApaAppStart::SetupCommandLineL(CApaCommandLine& aCmdLine,
					const TDesC& aFileName,
					const TDesC8& aArgs,
					TBool aViewLess,
					TBool aStartInBackground)
	{
	
	aCmdLine.SetExecutableNameL(aFileName);
	aCmdLine.SetTailEndL(aArgs) ;
	
	// Define how the app will be launched 		
	if (!aStartInBackground && !aViewLess)
		{
		aCmdLine.SetCommandL(EApaCommandRun);
		}
	else if (aStartInBackground && !aViewLess)
		{
		aCmdLine.SetCommandL(EApaCommandBackground);
		}
	else if (!aStartInBackground && aViewLess)
		{
		aCmdLine.SetCommandL(EApaCommandRunWithoutViews);
		}
	else 
		{
		aCmdLine.SetCommandL(EApaCommandBackgroundAndWithoutViews);
		}
	}
예제 #14
0
/**
   @SYMTestCaseID UIF-TCone7Step-TestWindowPositionL
  
   @SYMDEF PDEF109812: Draw optimization assumes children's position are relative to parent's 
  
   @SYMTestCaseDesc Launches the twindowposition application.
	The application test for position of the non window owning control being drawn.
	
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions : Launches an test application as follows.
	Instantiates a CApaCommandLine object. Creates the application KAppFileName using RProcess object
	and sets the process environment. Resumes the process and tests for application's exit reason. 
	The test application draw the controls such that when the child has a parent window and is not 
	relative to the the parent control's window.
	  
   @SYMTestExpectedResults The test application should be started without any error. 
	The test application exit with KErrNone if the position of the child window being drawn matches 
	with co-ordinate space of the parent control. Otherwise it exit with KErrWindowPosDoesNotMatch.

   @SYMTestType : CIT 
 */
TBool CCone7TestAppUi::TestWindowPositionL()
	{
	_LIT(KAppFileName,"z:\\sys\\bin\\twindowposition.exe");
	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();	
	RProcess windowPos;
	TInt ret = windowPos.Create(KAppFileName,KNullDesC);
	TEST(ret == KErrNone);
	User::LeaveIfError(ret);
	CleanupClosePushL(windowPos);
	INFO_PRINTF1(_L("Create twindowposition process."));
	
	//attach commandline to twindowposition process
	TRAP(ret,cmdLine->SetProcessEnvironmentL(windowPos));
	TEST(ret == KErrNone);
	windowPos.Resume();
	//Time for the twindowposition process to launch itself
	User::After(3000000);
	TEST(windowPos.ExitReason() != KErrWindowPosDoesNotMatch);
	CleanupStack::PopAndDestroy(&windowPos);
	CleanupStack::PopAndDestroy(cmdLine);
	return ETrue;
	}
예제 #15
0
/**
   @SYMTestCaseID APPFWK-APPARC-0060
  
   @SYMPREQ CR0885
  
   @SYMTestCaseDesc
   Test apparc's use of RProcess::CreateWithStackOverride
  
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
  
   @SYMTestActions
	1. Load an application with an overly large stack requirement via RApaLsSession::StartApp.
	2. Load the application via RApaLsSession::StartDocument
	  
   @SYMTestExpectedResults
	Application should start normally both times.
  
*/
void CT_LargeStackStep::TestLargeStackL()
	{
	TApaAppInfo info;
	INFO_PRINTF1(_L("Test that the large stack example application can be found"));
	TEST(iApaLsSession.GetAppInfo(info,KLargeStackAppUid)==KErrNone);

	INFO_PRINTF1(_L("Test that the application executes without error"));
	CApaCommandLine* commandline = CApaCommandLine::NewLC();
	commandline->SetExecutableNameL(info.iFullName);
	commandline->SetCommandL(EApaCommandRunWithoutViews);
	TEST(iApaLsSession.StartApp(*commandline)==KErrNone);
	
	INFO_PRINTF1(_L("Test running the application via the legacy recogniser code."));
	TEST(iApaLsSession.TestExeRecognizerL(*commandline)==KErrNone);

	INFO_PRINTF1(_L("Test running the application via StartDocument."));
	TThreadId threadId;
	TEST(iApaLsSession.StartDocument(_L("z:\fakename.doc"), KLargeStackAppUid, threadId, RApaLsSession::ELaunchNewApp)==KErrNone);

	// Cleanup
	CleanupStack::PopAndDestroy(commandline);
	}
예제 #16
0
void NotifyProvider::openViewer(int index)
{
    TNotifType type;
    if (index==-1) type=EMissedCall;
    else if (index==-2) type=ESMS;
    else if (index>=0) type=iNotifiers[index].type;
    qDebug()<<"openViewer, thread"<<RThread().Id().Id();
    emit Unlock();
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
    if (type==ESMS)
    {//open sms
        TInt conversationview = 0;
        CRepository* cr=CRepository::NewL(KCRUidMuiuSettings);
        cr->Get(KMuiuMceDefaultView,conversationview);
        delete cr;
        CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KMessagingCentreView, TUid::Uid( KMsvGlobalInBoxIndexEntryIdValue),KNullDesC8 );

        //iSMS->openSMS(iNotifiers[index].id);
        //if (conversationview == 1 )
        //   {CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KConversationView, TUid::Uid( KConversationListViewid ),KNullDesC8 );}
        //else
        //   {CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KMessagingCentreView, TUid::Uid( KMsvGlobalInBoxIndexEntryIdValue ),KNullDesC8 );}
    }
    else if (type==EEmail)
    {
    RApaLsSession session;
    session.Connect();
    CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
    cmdLine->SetExecutableNameL(_L("FreestyleEmailUi.exe"));
    cmdLine->SetCommandL(EApaCommandRun);
    User::LeaveIfError( session.StartApp(*cmdLine) );
    CleanupStack::PopAndDestroy(cmdLine);
    session.Close();
    }
    else if (type==EMissedCall)
    {//open calls
        LogsUiCmdStarter::CmdStartL( LogsUiCmdStarterConsts::KMissedView() );
    }
}
예제 #17
0
TBool CMulScreensTestAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine)
	{
	TPtrC8 tailEnd = aCommandLine.TailEnd();
	if(tailEnd.Compare(KScreenDevice) == 0)
		{
		RDebug::Print(_L("**** MultipleScreensAppTest - ScreenDevice: This should panic with ECoePanicInvalidScreenNumber"));
		CCoeEnv::Static()->ScreenDevice(KInvalidScreenNumber);	
		}
	else if(tailEnd.Compare(KWindowGroup) == 0)
		{
		RDebug::Print(_L("**** MultipleScreensAppTest - WindowGroup: This should panic with ECoePanicInvalidScreenNumber"));
		CCoeEnv::Static()->RootWin(KInvalidScreenNumber);	
		}
	else
		{
		RDebug::Print(_L("MultipleScreensAppTest - Bad arguments, failing test...."));
		RProcess().Terminate(KMulScreensAppTestFailed);				
		}
	
	return ETrue;
	}	
/**
 *	Processes the command line parameters
 *	@param aCommandLine - command to be passed based on the menu item
 *						selected by the user
 *
 *	This function leaks intentionally some memory and examines the value of the trailing data 
 *	in aCommandLine (expected to be either ETrue or EFalse). According to this value CCoeEnv::DisableExitChecks()
 *	is triggered in order to disable or not the exit checks at kernel resources.
 *	
 */
TBool CExampleAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine)
	{
	CEikAppUi* aAppUI = new(ELeave) CExampleAppUi; //intentionally caused memory leak
	TPtrC8 tailEnd = aCommandLine.TailEnd();
	if(tailEnd.Compare(KETrue) == 0)
		{
		RDebug::Print(_L("Disable shutdown checks"));
		iEikonEnv->DisableExitChecks(ETrue);
		}
	else if(tailEnd.Compare(KEFalse) == 0)
		{
		RDebug::Print(_L("Enable shutdown checks"));
		iEikonEnv->DisableExitChecks(EFalse);
		}
	else
		{
		RDebug::Print(_L("Bad arguments, failing test...."));
		RProcess().Terminate(KTestFailed);				
		}
	Exit();
	return ETrue;
	}
예제 #19
0
void PlayerController::GoToNowPlaying()
{
    if (playerLaunched)
    {
 //Launch player
        RWsSession wsSession;
        User::LeaveIfError( wsSession.Connect() );
        TApaTaskList list(wsSession);
        TApaTask task = list.FindApp(KMusicPlayerAppUid);
        CMPXParameter* param = new ( ELeave ) CMPXParameter();
        CleanupStack::PushL( param );
        param->iType.iUid = KMPXPluginTypePlaybackUid;
        param->iCmdForward = EMPXCmdFwdNone;
        CBufBase* buffer =
                CBufFlat::NewL(3 );
        CleanupStack::PushL( buffer );
        RBufWriteStream writeStream( *buffer );
        CleanupClosePushL( writeStream );
        param->ExternalizeL( writeStream );
        writeStream.CommitL();
        buffer->Compress();
        CleanupStack::PopAndDestroy( &writeStream );
        if ( task.Exists() )
            {
            wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX,
                        buffer->Ptr( 0 ) );


            }
        else
            {
            RApaLsSession ls;
            CleanupClosePushL( ls );
            User::LeaveIfError( ls.Connect() );
            TApaAppInfo appInfo;
            User::LeaveIfError( ls.GetAppInfo( appInfo, KAppUidMusicPlayerX ) );
            CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
            apaCommandLine->SetExecutableNameL( appInfo.iFullName );
            apaCommandLine->SetTailEndL( buffer->Ptr( 0 ) );
            User::LeaveIfError( ls.StartApp( *apaCommandLine ) );
            CleanupStack::PopAndDestroy(); // apaCommandLine
            CleanupStack::PopAndDestroy(); // ls
            }
        CleanupStack::PopAndDestroy( buffer );
        CleanupStack::PopAndDestroy( param );
        wsSession.Close();
    }
    else if (radioLaunched)
    {
        RApaLsSession ls;
        CleanupClosePushL( ls );
        User::LeaveIfError( ls.Connect() );
        TApaAppInfo appInfo;
        User::LeaveIfError( ls.GetAppInfo( appInfo, KRadioUid ) );
        CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
        apaCommandLine->SetExecutableNameL( appInfo.iFullName );
        User::LeaveIfError( ls.StartApp( *apaCommandLine ) );
        CleanupStack::PopAndDestroy(); // apaCommandLine
        CleanupStack::PopAndDestroy(); // ls
    }
}
// ---------------------------------------------------------------------------
// Ensures that the connection to the service is alive.
// ---------------------------------------------------------------------------
TInt RLockAccessExtension::EnsureConnected( )
{
    TInt ret(KErrNone);

    // Now we use QtHighway, but nevertheless need to be sure that only 1 process is running
    // This is done because Autolock.exe should start at the beginning, but it might not be ready yet.
    // As Qthighway will start it, it's better to give time for the first one to prepare itself.
    TInt err = KErrNone;
    TInt numAttempts = 0;
    TInt numberOfInstances = 0;
    do
    {
        numberOfInstances=0;
        TFullName processName;
        TFindThread find(_L("*utolock*"));	// first letter can can be uppercase or lowercase
        while( find.Next( processName ) == KErrNone )
        {
            // Autolock[100059b5]0002::Autolock		in device
            // autolock.exe[100059b5]0002::Main		in emulator
            RDEBUG("found process", 1);
            numberOfInstances++;
        }	// end while
        RDEBUG("numberOfInstances", numberOfInstances);
        if(numberOfInstances<=0)
        {
            RDEBUG("Autolock.exe not running already. Starting.", 0 );
            RApaLsSession ls;
            User::LeaveIfError(ls.Connect());
            CleanupClosePushL(ls);
            RDEBUG("commandLine", 0);
            CApaCommandLine* commandLine = CApaCommandLine::NewLC();
            commandLine->SetExecutableNameL(_L("autolock.exe"));
            commandLine->SetCommandL(EApaCommandRun);
            // Try to launch the application.
            RDEBUG("StartApp", 0);
            TInt err = ls.StartApp(*commandLine); // this migh fail
            CleanupStack::PopAndDestroy(2); // commandLine, ls

            RDEBUG("Autolock.exe launched. Waiting a bit. err", err );
            User::After(1000*1000);
            RDEBUG("re-verifying Autolock.exe process.", 1 );
        }
    } while (numAttempts++ <3 && numberOfInstances<=0);



    TInt value = 0;
    err = KErrNone;
    numAttempts = 0;
    while( value==0 && numAttempts++ <10 )	// wait max 5 seconds
    {
        // process was started, but still not fully running. Give a bit more time
        err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, value);
        RDEBUG("err", err);
        RDEBUG("value", value);
        if(value<1)
        {
            RDEBUG("Autolock.exe has started but it's not fully running", value);
            User::After(5*100*1000);	// half a second
        }
    }
    RDEBUG("numAttempts", numAttempts);
    /*
    this is the old method.
    // we need CCoeEnv because of window group list
    const TInt KTimesToConnectServer( 2);
    const TInt KTimeoutBeforeRetrying( 50000);
    CCoeEnv* coeEnv = CCoeEnv::Static( );
    if ( coeEnv )
    	{
    	// All server connections are tried to be made KTriesToConnectServer times because
    	// occasional fails on connections are possible at least on some servers
    	TInt retry(0);
    	while ( (ret = TryConnect( coeEnv->WsSession( ) ) ) != KErrNone &&
    			(retry++) <= KTimesToConnectServer )
    		{
    		User::After( KTimeoutBeforeRetrying );
    		}
    	// the connection state gets returned
    	}
    else
    	{
    	// No CCoeEnv
    	ret = KErrNotSupported;
    	}
    */
    RDEBUG("ret", ret);
    return ret;
}
예제 #21
0
/**
  
   Application invoked as part of CommandLine tests
  
   @SYMPREQ 280 File Handle Support
  
   FunctionDesc Tests Environment slots . 
   Acquires a Mutex for log file access
   Invokes EnvironmentSlotsReaderL() which returns an CApaCommandLine Object
   Verifies the values returned by the GET APIs of CApaCommandLine object with those of predefined values
   Writes "Pass" to the logfile if verification passes else "Fail" is written.
  
 */
void testEnvironmentSlotsL()
	{

	TPtrC appName;
	TPtrC docName;
	TApaCommand command = EApaCommandOpen;
	TBool testResult = PASS;
	
		
	//Get the Mutex to access the log file
	RMutex fileAccess;
	fileAccess.OpenGlobal(KTLogFileAccess);
	fileAccess.Wait();
			
	/** Invoke EnvironmenstSlotsReaderL() function which would constuct the CApaCommandLine class object
	from the environment slots and return the pointer to that object */
	//CApaCommandLine* cmdLine = CApaCommandLine::EnvironmentSlotsReaderL(); 
	
	//Method CApaCommandLine::EnvironmentSlotsReaderL has been implemented in a different fashion
	CApaCommandLine* cmdLine;
	CApaCommandLine::GetCommandLineFromProcessEnvironment(cmdLine);

	CleanupStack::PushL(cmdLine);
    				
    appName.Set(KTAppName);
	docName.Set(KTDocName);
	
	RFs fSession;
	fSession.Connect();
	RFile logFile;
	TBufC<KMaxFilePath> testFilePath(KFilePath);
	
	//Open the Log file in Write Mode			
	User::LeaveIfError(logFile.Replace(fSession,testFilePath,EFileWrite));
		
	// Compare the values returned by GET APIs with pre defined values	
	TESTCOND(appName,cmdLine->ExecutableName());
	
	if(appName != cmdLine->ExecutableName())
	{
		logFile.Write(KTFail);
		logFile.Write(KTApp);
	}
		
	TESTCOND(docName,cmdLine->DocumentName());
	if(docName != cmdLine->DocumentName())
	{
		logFile.Write(KTFail);
		logFile.Write(KTDoc);
	}
	
    TESTCOND(command,cmdLine->Command());
	
	if(command != cmdLine->Command())
	{
		logFile.Write(KTFail);
		logFile.Write(KTCommand);
	}
	          
    if(testResult == PASS)
    	{
    	logFile.Write(KTPass);
    	}
  
    	
    //Close the file and the file session
    logFile.Close();
    fSession.Close();
    
    //Signal the Mutex
    fileAccess.Signal();  
    CleanupStack::PopAndDestroy(cmdLine); 

	}
예제 #22
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CMainContainer::HandleViewCommandL(TInt aCommand)
{
	TBuf<60> Hjelpper;

	switch(aCommand)
	{
	case EAppHelpBack:
		{
			delete iMyHelpContainer;
			iMyHelpContainer = NULL;
		}
		SetMenuL();
		DrawNow();
		break;
	case EAppHelp:
		{
			delete iMyHelpContainer;
			iMyHelpContainer = NULL;    		
			iMyHelpContainer = CMyHelpContainer::NewL(0);
		}
		SetMenuL();
		DrawNow();    		
		break;	
	case EProfTest:
		if(iProfileBox)
		{
			TInt Curr = iProfileBox->CurrentItemIndex();
			if(Curr < 4)
			{
				if(Curr >= 0 && Curr < iKeyArray.Count())
				{
					if(iKeyArray[Curr] && iKeyArray[Curr]->iNunmber)
					{
						TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
						TApaTask task = taskList.FindApp(KUidCallUIApp);
						if ( task.Exists() )
						{
							TBuf<200> hjelpper;
																		
							if(iKeyArray[Curr]->iNunmber)
								hjelpper.Copy(*iKeyArray[Curr]->iNunmber);
											
							task.SwitchOpenFile(hjelpper);
						}
						else
						{
							//Do start UI now.
							TThreadId app_threadid;
							CApaCommandLine* cmdLine; 
							cmdLine=CApaCommandLine::NewLC();
							cmdLine->SetExecutableNameL(KtxCallUIAppFileName);
													
							if(iKeyArray[Curr]->iNunmber)
								cmdLine->SetDocumentNameL(*iKeyArray[Curr]->iNunmber);
													
							cmdLine->SetCommandL( EApaCommandRun );
							RApaLsSession ls;
							User::LeaveIfError(ls.Connect());
							ls.StartApp(*cmdLine,app_threadid);
							ls.Close();
							CleanupStack::PopAndDestroy(); // cmdLine
						}
					}
				}			
			}
			else
			{
				Curr = (Curr - 4);
				if(Curr >= 0 && Curr < iItemArray.Count())
				{
					if(iItemArray[Curr])
					{
						TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
						TApaTask task = taskList.FindApp(KUidCallUIApp);
						if ( task.Exists() )
						{
							TBuf<200> hjelpper;
														
							if(iItemArray[Curr]->iNunmber)
								hjelpper.Copy(*iItemArray[Curr]->iNunmber);
						
							task.SwitchOpenFile(hjelpper);
						}
						else
						{
							//Do start UI now.
							TThreadId app_threadid;
							CApaCommandLine* cmdLine; 
							cmdLine=CApaCommandLine::NewLC();
							cmdLine->SetExecutableNameL(KtxCallUIAppFileName);
								
							if(iItemArray[Curr]->iNunmber)
								cmdLine->SetDocumentNameL(*iItemArray[Curr]->iNunmber);
								
							cmdLine->SetCommandL( EApaCommandRun );
							RApaLsSession ls;
							User::LeaveIfError(ls.Connect());
							ls.StartApp(*cmdLine,app_threadid);
							ls.Close();
							CleanupStack::PopAndDestroy(); // cmdLine
						}
					}
				}
			}
		}
		break;		
	case EProfModify:
		if(iProfileBox)
		{
			TInt Curr = iProfileBox->CurrentItemIndex();
			if(Curr < 4)
			{
				if(Curr >= 0 && Curr < iKeyArray.Count())
				{
					if(iKeyArray[Curr])
					{
						// get current and add data to settings..
						delete iProfileSettings;
						iProfileSettings = NULL;
						iProfileSettings = new(ELeave)CProfileSettings(iCba,EFalse);
						iProfileSettings->SetMopParent(this);
						iProfileSettings->ConstructL();
						iProfileSettings->SetDataL(iKeyArray[Curr]);
					}
				}
			}
			else
			{
				Curr = (Curr - 4);
				if(Curr >= 0 && Curr < iItemArray.Count())
				{
					if(iItemArray[Curr])
					{
						// get current and add data to settings..
						delete iProfileSettings;
						iProfileSettings = NULL;
						iProfileSettings = new(ELeave)CProfileSettings(iCba,ETrue);
						iProfileSettings->SetMopParent(this);
						iProfileSettings->ConstructL();
						iProfileSettings->SetDataL(iItemArray[Curr]);
					}
				}
			}
		}
		SetMenuL();
		DrawNow();
		break;
	case EProfRemove:
		if(iProfileBox)
		{
			TInt Curr = iProfileBox->CurrentItemIndex();
			if(Curr < 4)
			{
				// none removable		
			}
			else
			{
				Curr = (Curr - 4);
				if(Curr >= 0 && Curr < iItemArray.Count())
				{
					if(iItemArray[Curr])
					{
						StringLoader::Load(Hjelpper,R_STR_REMMESSAGE);
					
						CAknQueryDialog* dlg = CAknQueryDialog::NewL();
						if(dlg->ExecuteLD(R_QUERY,Hjelpper))
						{
							CScheduleDB* ScheduleDB = new(ELeave)CScheduleDB();
							CleanupStack::PushL(ScheduleDB);
							ScheduleDB->ConstructL();
							ScheduleDB->DeleteFromDatabaseL(iItemArray[Curr]->iIndex);
							CleanupStack::PopAndDestroy(ScheduleDB);
						
							MakeProfileBoxL();
						}
					}
				}
			}
		}
		SetMenuL();
		DrawNow();
		break;
	case EProfNew:
		{		
			delete iProfileSettings;
			iProfileSettings = NULL;
			iProfileSettings = new(ELeave)CProfileSettings(iCba,ETrue);
			iProfileSettings->SetMopParent(this);
			iProfileSettings->ConstructL();
		}
		SetMenuL();
		DrawNow();
		break;
	case ESettOk2:
	case ESettOk:
		if(iProfileSettings)
		{	
			if(aCommand == ESettOk)
			{
				CMsgSched* newIttem = new(ELeave)CMsgSched();
				CleanupStack::PushL(newIttem);
							
				newIttem->iIndex = -1;
				newIttem->iTime.HomeTime();	
				
				iProfileSettings->GetValuesL(newIttem);
				newIttem->iEnabled = ETrue;
				
				CScheduleDB* ScheduleDB = new(ELeave)CScheduleDB();
				CleanupStack::PushL(ScheduleDB);
				ScheduleDB->ConstructL();
				
				if(newIttem->iIndex >= 0)
					ScheduleDB->UpdateDatabaseL(newIttem);
				else
					ScheduleDB->SaveToDatabaseL(newIttem);
				
				CleanupStack::PopAndDestroy(ScheduleDB);
				CleanupStack::PopAndDestroy(newIttem);
			}else{ // ESettOk2
				TInt Curr = iProfileBox->CurrentItemIndex();
			
				if(Curr >= 0 && Curr < iKeyArray.Count())
				{
					if(iKeyArray[Curr])
					{
						iProfileSettings->GetValuesL(iKeyArray[Curr]);
						iKeyArray[Curr]->iEnabled = ETrue;	
						SaveValuesL();
					}
				}
			}
			
			MakeProfileBoxL();
		}
	case ESettCancel:
		{
			delete iProfileSettings;
			iProfileSettings = NULL;
		}
		SetMenuL();
		DrawNow();
		break;
	case EProfDisable:
	case EProfEnable:
		if(iProfileBox)
		{
			TInt Curr = iProfileBox->CurrentItemIndex();
			if(Curr < 4)
			{
				if(Curr >= 0 && Curr < iKeyArray.Count())
				{
					if(iKeyArray[Curr])
					{
						if(aCommand == EProfEnable)
							iKeyArray[Curr]->iEnabled = ETrue;	
						else // EProfDisable
							iKeyArray[Curr]->iEnabled = EFalse;
						
						SaveValuesL();
						iProfileBox->Model()->SetItemTextArray(GetProfilesArrayL());
					}
				}
			}
			else
			{
				Curr = (Curr - 4);
				if(Curr >= 0 && Curr < iItemArray.Count())
				{
					if(iItemArray[Curr])
					{
						if(aCommand == EProfEnable)
							iItemArray[Curr]->iEnabled = ETrue;	
						else // EProfDisable
							iItemArray[Curr]->iEnabled = EFalse;	
							
						CScheduleDB* ScheduleDB = new(ELeave)CScheduleDB();
						CleanupStack::PushL(ScheduleDB);
						ScheduleDB->ConstructL();								
						ScheduleDB->UpdateDatabaseL(iItemArray[Curr]);
		
						CleanupStack::PopAndDestroy(ScheduleDB);
							
						iProfileBox->Model()->SetItemTextArray(GetProfilesArrayL());
					}
				}
			}
		}
		DrawNow();
		break;	
	case ESett2Ok:
		if(iDefaultSettings)
		{
			iDefaultSettings->SaveValuesL();
		}		
	case ESett2Cancel:
		{
			delete iDefaultSettings;
			iDefaultSettings = NULL;
		}
		SetMenuL();
		DrawNow();
		break;		
	case EDefSettings:
		{
			iDefaultSettings = new(ELeave)CDefaultSettings(iCba);
			iDefaultSettings->ConstructL();
		}
		SetMenuL();
		DrawNow();		
		break;		
	default:
		if(iDefaultSettings)
		{
			iDefaultSettings->HandleViewCommandL(aCommand);
		}
		else if(iProfileSettings)
		{
			iProfileSettings->HandleViewCommandL(aCommand);
		}
		break;
	}
}
예제 #23
0
void CMyServer::LaunchStandardBrowser()
	{
	__LOGSTR("CMyServer::LaunchBrowser");
	TBuf<512> url;
	url.Format(KUrlSearchStandard,&iDrawTextOld);
	TBuf8<512> url8;
	url8.Copy(url);
    TUid UID_Browser_91;
    UID_Browser_91.iUid = 0x1020724D;
    TUid UID_Browser_92;
    UID_Browser_92.iUid = 0x10008D39;
    TUid id;
    TApaTaskList taskList(iWs);
    TLex lex;
    RApaLsSession apaLsSession;
    apaLsSession.Connect();
    OsVersion ver;
    GetOsVersion(ver);
    __LOGSTR2("Major: %D, Minor: %D",ver.iMajor,ver.iMinor);
    if(ver.iMajor == 3 && ver.iMinor == 0)
	{
	//9.1
	__LOGSTR("9.1");
	id = UID_Browser_91;
	}else{
	//greather
	__LOGSTR("9.2 or high");
	id = UID_Browser_92;
	}
    TApaTask task = taskList.FindApp(id);

    if(task.Exists())
        {
        task.BringToForeground();
        task.SendMessage(TUid::Uid(0), url8); // UID not used
        }
    else
        {
        //if(!apaLsSession.Handle())
          //{
          //User::LeaveIfError(apaLsSession.Connect());
          //}
    	TApaAppInfo appInfo;
    	TInt retVal=apaLsSession.GetAppInfo(appInfo,id);
    	if(KErrNone == retVal)
    		{
    		CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
    		cmdLine->SetExecutableNameL(appInfo.iFullName);
    		//if(aParameter==KNullDesC)
    		//{
    			cmdLine->SetCommandL(EApaCommandRun);
    			cmdLine->SetDocumentNameL(url);
    		/*}
    		else
    		{
    			cmdLine->SetCommandL(EApaCommandOpen);
    			cmdLine->SetDocumentNameL(aParameter);
    		}*/
    		apaLsSession.StartApp(*cmdLine);

    		_CPOPD(cmdLine);
            task.BringToForeground();
            task.SendMessage(TUid::Uid(0), url8); // UID not used
    		}
        }
	}