// -----------------------------------------------------------------------------
// CContactSubscriber::RunL()
// Assyncronous request handler , on completion of notification
// -----------------------------------------------------------------------------
//
void CContactSubscriber::RunL()
{
    __TRACE_CALLSTACK;
    SubscribeChangeNotiFication();
    // property updated, get new value 
    TBuf8 <KBufferSize> value; 
    TPtrC8  id; 
    TPtrC8  sourceType; 
    TPtrC8  addressCount; 
    
    if ( KErrNone == iProperty.Get( value ) )
    { 
        TInt pos =  value.Locate(TChar('-')); 
        id.Set( value.Left(pos) ); 
        
        TPtrC8 ptr = value.Right(3); 
        sourceType.Set(ptr.Left(1)); 
        addressCount.Set(ptr.Right(1)); 
        
        TInt appId = -1, addressType = -1, addressTypeCount = -1; 
        TLex8 lex(id); 
        lex.Val(appId); 
        
        TLex8 lex1(sourceType); 
        lex1.Val( addressType ); 
        
        TLex8 lex2(addressCount); 
        lex2.Val(addressTypeCount); 
        
        iNotifyChange.GetChangeNotificationL( appId, addressType,addressTypeCount ); 
    } 
}
예제 #2
0
void AsciiUnicode<R,S,L,B,T>::Test1()
// R == TReal32 or TReal64
// S == TText, TText8 or TText16
// L == TLex, TLex8 or TLex16
// B == TBuf, TBuf8 or TBuf16
// T == TPtr, TPtr8 or TPtr16
	{

	L lex1(_TL("123.456"));
	R real; // TReal32 or TReal64 
	test(lex1.Val(real)==KErrNone);							 
	test(Abs(real-123.456)<1E-5);
	test(lex1.TokenLength()==7);
	test((lex1.Remainder()).Compare(T(_TL(""),0,0))==0);
	test(lex1.Val(real)==KErrGeneral);

	L lex2(_TL("123.456abc"));
	test(lex2.Val(real)==KErrNone);
	test(Abs(real-123.456)<1E-5);
	test(lex2.TokenLength()==7);
	test((lex2.Remainder()).Compare(T(_TL("abc"),3,3))==0);
	test(lex2.Val(real)==KErrGeneral);

	L lex3;
	real=(R)0.5;
	test(lex3.Val(real)==KErrGeneral);
	test(real==((R)0.5));
	test(lex3.TokenLength()==0);

	L lex4(_TL("abc123.45"));
	real=(R)0.5;
	test(lex4.Val(real)==KErrGeneral);
	test(real==((R)0.5));

	L Lex5(_TL("1.2e37"));
	real=(R)0.5;
	test(Lex5.Val(real)==KErrNone);
	
	L Lex6(_TL("1.2e"));
	real=(R)0.5;
	test(Lex6.Val(real)==KErrNone);

	TRealFormat format(20,3); // first param width, 2nd decimals
	real=(R)12345.6789;
	B buf1;
	test(buf1.Num(real,format)==10);
	test(buf1.Compare(T(_TL("12,345.679"),10,10))==0);

	B buf2(_TL("abc"));
	test(buf2.AppendNum(real,format)==13);
	test(buf2.Compare(T(_TL("abc12,345.679"),13,13))==0); 

	B buf3;
	test(buf3.AppendNum(real,format)==10);
	test(buf3.Compare(T(_TL("12,345.679"),10,10))==0);
	}
예제 #3
0
GLDEF_C TInt E32Main()
	{
	test.Title();
	TBuf<256> cmd;
	TFullName fn;
	User::CommandLine(cmd);
	TLex lex(cmd);
	TPtrC threadSpec(lex.NextToken());
	TFindThread ft(threadSpec);
	TExitType exitType=EExitKill;
	TInt exitCode=0;
	if (!lex.Eos())
		{
		TPtrC xtSpec(lex.NextToken());
		TPtrC xc(xtSpec);
		TChar xt0=xtSpec[0];
		if (xt0.IsAlpha())
			{
			xt0.LowerCase();
			if (xt0==TChar('t'))
				exitType=EExitTerminate;
			else if (xt0==TChar('p'))
				exitType=EExitPanic;
			new(&xc) TPtrC(lex.NextToken());
			}
		if (xc.Length())
			{
			TLex lex2(xc);
			lex2.Val(exitCode);
			}
		}
	while (ft.Next(fn)==KErrNone)
		{
		test.Printf(_L("Killing %S\n"),&fn);
		RThread t;
		TInt r=t.Open(ft);
		if (r==KErrNone)
			{
			// FIXME: SHOULD REMOVE CRITICALNESS - WOULD NEED DEVICE DRIVER
			switch (exitType)
				{
				case EExitKill:	t.Kill(exitCode); break;
				case EExitTerminate: t.Terminate(exitCode); break;
				case EExitPanic: t.Panic(KPanicCat,exitCode); break;
				default: break;
				}
			t.Close();
			}
		}
	return 0;
	}
