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 }
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 }
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 }
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, ¶ms); // 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, }
// ----------------------------------------------------------------------------- // 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; }
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 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); } }
// 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; } }
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 }
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); }
/** * 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 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); }