Ejemplo n.º 1
0
TInt E32Main()
	{
	TInt cmdLineLen = User::CommandLineLength();
	if (cmdLineLen == 0)
		return PagingInfo::PrintAll();
	else
		{
		RBuf cmdLine;
		TInt r = cmdLine.Create(cmdLineLen);
		if (r != KErrNone)
			return r;
		User::CommandLine(cmdLine);

		if (cmdLine == _L("-r"))
			{
			RDebug::Printf("Resetting demand paging info");
			return PagingInfo::ResetAll();
			}
		else
			{
			RDebug::Printf("usage: dpinfo [-r]");
			return KErrArgument;
			}
		}
	}
Ejemplo n.º 2
0
 /*
  * Save Form data, function to be executed when save option is selected. 
  * Creates the second form which allows for selecting the category.
  */
 TBool CYPagesForm1::SaveFormDataL()
{  
    CAknPopupFieldText* popupFieldText = static_cast <CAknPopupFieldText*> (ControlOrNull(EYPagesPopup));
 	if (popupFieldText) {		
		TInt categoryIndex = popupFieldText->CurrentValueIndex();
		TBuf <30> KMyTextFile;
		KMyTextFile.Format(_L("D:\\YPages\\%d%d.txt"), iColor, categoryIndex);
		
		RFs fileServer;
 	    User :: LeaveIfError (fileServer.Connect());
 	    RFile file;
 	    User::LeaveIfError(file.Open(fileServer, KMyTextFile, EFileRead|EFileStreamText));
 	    CleanupClosePushL(file);
 	    
 	    TFileText fileText;
 	    fileText.Set(file);
 	    
 	    TBuf<100> buffer;
 	    buffer = _L("");

 	    RBuf rBuf;
 	    rBuf.Create(buffer);
 	    rBuf.CleanupClosePushL();
 	    
 	  
 	    TInt err = KErrNone;
 	    while(err != KErrEof) {
 			err = fileText.Read(buffer);
 	    
 			if ((err != KErrNone) && (err != KErrEof)) {
 				User :: Leave(err);
 			}
 			if (KErrNone == err) {
 				rBuf.ReAllocL(rBuf.Length() + buffer.Length()+2);
 				rBuf.Append(buffer);
 				rBuf.Append(_L("\n"));
 			}
 	    }
 	    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(rBuf);
 	    dlg->PrepareLC(R_ABOUT_HEADING_PANE);
   	    dlg->SetHeaderTextL(_L(""));  
   	    dlg->RunLD();
 	    		     
 	    CleanupStack::PopAndDestroy(&rBuf);
 	    CleanupStack::PopAndDestroy(&file);
 	    
 	    fileServer.Close();

 	
 	}

        

 	return ETrue;
 }
Ejemplo n.º 3
0
void CVideoEntry::GenerateThumbnailFileL( const TDesC& aCacheDirectory )
	{
	delete iThumbnailFile;

	RBuf path;
	CleanupClosePushL( path );
	path.Create( aCacheDirectory.Length() + iVideoId->Length() + KCacheFileExtension().Length() );
	path.Copy( aCacheDirectory );
	path.Append( *iVideoId );
	path.Append( KCacheFileExtension() );
	iThumbnailFile = path.AllocL();
	CleanupStack::PopAndDestroy( &path );
	}
void CTestRControlChannel::SavePreviousLogFileL()
	{
	_LIT(KInfoLogFile, "Saving Previous logs If any.... \n");
	INFO_PRINTF1(KInfoLogFile);
	RFs fileserv;
	TInt error = fileserv.Connect();
	if(!error)
		{
		_LIT(KlogFile, "C:\\logs\\log.txt");
		_LIT(KPrefixLog, "C:\\logs\\");
		_LIT(KSuffix, "_UDEB");
		_LIT(KExtn, ".txt");
		
		CFileMan* fMan = NULL;
		TRAP_IGNORE(fMan = CFileMan::NewL(fileserv));
		if(fMan != NULL)
			{
			CleanupStack::PushL(fMan);
			RBuf newFileName;
			const TInt KTwenty = 20;
			newFileName.Create(ConfigSection().Length() + KTwenty );
			newFileName.Copy(KPrefixLog);
			//Script file name
			iScriptName.Copy(ConfigSection());
			newFileName.Append(iScriptName);
			newFileName.Append(KSuffix);
			newFileName.Append(KExtn);
			
			TInt error = fMan->Rename(KlogFile, newFileName);
			if (error != KErrNone)
				{
				_LIT(KErrInfo, "Unable to Save Previous logs...May be NO Previous logs exist \n");
				ERR_PRINTF1(KErrInfo);
				}
			else
				{
				_LIT(KSavingInfo, "Saved Previous logs with File Name: %S \n");
				INFO_PRINTF2(KSavingInfo, &newFileName);
				}
			CleanupStack::PopAndDestroy(fMan);
			newFileName.Close();
			}
		}
	fileserv.Close();
	_LIT(KInfoLogFile1, "Saving Previous logs End.... \n");
	INFO_PRINTF1(KInfoLogFile1);
	}
