예제 #1
0
// -----------------------------------------------------------------------------
// CMceItcSender::ReadArrayL 
// -----------------------------------------------------------------------------
//
CDesC8Array* CMceItcSender::ReadArrayL( TMceIds& aIds,
				                        TMceItcFunctions aITCFunction, 
				                        const TDesC8& aData )
	{
    MCECLI_DEBUG("CMceItcSender::ReadArrayL(inout), Entry");
	
    Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) );
    aIds.iMsgType = KMceNotAssigned;

    CMceMsgTextArray* textArray = new (ELeave) CMceMsgTextArray();
    CleanupStack::PushL( textArray );
    
	HBufC8* arrayBuf = HBufC8::NewLC( KMceMaxSizeInReadStream );
	TPtr8 arrayBufPtr = arrayBuf->Des();
	arrayBufPtr.Copy( aData );
    iITCMsgArgs.Set ( EMceItcArgContext, &arrayBufPtr );
    SendL ( aIds, aITCFunction );

    textArray->DecodeL( *arrayBuf );

    CDesC8Array* array = textArray->iArray;
    
    CleanupStack::PopAndDestroy( arrayBuf );//arrayBuf
    CleanupStack::PopAndDestroy( textArray );//textArray
    
    MCECLI_DEBUG("CMceItcSender::ReadArrayL(inout), Exit");
    return array;
		
	}
예제 #2
0
// -----------------------------------------------------------------------------
// 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;
    }
예제 #3
0
// ---------------------------------------------------------------------------
// Allocates a channel
// ---------------------------------------------------------------------------
//
void CDunIrPlugin::AllocateChannelL()
    {
    FTRACE(FPrint(_L("CDunIrPlugin::AllocateChannelL()")));
    HBufC8* channelName = HBufC8::NewMaxLC( KIrChannelName().Length() );
    TPtr8 channelNamePtr = channelName->Des();
    channelNamePtr.Copy( KIrChannelName );
    iTransporter->AllocateChannelL( &iIrPort,
                                    KDunIrPluginUid,
                                    channelNamePtr,
                                    ETrue );
    iTransporter->AddConnMonCallbackL( &iIrPort,
                                       this,
                                       EDunReaderUpstream,
                                       EFalse );
    iTransporter->AddConnMonCallbackL( &iIrPort,
                                       this,
                                       EDunWriterUpstream,
                                       EFalse );
    iTransporter->AddConnMonCallbackL( &iIrPort,
                                       this,
                                       EDunReaderDownstream,
                                       EFalse );
    iTransporter->AddConnMonCallbackL( &iIrPort,
                                       this,
                                       EDunWriterDownstream,
                                       EFalse );
    iTransporter->IssueTransferRequestsL( &iIrPort );
    CleanupStack::PopAndDestroy( channelName );
    FTRACE(FPrint(_L("CDunIrPlugin::AllocateChannelL() complete")));
    }
// ---------------------------------------------------------------------------
// 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);
		}
	
	}
// ---------------------------------------------------------------------------
//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);
    }
}
예제 #6
0
void CT_DataRGavdp::Read(const TDesC& aSection, const TInt aAsyncErrorIndex)
{
    TPtrC 	inputStr;
    if( GetStringFromConfig(aSection, KFldExpectedData, inputStr))
    {
        if (!iReadExpectBuffer)
            iReadExpectBuffer = HBufC8::NewL(512);
        TPtr8 des = iReadExpectBuffer->Des();
        des.Copy(inputStr);
    }
    else
    {
        if (iReadExpectBuffer)
        {
            delete iReadExpectBuffer;
            iReadExpectBuffer = NULL;
        }
    }

    INFO_PRINTF1(KLogInfoReading);
    iReadBuffer = HBufC8::NewL(512);
    iReadBuffer->Des().SetMax();
    iReadBufferDes.Set(iReadBuffer->Des());

    iSockets[0].Read(iReadBufferDes,iActive->iStatus);
    iActive->Activate(aAsyncErrorIndex);
    IncOutstanding();
}
예제 #7
0
void CDHCPIP6Control::GetRawOptionDataL(TUint aOpCode, TPtr8& aPtr )
	{
	HBufC8* buf = NULL;
	DHCPv6::CDHCPMessageHeaderIP6 msg(buf);
	CleanupClosePushL(msg);
	TPtr8 ptr( const_cast<TUint8*>(iValidMsg.Ptr()), iValidMsg.Length(), iValidMsg.Length() );
	msg.iRecord.ParseL(ptr); //no check necessary
    DHCPv6::COptionNode* pOption = msg.GetOptions().FindOption(aOpCode);
    if (!pOption)
      {
#ifdef SYMBIAN_TCPIPDHCP_UPDATE
      // The option is not found try to get the option through DHCP INFORM message 
      //by calling RequestInformOrCompleteCallL
      CleanupStack::PopAndDestroy();
	  TUint opcode = aOpCode;
	  TPtr8 optPtr(reinterpret_cast<TUint8*>(&opcode),1,1);
	  return(RequestInformOrCompleteCallL(optPtr));
#else	  
	  User::Leave(KErrNotFound);  
#endif //SYMBIAN_TCPIPDHCP_UPDATE	  
      }
    ptr.Set(pOption->GetBodyDes());
    if (ptr.Length() > aPtr.MaxLength())
      {
      User::Leave(KErrOverflow);
      }
    aPtr.Copy(ptr);
    CleanupStack::PopAndDestroy();
	}
예제 #8
0
void CRFC3984Encode::PayloadizeFrameSingleNALModeL(
    TDes8& aBuffer, 
    TUint32 /*aTimeStamp*/, 
    TUint32& /*aMarkerBit*/, 
    TInt& aNalCount )
    {
	// This implementation assumes the NAL units for one frame are seperated
	// by 0x001 or 0x0001 start codes 
    
    // Resetting iBufferIndex for this new frame, always do this for new frame
    // because this is used to find start codes within one frame
    iBufferIndex = 0; 	
    
    TInt startIndex = 0;	// holds first byte-index of NALU
    TInt endIndex = 0;		// hold byte-index of next to last byte of NALU
    TInt size = 0;
    HBufC8 * pBuffer = 0;
    
    // loop to find and packetize all NAL Units in the frame
	while ( ETrue )
	    {
		startIndex = TMccCodecInfo::FindAvcNaluStart( iBufferIndex, aBuffer );
		if ( KErrNotFound == startIndex )
		    {
			break;
		    }
		
		endIndex = TMccCodecInfo::FindAvcNaluEnd( iBufferIndex, aBuffer );
		if ( KErrNotFound == endIndex )
		    {
			break;
		    }
		
		if ( startIndex == endIndex )
		    {
			break;
		    }
				
		// finding size of the NAL unit
		size = endIndex - startIndex;
		
		__ASSERT_ALWAYS( size > 0, User::Leave( KErrGeneral ) ); // some flaw in logic
		
		pBuffer = HBufC8::NewLC( size );
		
		TPtr8 aPtr = pBuffer->Des();
		// Now the size and start Index is known, copying the data
		
		aPtr.Copy( aBuffer.Mid( startIndex, size ) );
		
		// Now inserting pointer
		iPayloadizedBuffers.InsertL( pBuffer, iNalCount );
		CleanupStack::Pop( pBuffer );
		pBuffer = NULL;	// ownership transferred
		iNalCount++;
	    }
    
    aNalCount = iNalCount;
    }
