コード例 #1
0
void TestFileLengthExceedMax()
	{
	test.Next(_L("Test accesing a long file with filename length >250 characters"));
	__UHEAP_MARK;

	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));

	TInt r = TheFs.SessionPath(gSessionPath);
	testAndLog(r==KErrNone);
	
	TBuf<350> longName;

	_LIT(KTestDir1,	"\\TEST\\TESTLONGFILENAMELENGTH\\TESTMORETHAN260CHARACTERS\\") ;
	_LIT(KTestDir2,  "\x65B0\x6587\x4EF6\x4EF6(ABCDEFGH)\\(\x65B0\x6587\x4EF6\x4EF6)PQRST\\");
	_LIT(KTestDir3,  "MULTILEVEL-FOLDER1\\MULTILEVEL-FOLDER2\\MULTILEVEL-FOLDER3\\");
	_LIT(KTestDir4,  "\x65B0\x65B0\x65B0\x65B0(x6587)\\(\x6587\x6587\x6587\x6587)PQRST\\");
	_LIT(KTestDir5,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6)\\(\x6587\x6587\x6587\x6587)XYZ\\");	
	_LIT(KTestDir6,  "TESTINGINPROGRESS(TESTLENGTH)>256\\");	
	_LIT(KTestLongFileLength,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6).TXT");
	
	longName = gSessionPath;
	longName += KTestDir1;
	longName += KTestDir2;
	longName += KTestDir3;
	longName += KTestDir4;
	longName += KTestDir5;
	longName += KTestDir6;
	
	test.Printf(_L("longName length is  %d "), longName.Length());
	r=TheFs.MkDirAll(longName);
	
	longName += KTestLongFileLength;
	test.Printf(_L("longName count is  %d "), longName.Length());

	testAndLog(longName.Length()>256);
	
	r=TheFile.Create(TheFs,longName ,EFileWrite);
	testAndLog(r==KErrBadName);
	// TheFile.Close();
		
	r=TheFile.Open(TheFs,longName ,EFileWrite);
	testAndLog(r==KErrBadName);
	// TheFile.Close();
	
	TheFs.Delete(longName);	
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;		
	}
コード例 #2
0
void TestLeadingE5Handling()
	{
	test.Next(_L("Test Leading \'E5\' byte handling"));
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));

	// Enables codepage dll implementation of LocaleUtils functions for this test only
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	
	r = UserSvr::ChangeLocale(KTestLocale);
	testAndLog(r==KErrNone);

	r=TheFs.SessionPath(gSessionPath);
	testAndLog(r==KErrNone);

	_LIT(KTestFilePathAndName,		"\\F32-TST\\T_FATCHARSETCONV\\\x88F9.TXT");
	_LIT(KTestFileShortName, 		"\x88F9.TXT");
	
	MakeFile(KTestFilePathAndName);
	TFileName sn;
	r = TheFs.GetShortName(KTestFilePathAndName, sn);
	testAndLog(r==KErrNone);
	r = sn.Compare(KTestFileShortName);
	testAndLog(r==KErrNone);
	
	r=TheFs.Delete(KTestFilePathAndName);
	testAndLog(r==KErrNone);

	// Disables codepage dll implementation of LocaleUtils functions for other base tests
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}
コード例 #3
0
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::ModifyQueryForSortOrderLastMostUsedL(
        const CCaInnerQuery::TSortAttribute aSortType, RBuf& aQuery )
    {
    DEBUG(("_CA_:CASqlQueryCreator::ModifyQueryForSortOrderLastMostUsedL"));

    RBuf descPart;
    descPart.CleanupClosePushL();
    if( aSortType == CCaInnerQuery::MostUsedDesc || 
         aSortType == CCaInnerQuery::LastUsedDesc )
        {
        descPart.CreateL( KDesc );
        }
    else
        {
        descPart.CreateL( KNullDesC );
        }

    RBuf usageDataQuery;
    usageDataQuery.CleanupClosePushL();
    if( aSortType == CCaInnerQuery::MostUsed || 
         aSortType == CCaInnerQuery::MostUsedDesc )
        {
        usageDataQuery.CreateL( KSQLGetMostUsed );
        }
    else
        {
        usageDataQuery.CreateL( KSQLGetLastUsed );
        }

    RBuf newQuery;
    newQuery.CleanupClosePushL();
    newQuery.CreateL( KSQLGetListByLaunchDataPart1().Length() +
            KSQLGetListByLaunchDataPart1().Length() +
            KSQLGetListByLaunchDataPart3().Length() +
            usageDataQuery.Length() +
            descPart.Length() +
            aQuery.Length() );
    newQuery.Append( KSQLGetListByLaunchDataPart1 );
    newQuery.Append( aQuery );
    newQuery.Append( KSQLGetListByLaunchDataPart2 );
    newQuery.Append( usageDataQuery );
    newQuery.Append( KSQLGetListByLaunchDataPart3 );
    newQuery.Append( descPart );
    aQuery.Close();
    aQuery.CreateL( newQuery );

    CleanupStack::PopAndDestroy( &newQuery );
    CleanupStack::PopAndDestroy( &usageDataQuery );
    CleanupStack::PopAndDestroy( &descPart );
    }
