/**
   @SYMTestCaseID UIF-ETUL-0024

   @SYMREQ DEF114388
 
   @SYMTestCaseDesc Test of CTulAddressStringTokenizer::SearchPhoneNumberL( const TDesC& aText )
                    with all the phone number separators.
  
   @SYMTestPriority Normal 
 
   @SYMTestStatus Implemented
  
   @SYMTestActions There should be 5 phone numbers separators:
                      - KCharLinefeed = 0x000A 
                      - KCharFormfeed = 0x000C
                      - KCharCarriageReturn = 0x000D
                      - KCharLineSeparator = 0x2028
                      - KCharParagraphSeparator = 0x2029
                   With a simple string _LIT16(KTestPhoneSeparator, "11111%c22222")
                   and with all the separators above, we apply the tested function:
                   CTulAddressStringTokenizer::SearchPhoneNumberL( const TDesC& aText )
                      
  
   @SYMTestExpectedResults On the 5 cases, the function should find 2 phone numbers
                           i.e: multiSearch->ItemCount() should be equal to 2
                           otherwise the test fail.
 */
void CT_AddressStringTokenizerStep::TestPhoneSearchSeparatorsL()
	{
	TInt KCharLinefeed = 0x000A;
	TInt KCharFormfeed = 0x000C;
	TInt KCharCarriageReturn = 0x000D;
	TInt KCharLineSeparator = 0x2028;
	TInt KCharParagraphSeparator = 0x2029;
	TInt KSeparators[5]={KCharLinefeed,KCharFormfeed,KCharCarriageReturn,KCharLineSeparator,KCharParagraphSeparator};
	_LIT16(KTestPhoneSeparator, "11111%c22222");
	TBool succeed=ETrue;
	TBuf16<16> str;
	for (TInt k=0;k<5;k++)
		{
		str.Format(KTestPhoneSeparator,KSeparators[k]);
		CTulAddressStringTokenizer* multiSearch = CTulAddressStringTokenizer::NewL(str,
				CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin);

		 if (multiSearch->ItemCount()!=2)
			 {
			 succeed=EFalse;
			 }
		 delete multiSearch;
		 if (succeed==EFalse)
			 {
			 break;
			 }
		}
	TEST(succeed);	
	}
//Create an URI
void CExampleInetProtUtil::CreateUriL()
	{
	//Set the physical path of the file
	
	_LIT(KText1, "\n\n\nThe Physical location of the file is....");
	iConsole->Printf ( KText1 );
	
	_LIT(KFullUriName, "K:\\ws\\direct\\direct.mmp");

	//display it 
	TBuf<40> desFullUriName(KFullUriName);
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( KFullUriName );
	
	//create the Uri for the path
	CUri8* uri8 = CUri8::CreateFileUriL(desFullUriName); 
	
	const TDesC8& desUriDisplay = uri8->Uri().UriDes();
	TBuf16<100> desCreateUri;
	desCreateUri.Copy (desUriDisplay);
	
	//display it 
	_LIT(KText2, "And its Uri is....");
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( KText2 );
	
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( desCreateUri );
	
	delete uri8;
	
	iConsole->Getch ();
	}
//Encode and Decode the Uri
void CExampleInetProtUtil::EscapeEncodeDecodeL()
	{
	//Take an eg file to encode it and then decode it....
	_LIT(KFullUriName,"K:\\ws\\direct\\direct.mmp");
	TBuf<40> desFullUriName(KFullUriName);
	
	//UTF-8 defines a mapping from sequences of octets to sequences of chars
	HBufC8* convert = EscapeUtils::ConvertFromUnicodeToUtf8L(desFullUriName);

	//Encode the eg Uri and display it
	_LIT(KTextEncode, "\n\n\nThe Encoded Uri is....\n");
	iConsole->Printf ( KTextEncode );
	HBufC16* encode = EscapeUtils::EscapeEncodeL(desFullUriName,EscapeUtils::EEscapeNormal);
	TPtr uriEncoded = encode->Des();
	TBuf16<100> desEncodedUri;
	desEncodedUri.Copy (uriEncoded);
	iConsole->Printf ( _L("%S"), &desEncodedUri );

	//Decode the eg Uri and display it
	_LIT(KTextDecode, "\nThe Decoded Uri is....\n");
	iConsole->Printf ( KTextDecode );
	
	HBufC16* decode = EscapeUtils::EscapeDecodeL(desFullUriName);
	TPtr uriDecoded = decode->Des();
	TBuf16<100> desDecodedUri;
	desDecodedUri.Copy (uriDecoded);
	iConsole->Printf ( _L("%S"), &desDecodedUri );

	delete decode;
	delete encode;
	delete convert;

	iConsole->Getch();
	iConsole->Printf ( KLeaveALine );
	}