예제 #9
0
HBufC8* QNFCNdefUtility::QString2HBufC8L(const QString& qstring)
    {
    TPtrC wide(static_cast<const TUint16*>(qstring.utf16()),qstring.length());
    HBufC8* newBuf = HBufC8::NewL(wide.Length());
    TPtr8 des = newBuf->Des();
    des.Copy(wide);
    return newBuf;
    }
/**
 * Handle the rightSoftKeyPressed event.
 * @return ETrue if the command was handled, EFalse if not
 */
TBool Csymbian_ua_guiSettingItemListView::HandleControlPaneRightSoftKeyPressedL (TInt aCommand)
{
    TUint8 domain[256] = {0};
    TPtr8 cDomain (domain, sizeof (domain));
    TUint8 user[64] = {0};
    TPtr8 cUser (user, sizeof (user));
    TUint8 pass[64] = {0};
    TPtr8 cPass (pass, sizeof (pass));

    cDomain.Copy (iSettings->Ed_registrar());
    cUser.Copy (iSettings->Ed_user());
    cPass.Copy (iSettings->Ed_password());
    symbian_ua_set_account ( (char*) domain, (char*) user, (char*) pass, false, false);

    AppUi()->ActivateLocalViewL (TUid::Uid (ESymbian_ua_guiContainerViewId));
    return ETrue;
}
예제 #11
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;
    }
예제 #12
0
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::WriteClosingTags
 // Close GPX file
 // ---------------------------------------------------------------------------
void CGpxConverterAO::WriteClosingTags()
	{
	LOG("CGpxConverterAO::WriteClosingTags ,begin");
	TPtr8 writePtr = iWriteBuf->Des();
	
	// end segment
	if ( !iFixLost )
		{
		writePtr.Copy( KTagSegmentEnd );	
		iGpxFile.Write( writePtr );
		}

	// closing tags
	writePtr.Copy( KTagTrackEnd );
	writePtr.Append( KTagGpxEnd );

	iGpxFile.Write( writePtr );
	LOG("CGpxConverterAO::WriteClosingTags ,end");
	}
예제 #13
0
// ---------------------------------------------------------------------------
// Allocates a free channel
// ---------------------------------------------------------------------------
//
void CDunBtPlugin::AllocateChannelL( TBool& aNoFreeChans,
                                     TBtCleanupInfo& aCleanupInfo )
    {
    FTRACE(FPrint(_L("CDunBtPlugin::AllocateChannelL()")));
    // iDataSocket has new data socket information so copy it to iBTPorts
    TBtPortEntity* foundEntity = NULL;
    TInt foundIndex = GetFirstFreePort( foundEntity );
    if ( !foundEntity )  // free not found so add new
        {
        TBtPortEntity newEntity;
        iBTPorts.AppendL( newEntity );
        aCleanupInfo.iNewEntity = ETrue;
        aCleanupInfo.iEntityIndex = iBTPorts.Count() - 1;
        foundEntity = &iBTPorts[ aCleanupInfo.iEntityIndex ];
        }
    else  // free found so change array
        {
        aCleanupInfo.iNewEntity = EFalse;
        aCleanupInfo.iEntityIndex = foundIndex;
        foundEntity = &iBTPorts[ foundIndex ];
        }
    foundEntity->iChannelNum = iEntity.iChannelNum;
    foundEntity->iBTPort = iEntity.iBTPort;
    RSocket* socket = &foundEntity->iBTPort;
    HBufC8* channelName = HBufC8::NewMaxLC( KBtChannelName().Length() +
                          KCharactersInTInt );
    TPtr8 channelNamePtr = channelName->Des();
    channelNamePtr.Copy( KBtChannelName );
    channelNamePtr.AppendNum( iEntity.iChannelNum );
    iTransporter->AllocateChannelL( socket,
                                    KDunBtPluginUid,
                                    channelNamePtr,
                                    EFalse,
                                    aNoFreeChans );
    iTransporter->AddConnMonCallbackL( socket,
                                       this,
                                       EDunReaderUpstream,
                                       EFalse );
    iTransporter->AddConnMonCallbackL( socket,
                                       this,
                                       EDunWriterUpstream,
                                       EFalse );
    iTransporter->AddConnMonCallbackL( socket,
                                       this,
                                       EDunReaderDownstream,
                                       ETrue );
    iTransporter->AddConnMonCallbackL( socket,
                                       this,
                                       EDunWriterDownstream,
                                       EFalse );
    iTransporter->IssueTransferRequestsL( socket );
    CleanupStack::PopAndDestroy( channelName );
    FTRACE(FPrint(_L("CDunBtPlugin::AllocateChannelL() complete")));
    }
예제 #14
0
void CRFC3984Encode::AddSnaluPacketL( TPtr8 aStart, TInt aSize )
    {
    HBufC8* pBuffer = HBufC8::NewLC( aSize );
	
	TPtr8 pPtr = pBuffer->Des();
	pPtr.Copy( aStart.Ptr(), aSize );
	
	// inserting into the payloadized NAL unit buffer for retreival
	iPayloadizedBuffers.InsertL( pBuffer, iNalCount );
	iNalCount++;
	CleanupStack::Pop( pBuffer );
    }
