EXPORT_C void CSenWsSecurityHeader2::BaseConstructL(const TDesC8& aData,
                                                    RSenDocument aDocument,
                                                    TXmlEngElement aElement)
    {
    BaseConstructL(aDocument, aElement);
    if ( aData.Length() )
        {
        TXmlEngElement element = AsElementL();
        TPtrC8 content = element.Text();
        if ( content.Length() > 0 )
            {
            HBufC8* pContent = HBufC8::NewLC( content.Length() + aData.Length() );
            TXmlEngElement element = AsElementL();
            TPtr8 ptrContent = pContent->Des();
            ptrContent.Append(content);
            ptrContent.Append(aData);
            element.SetTextNoEncL(*pContent);
            CleanupStack::PopAndDestroy(pContent);    
            }
        else
            {
            element.SetTextNoEncL(aData);
            }        
        }
    }
CSenElement* CSenPropertiesElement::CreateElementL(const TDesC8& aNsPrefix,
                                                   const TDesC8& aLocalName)
    {
    CSenElement* pNewElement = NULL;

    if (aNsPrefix.Length() > 0)
        {
        CSenNamespace* pNamespace = (CSenNamespace*)Namespace(aNsPrefix);
        if (pNamespace)
            {
            HBufC8 *pQName =
                HBufC8::NewLC(aNsPrefix.Length() + aLocalName.Length() +5);
            TPtr8 ptr = pQName->Des();
            ptr.Append(aNsPrefix);
            ptr.Append(':');
            ptr.Append(aLocalName);
            pNewElement = CSenPropertiesElement::NewL(pNamespace->URI(),
                                                      aLocalName,
                                                      *pQName,
                                                      ipStringPool);
                                                      
            CleanupStack::PopAndDestroy(); // pQName
            }
        }
    else
        {
        pNewElement = CSenPropertiesElement::NewL(aLocalName, ipStringPool);
        }

    return pNewElement; // Returns NULL if required namespace can not be found!
    }
// -----------------------------------------------------------------------------
// CSIPHeaderBase::ToTextL
// -----------------------------------------------------------------------------
//
EXPORT_C HBufC8* CSIPHeaderBase::ToTextL() const
	{
	TPtrC8 fullname(Name().DesC());
    // Because SIP Codec's string table has entry "expires" before "Expires",
    // and entry "require" before "Require",
    // literal "Expires" and "Require" must be used here. 
    // Changing the order of string table entries would have caused a SC break.	
	if (Name() == SIPStrings::StringF(SipStrConsts::EExpiresHeader))
	    {
        fullname.Set(KExpiresHeaderNameDes);
	    }
	else if (Name() == SIPStrings::StringF(SipStrConsts::ERequireHeader))
	    {
	    fullname.Set(KRequireHeaderNameDes);
	    }
	else
	    {
	    }
	TUint headerLength = fullname.Length();
	headerLength += KColonAndSpace().Length();
	HBufC8* encodedHeaderValue = ToTextValueL();
	headerLength += encodedHeaderValue->Length();

	CleanupStack::PushL (encodedHeaderValue);

	HBufC8* encodedHeader = HBufC8::NewL(headerLength);
	TPtr8 encodedHeaderPtr = encodedHeader->Des(); 
	encodedHeaderPtr.Append(fullname);
	encodedHeaderPtr.Append(KColonAndSpace);
	encodedHeaderPtr.Append(*encodedHeaderValue);
	
	CleanupStack::PopAndDestroy(encodedHeaderValue);

	return encodedHeader;
	}