Esempio n. 4
0
void CMemoryUsageLogger::WriteMaxHeapToLog()
	{
	_LIT(KLogMaxHeapFormat, "%d, %d");

	//connect to file iLogger
	TInt err = iLogger.Connect();
	if (KErrNone == err)
		{
		//create new log file name out of existing
		TInt pos = iFileName.LocateReverse(TChar('.'));
		if (KErrNotFound != pos)
			{
			iFileName.Insert(pos, _L("_max_ram"));

			//create log file
			iLogger.CreateLog(KLbsDevLogFolder, iFileName, EFileLoggingModeOverwrite);
			
			//write header to log file
			iLogger.SetDateAndTime(EFalse, EFalse);

			//create log text and write to log file
			TBuf16<KLbsDevLogMaxBufSize> logData;
			logData.Format(KLogMaxHeapFormat, iMaxHeapTotal, iMaxChunkTotal);
			iLogger.Write(logData);
			iLogger.Write(KNullDesC8);
			}
		iLogger.Close();
		}
	}
/**
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0536
@SYMTestCaseDesc        Splitting and converting from Unicode to EucJpPacked test
@SYMTestPriority        Medium
@SYMTestActions         Tests for conversion after splitting, from Unicode to EucJpPacked and back to Unicode
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void CT_EUCJP_PACKED_2::TestSplittingConvertingFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfEucJpPacked, const TDesC8& aExpectedEucJpPacked, const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0536 "));
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
	test(aMaximumLengthUpperLimit<=KBufferLength);
	TUint8 eucJpPackedBuffer[KBufferLength];
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
		{
		TPtr8 generatedFirstPartOfEucJpPacked(eucJpPackedBuffer, i);
		test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfEucJpPacked, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
		test(generatedFirstPartOfEucJpPacked==aExpectedEucJpPacked.Left(aExpectedLengthOfFirstPartOfEucJpPacked));
		TBuf8<KBufferLength> generatedSecondPartOfEucJpPacked;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfEucJpPacked, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
		test(generatedSecondPartOfEucJpPacked==aExpectedEucJpPacked.Mid(aExpectedLengthOfFirstPartOfEucJpPacked));
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfEucJpPacked, state)==0);
		test(state==CCnvCharacterSetConverter::KStateDefault);
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfEucJpPacked, state)==0);
		test(state==CCnvCharacterSetConverter::KStateDefault);
		generatedUnicode.Append(generatedSecondPartOfUnicode);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
Esempio n. 6
0
// ---------------------------------------------------------------------------
// SdpUtil::SetDefaultNetTypeAndAddrType
// Sets network type and address type to their "default" values
// ---------------------------------------------------------------------------
//
void SdpUtil::SetDefaultNetTypeAndAddrType( 
    RStringPool aPool, 
    const TInetAddr& aAddress,
    RStringF& aNetType, 
    RStringF& aAddressType )
    {
     // Sets network type to IN
    aNetType.Close();
    aNetType = aPool.StringF( SdpCodecStringConstants::ENetType,
                              SdpCodecStringConstants::Table ).Copy();
    // Address type       
    aAddressType.Close();

    TBuf16 <KMaxAddressLength> output;
    aAddress.Output(output);


    //addresstype for IPv4    
	if((aAddress.Address() &&  !aAddress.IsV4Mapped()) ||
       (!aAddress.Address() && aAddress.IsWildAddr() && 
        output.Match(KWildAddr) == 0))
        {
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    else
        {
		//addresstype for IPv4-Mapped IPv6 && IPv6
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressType,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    }
Esempio n. 7
0
HBufC* CPluginUtils::ConvertUtfToUnicodeL( const TDesC8& aUtf7 )
	{

	RBuf output;
	CleanupClosePushL( output );
	
	TBuf16<20> outputBuffer;
	TPtrC8 remainderOfUtf7( aUtf7 );

	for(;;)
		{
		const TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(outputBuffer, remainderOfUtf7);
		if (returnValue==CnvUtfConverter::EErrorIllFormedInput)
			return NULL;
		else if (returnValue<0)
			return NULL;
        
		output.ReAllocL( output.Length() + outputBuffer.Length() );
		output.Append( outputBuffer );

        if (returnValue == 0)
            break;

        remainderOfUtf7.Set(remainderOfUtf7.Right(returnValue));
		}

	HBufC* ret = output.AllocL();
	
	CleanupStack::PopAndDestroy( &output );
	return ret;
	}
void CT_ISO2022JP1_2::TestSplittingConvertingFromUnicodeToIso2022Jp(
                CCnvCharacterSetConverter& aCharacterSetConverter,
                TInt aMaximumLengthLowerLimit,
                TInt aMaximumLengthUpperLimit,
                TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit,
                const TDesC8& aExpectedFirstPartOfIso2022Jp,
                const TDesC8& aExpectedSecondPartOfIso2022Jp,
                const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp "));
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
	test(aMaximumLengthUpperLimit<=KBufferLength);
	TUint8 iso2022JpBuffer[KBufferLength];
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
		{
		TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i);
		test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
		test(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp);
		TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
		test(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0);
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0);
		generatedUnicode.Append(generatedSecondPartOfUnicode);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
Esempio n. 9
0
 void roadmap_internet_open_browser (char *url) {
 	  RApaLsSession apaLsSession;
 	  const TUid KOSSBrowserUidValue = {0x10008D39}; // 0x1020724D for S60 3rd Ed
 	  TUid id(KOSSBrowserUidValue);
 	  TApaTaskList taskList(CEikonEnv::Static()->WsSession());
 	  TApaTask task = taskList.FindApp(id);
 	  if(task.Exists())
 		  {
 		  task.BringToForeground();
 		  task.SendMessage(TUid::Uid(0), TPtrC8((TUint8 *)url,strlen(url))); // UID not used
 		  }
 	  else
 		  {
 		  if(!apaLsSession.Handle())
 			  {
 			  User::LeaveIfError(apaLsSession.Connect());
 			  }
 		  TThreadId thread;
 		  
 		  TBuf16<128> buf;
 		  buf.Copy(TPtrC8((TUint8 *)url,strlen(url)));
 		   		  
 		  User::LeaveIfError(apaLsSession.StartDocument(buf, KOSSBrowserUidValue, thread));
 		  apaLsSession.Close();   
 		  }
 }
//Modify URI components
void CExampleInetProtUtil::ModifyUriComponentsL()
	{	
	TUriParser8 parser1;
	CUri8* aUri = CUri8::NewL(parser1);
	
	_LIT(KText3, "\n\n\nAdding Uri components one by one....");
	iConsole->Printf ( KText3 );

	// Adding components to the Uri
	
	//Setting and displaying SCHEME
	_LIT8(KScheme, "http");
	_LIT(KScheme1, "\nSCHEME : http");
	iConsole->Printf ( KScheme1 );
	aUri->SetComponentL(KScheme, EUriScheme);
	
	//Setting and displaying HOST
	_LIT8(KHost, "www.symbian.com");
	_LIT(KHost1, "\nHOST : www.symbian.com");
	iConsole->Printf ( KHost1 );
	aUri->SetComponentL(KHost, EUriHost);
	
	//Setting and displaying PORT
	_LIT8(KPort, "80");
	_LIT(KPort1, "\nPORT : 80");
	iConsole->Printf ( KPort1 );
	aUri->SetComponentL(KPort, EUriPort);
	
	//Setting and displaying PATH
	_LIT8(KPath, "/developer/techlib/turic8class.html");
	_LIT(KPath1, "\nPATH : /developer/techlib/turic8class.html");
	iConsole->Printf ( KPath1 );
	aUri->SetComponentL(KPath, EUriPath);
	
	//Display the constucted Uri
	_LIT(KText4, "\nThe fully constructed Uri....");
	iConsole->Printf ( KText4 );
	const TDesC8& desUriDisplay = aUri->Uri().UriDes();
	TBuf16<100> desFullUri;
	desFullUri.Copy (desUriDisplay);
	
	iConsole->Printf( KLeaveALine );
	iConsole->Printf ( desFullUri );
	
	// Removal of component from the Uri
	iConsole->Getch ();
	_LIT(KText5, "\n\nUri with the Port number removed....\n");
	iConsole->Printf ( KText5 );
	aUri->RemoveComponentL(EUriPort);

	//Display the modified Uri
	const TDesC8& desRemovedComponentDisplay =aUri->Uri().UriDes();
	TBuf16<100> desRemovedComponent;
	desRemovedComponent.Copy (desRemovedComponentDisplay);
	iConsole->Printf ( desRemovedComponent );
	
	delete aUri;
	
	iConsole->Getch ();
	}
Esempio n. 11
0
TInt CSEIConnector::RunError(TInt aError)
	{
	//TODO: see how to handle this
	_LIT(KErrorPattern, "@CSEIConnector::RunError: %d");
	TBuf16<128> buf;
	buf.Format(KErrorPattern, aError);
	iDriver->Log(buf);
	return KErrNone;
	}
Esempio n. 12
0
void CPhoneCallMonitor::RunL()
	{
  	CTelephony::TCallStatus status = iCallStatus.iStatus;
  	
  	// use callback function to tell owner that call status has changed
  	//iCallBack.NotifyChangeInCallStatusL(status,errVal);
  	if(iStatus.Int() == KErrNone)
  	{
  	if(status == CTelephony::EStatusConnected)
  		{
		CTelephony::TRemotePartyInfoV1 remInfoUse;
  		CTelephony::TCallInfoV1		   callInfoUse;
  		CTelephony::TCallSelectionV1   callSelectionUse;
  		
  		// we are interested only voice lines
  		callSelectionUse.iLine = CTelephony::EVoiceLine;
  		// and calls that are currently connected
  		callSelectionUse.iSelect = CTelephony::EActiveCall;  //EHeldCall, EInProgressCall
  		
  		CTelephony::TRemotePartyInfoV1Pckg 	remParty(remInfoUse);
  		CTelephony::TCallInfoV1Pckg 		callInfo(callInfoUse);
  		CTelephony::TCallSelectionV1Pckg 	callSelection(callSelectionUse);
  		
  		// Some S60 devices have a bug that requires some delay in here
  		// othervise the telephone application gets "Out of Memory" error
  		User::After(100000);
  		if(KErrNone == iTelephony->GetCallInfo(callSelection,callInfo,remParty))
  			{
			if(remInfoUse.iDirection == CTelephony::EMobileOriginated) //outgoign call
				{
				iCallBack.NotifyConnectedCallStatusL(callInfoUse.iDialledParty.iTelNumber);
				}
			else   //incoming call
				{
				// if the call is mobile terminated then the remote party is the calling party.
				// TCallRemoteIdentityStatus::ERemoteIdentityUnknown, ERemoteIdentityAvailable, ERemoteIdentitySuppressed
				if(remInfoUse.iRemoteIdStatus == CTelephony::ERemoteIdentityAvailable)
					{
					iCallBack.NotifyConnectedCallStatusL(remInfoUse.iRemoteNumber.iTelNumber);
					}
				else  // private number
					{
					TBuf16<1> privNum;
					privNum.Zero();
					iCallBack.NotifyConnectedCallStatusL(privNum);
					}
				}
  			}
  		}
  	if(status == CTelephony::EStatusIdle)
  		{
		iCallBack.NotifyDisconnectedCallStatusL();
  		}
  	//iPreviousStatus = status;
  	}
	StartListeningForEvents();
	}
Esempio n. 13
0
void CTextWindow::Draw()
//This function is virtual and so cannot have an 'L' at the end of it's name
	{
	iGc->Clear();
	ResetPrintLine();
	switch(iDrawMode)
		{
	case EDrawModeWordJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawWordJustified(_L("Hello World"));
		DrawWordJustified(_L("One Two Three Four Five Six Seven"));
		DrawWordJustified(_L("AA    B        CC D"));
		DrawWordJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeCharJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawCharJustified(_L("Hello World"));
		DrawCharJustified(_L("One Two Three Four Five Six Seven"));
		DrawCharJustified(_L("AA    B        CC D"));
		DrawCharJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeFonts:
		{
		TTypefaceSupport typefaceSupport;
		Client()->iScreen->TypefaceSupport(typefaceSupport,iTypeFaceIndex);
		TBuf<0x40> title;
		TBuf16<KMaxTypefaceNameLength> tmpBuf;
		tmpBuf.Copy(typefaceSupport.iTypeface.iName);
		title.Append(tmpBuf);
		title.AppendFormat(TRefByValue<const TDesC>(_L(", Heights (Min=%d, Max=%d, Num=%d)")),typefaceSupport.iMinHeightInTwips,typefaceSupport.iMaxHeightInTwips,typefaceSupport.iNumHeights);
		PrintLine(iFont,title);
		PrintDivider();
		for (TInt tfHeight=0;tfHeight<typefaceSupport.iNumHeights;tfHeight++)
			{
			TFontSpec fspec(typefaceSupport.iTypeface.iName,Client()->iScreen->FontHeightInTwips(iTypeFaceIndex,tfHeight));
			PrintStylesL(_L("Normal, "), fspec, TFontStyle());
			PrintStylesL(_L("Bold, "), fspec, TFontStyle(EPostureUpright,EStrokeWeightBold,EPrintPosNormal));
			PrintStylesL(_L("Italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightNormal,EPrintPosNormal));
			PrintStylesL(_L("Bold/italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightBold,EPrintPosNormal));
			if (iYpos>Size().iHeight)
				break;
			}
		}
		break;
		}
	}
Esempio n. 14
0
EXPORT_C void TcLog::WriteFormat( TRefByValue< const TDesC16 > aFormat, ... )
	{
	VA_LIST list;
	VA_START( list, aFormat );

	TBuf16< KTcBufferSize > buf;
	TTcDes16Overflow handler;
	buf.AppendFormatList( aFormat, list, &handler );

	Write( buf );
	}
//Validate URI components
void CExampleInetProtUtil::ValidateUriComponentsL()
	{
	TUriParser8 parser1;
	CUri8* aUri = CUri8::NewL(parser1);
	
	_LIT(KTextf, "\n\n\nValidating the Uri....\n");
	iConsole->Printf ( KTextf );
	
	// Adding components to the Uri
	
	//Adding Scheme
	_LIT8(KScheme, "http");
	aUri->SetComponentL(KScheme,EUriScheme);
	
	//Adding Host
	_LIT8(KHost, "waterlang.org");
	aUri->SetComponentL(KHost,EUriHost);
	
	//Adding Port
	_LIT8(KPort, "90");
	aUri->SetComponentL(KPort,EUriPort);
	
	//Adding Path
	_LIT8(KPath, "/turic8class.html");
	aUri->SetComponentL(KPath,EUriPath);
	
	//Adding Query
	_LIT8(KQuery, "bar=2&x=3");
	aUri->SetComponentL(KQuery,EUriQuery);
	
	//Adding Fragment
	_LIT8(KFragment, "fragment");
	aUri->SetComponentL(KFragment,EUriFragment);
	
	//Display the constructed Uri
	const TDesC8& desUriDisplays =aUri->Uri().UriDes();
	TBuf16<100> desValidate;
	desValidate.Copy (desUriDisplays);
	iConsole->Printf ( desValidate );
	
	// Validate() is not supported for HTTP, but only SIP and SIPS. 
	//The Parse() function itself validates the components and returns the 
	//appropriate result.
	TInt res = parser1.Parse(desUriDisplays);
	if (res==KErrNone)
	{
		_LIT(KText8, "\nThis Uri is VALID");
		iConsole->Printf ( KText8 );
	}
	
	delete aUri;
	
	iConsole->Getch();
	}
TVerdict CSysUtilsGetLangSWVersionNoNewLinesStep::doTestStepL()
	{
	TInt err = SetTestPath(ETrue);
	if( err != KErrNone )
		{
		ERR_PRINTF2(_L("Could not turn test path on. Error = %d"), err);
		SetTestStepResult(EAbort);
		return TestStepResult();
		}
	INFO_PRINTF1(_L("Test path turned on."));
	
	err = DeletePSProperties();
	if( err != KErrNone )
		{
		ERR_PRINTF2(_L("Could not delete P&S properties. Error = %d"), err);
		SetTestStepResult(EAbort);
		return TestStepResult();
		}
	INFO_PRINTF1(_L("Deleted P&S properties successfully."));

	_LIT16(KDummy,"xxxxx");

	TBuf16<KSysUtilVersionTextLength> version;
	version.Insert(0,KDummy);

	err = SysUtil::GetLangSWVersion( version );
	
	if ( err == KErrNone)
		{
		_LIT(KLangSw, "LangSW");
		TPtrC16 line;
		TESTL( GetStringFromConfig(ConfigSection(), KLangSw, line) );
		TBuf16<KSysUtilVersionTextLength> testBuf(line);
		if (version.Compare(testBuf)==0)
			{
			INFO_PRINTF1(_L("Got version "));
			INFO_PRINTF1(version);
			}
		else
			{
			ERR_PRINTF1(_L("Version not correct"));
			INFO_PRINTF1(version);
			SetTestStepResult(EFail);
			}

		}
	else 
		{
		ERR_PRINTF2(_L("Error code = %d"), err);
		SetTestStepResult(EFail);
		}

	return TestStepResult();
	}
Esempio n. 17
0
void CMemoryUsageLogger::WriteToLog()
	{
	//seconds passed since start of application
	TTime currentTime;
	TTimeIntervalSeconds seconds;
	currentTime.UniversalTime();
	currentTime.SecondsFrom(iStartTime, seconds);
	
	if (seconds.Int() <= 60)
		{
		TInt heapTotal = 0;
		TInt heapAvail = 0;
		TInt chunkTotal = 0;
		TInt chunkAvail = 0;
		TInt cellsTotal = 0;
		TInt cellsAvail = 0;
		TInt heapStackTotal = 0;
		TInt ramTotal = 0;
		TInt ramAvail = 0;
		
		//get system memory info from hardware abstraction layer
		HAL::Get(HAL::EMemoryRAM, ramTotal);
		HAL::Get(HAL::EMemoryRAMFree, ramAvail);
		
		//get process UID
		TSecureId processUid(iProcess.SecureId());
		
		//get various heap and chunk memory sizes
		iHeap.AllocSize(heapTotal);
		if (heapTotal > iMaxHeapTotal)
			{
			iMaxHeapTotal = heapTotal;
			}
		iHeap.Available(heapAvail);
		chunkTotal = iHeap.Size();
		chunkAvail = chunkTotal - heapTotal;
		if (chunkTotal > iMaxChunkTotal)
			{
			iMaxChunkTotal = chunkTotal;
			}
		
		//get cells info
		cellsTotal = iHeap.Count(cellsAvail);
		
		//sum up the total heap and stack sizes
		heapStackTotal = heapTotal + iStackSize;
		
		//create log text and write to log file
		TBuf16<KLbsDevLogMaxBufSize> logData;
		logData.Format(KLogFormat, seconds.Int(), processUid.iId, iStackSize, heapTotal, heapAvail, chunkTotal, chunkAvail, cellsTotal, cellsAvail, heapStackTotal, ramTotal, ramAvail);
		iLogger.Write(logData);
		}
	}
Esempio n. 18
0
/**  Delete content of directory

	@param aDir	Target directory
	
	@return Error returned if any, otherwise KErrNone
*/
TInt DeleteAll(TDes16& aDir) 
	{
		TBuf16<100> dir;
		CFileMan* fMan=CFileMan::NewL(TheFs);
		TInt r=0;
		
		dir = aDir;
		dir.Append(_L("F*.*"));
		r = fMan->Delete(dir);	

		delete fMan;
		return r;
	}