TInt COpenMAXALTestModule::al_SetDataFormat( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    TInt type;
    TInt contType(0);
    TPtrC mimetype;
    status = aItem.GetNextInt(type);

    switch(type)
        {
        case XA_DATAFORMAT_MIME:
            {
            status = aItem.GetNextString(mimetype);
            if(!status)
                {
                status = aItem.GetNextInt(contType);
                if(!status)
                    {
                    if(m_MimeType)
                        {
                        delete m_MimeType;
                        m_MimeType = NULL;
                        }
                    m_MimeType = HBufC8::NewL(mimetype.Length()+1);
                    TPtr8 desc = m_MimeType->Des();
                    desc.Copy(mimetype);
                    m_Mime.formatType = XA_DATAFORMAT_MIME;
                    m_Mime.mimeType = (XAchar*) desc.PtrZ();
                    m_Mime.containerType = contType;
                    }
                else
                    {
                    status = KErrGeneral;
                    }
                }
            else
                {
                status = KErrGeneral;
                }
            }
            break;
        case XA_DATAFORMAT_PCM:
        case XA_DATAFORMAT_RAWIMAGE:
            break;
        default:
            status = KErrGeneral;
            break;
        }
    return status;
    }
예제 #16
0
/** Writing data 
@param  aPos position to write
@param  aSrc source buffer
@return KErrNone or KErrOverflow in case of an error
*/
TInt CTestProxyDrive::Write (TInt64 aPos, const TDesC8& aSrc)
	{
	__FNLOG ("CTestProxyDrive::Write");

	// TInt64 is not supported by Copy()
	ASSERT(0 == I64HIGH(aPos));
	if (!aSrc.Length())
		{ return KErrNone; }

	if ( (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos)) && (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos) + static_cast<TUint>(aSrc.Length())) )
		{ return KErrOverflow; }

	TPtr8 ptr (&iMediaBuf[I64LOW(aPos)], aSrc.Length(), aSrc.Length());
	ptr.Copy(aSrc);
	return KErrNone;
	}
예제 #17
0
TReal CGpsDataHandler::ParseCoordinateData() {
	TPtr8 pBuffer = iBuffer->Des();
	TReal aAngle;
	TReal aResult = 0.0;
	TInt aFindResult;

	aFindResult = pBuffer.Find(_L8(","));
	if(aFindResult != KErrNotFound) {
		HBufC8* aField = HBufC8::NewL(aFindResult);
		CleanupStack::PushL(aField);
		TPtr8 pField = aField->Des();

		pField.Copy(pBuffer.Ptr(), aFindResult);
		pBuffer.Delete(0, aFindResult+1);

		TLex8 aFieldLex(pField.Ptr());
		if(aFieldLex.Val(aAngle, '.') == KErrNone) {
			TInt32 aDegrees;
			Math::Int(aDegrees, aAngle / 100.0);

			TInt32 aMinutes;
			Math::Int(aMinutes, aAngle - aDegrees * 100);

			TReal aDecimal;
			Math::Frac(aDecimal, aAngle);

			aResult = aDegrees + (aMinutes + aDecimal) / 60.0;

			if(pBuffer[0] == TUint('S') || pBuffer[0] == TUint('W')) {
				aResult = -aResult;
			}

			aFindResult = pBuffer.Find(_L8(","));

			if(aFindResult != KErrNotFound) {
				pBuffer.Delete(0, aFindResult+1);
			}
		}

		CleanupStack::PopAndDestroy();
	}

	return aResult;
}
void CImMobilityLogger::LogFormat(TInt /*aFilePos*/, VA_LIST& /*aList*/, TRefByValue<const TDesC8> /*aFmt*/)
#endif //__IM_MOBILITY_LOGGING
	{
#ifdef __IM_MOBILITY_LOGGING

	if (iFileList.Count() == 0)
		{
		return;
		}

	if (aFilePos >= iFileList.Count())
		{
		aFilePos = KDefaultLog;
		}

	if ((aFilePos == KDefaultLog) && (iDefaultLogFileInUse == EFalse))
		{
		return;
		}

	if (!iFileList[aFilePos].iLoggingOn)
		{
		return;
		}

	iFile = &iFileList[aFilePos].iFile;

	TPtr8 buf = iLogBuffer->Des();
	buf.Zero();

	TTime date;
	date.UniversalTime();
	TBuf<KDateFormatLength> dateString;
	TRAP_IGNORE(date.FormatL(dateString, KTxtLogDateFormat));
	buf.Copy(dateString);

	buf.AppendFormatList(aFmt, aList, this);
	iFile->Write(buf);
	iFile->Write(KTxtCRLF());

#endif //__IM_MOBILITY_LOGGING
	}
예제 #19
0
void CT_DataRGavdp::Send(const TDesC& aSection, const TInt aAsyncErrorIndex)
{
    TPtrC 	inputStr;
    if( GetStringFromConfig(aSection, KFldSendData, inputStr))
    {
        INFO_PRINTF1(KLogInfoSending);
        iSendBuffer = HBufC8::NewL(512);
        TPtr8 des = iSendBuffer->Des();
        des.Copy(inputStr);

        iSockets[0].Write(*iSendBuffer, iActive->iStatus);
        iActive->Activate(aAsyncErrorIndex);
        IncOutstanding();
    }
    else
    {
        ERR_PRINTF2(KLogErrMissingParameter, &KFldSendData());
        SetBlockResult(EFail);
    }
}
예제 #20
0
// -----------------------------------------------------------------------------
// CWimRSASigner::SignMessage()
// Sign some data. The data is hashed before the signature is created using 
// the SHA-1 algorithm.
// -----------------------------------------------------------------------------
//
void CWimRSASigner::SignMessage( const TDesC8& aPlaintext, 
  				                 CRSASignature*& aSignature, 
  				                 TRequestStatus& aStatus )
	{
    if( iDigest )
        {
        delete iDigest;
        iDigest = NULL;
        }
    if( iDigestBuf )
        {
        delete iDigestBuf;
        iDigest = NULL;
        }

	// Hash the data on the client side
	TRAPD( err, iDigest = CSHA1::NewL() );

	if ( err == KErrNone )
		{
	    iDigest->Update( aPlaintext );
	    TRAP( err, iDigestBuf = HBufC8::NewL( iDigest->HashSize() ) );
	    
	    if (err != KErrNone )
	       {
	       TRequestStatus* status = &aStatus;
		     User::RequestComplete( status, err );
	       return;
	    	 }
	    
	    TPtr8 tempPtr = iDigestBuf->Des();
	    tempPtr.Copy( iDigest->Final() );	
	    Sign( *iDigestBuf, aSignature, aStatus );
		}
    else
        {
		TRequestStatus* status = &aStatus;
		User::RequestComplete( status, err );
        }
	}
