Пример #1
0
LOCAL_C void DoStartL()
	{
	// Create active scheduler (to run active objects)
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
	CleanupStack::PushL(scheduler);
	CActiveScheduler::Install(scheduler);

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	CFed* fed = CFed::NewL(*console, fs);
	CleanupStack::PushL(fed);
	CDesC16ArrayFlat* argsBuf = new(ELeave) CDesC16ArrayFlat(4);
	CleanupStack::PushL(argsBuf);
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	for (TInt i = 1; i < args->Count(); i++) // Start from 1 as arg zero is the exe name
		{
		// No attempt to be clever with arguments - this code is only used when building a raw non-fshell version - mainfshell has the nicer equivalent
		TPtrC arg = args->Arg(i);
		argsBuf->AppendL(arg);
		}
	CleanupStack::PopAndDestroy(args);
	CleanupStack::Pop(argsBuf);
	gFed = fed;
	fed->StartL(argsBuf);
	CActiveScheduler::Start();

	// Delete active scheduler
	CleanupStack::PopAndDestroy(3, scheduler); // fed, fs, scheduler
	}
Пример #2
0
LOCAL_C void MainL()
/**
 * Main implementation
 */
	{
	CActiveScheduler* sched=NULL;
	sched=new(ELeave) CActiveScheduler;
	CActiveScheduler::Install(sched);
	CTeIpUpsSuite* server = NULL;
		
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	TPtrC exeName = args->Arg(0);
	TParse fullName;
	fullName.Set(exeName, NULL, NULL);
	CleanupStack::PopAndDestroy(args);
	
	// Create the CTestServer derived server
	TRAPD(err,server = CTeIpUpsSuite::NewL(fullName.Name()));
	if(!err)
		{
		// Sync with the client and enter the active scheduler
		RProcess::Rendezvous(KErrNone);
		sched->Start();
		}
	delete server;
	delete sched;
	}
TInt MainL()
	{
	RDebug::Print(_L("appfwk-sysmon-0033: MainL"));

	TInt runCount = 0;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    TInt err = RProperty::Define(KTestSysMon, KRestartExeCount, RProperty::EInt);
    RDebug::Printf("Defining P&S key with key %d returns with err %d", err, KRestartExeCount);
    
    runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0));
	CSysMonTestHelper::IncrementRunCountL(args->Arg(0));
    CleanupStack::PopAndDestroy(args);

    RDebug::Printf("runCount = %d", runCount);
    switch (runCount)
        {
		case 0:
			{
			RProcess::Rendezvous(KErrNone);
			RSysMonSession sysmon;
			sysmon.OpenL();
			CleanupClosePushL(sysmon);
			
			CStartupProperties* props = CStartupProperties::NewLC(_L("tsysmon_app_donothing.exe"), _L("33"));
			props->SetMonitored(ETrue);
			props->SetStartupType(EStartProcess);
			props->SetStartMethod(EWaitForStart);
			props->SetNoOfRetries(0);
			props->SetTimeout(0);
			props->SetRecoveryParams(EIgnoreOnFailure, 0);
			
			RProcess slave1;
			slave1.Create(_L("tsysmon_app_donothing.exe"), _L("5000"));
			CleanupClosePushL(slave1);
			TRequestStatus status;
			slave1.Rendezvous(status);
			slave1.Resume();
			User::WaitForRequest(status);

			// Register with SysMon
			sysmon.MonitorL(*props, slave1);
			slave1.Terminate(KErrNone);
			
			CleanupStack::PopAndDestroy(3, &sysmon);
			break;
			}
        default: //Run normally
			{
            RProcess::Rendezvous(KErrNone);
            break;
			}
        }
    
	RDebug::Print(_L("appfwk-sysmon-0033: End MainL"));
	return KErrNone;
	}
