示例#1
0
LOCAL_C void test8()
//
// Some tests for calc to check that a number entered is printed to same significance when
// returned
// do dtor and rtod test
//
	{

	TLex l;
	TBuf<0x100> buf;
	TInt ret;
	TReal64 num;

	for (TInt jj=0;jj<TInt(size_calctest/sizeof(CALC_TEST));jj++)
		{
		// string to real
		const CALC_TEST tst=calctest[jj];
		l=tst.iLex;
		test(l.Val(num)==KErrNone);
		
		// real to string
 		ret=buf.Num(num,tst.iFormat);
		if (ret!=KErrGeneral)
			{
			buf.ZeroTerminate();
			test(buf.Compare(TPtrC(tst.iRes))==0);
			}
		test(ret>=0);    
		}
	}
示例#2
0
LOCAL_C void test5()
//
// Test string to real conversion with selected numbers
// added by AnnW, December 1996
//
	{
	
	TLex l;
	TReal64 r64;
	TInt jj;
	
	for (jj=0; jj<TInt(size_testd2/sizeof(DtoR_TEST64)); jj++)
		{
		const DtoR_TEST64* tst64=&testd2[jj];
		l=tst64->iLex;
		test(l.Val(r64)==KErrNone);
		test(tst64->iRes==r64);
		}
	
	TReal32 r32;

	for (jj=0; jj<TInt(size_testd32/sizeof(DtoR_TEST32)); jj++)
		{
		const DtoR_TEST32* tst32=&testd32[jj];
		l=tst32->iLex;
		test(l.Val(r32)==KErrNone);
		test(tst32->iRes==r32);
		}
	}	
TPtrC NextWord(TLex& aLex)
	{
	aLex.SkipSpaceAndMark();
	aLex.SkipCharacters();
	TPtrC word(aLex.MarkedToken());
	return word;
	}
/**
 * Reads the value present from the test steps ini file within the mentioned section name and key name
 * Copies the value to the TInt reference passed in. The value can optionally be prefixed with 0x
 * @param aSectName - Section within the test steps ini file
 * @param aKeyName - Name of a key within a section
 * @return aResult - The integer value of the Hex input
 * @return TBool - ETrue for found, EFalse for not found 
 */	
TBool CDataWrapperBase::GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult)
	{
	TPtrC	result;
	TBool	ret=EFalse;
	TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result));
	if ( err != KErrNone )
		{
		ret=EFalse;
		}
	if ( ret )
		{
		TLex	lex;
		if( result.FindC(KPrefixHex)==KErrNone )
			{
			lex=result.Mid(KPrefixHex().Length());
			}
		else
			{
			lex=result;
			}
		ret=(lex.Val((TUint &)aResult, EHex)==KErrNone);
		}

	return ret;
	}
示例#5
0
void CTap2MenuAppUi::ReadExceptions()
	{
	TInt err=KErrNone;
	iExceptions.Reset();
	if (BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),KExceptionsPath)) //!!!!!!!!!!!!!!!!!!!!!!!!!!!
		{
		TBuf<255> val;
		TLex conv;
		TUint32 IntVal;
		RFile filesave;
		TBuf<255> t;
		TFileText ft;
		filesave.Open(CEikonEnv::Static()->FsSession(), KExceptionsPath, EFileRead);
		ft.Set(filesave);
		while (ft.Read(val)==KErrNone)
			{
			conv.Assign(val);
			conv.Val(IntVal,EHex);
			iExceptions.AppendL(TUid::Uid(IntVal));
			}
		filesave.Close();
		}
	else
		{
		TParse parse;
		CEikonEnv::Static()->FsSession().Parse(KExceptionsPath,parse);
		if (!BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(),parse.DriveAndPath()))
			{
			CEikonEnv::Static()->FsSession().MkDirAll(parse.DriveAndPath());
			}
		}
	}
// -----------------------------------------------------------------------------
// CLandmarksEditDialog::FetchFloatL
// 
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CLandmarksEditDialog::FetchFloatL(
    TRealX& aFloat, 
    TInt aEditorResourceId, 
    TInt aErrorResourceId)
    {
    const TChar KDecimalPoint = '.';
    TBuf<KPosLmMaxTextFieldLength> textFieldValue;
    TLex fieldLex;
    TInt result(KErrNone);
    CEikEdwin* editor = static_cast <CEikEdwin*> (Control(aEditorResourceId));

    editor->GetText(textFieldValue);
    if (textFieldValue == KNullDesC)
        {
        // User has indicated that he/she wants this value to be undefined.
        aFloat.SetNaN();
        }
    else 
        {
        // Try to extract value
        fieldLex = textFieldValue;
        TReal floatValue(0);
        result = fieldLex.Val(floatValue, KDecimalPoint);
        if (result != KErrNone)
            {
            NotifyErrorToUserL(aErrorResourceId);
            }

        // Update output parameter
        User::LeaveIfError(aFloat.Set(floatValue));
        }
    }