// ---------------------------------------------------------------------------
// JavaRegUidArrayConverter::GetTUidsL
// ---------------------------------------------------------------------------
//
void JavaRegUidArrayConverter::
GetTUidsL(const TDesC& aValue, RArray<TUid>& aUids)
{
    TInt32 count;

    HBufC8* buf = HBufC8::NewLC(aValue.Length());
    TPtr8 ptr = buf->Des();
    ptr.Copy(aValue);

    RDesReadStream  stream(*buf);
    CleanupClosePushL(stream);

    stream >> count;
    for (TInt i = 0; i < count; i++)
    {
        TUid uidValue;
        stream >> uidValue.iUid;
        aUids.AppendL(uidValue);
    }

    CleanupStack::PopAndDestroy(&stream);
    CleanupStack::PopAndDestroy(buf);
}
예제 #22
0
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::WriteStartingTags
 // Writes header tags for GPX file
 // ---------------------------------------------------------------------------
void CGpxConverterAO::WriteStartingTags()
	{
	LOG("CGpxConverterAO::WriteStartingTags ,begin");
	TPtr8 writePtr = iWriteBuf->Des();
	TPtr formatter = iFormatBuf->Des();
	
	// write starting tags
	writePtr.Copy( KTagXml );
	writePtr.Append( KTagGpxStart );
	iGpxFile.Write( writePtr );
	
	writePtr.Copy( KTagMetaStart );
	formatter.Format( KTagName, &iGpxFileName );
	writePtr.Append( formatter );
	iGpxFile.Write( writePtr );
	
	TTime timeStamp( 0 );
	timeStamp.UniversalTime();
	TDateTime datetime = timeStamp.DateTime();
	
	formatter.Format( KTagTimeStamp, datetime.Year(), datetime.Month() + 1, datetime.Day() + 1,
			datetime.Hour(), datetime.Minute(), datetime.Second() );
	writePtr.Copy( formatter );
	iGpxFile.Write( writePtr );
	
	if ( iBoundaries )
		{
		formatter.Format( KTagBounds, iBoundaries->minLatitude, iBoundaries->minLongitude, 
				iBoundaries->maxLatitude, iBoundaries->maxLongitude );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		}
	writePtr.Copy( KTagMetaEnd );
	iGpxFile.Write( writePtr );
	
	writePtr.Copy( KTagTrackStart );
	iGpxFile.Write( writePtr );
	LOG("CGpxConverterAO::WriteStartingTags ,end");
	}