Ejemplo n.º 5
0
/** 
  Terminates the timer
  @param aComment Name of API.
*/
EXPORT_C void TTimerLogger::EndTimer(const TDesC& aComment)
	{
    #if defined (__LOG_PERFORMANCE) && !defined (_DEBUG)
	iEndTime.UniversalTime();
	TTimeIntervalMicroSeconds iTimeDifference = iEndTime.MicroSecondsFrom(iStartTime);	
	_LIT(KTimeDiff, ",%d microseconds\n");
	RBuf myBuf;
	TInt err = myBuf.Create (aComment.Length()+64);
	__ASSERT_ALWAYS(KErrNone == err, User::Invariant() );
	myBuf.Append (aComment );
	myBuf.AppendFormat(KTimeDiff, iTimeDifference.Int64());
    LogIt(myBuf);
	myBuf.Close();	
	iStartTime = 0;
	iEndTime = 0;
	#endif
	}
Ejemplo n.º 6
0
CDecisionRecord* CDatabase::ParseAndCreateRecordLC(TDesC8& aLine)
/**
	Parse a line and create a decision record from the parsed values
	@param aLine A line containing a decision record values quoted with double quotes and separated by semi-colon
	@return A newly created decision record
 */
	{
	CDecisionRecord* record = NULL;
	
	TLex8 parser(aLine);
	TChar achar;
	TBool start = ETrue;
	
	TUint16 flag = 0x078F;
	TUint16 pos	 = 0x0001;
	
	TInt32 value=0; 
	TUint32 hexVal = 0;
	
	TSecureId clientSid(0);
	TSecureId serverSid(0);
	TUid serviceId = TUid::Null();
	TUid evaluatorId = TUid::Null();
	TBuf8<KUpsMaxFingerprintLength*2> fingerprint;
	TBuf8<KUpsMaxClientEntityLength*2> clientEntity;
	RBuf description;
	TUint8 result=0;
	TUint32 evaluatorInfo=0;
	TUint16 policyVer=0;
	TUint32 recordId=0;
	
	while(!parser.Eos())
		{
		//Get cyrrent char
		achar = parser.Get();
		//Skip delimiter
		if(achar == ';')
			{
			start = ETrue;
			}
		//if double quote start or stop token reading	
		if('\"' == achar)
			{
			if(start)
				{
				parser.Mark();
				start = EFalse;
				}
			else
				{
				parser.UnGet();
				
				if(flag & pos)
					{
					TLex8 intToken(parser.MarkedToken());
					switch(pos)
						{
						case KLocClientSid:
							intToken.Val(hexVal,EHex);
							clientSid.iId = hexVal;
							break;
						case KLocEvaluatorId:
							intToken.Val(hexVal,EHex);
							evaluatorId.iUid = hexVal;
							break;
						case KLocServiceId:
							intToken.Val(hexVal,EHex);
							serviceId.iUid = hexVal;
							break;
						case KLocServerSid:
							intToken.Val(hexVal,EHex);
							serverSid.iId = hexVal;
							break;
						case KLocResult:
							intToken.Val(value);
							result = (TUint8)value;
							break;
						case KLocEvaluatorInfo:
							intToken.Val(value);
							evaluatorInfo = value;
							break;
						case KLocMajorPolicyVersion:
							intToken.Val(value);
							policyVer = (TUint16)value;
							break;
						case KLocRecordId:
							intToken.Val(value);
							recordId = (TUint32)value;							
							break;
						default:
							User::Leave(KErrGeneral);
						}
					}
				else
					{
					switch(pos)
						{
						case KLocDescription:
							{	
							TPtrC8 tmpDescription = parser.MarkedToken();
							description.Create(tmpDescription.Length());
							description.CleanupClosePushL();
							description.Copy(tmpDescription);
							break;
							}
	
						case KLocFingerprint:
							{
							fingerprint = parser.MarkedToken();
							HexToStrL(fingerprint);	
							break;						
							}
						case KLocClientEntity:
							{
							clientEntity = parser.MarkedToken();
							if(!(iFlag & EPrintBinary))							
								{
								HexToStrL(clientEntity);
								}
							break;							
							}
							default:
							User::Leave(KErrGeneral);
						}
					}
				
					
				start = ETrue;
				pos = pos<<1;
				
				}			
			}
		}
	record = CDecisionRecord::NewL(clientSid,evaluatorId,serviceId,serverSid,fingerprint,clientEntity,description,result,policyVer,evaluatorInfo,recordId);
	CleanupStack::PopAndDestroy(&description);
	CleanupStack::PushL(record);
	return record;
	}
