コード例 #1
0
// -----------------------------------------------------------------------------
// CSIPSettIntegerSetPage::OkToExitL
// Called to validate input before closing the page
// -----------------------------------------------------------------------------
//
TBool CSIPSettIntegerSetPage::OkToExitL( TBool aAccept )
    {
    __GSLOGSTRING("CSIPSettIntegerSetPage::OkToExitL " )
    TBool ret( ETrue );
    TLex16 lex;
    TInt value;
    TBuf<KMaxServerPortLength> intText; 
    if ( !aAccept )
        {
        // User pressed cancel - return back to original text and go away
        RestoreOriginalSettingL();
        return ETrue;
        }
       TextControl()->GetText( intText );
       lex.Assign( intText.Ptr() );
       lex.Val( value );
       if( value >= 0 && value <= 65535 || intText == NULLString )
    	   {
           if( intText == NULLString )
    	       {
               TextControl()->SetTextL(&ZeroString);
    	       }
           UpdateSettingL();  
            
           // Everything OK, save setting and exit page
           AcceptSettingL();	   
    	   ret = ETrue;
    	   }
       else
    	   {
    	   ret = EFalse;
    	   }
        
        return ret;    
    }
コード例 #2
0
//*******************************************************************************
// Method      : CTestAppConsole::QueryIPAddress()
// Purpose     : 
// Parameters  : 
// Return Value: 
//*******************************************************************************
void CTestAppConsole::QueryIPAddress()
    {    
    TBuf16<80> line;
    
    // Query IP address and parse it
    TUint32 address;
    RArray<TUint32> values;
    TInt inputErr( 0 );
    
    iConsole->Printf( _L("\nINPUT IP (use dot as a separator): ") );
    iConsole->Printf( _L("\nPress enter if IP not needed in tests\n\n") );
    GetStringFromConsole( line );
    	
    if ( line.Length() != 0 )
        {
        TInt dotIndex( 0 );
        TBool dotExist = ETrue;

        while ( dotExist )
            {
            dotIndex = line.Locate( '.' );

            // True if last attribute value
            if( KErrNotFound == dotIndex  )
                {
                dotExist = EFalse;
                dotIndex = line.Length();
                }

            TUint8 number;
            TLex16 lex = line.Mid( 0, dotIndex );

            inputErr = lex.Val( number, EDecimal );
                
            if ( !inputErr )
                {
                values.AppendL( number );
                }
                
            if( dotExist )
                {
                line.Delete( 0, dotIndex + 1 );
                }
            }
            
        if ( !inputErr && values.Count() == 4 )
            {
            address = INET_ADDR( values[0], values[1], values[2], values[3] );
            iNetsettings.iRemoteAddress.SetAddress( address );    
            }
	    }
    }
コード例 #3
0
/**
Initialize the counter with the numeric equivalent of the descriptor contents
This function is here to demonstrate reading from the client address space.
Note that in this example, the client and the server are part of the same process,
*/
void CCountServSession::SetFromStringL(const RMessage2& aMessage)
	{
	
	  // length of passed descriptor (1st parameter passed from client)
	TInt deslen = aMessage.GetDesLength(0);
	
	  // Passed data will be saved in this descriptor.
    RBuf buffer;
      
      // Max length set to the value of "deslen", but current length is zero
    buffer.CreateL(deslen);
      
      // Do the right cleanup if anything subsequently goes wrong
    buffer.CleanupClosePushL();
    
      // Copy the client's descriptor data into our buffer.
    aMessage.ReadL(0,buffer,0);
    
      // Now do a validation to make sure that the string only has digits
    if (buffer.Length() == 0)
        {
    	User::Leave(ENonNumericString);
        }
    
    TLex16 lexer;
    
    lexer.Assign(buffer);
    while (!lexer.Eos())
        {
        TChar thechar;
        
        thechar = lexer.Peek();
        if (!thechar.IsDigit())
            {
        	User::Leave(ENonNumericString);
            }
        lexer.Inc();
        }
       
      // Convert to a simple TInt value. 
    lexer.Assign(buffer);           
    if (lexer.Val(iCount))
        {
    	User::Leave(ENonNumericString);
        }
    	
	  // Clean up the memory acquired by the RBuf variable "buffer"
	CleanupStack::PopAndDestroy();
	}