// -----------------------------------------------------------------------------
// CWPPushMessage::ConvertIMSIL
// -----------------------------------------------------------------------------
//
void CWPPushMessage::ConvertIMSIL( const TDesC& aIMSI, TPtr8& aKey ) const
    {
    TUint8 parity( TUint8((aIMSI.Length() % 2) << KParityBitNum) );

    if( aIMSI.Length() == 0 )
        {
        aKey.Append( (KPadNibble<<KNumBitsInNibble) + KFirstNibble + parity );
        return;
        }

    // First byte contains just a header and one digit
    TInt first( aIMSI[0] - KZero );
    aKey.Append( (first<<KNumBitsInNibble) | KFirstNibble | parity );

    // Use semi-octet or BCD packing of IMSI. It means that one byte contains
    // two decimal numbers, each in its own nibble.
    for( TInt i( 1 ); i < aIMSI.Length(); i += KNumDigitsInByte )
        {
        first = aIMSI[i] - KZero;
        TInt second( 0 );

        if( aIMSI.Length() == i+1 )
            {
            second = KPadNibble;
            }
        else
            {
            second = aIMSI[i+1] - KZero;
            }

        aKey.Append( (second<<KNumBitsInNibble) + first );
        }
    }
EXPORT_C void CSenWsSecurityHeader2::BaseConstructL(const TDesC8& aData,
                                                    const TDesC8& aSecurityNs,
                                                    RSenDocument aDocument,
                                                    TXmlEngElement aElement)
    {
    RAttributeArray attrArray;
    CSenFragmentBase::BaseConstructL(aSecurityNs, KSecurityName, XmlNsPrefix(),
                                     attrArray, aElement, aDocument);
    if ( aData.Length() )
        {
        TXmlEngElement element = AsElementL();
        TPtrC8 content = element.Text();
        if ( content.Length() > 0 )
            {
            HBufC8* pContent = HBufC8::NewLC( content.Length() + aData.Length() );
            TXmlEngElement element = AsElementL();
            TPtr8 ptrContent = pContent->Des();
            ptrContent.Append(content);
            ptrContent.Append(aData);
            element.SetTextNoEncL(*pContent);
            CleanupStack::PopAndDestroy(pContent);    
            }
        else
            {
            element.SetTextNoEncL(aData);
            }        
        }
    }
Beispiel #6
0
EXPORT_C CWritePropPipe& CWritePropPipe::operator<<(const TDesC16& aSrc)
//
// Write the string to the buffer. If there is insufficient space, then leave with 
// KErrOverflow
//
	{
	__ASSERT_DEBUG(iBuf, User::Invariant());
	
	TPtr8 p = iBuf->Des();
	if(p.MaxSize() < (p.Size() + aSrc.Size() + sizeof(TInt32)))
		{
		User::Leave(KErrOverflow);
		}
	
	TPckgBuf<TInt32> size(aSrc.Size());
	p.Append(size);	
	
	TUint8* pTgt = new(ELeave)TUint8[aSrc.Size()+8];
	const TAny* pSrc = &aSrc[0];
		
	Mem::Copy(pTgt, pSrc, aSrc.Size());
	
	TPtr8 p2(pTgt, aSrc.Size(), aSrc.Size());
	p.Append(p2);
	delete pTgt;
	
	return *this;	
	}
// -----------------------------------------------------------------------------
// CNATFWUNSAFErrorCodeAttribute::EncodeValueL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFErrorCodeAttribute::EncodeValueL() const
{
    __TEST_INVARIANT;

    TInt encodedReasonPhraseLength = EncodedReasonPhraseLength();
    HBufC8* encodedValue =
        HBufC8::NewLC(EReasonPhraseOffset + encodedReasonPhraseLength);
    TPtr8 ptr = encodedValue->Des();
    ptr.FillZ(EReasonPhraseOffset);


    ptr[EClassOffset] = (iResponseCode / E100) & EClassMask;
    ptr[ENumberOffset] = iResponseCode % E100;


    ptr.Append(*iReasonPhrase);

    TInt spacesToAppend = encodedReasonPhraseLength - iReasonPhrase->Length();
    const TChar KSpace(' ');
    for (TInt i = 0; i < spacesToAppend; ++i)
    {
        ptr.Append(KSpace);
    }

    CleanupStack::Pop(encodedValue);
    return encodedValue;
}
// -----------------------------------------------------------------------------
// CSIPParamContainerBase::ToTextLC
// -----------------------------------------------------------------------------
//
HBufC8* CSIPParamContainerBase::ToTextLC () const
	{
	TUint encodedLength = 0;

	RPointerArray<HBufC8> paramsAsText;
	CleanupStack::PushL (TCleanupItem(ResetAndDestroy,&paramsAsText));

	for (TInt i=0; i < iParams.Count(); i++)
		{
		HBufC8* paramAsText = iParams[i]->ToTextLC();
		encodedLength += paramAsText->Length();
		if (i < iParams.Count()-1) 
		    {
		    encodedLength += 1; // param separator
		    }
		paramsAsText.AppendL(paramAsText);
		CleanupStack::Pop(paramAsText);
		}
	
	HBufC8* encodedParams = HBufC8::NewL (encodedLength);
	TPtr8 encodedParamsPtr = encodedParams->Des();

	for (TInt j=0; j < paramsAsText.Count(); j++)
		{
		encodedParamsPtr.Append (*paramsAsText[j]);
		if (j < paramsAsText.Count()-1)
			{
			encodedParamsPtr.Append(iParamSeparator);
			}
		}

	CleanupStack::PopAndDestroy(1); // paramsAsText
	CleanupStack::PushL(encodedParams);
	return encodedParams;
	}