Ejemplo n.º 7
0
GLDEF_C TInt E32Main()
//
// Test RAM allocation
//
    {
	test.Title();
	test.Start(_L("Load test LDD"));
	TInt r=User::LoadLogicalDevice(KLddFileName);
	test(r==KErrNone || r==KErrAlreadyExists);

	r=UserHal::PageSizeInBytes(PageSize);
	test(r==KErrNone);

	TInt psz=PageSize;
	PageShift=-1;
	for (; psz; psz>>=1, ++PageShift);

	TUint currentCacheSize;
	CacheSizeAdjustable = DPTest::CacheSize(OrigMinCacheSize, OrigMaxCacheSize, currentCacheSize) == KErrNone;

	TUint memodel = UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL) & EMemModelTypeMask;

	TInt cmdLineLen = User::CommandLineLength();
	if(cmdLineLen)
		{
		_LIT(KManual, "manual");
		RBuf cmdLine;
		test_KErrNone(cmdLine.Create(cmdLineLen));
		User::CommandLine(cmdLine);
		cmdLine.LowerCase();
		ManualTest = cmdLine.Find(KManual) != KErrNotFound;
		}

	// Turn off lazy dll unloading and ensure any supervisor clean up has completed 
	// so the free ram checking isn't affected.
	RLoader l;
	test(l.Connect()==KErrNone);
	test(l.CancelLazyDllUnload()==KErrNone);
	l.Close();
	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);

	test_KErrNone(HAL::Get(HAL::EMemoryRAM, TotalRam));

	test.Printf(_L("Free RAM=%08x, Page size=%x, Page shift=%d\n"),FreeRam(),PageSize,PageShift);

	test.Next(_L("Open test LDD"));
	r=Shadow.Open();
	test(r==KErrNone);
	
	test.Next(_L("TestAlignedAllocs"));
	TestAlignedAllocs();
	
	test.Next(_L("TestClaimPhys"));
	TestClaimPhys();

	if (memodel >= EMemModelTypeFlexible)
		{
		// To stop these tests taking too long leave only 8MB of RAM free.
		const TUint KFreePages = 2048;
		test.Next(_L("Load gobbler LDD"));
		TInt r = User::LoadLogicalDevice(KGobblerLddFileName);
		test_Value(r, r == KErrNone || r == KErrAlreadyExists);
		RGobbler gobbler;
		r = gobbler.Open();
		test_KErrNone(r);
		TUint32 taken = gobbler.GobbleRAM(KFreePages * PageSize);
		test.Printf(_L("Gobbled: %dK\n"), taken/1024);
		test.Printf(_L("Free RAM 0x%08X bytes\n"),FreeRam());

		test.Next(_L("TestFragmentedAllocation"));
		TestFragmentedAllocation();

		test.Next(_L("TestMultipleContiguousAllocations"));
		TestMultipleContiguousAllocations(20, PageSize * 16, 0);
		TestMultipleContiguousAllocations(20, PageSize * 16, PageShift + 1);
		TestMultipleContiguousAllocations(20, PageSize * 128, PageShift + 2);

		FragmentMemory(PageSize, PageSize * 2, EFalse, EFalse, EFalse);
		TestMultipleContiguousAllocations(20, PageSize * 128, PageShift + 2);
		UnfragmentMemory(EFalse, EFalse, EFalse);

		test.Next(_L("TestMultipleContiguousAllocations while accessing memory"));
		FragmentMemory(PageSize, PageSize * 2, EFalse, ETrue, EFalse);
		TestMultipleContiguousAllocations(20, PageSize * 128, PageShift + 2);
		UnfragmentMemory(EFalse, ETrue, EFalse);
		FragmentMemory(PageSize, PageSize * 2, ETrue, ETrue, EFalse);
		TestMultipleContiguousAllocations(50, PageSize * 256, PageShift + 5);
		UnfragmentMemory(ETrue, ETrue, EFalse);
		FragmentMemory(PageSize * 16, PageSize * 32, ETrue, ETrue, EFalse);
		TestMultipleContiguousAllocations(10, PageSize * 512, PageShift + 8);
		UnfragmentMemory(ETrue, ETrue, EFalse);
		FragmentMemory(PageSize * 32, PageSize * 64, ETrue, ETrue, EFalse);
		TestMultipleContiguousAllocations(10, PageSize * 1024, PageShift + 10);
		UnfragmentMemory(ETrue, ETrue, EFalse);

		test.Next(_L("TestMultipleContiguousAllocations with repeated movable and discardable allocations"));
		FragmentMemory(PageSize, PageSize * 2, EFalse, EFalse, ETrue);
		TestMultipleContiguousAllocations(20, PageSize * 2, PageShift);
		UnfragmentMemory(EFalse, EFalse, ETrue);
		FragmentMemory(PageSize, PageSize * 2, EFalse, EFalse, ETrue);
		TestMultipleContiguousAllocations(20, PageSize * 128, PageShift + 2);
		UnfragmentMemory(EFalse, EFalse, ETrue);
		FragmentMemory(PageSize, PageSize * 2, ETrue, EFalse, ETrue);
		TestMultipleContiguousAllocations(50, PageSize * 256, PageShift + 5);
		UnfragmentMemory(ETrue, EFalse, ETrue);
		FragmentMemory(PageSize * 16, PageSize * 32, ETrue, EFalse, ETrue);
		TestMultipleContiguousAllocations(20, PageSize * 512, PageShift + 8);
		UnfragmentMemory(ETrue, EFalse, ETrue);
		FragmentMemory(PageSize * 32, PageSize * 64, ETrue, EFalse, ETrue);
		TestMultipleContiguousAllocations(20, PageSize * 1024, PageShift + 10);
		UnfragmentMemory(ETrue, EFalse, ETrue);

		gobbler.Close();
		r = User::FreeLogicalDevice(KGobblerLddFileName);
		test_KErrNone(r);
		}

	Shadow.Close();
	r = User::FreeLogicalDevice(KLddFileName);
	test_KErrNone(r);
	test.Printf(_L("Free RAM=%08x at end of test\n"),FreeRam());
	test.End();
	return(KErrNone);
    }