예제 #23
0
size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry* handle) {
	TSymbianFileEntry* entry = ((TSymbianFileEntry *)(handle));
	TUint32 totsize = size*numItems;
	TPtr8 pointer ( (unsigned char*) ptr, totsize);

	// Nothing cached and we want to load at least KInputBufferLength bytes
	if (totsize >= KInputBufferLength) {
		TUint32 totLength = 0;
		if (entry->_inputPos != KErrNotFound) {
			TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer+entry->_inputPos, entry->_inputBufferLen - entry->_inputPos, KInputBufferLength);
			pointer.Append(cacheBuffer);
			entry->_inputPos = KErrNotFound;
			totLength+=pointer.Length();
			pointer.Set(totLength+(unsigned char*) ptr, 0, totsize-totLength);
		}

		entry->_lastError = entry->_fileHandle.Read(pointer);

		totLength+=pointer.Length();

		pointer.Set((unsigned char*) ptr, totLength, totsize);

	} else {
		// Nothing in buffer
		if (entry->_inputPos == KErrNotFound) {
			TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer, KInputBufferLength);
			entry->_lastError = entry->_fileHandle.Read(cacheBuffer);

			if (cacheBuffer.Length() >= totsize) {
				pointer.Copy(cacheBuffer.Left(totsize));
				entry->_inputPos = totsize;
				entry->_inputBufferLen = cacheBuffer.Length();
			} else {
				pointer.Copy(cacheBuffer);
				entry->_inputPos = KErrNotFound;
			}

		} else {
			TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer, entry->_inputBufferLen, KInputBufferLength);

			if (entry->_inputPos+totsize < entry->_inputBufferLen) {
				pointer.Copy(cacheBuffer.Mid(entry->_inputPos, totsize));
				entry->_inputPos+=totsize;
			} else {

				pointer.Copy(cacheBuffer.Mid(entry->_inputPos, entry->_inputBufferLen-entry->_inputPos));
				cacheBuffer.SetLength(0);
				entry->_lastError = entry->_fileHandle.Read(cacheBuffer);

				if (cacheBuffer.Length() >= totsize-pointer.Length()) {
					TUint32 restSize = totsize-pointer.Length();
					pointer.Append(cacheBuffer.Left(restSize));
					entry->_inputPos = restSize;
					entry->_inputBufferLen = cacheBuffer.Length();
				} else {
					pointer.Append(cacheBuffer);
					entry->_inputPos = KErrNotFound;
				}
			}
		}
	}

	if ((numItems * size) != pointer.Length() && entry->_lastError == KErrNone) {
		entry->_eofReached = ETrue;
	}

	return pointer.Length() / size;
}
TVerdict CSymmetricMacIncrementalWithReplicateStep::doTestStepL()
	{
	//Assume faliure, unless all is successful
	SetTestStepResult(EFail);
		
	INFO_PRINTF1(_L("*** Symmetric Mac - Incremental with Replicate ***"));
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
		
	TPtrC keyPath;
	TPtrC sourcePath;
	TVariantPtrC algorithm;

	if(	!GetStringFromConfig(ConfigSection(),KConfigEncryptKeyPath, keyPath) ||
		!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid, algorithm) ||
		!GetStringFromConfig(ConfigSection(),KConfigSourcePath, sourcePath))
		{
		User::Leave(KErrNotFound);
		}
	
	// Create key 
	TKeyProperty keyProperty;
	CCryptoParams* keyParams = CCryptoParams::NewLC(); 
	
	HBufC8* convertKey = ReadInHexPlainTextL(keyPath);
	CleanupStack::PushL(convertKey);
	
	keyParams->AddL(*convertKey, KSymmetricKeyParameterUid);
	
	CKey* key=CKey::NewL(keyProperty, *keyParams);
	CleanupStack::PushL(key);
	
	//Create a pointer for the Hmac Implementation Object
	CMac* macImpl= NULL;
	
	//Retrieve a Mac Factory Object			
	TRAPD(err,CMacFactory::CreateMacL(macImpl,
										algorithm,
										*key,
										NULL));
				
	if (err != KErrNone)
		{
		CleanupStack::PopAndDestroy(3, keyParams); // keyParams, convertKey, key
		delete macImpl;
		ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Mac Object - %d ***"), err);
		return EFail;
		}
	
	INFO_PRINTF1(_L("Plugin loaded."));
	
	//Push the Mac Implementation Object onto the Cleanup Stack
	CleanupStack::PushL(macImpl);

	RFs fsSession;
	
	User::LeaveIfError(fsSession.Connect());
	CleanupClosePushL(fsSession);

	RFile sourceFile;
	CleanupClosePushL(sourceFile);
	
	//Open the specified source file
	User::LeaveIfError(sourceFile.Open(fsSession,sourcePath, EFileRead));

	TInt sourceLength = 0;
	TInt readPosition = 0;
	TInt readIncrement = 0;
	TBool macComplete = EFalse;
	TBool macReplicated = EFalse;
	TPtrC8 macStr;
	
	CMac* macReplicateImpl = NULL;
	
	User::LeaveIfError(sourceFile.Size(sourceLength));
	
	//Divide the total size of the source file up into individual equal sized blocks to read
	//over several increments
	readIncrement = sourceLength/KDataReadBlocks;
	
	if (readIncrement == 0)
		{
		ERR_PRINTF2(_L("*** Error: Source File must be larger than %d bytes ***"), KDataReadBlocks);
		User::LeaveIfError(KErrNotSupported);
		}

	do 
		{							
		//Create a heap based descriptor to store the data
		HBufC8* sourceData = HBufC8::NewL(readIncrement);
		CleanupStack::PushL(sourceData);
		TPtr8 sourcePtr = sourceData->Des();
		
		//Read in a block of data from the source file from the current position
		err = sourceFile.Read(readPosition,sourcePtr,readIncrement);
		
		HBufC8* convertSrc = ConvertFromHexFormatToRawL(*sourceData);
		CleanupStack::PopAndDestroy(sourceData);
		CleanupStack::PushL(convertSrc);
		
		//Update the read position by adding the number of bytes read
		readPosition += readIncrement;
		
		if(readPosition == readIncrement)
			{
			//Read in the first block from the data file into the Mac implementation object
			if(macReplicated == EFalse)
				{
				macImpl->MacL(*convertSrc);
				INFO_PRINTF2(_L("Intial Mac - Bytes Read: %d"), readPosition);
				}
			else
				{
				macReplicateImpl->MacL(*convertSrc);
				INFO_PRINTF2(_L("Intial Mac (Replicate) - Bytes Read: %d"), readPosition);	
				}
			CleanupStack::PopAndDestroy(convertSrc);
			}
		else if(readPosition >= sourceLength)
			{
			//Reading in the final block, constructs the complete hash value and returns it within a TPtrC8
			macStr.Set(macReplicateImpl->FinalL(*convertSrc));
			
			CleanupStack::PopAndDestroy(convertSrc);
			
			//Sets the Complete Flag to ETrue in order to drop out of the loop
			macComplete = ETrue;
			
			TInt totalRead = (readPosition - readIncrement) + (*sourceData).Length();
			INFO_PRINTF2(_L("Final Mac - Bytes Read: %d"),totalRead);
			}
		//If the read position is half the source length and the implementation
		//object hasn't already been replicated
		else if((readPosition >= sourceLength/2) && (macReplicated == EFalse))
			{
			INFO_PRINTF1(_L("Replicating Mac Object..."));
			macImpl->UpdateL(*convertSrc);
			
			CleanupStack::PopAndDestroy(convertSrc);
			
			//Create a Copy of the existing Mac Object with NO internal message state
			macReplicateImpl = macImpl->ReplicateL();
			
			macReplicated = ETrue;
			
			//Sets the read position back to 0 inorder to restart the file read from the beginning
			readPosition =0;
			CleanupStack::PushL(macReplicateImpl);
			INFO_PRINTF2(_L("*** Mac REPLICATE - Bytes Read: %d ***"), readPosition);
			}
		else
			{
			//Update the message data within the Mac object with the new block
			if(macReplicated == EFalse)
				{
				macImpl->UpdateL(*convertSrc);
				INFO_PRINTF2(_L("Mac Update - Bytes Read: %d"), readPosition);		
				}
			else
				{
				macReplicateImpl->UpdateL(*convertSrc);
				INFO_PRINTF2(_L("Mac Update (Replicate) - Bytes Read: %d"), readPosition);		
				}
			CleanupStack::PopAndDestroy(convertSrc);
			}					
		}while(macComplete == EFalse);

	//Create a NULL TCharacteristics pointer
	const TCharacteristics* charsPtr(NULL);
	
	//Retrieve the characteristics for the mac implementation object
	TRAP_LOG(err, macImpl->GetCharacteristicsL(charsPtr));
	
	//Static cast the characteristics to type TMacCharacteristics
	const TMacCharacteristics* macCharsPtr = static_cast<const TMacCharacteristics*>(charsPtr);
	
	//The mac output size is returned in Bits, divide by 8 to get the Byte size
	TInt macSize = macCharsPtr->iCipherAlgorithmChar->iBlockSize/8;
	HBufC8* macData = HBufC8::NewLC(macSize);
	TPtr8 macPtr = macData->Des();

	macPtr.Copy(macStr);

	//Check that expected data equals the encrypted data
	HBufC8* encryptedFileData = ReadInHexCiphertextL();
	CleanupStack::PushL(encryptedFileData);
			
	if(	!macPtr.Compare(TPtrC8(*encryptedFileData)))
		{
		INFO_PRINTF1(_L("*** Mac - Incremental with Replicate : PASS ***"));
		SetTestStepResult(EPass);	
		}
	else
		{
		ERR_PRINTF2(_L("*** FAIL: Mac Mismatch  ***"), err);
		}						

	CleanupStack::PopAndDestroy(9, keyParams);	// keyParams, convertKey, key, macImpl, &fsSession, &sourceFile, macReplicateImpl, macData, encryptedFileData
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
	return TestStepResult();  
	}
