// ----------------------------------------------------------------------------- // CWPPushMessage::GetFieldName // ----------------------------------------------------------------------------- // TUint CWPPushMessage::GetFieldName( TLex8& aPointer ) const { // Field name can be a short integer or text. TUint result( 0 ); if( !aPointer.Eos() ) { TUint first( aPointer.Peek() ); if( first > KShortIntegerMask ) { result = GetShortInteger( aPointer ); } else { // Only well-known fields are read GetTokenText( aPointer ); } } return result; }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetIntegerValue // ----------------------------------------------------------------------------- // TInt64 CWPPushMessage::GetIntegerValue( TLex8& aPointer ) const { // Integer value can be a short integer or a long integer. // Short integer is always >KShortIntegerMask. TInt64 result( 0 ); if( !aPointer.Eos() ) { TUint first( aPointer.Peek() ); if( first > KShortIntegerMask ) { result = GetShortInteger( aPointer ); } else { result = GetLongInteger( aPointer ); } } return result; }
OMX_ERRORTYPE CBellagioOpenMaxSymbianLoader::GetRolesOfComponent(OMX_STRING compName, OMX_U32 *pNumRoles, OMX_U8 **roles) { TInt index = 0; index = GetInfoIndex(compName); if (index < 0) { return OMX_ErrorComponentNotFound; } TLex8 lexer = TLex8((componentInfos[index])->OpaqueData()); lexer.Val((TUint32 &)(*pNumRoles), EDecimal); if((*pNumRoles) == 0) { return OMX_ErrorNone; } // check if client is asking only for the number of roles if (roles == NULL) { return OMX_ErrorNone; } // TODO We copy only one role here and there might be several of those TBuf8<257> role; TBufC8<1> endOfString((TText8*)"\0"); role.Append((componentInfos[index])->DataType()); role.Append(endOfString); strcpy((char*)roles[0], (char*)role.Ptr()); return OMX_ErrorNone; }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetConstrainedEncoding // ----------------------------------------------------------------------------- // TUint CWPPushMessage::GetConstrainedEncoding( TLex8& aPointer ) const { // Constrained encoding can be extension media or short integer TUint result( 0 ); if( !aPointer.Eos() ) { TUint first( aPointer.Peek() ); if( first > KShortIntegerMask ) { result = GetShortInteger( aPointer ); } else { // Just skip the text version GetTokenText( aPointer ); } } return result; }
// ----------------------------------------------------------------------------- // NATFWUNSAFUtils::SkipAndCheckContChars // ----------------------------------------------------------------------------- // TBool NATFWUNSAFUtils::SkipAndCheckContChars(TLex8& aLex, TInt aCount) { TInt counter = 0; TChar chr = 0; while (aCount > counter++) { chr = aLex.Get(); if (IsUTF8ContChar(chr)) { return EFalse; } } return ETrue; }
TBool CTestConfig::IsNewComment(const TDesC8& aSource, const TLex8& aLex) const { TBool ret(EFalse); const TPtrC8 token(aLex.MarkedToken()); const TPtrC8 commentStart(KScriptCommentStart); const TInt commentStartLen(commentStart.Length()); const TInt tokenLen(token.Length()); if (commentStartLen <= tokenLen && token.Left(commentStartLen).Compare(commentStart) == 0) { ret = IsAtStartOfNewLine(aSource, aLex, ETrue); } return ret; }
TBool CLinePaginatorTest::ReadTestFile(TPageLine& aLine) { TLex8 lex; TBuf8<128> textBuffer; TBuf8<128> numBuffer; TInt startNum; iTestFile.Read(iFilePos,textBuffer,128); if (textBuffer.Locate('X') != KErrNotFound && textBuffer.Locate('X') < textBuffer.Locate('\r')) { startNum=textBuffer.Locate('\n')+1; textBuffer.Delete(0,startNum); iFilePos+=startNum; lex=textBuffer; lex.Val(aLine.iDocPos); TBuf<254> buf; buf.AppendFormat(_L("%d\tX\n"), aLine.iDocPos); TESTPRINT(buf); return EFalse; } startNum=textBuffer.Locate('\n')+1; textBuffer.Delete(0,startNum); iFilePos+=startNum; lex=textBuffer; lex.Val(aLine.iDocPos); startNum=textBuffer.Locate('\t')+1; textBuffer.Delete(0,startNum); iFilePos+=startNum; lex=textBuffer; lex.Val(aLine.iLineHeight); startNum=textBuffer.Locate('\t')+1; textBuffer.Delete(0,startNum); iFilePos+=startNum; lex=textBuffer; lex.Val(aLine.iKeepWithNext); startNum=textBuffer.Locate('\t')+1; textBuffer.Delete(0,startNum); iFilePos+=startNum; lex=textBuffer; lex.Val(aLine.iStartNewPage); if (textBuffer.Locate('\t')<textBuffer.Locate('\r') && textBuffer.Locate('B')!=KErrNotFound && textBuffer.Locate('B')<textBuffer.Locate('\r')) iTestPageBreak=ETrue; else iTestPageBreak=EFalse; iFilePos+=textBuffer.Locate('\r')+1; return ETrue; }
TInt CTestConfig::GetNextElement(TLex8& aInput, TChar aDelimiter, TPtrC8& aOutput) { if (aInput.Eos()) return KErrNotFound; //Get to the start of the descriptor while (!aInput.Eos() && aInput.Peek() != aDelimiter) aInput.Inc(); aOutput.Set(aInput.MarkedToken()); if (!aInput.Eos()) aInput.SkipAndMark(1); return KErrNone; }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetTextString // ----------------------------------------------------------------------------- // TPtrC8 CWPPushMessage::GetTextString( TLex8& aPointer ) const { // Text-string can be quoted. if( aPointer.Peek() == KQuotedTextStringStart ) { aPointer.Inc(); } aPointer.Mark(); while( aPointer.Get() != EKeyNull ) { // Nothing } // We don't want to have NULL in the resulting descriptor, so // back that out. aPointer.UnGet(); TPtrC8 result( aPointer.MarkedToken() ); aPointer.Inc(); return result; }
TVerdict CSendSmsAndCancel::doTestStepL( void ) { TInt i; TRequestStatus status; INFO_PRINTF1(_L("Sending SMS and cancelling.")); // Create message PDU and convert to binary _LIT8(KMsgDataBeforeTargetAddress,"1d00"); _LIT8(KMsgDataAfterTargetAddress,"01A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A0"); TBuf8<400> msgData; TLex8 lex; TUint8 val; msgData.Zero(); const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_before;++i) { lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); TESTL(KErrNone == lex.Val(val,EHex)); msgData.Append(TChar(val)); } TBuf8<20> targetAddressAscii; targetAddressAscii.Zero(); RMobilePhone::TMobileAddress targetAddress; targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; targetAddress.iTelNumber.Copy(iTelNumber); TInt ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); if(ret) return(EFail); const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even for(i=0;i<count_address;++i) { lex=targetAddressAscii.Mid(i*2,2); lex.Val(val,EHex); msgData.Append(TChar(val)); } const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_after;++i) { lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); lex.Val(val,EHex); msgData.Append(TChar(val)); } // Create message attibutes RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; msgAttr.iFlags=0x184; msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); // Package up data ready for sending to etel RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); // Send the message INFO_PRINTF1(_L("..")); TSmsPdu smsPduSent; smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); iSms.SendMessage(status,smsPduSent,msgAttrPkg); // Wait for a bit User::After(KOneSecond*2); // Cancel sending, then wait for sending operation to complete iSms.CancelAsyncRequest(EMobileSmsMessagingSendMessage); //if(status==KRequestPending) User::WaitForRequest(status); ret=KErrNone; if(status!=KErrCancel && status!=KErrNone) ret=status.Int(); else INFO_PRINTF1(_L("TESTL(s) passed")); // If we don't cause a panic or leave the test has passed /* iSms.Close(); iPhone->Close(); User::After(500000L); iPhone.Open(iTelServer,GSM_NAME); iSms.Open(iPhone); */ return TestStepResult(); }
/** * After the player has received the update after the last iteration of the game. * We want to display the current game status, if there is only one player remaining then * the game has finished. */ void CScabbyQueenPlayer::ReceiveNextRole() { if (iPlayerUpdate == iGameOverBuffer) { iConsole.Printf(_L("\nDealer Says: GAME OVER")); } else { // Break down the update descriptor and display the result TBufC<20> buffer; buffer.Des().Copy(iPlayerUpdate); iConsole.Printf(_L("\n\nUpdate from the dealer...%S\n"), &buffer); TInt position; TPtrC8 ptr(iPlayerUpdate); TLex8 lex; TInt player; TBool stillIn = EFalse; iConsole.Printf(_L("\n Number of players: %d\n"), iPlayerUpdate.Length()-1); TInt stillInCount = 0; for (TInt i=0; i<iPlayerUpdate.Length();i++) { TChar inspect = ptr[i]; if (inspect != 'F') { TBuf8<2> buff; buff.Append(inspect); lex.Assign(buff); lex.Val(player); if (stillIn) { TBufC16<2> buff; buff.Des().Append(inspect); iConsole.Printf(_L("\n Player %S still in play"), &buff); stillInCount++; } else { position = i+1; if (i == 0) { iConsole.Printf(_L("\n The winner is player %d"), player); } else { iConsole.Printf(_L("\n In position %d is player %d"), position, player); } } } else { stillIn = ETrue; } } if (stillInCount == 1) { // If there is only one player left the game is over. iGameOver = ETrue; iConsole.Printf(_L("\nThe loser is player %d, give them a smack"), player); iConsole.Printf(_L("\n\nDealer Says: GAME OVER")); } iGameStatus = EReadyForToken; iSendMode = ESendReadyForToken; BaseSendTo(iGameStatus, KDealerIpAddr); } }
inline void CPppMsChap::ProcessFailureMessageL( const TDesC8& aFailureMessage, TUint& aErrorCode, TUint8& aRetryFlag, TBool& aHasNewChallenge, TDes8& aChallenge, TUint8& aPasswordProtoVersion) /** Processes a MS-CHAP Failure Message. @param aFailureMessage [in] A MS-CHAP Failure Message. The Failure Message needs to be in the format specified in RFC 2433: "E=eeeeeeeeee R=r C=cccccccccccccccc V=vvvvvvvvvv". @param aErrorCode [out] The MS-CHAP Failure error code. @param aRetryFlag [out] The retry flag. The flag will be set to "1" if a retry is allowed, and "0" if not. When the authenticator sets this flag to "1" it disables short timeouts, expecting the peer to prompt the user for new credentials and resubmit the response. @param aHasNewChallenge [out] The flag that indicates if the Failure Message contains a new Challenge Value. @param aChallenge [out] The new Challenge Value, if the Failure Message contains a one. @param aPasswordProtoVersion [out] The password changing protocol supported by the peer. @internalComponent */ { ASSERT(aChallenge.Length() == KPppMsChapChallengeSize); TLex8 input(aFailureMessage); if (input.Get() != 'E') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); // RFC 2433: ""eeeeeeeeee" is the ASCII representation of a decimal // error code (need not be 10 digits) corresponding to one of those // listed below, though implementations should deal with codes not on // this list gracefully." TInt ret; if ((ret = input.Val(aErrorCode)) != KErrNone) if (ret != KErrOverflow) User::Leave(KErrGeneral); else // Gracefully handle unusually large, yet valid, MS-CHAP specific // error code values. This code only handles the MS-CHAP specific // error code values specified in RFC 2433. aErrorCode=0; input.SkipSpace(); if (input.Get() != 'R') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); if (input.Val(aRetryFlag, EDecimal)!=KErrNone) User::Leave(KErrGeneral); input.SkipSpace(); switch (input.Get()) { case 'C': { if (input.Get() != '=') User::Leave(KErrGeneral); TPtrC8 token(input.NextToken()); // This field is 16 hexadecimal digits representing an ASCII // representation of a new challenge value. Each octet is represented // in 2 hexadecimal digits. if (token.Length() != KPppMsChapChallengeSize*2) User::Leave(KErrGeneral); TLex8 lex; TUint8 octet; TUint8* pChallengeOctet = const_cast<TUint8*>(aChallenge.Ptr()); TUint8 i = 0; do { lex.Assign(token.Mid(i*2, 2)); if (lex.Val(octet, EHex) != KErrNone) User::Leave(KErrGeneral); *(pChallengeOctet + i) = octet; } while (++i < KPppMsChapChallengeSize); aHasNewChallenge = ETrue; input.SkipSpace(); if (input.Get()!='V') { aPasswordProtoVersion = 1; User::Leave(KErrGeneral); } } // As specified in RFC 2433, the field containing the ASCII // representation of a new challenge value is optional, so fall // through. case 'V': // RFC 2433: "The "vvvvvvvvvv" is the decimal version code (need not // be 10 digits) indicating the MS-CHAP protocol version supported on // the server. Currently, this is interesting only in selecting a // Change Password packet type. If the field is not present the // version should be assumed to be 1; since use of the version 1 // Change Password packet has been deprecated, this field SHOULD // always contain a value greater than or equal to 2." aHasNewChallenge = EFalse; if (input.Get() != '=') User::Leave(KErrGeneral); if ((ret=input.Val(aPasswordProtoVersion, EDecimal)) != KErrNone) if (ret!= KErrOverflow) User::Leave(KErrGeneral); else // Gracefully handle unusually large, yet valid, password changing // protocol version values. This code only handles the password // changing protocol version codes values specified in RFC 2433. aPasswordProtoVersion = 0; break; default: aHasNewChallenge = EFalse; aPasswordProtoVersion = 1; } }
// --------------------------------------------------------------------------- // Received a response header // --------------------------------------------------------------------------- // void CCatalogsHttpTransaction::ResponseHeaderReceived( const TDesC8& aHeader, const TDesC8& aValue ) { DLTRACEIN( ("") ); DASSERT( iObserver ); TRAPD( err, iResponseHeaders->AddHeaderL( aHeader, aValue ) ); if ( err != KErrNone ) { HandleHttpError( ECatalogsHttpErrorGeneral, err ); return; } iState.iOperationState = ECatalogsHttpOpInProgress; iState.iProgressState = ECatalogsHttpResponseHeaderReceived; if ( aHeader.CompareF( KHttpContentRangeHeader ) == 0 ) { // // Content-Range, bytes x-y/z // Extract 'z' and use it as the total content length // TPtrC8 ptr( aValue ); TInt offset = ptr.Locate( '/' ); if ( offset != KErrNotFound ) { TLex8 val; val.Assign( ptr.Mid( offset + 1 ) ); TInt value; TInt err = val.Val( value ); if ( err == KErrNone ) { iContentLength = value; DLTRACE(( "Content length: %i", iContentLength )); } } } else if ( aHeader.CompareF( KHttpContentLengthHeader ) == 0 ) { // // If content length for this request has not been already set // e.g. from a Content-Range header, extract from Content-Length header // if ( iContentLength == 0 ) { TLex8 val; val.Assign( aValue ); TInt value; TInt err = val.Val( value ); if ( err == KErrNone ) { iContentLength = value; DLTRACE(( "Content length: %i", iContentLength )); } } else { DLTRACE(( "-> ContentLength set, ignoring" )); } } else if ( aHeader.CompareF( KHttpContentTypeHeader ) == 0 ) { // Content type from the header DLTRACE( ( "Content type received" ) ); TRAPD( err, SetContentTypeL( aValue ) ); if ( err != KErrNone ) { DLTRACE( ( "Content type setting failed with err: %i", err ) ); HandleHttpError( ECatalogsHttpErrorGeneral, err ); return; } else { iState.iProgressState = ECatalogsHttpContentTypeReceived; } } // Report the observer that a header has been received NotifyObserver(); }
// Function to read a line from a buffer GLDEF_C void ReadConfigFileL(RFile& aConfigFile, TListeners& aListeners, RSocketServ& aSocketServ, RConnection& aConnect) { TInt fileLen; User::LeaveIfError(aConfigFile.Size(fileLen)); HBufC8* readBuffer = HBufC8::NewL(fileLen); CleanupStack::PushL(readBuffer); TPtr8 buff = readBuffer->Des(); // Read File // Here, we read the whole file as we know it's small TRequestStatus status; aConfigFile.Read(buff, status); User::WaitForRequest(status); if(status.Int() != KErrNone && status.Int() != KErrEof) { User::LeaveIfError(status.Int()); } HBufC8* tempBuffer = HBufC8::NewL(KLineSize); CleanupStack::PushL(tempBuffer); TPtr8 lineBuff = tempBuffer->Des(); TLex8 lex; lex.Assign(buff); /* Parse whole stream in to split it in lines We discard commented line with # */ TBool error = EFalse; while(!lex.Eos() && !error) { TBool comment = EFalse; if(lex.Peek() == '#') { // We've got a comment comment = ETrue; } TInt nbCharRead = 0; // To count number of character per line. Used to avoid a buffer overflow while(!error && !lex.Eos() && lex.Peek() != '\r' && lex.Peek() != '\n') { // We look if we are allowed to append character. Otherwise we stop loopping. if(nbCharRead < KLineSize) { lineBuff.Append(lex.Get()); nbCharRead++; } else { error = ETrue; } } if(!comment) { // We create a new listener TInt nbListeners = aListeners.Count(); if(nbListeners < KNbListeners) { aListeners.Append(CListener::NewL(aSocketServ, aConnect, CListenerOptions::NewL(lineBuff))); aListeners[nbListeners]->AcceptL(); } } lineBuff.Zero(); if(lex.Peek() == '\r') { lex.Get(); // Get rid of \r } lex.Get(); // Get rid of \n } // Delete buffers CleanupStack::PopAndDestroy(tempBuffer); CleanupStack::PopAndDestroy(readBuffer); if(error) { // We have a bad line in our configuration file so we delete all listeners aListeners.ResetAndDestroy(); } }
// --------------------------------------------------------------------------- // SdpUtil::ChopElementsFromLineL // Chops all the elements that are divided by delimiter from the string // --------------------------------------------------------------------------- // void SdpUtil::ChopElementsFromLineL( RArray<TPtrC8>& aArray, TLex8& aLexer, TChar aDelimiter, TInt aErrCode ) { // Chop the elements to the array from lexer TBool eofcFound = EFalse; while (!eofcFound) { aLexer.Mark(); // Parse single token, leave other special characters // to token except aDelimiter | '\r' | '\n' | '\0' while ( aLexer.Peek() != aDelimiter && aLexer.Peek() != KCRChar && aLexer.Peek() != KLFChar && aLexer.Peek() != KEofChar ) { aLexer.Inc(); } if ( aLexer.MarkedToken().Length() > 0 ) { aArray.AppendL( aLexer.MarkedToken() ); } if ( aDelimiter == KSPChar && aLexer.Peek() == aDelimiter ) { SkipSpacesUntilNextLineBreak( aLexer ); } // Check if its end-of-line if ( aLexer.Peek() == KCRChar ) { aLexer.Inc(); } if ( aLexer.Peek() == KLFChar ) { aLexer.Inc(); if ( aLexer.Peek() != KEofChar ) { User::Leave( aErrCode ); } eofcFound = ETrue; } else if ( aLexer.Peek() == KEofChar ) { // EoF character not tolerated at the middle of the string User::Leave( aErrCode ); } else { aLexer.Inc(); } } }
inline void CPppMsChap2::ProcessFailureMessageL( const TDesC8& aFailureMessage, TUint& aErrorCode, TUint8& aRetryFlag, TDes8& aAuthChallenge, TUint8& aPasswordProtoVersion, TPtrC8& aMessage) /** Processes a MS-CHAP-V2 Failure Message. @param aFailureMessage [in] A MS-CHAP-V2 Failure Message. The Failure Message needs to be in the format specified in RFC 2759: "E=eeeeeeeeee R=r C=cccccccccccccccccccccccccccccccc V=vvvvvvvvvv M=<msg>". @param aErrorCode [out] The MS-CHAP-V2 Failure error code. @param aRetryFlag [out] The retry flag. The flag will be set to "1" if a retry is allowed, and "0" if not. When the authenticator sets this flag to "1" it disables short timeouts, expecting the peer to prompt the user for new credentials and resubmit the response. @param aAuthChallenge [out] The new Authenticator Challenge Value. @param aPasswordProtoVersion [out] The password changing protocol supported by the peer. @param aMessage [out] A failure text message. @internalComponent */ { ASSERT(aAuthChallenge.Length() == KPppMsChap2AuthenticatorChallengeSize); TLex8 input(aFailureMessage); if (input.Get() != 'E') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); // RFC 2759: ""eeeeeeeeee" is the ASCII representation of a decimal // error code (need not be 10 digits) corresponding to one of those // listed below, though implementations should deal with codes not on // this list gracefully." TInt ret; if ((ret = input.Val(aErrorCode))!=KErrNone) if (ret!= KErrOverflow) User::Leave(KErrGeneral); else // Gracefully handle unusually large, yet valid, MS-CHAP-V2 specific // error code values. This code only handles the MS-CHAP-V2 specific // error code values specified in RFC 2759. aErrorCode=0; input.SkipSpace(); if (input.Get() != 'R') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); if (input.Val(aRetryFlag, EDecimal)!=KErrNone) User::Leave(KErrGeneral); input.SkipSpace(); if (input.Get() != 'C') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); TPtrC8 token(input.NextToken()); // This field is 32 hexadecimal digits representing an ASCII // representation of a new challenge value. Each octet is represented // in 2 hexadecimal digits. if (token.Length() != KPppMsChap2AuthenticatorChallengeSize*2) User::Leave(KErrGeneral); TLex8 lex; TUint8 octet; TUint8* pChallengeOctet = const_cast<TUint8*>(aAuthChallenge.Ptr()); TUint8 i = 0; do { lex.Assign(token.Mid(i*2, 2)); if (lex.Val(octet, EHex) != KErrNone) User::Leave(KErrGeneral); *(pChallengeOctet + i) = octet; } while (++i < KPppMsChap2AuthenticatorChallengeSize); input.SkipSpace(); if (input.Get() != 'V') User::Leave(KErrGeneral); if (input.Get() != '=') User::Leave(KErrGeneral); // RFC 2759: "The "vvvvvvvvvv" is the ASCII representation of a // decimal version code (need not be 10 digits) indicating the // password changing protocol version supported on the server. For // MS-CHAP-V2, this value SHOULD always be 3." if ((ret = input.Val(aPasswordProtoVersion, EDecimal)) != KErrNone) if (ret != KErrOverflow) User::Leave(KErrGeneral); else // Gracefully handle unusually large, yet valid, password changing // protocol version values. This code only handles the password // changing protocol version values specified in RFC 2759. aPasswordProtoVersion=0; input.SkipSpace(); switch (input.Get()) { case 'M': if (input.Get() != '=') User::Leave(KErrGeneral); aMessage.Set(input.NextToken()); break; case 0: break; default: User::Leave(KErrGeneral); } ASSERT(aAuthChallenge.Length() == KPppMsChap2AuthenticatorChallengeSize); }
// ----------------------------------------------------------------------------- // CSeiForwardPlugin::HandleNotifyL // // ----------------------------------------------------------------------------- // void CSeiForwardPlugin::HandleNotifyL( const CEcmtMessageEvent& aEvent ) { const TPtrC8 m = iMessaging->Message( aEvent ); TLex8 lexer( m ); TPtrC8 type = lexer.NextToken(); TPtrC8 channelStr = lexer.NextToken(); TLex8 num ( channelStr ); TInt channel; // Check message type if ( ( type != KConnect ) && ( type != KListen ) && ( type != KMsg ) ) { RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid message" ) ); return; } // Get channel number if ( num.Val( channel ) ) { RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid channel" ) ); return; } // Process message if ( type == KConnect ) { TPtrC8 portStr = lexer.NextToken(); TInt port; num.Assign ( portStr ); // Get port number if ( num.Val( port ) ) { RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid port" ) ); return; } ConnectL( channel, port ); } else if ( type == KListen ) { ListenL( channel ); } else if ( type == KMsg ) { // Now this just sends the message back to the Java plug-in. // Instead, should cancel the appropriate socket read and write // the message to the socket. TPtrC8 msg = lexer.Remainder(); SendMessageL( channel, msg ); } }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetShortInteger // ----------------------------------------------------------------------------- // TUint CWPPushMessage::GetShortInteger( TLex8& aPointer ) const { return aPointer.Get() & KShortIntegerMask; }
TInt CReceiveStoredSms::SendSms(TBool aQuiet, RMobileSmsMessaging& aSms) /** * SendSms test. */ { if(!aQuiet) INFO_PRINTF1(_L("Sending SMS.")); // Create message PDU and convert to binary TBuf8<400> msgData; TLex8 lex; TUint8 val; TInt i; TInt ret; msgData.Zero(); const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_before;++i) { lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } TBuf8<20> targetAddressAscii; targetAddressAscii.Zero(); RMobilePhone::TMobileAddress targetAddress; targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; targetAddress.iTelNumber.Copy(iTelNumber); ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); if(ret) return ret; const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even for(i=0;i<count_address;++i) { lex=targetAddressAscii.Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_after;++i) { lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } // Create message attibutes RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; msgAttr.iFlags=0x184; msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); // Package up data ready for sending to etel RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); // Send the message, try upto 3 times if phone is not ready TRequestStatus status; INFO_PRINTF1(_L("..")); TSmsPdu smsPduSent; smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) { INFO_PRINTF1(_L("..")); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) { INFO_PRINTF1(_L("..")); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); } } ret = status.Int(); if(ret) return ret; // Validate message reference number has changed if(!(msgAttr.iFlags&RMobileSmsMessaging::KMessageReference)) { return(KErrCorrupt); } if(!aQuiet) { INFO_PRINTF1(_L("test(s) passed")); } return(KErrNone); }
void CDomainNameCodec::EncodeL(TDomainNameArray& aNames, RBuf8& aBuf8) { TUint requiredLength = 0; TUint8 nameIdx = 0; for (nameIdx=0;nameIdx<aNames.Count();nameIdx++) { // The total length required for the labels that comprise an // individual domain name needs to take into the length octet // for the initial label and the null-termination character. // Hence the '+ 2' below. requiredLength += (aNames[nameIdx].Length() + 2); // A further length check is performed on each domain name to // ensure it does not exceed the maximum length permitted according // to RFC 1035. if(aNames[nameIdx].Length() > KMaxDomainNameLength) { User::Leave(KErrArgument); } } aBuf8.Zero(); aBuf8.ReAllocL(requiredLength); TLex8 domainName; TPtrC8 currentLabel; for (nameIdx=0;nameIdx<aNames.Count();nameIdx++) { domainName.Assign(aNames[nameIdx]); domainName.Mark(); while (!domainName.Eos()) { TChar ch; do { ch = domainName.Get(); } while ( ch != TChar('.') && !domainName.Eos() ); // if not the end of the string, unget the previous char to skip the trailing // dot in our marked token // if( !domainName.Eos() ) { domainName.UnGet(); } currentLabel.Set(domainName.MarkedToken()); // move past the dot again, or do nothing in particular at EOS // domainName.Get(); User::LeaveIfError(currentLabel.Length() > KMaxDnsLabelLength ? KErrArgument : KErrNone); aBuf8.Append(TChar(currentLabel.Length())); aBuf8.Append(currentLabel); domainName.Mark(); } aBuf8.Append(TChar(0)); } }
// ----------------------------------------------------------------------------- // CEcmtPanPlugin::SendCurrentValues // // ----------------------------------------------------------------------------- // void CEcmtPanPlugin::SendCurrentValuesL( ) { #ifdef ECMT_RDEBUG RDebug::Print( _L( "EcmtPanPlugin::SendCurrentValuesL" ) ); #endif TBuf<KMaxWin32Path> buf; TBuf8<KMaxPanMsgLen> msg; TPtrC8 line; TLex8 lexer; /* * Handle bt.esk */ GetBtEskFilename( buf ); REcmtFile btFile( buf ); btFile.Read(); if ( !btFile.IsGood() ) { return; } line.Set( btFile.FindLine( KBtPort ) ); if ( line.Length() == 0 ) { return; } msg.Append( KBtCom ); msg.Append( ' ' ); lexer.Assign( line ); lexer.SkipCharacters(); msg.Append( lexer.NextToken() ); msg.Append( ' ' ); line.Set( btFile.FindLine( KHciDll ) ); if ( line.Length() == 0 ) { return; } msg.Append( KHci ); msg.Append( ' ' ); lexer.Assign( line ); lexer.SkipCharacters(); TPtrC8 dll( lexer.NextToken() ); if ( dll.CompareF( KHciDllBcsp ) == 0 ) { msg.Append( '0' ); } else if ( dll.CompareF( KHciDllH4 ) == 0 ) { msg.Append( '1' ); } else if ( dll.CompareF( KHciDllUsb ) == 0 ) { msg.Append( '2' ); } else { msg.Append( '-1' ); } /* * Handle irda.esk */ GetIrdaEskFilename( buf ); REcmtFile irdaFile( buf ); irdaFile.Read(); if ( !irdaFile.IsGood() ) { return; } line.Set( irdaFile.FindLine( KIrdaPort ) ); if ( line.Length() == 0 ) { return; } msg.Append( ' ' ); msg.Append( KIrdaCom ); msg.Append( ' ' ); lexer.Assign( line ); lexer.SkipCharacters(); msg.Append( lexer.NextToken() ); /* * Send values */ CEcmtMessageEvent* m = iMessaging->NewMessageEvent( iTargetUid, msg ); if ( m ) { #ifdef ECMT_RDEBUG RDebug::Print( _L( "EcmtPanPlugin::SendCurrentValuesL: Sending a message" ) ); #endif iMessageSender->SendMessage( m ); } }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetNoValue // ----------------------------------------------------------------------------- // void CWPPushMessage::GetNoValue( TLex8& aPointer ) const { // We're not checking anything here. No value is no value. aPointer.Get(); }
// ----------------------------------------------------------------------------- // CWPPushMessage::ParseContentType // ----------------------------------------------------------------------------- // void CWPPushMessage::ParseContentType( TLex8& aPointer ) { // Go through the whole content type header. while( !aPointer.Eos() ) { // Each parameter might be well-known (integer) or unknown (text) if( IsIntegerValue( aPointer ) ) { // For well-known parameters, the token is an integer value TUint paramToken( I64LOW( GetIntegerValue( aPointer ) ) ); // These are filled with results from parsing. TInt resultInteger( 0 ); TPtrC8 resultString; // Make sure paramToken fits into KParameterTypes table if( paramToken < sizeof(KParameterTypes)/sizeof(TParameterCodingType)) { // Get the coding and use it to determine how we should decode // the next parameter value. We actually ignore all results // except short integer (SEC) and text-value (MAC), but the // rest of the parameters have to be parsed anyway. TParameterCodingType coding( KParameterTypes[paramToken] ); switch( coding ) { case EQValue: GetQValue( aPointer ); break; case EWellKnownCharset: GetWellKnownCharset( aPointer ); break; case EVersionValue: GetVersionValue( aPointer ); break; case EIntegerValue: GetIntegerValue( aPointer ); break; case ETextString: GetTextString( aPointer ); break; case EFieldName: GetFieldName( aPointer ); break; case EShortInteger: resultInteger = GetShortInteger( aPointer ); break; case EConstrainedEncoding: GetConstrainedEncoding( aPointer ); break; case EDeltaSecondsValue: GetDeltaSecondsValue( aPointer ); break; case ENoValue: GetNoValue( aPointer ); break; case ETextValue: resultString.Set( GetTextValue( aPointer ) ); break; case EDateValue: GetDateValue( aPointer ); break; default: break; } // We have a result. We're actually only interested in // SEC and MAC parameters, so we save them here. switch( paramToken ) { case KWSPHeaderSEC: iSEC = resultInteger; break; case KWSPHeaderMAC: iMAC.Set( resultString ); break; default: break; } } } else { // Unknown parameter. Its name is in text, and the value // might be an integer or text. GetTokenText( aPointer ); if( IsIntegerValue( aPointer ) ) { GetIntegerValue( aPointer ); } else { GetTextValue( aPointer ); } } } }
// ----------------------------------------------------------------------------- // CMccCodecInformation::ParseFmtpAttr // Parses the fmtp attribute // ----------------------------------------------------------------------------- // TBool CMccCodecRed::ParseFmtpAttrL( const TDesC8& aFmtp ) { // Parse codecs used for primary and secondary etc. codecs from the // fmtp attribute // example fmtp attribute: // a=fmtp:99 0/103 // 99 is the redundancy format payload type // 0 is the primary codecs payload type // 103 is the secondary codecs payload type // NOTE: currently redundancy is allowed only for single payload type TBool updated( EFalse ); TInt nextIndex = 0; TInt prevIndex = 0; TUint8 prevPayloadFormat = KMccPayloadTypeMax; HBufC8* modifyBuf = HBufC8::NewLC( aFmtp.Length() ); TPtr8 pFmtpValue( modifyBuf->Des() ); pFmtpValue = aFmtp; if( aFmtp.Length() > 0 ) { // Search for all the slashes and convert number strings between them // to integers TBool found = ETrue; while( EFalse != found ) { pFmtpValue = modifyBuf->Mid( nextIndex ); nextIndex = pFmtpValue.Locate( KCharSlash ); if( ( KErrNotFound == nextIndex ) ) { found = EFalse; if( 0 != pFmtpValue.Length() ) { nextIndex = pFmtpValue.Length(); // Handle last payload value } } if( 0 != pFmtpValue.Length() ) { TLex8 lex = pFmtpValue.Mid( prevIndex, (nextIndex - prevIndex) ); TUint8 payloadFormat; TInt err = lex.Val( payloadFormat, EDecimal ); if( KErrNone == err ) { if ( prevPayloadFormat != KMccPayloadTypeMax && prevPayloadFormat != payloadFormat ) { iRedPayloads.Reset(); User::Leave( KErrNotSupported ); } iRedPayloads.AppendL( static_cast<TUint>( payloadFormat ) ); updated = ETrue; prevPayloadFormat = payloadFormat; } nextIndex++; prevIndex = 0; } } } CleanupStack::PopAndDestroy( modifyBuf ); return updated; }
TInt CProfilerPowerListener::StartL(const TDesC8& aBuf) { LOGTEXT(_L("CProfilerPowerListener::StartL() - entry")); // get the property value TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime); if(r != KErrNone) { LOGSTRING2("CProfilerPowerListener::StartL() - getting iSyncOffset failed, error %d", r); } // check if given sampling period is valid if(aBuf.CompareF(KNullDesC8)!= 0) { TLex8* lex = new TLex8(aBuf); lex->Val(iPwrSamplingPeriod); delete lex; } else { // set default period iPwrSamplingPeriod = 250; } // Check that sampling period is in allowed range if (KMinSampleInterval > 0 && iPwrSamplingPeriod < KMinSampleInterval) { iPwrSamplingPeriod = KMinSampleInterval; } LOGSTRING2("CProfilerPowerListener::StartL() - Sampling period %d", iPwrSamplingPeriod); // Start monitoring voltage and current iPowerAPI = CHWRMPower::NewL(); iPowerAPI->SetPowerReportObserver(this); // Read HWRM reporting settings from central repository CRepository* centRep = CRepository::NewL(KCRUidPowerSettings); TInt baseInterval(0); User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval)); User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod)); LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval); LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod); User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite)); // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms. if ( baseInterval < KMinSampleInterval ) { baseInterval = KMinSampleInterval; LOGSTRING2("CProfilerPowerListener::StartL() - Power report interval too low. Changed to: %d", baseInterval); } // Power reporting period is multiplier of HWRM base period TInt intervalMultiplier = iPwrSamplingPeriod / baseInterval; if (intervalMultiplier < 1) { intervalMultiplier = 1; } LOGSTRING2("CProfilerPowerListener::StartL() - Reporting period multiplier: %d", intervalMultiplier); TRequestStatus status(KRequestPending); iPowerAPI->StartAveragePowerReporting(status, intervalMultiplier); User::WaitForRequest(status); if (status.Int() != KErrNone) { LOGTEXT(_L("CProfilerPowerListener::StartL() - Failed to initialize power reporting")); DisplayNotifierL(KPowerTextLine1, KPowerTextLine2, KButtonOk, KNullDesC); return status.Int(); } #ifdef PWR_SAMPLER_BACKLIGHT // Start monitoring backlight status iLightAPI = CHWRMLight::NewL(this); #endif LOGTEXT(_L("CProfilerPowerListener::StartL() - exit")); return KErrNone; }