コード例 #4
0
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);
	}
コード例 #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
	}
コード例 #6
0
void CWindowGroupListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
	{
	_LIT(KWgDesc,"WindowGroup;RawName;OwnerThreadId;System;Busy;Hidden");
	_LIT(KWgFmt,"WindowGroup;%S;%i;%i;%i;%i");

	if (i == 0) clogger.Log(KWgDesc);
	SWgInfo& info = *reinterpret_cast<SWgInfo*>(iInfo);
	CApaWindowGroupName* wg = info.iName;
	TPtrC name = wg->WindowGroupName();
	TBuf<256> temp = name;
	PrettyName(EListWindowGroups, temp);
	RBuf val;
	val.CreateL(256);
	TThreadId tid;
	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
	if (res == KErrNone)
		{
		res = tid;
		}

	clogger.Log(KWgFmt, &temp, res, wg->IsSystem(), wg->IsBusy(), wg->Hidden());
	val.Close();
	}
コード例 #7
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();
	}
コード例 #8
0
void TestVFATCase1()
	{
	test.Next(_L("Test Without VFAT entry, but DOS entry uses CP932 Japanese file's access"));
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));

	GetBootInfo();

   	RFile file;
  	TFileName fn = _L("\\ABCD");
  	
  	TInt r=file.Create(TheFs,fn,EFileRead);
  	testAndLog(r==KErrNone);
  	file.Close();
  
  	//	Assume this file is the first entry in the root directory
  	r=TheDisk.Open(TheFs,CurrentDrive());
  	testAndLog(r==KErrNone);

    //-- read the 1st dir entry, it should be a DOS entry 
    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
      
    TFatDirEntry fatEntry1;
 	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
	testAndLog(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); 
	testAndLog(!fatEntry1.IsVFatEntry());

	// Manually modify the short name into unicode characters
	// 	Unicode: 	0x(798F 5C71 96C5 6CBB)
	//	Shift-JIS: 	0x(959F 8E52 89EB 8EA1)

	TBuf8<8> unicodeSN = _L8("ABCD1234");
	unicodeSN[0] = 0x95;
	unicodeSN[1] = 0x9F;
	unicodeSN[2] = 0x8E;
	unicodeSN[3] = 0x52;
	unicodeSN[4] = 0x89;
	unicodeSN[5] = 0xEB;
	unicodeSN[6] = 0x8E;
	unicodeSN[7] = 0xA1;

	fatEntry1.SetName(unicodeSN);
	testAndLog(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
	TheDisk.Close();

  	// The Unicode file name of the file that is created
  	fn = _L("\\ABCD");
  	fn[1] = 0x798F;
  	fn[2] = 0x5C71;
  	fn[3] = 0x96C5;
  	fn[4] = 0x6CBB;
  	
  	// Access the file using its unicode file name without the DLL loaded.
      r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
  	test_KErrNone(r);
  	
  	TEntry entry;
  	TInt err = TheFs.Entry(fn, entry);
  	testAndLog(err==KErrNotFound);
  	
      // Access the file using its unicode file name with the DLL loaded.
      r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);  	
	test_KErrNone(r);
 	r = UserSvr::ChangeLocale(KTestLocale);  	
	test_KErrNone(r);
  
  	err = TheFs.Entry(fn, entry);
  	testAndLog(err==KErrNone);
  	
  	//file is no more required,delete it.
  	err = TheFs.Delete(fn);
  	testAndLog(err==KErrNone);
  	
      r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
  	test_KErrNone(r);
  	
 	r=TheFs.SessionPath(gSessionPath);
  	test_KErrNone(r);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}