TInt COpenMAXALTestModule::al_SetDataLocator( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    TInt type;

    status = aItem.GetNextInt(type);

    switch(type)
        {
        case XA_DATALOCATOR_URI:
            {
            TPtrC uri;
            if(m_URIName)
                {
                delete m_URIName;
                m_URIName = NULL;
                }
            //status = aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing);
            status = aItem.GetNextString(uri);
            if(!status)
                {
                m_URIName = HBufC8::NewL(uri.Length()+1);
                TPtr8 desc = m_URIName->Des();
                desc.Copy(uri);
                m_Uri.locatorType = XA_DATALOCATOR_URI;
                m_Uri.URI = (XAchar*) desc.PtrZ();
                }
            else
                {
                status = KErrGeneral;
                }
            }
            break;
        case XA_DATALOCATOR_IODEVICE:
            {
            TInt devicetype;
            TUint deviceId;

            status = aItem.GetNextInt(devicetype);
            if(!status)
                {
                status = aItem.GetNextInt(deviceId);
                if(!status)
                    {
                    TInt srcsinktype(0);
                    status = aItem.GetNextInt(srcsinktype);
                    if(!status)
                        {
                        if(srcsinktype == 1)
                            {
                            m_SrcIODevice.deviceID = deviceId;
                            m_SrcIODevice.deviceType = devicetype;
                            m_SrcIODevice.locatorType = XA_DATALOCATOR_IODEVICE;
                            }
                        else
                            {
                            m_SinkIODevice.deviceID = deviceId;
                            m_SinkIODevice.deviceType = devicetype;
                            m_SinkIODevice.locatorType = XA_DATALOCATOR_IODEVICE;
                            }
                        }
                    else
                        {
                        status = KErrGeneral;
                        }
                    }
                else
                    {
                    status = KErrGeneral;
                    }
                }
            else
                {
                status = KErrGeneral;
                }
            }
            break;
        case XA_DATALOCATOR_OUTPUTMIX:
        case XA_DATALOCATOR_NATIVEDISPLAY:
        case XA_DATALOCATOR_ADDRESS:
            break;
        default:
            status = KErrGeneral;
            break;
        }
    return status;
    }
예제 #26
0
TVerdict CPluginLoadStep::doTestStepL()
	{
	
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
	
  	if (TestStepResult()==EPass)
		{
		//Assume faliure, unless all is successful
		SetTestStepResult(EFail);
		
		TPtrC encryptKey;
		TVariantPtrC keyType;
		TVariantPtrC algorithm;
		TVariantPtrC operationMode;
		TVariantPtrC paddingMode;
		TBool ruleSelectorToggle = EFalse;
		
		
		if(	!GetStringFromConfig(ConfigSection(),KConfigEncryptKey,encryptKey) || 
			!GetStringFromConfig(ConfigSection(),KConfigEncryptKeyType,keyType) ||
			!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid, algorithm) || 
			!GetStringFromConfig(ConfigSection(),KConfigOperationMode, operationMode) ||
			!GetStringFromConfig(ConfigSection(),KConfigPaddingMode, paddingMode ) ||
			!GetBoolFromConfig(ConfigSection(),KConfigRuleSelectorToggle, ruleSelectorToggle ))
			{
			ERR_PRINTF1(_L("** Error: Failed to Load DoStep() Configuration Parameters **"));
			User::Leave(KErrNotFound);
			}
		else
			{
			//Convert encryption key to an 8 Bit Descriptor
			HBufC8* keyStr = HBufC8::NewLC(encryptKey.Length());
			TPtr8 keyStrPtr = keyStr->Des();

			keyStrPtr.Copy(encryptKey);
			
			//Create an new CryptoParams object to encapsulate the key type and secret key string
			CCryptoParams* keyParams = CCryptoParams::NewL();
			CleanupStack::PushL(keyParams);
			keyParams->AddL(*keyStr,keyType);

			//Create Key Object
			TKeyProperty keyProperty;
			CKey* key=CKey::NewL(keyProperty,*keyParams);
			CleanupStack::PushL(key);
			
			//***** Determine whether to set the Rule Selector *****
			
			CRuleSelector* ruleSelector = NULL;
			
			if(ruleSelectorToggle)
				{
				//Create Rule Selection Rules Object
				CSelectionRules* rules = CSelectionRules::NewL();
				CleanupStack::PushL(rules);
				
				//Create Rule Selector Object	
				ruleSelector = CRuleSelector::NewL(rules);
				CleanupStack::Pop(rules);
				CleanupStack::PushL(ruleSelector);

				//Set the Selector Passing in a pointer to the Default Selector and SPI State	
				CCryptoSpiStateApi::SetSelector(ruleSelector);	
				}
				
			//******************************************************

			// Create a Symmetric Cipher with the values from the ini file
			CryptoSpi::CSymmetricCipher * impl = NULL;	
	
			TRAPD(err,CSymmetricCipherFactory::CreateSymmetricCipherL(impl,
															algorithm,
															*key,
															KCryptoModeEncryptUid,
															operationMode,
															paddingMode,
															NULL));

			if(impl && (err==KErrNone))
				{
				INFO_PRINTF1(_L("Successful Implementation Object Load..."));
				
				CleanupStack::PushL(impl);
				
				//Define a pointer of type TCharacteristics in order to store the appropriate
				//encryption object's characterisctics
				const TCharacteristics* characteristics(NULL);
					
				//Retrieve the characteristics for the symmetric cipher implementation object
				TRAP_LOG(err, impl->GetCharacteristicsL(characteristics));
				
				TVariantPtrC exAlgorithmUid;
				TVariantPtrC exImplementationUid;
						
				if(!GetStringFromConfig(ConfigSection(),KConfigExAlgorithmUid,exAlgorithmUid) ||
					!GetStringFromConfig(ConfigSection(),KConfigExImplementationUid,exImplementationUid))
					{
					ERR_PRINTF1(_L("** .INI Error: Expected Algorithm Arguments Not Located **"));
					SetTestStepResult(EFail);
					}
				else
					{
					INFO_PRINTF1(_L("Checking Plug-in Selection..."));
					
					CPluginCharsChecker* pluginCheck = CPluginCharsChecker::NewLC();
					
					TPtrC errorMessage;
					
					//Perform plug-in Check
					if(pluginCheck->checkSelectedPlugin(characteristics,
														exAlgorithmUid,
														exImplementationUid,
														errorMessage))
						{
						INFO_PRINTF1(_L("** PASS: Expected Plugin Loaded Successfully **"));
						SetTestStepResult(EPass);	
						}
					else
						{
						ERR_PRINTF2(_L("** FAIL: Unexpected Plugin Implementation Loaded - %S **"),&errorMessage);
						}
					
					CleanupStack::PopAndDestroy(pluginCheck);
				
					}
					
				CleanupStack::PopAndDestroy(impl);
				
				
				}
			else
				{
				ERR_PRINTF2(_L("*** FAIL: Implementation Object Load Failure ***"), err);
				SetTestStepResult(EFail);
				}
				
			if(ruleSelectorToggle)
				{
				//Set the Selector Passing in a pointer to the Default Selector and SPI State	
				CCryptoSpiStateApi::UnsetSelector();	
				
				CleanupStack::PopAndDestroy();
				}
			
			CleanupStack::PopAndDestroy(3,keyStr);	
			}
		
		}
	else
		{
		ERR_PRINTF1(_L("*** FAIL: Test Case Initialistion Failure ***"));	
		}
	
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
	
	return TestStepResult();
	}