// send a request and resend any continuations - use SDP_DEBUG to dump
TUint testSdpContL(RTest& test, TUint8* aReqData, TUint aReqLen, TUint8 aReqId, /*TUint8* aRespData,*/ TUint aMtu)
{
	TUint8 pduId = aReqId;
	HBufC8* requestHBuf = HBufC8::New(aReqLen + 10 /*KSdpContinuationStateLength*/);
	HBufC8* responseHBuf;
	TPtr8 request = requestHBuf->Des();
	TPtr8 buf(0,0);
	TInt continuationLen = 0;
	TInt partial = 0;
	TInt continutations = 0;

	request.SetLength(0);
	request.Append(aReqData, aReqLen);
	do
		{
		pduId = aReqId;
		responseHBuf = InjectLC(pduId, request, aMtu);
		buf.Set(responseHBuf->Des());

		switch(pduId)
			{
			case 0x03:
				test.Printf(_L("Got SDP_ServiceSearchResponse\n"));
				partial = BigEndian::Get16(&buf[2]);
				partial *= 4;
				partial += 4;
				continuationLen = buf[partial];
				break;
			
			case 0x05:
				test.Printf(_L("Got SDP_ServiceAttributeResponse\n"));
				partial = BigEndian::Get16(&buf[0]);
				partial += 2;
				continuationLen = buf[partial];
				break;
			
			case 0x07:
				test.Printf(_L("Got SDP_ServiceSearchAttributeResponse\n"));
				partial = BigEndian::Get16(&buf[0]);
				partial += 2;
				continuationLen = buf[partial];
				break;
			default:

				test.Printf(_L("Got UnknownResponse (0x%x)\n"), buf[0]);
				continuationLen = 0;	// create a dummy non-continuation
				break;
			}
		continutations++;

		request.Zero();
		request.Append(aReqData, aReqLen-1);
		request.Append(&buf[partial], continuationLen+1);  //1 for continuation len
		CleanupStack::PopAndDestroy(/*responseHBuf*/);
		} while (continuationLen != 0);

	
	delete requestHBuf;
	return continutations;
}
Beispiel #10
0
DMAD_EXPORT_C HBufC8* TDmAdUtil::BuildUriL(const TDesC8& aUriPath, const TDesC8& aUriSeg)
    {
    HBufC8* uri = HBufC8::NewL(aUriPath.Length() + 1 + aUriSeg.Length());
    TPtr8 uriDesc = uri->Des();
    uriDesc.Copy(aUriPath);
    uriDesc.Append(KDmAdSeparator);
    uriDesc.Append(aUriSeg);
    return uri;
    }