Ejemplo n.º 8
0
TVerdict CWriteStringStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
	{
	INFO_PRINTF1(_L("This step tests WriteStringToConfig function."));
	SetTestStepResult(EFail);
	
	TPtrC originalValue;
	TBool ret = EFalse;
	
	if(!GetStringFromConfig(ConfigSection(),KTe_RegStepTestSuiteString, originalValue))
		{
		// Leave if there's any error.
		User::Leave(KErrNotFound);
		}

	INFO_PRINTF2(_L("The Original String is %S"), &originalValue); // Block end
	
	RBuf buf;
	buf.Create(originalValue.Length());
	buf.Copy(originalValue);
	
	_LIT(KText,"GoodBye Jason");
	TBufC<16> buf1(KText); 
	TPtrC TheString1(buf1);
	if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1))
		{
		if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1) && 0==TheString1.Compare(KText()))
			{
			INFO_PRINTF2(_L("Changed String To %S"),&TheString1); 
			ret = ETrue;
			}
		}
		
	_LIT(KText2,"Hello Jason");
	TBufC<16> buf2(KText2); 
	TPtrC TheString2(buf2);
	
	if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2))
		{
		if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2) && 0==TheString2.Compare(KText2()))
			{
			INFO_PRINTF2(_L("Changed String To %S"), &TheString2); 
			}
		}
	else
		{
		ret = EFalse;
		}
	
	if (!WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, buf))
		{
		ret = EFalse;
		}
	buf.Close();
	
	if (ret)
		{
		SetTestStepResult(EPass);
		}
	
	return TestStepResult();
	}
// ---------------------------------------------------------------------------
// CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL
// ---------------------------------------------------------------------------
//
void CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL( TMeterState aNextState )
    {
    RFile roapTrigger;
    DRM::CFileNameContainer* triggerFileName(NULL);

    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDoDownloadAndHandleRoapTriggerL() );
    // If no Trigger URL then nothing to download. So finish transaction
    if ( !iTriggerUrl || iTriggerUrl->Length() <= 0 )
        {
        Continue( EComplete, KErrNone );
        return;
        }

    triggerFileName=DRM::CFileNameContainer::NewLC();
#ifndef RD_MULTIPLE_DRIVE

    User::LeaveIfError( roapTrigger.Temp(
            iFs, KHelperTriggerFilePath, triggerFileName->iBuffer, EFileWrite ) );

#else //RD_MULTIPLE_DRIVE
    _LIT( KDrive, "%c:\\" );
    TInt driveNumber( -1 );
    TChar driveLetter;
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber );
    iFs.DriveToChar( driveNumber, driveLetter );

    DRM::CFileNameContainer*
        helperTriggerFilePath( DRM::CFileNameContainer::NewLC() );

    helperTriggerFilePath->iBuffer.Format( KDrive, ( TUint )driveLetter );

    User::LeaveIfError( roapTrigger.Temp( iFs, helperTriggerFilePath->iBuffer,
                triggerFileName->iBuffer, EFileWrite ) );
    CleanupStack::PopAndDestroy( helperTriggerFilePath );
    helperTriggerFilePath=NULL;