void GetEnumValuesL(TLex& aLex, RBuf& aValues, RBuf& aDescriptions)
	{
	aValues.CreateL(0x100);
	aDescriptions.CreateL(0x100);

	while (!aLex.Eos())
		{
		TLexMark mark;
		aLex.Mark(mark);
		TPtrC command(NextCommand(aLex));
		if (command == KCmndEnumValue)
			{
			TPtrC value(NextWord(aLex));
			TPtrC description(TextToNextCommand(aLex));
			if (value.Length() == 0)
				{
				User::Leave(KErrArgument);
				}
			AppendL(aValues, value, EFalse);
			if (description.Length() > 0)
				{
				AppendL(aDescriptions, description, ETrue);
				}
			}
		else
			{
			aLex.UnGetToMark(mark);
			break;
			}
		}
	}
示例#8
0
void CSettings::ConstructL()
{
    RFs fs;
    RFile file;
    TFileText text;
    TLex lex;
    TBuf<256> buf;
    User::LeaveIfError(fs.Connect());
    if(file.Open(fs,_L("C:\\System\\Apps\\vcall\\times"),EFileRead) != KErrNone)
    {
        User::Panic(_L("Config file not open"),KErrNotFound);
    }
    text.Set(file);
    while(text.Read(buf) == KErrNone)
    {
        lex.Assign(buf);
        TInt val;
        lex.Val(val);//TODO: error handling
        iTimes.Append(val);
    }
    file.Close();
    //iTimes.SortSigned();//TODO: fix sort
    iTimer = CVTimer::NewL();
    iTimer->setTimes(iTimes);
}
TBool CEmTubeVideoUploadDialog::OkToExitL(TInt aButtonId)
	{
	if (aButtonId == EAknSoftkeyDone)
		{
		SaveFormDataL();

	    if( iQueueEntry->Title().Length() == 0 )
	    	{
			HBufC* message = StringLoader::LoadLC( R_DIALOG_TITLE_AND_DESCRIPTION_NEEDED_TXT );
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD( *message );                    
			CleanupStack::PopAndDestroy( message );
    	    return EFalse;    	    
		    }
		
	    if( iQueueEntry->Description().Length() == 0 )
	    	{
			HBufC* message = StringLoader::LoadLC( R_DIALOG_TITLE_AND_DESCRIPTION_NEEDED_TXT );
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD( *message );                    
			CleanupStack::PopAndDestroy( message );
    	    return EFalse;    	    
		    }

		TBool res = ETrue;

	    if( iQueueEntry->Tags().Length() == 0 )
	        res = EFalse;
    
	    TLex lex = TLex( iQueueEntry->Tags() );            
	    TPtrC16 ptr( lex.NextToken() );
	    TInt tokenCount = 0;
    
	    while( ptr.Length() && (tokenCount < 2) )
    	    {
        	tokenCount++;
	        ptr.Set( lex.NextToken() );
    	    }

		if( tokenCount < 2 )
			res = EFalse;
		
		if( !res )
			{
			HBufC* message = StringLoader::LoadLC( R_DIALOG_TWO_TAGS_NEEDED_TXT );
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD( *message );                    
			CleanupStack::PopAndDestroy( message );
    	    return EFalse;    	    
			}

  		return ETrue;
		}
	else
		{
		return CAknForm::OkToExitL(aButtonId);
		}
	}
TInt SkipToNextCommand(TLex& aLex)
	{
	if ((aLex.Offset() == 0) && (aLex.Remainder().Find(KPartialCommandStart) == 0))
		{
		return KErrNone;
		}

	return SkipTo(aLex, KCommandStart);
	}
示例#11
0
TBool TfrLex::EatF( TLex& aLex, const TDesC& aTerm )
{
aLex.SkipSpace();
TLexMark unget;
aLex.Mark(unget);
if ( ValF(aLex,aTerm) == KErrNone ) return ETrue;
aLex.UnGetToMark(unget);
return EFalse;
} 
示例#12
0
// ----------------------------------------------------
// CheckIPv4Address()
// IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
// ----------------------------------------------------
//
LOCAL_C TBool CheckIPv4Address( TLex& aLex )
    {
    return CheckIPv4AddressPart( aLex ) 
        && aLex.Get() == '.'
        && CheckIPv4AddressPart( aLex ) 
        && aLex.Get() == '.'
        && CheckIPv4AddressPart( aLex ) 
        && aLex.Get() == '.'
        && CheckIPv4AddressPart( aLex ) && aLex.Get() == '\0' ;
    }