// ----------------------------------------------------------------------------
// TTCPCompMsgEnd::DataReceivedL
// ----------------------------------------------------------------------------
//
void TTCPCompMsgEnd::DataReceivedL( TPtr8 aData, TUint&  aNextLength )
	{
	// panic if sigcomp is not supported in debug mode.leaves in release mode.
	__SIP_ASSERT_LEAVE(	iMsgAssembler.SigComp().IsSupported(), KErrGeneral );
	// panic if received data is not compressed in debug mode.
	// leaves in release mode.
	__SIP_ASSERT_LEAVE(	iMsgAssembler.SigComp().IsSigCompMsg( aData ), 
	                    KErrGeneral );
	// panic if received data is not completed compressed msg in debug mode.
	// leaves in release mode.
	__SIP_ASSERT_LEAVE(	
			iMsgAssembler.SigComp().IsCompleteSigCompMessageL( aData ), 
	        KErrGeneral );
	        
	TUint bytesConsumed( 0 );
	CBufBase* decompressedData = iMsgAssembler.SigComp().DecompressL( 
											aData, bytesConsumed, ETrue);

    TUint dataLen( static_cast<TUint>( aData.Length() ) );
    
    // Whole data was not decompressed and non-decompressed data might
	// be part of next sigcomp message, remember amount of non-decompressed
	// data
	iMsgAssembler.SetUnConsumedBytes( dataLen - bytesConsumed );
		
	if ( bytesConsumed < dataLen )
		{	
    	CleanupStack::PushL(decompressedData);
		aData.Delete(0, bytesConsumed);

		HBufC8* newData = 
		   HBufC8::NewL( decompressedData->Size() + aData.Length() );
	    // copy the msg buffer data and the received data to new data buffer
	    TPtr8 newDataPtr = newData->Des();
	    newDataPtr.Append(decompressedData->Ptr(0));
 	    CleanupStack::PopAndDestroy(decompressedData);
	    newDataPtr.Append(aData);
	    // delete all content of received data
	    aData.Delete( 0, aData.Length() );
  	    CleanupStack::PushL(newData);
  	    DecideNextStateL( newDataPtr, aNextLength );
	    CleanupStack::PopAndDestroy(newData);	
		}	
	else if ( bytesConsumed == dataLen )
		{
		CleanupStack::PushL( decompressedData );
		aData.Delete(0, bytesConsumed);	
		TPtr8 decompressedDataPtr = decompressedData->Ptr(0);
	    DecideNextStateL( decompressedDataPtr, aNextLength );
	    CleanupStack::PopAndDestroy( decompressedData );
		}
	else // bytesConsumed > dataLen error happens, reset the state
		{
		delete decompressedData;
		iMsgAssembler.ChangeState( MMsgAssemblerContext::EMsgInit );
		}				
	}
// ----------------------------------------------------------------------------
// CSIPProfileSIMRecord::AddSIPPrefixLC
// ----------------------------------------------------------------------------
//
HBufC8* CSIPProfileSIMRecord::AddSIPPrefixLC( const TDesC8& aValue )
    {
    _LIT8(KSIPprefix, "sip:");
    TUint length = KSIPprefix().Length() + aValue.Length();
	HBufC8* temp = HBufC8::NewLC(length);
	TPtr8 appendtemp = temp->Des();
	appendtemp.Append(KSIPprefix);
	appendtemp.Append(aValue);
    return temp;
    }    