Пример #4
0
// -----------------------------------------------------------------------------
// Cosmo4AppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void COsmo4AppUi::ConstructL()
{
    // Initialise app UI with standard value.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    /*Create display*/
    iAppView = COsmo4AppView::NewL( ClientRect() );
	AddToStackL(iAppView);

	/*create playlist*/
#ifndef GPAC_GUI_ONLY
	iPlaylist = CPlaylist::NewL( ClientRect(), iAppView->GetUser() );

	iPlaylist->MakeVisible(EFalse);
#endif
	
	iAppView->MakeVisible(ETrue);
	view_mode = 0;

	m_title = NULL;

	//StatusPane ()->SwitchLayoutL ( R_AVKON_STATUS_PANE_LAYOUT_SMALL );

	nb_keys = 0;
	CaptureKeys(1);



	CCommandLineArguments *args = CCommandLineArguments::NewL();
#ifndef GPAC_GUI_ONLY
	if (args->Count() > 1) {
		TPtrC url = args->Arg(1);
#if defined(_UNICODE)
		char szURL[1024];
		u16 szURLUTF16[1024];
		size_t len;
		len = url.Size();
		memcpy(szURLUTF16, url.Ptr(), sizeof(u8)*len);
		szURLUTF16[len/2] = 0;
		const u16 *sptr = szURLUTF16;
		len = gf_utf8_wcstombs(szURL, 512, &sptr);
		if (len != (size_t) -1) {
			szURL[len] = 0;
			iAppView->Connect((const char *)szURL);
		}
#else
		iAppView->Connect((const char *)url.Ptr());
#endif
	}
#endif
	delete args;
}
LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	CConsoleBase* console = Console::NewL(_L("Siftestintegrationlockfile"),TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);
	TInt argTotal(cmdLine->Count());
	if (argTotal < 2  || argTotal > 3)
		{
		console->Printf(_L("Incorrect arguments specified: expected 1, received %d"), argTotal - 1);
		User::Leave(KErrArgument);
		}
		
	TPtrC filename(cmdLine->Arg(1));
	_LIT(KDoLockFileParam, " lockfile");
	if (argTotal == 2)
		{
		RBuf params;
		params.CreateL(filename.Length() + KDoLockFileParam().Length());
		params.CleanupClosePushL();
		params.Append(cmdLine->Arg(1));
		params.Append(KDoLockFileParam());
		// Since this executable is used by TEF, we wish to lock the file after the launched process has exited, so we spawn this process again with a different set of parameters
		RProcess newInstance;
		User::LeaveIfError(newInstance.Create(_L("Siftestintegrationlockfile"), params));
		CleanupClosePushL(newInstance);
		newInstance.Resume();
		TRequestStatus status;		
		newInstance.Rendezvous(status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		CleanupStack::PopAndDestroy(2, &params); // newInstance
		}
	else
		{
		// This is the execution for locking the file, invoked using the branch above
		console->Printf(_L("Locking file %S for read"), &filename);	
		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
	
		RFile file;
		User::LeaveIfError(file.Open(fs, filename, EFileShareReadersOnly|EFileRead));
		CleanupClosePushL(file);
		// Signal the invoker only here, so that the file will definitely get locked before TEF proceeds to the next step
		RProcess::Rendezvous(KErrNone);		
		
		User::After(10*1000*1000); // Wait for 10 seconds
	
		CleanupStack::PopAndDestroy(2 , &fs); // file
		}
	CleanupStack::PopAndDestroy(2, cmdLine); // console,
    }
TInt MainL()
	{
	RDebug::Print(_L("appfwk-sysmon-0038: MainL"));

	TInt runCount = 0;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0));
	CSysMonTestHelper::IncrementRunCountL(args->Arg(0));
    CleanupStack::PopAndDestroy(args);

    
    switch (runCount)
        {
		case 0:
			{
			RProcess::Rendezvous(KErrNone);
			RSysMonSession sysmon;
			sysmon.OpenL();
			CleanupClosePushL(sysmon);
			TTime time1();

			CStartupProperties* props = CStartupProperties::NewLC(_L("tsysmon_app_failcount2failwait_slave.exe"), _L("APPFWK-SYSMON-0038"));
			props->SetMonitored(ETrue);
			props->SetStartupType(EStartProcess);
			props->SetStartMethod(EWaitForStart);
			props->SetNoOfRetries(1);
			props->SetTimeout(0);
			props->SetRecoveryParams(EIgnoreOnFailure, 0);

			RProcess slave1;
			slave1.Create(_L("tsysmon_app_failcount2failwait_slave.exe"), _L("APPFWK-SYSMON-0038"));
			CleanupClosePushL(slave1);
			slave1.Resume();

			// Register with SysMon
			sysmon.MonitorL(*props, slave1);
			slave1.Terminate(KErrNone);

			CleanupStack::PopAndDestroy(3, &sysmon);
			break;
			}
		default: //Run normally
			{
            RProcess::Rendezvous(KErrNone);
            break;
			}
        }
	RDebug::Print(_L("appfwk-sysmon-0038: End MainL"));
	return KErrNone;
	}