#endif
    UpdateBufferL< HBufC, TFileName >( iFileName, triggerFileName->iBuffer );
    CleanupStack::PopAndDestroy( triggerFileName );
    triggerFileName=NULL;

    try
		{
		// create and start download
        QString downloadUrl((QChar*)iTriggerUrl->Des().Ptr(),iTriggerUrl->Length());
        iDownload = iDlMgr->createDownload( downloadUrl );
		iRoHandlerDMgrEventHandler = q_check_ptr(new QRoHandlerDMgrEventHandler(*this, *iDownload));
		}
    catch(const std::exception& exception)
		{
		qt_symbian_exception2LeaveL(exception);
		}
    		
    CleanupClosePushL( roapTrigger );

    
	DRMDEBUG2(
		RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(),
		&RoHdlrDMgrWrDebugLiterals::KStrDlCreated() );
	iDownloadSuccess = EFalse;
	iConnectionError = EFalse;

	SetDefaultAccessPointL();
        
	try
		{
		RBuf fileName;
		User::LeaveIfError(fileName.Create(KMaxFileName));
		CleanupClosePushL(fileName);
		roapTrigger.Name(fileName);
		const QVariant& roapTriggerValue( QString((QChar*) fileName.Ptr(), fileName.Length()) );
		CleanupStack::PopAndDestroy(&fileName);
		iDownload->setAttribute(FileName,roapTriggerValue);
		const QVariant& val(ETrue);
		iDownload->setAttribute(ContentType, val);
		iDownload->start();
		}
	catch(const std::exception& exception)
		{
		qt_symbian_exception2LeaveL(exception);
		}
	
	// wait until download is finished
	iState = aNextState;
	TRequestStatus* status( &iStatus );
	*status = KRequestPending;
	SetActive();
        
    CleanupStack::PopAndDestroy( &roapTrigger );
    }
// ---------------------------------------------------------------------------
// Handles the event of a SIM change
// ---------------------------------------------------------------------------
//
void COMASuplIMSIObserver::HandleIMSIChangeL()
    {
    Trace( _L( "HandleIMSIChangeL() Start" ), KImsiObserver, __LINE__ );
        
    TBool isIMSIChanged = EFalse;
    if(iSettings)
        {
        TInt err = iSettings->IsImsiChanged( isIMSIChanged ) ;
        if(err != KErrNone)
            {
            Trace( _L("Deleted Settings Object"), KImsiObserver, __LINE__ );
            delete iSettings;
            iSettings = NULL;
            User::Leave( err);
            }
        }
    
    if ( isIMSIChanged )
        {
        // delete all servers which have the Sim Change Remove Flag set
        
        Trace( _L( "RemoveOnSimChange()" ), KImsiObserver, __LINE__ );
        iSettings->RemoveOnSimChange(); //Ignore the error
        RBuf hslpaddr;
        User::LeaveIfError( hslpaddr.Create( KSettingsParamLen ) );
        CleanupClosePushL( hslpaddr );
        
        RBuf iapn;
        User::LeaveIfError( iapn.Create( KSettingsParamLen ) );
        CleanupClosePushL( iapn );
        
        
        Trace( _L( "GenerateHslpAddressFromImsi()" ), KImsiObserver, __LINE__ );
        if(iSettings)
            {
            TInt err = iSettings->GenerateHslpAddressFromImsi( hslpaddr );
            if(err != KErrNone)
                {
                Trace( _L("Deleted Settings Object"), KImsiObserver, __LINE__ );
                delete iSettings;
                iSettings = NULL;
                CleanupStack::PopAndDestroy(2); //hslpaddr,iapn
                User::Leave( err);
                }
            err = iSettings->GetDefaultIAPName(iapn);
            if(err != KErrNone)
                {
                Trace( _L("error retrieving default IAP"), KImsiObserver, __LINE__ );
                delete iSettings;
                iSettings = NULL;
                CleanupStack::PopAndDestroy(2); //hslpaddr,iapn
                User::Leave( err);
                }
            Trace( hslpaddr, KImsiObserver, __LINE__ );
            Trace( iapn, KImsiObserver, __LINE__ );
            }
        
        
        //create param structure
        CServerParams* param=CServerParams::NewL();
        CleanupStack::PushL(param);
        User::LeaveIfError(param->Set( hslpaddr,iapn,ETrue,ETrue,ETrue,EFalse ));
        param->SetServerConfigurationType(EFalse);
        
        // add new server into settings
        TInt64 slpId;
        Trace( _L( "AddNewServer()" ), KImsiObserver, __LINE__ );
        TInt err=iSettings->AddNewServer( param,slpId ); //Ignore error
        Trace( _L( "AddNewServer() error code" ), KImsiObserver, err );
        
        
        CleanupStack::PopAndDestroy(3); //iapn,hslpaddr,param
        }
    if(iSettings)
        {
        Trace( _L("Deleted Settings Object"), KImsiObserver, __LINE__ );
        delete iSettings;
        iSettings = NULL;
        }
    Trace( _L( "HandleIMSIChangeL() End" ), KImsiObserver, __LINE__ );
    iImsiObserver.HandleImsiObserverCompleteL();
    }
Ejemplo n.º 11
0
void ScrShotsGenUtils::DumpJsFileL(CScrShotsSettings* scrShotsSettings)
{
    CGetImei* getImei = CGetImei::NewL();
    CleanupStack::PushL(getImei);
    RBuf8 formatBuf;
    formatBuf.Create(256);
    formatBuf.CleanupClosePushL();
    TFileName infoFile;
    
    User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(infoFile));
    infoFile.Append( KDeviceJSFile );
    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName());
    infoFile.Insert(0, KCDriveWithColon);
    
    RFs fsConn;
    User::LeaveIfError(fsConn.Connect());
    CleanupClosePushL(fsConn);
    RFile jsFile;
    if(BaflUtils::FileExists(fsConn, infoFile)){
        BaflUtils::DeleteFile(fsConn, infoFile);
    }
    //now create the file
    User::LeaveIfError(jsFile.Create(fsConn, infoFile, EFileWrite));
    CleanupClosePushL(jsFile);
    