EXPORT_C TInt CSenSoapMessage2::AddSecurityTokenL(const TDesC8& aNewToken)
    {
    TLSLOG_L(KSenMessagesLogChannel, KMinLogLevel, "CSenSoapMessage2::AddSecurityTokenL(aNewToken)");
    TXmlEngElement element = AsElementL();
    RSenDocument document = AsDocumentL();
    TXmlEngElement soapHeader = HeaderL();
    TXmlEngElement wsSecurityHeader;

    // Create <wsse:Security> element into wrong place
    // <=> into a root element = Envelope.
    // <S:Envelope>
    //   ...
    //   <wsse:Security>
    // That's because we don't want following search to find
    // this new header inside <S:Header> element.
    CSenWsSecurityHeader2* pHeader = NewSecurityHeaderLC(NULL, document, element);
    RXmlEngNodeList<TXmlEngElement> list;
    CleanupClosePushL(list);
    soapHeader.GetElementsByTagNameL(list, KSecurityName,
                                           pHeader->XmlNs());
                                          
    if ( !list.HasNext() )
        {
        // <wsse:Security> element was not found from <S:Header> element.
        // => Add new header by moving header from (root) <S:Envelope>
        //    element into <S:Header> element.
        wsSecurityHeader = pHeader->ExtractElement();
        wsSecurityHeader.MoveTo(soapHeader);
        }
    else
        {
        // <wsse:Security> element was found from <S:Header> element.
        // => Delete new header element from SoapMessage DOM tree by
        //    removing header from (root) <S:Envelope> element.
        wsSecurityHeader = pHeader->ExtractElement();
        wsSecurityHeader.Remove();
        
        // Select found <wsse:Security> element to be edited
        wsSecurityHeader = list.Next();
        }
        
    CleanupStack::PopAndDestroy(&list);

    CleanupStack::PopAndDestroy(); // pHeader // safe to delete

    TPtrC8 content = wsSecurityHeader.Text();
    HBufC8* pContent = HBufC8::NewLC( content.Length() + aNewToken.Length() );
    TPtr8 ptrContent = pContent->Des();
    ptrContent.Append(content);
    ptrContent.Append(aNewToken);
    wsSecurityHeader.SetTextNoEncL(*pContent);
    CleanupStack::PopAndDestroy(pContent);    

    return KErrNone;
    }
void XQAccessPointManagerPrivate::asciiToHex(const TDesC8& aSource, 
                                               HBufC8*& aDest)
{
    _LIT(hex, "0123456789ABCDEF");
    TInt size = aSource.Size();
    TPtr8 ptr = aDest->Des();
    for (TInt ii = 0; ii < size; ii++) {
        TText8 ch = aSource[ii];
        ptr.Append( hex()[(ch/16)&0x0f] );
        ptr.Append( hex()[ch&0x0f] );
    }
}
void CQName::ConstructL(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri)
    {
	_LIT8(KColon, ":"); 
    iName = aName.AllocL();
    iPrefix = aPrefix.AllocL();
    iUri = aUri.AllocL();
    iQName = HBufC8::NewL( aPrefix.Length() + KColon().Length() + aName.Length() );
    TPtr8 qname = iQName->Des();
    qname.Append( aPrefix );
    qname.Append( KColon );
    qname.Append( aName );
    }
// -----------------------------------------------------------------------------
// ConvertAsciiToHex
// -----------------------------------------------------------------------------
//
void CHssIapHandler::ConvertAsciiToHex( const TDes8& aSource, 
                                                HBufC8*& aDest )
    {
    DEBUG("CHssIapHandler::ConvertAsciiToHex");
    _LIT( hex, "0123456789ABCDEF" );
    TInt size = aSource.Size();
    TPtr8 ptr = aDest->Des();
    for ( TInt ii = 0; ii < size; ii++ )
        {
        TText8 ch = aSource[ii];
        ptr.Append( hex()[(ch/16)&0x0f] );
        ptr.Append( hex()[ch&0x0f] );
        }
    }
// ==========================================================================
// METHOD:  HexDump
//
// DESIGN:  
// ==========================================================================
void CLogFileHandler::HexDump( const TDesC8& /*aClassName*/,
                               const TDesC8& /*aFuncName*/,
                               const TDesC8& aBuffer )
    {
	TInt remainingLength = aBuffer.Length();
	TInt i = 0;
	
	while( remainingLength > 0 )
		{
        const TInt KHexDumpWidth=32;
		TInt n = Min( KHexDumpWidth, remainingLength );
		
		// Add the starting byte number.
        _LIT8(KFirstFormatString,"%04x : ");
		iFormatBuffer8.Format(KFirstFormatString, i);
		
		// Add hex values.
		TInt j;
		for (j=0; j<n; j++)
		    {		    
            _LIT8(KSecondFormatString,"%02x ");
			iFormatBuffer8.AppendFormat(KSecondFormatString, aBuffer[i+j]);
		    } // end for
			
        // Fill in incomplete lines.			
		while (j<KHexDumpWidth)
		    {		    
            _LIT8(KThreeSpaces,"   ");
			iFormatBuffer8.Append(KThreeSpaces);
			j++;
		    } // end while
		    
		// Add text representation.
        _LIT8(KTwoSpaces," ");
		iFormatBuffer8.Append(KTwoSpaces);
		for (j=0; j<n; j++)
		    {		    
            _LIT8(KThirdFormatString,"%c");
			iFormatBuffer8.AppendFormat( KThirdFormatString, aBuffer[i+j] );
		    } // end for
		
		iOutputBuffer.SetLength( 0 );		
		TRAP_IGNORE( WriteLineL( iFormatBuffer8 ) );
		
		remainingLength -= n;
		i += n;
		
		} // end while
		    
    } // END HexDump