void CCellTowerDataSimulation::InternalizeL() {
	RFs aSession;
	RFile aFile;
	TFileName aFileName;
	TInt aFileSize;

	if(aSession.Connect() == KErrNone) {
		CleanupClosePushL(aSession);

#ifndef __SERIES60_3X__
		aFileName = TFileName(_L("CellTowerSimData.txt"));
		CompleteWithAppPath(aFileName);
#else
		if(aSession.PrivatePath(aFileName) == KErrNone) {
#ifndef __WINSCW__
			aFileName.Insert(0, _L(":"));
			CCommandLineArguments* pArguments;
			TFileName drive;
			pArguments = CCommandLineArguments::NewL();
			if (pArguments->Count() > 0) {
				drive.Append(pArguments->Arg(0)[0]);
				aFileName.Insert(0, drive);
				delete pArguments;
			}
#endif

			aFileName.Append(_L("CellTowerSimData.txt"));

#ifdef __WINSCW__
			aFileName.Insert(0, _L("z:"));
#endif
		}
#endif

		if(aFile.Open(aSession, aFileName, EFileStreamText|EFileRead) == KErrNone) {
			CleanupClosePushL(aFile);
			aFile.Size(aFileSize);

			// Creat buffer & read file
			iCellBuffer = HBufC8::NewL(aFileSize);
			TPtr8 pCellBuffer(iCellBuffer->Des());
			aFile.Read(pCellBuffer);
			aFile.Close();
			
			CleanupStack::PopAndDestroy(&aFile);
		}
		
		CleanupStack::PopAndDestroy(&aSession);
	}
}
Пример #8
0
//             Called by the UI framework when a command has been issued.
//             In this example, a command can originate through a 
//             hot-key press or by selection of a menu item.
//             The command Ids are defined in the .hrh file
//             and are 'connected' to the hot-key and menu item in the
//             resource file.
//             Note that the EEikCmdExit is defined by the UI
//             framework and is pulled in by including eikon.hrh
//
void CExampleAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		      // Just issue simple info messages to show that
		      // the menu items have been selected
	case EExampleItem0:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
		break;

	
	case EExampleItem1:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
		break;
	
	case EExampleItem2:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
		break;
               // Exit the application. The call is
		       // implemented by the UI framework.

	case EEikCmdExit: 
		TInt timerDuration(KDefaultTimeout);
	    CCommandLineArguments* cmdLine = CCommandLineArguments::NewL();
		TInt argTotal=cmdLine->Count();
		for (TInt loop=1 ; loop < argTotal ; ++loop)
			{
			TPtrC arg(cmdLine->Arg(loop));
			if (arg==KSetShutDownTimeOption && loop++ < (argTotal-1))
				{
				TLex timeoutLex(cmdLine->Arg(loop));
				timeoutLex.Val(timerDuration);
				}
			}
		delete cmdLine;
		if(timerDuration > 0)
			{
			RTimer timer;
			TRequestStatus timerStatus;
			timer.CreateLocal();
			timer.After(timerStatus, timerDuration);
			User::WaitForRequest(timerStatus);
			timer.Close();
			}
		Exit();
		break;
		}
	}