コード例 #9
0
void TestVFATCase2()
	{
	test.Next(_L("Test With VFAT entry, and DOS entry using CP932 Japanese file's access"));
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));

	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
	test_KErrNone(r);
		
	r = UserSvr::ChangeLocale(KTestLocale);
	test_KErrNone(r);
	r=TheFs.SetSessionPath(gSessionPath);
	testAndLog(r==KErrNone);
	
	_LIT(KTestNormalFileName, 		"\x65B0\x6587\x4EF6.TXT");	
	_LIT(KTestNormalFileShortName, 	"\x65B0\x6587\x4EF6.TXT");
	
	test.Printf(_L("Create a file with the DLL installed, and get the shortname"));
	r=TheFile.Create(TheFs,KTestNormalFileName,EFileRead|EFileWrite);
	testAndLog(r==KErrNone);
	TFileName sn;
	r = TheFs.GetShortName(KTestNormalFileName, sn);
	testAndLog(r==KErrNone);
	r = sn.Compare(KTestNormalFileShortName);
	testAndLog(r==0);
	TheFile.Close();
	
	test.Printf(_L("Access the file with the DLL installed"));
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
	testAndLog(r==KErrNone);
	
	TBuf<50> name;	
	r=TheFile.FullName(name);
	testAndLog(r==KErrNone);
	TheFile.Close();
	
	r=TheFile.Open(TheFs,KTestNormalFileShortName,EFileWrite);
	testAndLog(r==KErrNone);
	TheFile.Close();
	
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	
	test.Printf(_L("Access the file without the DLL installed"));
	
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
	testAndLog(r==KErrNone);

	r=TheFile.FullName(name);
	testAndLog(r==KErrNone);
	TheFile.Close();
	
	r=TheFile.Open(TheFs,KTestNormalFileShortName,EFileWrite);
	testAndLog(r==KErrNone);
	TheFile.Close();
	
	r=TheFs.Delete(KTestNormalFileName);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}