//    User::LeaveIfError(jsFile.Write(KFunctionBlockStart));
    RBuf8 values;
    values.Create(256);
    for(int i = 0; i < KDeviceParamsCount ; i++){
        formatBuf.Zero();
        TInt sizeOfItem = User::StringLength((TText8 *)DeviceParams [i]);
        TPtr8 item((unsigned char*)DeviceParams [i],sizeOfItem ,sizeOfItem );
        switch(i){
            //device_model
            case 0:{
                CDeviceTypeInformation* devInfo = SysUtil::GetDeviceTypeInfoL();
                CleanupStack::PushL(devInfo);
                TPtrC manufName, modelCode, modelName;
                devInfo->GetManufacturerName(manufName);
                devInfo->GetModelCode(modelCode);
                devInfo->GetModelName(modelName);
                RBuf8 manufName8, modelName8, modelCode8;
                manufName8.Create(128); modelName8.Create(128); modelCode8.Create(128);
                manufName8.CleanupClosePushL(); modelName8.CleanupClosePushL(); modelCode8.CleanupClosePushL();
                manufName8.Copy(manufName);
                modelName8.Copy(modelName);
                modelCode8.Copy(modelCode);
                values.Format(KModelNameFormatString, &manufName8, &modelName8, &modelCode8);
                CleanupStack::PopAndDestroy(4);
                break;
            }
            //firmware_version
            case 1:{
                RBuf swVersion;
                swVersion.Create(128);
                SysUtil::GetSWVersion(swVersion);
                values.Copy(swVersion);
                TInt pos = 0;
                while((pos = values.Find(_L8("\n"))) != KErrNotFound){
                    //values.Delete(pos,1);
                    values.Replace(pos,1,_L8("_"));
                }
                swVersion.Close();
                break;
            }
            
            //ram_info
            case 2:{
                TInt totalram= 0;
                HAL::Get(HALData::EMemoryRAM, totalram);
                totalram /= 1024;
                values.Num(totalram);
                break;
            }
            
            //uptime
            case 3:{
                TTimeIntervalMicroSeconds32 iTickPeriod;
                UserHal::TickPeriod(iTickPeriod);
                TUint tickCount = User::TickCount();
                TUint noOfTicksPerSecond = (1000 * 1000) / iTickPeriod.Int();
                TInt noOfSecsSinceStartUp = tickCount / noOfTicksPerSecond;//noOfMicroSecsSinceStartup / (1000 * 1000);
                values.Num(noOfSecsSinceStartUp);
                break;
            }
            
            //scrshot count
            case 4:{
                values.Num(scrShotsSettings->TotalScrShotCount());
                break;
            }
            
            //symbian version
            case 5:{
                TVersion epocver = User::Version();
                values.Copy(epocver.Name());            
                break;
            }
            
            //series 60 version
            case 6:{
                VersionInfo::TPlatformVersion platformVersion;
                VersionInfo::GetVersion(platformVersion);
                TInt aMajor = platformVersion.iMajorVersion;
                TInt aMinor = platformVersion.iMinorVersion;
                values.Format(_L8("%d.%d"),aMajor, aMinor);
                break;
            }
            //country code
            case 7:{
            
                TLocale loc;
                int code = loc.CountryCode();
                values.Num(code);
                break;
            }
            //imei hash
            case 8:{
                TBuf8<256> inputimei;
                TBuf8<256> outimeihash;
                if(getImei->IsImeiFetched()){
                    getImei->GetImei(inputimei);
                    GetWhirlPoolHash(outimeihash,inputimei);
                    values.Copy(outimeihash);
                }
            }
            break;

        }
        
        formatBuf.Format(KStringVariableDeclaration, 
                &item, 
                &values);
        TRACE_ON(RDebug::Printf((const char*)formatBuf.PtrZ()));
        jsFile.Write(formatBuf);
    }
    values.Close();
    CleanupStack::PopAndDestroy(4);
    //TODO: This code should be commented in final release build
#if BRAHMA_DEBUG
    //code to copy the js file just created to the c:\ so that it can be analyzed
    _LIT(KTargetFileName, "c:\\device_info.js");
    BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(),infoFile, KTargetFileName);