Пример #9
0
void CSdlAppUi::StartTestL(TInt aCmd)
{

	//TInt flags = CSDL::EDrawModeGdi | CSDL::EEnableFocusStop
	//		| CSDL::EMainThread;// | CSDL::EAutoOrientation;

	TInt flags = 0;

	//flags |= CSDL::EDrawModeDSB | CSDL::EDrawModeDSBDoubleBuffer;
	flags |= CSDL::EDrawModeGdi;
	// Don't draw when in background.
	//flags |= CSDL::EEnableFocusStop;
	flags |= CSDL::EAutoOrientation;
	// This should be on by default anyway
	flags |= CSDL::EMainThread;

	//Create CommandLine Arguments and read it.
	CDesC8ArrayFlat *arr = new (ELeave) CDesC8ArrayFlat(1);
	CleanupStack::PushL(arr);

	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	// The real args we are interested in start at the 2nd arg
	for (TInt i = 1; i < args->Count(); i++)
	{
		TBuf8<256> arg;
		arg.Copy(args->Arg(i));

		arr->AppendL(arg);
		//TPtrC argumentPrt(args->Arg(i));
		//console->Printf(_L("Arg %d == %S\n"), i, &argumentPrt);
	}

	iSdl = CSDL::NewL(flags);

	iSdl->SetContainerWindowL(iSDLWin->GetWindow(), iEikonEnv->WsSession(),
			*iEikonEnv->ScreenDevice());
	iSdl->CallMainL(iWait->iStatus, *arr, flags, 0x14000);
	iWait->Start();

	arr->Reset();
	CleanupStack::PopAndDestroy(2); // command line and arr
}
Пример #10
0
LOCAL_C void DoStartL() 
	{
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	TInt i = args->Count();

	if ( args->Count() == 2 )
		{
		TLex tlex(args->Arg(1));
		TInt argVal = 0;
		if ( tlex.Val(argVal) == KErrNone )
			{
			// 
			if(argVal == 1)
				{
				RFeatureControl control;
				TInt err = control.Connect();

				TBitFlags32 flags( 0 );
				flags.Set( EFeatureSupported);
				flags.Set( EFeatureModifiable );

				// Adding features
				TFeatureEntry entry1( KNewUid1, flags, KDefaultData1 );
				err = control.AddFeature(entry1);

				control.Close();
				}
			else if( argVal == 2)
				{
				RFeatureControl control;
				TInt err = control.Connect();

				err = control.SWIEnd();

				control.Close();
				}
			}
		}
	CleanupStack::PopAndDestroy(); //args
	}
Пример #11
0
void CAppView::ConstructL()
{
	DebugMarkStart();
	LOGD("HELLOTE\n");

#if 0
	CCommandLineArguments* cla = CCommandLineArguments::NewLC();
	LOGD("CLA count: %i\n", cla->Count());
	for(int i=0; i<cla->Count(); i++) {
		HBufC8* buf = CreateHBufC8FromDesC16LC(cla->Arg(i));
		LOGD("%i \"%S\"\n", i, buf);
		CleanupStack::PopAndDestroy(buf);
	}
	CleanupStack::PopAndDestroy(cla);
#endif	//0

	CreateWindowL();  // Create a window for this application view
	// Set the window size
	SetRect(CCoeEnv::Static()->ScreenDevice()->SizeInPixels());
	iEngine = CDirScrAccEng::NewL(iEikonEnv->WsSession(),
		*(CCoeEnv::Static()->ScreenDevice()), Window());
	LOGD("AVC1\n");

	EnableDragEvents();

	iEventBuffer.SetLengthL(EVENT_BUFFER_SIZE);

	ActivateL();  // Activate the window, which makes it ready to be drawn
	LOGD("AVC3\n");

	iWaitTimer = new (ELeave) CWaitTimer(*this);
	iWaitTimer->ConstructL();

	iDelayTimer = new (ELeave) CDelayTimer(*this);
	iDelayTimer->ConstructL();

	iIdle = CIdle::NewL(MyPrioIdle);
	iIdle->Start(TCallBack(StartStuff, this));
}
void StartPSYCRTesterL() 
	{

	// Read the Process Arguments
	TInt psyIDValue;

    // PSY Tester sends the UID of the PSY as an argument
	CCommandLineArguments *args = CCommandLineArguments::NewL();
	CleanupStack::PushL(args);
	if(args->Count() <= 1)
	{
			User::Leave(KErrArgument);
	}
	TPtrC ptr = args->Arg(1);
	
	TLex lex(ptr.Ptr());
	TInt err = lex.Val(psyIDValue);

	if(KErrNone == err)
	{
		
		CPosPSYCRTestHandler* psyCRTestHandler = CPosPSYCRTestHandler::NewL();
		CleanupStack::PushL(psyCRTestHandler);

		TUid psyID;
		psyID.iUid = psyIDValue;
	
	    // Start the test	
		psyCRTestHandler->StartPSYCRTesterL(psyID);
		
		CleanupStack::PopAndDestroy(psyCRTestHandler);
	}
	
	CleanupStack::PopAndDestroy(args);
		
	RProcess::Rendezvous(KErrNone);

	}