Esempio n. 19
0
GLDEF_C TInt E32Main()
    {
	TBuf16<512> cmd;
	User::CommandLine(cmd);
	if(cmd.Length() && TChar(cmd[0]).IsDigit())
		{
		TInt function = -1;
		TInt arg1 = -1;
		TInt arg2 = -1;
		TLex lex(cmd);

		lex.Val(function);
		lex.SkipSpace();
		lex.Val(arg1);
		lex.SkipSpace();
		lex.Val(arg2);
		return DoTestProcess(function,arg1,arg2);
		}

	test.Title();

	if((!PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation))||(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)))
		{
		test.Start(_L("TESTS NOT RUN - PlatSecProcessIsolation is not enforced"));
		test.End();
		return 0;
		}

	test(SyncMutex.CreateGlobal(KSyncMutext)==KErrNone);
	
	test.Start(_L("Test SetJustInTime"));
	TestSetJustInTime();

	test.Next(_L("Test Rename"));
	TestRename();

	test.Next(_L("Test Kill, Panic and Teminate"));
	TestKill();

	test.Next(_L("Test Resume"));
	TestResume();

	test.Next(_L("Test SetPriority"));
	TestSetPriority();


	SyncMutex.Close();
	test.End();

	return(0);
    }
Esempio n. 20
0
void CMobilePhone::RunL(void)
{
  TBuf16<128> string;
  if(iStatus==KErrNone)
  {
    string.Append(_L("Success."));
  }
  else
  {
    string.Append(_L("Error ("));
    string.AppendNum(iStatus.Int());
    string.Append(_L(")."));
  }
  ShowResult(string);
}
/**
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0537
@SYMTestCaseDesc        Tests for truncated conversion from EucJpPacked to Unicode
@SYMTestPriority        Medium
@SYMTestActions         Tests for truncated conversion from EucJpPacked to Unicode and back to EucJpPacked
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void CT_EUCJP_PACKED_2::TestTruncatedConversionToUnicodeFromEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalEucJpPacked)
	{
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0537 "));
	for (TInt i=aOriginalEucJpPacked.Length(); i>=3; --i) // 3 is the length of GBK's longest multi-byte characters
		{
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalEucJpPacked.Left(i), state);
		test(returnValue>=0);
		TBuf16<KBufferLength> generatedsecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalEucJpPacked.Mid(i-returnValue), state)==0);
		generatedUnicode.Append(generatedsecondPartOfUnicode);
		test(generatedUnicode==aExpectedUnicode);
		}
	}
Esempio n. 22
0
TInt CSwiEngine::RunInNewThreadL(CSwiTask* aTask)
	{
	CPassiveLogger* logger = aTask->Logger();
	
	RThread installRunnerThread;       
	TInt status = installRunnerThread.Create(       
		KThreadName,       
		reinterpret_cast<TThreadFunction>(ThreadFunction),       
		KDefaultStackSize,       
		NULL,
		aTask     
		);       

	User::LeaveIfError(status);       

	TRequestStatus threadStat;
	threadStat=KRequestPending;       

	installRunnerThread.Resume();       
	installRunnerThread.Logon(threadStat);

	User::WaitForRequest(threadStat);
	installRunnerThread.Close();       

	TInt result = threadStat.Int();  
	//NOTE: if removal result==-14 (KErrInUse) it's because the VM didnt exit yet.
	// Security checks if the suite is in use in a very naive way, it simply
	// tries to open the Jar file..
	// However, in that case, it is undefined if the removal was successfull.
	if(result == KErrNone)
		{
		logger->AppendL(_L("Swi:Task complete"));
		}
	else
		{
	    _LIT(KErrorPattern, "Swi:Task failed: %d");
    	TBuf16<64> buf;
    	buf.AppendFormat(KErrorPattern, result);
    	logger->AppendL(buf);
    	//User::Leave(error);
		//not leaving to allow command response to be written back
		//to the SEI
		}
	logger->Flush();     
	delete logger;
	return result;
	}
Esempio n. 23
0
void GenarateUriTestsL()
	{
	test.Next(_L("@SYMTestCaseID IWS-APPPROTOCOLS-INETURILIST-TESTUTILS-0002 Generating 8 bit URIs"));
	CUri8* uri8 = CUri8::NewLC();
	uri8->SetComponentL(KScheme0, EUriScheme);
	uri8->SetComponentL(KHost0, EUriHost);
	uri8->SetComponentL(KUserInfo0, EUriUserinfo);
	uri8->SetComponentL(KPort0, EUriPort);
	uri8->SetComponentL(KParams0, EUriPath);
	uri8->SetComponentL(KHeaders0, EUriQuery);
	const TDesC8& des8 = uri8->Uri().UriDes();
	TInt result = des8.Compare(KUri0);
	test(!result);
	CleanupStack::PopAndDestroy(uri8);
	
	test.Next(_L("Generating 16 bit URIs"));
	CUri16* uri16 = CUri16::NewLC();
	gUriComponent16.Copy(KScheme0);
	uri16->SetComponentL(gUriComponent16, EUriScheme);
	gUriComponent16.Copy(KHost0);
	uri16->SetComponentL(gUriComponent16, EUriHost);
	gUriComponent16.Copy(KUserInfo0);
	uri16->SetComponentL(gUriComponent16, EUriUserinfo);
	gUriComponent16.Copy(KPort0);
	uri16->SetComponentL(gUriComponent16, EUriPort);
	gUriComponent16.Copy(KParams0);
	uri16->SetComponentL(gUriComponent16, EUriPath);
	gUriComponent16.Copy(KHeaders0);
	uri16->SetComponentL(gUriComponent16, EUriQuery);
	const TDesC16& des16 = uri16->Uri().UriDes();
	gFullUri16.Copy(KUri0);
	result = des16.Compare(gFullUri16);
	test(!result);
	CleanupStack::PopAndDestroy(uri16);
	}
Esempio n. 24
0
void CT_KOI8R::DoE32MainL()
	{
	RFs fileServerSession;
	CleanupClosePushL(fileServerSession);
	User::LeaveIfError(fileServerSession.Connect());
	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=\
		CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
	
	INFO_PRINTF1(_L("Available:\n"));
	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
		{
		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
		TPtrC charactersSetName(charactersSet.Name());
		if (charactersSet.NameIsFileName())
			{
			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
			}
		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
		}
	
	INFO_PRINTF1(_L("Encoding from Unicode to Foreign"));
	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifier, *arrayOfCharacterSetsAvailable, fileServerSession);
	TBuf8<508> temp;
	TBuf16<254> originalUnicode;
	TBuf8<254> generatedForeign;
	TBuf16<254> generatedUnicode;
	ReadDescL(temp, KInputUnicodeFilename, fileServerSession);
	Merge_Big(temp, originalUnicode);
    test(characterSetConverter->ConvertFromUnicode(generatedForeign, originalUnicode) == 0);
	ReadDescL(temp, KExpectForeignFilename, fileServerSession);
	test(generatedForeign == temp);

	INFO_PRINTF1(_L("Encoding from Foreign to Unicode"));	
	ReadDescL(generatedForeign, KInputForeignFilename, fileServerSession);
	TInt state=CCnvCharacterSetConverter::KStateDefault;
	test( 0 == characterSetConverter->ConvertToUnicode(generatedUnicode, generatedForeign, state));
	ReadDescL(temp, KExpectUnicodeFilename, fileServerSession);
	originalUnicode.Zero();
	Merge_Big(temp, originalUnicode); 
	test(generatedUnicode == originalUnicode);
	
	CleanupStack::PopAndDestroy(3);
    }
Esempio n. 25
0
void ParseUriTestsDeprecated()
	{	
	test.Next(_L("Parsing 16 bit URIs (deprecated)"));
	gFullUri16.Copy(KUri0);
	TUriParser16 parser16;
	parser16.Parse(gFullUri16);
	gUriComponent16.Copy(KScheme0);
	TInt result = parser16.Extract(EUriScheme).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KUserInfo0);
	result = parser16.Extract(EUriUserinfo).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KHost0);
	result = parser16.Extract(EUriHost).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KPort0);
	result = parser16.Extract(EUriPort).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KParams0);
	result = parser16.Extract(EUriPath).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KHeaders0);
	result = parser16.Extract(EUriQuery).Compare(gUriComponent16);
	test(!result);
	}
// -----------------------------------------------------------------------------
// CSdDisk::ReleaseFiles
// This method deletes files created for filling the drive C
// 
// -----------------------------------------------------------------------------
void CSdDisk::ReleaseDisk(RFs& aFs)
    {
	// RDebug::Print(_L("Shareddatatest ## ReleaseDisk"));
	TInt i = 0;
	TInt err = KErrNone;
		
	do
	    {
		TBuf16<35> str;
		str.Copy(KFileName);
		str.AppendNum(i,EDecimal);
		
		err = aFs.Delete (str) ;
		
		i++;
	    }
	while ( err == KErrNone );
}
Esempio n. 27
0
void CT_ISO2022JP1_2::TestTruncatedConversionToUnicodeFromIso2022Jp(
                CCnvCharacterSetConverter& aCharacterSetConverter,
                const TDesC16& aExpectedUnicode,
                const TDesC8& aOriginalIso2022Jp)
	{
	INFO_PRINTF1(_L(" TestTruncatedConversionToUnicodeFromIso2022Jp "));
	for (TInt i=aOriginalIso2022Jp.Length(); i>=3; --i) // 3 is the length of ISO-2022-JP's longest escape sequence
		{
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalIso2022Jp.Left(i), state);
		test(returnValue>=0);
		TBuf16<KBufferLength> generatedsecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalIso2022Jp.Mid(i-returnValue), state)==0);
		generatedUnicode.Append(generatedsecondPartOfUnicode);
		test(generatedUnicode==aExpectedUnicode);
		}
	}
/**
@SYMTestCaseID		SYSLIB-BAFL-CT-4022 
@SYMREQ  	    	REQ8170
@SYMDEF			DEF141094
@SYMTestCaseDesc    GetVersionInsufficientBuffer
@SYMTestPriority    HIGH
@SYMTestStatus      Implemented
@SYMTestActions    	Use  the SysUtil::GetSWVersion method with its descriptor 
@SYMTestActions    	parameter’s size smaller than the length of the software version text 
@SYMTestActions    	Repeat for SysUtil::GetLangSWVersion 
@SYMTestExpectedResults KErrTooBig is returned because not all the software version text can 
@SYMTestExpectedResults	be read into the buffer supplied. 
*/
TVerdict CSysUtilsGetVersionInsufficienBufferStep::doTestStepL()
	{
	TInt err=KErrNone;
	const TInt bufSize = 6;
	
	_LIT16(kDummy,"xxxxx");

	TBuf16<bufSize> version;
	version.Insert(0,kDummy);
	
	err = SysUtil::GetSWVersion( version );
	ProcessError(err);
	err = SysUtil::GetLangSWVersion( version );
	ProcessError(err);
	err = SysUtil::GetPRInformation( version );
	ProcessError(err);
	
	return TestStepResult();
	}