TInt SkipToEnd(TLex& aLex, const TDesC& aDes)
	{
	TInt ret = aLex.Remainder().Find(aDes);
	if (ret >= 0)
		{
		aLex.Inc(ret + aDes.Length());
		return KErrNone;
		}
	return KErrNotFound;
	}
TPtrC LineRemainder(TLex& aLex)
	{
	aLex.Mark();
	if (SkipTo(aLex, KNewLine) == KErrNone)
		{
		return aLex.MarkedToken();
		}
	else
		{
		return aLex.Remainder();
		}
	}
/**
 * Used for extracting the latter components of a TVersion from a string of the
 * form 1.2.3
 * Before reading checks that the end of the string has not yet been reached,
 * then steps past the first character (assumed to be '.' and attempts to read
 * an integer from the following character(s).
 * Any error in version length or missing components (e.g. if the version is "1")
 * reports 0 for thet missing part(s).
 */
TInt CTe_LbsIniFileReader::GetNextVersionPart(TLex& aLex) const
{
    TInt number = 0;
    if(!aLex.Eos())
    {
        aLex.Inc();
        if(!aLex.Eos())
        {
            aLex.Val(number);
        }
    }
    return(number);
}
TInt CTerminalControlServer::GetIntValueL( TInt aSCPCommandEnum )
{
    TBuf<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> valueStr;
    TInt value;
    TLex lex;

    User::LeaveIfError( iSCPClient.GetParamValue( aSCPCommandEnum, valueStr ) );

    lex.Assign( valueStr );
    User::LeaveIfError( lex.Val( value ) );

    return value;
}
示例#17
0
void CScriptFile::FoundNewItemL(const TDesC& aText, TLex& arInput, TInt& arCurrentItemStart, CScriptSection& aSection, CScriptSectionItem*& arCurrentItem)
	{
	TPtrC token = arInput.MarkedToken();

	ParseAndSetItemValueL(aText, arInput, arCurrentItemStart, arCurrentItem);

	arInput.SkipSpaceAndMark();
	arCurrentItemStart = arInput.Offset();

	TPtrC itemEnd(KScriptItemEnd);
	const TInt length = token.Length() - itemEnd.Length();
	arCurrentItem = &aSection.ReplaceItemL(token.Left(length), KNullDesC);
	}
示例#18
0
// ----------------------------------------------------
// CheckIPv6Hex4()
// hex4    = 1*4HEXDIG
// ----------------------------------------------------
//
LOCAL_C TBool CheckIPv6Hex4( TLex& aLex )
    {
    _LIT( KHexDigits, "0123456789ABCDEF" );

    TPtrC hexDigits( KHexDigits );
    TBool foundOne( EFalse );
    while( hexDigits.LocateF( aLex.Peek() ) != KErrNotFound )
        {
        foundOne = ETrue;
        aLex.Inc();
        }

    return foundOne;
    }
