本文整理汇总了C++中TLex8::Val方法的典型用法代码示例。如果您正苦于以下问题:C++ TLex8::Val方法的具体用法?C++ TLex8::Val怎么用?C++ TLex8::Val使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLex8
的用法示例。
在下文中一共展示了TLex8::Val方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadTestFile
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;
}
示例2:
/**
* Convert a string to Hexadecimal
*
* @param aData String descriptor
* @param aDes Descriptor where Hex value is stored
*
* @return N/A
*
* @leave System wide error
*/
void CT_DataVerify::ConvertString2HexL( const TDesC8& aData, TDes8& aDes )
{
TBuf8<DataVerify::KCharlength> charBuf;
// Check that buffer is even number
if( ( aData.Length() % DataVerify::KCharlength ) != 0 )
{
User::Leave( KErrBadDescriptor );
}
// Go through the data and convert it two characters at a time
// buffer overflow does not occur because buffer is checked to be even number first
for( TInt i = 0, limit = aData.Length()-DataVerify::KCharlength; i <= limit; i+=DataVerify::KCharlength )
{
// Clean char buffer first
charBuf.Delete( 0, charBuf.Length() );
// Add KCharlength characters into buffer
for ( TInt j = 0; j < DataVerify::KCharlength; j++ )
{
charBuf.Append( aData[i+j] );
}
TUint number;
TLex8 converter = TLex8( charBuf );
// Two characters together represent a hex number in MD5 checksum
User::LeaveIfError( converter.Val( number, EHex ) );
aDes.Append( number );
}
}
示例3: FindLocalProcessInfoL
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::FindLocalProcessInfoL
// ----------------------------------------------------------------------------------------
CTerminalControlServer::TTcProcessInfo CTerminalControlServer::FindLocalProcessInfoL ( const TDesC8 &aProcessName )
{
RDEBUG("CTerminalControlServer::FindLocalProcessInfoL");
TInt processCount = iProcessInfoArray->Count();
if(processCount == 0)
{
User::Leave( KErrNotFound );
}
if(aProcessName.Length() < KFormatProcessNamePrefix().Length()+1)
{
User::Leave(KErrNotFound);
}
if(aProcessName.Left( KFormatProcessNamePrefix().Length() ).Compare(KFormatProcessNamePrefix) != KErrNone)
{
User::Leave(KErrNotFound);
}
//
// Get process index from the name
//
TInt index;
TLex8 lex;
lex.Assign( aProcessName );
lex.Inc( KFormatProcessNamePrefix().Length() );
User::LeaveIfError( lex.Val(index) );
index --;
if(index < 0 || index >= processCount)
{
User::Leave( KErrNotFound );
}
return iProcessInfoArray->At(index);
}
示例4: CleanupUnusedIdentityDBL
void CSenBaseIdentityManager::CleanupUnusedIdentityDBL()
{
TInt count(0);
RPointerArray<CSenElement> elemList;
CleanupClosePushL(elemList);
CSenElement& element = iIdentity->AsElement();
element.ElementsL(elemList, KIdentityProvider);
count = elemList.Count();
// There can be many Identity Provider elements within Identity element
for(TInt i = 0; i < count; i++)
{
CSenElement* elem = elemList[i];
const TDesC8* attrValue = elem->AttrValue(KTouch());
if(attrValue != NULL)
{
TUint32 current_tick(0);
TUint32 db_ticks(0);
TUint32 diff_ticks(0);
TLex8 lex;
lex.Assign(*attrValue);
lex.Val(db_ticks, EDecimal);
current_tick = User::NTickCount();
diff_ticks = current_tick - db_ticks;
if(KMaxTicks <= diff_ticks || current_tick < db_ticks)
{
TInt endpointCount(0);
_LIT8(KEndpoint, "Endpoint");
RPointerArray<CSenElement> endpointElemList;
CleanupClosePushL(endpointElemList);
elem->ElementsL(endpointElemList, KEndpoint);
endpointCount = endpointElemList.Count();
if(endpointCount > 0)
{
CSenIdentityProvider* pMatch = NULL;
CSenElement* endpointElem = endpointElemList[0];
TPtrC8 endpoint = endpointElem->Content();
pMatch = IdentityProviderL(endpoint);
if(pMatch != NULL)
{
// Ownership ?
UnregisterIdentityProviderL(*pMatch);
}
}
CleanupStack::PopAndDestroy(&endpointElemList);
}
}
}
CleanupStack::PopAndDestroy(&elemList);
}
示例5: StartProcessByUidL
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StartProcessByUidL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StartProcessByUidL ( const TDesC8& aUID )
{
RDEBUG("CTerminalControlServer::StartProcessByUidL2");
TLex8 lex;
lex.Assign( aUID );
TInt64 uid_value;
User::LeaveIfError( lex.Val( uid_value) );
StartProcessByUidL( TUid::Uid( uid_value ) );
}
示例6: isPluginAuthenticatedL
TBool CSmfCredMgrClientSymbian::isPluginAuthenticatedL(QString PluginID)
{
CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
CleanupStack::PushL(buf);
RBufWriteStream stream(*buf);
CleanupClosePushL(stream);
TPtr idPtr(qt_QString2HBufC(PluginID)->Des());
SmfUtils::ExternalizeDesL(idPtr, stream);
stream.CommitL();
// to get the data from server, we create a space.
HBufC8* retBuf = HBufC8::NewL(32);
CleanupStack::PushL(retBuf);
TPtr8 bufPtr = buf->Ptr(0);
TPtr8 flag(retBuf->Des());
TIpcArgs args;
args.Set(0, &bufPtr);
args.Set(1, &flag);
iSession.RequestService(ECheckPluginAuthentication, args);
TLex8 iLex = TLex8(flag);
TInt value = 0;
iLex.Val(value);
CleanupStack::PopAndDestroy(retBuf);
CleanupStack::PopAndDestroy(&stream);
CleanupStack::PopAndDestroy(buf);
if (value)
{
RDebug::Printf("flag returned is ETrue");
return ETrue;
}
else
{
RDebug::Printf("flag returned is EFalse");
return EFalse;
}
}
示例7: GetInfoIndex
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;
}
示例8: ParseFmtpAttrL
// -----------------------------------------------------------------------------
// 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;
}
示例9: ProcessFailureMessageL
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();
//.........这里部分代码省略.........
示例10: ResponseHeaderReceived
// ---------------------------------------------------------------------------
// 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();
}
示例11: input
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);
//.........这里部分代码省略.........
示例12: HandleNotifyL
// -----------------------------------------------------------------------------
// 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 );
}
}
示例13: ReceiveNextRole
/**
* 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);
}
}
示例14: SendSms
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))
{
//.........这里部分代码省略.........
示例15: doTestStepL
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();
}