Пример #13
0
static void MainL(void)
/**
Takes a User Prompt Service policy resource file and dumps it as human readable text to the 
console. The user may also specify the name of an output file on the command line. If so, text
is also written to this file.
*/
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
		
	CConsoleBase* console = Console::NewL(KAppName, TSize(KDefaultConsWidth, KDefaultConsHeight));
	CleanupStack::PushL(console);
	
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	
	if (args->Count() > 1)
		{		
		CPolicyReader* reader = CPolicyReader::NewLC(fs, args->Arg(1));		
		CPrinter* printer(0);
		if (args->Count() > 2)
			{
			RFile outFile;
			User::LeaveIfError(outFile.Replace(fs, args->Arg(2), EFileShareExclusive | EFileWrite));
			CleanupClosePushL(outFile);
			printer = CPrinter::NewLC(console, outFile);		
			
			CleanupStack::Pop(printer); 
			CleanupStack::PopAndDestroy(&outFile);
			CleanupStack::PushL(printer);
			}
		else
			{
			printer = CPrinter::NewLC(console);	
			}
		__UHEAP_MARK;
		PrintPoliciesL(printer, reader);
		__UHEAP_MARKEND;
		
		if (args->Count() < 3)
			{
			// If no output file is specified then pause after finishing
			// because the console will vanish when it is closed.
			console->Printf(_L("Press any key to continue\r\n"));
			console->Getch();
			}		
		CleanupStack::PopAndDestroy(2, reader); // printer, reader		
		}
	else 
		{
		console->Printf(_L("Usage: dumppolicy.exe policy.rsc <output.txt>\r\n"));
		console->Printf(_L("Press any key to continue\r\n"));
		console->Getch();
		}
	
	CleanupStack::PopAndDestroy(3, &fs); // args, console, fs
	}