// -----------------------------------------------------------------------------
// CMCETestUIEngineOutRefer::ConstructL()
// -----------------------------------------------------------------------------
//
void CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineProfile& /*aProfile*/)
    {
 
     /////////////////////
    //
    // TODO: After implementing wrappers for streams, sinks and sources 
    //       this function should be refactored to make use of them. That will 
    //       also simplify the function to some extent.
    //
    //////////////////////
    
 
    BaseConstructL();
    if(iProfile )
    	{
    	FillProfileRegistrar();
    
    if(ReferParamsL(iReferParams))
    	{
    	// Solve recipient
	    CMCETestUIQuestionDataQuery* question = 
		    CMCETestUIQuestionDataQuery::NewLC();
		question->SetCaptionL( KUserQuestionInputRecipient );
		question->SetDefaultValueL(iReferParams.iRecipentAddress  );
		question->SetAnswerL( iReferParams.iRecipentAddress  );
		TBufC8<100> recipient( question->Answer8() );
		
		CleanupStack::PopAndDestroy( question );
		//solve referTo
		
		CMCETestUIQuestionDataQuery* questionreferto = 
		    CMCETestUIQuestionDataQuery::NewLC();
		questionreferto->SetCaptionL( KUserQuestionInputReferTo );
		questionreferto->SetDefaultValueL(iReferParams.iReferTo  );
		questionreferto->SetAnswerL( iReferParams.iReferTo  );
		TBufC8<100> referTo( questionreferto->Answer8() );
		
		CleanupStack::PopAndDestroy( questionreferto );
	   // solve originator
	   
	   if ( iReferParams.originator.Compare(KNone))
	   	{
		   	HBufC8* orig8 = HBufC8::NewL(iReferParams.originator.Length());
		   	TPtr8 ptr = orig8->Des();
		    ptr.Copy(iReferParams.originator);
		    // Create OutRfer
		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
		       	iEngine.MCEManager(), 
			    iProfile->Profile(),
			    recipient,referTo);
			CleanupStack::PushL(outRefer);
		    CleanupStack::Pop( outRefer );
			iRefer = outRefer;
			iOutRefer = outRefer;        
	   	}
	   else 
	   	{
		   	// Create OutEvent
		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
		       iEngine.MCEManager(),
		       iProfile->Profile(),
			   recipient,referTo );
			CleanupStack::PushL(outRefer);
		    CleanupStack::Pop( outRefer );
			iRefer = outRefer;
			iOutRefer = outRefer;
	   	}
	    // Get identity
	    iId = iEngine.NextOutReferId();
    	}
    	}
    
    
    }