#endif
}
Ejemplo n.º 12
0
TInt E32Main()
	{
	StaticMain();
	
	RBuf cmd;
	test_KErrNone(cmd.Create(User::CommandLineLength()));
	User::CommandLine(cmd);

	TLex lex(cmd);
	TTestType type;
	test_KErrNone(lex.Val((TInt&)type));
	GlobalObjectWithDestructor.iTestType = type;

	RMsgQueue<TMessage> messageQueue;
	test_KErrNone(messageQueue.OpenGlobal(KMessageQueueName));

	// Dynamically load DLL with global data
	RLibrary library;
	test_KErrNone(library.Load(KDynamicDll));
	
	switch(type)
		{
		case ETestMainThreadReturn:
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			return type;

		case ETestMainThreadExit:
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			User::Exit(type);
			break;

		case ETestChildThreadReturn:
			{
			// Start child thread passing this thread's id
			MainThreadId = RThread().Id();
			RThread childThread;
			test_KErrNone(childThread.Create(_L("ChildThread"), ChildThread, 4096, NULL, (TAny*)type));
			TRequestStatus status;
			childThread.Rendezvous(status);
			childThread.Resume();

			User::After(1);

			// Wait for child to open handle on this thread
			User::WaitForRequest(status);
			test_KErrNone(status.Int());
			childThread.Close();

			// Set this thread non-critical and exit
			User::SetCritical(User::ENotCritical);
			}
			break;

		case ETestOtherThreadExit:
			{
			RThread childThread;
			test_KErrNone(childThread.Create(_L("ChildThread"), ExitThread, 4096, NULL, (TAny*)type));
			childThread.Resume();
			TRequestStatus status;
			childThread.Logon(status);
			User::WaitForRequest(status);
			test_KErrNone(status.Int());
			childThread.Close();
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			}
			return type;

		case ETestOtherThreadPanic:
			{
			RThread childThread;
			test_KErrNone(childThread.Create(_L("ChildThread"), PanicThread, 4096, NULL, (TAny*)type));
			childThread.Resume();
			TRequestStatus status;
			childThread.Logon(status);
			User::WaitForRequest(status);
			test_KErrNone(status.Int());
			childThread.Close();
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			}
			return type;
			
		case ETestOtherThreadRunning:
			{
			RThread childThread;
			test_KErrNone(childThread.Create(_L("ChildThread"), LoopThread, 4096, NULL, (TAny*)type));
			childThread.Resume();
			childThread.Close();
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			}
			return type;
			
		case ETestPermanentThreadExit:
			{
			RThread childThread;
			test_KErrNone(childThread.Create(_L("ChildThread"), PermanentThread, 4096, NULL, (TAny*)type));
			childThread.Resume();
			TRequestStatus status;
			childThread.Logon(status);
			User::WaitForRequest(status);
			test_KErrNone(status.Int());
			childThread.Close();
			}
			break;
			
		case ETestRecursive:
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			break;

		case ETestDestructorExits:
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			break;

		case ETestLastThreadPanic:
			test_KErrNone(messageQueue.Send(EMessagePreDestruct));
			Panic(type);
			break;
			
		default:
			test(EFalse);
		}
	return KErrNone;
	}
Ejemplo n.º 13
0
//  Local Functions
LOCAL_C void MainL()
	{
	// to json
	RBuf jsonString;
		{
		CJsonObject* root = new (ELeave) CJsonObject();
		
		CJsonObject* project = new (ELeave) CJsonObject();
		// this will transfer ownership of project to root object
		root->AddL(_L("project"), project);
			project->AddL(_L("name"), _L("s60-json-library"));
			root->AddBoolL(_L("booleanVariable"), ETrue);
			root->AddL(_L("nullValue"), (CJsonObject*)NULL);
			
		root->AddBoolL(_L("booleanVariable"), ETrue);
		
		CJsonArray* values = new (ELeave) CJsonArray();
		// this will transfer ownership of values to root object
		root->AddL(_L("arrayOfValues"), values);
			values->AddBoolL(ETrue);
			values->AddIntL(123);
			values->AddL(_L("string"));
			values->AddReal32L(1.23);
			values->AddL((CJsonObject*)NULL);
			
		jsonString.Create(256);
		
		// convert in memory structure to json string format
		root->ToStringL(jsonString);
		
		// this will release all objects
		delete root;
		}
	
	// from json
		{
		CJsonBuilder* jsonBuilder = CJsonBuilder::NewL();
		
		// this will create json string representation in memory
		jsonBuilder->BuildFromJsonStringL(jsonString);
		
		CJsonObject* rootObject;
		jsonBuilder->GetDocumentObject(rootObject);
		
		if(rootObject)
			{
			CJsonObject* project;
			// this will not transfer ownership, owner of project is rootObject
			rootObject->GetObjectL(_L("project"), project);
			
			if(project)
				{
				TBuf<256> name;
				project->GetStringL(_L("name"), name);
				}
			}
		
		// we need manually release created object
		delete rootObject;
		
		// releases only jsonBuilder object, not objects which was created by him
		delete jsonBuilder;
		}
		
	// from formatted json
		{
		CJsonBuilder* jsonBuilder = CJsonBuilder::NewL();
		
		// this will create json string representation in memory
		jsonBuilder->BuildFromJsonStringL(KTestFormatedJson);
		
		CJsonObject* rootObject;
		jsonBuilder->GetDocumentObject(rootObject);
		
		if(rootObject)
			{
			TBuf<256> message;
			rootObject->GetStringL(_L("message"), message);
			}
		
		// we need manually release created object
		delete rootObject;
		
		// releases only jsonBuilder object, not objects which was created by him
		delete jsonBuilder;
		}
	
	// release json string
	jsonString.Close();
	}