コード例 #10
0
void TestIllegalCharsWithDll()
	{
	test.Next(_L("Test Illegal Character handling with DLL"));			
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
	
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
	testAndLog(r==KErrNone);

	r = UserSvr::ChangeLocale(KTestLocale);
	testAndLog(r==KErrNone);

	_LIT(KTestNormalUnicodeFileName, 				"\x65B0\x6587\x4EF6.TXT");
	_LIT(KTestNormalUnicodeFileNameShortDefualt, 	"\x65B0\x6587\x4EF6.TXT");
	_LIT(KTestFileNameWithIllegalChars, 			"\x222F\x2F3A\x3C3E\x7C00.TXT");
	_LIT(KFileNameWithIllegalCharsShort, 			"___\x7C00.TXT");
	_LIT(KTestFileNameWithWildChars, 				"\x235B\x245C\x255D\x265E.TXT");
	_LIT(KTestFileNameWithWildCharsShort, 			"____.TXT");

	TFileName shn;

	MakeFile(KTestNormalUnicodeFileName);
	r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
	testAndLog(r==KErrNone);
	r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
	testAndLog(r==0);

	TFileName lgn;
	r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
	testAndLog(r==KErrNone);
	r = lgn.Compare(KTestNormalUnicodeFileName);
	testAndLog(r==0);

	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
	MakeFile(KTestFileNameWithIllegalChars);
	r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
	testAndLog(r==KErrNone);
	r = shn.Compare(KFileNameWithIllegalCharsShort);
	testAndLog(r==0);
	
	// Test wildcards, 8-bit ASCII chars in 16-bit Unicode chars.
	MakeFile(KTestFileNameWithWildChars);
	r = TheFs.GetShortName(KTestFileNameWithWildChars, shn);
	test_KErrNone(r);
	r = shn.Compare(KTestFileNameWithWildCharsShort);
	testAndLog(r==0);
	
	r=TheFs.Delete(KTestFileNameWithIllegalChars);
	testAndLog(r==0);
	r=TheFs.Delete(KTestNormalUnicodeFileName);
	testAndLog(r==0);
	r=TheFs.Delete(KTestFileNameWithWildChars);
	testAndLog(r==0);
	
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}
コード例 #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
}
コード例 #12
0
ファイル: FSocket.cpp プロジェクト: ruphy/kfunambol
void FSocket::ConstructL(const StringBuffer& peer, int32_t port) 
{
    //LOG.debug("FSocket::ConstructL");
    
    StringBuffer  errorMsg;
    RHostResolver resolver; 
    RBuf          serverName;
    TNameEntry    hostAddress;
    TInetAddr     address;
    TInt          res = KErrNone;

    serverName.Assign(stringBufferToNewBuf(peer));
    
    //
    // Get the connection manager instance
    //
    FConnection* connection = FConnection::getInstance();
    if (!connection) {
        iStatus = -1;
        errorMsg = "Error opening connection";
        goto error;
    }
    // Session is owned by FConnection!
    RSocketServ* session = connection->getSession();

    //
    // Open the Client Socket tcp/ip
    //
#ifdef __WINSCW__
    // WINSCW: simply open the socket
    res = iSocket.Open(*session, KAfInet, KSockStream, KProtocolInetTcp);
#else
    // GCCE: use the existing connection
    // If first time, connect to gprs
    if (!connection->isConnected()) {
        LOG.debug("FSocket: not connected, start new connection");
        if (connection->startConnection()) {
            iStatus = -1;
            errorMsg = "FSocket: error starting connection";
            goto error;
        }
    }
    RConnection* conn = connection->getConnection();
    
    LOG.debug("Opening socket and associate with existing connection");
    res = iSocket.Open(*session, KAfInet, KSockStream, KProtocolInetTcp, *conn);
    //LOG.debug("Socket opened (err = %d)", res);
#endif
    if (res != KErrNone) {
        iStatus = -1;
        errorMsg.sprintf("FSocket : Error opening socket. code %d", res);
        goto error;
    }
    
    
    // This works if serverName is the ip address, like "x.y.z.w"
    res = address.Input(serverName);
    
    if (res != KErrNone) {
        //
        // Try to resolve the host address. (On GCCE, use the existing RConnection)
        //
        LOG.debug("Resolve IP address...");
#ifdef __WINSCW__
        res = resolver.Open(*session, KAfInet, KProtocolInetTcp);
#else
        res = resolver.Open(*session, KAfInet, KProtocolInetTcp, *conn);
#endif
        if (res != KErrNone) {
            iStatus = -2;
            errorMsg.sprintf("FSocket: Host resolver open failed. code %d", res);
            goto error;
        }
        
        resolver.GetByName(serverName, hostAddress, iStatus);
        User::WaitForRequest(iStatus);
        resolver.Close();
        if (iStatus != KErrNone) {
            errorMsg.sprintf("FSocket: DNS lookup failed. code %d", iStatus.Int());
            goto error;
        }

        // Set the socket server address/port
        address = hostAddress().iAddr;
    }
    
    address.SetPort(port);
    
    
    // --- Connect to host ---
    LOG.debug("Socket connect...");
    iSocket.Connect(address, iStatus);
    User::WaitForRequest(iStatus);
    if (iStatus != KErrNone) {
        errorMsg.sprintf("FSocket: Failed to connect to Server. code %d", iStatus.Int()); 
        goto error;
    }

    serverName.Close();
    return;
    
error:
    LOG.error("%s", errorMsg.c_str());
    serverName.Close();
    return;
}
コード例 #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();
	}