예제 #28
0
void CT_DataRGavdp::DoCmdSendSecurityControl(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
{
    TBool	dataOk=ETrue;

    TSEID* SEID;
    if ( !CT_BTUtil::GetSEIDL(*this, aSection, KFldSEID, SEID) )
    {
        dataOk=EFalse;
        ERR_PRINTF2(KLogErrMissingParameter, &KFldSEID());
        SetBlockResult(EFail);
    }

    TPtrC 	inputStr;
    HBufC8 *securityData = HBufC8::NewL(512);
    if( GetStringFromConfig(aSection, KFldSecurityData, inputStr))
    {
        TPtr8 des = securityData->Des();
        des.Copy(inputStr);
    }
    else
    {
        dataOk=EFalse;
        ERR_PRINTF2(KLogErrMissingParameter, &KFldSecurityData());
        SetBlockResult(EFail);
    }

    if( GetStringFromConfig(aSection, KFldExpectedResponseData, inputStr))
    {
        if (!iExpectedResponseSecurityData)
            iExpectedResponseSecurityData = HBufC8::NewL(512);
        TPtr8 des = iExpectedResponseSecurityData->Des();
        des.Copy(inputStr);
    }
    else
    {
        dataOk=EFalse;
        ERR_PRINTF2(KLogErrMissingParameter, &KFldExpectedResponseData());
        SetBlockResult(EFail);
        if (iExpectedResponseSecurityData)
        {
            delete iExpectedResponseSecurityData;
            iExpectedResponseSecurityData = NULL;
        }
    }

    if (!ReadExpectedEventsFromConfig(aSection))
    {
        dataOk = EFalse;
        SetBlockResult(EFail);
    }

    if ( dataOk )
    {
        INFO_PRINTF1(KLogInfoCmdSendSecurityControl);
        SetEventOutstanding();
        iCmdIndex = aAsyncErrorIndex;
        iRGavdp->SendSecurityControl(*SEID, *securityData);
    }

    delete 	securityData;
}
예제 #29
0
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::WriteItemToFile
 // Writes single trackpoint to GPX file
 // ---------------------------------------------------------------------------
void CGpxConverterAO::WriteItemToFile()
	{
	LOG("CGpxConverterAO::WriteItemToFile ,begin");
	TTime timeStamp;
	
	TPtr8 writePtr = iWriteBuf->Des();
	TPtr formatter = iFormatBuf->Des();
	
	if ( Math::IsNaN(iTempItem.iLatitude) || Math::IsNaN(iTempItem.iLongitude) )
		{
		if ( !iFixLost )
			{
			writePtr.Copy( KTagSegmentEnd );
			iGpxFile.Write( writePtr );
			iFixLost = ETrue;
			}
		}
	else
		{
		if ( iFixLost )
			{
			writePtr.Copy( KTagSegmentStart );
			iGpxFile.Write( writePtr );
			iFixLost = EFalse;
			}
		
		// write single track point
		// coordinates
		formatter.Format( KTagTrkPointStart, iTempItem.iLatitude, iTempItem.iLongitude );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		// elevation
		if ( !Math::IsNaN( iTempItem.iAltitude ))
			{
			formatter.Format( KTagElevation, iTempItem.iAltitude );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
		// course
		if ( !Math::IsNaN( iTempItem.iCourse ))
			{
			formatter.Format( KTagCourse, iTempItem.iCourse );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}

		timeStamp = iTempItem.iTimeStamp;
		TDateTime datetime = timeStamp.DateTime();
		
		formatter.Format( KTagTimeStamp, datetime.Year(), datetime.Month() + 1, datetime.Day() + 1,
				datetime.Hour(), datetime.Minute(), datetime.Second() );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		
		if ( !Math::IsNaN( iTempItem.iAltitude ))
			{
			writePtr.Copy( KTagFix3D );
			iGpxFile.Write( writePtr );
			}
		else
			{
			writePtr.Copy( KTagFix2D );
			iGpxFile.Write( writePtr );
			}

		// number of satellites
		formatter.Format( KTagSatellites, iTempItem.iNumSatellites );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );

		// accuracy (hdop, vdop)
		if ( !Math::IsNaN( iTempItem.iHdop ))
			{
			formatter.Format( KTagHdop, iTempItem.iHdop );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
		if ( !Math::IsNaN( iTempItem.iVdop ))
			{
			formatter.Format( KTagVdop, iTempItem.iVdop );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
	
		// end track point
		writePtr.Copy( KTagTrkPointEnd );
		iGpxFile.Write( writePtr );
		}
	LOG("CGpxConverterAO::WriteItemToFile ,end");
	}
TVerdict CPluginCharsCommonStep::doTestStepL()
	{
	
	INFO_PRINTF1(_L("Plugin Characteristics - Common Chracteristics"));
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
		
	if (TestStepResult()==EPass)
		{
		
		//Assume faliure, unless all is successful
		SetTestStepResult(EFail);
		
		TPtrC encryptKey;
		TVariantPtrC keyType;
		TVariantPtrC algorithmUid;
		TVariantPtrC cryptoMode;
		TVariantPtrC operationMode;
		TVariantPtrC paddingMode;
		
		//Each of the individual parameters required to create the Symmetric Cipher object
		//are read in from the specified INI configuration file	
		if(!GetStringFromConfig(ConfigSection(),KConfigEncryptKey,encryptKey) || 
			!GetStringFromConfig(ConfigSection(),KConfigEncryptKeyType,keyType) ||
			!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
			!GetStringFromConfig(ConfigSection(),KConfigCryptoMode,cryptoMode) ||
			!GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationMode) ||
			!GetStringFromConfig(ConfigSection(),KConfigPaddingMode,paddingMode))
			{
			ERR_PRINTF1(_L("** .INI Error: Symmetric Cipher Arguments Not Located **"));
			SetTestStepResult(EFail);
			}
		else
			{						
			//Convert encryption key to an 8 Bit Descriptor
			HBufC8* keyStr = HBufC8::NewLC(encryptKey.Length());
			TPtr8 keyStrPtr = keyStr->Des();

			keyStrPtr.Copy(encryptKey);
			
			//Create an new CryptoParams object to encapsulate the key type and secret key string
			CCryptoParams* keyParams = CCryptoParams::NewL();
			CleanupStack::PushL(keyParams);
			keyParams->AddL(*keyStr,keyType);

			//Create Key Object
			TKeyProperty keyProperty;
			CKey* key=CKey::NewL(keyProperty,*keyParams);
			CleanupStack::PushL(key);
			
			CSymmetricCipher* symmetricCipherImpl = NULL;	
				
			TRAPD_LOG(err,CSymmetricCipherFactory::CreateSymmetricCipherL(symmetricCipherImpl,
																algorithmUid,
																*key,
																cryptoMode,
																operationMode,
																paddingMode,
																NULL)); 
			
			
						
			if(symmetricCipherImpl && (err == KErrNone))
				{
				
				CleanupStack::PushL(symmetricCipherImpl);
				
				INFO_PRINTF1(_L("** Successfully Loaded Symmetric Cipher Object **"));
				
				//Define a pointer of type TCharacteristics in order to store the symmetric cipher
				//encryption object's characterisctics	
				const TCharacteristics* chars(NULL);
							
				//Retrieve the characteristics for the symmetric cipher implementation object
				TRAP_LOG(err, symmetricCipherImpl->GetCharacteristicsL(chars));
				
				//Static cast the characteristics to type TCommonCharacteristics
				const TCommonCharacteristics* commonChars = static_cast<const TCommonCharacteristics*>(chars);

				//Retrieve all the Common characteristics that are required for all test cases
				TVariantPtrC exInterfaceUid;
				TVariantPtrC exAlgorithmUid;
				TVariantPtrC exImplementationUid;
				TVariantPtrC exCreatorName;
				TBool exFIPSApproved;
				TBool exHardwareSupported;
				TInt exMaxConcurrencySupported;
				TVariantPtrC exAlgorithmName;
				TInt exLatency;
				TInt exThroughput;
				
				if(!GetStringFromConfig(ConfigSection(),KConfigExInterfaceUid,exInterfaceUid) ||
					!GetStringFromConfig(ConfigSection(),KConfigExAlgorithmUid,exAlgorithmUid) ||
					!GetStringFromConfig(ConfigSection(),KConfigExImplementationUid,exImplementationUid) ||
					!GetStringFromConfig(ConfigSection(),KConfigExCreatorName,exCreatorName) ||
					!GetBoolFromConfig(ConfigSection(),KConfigExFIPSApproved,exFIPSApproved) ||
					!GetBoolFromConfig(ConfigSection(),KConfigExHardwareSupport,exHardwareSupported) ||
					!GetIntFromConfig(ConfigSection(),KConfigExMaxConcurrency,exMaxConcurrencySupported) ||
					!GetStringFromConfig(ConfigSection(),KConfigExAlgorithmName,exAlgorithmName) ||
					!GetIntFromConfig(ConfigSection(),KConfigExLatency,exLatency) ||
					!GetIntFromConfig(ConfigSection(),KConfigExThroughput,exThroughput))
					{
					ERR_PRINTF1(_L("** .INI Error: Expected Common Characteristic Arguments Not Located **"));
					SetTestStepResult(EFail);
					}
				else
					{
			
					INFO_PRINTF1(_L("** Checking common Characteristics.... **"));
					
					CPluginCharsChecker* pluginCheck = CPluginCharsChecker::NewLC();
					
					TPtrC errorMessage;
					
					//******************************************************************
					//Perform Characteristic Checks
					//******************************************************************
					if(pluginCheck->checkCommonCharacteristics(commonChars,
																exInterfaceUid,
																exAlgorithmUid,
																exImplementationUid,
																exCreatorName,
																exFIPSApproved,
																exHardwareSupported,
																exMaxConcurrencySupported,
																exAlgorithmName,
																exLatency,
																exThroughput,
																errorMessage))
						{
						INFO_PRINTF1(_L("** PASS : Common characteristics successfully match expected values **"));
						SetTestStepResult(EPass);	
						}
					else
						{
						ERR_PRINTF2(_L("** FAIL: Characteristic Mismatch - %S **"),&errorMessage);	
						}
						
					CleanupStack::PopAndDestroy(pluginCheck);
					}
				
				CleanupStack::PopAndDestroy(symmetricCipherImpl);
				}
			else
				{
				ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Cipher Object - %d ***"), err);	
				}
				
			CleanupStack::PopAndDestroy(3,keyStr);
			}
		}
						
		
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());	
	return TestStepResult();
	}