Ejemplo n.º 14
0
/**
 * Read command line parameters and control the launching of targets. 
 * Create global launch semaphore KLaunchSemaphoreName
 */
void MainL()
    {

    TInt numApps = KNumApps;
    TInt numLaunches = KNumLaunches;
    TInt launchControl = 0;

    TInt argc = User::CommandLineLength();
    HBufC* commandLine = NULL;
    RDebug::Printf( ">Launcher Process() argc=%d", argc );

    if( argc )
        {
        commandLine = HBufC::NewLC(argc);
        TPtr commandLineBuffer = commandLine->Des();
        User::CommandLine(commandLineBuffer);

        RBuf printCommandLine;
        CleanupClosePushL( printCommandLine );
        printCommandLine.CreateL( commandLine->Des().Length() );
        printCommandLine.Copy( commandLine->Des() );
        printCommandLine.Collapse();
        RDebug::Printf( ">command line = %S", &printCommandLine );
        CleanupStack::PopAndDestroy( &printCommandLine );

        // create a lexer and read through the command line
        TLex lex(*commandLine);
        while (!lex.Eos())
            {
            // only look for options with first character '+', other switches are for the targets
            if (lex.Get() == '+')
                {
                TChar arg = lex.Get();
                switch (arg)
                    {
                    case 'n':
                        lex.Val( numApps );
                        RDebug::Printf("parsed numApps as %d", numApps);
                        break;
                    case 'm':
                        lex.Val( numLaunches );
                        RDebug::Printf("parsed numLaunches as %d", numLaunches );
                        break;
                    case 'o':
                        lex.Val( launchControl );
                        RDebug::Printf("parsed launchControl as %d", launchControl);
                        break;
                    default:
                        // unknown argument ignore it
                        break;             
                    }//switch
                }// if +
            }//while
        }//if argc

   RSemaphore launchSemaphore;
   TInt ret = KErrNone;
   CleanupClosePushL( launchSemaphore );
   ret = launchSemaphore.CreateGlobal( KLaunchSemaphoreName, 0 );
   RDebug::Printf( ">Target Launcher : RSemaphore.CreateGlobal ret %d", ret);
   User::LeaveIfError( ret );

   ret = launchSemaphore.OpenGlobal( KLaunchSemaphoreName );
   RDebug::Printf( ">Target Launcher : RSemaphore.OpenGlobal ret %d", ret);
   User::LeaveIfError( ret );
   
   //Only now indicate to the launcher that we have fully started, so they can find and open the semaphore
   RProcess::Rendezvous(KErrNone);

   //Now launch the requested number of apps for the requested number of launches
   for( ; numLaunches > 0; numLaunches-- )
       { 
       for( TInt launchIndex = numApps; launchIndex > 0; launchIndex-- )  
           {
           RDebug::Printf( ">Target Launcher:  Semaphore wait app %d, launch %d", launchIndex, numLaunches );
           launchSemaphore.Wait();

           RBuf targetName;
           CleanupClosePushL( targetName );
           RDebug::Printf( ">Target Launcher:  targetName.Create %d, launch %d", launchIndex, numLaunches );
           targetName.Create( KTargetExe().Length() + 2 );

           if( launchControl == 1 )
               {
               // Reverse the order of the apps launched by reversing the index in the name
               RDebug::Printf( ">Target Launcher:  targetName.Format %d, launch %d", numApps - launchIndex + 1, numLaunches );
               targetName.Format( KTargetExe(), numApps - launchIndex + 1 );
               }
           else
               {
               RDebug::Printf( ">Target Launcher:  targetName.Format %d, launch %d", launchIndex, numLaunches );
               targetName.Format( KTargetExe(), launchIndex );
               }

           RProcess aProc;
           CleanupClosePushL( aProc ); 
    
           RDebug::Printf( ">Target Launcher: LaunchProcess %d, launch %d", launchIndex, numLaunches );
           RDebug::Printf( ">LaunchProcess %lS", &targetName );
           TPtr cmdLinePtr( commandLine->Des() );
           ret = LaunchProcess( aProc, targetName, cmdLinePtr );
           CleanupStack::PopAndDestroy( &aProc );

           RDebug::Printf( "<Target Launcher: LaunchProcess returned %d", ret );
           CleanupStack::PopAndDestroy( &targetName );

           User::LeaveIfError( ret );

           //By now the add proc event should have been delivered to the
           //test app agent.
           }
       }

    launchSemaphore.Wait( 500000 );

    CleanupStack::PopAndDestroy( &launchSemaphore );

    if( commandLine )
       CleanupStack::PopAndDestroy( commandLine );
 
    }