/**
 * Returns bluetooth friendly name
 * Output: bluetooth friendly name
 */
std::wstring *S60BluetoothPlatformControl::getBluetoothName()
{
    TBuf16<KMaxBluetoothNameLen> bluetoothName;

    JELOG2(EJavaBluetooth);
    TInt error = RProperty::Get(KPropertyUidBluetoothCategory,
                                KPropertyKeyBluetoothGetDeviceName, bluetoothName);

    if (error != KErrNone || (0 == bluetoothName.Length()))
    {
        ELOG(EJavaBluetooth, "Bluetooth friendly name was not set");
        return NULL;
    }
    std::wstring *deviceName =
        new std::wstring((wchar_t*) bluetoothName.Ptr());

    deviceName->resize(bluetoothName.Length());
    return deviceName;
}
void CBrCtlSampleAppCommandObserver::HandleCommandL(TBrCtlDefs::TBrCtlClientCommands aCommand, 
const CArrayFix<TPtrC>& /*aAttributesNames*/,
const CArrayFix<TPtrC>& /*aAttributeValues*/)
{
    
    // Here we are creating a text string to be displayed on the screen, but if 
    // you were implementing this method, you would most likely be displaying a
    // progress bar.

    TBuf16<256> tgt; 

    _LIT(KHandleCommandEvent, "Command event = %d");//, size = %d, trId = %d");
     
    tgt.AppendFormat(KHandleCommandEvent, aCommand); //, aSize, aTransactionId);

    iContainer->SetText(tgt);

    iContainer->DrawNow();    
}