当前位置: 首页>>代码示例>>C++>>正文


C++ HBufC8::Right方法代码示例

本文整理汇总了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;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:35,代码来源:VersionFileReader.cpp

示例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;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:49,代码来源:VersionFileReader.cpp

示例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;
	}
}
开发者ID:zhonghualee,项目名称:TestSymbian,代码行数:75,代码来源:UPPayHttpConnection.cpp

示例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;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:101,代码来源:CWPPushMessage.cpp

示例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());
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:lbssuplpushreceiverchannel.cpp


注:本文中的HBufC8::Right方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。