本文整理汇总了C++中HBufC8::Right方法的典型用法代码示例。如果您正苦于以下问题:C++ HBufC8::Right方法的具体用法?C++ HBufC8::Right怎么用?C++ HBufC8::Right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBufC8
的用法示例。
在下文中一共展示了HBufC8::Right方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadOldVersionFileL
TInt CVersionFileReader::ReadOldVersionFileL(const TDesC& aFilename)
{
// The file contains a string matching this regex
// [0-9]\+\.[0-9]\+_[0-9]\+
iOldVersionArray->Reset();
class RFs& fs = CCoeEnv::Static()->FsSession();
class RFile versionFile;
TInt ret = versionFile.Open(fs, aFilename,
EFileStreamText | EFileRead);
if(ret != KErrNone) {
/* Could not open file, return the error code */
return ret;
}
HBufC8* line = HBufC8::NewLC(30);
TInt pos = -1;
versionFile.Seek(ESeekStart, pos);
TPtr8 pLine = line->Des();
ret = versionFile.Read(pLine);
iOldVersionArray->AppendL(*line);
if(line->Length() == 0) {
versionFile.Close();
return KErrEof;
}
versionFile.Close();
if(line->Locate('_') != KErrNotFound) {
iOldVersionArray->AppendL(line->Left(line->Locate('_')));
iOldVersionArray->AppendL(line->Right(line->Length() - line->Locate('_') - 1));
} else {
iOldVersionArray->AppendL(*line);
}
CleanupStack::PopAndDestroy(line);
return ret;
}
示例2: ReadNewVersionFileL
TInt CVersionFileReader::ReadNewVersionFileL(const TDesC& versionFile)
{
iNewVersionArray->Reset();
class RFs& fs = CCoeEnv::Static()->FsSession();
class RFile file;
TInt ret = file.Open(fs, versionFile,
EFileStreamText | EFileRead);
if(ret != KErrNone) {
/* Could not open file, return the error code */
return ret;
}
HBufC8* line = HBufC8::NewLC(40);
TInt pos = -1;
file.Seek(ESeekStart, pos);
TPtr8 pLine = line->Des();
ret = file.Read(pLine);
if(line->Length() == 0) {
// Empty file
file.Close();
return KErrEof;
}
file.Close();
// The file contains a string that should match this regex:
// [0-9]+\.[0-9]+\.[0-9]\+:[0-9]+\.[0-9]+\.[0-9]\+:[0-9]\+
// The string is separated into three parts by ':'.
// The first part is the application version
// The second part is the resource version
// The third part is the mlfw version.
const TChar colon = ':';
const TChar dot = '.';
while(line->Length() > 0) {
if(line->Locate(colon) != KErrNotFound) {
TPtrC8 part = line->Left(line->Locate(colon));
TPtrC8 version = part.Left(part.LocateReverse(dot));
TPtrC8 misc = part.Right(part.Length() - part.LocateReverse(dot) - 1);
iNewVersionArray->AppendL(part);
iNewVersionArray->AppendL(version);
iNewVersionArray->AppendL(misc);
line->Des().CopyF(line->Right(line->Length() - line->Locate(colon) - 1));
} else {
iNewVersionArray->AppendL(*line);
break;
}
}
CleanupStack::PopAndDestroy(line);
return 0;
}
示例3: StateChange
void CSyncHttpConnection::StateChange(THttpEngineState aState)
{
iEngineStatus = aState;
//CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange iEngineStatus = "), iEngineStatus);
switch (aState)
{
case EHttpError:
case EHttpGetHeaderTimeOut:
case EHttpGetBodyTimeOut:
case EHttpFinished:
if (iWait->IsStarted())
{
iWait->AsyncStop();
}
break;
case EGetHeader:
break;
case ERedirect:
{
HBufC8* head = iConnection->GetResponeHeader();
TPtrC8 redirectUrl;
if (head)
{
_LIT8(GOHREF, "Location:");
TInt redirectUrlIndex = head->FindC(GOHREF);
if (redirectUrlIndex >= 0)
{
redirectUrl.Set(head->Right(head->Length() - redirectUrlIndex - GOHREF().Length()));
_LIT8(SPACE, " ");
redirectUrlIndex = redirectUrl.FindC(SPACE);
while (redirectUrlIndex == 0)
{
redirectUrl.Set(redirectUrl.Right(redirectUrl.Length() - redirectUrlIndex - SPACE().Length()));
redirectUrlIndex = redirectUrl.FindC(SPACE);
}
redirectUrlIndex = redirectUrl.FindC(_L8("\r\n"));
if (redirectUrlIndex >= 0)
{
redirectUrl.Set(redirectUrl.Left(redirectUrlIndex));
}
}
}
if (redirectUrl.Length() > 0)
{
TBuf<200> aUri;
aUri.Copy(redirectUrl);
//CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange redirectUrl = "), aUri);
iConnection->ResetVarible();
iConnection->Stop();
iConnection->GetRequestL(aUri, 0);
iConnection->sendRequest();
}
else
{
//CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange ERedirect error"), _L(""));
iEngineStatus = EHttpError;
if (iWait->IsStarted())
{
iWait->AsyncStop();
}
}
}
break;
default:
if (iWait->IsStarted())
{
iWait->AsyncStop();
}
break;
}
}
示例4: AuthenticateL
//.........这里部分代码省略.........
else
{
result = KWPAuthResultAuthenticationFailed;
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultAuthenticationFailed" ) );
}
break;
}
case KSECUSERPINMAC:
{
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KSECUSERPINMAC" ) );
if (EAuthNETWPINOnly != value)
{
if( aPIN.Length() == 0 )
{
result = KWPAuthResultPinRequired;
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultPinRequired" ) );
}
keyPtr.Copy( aPIN );
}
else
{
result = KWPAuthResultAuthenticationFailed;
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultAuthenticationFailed" ) );
}
break;
}
default:
{
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: default" ) );
if (EAuthNETWPINOnly == value || EAuthNoSecurity == value )
{
result = KWPAuthResultAuthenticationFailed;
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultAuthenticationFailed" ) );
}
else
{
result = KWPAuthResultNoAuthentication;
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultNoAuthentication" ) );
}
break;
}
}
if( result == KWPAuthResultAuthenticated )
{
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: KWPAuthResultAuthenticated" ) );
CMessageDigest* digest = CSHA1::NewL();
CleanupStack::PushL( digest );
if( SEC() == KSECUSERPINMAC )
{
// key C is a concatenation of pin K and digest m
TPtrC8 K( key->Left( key->Length()/2 ) );
TPtrC8 m( key->Right( key->Length()/2 ) );
// M' = HMAC-SHA(K, A)
CHMAC* hmac = CHMAC::NewL( K, digest );
CleanupStack::Pop( digest );
CleanupStack::PushL( hmac );
TPtrC8 MM( hmac->Hash( Body() ) );
// Create m' (renamed to mm)
HBufC8* mm = HBufC8::NewLC( m.Length() );
TPtr8 ptr( mm->Des() );
for( TInt i( 0 ); i < m.Length(); i++ )
{
ptr.Append( (MM[i]%10)+KZero );
}
// Compare the MACs and mark the message as authenticated
if( *mm != m )
{
result = KWPAuthResultAuthenticationFailed;
}
CleanupStack::PopAndDestroy(); // mm
}
else
{
FLOG( _L( "[Provisioning] CWPPushMessage::AuthenticateL: not KWPAuthResultAuthenticated" ) );
// Create the HMAC from body
CHMAC* hmac = CHMAC::NewL( *key, digest );
CleanupStack::Pop( digest );
CleanupStack::PushL( hmac );
// Compare the MACs and mark the message as authenticated
if( headerMac->Length() == 0
|| hmac->Hash( Body() ) != *headerMac )
{
result = KWPAuthResultAuthenticationFailed;
}
}
CleanupStack::PopAndDestroy(); // hmac
}
CleanupStack::PopAndDestroy( 2 ); // key, headerMac
return result;
}
示例5: RunL
/**
Called when the INIT property is changed and once on the construction of the object. Extracts
the message from the INIT property, notifies both the observer by calling the
MLbsSuplPushRecObserver::OnSuplInit function and the sender by setting the ACK property.
Then it resubscribes for the INIT property to listen for next messages.
@see CSuplPushImpl
@see MLbsSuplPushRecObserver::OnSuplInit
@see CActive::RunL
*/
void CLbsSuplPushRecChannel::RunL()
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() Begin\n");
if(iStatus==KErrNone)
{
iInitProperty.Subscribe(iStatus);
SetActive();
TPckgBuf<TInt> length;
TInt err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, length);
//The INIT propery has been defined but not set yet.
if(err==KErrNone && length.Length()==0)
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err==KErrNone && length.Length()==0 End\n");
return;
}
//Can't do anything here, just resubscribe
if(err!=KErrOverflow || length()<=0)
{
//The property must be set in the correct value.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err!=KErrOverflow || length()<=0 End\n");
return;
}
TInt len = length() + 2*sizeof(TInt);
HBufC8* msg = HBufC8::New(len);
//Not enough memory to handle the message, just resubscribe
if(msg==0)
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - msg==0 End\n");
return;
}
TPtr8 ptr = msg->Des();
err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr);
if(err!=KErrNone || ptr.Length()!=len)
{
delete msg;
//Unexpected environment error or the length of the message is not equal the length declared in
//the header.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1,
"CLbsSuplPushRecChannel::RunL() RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr)|| ptr.Length()!=len End\n");
return;
}
TPckgBuf<TInt> reqId;
reqId.Copy(msg->Mid(sizeof(TInt), sizeof(TInt)));
if(reqId()<=0)
{
delete msg;
//Message is corrupted, the reqId must be > 0.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - reqId()<=0 End\n");
return;
}
TInt ackId = 0;
err = RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId);
if(err!=KErrNone || ackId<0)
{
delete msg;
if(ackId<0)
{
RProperty::Set(iPropOwnerSecureId, iAckPropKey, 0);
}
//Unexpected environment error or wrong ackId, it must be > 0.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1,
"CLbsSuplPushRecChannel::RunL() - RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId)!=KErrNone || ackId<0 End\n");
return;
}
//We notify the observer only if message was not delivered before
if(ackId!=reqId())
{
TLbsSuplPushRequestId reqIdUnsgn = reqId();
TPtrC8 msgPtr = msg->Right(length());
err = RProperty::Set(iPropOwnerSecureId, iAckPropKey, reqId());
//Unexpected environment error.
__ASSERT_DEBUG(err==KErrNone, User::Invariant());
//.........这里部分代码省略.........