示例#19
0
// ----------------------------------------------------
// DoOrReverse()
// Calls aFunc. If it fails, the lexer is returned to 
// the state before calling DoOrReverse().
// ----------------------------------------------------
//
LOCAL_C TBool DoOrReverse( TParseFunc aFunc, TLex& aLex )
    {
    TLexMark mark;
    aLex.Mark( mark );
    if( (*aFunc)(aLex) )
        {
        return ETrue;
        }
    else
        {
        aLex.UnGetToMark( mark );
        return EFalse;
        }
    }
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetLockMaxTimeoutL
// ----------------------------------------------------------------------------------------
TInt CTerminalControlServer::GetLockMaxTimeoutL( )
{
    RDEBUG("CTerminalControlServer::GetLockMaxTimeoutL");

    TBuf<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> valueStr;
    TInt     value;
    TLex     lex;

    User::LeaveIfError( iSCPClient.GetParamValue(ESCPMaxAutolockPeriod/*RTerminalControl3rdPartySession::EMaxTimeout*/, valueStr) );

    lex.Assign(valueStr);
    User::LeaveIfError(lex.Val( value ));

    return value;
}
示例#21
0
bool CMobileOfficeAppUi::Register()
{
    TBuf <64> buff;
    HBufC * propmtText = CEikonEnv::Static()->AllocReadResourceL( R_STR_INPUT_ACTIVATION_CODE );

    CAknTextQueryDialog* dlg = new(ELeave) CAknTextQueryDialog( buff, CAknQueryDialog::ENoTone );
    if (dlg->ExecuteLD(R_GNFIELDQUERY_BIGNUMBER_QUERY, *propmtText ))
					
    {
         int user_number = 0;
         TLex lx;
         lx.Assign( buff );
         lx.Val( user_number );

        licMan.SetUnlockCode( user_number );

         // Dummy code
         TBuf<64> aImei;
    }

    if( licMan.Is_dm_1() )
    {
		HBufC* errorText = StringLoader::LoadLC( R_MOBILESEARCH_ERROR );

			HBufC* invalidCodeText = StringLoader::LoadLC( R_MOBILESEARCH_INVALIDCODE );

				CEikonEnv::Static()->InfoWinL( *errorText, *invalidCodeText );
			
			CleanupStack::PopAndDestroy( invalidCodeText );

		CleanupStack::PopAndDestroy( errorText );
    }
	else 
	{
		HBufC* correctCodeText = StringLoader::LoadLC( R_MOBILESEARCH_CORRECTCODE );

			HBufC* thanksText = StringLoader::LoadLC( R_MOBILESEARCH_THANKS );
	
				CEikonEnv::Static()->InfoWinL( *correctCodeText, *thanksText );

			CleanupStack::PopAndDestroy( thanksText );	

		CleanupStack::PopAndDestroy( correctCodeText );
	}

    delete propmtText;
	return true;
}
TPtrC NextCommand(TLex& aLex)
	{
	TPtrC command;
	if (SkipToNextCommand(aLex) == KErrNone)
		{
		SkipToEnd(aLex, KPartialCommandStart);
		aLex.Mark();
		aLex.SkipCharacters();
		command.Set(aLex.MarkedToken());
		}
	else
		{
		aLex.Inc(aLex.Remainder().Length());
		}
	return command;
	}
示例#23
0
// ----------------------------------------------------
// CheckIPv6HexPart()
// hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
// ----------------------------------------------------
//
LOCAL_C TBool CheckIPv6HexPart( TLex& aLex )
    {
    TBool hexSeq( DoOrReverse( CheckIPv6HexSeq, aLex ) );
    TBool doubleSemiColon( EFalse );
    if( aLex.Peek() == ':' )
        {
        aLex.Inc();
        if( aLex.Get() == ':' )
            {
            doubleSemiColon = ETrue;
            DoOrReverse( CheckIPv6HexSeq, aLex );
            }
        }

    return hexSeq || doubleSemiColon;
    }
示例#24
0
//fix for DEF017686: EMail notification parser leaves when field data is empty  
void CEmailNotificationParser::LeaveIfEmptyFieldsL(const TDesC& aFieldName,
												   const TLex& aTokenLex)
	{
/*
 		The following  checks for an empty field value.
 		The only fields allowed to be empty are the subject  and extension fields.
 		Hence, the check is done when aFieldName is not  a subject field and an extension field.
 		However, it is not possible to explicitly check for an extension field as we don't 
 		know which strings to compare. Therefore, a comparison with all the known field names
 		must be performed instead. The risk is fairly small as the change is localised and it can 
 		be easily tested.
*/

	if ((aFieldName.CompareF(KHeaderFrom)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderSize)==KErrNone) ||
		(aFieldName.CompareF(KHeaderUidImap)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderUidPop)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderServerId)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderAttachments)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderTo)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderCc)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderDate)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderFolder)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderSender)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderReplyTo)==KErrNone) ||
 		(aFieldName.CompareF(KHeaderUidValidity)==KErrNone) //not sure if this actually exists*/
	   )
 		
 		if (aTokenLex.Eos())
 			User::Leave(KBspSmartMessageInvalidToken);	
	}