void CObexAuthenticator::GenerateResponseL(const TDesC8& aPasswd, const TNonce& aNonce, TRequestDigest& aRequestDigest)
	{
	//work out the length of buffer we need
	TInt buflen = aNonce.Length() + KColonCharacter().Length() + aPasswd.Length();
	HBufC8* buf = HBufC8::NewLC(buflen);
	TPtr8 ptr = buf->Des();
	ptr.Zero();
	ptr.Append(aNonce);
	ptr.Append(KColonCharacter);
	ptr.Append(aPasswd);
	iMD5->Reset();
	aRequestDigest.Append(iMD5->Hash(*buf));

	CleanupStack::PopAndDestroy();//buf
	}
EXPORT_C void CSenWsSecurityHeader::BaseConstructL()
    {
    // create and push pQualifiedName
    HBufC8 *pQualifiedName = HBufC8::NewLC(XmlNsPrefix().Length()+
                                        KColon().Length() +
                                        KSecurityName().Length());

    TPtr8 qualified = pQualifiedName->Des();
    qualified.Append(XmlNsPrefix());
    qualified.Append(KColon);
    qualified.Append(KSecurityName);
    CSenBaseFragment::BaseConstructL(XmlNs(), KSecurityName, qualified);

    CleanupStack::PopAndDestroy(); // pQualifiedName
    }
// -----------------------------------------------------------------------------
// CMccCodecRed::SetRedCodecs
// Set the payload types used in redundancy
// -----------------------------------------------------------------------------
//
void CMccCodecRed::SetRedPayloadsL( RArray<TUint>& aRedPayloads )
    {
    iRedPayloads.Reset();
    TInt i;
    for( i = 0; i < aRedPayloads.Count(); i++ )
        {
        iRedPayloads.AppendL( aRedPayloads[ i ] );  
        }
    
    // Convert parsed payload formats back to string and set
    // the iFmtpAttr variable
    const TInt KCharsPerPayload( 4 );
    delete iFmtpAttr;
    iFmtpAttr = NULL;
    iFmtpAttr = HBufC8::NewL( iRedPayloads.Count() * KCharsPerPayload );
    
    TPtr8 descPtr = iFmtpAttr->Des();
    for( i = 0; i < iRedPayloads.Count(); i++ )
        {
        descPtr.AppendNum( static_cast<TUint64>( iRedPayloads[i] ), EDecimal );
        descPtr.Append( KCharSlash );       
        }   
    
    // Remove the last slash character
    descPtr.SetLength( descPtr.Length() - 1 );  
    }
HBufC8* CValidateTest::ReadFilesLC(CDesCArray& aServerCerts)
	{
	TInt count = aServerCerts.MdcaCount();
	TInt totalSize = 0;
	TInt i;

	for (i = 0; i < count; i++)
		{
		TPtrC filename = aServerCerts.MdcaPoint(i);
		RFile file;
		TRAPD(err, file.Open(iFs, filename, EFileRead));
		if(err != KErrNone)
			{
			HBufC *failedToLoad = filename.AllocLC();
			SetScriptError(EFileNotFound, failedToLoad->Des());
			CleanupStack::PopAndDestroy(2);//fsclose, fileClose	
			return(NULL);
			};
		CleanupClosePushL(file);
		TInt size;
		file.Size(size);
		CleanupStack::PopAndDestroy(1);	//	fileClose
		totalSize += size;
		}

	HBufC8* res = HBufC8::NewLC(totalSize);
	TPtr8 pRes = res->Des();
	for (i = 0; i < count; i++)
		{
		HBufC8* cert = ReadFileLC(aServerCerts.MdcaPoint(i));
		pRes.Append(cert->Des());
		CleanupStack::PopAndDestroy();//cert
		}
	return res;
	}