Пример #14
0
/**
* Main function. Process command line arguments and import bookmark data.
*/
LOCAL_D void MainL()
    {
    TBuf<KFormatBufLen> buf;
    TInt num;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    if( args->Count() != 2 )
        {
        // Expecting command line 'Appname outfile'.
        User::Leave( KErrArgument );
        }
    RFs fs;
    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL<RFs>( fs );
    RUnicodeFile file;
    User::LeaveIfError( file.ReplaceL
        ( fs, args->Arg( 1 ), EFileWrite | EFileShareExclusive ) );
    CleanupClosePushL<RUnicodeFile>( file );
    RFavouritesSession sess;
    User::LeaveIfError( sess.Connect() );
    CleanupClosePushL<RFavouritesSession>( sess );
    RFavouritesDb db;
    User::LeaveIfError( db.Open( sess, KBrowserBookmarks ) );
    CleanupClosePushL<RFavouritesDb>( db );
    User::LeaveIfError( db.Begin( /*aWrite=*/EFalse ) );
    db.CleanupRollbackPushL();

    CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
    CleanupStack::PushL( items );
    const CFavouritesItem* item;
    User::LeaveIfError( db.GetAll( *items ) );
    buf.Format( _L("%d entries\r\n"), items->Count() );
    User::LeaveIfError( file.Write( buf ) );
    for ( TInt i = 0; i < items->Count(); i++ )
        {
        User::LeaveIfError( file.Write( _L("\r\n") ) );
        item = items->At( i );
        // Uid.
        num = item->Uid();
        buf.Format( _L("Uid=(%d)"), num );
        User::LeaveIfError( file.Write( buf ) );
        // Fixed Uid info.
        if ( num == KFavouritesRootUid )
            {
            User::LeaveIfError( file.Write( _L(" (root folder)\r\n") ) );
            }
        else if ( num == KFavouritesHomepageUid )
            {
            User::LeaveIfError( file.Write( _L(" (homepage)\r\n") ) );
            }
        else if ( num == KFavouritesLastVisitedUid )
            {
            User::LeaveIfError( file.Write( _L(" (last visited)\r\n") ) );
            }
        else
            {
            User::LeaveIfError( file.Write( _L("\r\n") ) );
            }
        // Type.
        if ( item->Type() == CFavouritesItem::EFolder )
            {
            User::LeaveIfError( file.Write( _L("Type=Folder\r\n") ) );
            }
        else if ( item->Type() == CFavouritesItem::EItem )
            {
            User::LeaveIfError( file.Write( _L("Type=Item\r\n") ) );
            }
        else
            {
            User::LeaveIfError( file.Write( _L("Type=HUH???\r\n") ) );
            }
        TPtrC ptr;
        // Name
        ptr.Set( item->Name() );
        buf.Format( _L("Name=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Parent.
        buf.Format( _L("ParentFolder=(%d)\r\n"), item->ParentFolder() );
        User::LeaveIfError( file.Write( buf ) );
        // Url.
        ptr.Set( item->Url() );
        buf.Format( _L("Url=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Access Point.
        if ( item->WapAp().IsNull() )
            {
            User::LeaveIfError( file.Write( _L("WapAp=Null\r\n") ) );
            }
        else if ( item->WapAp().IsDefault() )
            {
            User::LeaveIfError( file.Write( _L("WapAp=Default\r\n") ) );
            }
        else
            {
            buf.Format( _L("WapAp=(%d)\r\n"), item->WapAp().ApId() );
            User::LeaveIfError( file.Write( buf ) );
            }
        // UserName.
        ptr.Set( item->UserName() );
        buf.Format( _L("UserName=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Password.
        ptr.Set( item->Password() );
        buf.Format( _L("Password=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Read-only.
        buf.Format( _L("ReadOnly=(%d)\r\n"), item->IsReadOnly() );
        User::LeaveIfError( file.Write( buf ) );
        // Factory item.
        buf.Format( _L("FactoryItem=(%d)\r\n"), item->IsFactoryItem() );
        User::LeaveIfError( file.Write( buf ) );
        // ContextId.
        buf.Format( _L("ContextId=(0x%x)\r\n"), item->ContextId() );
        User::LeaveIfError( file.Write( buf ) );
        // Modified.
        item->Modified().FormatL
            ( buf, _L("Modified=<%F%Y/%M/%D %H:%T:%S>\r\n") );
        User::LeaveIfError( file.Write( buf ) );
        // Preferred uid.
        if ( item->Type() == CFavouritesItem::EFolder )
            {
            User::LeaveIfError( db.PreferredUid( item->Uid(), num ) );
            buf.Format( _L("PreferredUid=(%d)\r\n"), num );
            User::LeaveIfError( file.Write( buf ) );
            }
        }
    CleanupStack::PopAndDestroy();      // items

    User::LeaveIfError( db.Commit() );
    CleanupStack::Pop();                // Pop the rollback

    CleanupStack::PopAndDestroy( 5 );   // sess, db, file, fs, args
    }
LOCAL_C TInt MainL()
{
    RProcess delayer;
    delayer.Create(_L("tsysmon_app_delayshutdown.exe"),KNullDesC);
    delayer.Resume();
    delayer.Close();

    TInt runCount = 0;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0));

    CSysMonTestHelper::IncrementRunCountL(args->Arg(0));
    CleanupStack::PopAndDestroy(args);

    TBool keepRunning = EFalse;

    CSysMonTestHelper* helper = NULL;

    switch (runCount)
    {
    case 0:
    {
        RProcess::Rendezvous(KErrNone);
        helper = CSysMonTestHelper::NewLC();

        RSysMonSession sysmon;
        sysmon.OpenL();
        CleanupClosePushL(sysmon);

        TBuf<255> args;
        TBuf<255> testId;
        helper->GetTestId(testId);
        RDebug::Print(testId);
        args.Append(testId);
        args.Append(_L(" "));
        args.Append(_L("5000"));

        CStartupProperties* props = CStartupProperties::NewLC(KFilenameDeregTimeout, args);
        props->SetMonitored(ETrue);
        props->SetStartupType(EStartProcess);
        props->SetStartMethod(EWaitForStart);
        props->SetNoOfRetries(0);
        props->SetTimeout(0);
        props->SetRecoveryParams(ERestartOSWithMode, 1);

        CStartupProperties* props2 = CStartupProperties::NewLC(_L("tsysmon_app_donothing.exe"), KNullDesC);
        props2->SetMonitored(ETrue);
        props2->SetStartupType(EStartProcess);
        props2->SetStartMethod(EWaitForStart);
        props2->SetNoOfRetries(1);
        props2->SetTimeout(0);
        props2->SetRecoveryParams(ERestartOS, 0);

        RProcess slave1;
        slave1.Create(KFilenameDeregTimeout, args);
        CleanupClosePushL(slave1);
        slave1.Resume();

        RProcess slave2;
        slave2.Create(_L("tsysmon_app_donothing.exe"), KNullDesC);
        CleanupClosePushL(slave2);
        slave2.Resume();

        // Register with SysMon
        TInt err = 0;
        TRAP(err, sysmon.MonitorL(*props, slave1));
        TRAP(err, sysmon.MonitorL(*props2, slave2));
        slave1.Terminate(KErrNone);
        slave2.Terminate(KErrNone);

        CleanupStack::PopAndDestroy(5, helper);
        break;
    }
    case 1:
    {
        RProcess::Rendezvous(KErrNone);
        keepRunning = ETrue;
        helper = CSysMonTestHelper::NewLC();
        TInt startupMode;
        HAL::Get(HALData::EPersistStartupModeKernel, startupMode);
        helper->WriteResultL(startupMode);
        CleanupStack::PopAndDestroy(helper);
        break;
    }
    default: //Run normally
    {
        RProcess::Rendezvous(KErrNone);
        keepRunning = ETrue;
        break;
    }
    }

    CSysMonTestHelper::IncrementRunCountL(args->Arg(0));
    CleanupStack::PopAndDestroy(args);

    while (keepRunning)
    {
        User::After(5000000); // 5 seconds
    }
    return 0;
}
Пример #16
0
/**
Second phase construction
*/
void CCallRunner::ConstructL()
	{
	iTelephony = CTelephony::NewL();
	// rename process
	RProcess process;
	process.RenameMe(KCallRunnerStr);
	
	// read the calls number
	CCommandLineArguments* clArg = CCommandLineArguments::NewLC();
	TPtrC buff = clArg->Arg(1);
	TBuf<255> number(buff);
	number.TrimAll();
	if (number.Length() != 1)
		{
		User::Leave(KErrArgument);
		}
	
	iNumberOfCalls = number[0] - '0';
	if (iNumberOfCalls < 0 || iNumberOfCalls > 2)
		{
		User::Leave(KErrArgument);
		}
	
	CleanupStack::PopAndDestroy(clArg);
	
	// set up the property
	static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
	User::LeaveIfError( iCallRunnerProperty.Define(KCallRunnerPropertyKey,
							RProperty::EInt,KAllowAllPolicy,KAllowAllPolicy) );
	User::LeaveIfError( iCallRunnerProperty.Attach(KCallRunnerPropertyUid, KCallRunnerPropertyKey) );
	
	// make calls
	_LIT(KGoodNumber,"1789");
	CTelephony::TCallStatusV1 status;
	CTelephony::TCallStatusV1Pckg statusPckg(status);
	
	//Set the call parameters for call 1
	CTelephony::TCallParamsV1 callParams1;
	callParams1.iIdRestrict = CTelephony::ESendMyId;
	CTelephony::TCallParamsV1Pckg callParamsPckg1(callParams1);	

	TTestCallParams testCallParams1;
	testCallParams1.iLine = CTelephony::EVoiceLine;
	testCallParams1.iCallParamsV1Pckg = &callParamsPckg1;
	testCallParams1.iTelAddress.iTelNumber = KGoodNumber;
	testCallParams1.iExpStat = KErrNone;

	// Create active DialNewCallAct objects
	CTestDialNewCallAct* testDialNewCallAct = CTestDialNewCallAct::NewLC(NULL, iTelephony);
	testDialNewCallAct->TestDialNewCall(testCallParams1);
	CActiveScheduler::Start();
	User::LeaveIfError(iTelephony->GetCallStatus(testCallParams1.iCallId,  statusPckg));
	if (iNumberOfCalls == 2)
		{
		//Set the call parameters for call 2
		CTelephony::TCallParamsV1 callParams2;
		callParams2.iIdRestrict = CTelephony::ESendMyId;
		CTelephony::TCallParamsV1Pckg callParamsPckg2(callParams2);	

		TTestCallParams testCallParams2;
		testCallParams2.iLine = CTelephony::EVoiceLine;
		testCallParams2.iCallParamsV1Pckg = &callParamsPckg2;
		testCallParams2.iTelAddress.iTelNumber = KGoodNumber;
		testCallParams2.iExpStat = KErrNone;
		
		// Put on hold first
		CTestHoldAct* TestHoldAct = CTestHoldAct::NewLC(NULL,iTelephony);	
		TestHoldAct->TestHold(testCallParams1);
		CActiveScheduler::Start();	

		User::LeaveIfError(iTelephony->GetCallStatus(testCallParams1.iCallId,  statusPckg));
		
		// Create active DialNewCallAct objects
		testDialNewCallAct->TestDialNewCall(testCallParams2);
		CActiveScheduler::Start();
		
		User::LeaveIfError(iTelephony->GetCallStatus(testCallParams2.iCallId,  statusPckg));
		
		CleanupStack::PopAndDestroy(TestHoldAct);
		}
 	CleanupStack::PopAndDestroy(testDialNewCallAct);
 	
 	// Inform the client calls are established
 	User::LeaveIfError( iCallRunnerProperty.Set(KCallRunnerPropertyUid, KCallRunnerPropertyKey, ECallRunnerStarted) );
 	}
LOCAL_C TInt MainL()
    {
    TInt runCount = 0;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0));
	CSysMonTestHelper::IncrementRunCountL(args->Arg(0));
    CleanupStack::PopAndDestroy(args);
	
	TBool keepRunning = EFalse;
    
	CSysMonTestHelper* helper = NULL;
	TDateTime datetime1;
	TTime time1;
	TInt millisecs = 0;
	
    switch (runCount)
        {
		case 1:
			{
			RProcess::Rendezvous(KErrNone);
			time1.HomeTime();
			datetime1 = time1.DateTime();
			millisecs = (datetime1.MicroSecond() / 1000) + 
						(datetime1.Second() * 1000) + 
						(datetime1.Minute() * 60 * 1000) +
						(datetime1.Hour() * 60 * 60 * 1000);
	
			helper = CSysMonTestHelper::NewLC();
			helper->WriteResultL(millisecs);
			CleanupStack::PopAndDestroy(helper);
			break;
			}
		case 2:
			{
			RProcess::Rendezvous(KErrNone);
			time1.HomeTime();
			datetime1 = time1.DateTime();
			millisecs = (datetime1.MicroSecond() / 1000) + 
						(datetime1.Second() * 1000) + 
						(datetime1.Minute() * 60 * 1000) +
						(datetime1.Hour() * 60 * 60 * 1000);
											
			TInt secondRunTime;
			CSysMonTestHelper::GetResultIntL(_L("APPFWK-SYSMON-0037"), secondRunTime);
			CSysMonTestHelper* helper = CSysMonTestHelper::NewLC();

			if ( (millisecs - secondRunTime) *1000 >= KWaitTime )
				{
				helper->WriteResultL(1);
				}
			else
				{
				helper->WriteResultL(0);
				}
			CleanupStack::PopAndDestroy(helper);
			keepRunning = ETrue;
			break;
			}
        default: //Run normally
			{
            RProcess::Rendezvous(KErrNone);
			keepRunning = ETrue;
            break;
			}
        }
	
	while (keepRunning)
		{
		User::After(5000000); // 5 seconds
		}
	return 0;
    }
LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	TInt argTotal=cmdLine->Count();
	if (argTotal < 2 || argTotal > 3)
		{
		User::Leave(KErrArgument);
		}
	TUint sidRequested;
	TLex processLex(cmdLine->Arg(1));
	User::LeaveIfError(processLex.Val(sidRequested, EHex));
	if (sidRequested == 0)
		{
		User::Leave(KErrArgument);
		}
	
	if (argTotal == 3)
		{
		TUint timeout;
		TLex timeoutLex(cmdLine->Arg(2));
		User::LeaveIfError(timeoutLex.Val(timeout));
		if (timeout > 0)
			{
			User::After(timeout);
			}
		}

	TUid sid = {sidRequested};
	TBool needToScanFullList;
	TFullName fullName;

	do
		{
		needToScanFullList = EFalse;
		TFindProcess findProcess;

		while(findProcess.Next(fullName) == KErrNone)
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}

			TUid processSid(process.SecureId());
			if (processSid == sid && process.ExitType() == EExitPending)
				{
				process.Kill(KErrNone);
				needToScanFullList = ETrue;
				}
			process.Close();
			}
		} while (needToScanFullList);

	CleanupStack::PopAndDestroy(cmdLine);
	}