示例#25
0
TInt  TfrLex::ValF( TLex& aLex, const TDesC& aTerm )
{
TLex term( aTerm );
TLexMark mark;

aLex.Mark( mark );
while ( !term.Eos() )
	{
	if ( aLex.Eos() || User::Fold(term.Get()) != User::Fold(aLex.Get()) )
		{
		aLex.UnGetToMark( mark );
		return KErrNotFound;
		}
	}
return KErrNone;
}
示例#26
0
// This function is used to update month and day in aBufLocalTime
// to actual month and day to be passed to TTime() constructor.
// Remember using TTime::FormatL() in thelpers.cpp 
// has added extra month and a day to aBufLocalTime.
// aBufLocalTime is in format YYMMDD:HHMMSS.MMMMMM
// see TTime::Set() for aBufLocalTime expected format details.
TInt UpdateToActualMonthAndDay(TDes& aBufUTCTime)
	{	
	TInt mVal 	= 0;
	TInt dVal 	= 0;
	
	TBuf <4> tempBuf;
	_LIT(KFormat, "%02d");
	
	//Get the position of colon separator	
	TInt colon 	= aBufUTCTime.Locate(':');
		
	// Get Month & Day if Present	
	switch(colon)
		{
		case 0: break;
		case 8:
			{
			TLex month 	= aBufUTCTime.Mid(4,2);
			TLex day 	= aBufUTCTime.Mid(6,2);
			month.Val(mVal);
			day.Val(dVal);			
			}
			break;
		default:
			{
			// If the colon is at the wrong position
			return (KErrArgument);
			}
				
		}
		
		// Deduct extra month and a day and update aBufLocalTime
		if(mVal > 0 && dVal > 0)
			{
			mVal-=1;
			dVal-=1;
				
			tempBuf.Format(KFormat, mVal);
			aBufUTCTime.Replace(4,2, tempBuf);
				
			tempBuf.Format(KFormat, dVal);
			aBufUTCTime.Replace(6,2, tempBuf);				
			}
			
		return(KErrNone);		
	}
TInt CSwisExpressionEnvironment::ParseVersionComponent(const TDesC& aComponentString)
	{
	/** 
	 *  Convert the string into a TInt representation and check that
	 *  the string is a valid decimal value
	 */
	TLex componentLex = aComponentString;
	TInt componentValue = 0;
	
	if(componentLex.Val(componentValue) == KErrNone && componentLex.Eos())
		{
		return componentValue;
		}
	
	// Return an error if the TInt value is not parsed correctly
	return KErrNotFound;
	}
// -----------------------------------------------------------------------------
// CStartupAdaptationStubModel::ReadDurationL
//
// -----------------------------------------------------------------------------
//
TInt CStartupAdaptationStubModel::ReadDurationL( TLex& aLexer )
    {
    RDEBUG( _L( "CStartupAdaptationStubModel::ReadDurationL." ) );

    TInt val = KDefaultDuration;
    if ( aLexer.Peek() == '[' ) // Duration value is written to file
        {
        aLexer.Inc();
        User::LeaveIfError( aLexer.Val( val ) );
        if ( aLexer.Get() != ']' )
            {
            User::Leave( KErrCorrupt );
            }
        }

    RDEBUG_1( _L( "CStartupAdaptationStubModel::ReadDurationL finished with %d." ), val );
    return val;
    }
// -----------------------------------------------------------------------------
// RsearchServerSession::Connect()
// Connects to the server and create a session.
// -----------------------------------------------------------------------------
EXPORT_C TInt RSearchServerSession::Connect()
	{
    //read the name and Uid of the search server
    TInt err = KErrNotReady;
    // get the watchdog repro 
    //TRAP_IGNORE is used to avoid the code scanner error
    CRepository* wdrepo = NULL;
    TRAP_IGNORE(wdrepo = CRepository::NewL( KWDrepoUidMenu ));
    if ( wdrepo )
        {
        HBufC* servername = NULL;
        TUid serveruid = {0};
        TBuf<KCenrepUidLength> temp;
        TInt64 value;
        TLex uidvalue;
        //read the searchserver UId
        if ( KErrNone == wdrepo->Get( KSearchServerUIDKey, temp ))
            {
            uidvalue.Assign(temp);
            if (KErrNone == uidvalue.Val( value,EHex ))
                serveruid.iUid = value;
            }
        //read the search server name
        if ( KErrNone == wdrepo->Get( KSearchServerNAMEKey, temp ))
            {
            //TRAP_IGNORE is used to avoid the code scanner error
            TRAP_IGNORE(servername = HBufC::NewL( temp.Length() ));
            TPtr ssname = servername->Des(); 
            ssname.Copy( temp );
            }
        // make sure the server is started before creating connection
        if ( servername )
           err = StartServer( *servername , serveruid );
    
        if ( KErrNone == err )
            {
            err = CreateSession(*servername, Version(), KDefaultMessageSlots);
            }
        delete servername;
        }
    delete wdrepo;
	return err;
	}
示例#30
0
LOCAL_C void Work()
	{
	    __LOGSTR("Work");
	    RProcess proc;
	    TInt val;
	    TBuf<5> buf2;
	    TLex lex;
	    buf2.Copy(proc.FullName().Right(1));
	    lex.Assign(buf2);
	    lex.Val(val);

	    if(val > 1)
		{
		}else{
            CPhoneReceiver* res = CPhoneReceiver::NewLC();
            CActiveScheduler::Start();
            _CPOPD(res);
		}
    }