예제 #4
0
void CTestAppConsole::SetUpRtpStack()
    {
    TDes* line = new TBuf<80>;
   
    iConsole->ClearScreen();
    iConsole->Printf( _L("\nEnter the IAP ID: ") );
    GetStringFromConsole(*line);

    TLex lex(*line);
    lex.Val(iIapid,EDecimal);

    // Get Remote Port number
	iConsole->ClearScreen();
    iConsole->Printf(_L("\nMccEnter the Local port number "));

	GetStringFromConsole(*line);

    //Use INPUT
    TLex lex2(*line);
    lex2.Val(iPort,EDecimal);

    //Use INPUT
    iConsole->ClearScreen();
		
	TBuf<128> theInput;

	iConsole->Printf(_L("\nEnter the Remote IP address "));	
	GetStringFromConsole(*line);

	theInput.Copy( *line );
	iRemoteAddr.SetFamily(KAfInet);
	iRemoteAddr.Input(theInput);
    iRemoteAddr.SetPort(iPort);
    
    delete line;
    };
예제 #5
0
void CPolicyTest::ProcessResultsL(TRequestStatus& aStatus)
	{
	_LIT8(KSummaryLine, " tests failed out of ");
	_LIT8(KNewLine, "\r\n");

	TInt failCount = KErrNotFound, runCount;
	
	// Read entire log file into memory to process
	RFile file;
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TBuf<128> logTmpFile (sysDrive.Name());
	logTmpFile.Append(KLogTmpPath);
	User::LeaveIfError(file.Open(iFs, logTmpFile, EFileShareReadersOnly | EFileRead));
	CleanupClosePushL(file);

	TInt size;
	User::LeaveIfError(file.Size(size));
	HBufC8* buffer = HBufC8::NewLC(size);
	TPtr8 ptr = buffer->Des();

	User::LeaveIfError(file.Read(ptr));

	iOut.writeString(_L("Child test output:\n"));

	TInt pos = 0;
	while (pos < size)
		{
		TInt nextNewline = buffer->Mid(pos).Find(KNewLine);

		// Split buffer into lines
		TPtrC8 line;
		if (nextNewline == KErrNotFound)
			{
			line.Set(buffer->Mid(pos));
			}
		else
			{
			line.Set(buffer->Mid(pos, nextNewline + KNewLine().Length()));
			}
		pos += line.Length();

		// Search for summary line
		TInt pos2 = line.Find(KSummaryLine);
		if (pos2 != KErrNotFound)
			{
			// Parse the summary line to work out if the test passed
			TLex8 lex1(line.Left(pos2));
			TInt err1 = lex1.Val(failCount);
			TLex8 lex2(line.Mid(pos2 + KSummaryLine().Length()));
			TInt err2 = lex2.Val(runCount);

			if (err1 != KErrNone || err2 != KErrNone)
				{
				iOut.writeString(_L("Failed to parse summary line\n"));
				User::LeaveIfError(err1);
				User::LeaveIfError(err2);
				}
			}
		else
			{
			// Don't print the summary line as this will confuse whatever parsed
			// the main log
			iOut.writeString(_L("> "));
			iOut.writeString(line);
			}		
		}
	
	if (failCount == KErrNotFound)
		{
		iOut.writeString(_L("Couldn't find summary line in test output\n"));
		User::Leave(KErrNotFound);
		}
	iFailCount += failCount;

	// Print results in different format
	iOut.write(_L("Tests run: %d\n"), runCount);
	iOut.write(_L("Tests failed: %d\n"), failCount);
	iOut.writeNewLine();
	
	CleanupStack::PopAndDestroy(2, &file);

	TRequestStatus* status = &aStatus;
	User::RequestComplete(status, KErrNone);
	}