// ---------------------------------------------------------------------------
//Provides implementation required for aborting testing
// ---------------------------------------------------------------------------
//
void COMASuplPositionVelocityTest::TestingAborted(const TDesC8& /*aInfo*/)
{
    if(iCallBack)
    {
        HBufC8* infoBuf = NULL;
        TRAPD(err, infoBuf = HBufC8::NewL(KPositionVelocityTestAborted().Length() + KExtraBuffer));
        if(err != KErrNone)
        {
            iCallBack->TestingAborted(KPositionVelocityTestAborted);
        }
        else
        {
            TPtr8 info = infoBuf->Des();
            info.Copy(KPositionVelocityTestAborted);
            info.Append(KSessionId);
            info.AppendNum(iTestNo);
            iCallBack->TestingAborted(info);
        }
        delete infoBuf;
        iCallBack->UpdateSessionTestSummary(iInfo, iWarning, iError);
    }
    else
    {
        Cancel();
        iTestHandler->Cancel();
        iTestingStatus = ETestAborted;
        CActiveScheduler::Stop();
        iError++;
        iLogger->WriteLine(KPositionVelocityTestAborted, iTestNo);
    }
}
// ---------------------------------------------------------------------------
// Provides default implementation required for cancellation of testing
// ---------------------------------------------------------------------------
//
void COMASuplPosTesterCategory::TestingCancelled(const TDesC8& aInfo)
	{
	if(iCallBack)
		{
		HBufC8* infoBuf = NULL;
		TRAPD(err, infoBuf = HBufC8::NewL(aInfo.Length() + KExtraBuffer));
		if(err != KErrNone)
			{
			iCallBack->TestingCancelled(aInfo);
			}
		else
			{
			TPtr8 info = infoBuf->Des();
			info.Copy(aInfo);
			info.Append(KSessionId);
			info.AppendNum(iTestNo);
			iCallBack->TestingComplete(info);
			}
		delete infoBuf;
		iCallBack->UpdateSessionTestSummary(iInfo, iWarning, iError);
		}
	else
		{
		Cancel();
		iTestHandler->Cancel();
		iTestingStatus = ETestCancelled;
		CActiveScheduler::Stop();
		iInfo++;
		iLogger->WriteLine(aInfo, iTestNo);
		}
	
	}
// -----------------------------------------------------------------------------
// CCapInfo::WriteL(const TDesC& aText)
// Writes one element to capability buffer.
// -----------------------------------------------------------------------------
//
void CCapInfo::WriteL(const TDesC& aText)
    {
    if (aText.Length() > iBuf.MaxLength())
        {
        User::Leave(KErrTooBig);
        }
        

    iBuf=aText;
    iBuf.Trim();
    FormatElement(iBuf);
    TPtr8 ptr = iHeapBuf->Des();

    if ( iBuf.Length()+2 > ptr.MaxLength() )
        {
        User::Leave(KErrTooBig);
        }
        
    //unicode conversion
    HBufC8* convBuf = HBufC8::NewLC( iBuf.Size() );
    TPtr8 convPtr = convBuf->Des();
    
    CnvUtfConverter::ConvertFromUnicodeToUtf8(convPtr, iBuf);

    ptr.Copy(convPtr);
    ptr.Append( KLineFeed );  // linefeed
    
    CleanupStack::PopAndDestroy( convBuf );
    
    TInt pos=iCapabilityBuf->Size();
    iCapabilityBuf->InsertL(pos, ptr);

    iBuf=KNullDesC;
    }
// -----------------------------------------------------------------------------
// CSeiForwardPlugin::ReceiveMessageL
// 
// 
// -----------------------------------------------------------------------------
//
void CSeiForwardPlugin::ReceiveMessageL( TInt aChannel, TPtrC8 aMessage )
	{
	RDebug::Print( _L( "EcmtSeiForwardPlugin::ReceiveMessageL: channel = %d" ), aChannel );
	
	HBufC8* buf = HBufC8::NewLC( KMaxMsgPrefixLen + 1 + aMessage.Length() );
	TPtr8 message = buf->Des();
		
	message.Format( KMsg, aChannel );
	message.Append( KBlanco );
	message.Append( aMessage );
		
	CEcmtMessageEvent* m = iMessaging->NewMessageEvent( TUid::Uid( KSEIFORWARDPLUGIN_IMPL_UID ), message );
	
	User::LeaveIfNull( m );
	iMessaging->GetMessageSender()->SendMessage( m );
	}
	void CABDataOwnerCallbackImplementation::GetSnapshotDataL(TDriveNumber /*aDrive*/, TPtr8& aBuffer, TBool& aFinished)
		{
		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::GetSnapshotDataL()", iID.iId);
		aBuffer.Append(KABTestSnapshot());
		
		aFinished = ETrue;
		}
// -----------------------------------------------------------------------------
// Get value for given id.
// -----------------------------------------------------------------------------
//
HBufC8* CConfigurationHandler::GetTokenValue( const TDesC8& aData, 
											  const TDesC8& aKey )
	{
	if( aData.Find(aKey)==KErrNotFound )
		{
		return NULL;
		}

	// id is in the string
	TLex8 lex(aData);

	while( !lex.Eos() )
		{
		TPtrC8 token = lex.NextToken();

		TInt spos = token.Find(aKey);
		if( spos==KErrNotFound )
			{
			continue;
			}

		// key was found return value		
		
		TPtrC8 value = token.Right(token.Length()-aKey.Length()); 

		HBufC8* retval = HBufC8::NewL(value.Length());
		TPtr8 des = retval->Des();
		des.Append(value);
		return retval;
		}
		
	return NULL;
	}
// -----------------------------------------------------------------------------
// CSTSPinConverter::ConvertToBCDL
// Converts gived value to BCD (Binary Coded Desimal) format. In normal case,
// sets each upper nibble to 0. If halfBCD is used, sets each upper nibble to F.
// Returns: aConvertedPIN: Puts converted data into this pointer
// -----------------------------------------------------------------------------
void CSTSPinConverter::ConvertToBCDL(const TDesC& aPinValue,
                                     TPtr8& aConvertedPIN, TBool aHalfBCD)
{

    //verify that each character is a digit
    if (!IsAllDigits(aPinValue))
    {
        User::Leave(KErrCorrupt);
    }
    //encode the characters as BCD (see Section 2) digits: x = BCD(PIN)
    //BCD=Binary Coded Decimal
    TUint8 mask = 0x00;
    if (aHalfBCD)
    {
        //upper nibble
        mask = 0xF0;//IIII0000
    }

    TInt length = aPinValue.Length();
    for (TInt i = 0; i < length; i++)
    {
        TUint8 currentNumber = (TUint8) aPinValue[i];

        //ignore first nibble
        TUint8 firstNibleMask = 0x0F;
        TUint8 firstNibleIgnored = (TUint8)(currentNumber & firstNibleMask);

        TUint8 result = (TUint8)(firstNibleIgnored | mask);

        aConvertedPIN.Append(result);
    }
}
Beispiel #29
0
HBufC8* AlfGcExternalizeL( const RArray<T>& aArray )
    {
    const TInt itemCount = aArray.Count();
    if ( !itemCount)
        {
        return HBufC8::NewL(0);
        }
    
    const T* firstItem = &aArray[0];    
    TPtrC8 arrayPtr( (TUint8*)firstItem, itemCount*sizeof(T) );            
    HBufC8* buffer = HBufC8::NewL( sizeof(TInt) + arrayPtr.Length() );
    TPtr8 ptr = buffer->Des();     
    
    ptr.Append( (const TUint8*)&itemCount, sizeof(TInt) );
    ptr.Append( arrayPtr );    
    return buffer;
    }
static void GenerateInput(TInt aBytes, TPtr8& in)
 	{
 	for (TInt j = 0; j < aBytes; j++)
 		{
 		TInt text('a'+j%25);
 		in.Append(text);
 		}
 	}