TInt CUptCsvGenerator::FillReferenceBuffer(RBuf8& aBufferName, const TInt& aAppendCount, const RArray<TInt64>& aData1Name, const TInt& aData1Count, const RArray<TInt64>& aData2Name, const TInt& aData2Count)
	{
	for(TInt i=0; i!=aAppendCount;i++)
		{
		// first line of data
		for(TInt j=0;j!=aData1Count;j++)
			{
			aBufferName.AppendNum(aData1Name[j]);
			//if(j!=aData1Count-1)
			if(j!=aData1Count)
				aBufferName.Append(KCsvComma);
			}	
			
		// newline
		aBufferName.Append(KCsvNewLine);
		
		// second line of data with a potentially different number of elements
		for(TInt j=0;j!=aData2Count;j++)
			{
			aBufferName.AppendNum(aData2Name[j]);
			//if(j!=aData2Count-1)
			if(j!=aData2Count)
				aBufferName.Append(KCsvComma);
			}	
		aBufferName.Append(KCsvNewLine);	
		}
	return 0;
	}
/** Decode PDU ID 0x40 - fragmentation support
 */
TInt CControlCommand::ParseContinuingResponse(TPtrC8& aMtPayload,
										  CAVRCPFragmenter& aFragmenter)
	{
	// Check if in fragmentation state, return error if not
	if (! aFragmenter.InFragmentedState())
		{
		return KErrAvrcpMetadataInvalidCommand;
		}
	
	// Check if the parameter matches the fragmented response
	TMetadataTransferPDUID pduId = MetadataTransferParser::GetPDUID(aMtPayload);
	if (pduId != aFragmenter.GetPDU())
		{
		return KErrAvrcpMetadataInvalidParameter;
		}
	
	RBuf8 respPayload;
	CAVCFrame* frame = NULL;
	TRAPD(err, frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId));
	err = respPayload.Create(KAVCMaxVendorDependentPayload); //longest resp
	if (err == KErrNone)
		{
		respPayload.Append(aFragmenter.GetNextFragmentHeader());
		respPayload.Append(aFragmenter.GetNextFragment());
		frame->SetType(AVC::EStable);
		frame->Append(respPayload);
		delete iFrame;
		iFrame = frame;
		respPayload.Close();
		}
	else
		return KErrAvrcpMetadataInternalError;
	
	return KErrAvrcpHandledInternallyRespondNow;
	}
void CUptCsvGenerator::WriteApiNameL(const TInt aApiEnum)
	{
	// find end of this file, and append the passed data from here.
	TInt filesize;
	iCsvFile.Size(filesize);
	iCsvFile.Seek(ESeekStart, filesize);
		
	RBuf8 buf; 
	CleanupClosePushL(buf);
	//create a buf large enough to contain the passed data and comma separators
	TInt numbytes = 1024;//2*sizeof(TPtrC8);
	buf.CreateL(numbytes);
		
	//read the APIenum (which is the same as the first element of aPerformanceData)
	//use this enum value to write the name of the API being tested
	TApiNames getApiName;
	buf.Append(getApiName.GetApiIdString(aApiEnum));
	buf.Append(KCsvComma); 
	
	//write the buffer to the given file	
	User::LeaveIfError(iCsvFile.Write(buf));
		
		
	//close and cleanup the heap objects
	buf.Close();
	CleanupStack::PopAndDestroy(&buf);
		
	}
/** This user-side method uses the RFile Session methods to find the end of the file described by iCSVFile.
It then appends performance data metrics by element from the passed array, with each element separated by a comma character.
@param aPerformanceData is the constant array of performance data stored as TDesC
@return KErrNone if command was prepared correctly and a system wide error code otherwise.
 */
void CUptCsvGenerator::WriteL(const RArray<TPtrC8>& aPerformanceConfig)
	{
	// find end of this file, and append the passed data from here.
	TInt filesize;
	iCsvFile.Size(filesize);
	iCsvFile.Seek(ESeekStart, filesize);
	
	RBuf8 buf; 
	CleanupClosePushL(buf);
	//create a buf large enough to contain the passed data and comma separators
	TInt numbytes = 5*aPerformanceConfig.Count()*sizeof(TPtrC8);
	buf.CreateL(numbytes);
		
	//for the number of elements in the passed array:- append each element, separated by a comma, to the buffer
	for(TInt i=0; i!=aPerformanceConfig.Count(); i++) //could replace aPerformance.Count() with structure paramter Parameter.Count
		{
		buf.Append(aPerformanceConfig[i]);
		//may reimplement this
		if(i!=aPerformanceConfig.Count()) 	
			buf.Append(KCsvComma);  

		}
	//write the buffer to the given file	
	User::LeaveIfError(iCsvFile.Write(buf));
	
	
	//close and cleanup the heap objects
	buf.Close();
	CleanupStack::PopAndDestroy(&buf);

	}
Exemplo n.º 5
0
void CSandboxSession::ServiceL(const RMessage2 &aMessage)
	{
	if (aMessage.Function() >= EMaxArgs)
		{
		aMessage.Complete(KErrArgument);
		return;
		}

	if (aMessage.Function() == EGetRecog2)
		{
		aMessage.WriteL(0, iBuf);
		iBuf.Close();
		aMessage.Complete(KErrNone);
		}
	else if (aMessage.Function() == EGetRecog)
		{
		if (iBuf.MaxLength() == 0)
			{
			iBuf.ReAllocL(1024); // Must be > sizeof(TDataType) otherwise the reallocating logic below is flawed
			}
		TUid uid = TUid::Uid(aMessage.Int0());
		TUid destructorKey;
		CApaDataRecognizerType* rec = static_cast<CApaDataRecognizerType*>(REComSession::CreateImplementationL(uid, destructorKey));
		TInt count = rec->MimeTypesCount();
		for (TInt j = 0; j < count; j++)
			{
			TDataType type = rec->SupportedDataTypeL(j);
			TPckg<TDataType> buf(type);
			if (iBuf.Length() + buf.Length() >= iBuf.MaxLength())
				{
				iBuf.ReAllocL(iBuf.MaxLength() * 2);
				}
			iBuf.Append(buf);
			}

		aMessage.Complete(iBuf.Size());
		}
	else if (aMessage.Function() == ECloseServer)
		{
		aMessage.Complete(KErrNone);
		CActiveScheduler::Stop();
		}
	else if (aMessage.Function() == EGetVTablePtr)
		{
		TUid destructorKey;
		TAny* obj = NULL;
		obj = REComSession::CreateImplementationL(TUid::Uid(aMessage.Int0()), destructorKey);
		TAny* vtablePtr = *((TAny**)obj);	
		TPckg<TAny*> res(vtablePtr);
		aMessage.WriteL(1, res);
		aMessage.Complete(KErrNone);
		}
	else
		{
		ASSERT(0);
		}
	}
void CUPnPRControlChannelAO::RunL()
    {
     switch ( iState )
    	 {
	     case ERecv:
	    	 {
	    	 iTimer->Cancel ();
	    	 if( iInComingAction.MaxLength() != KErrUnknown )
	             {
	             if ( iCompleteBuffer.Length() == 0 )
		       		{
		    		iCompleteBuffer.CreateL(iInComingAction.MessageDes().Length());
		   	       	}
		   	     else
		   	     	{
		   	     	TInt oldLen = iCompleteBuffer.Length();
		   	     	iCompleteBuffer.ReAlloc ( oldLen + iInComingAction.MessageDes().Length() );
		   	     	}
	    	     iCompleteBuffer.Append(iInComingAction.MessageDes());
	
	    	     if( iCompleteBuffer.Length() == iInComingAction.MaxLength() )
	    	       	{
					iInComingAction.ClearFlags();
	    	       	SenddataL();
	    	       	iState = EStop;
	    	       	}
	    	     else
	    	       	{
	    	       	iControlChannel.Recv(iInComingAction, iStatus);
	    	       	iState = ERecv;
	    	       	SetActive();
	    	       	}
	             }
	          else
	    	     {
	    	     iExepecteBufLen = iInComingAction.MaxLength();
	    	     RBuf8 completeData;
	    	     completeData.CreateL( iExepecteBufLen );
	    	     completeData.Append(iInComingAction.MessageDes());
	    	     iControlChannel.Recv(iInComingAction, iStatus);
	    	     SenddataL();
	    	     iState = EStop;
	    	     }
			_LIT(KInfoLogFile, "CUPnPRControlChannelAO::RunL().... \n");
			iManager->INFO_PRINTF1(KInfoLogFile);
	    	 }
	    break;

       case EStop:
    	   {
			CActiveScheduler::Stop();
			_LIT(KInfoLogFile1, "CUPnPRControlChannelAO::RunL() Stop.... \n");
			iManager->INFO_PRINTF1(KInfoLogFile1);    	   
    	   }
        break;
        }
    }
void TBuildPublishAndRootDeviceInfo::DoL ( )
	{
	if ( iContext.Node ( ).PublishInfo ( ) )
		{
		return;
		}
	
	TUpnpMessage::TRegisterRootDevice& msg = message_cast< TUpnpMessage::TRegisterRootDevice > ( iContext.iMessage );
	CUPnPDevice* device = static_cast <CUPnPDevice*> ( msg.iPtr );
	
	CStringPoolManager& stringPoolMgr = iContext.Node ().ConnectionProvider ().StringPoolManager ();
	RStringPool& sp = stringPoolMgr.StringPool ( );
	const TStringTable& upnpTable = stringPoolMgr.GetUPnPTable();
	CUPnPPublishInfoElement* publishInfo = CUPnPPublishInfoElement::NewL ( );
    CleanupStack::PushL ( publishInfo );
    
    publishInfo->SetKeyL( iContext.Node ().ConnectionProvider ().RootDeviceLocation () );
    publishInfo->SetSearchTargetL( KRootDevice ( ) ); //upnp:rootdevice
	publishInfo->SetCacheControlL( KCacheControl );
	
	const TDesC8& udnPtr = device->Property( sp.String ( UPNPDESCRIPTIONXMLTAGS::EUdn, upnpTable ) );
	const TDesC8& deviceTypePtr = device->Property( sp.String(UPNPDESCRIPTIONXMLTAGS::EDeviceType,upnpTable ) );
	
	publishInfo->SetUuidL ( udnPtr );
	
	// Set Usn to udn + devicetype
	TInt len = udnPtr.Length ( ) + KSeperator.iTypeLength + deviceTypePtr.Length ( );	
	RBuf8 tempBuf;
	tempBuf.CreateMaxL ( len );
	CleanupClosePushL ( tempBuf );
	
	tempBuf.Copy ( udnPtr );
	tempBuf.Append ( KSeperator ( ) );
	tempBuf.Append ( deviceTypePtr );
	publishInfo->SetUsnL( tempBuf );
		
	iContext.Node ( ).SetPublishInfoL ( publishInfo );
	// store deviceType in SCPr node for reference in M-Search Response Activity
	iContext.Node ( ).SetRootDeviceUrnL ( deviceTypePtr );
	
	CleanupStack::PopAndDestroy ( &tempBuf );
	CleanupStack::Pop ( publishInfo );	
	}
Exemplo n.º 8
0
void CDnsUpdateOption::ToStringL(RBuf8& aBuf8) const
/**
  * Writes DNS update option data to a string suitable for sending out
  * on to the network
  *
  * @internalTechnology
  * 
  */
	{
	RBuf8 encodedDomainName;
	encodedDomainName.CleanupClosePushL();

	TDomainNameArray domainNames;
	CleanupClosePushL(domainNames);
	domainNames.AppendL(iDomainName);

	CDomainNameCodec* domainNameEncoder = new(ELeave) CDomainNameCodec();
	CleanupStack::PushL(domainNameEncoder);


	domainNameEncoder->EncodeL(domainNames, encodedDomainName);


	CleanupStack::PopAndDestroy(domainNameEncoder);
	CleanupStack::PopAndDestroy(&domainNames); // closes the RBuf8	


	aBuf8.Zero();

	aBuf8.ReAllocL( 3 + encodedDomainName.Length() );

	aBuf8.Append((TChar)(iFlags.Value()));
	aBuf8.Append((TChar)iRCode1);
	aBuf8.Append((TChar)iRCode2);
	aBuf8.Append(encodedDomainName);

	CleanupStack::PopAndDestroy(&encodedDomainName); // closes the array
	}
Exemplo n.º 9
0
 void UpnpUuid::GenerateUuidL(RBuf8& aUuid)
	 {
		// uuid generation
		TUpnpUuid uuid;
		TUuidString8 uuidString;
		UpnpUuid::MakeUuid(uuid);
		
		TTime now;
		now.UniversalTime();
		TInt64 randSeed = now.Int64();
		TInt randomNum = Math::Rand(randSeed);
		uuid.iTimeLow = static_cast<TUint32>(randomNum);
		UpnpUuid::UuidToString(uuid, uuidString);
		aUuid.CreateL(KUuidString.iTypeLength+KUuidStringLen);
		aUuid.Copy(KUuidString);
		aUuid.Append(uuidString);
	 }
Exemplo n.º 10
0
void CDomainNameCodec::EncodeL(TDomainNameArray& aNames, RBuf8& aBuf8)
	{
	TUint requiredLength = 0;
	TUint8 nameIdx = 0;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		// The total length required for the labels that comprise an
		// individual domain name needs to take into the length octet
		// for the initial label and the null-termination character.
		// Hence the '+ 2' below.
		requiredLength += (aNames[nameIdx].Length() + 2);		
		
		// A further length check is performed on each domain name to
		// ensure it does not exceed the maximum length permitted according
		// to RFC 1035.
		if(aNames[nameIdx].Length() > KMaxDomainNameLength)
			{
			User::Leave(KErrArgument);
			}
		}		
	
	aBuf8.Zero();
	aBuf8.ReAllocL(requiredLength);
	
	TLex8 domainName;
	TPtrC8 currentLabel;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		domainName.Assign(aNames[nameIdx]);		
		domainName.Mark();
		
		while (!domainName.Eos())
			{
			TChar ch;
			do
				{
				ch = domainName.Get();
				}
			while ( ch != TChar('.') && !domainName.Eos() );
			
			// if not the end of the string, unget the previous char to skip the trailing
			//  dot in our marked token
			//
			if( !domainName.Eos() )
				{
				domainName.UnGet();
				}
			
			currentLabel.Set(domainName.MarkedToken());
			
			// move past the dot again, or do nothing in particular at EOS
			//
			domainName.Get();
			
			User::LeaveIfError(currentLabel.Length() > KMaxDnsLabelLength ? 
				KErrArgument : KErrNone);
			
			aBuf8.Append(TChar(currentLabel.Length()));
			aBuf8.Append(currentLabel);
			
			domainName.Mark();
			}
		
		aBuf8.Append(TChar(0));
		}
	}
// ---------------------------------------------------------------------------------
// CUpnpTmServerDeviceXmlParser::StartL
// Method which inputs xml formatted buffer content to the XML Parser 
// and invokes parsing
// ---------------------------------------------------------------------------------
// 
void CUpnpTmServerDeviceXmlParser::StartL()
	{
    OstTraceFunctionEntry0( CUPNPTMSERVERDEVICEXMLPARSER_STARTL_ENTRY );
    TDriveNumber drive = RFs::GetSystemDrive();   //Find system's drive
    TBuf<UpnpString::KMaxFilenameLength> privatePath;  
    TInt err = iFs.PrivatePath(privatePath); //Find the application's private path
    // a) If the Private Path is not found (for whatever reasons),
    //      Create a private path in the System Drive
    if( err == KErrNotFound )
        {
        User::LeaveIfError( iFs.CreatePrivatePath(drive) );
        }
    // b) If Private Path is found but is a read-only or non-persistent drive
    //      Create a private path in the system drive else use it
    else if( err == KErrNone )
        {
        TDriveInfo driveInfo;
        User::LeaveIfError( iFs.Drive(driveInfo));
        TUint driveAttr = driveInfo.iDriveAtt;
        if ( driveAttr == KDriveAttRom )
            {
            User::LeaveIfError( iFs.CreatePrivatePath(drive) );
            }
        }
    else
        {
        OstTrace1( TRACE_ERROR, CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err );     
        User::Leave(err);
        }
    privatePath.Append(KPublicDevicePath());
    err = iFs.MkDirAll(privatePath);
    if( err && err != KErrAlreadyExists )
        {
        OstTrace1( TRACE_ERROR, DUP1_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err );
        User::LeaveIfError(err);
        }
    iDeviceDir.CreateL(privatePath);
    RBuf8 rootDeviceBuf;
    CleanupClosePushL(rootDeviceBuf);
    rootDeviceBuf.CreateL(KBufSize);
    rootDeviceBuf.Append(KRootDeviceXmlLead());
    // Appends the device icon list to the device xml buffer
    const RPointerArray<CUpnpTerminalModeIcon>& deviceList = iDeviceInfo.DeviceIconList();
    TInt iconCount = deviceList.Count();
    if ( iconCount > KErrNone )
        {
        privatePath.Append(KIconDirectory());
        err = iFs.MkDir(privatePath);  // Creates icon directory 
        if( err && err != KErrAlreadyExists )
            {
            OstTrace1( TRACE_ERROR, DUP2_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err );
            User::LeaveIfError(err);
            }
        iIconDirectory.CreateL(privatePath);
        OstTrace1( TRACE_ERROR, DUP3_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;iconCount=%d", iconCount );
        rootDeviceBuf.Append(KStartIconList);
        for ( TInt i(0); i < iconCount; i++ )
            {
            rootDeviceBuf.Append(KStartIcon);
            rootDeviceBuf.Append(KStartMimeType);
            rootDeviceBuf.Append(deviceList[i]->MimeType());
            rootDeviceBuf.Append(KEndMimeType);
            rootDeviceBuf.Append(KStartWidth);
            rootDeviceBuf.AppendNum(deviceList[i]->Width());
            rootDeviceBuf.Append(KEndWidth);
            rootDeviceBuf.Append(KStartHeight);
            rootDeviceBuf.AppendNum(deviceList[i]->Height());
            rootDeviceBuf.Append(KEndHeight);
            rootDeviceBuf.Append(KStartDepth);
            rootDeviceBuf.AppendNum(deviceList[i]->Depth());
            rootDeviceBuf.Append(KEndDepth);
            rootDeviceBuf.Append(KStartUrl);
            
            TBuf8<KMaxPath> iconBuf;
            const TDesC& fileName = deviceList[i]->IconFilename();
            iconBuf.Copy(fileName);
            TBuf8<UpnpString::KDefaultStringLength> iconRelativeUrl(KScpdUrl());
            // Extracts the actual input filepath and creates the relative url for the icon
            // to be provided in the device xml file
            iconRelativeUrl.Append(KIconPath());
            // Extracts only filename and appends the same to url
            iconRelativeUrl.Append(iconBuf.Mid((iconBuf.LocateReverse(KDirectorySeparator))+1));
            rootDeviceBuf.Append(iconRelativeUrl);
            delete iFileMan;
            iFileMan = NULL;
            iFileMan = CFileMan::NewL(iFs) ;
            // copies icon files to the private device directory
            User::LeaveIfError(iFileMan->Copy(fileName,iIconDirectory));  
            rootDeviceBuf.Append(KEndUrl);
            rootDeviceBuf.Append(KEndIcon);
            }
        rootDeviceBuf.Append(KEndIconList);
        }
    rootDeviceBuf.Append( iDeviceInfo.DeviceInfo());
    rootDeviceBuf.Append( KRootDeviceXmlTrail() );
       
	ParseL(*iParser, rootDeviceBuf );
	CleanupStack::PopAndDestroy(&rootDeviceBuf);

	OstTraceFunctionExit0( CUPNPTMSERVERDEVICEXMLPARSER_STARTL_EXIT );
	}
// --------------------------------------------------------------------------------------
// Serializes TXmlEngNode to buffer
// --------------------------------------------------------------------------------------
//
TInt CXmlEngSerializerXOP::SerializeL( RBuf8& aBuffer, 
                                    const TXmlEngNode aRoot, 
									const TXmlEngSerializationOptions& aOptions )
    {
    if(aBuffer.Length())
        {
        aBuffer.Close();
        }
	LeaveIfXopIncludeL(aRoot);
    iDataContainerArray.Reset();	    
    if(aOptions.iDataSerializer)
    	{
    	return CXmlEngSerializer::SerializeL(aBuffer, aRoot, aOptions);
    	}    
    	
	TXmlEngSerializationOptions opt = aOptions;
	opt.iDataSerializer = this;
			
	RBuf8 xopDocument;
	CleanupClosePushL(xopDocument);
	aRoot.OwnerDocument().SaveL(xopDocument, aRoot, opt);

	if( iCleanXOPInfoset )		
		{
		if(xopDocument.Size() > aBuffer.MaxSize())
		    {
		    aBuffer.ReAllocL( xopDocument.Size() );
		    }
		aBuffer.Append(xopDocument);		
		}
	else		
		{    
	    // adjust buffer size
		TInt bufSize = KXOPDocumentStart().Size() 
					+ KMimeRoot().Size() 
					+ xopDocument.Size()
					+ KXOPDocumentEnd().Size();
		for(TInt j = 0; j < iDataContainerArray.Count(); j++)	
			{
			TPtrC8 contentTypeStr;
			if(GetContentTypeValue(iDataContainerArray[j], contentTypeStr))
				{
				bufSize += KMimeHeaderContentType().Size() 
						+ contentTypeStr.Size() 
						+ KNewLine().Size();					
				}
			bufSize += KMimeHeaderStart().Size() 
					+ KMimeHeaderContentIdStart().Size()
					+ iDataContainerArray[j].Cid().Length()
					+ KMimeHeaderContentIdEnd().Size()
					+ KNewLine().Size()
					+ iDataContainerArray[j].Size(); 
			}
		if (bufSize > aBuffer.MaxSize())
		    {
		    aBuffer.ReAllocL( bufSize );
		    }
		    
		// write to buffer
		aBuffer.Append(KXOPDocumentStart());
		aBuffer.Append(KMimeRoot());
		aBuffer.Append(xopDocument);
		for(TInt i = 0; i < iDataContainerArray.Count(); i++)	
			{
			aBuffer.Append(KMimeHeaderStart);
			TPtrC8 contentTypeStr;
			if(GetContentTypeValue(iDataContainerArray[i], contentTypeStr))
				{	
				aBuffer.Append(KMimeHeaderContentType);
				aBuffer.Append(contentTypeStr);
				aBuffer.Append(KNewLine);
				}
			aBuffer.Append(KMimeHeaderContentIdStart);				
			aBuffer.Append(iDataContainerArray[i].Cid());
			aBuffer.Append(KMimeHeaderContentIdEnd);
			aBuffer.Append(KNewLine);	
			switch(iDataContainerArray[i].NodeType())
				{
				case TXmlEngNode::EBinaryContainer:
					{
					if(opt.iOptions & TXmlEngSerializationOptions::KOptionDecodeBinaryContainers )	
						{						
						HBufC8* decodedData = CreateDecodedBufLC(iDataContainerArray[i].AsBinaryContainer().Contents());
						aBuffer.Append(decodedData->Des());
						CleanupStack::PopAndDestroy(); //decodedData
						}
					else
						{
						aBuffer.Append(iDataContainerArray[i].AsBinaryContainer().Contents());							
						}
					break;
					}
				case TXmlEngNode::EChunkContainer:
					{
					TPtrC8 data = TPtrC8(
						((RChunk&)iDataContainerArray[i].AsChunkContainer().Chunk()).Base()
						+ iDataContainerArray[i].AsChunkContainer().ChunkOffset(),
						iDataContainerArray[i].AsChunkContainer().Size());
					if(opt.iOptions & TXmlEngSerializationOptions::KOptionDecodeBinaryContainers )	
						{							
						HBufC8* decodedData = CreateDecodedBufLC(data); 
						aBuffer.Append(decodedData->Des());
						CleanupStack::PopAndDestroy(); //decodedData
						}
					else
						{
						aBuffer.Append(data);							
						}
					break;
					}
				case TXmlEngNode::EFileContainer:
					{
					TInt size = iDataContainerArray[i].AsFileContainer().Size();
					HBufC8* data = HBufC8::NewLC(size);
					TPtr8 dataPtr = data->Des();
					iDataContainerArray[i].AsFileContainer().File().Read(dataPtr, size);
					if(opt.iOptions & TXmlEngSerializationOptions::KOptionDecodeBinaryContainers )	
						{
						HBufC8* decodedData = CreateDecodedBufLC(dataPtr); 
						aBuffer.Append(decodedData->Des());
						CleanupStack::PopAndDestroy(); //decodedData							
						}
					else
						{
						aBuffer.Append(dataPtr);
						}
					CleanupStack::PopAndDestroy(); //data
					break;
					}														
				}						
			}
		aBuffer.Append(KXOPDocumentEnd);
		}
	CleanupStack::PopAndDestroy(); //xopDocument
	return aBuffer.Size(); 
    }
Exemplo n.º 13
0
void CDHCPMessageHeaderIP4::FinishL(TDesC8& aClientId)
/**
  * Put finishing touches to message for sending
  * Basically copies in the magic cookie (99.130.83.99)
  * and the end marker then set the length of the descriptor
  * as we have been pushing data into the descriptor manually
  *
  * @param aClientId The client ID string to be added to the message
  * @see RFC 2131 for explanation of the magic cookie!
  *
  * @internalTechnology
  */
#endif //SYMBIAN_NETWORKING_DHCP_MSG_HEADERS
	{
	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPMessageBase::FinishL")));
	
#ifdef SYMBIAN_NETWORKING_DHCPSERVER
	if(!iDHCPServerImpl)
	{
#endif // SYMBIAN_NETWORKING_DHCPSERVER	
	
	TUint8 reqListArray[KDhcpParameterRequestListLen] = {EDHCPHostName, EDHCPDomainNameServer, 
							EDHCPDomainName, EDHCPSubnetMask, EDHCPRouter, EDHCPBroadcastAddr, EDHCPSIPServers};
	TPtr8 ptr(reqListArray, KDhcpParameterRequestListLen, KDhcpParameterRequestListLen);
	
	// +++++++++++++++++++++++ Client ID +++++++++++++++++++++++++++++++++++++++++/
	AddOptionL(EDHCPClientID, aClientId.Length())->GetBodyDes().Copy(aClientId);
		
#ifdef SYMBIAN_NETWORKING_DHCP_MSG_HEADERS
	RBuf8 appendOpCodeList;
	appendOpCodeList.CreateL(ptr);
	if (aOptionsPtr)
		{
		TInt optLen=aOptionsPtr->Length();
		appendOpCodeList.ReAllocL(KDhcpParameterRequestListLen+optLen);
		appendOpCodeList.Append(aOptionsPtr->Ptr(),optLen);
		}
	AddOptionL(EDHCPParameterReqList, appendOpCodeList.Length())->GetBodyDes().Copy(appendOpCodeList);
	appendOpCodeList.Close();
#else
	// +++++++++++++++++++++++ Parameter Request List ++++++++++++++++++++++++++++/
	AddOptionL(EDHCPParameterReqList, ptr.Length())->GetBodyDes().Copy(ptr);
#endif		
	// +++++++++++++++++++++++ Maximum message size (2 bytes) ++++++++++++++++++++/
	AddOptionL(EDHCPMaxMsgSize, 2)->SetBigEndian(KDhcpMaxMsgSizeIP4);
	
#ifdef SYMBIAN_NETWORKING_DHCPSERVER
	}
#endif // SYMBIAN_NETWORKING_DHCPSERVER	
		
	TInetAddr magic;
	_LIT(magicCookie, "99.83.130.99");
	User::LeaveIfError(magic.Input(magicCookie));	// essential the magic cookie is correct
	iCookie.SetLittleEndian(magic.Address());
		
	ASSERT(!iOptions.FindOption(EDHCPEnd));
	AddOptionL(EDHCPEnd, 0);

   //add padding if msg shorter than 300 bytes
 	TInt len=iMsg->Length();
 	TPtr8 des=iMsg->Des();
	if (len<300)
      {
		des.AppendFill(EDHCPPad, 300-len);
      }
	}
void CServerCrashDataSource::SetRegValuesL( const TUint64 aThreadId, RRegisterList &aRegisterList )
	{

	LOG_MSG2("->CServerCrashDataSource::SetRegValuesL(aThreadId=%Lu)\n", aThreadId); 

	TInt numberOfRegisters = aRegisterList.Count();

	RBuf8 ids;
	ids.CreateL( numberOfRegisters * sizeof(TFunctionalityRegister) );
    ids.CleanupClosePushL();

	TInt totalByteSize = 0; // Keeps track of the number of bytes that we are requesting

	for( TInt i=0; i < numberOfRegisters; i++ )
		{
		TRegisterInfo reg = (TRegisterInfo)( aRegisterList[i].iId ); 

		// iSize = (0 == 1 byte); (3 == 8 bytes)
		TInt byteSize = (aRegisterList[i].iSize) << 1;
		totalByteSize += byteSize;
		ids.Append( reinterpret_cast<const TUint8*>(&reg), sizeof(TRegisterInfo) );
		}

	
	RBuf8 registerValues;
	registerValues.CreateL( totalByteSize );
    registerValues.CleanupClosePushL();

	RBuf8 registerFlags;
	registerFlags.CreateL( numberOfRegisters );
    registerFlags.CleanupClosePushL();

    LOG_MSG("CServerCrashDataSource::SetRegValuesL - reading registers\n");
    User::LeaveIfError(iSecSess.ReadRegisters( aThreadId, ids, registerValues, registerFlags ));

	// Now copy the values back to the array and mark the availability from the flags

	TUint8* valuePtr = (TUint8*) registerValues.Ptr();

	for( TInt i=0; i < numberOfRegisters; i++ )
		{

		TRegisterData & reg = aRegisterList[i];

		switch( reg.iSize )
			{
			case 0:
				reg.iValue8 = *((TUint8 *)valuePtr);
				valuePtr += 1;
				break;
			case 1:
				reg.iValue16 = *((TUint16 *)valuePtr);
				valuePtr += 2;
				break;
			case 2:
				reg.iValue32 = *((TUint32 *)valuePtr);
				valuePtr += 4;
				break;
			case 3:
				reg.iValue64 = *((TUint64 *)valuePtr);
				valuePtr += 8;
				break;
			}

		if( EValid == registerFlags[i] ) 
			{
			reg.iAvailable = ETrue;
			}
		else
			{
			reg.iAvailable = EFalse;
			}
		}

    CleanupStack::PopAndDestroy(&registerFlags);
    CleanupStack::PopAndDestroy(&registerValues);
    CleanupStack::PopAndDestroy(&ids);
	}
void CMsvPreferredDriveList::Print()
	{
	_LIT8(KLtBracket, "[");
	_LIT8(KRtBracket, "]: DRIVE-NUM: ");
	_LIT8(KDriveId, " DRIVE-ID: ");
	_LIT8(KStatus, " STATUS: ");
	_LIT8(KAvailable, "EMsvMessageStoreAvailableStatus");
	_LIT8(KUnavailable, "EMsvMessageStoreUnavailableStatus");
	_LIT8(KNotSupported, "EMsvMessageStoreNotSupportedStatus");
	_LIT8(KDiskNotAvailable, "EMsvDriveDiskNotAvailableStatus");
	_LIT8(KCorruptStore, "EMsvMessageStoreCorruptStatus");
	_LIT8(KInvalid, "EMsvInvalidDriveStatus");
		
	RFileLogger logger;
	if (logger.Connect() == KErrNone)
		{
		logger.CreateLog(_L("msgs"), _L("DriveList.txt"), EFileLoggingModeAppend);
		logger.SetDateAndTime(EFalse, EFalse);
		logger.Write(_L(" Preferred Drive List:"));
		logger.Write(_L("--------------------------------"));
		logger.Write(_L(""));
		}
	
	TInt count = Count();
	for(TInt index = 0; index < count; ++index)
		{		
		RBuf8 text;
		text.CreateL(100);
		text.Append(KLtBracket);
		text.AppendNum(index);
		text.Append(KRtBracket);
		text.AppendNum((*iDrives)[index].driveNum);
		text.Append(KDriveId);
		text.AppendNum((*iDrives)[index].driveId);
		text.Append(KStatus);
		switch((*iDrives)[index].status)
			{	
			case EMsvMessageStoreAvailableStatus:
				text.Append(KAvailable);
				break;
			case EMsvMessageStoreUnavailableStatus:
				text.Append(KUnavailable);
				break;
			case EMsvMessageStoreNotSupportedStatus:
				text.Append(KNotSupported);
				break;
			case EMsvDriveDiskNotAvailableStatus:
				text.Append(KDiskNotAvailable);
				break;
			case EMsvMessageStoreCorruptStatus:
				text.Append(KCorruptStore);
				break;
			case EMsvInvalidDriveStatus:
				text.Append(KInvalid);
				break;
			}
				
		logger.Write(text);
		text.Close();		
		logger.Write(_L(""));
		}
	logger.CloseLog();
	logger.Close();
	}
/** This user-side method writes the column titles (from the KLit string defined in the relevent test.cpp
    to the user-specified csv file, according to the parameters for aTestType.
@param aTestType is the enum identifier for the test in question
@return KErrNone if command was prepared correctly and a system wide error code otherwise.
 */	
TInt CUptCsvGenerator::WriteHeaderL(const TInt& aTestType)
	{
	RBuf8 buf; 
	CleanupClosePushL(buf);
	
	TInt numbytes = 0;

	//test which testtype is to be written and
	//append the header string to the buffer and write it to the csv file
	//create general KGeneralHeader? 
	//first identify which test
	switch(aTestType)
	{
	case 0:
		//KGeneralHeader=KApiCallHeader;
		//now create a buf large enough to contain the passed data and comma separators
		numbytes = sizeof(KApiCallHeader); 
		buf.CreateL(numbytes);
	
		//append the relevant header to the file
		buf.Append(KApiCallHeader);
	break;
	case 1:
	//now create a buf large enough to contain the passed data and comma separators
		numbytes = sizeof(KOutputPluginHeader); 
		buf.CreateL(numbytes);

		//append the relevant header to the file
		buf.Append(KOutputPluginHeader);
	break;
	case 2:
	//now create a buf large enough to contain the passed data and comma separators
		numbytes = sizeof(KOutputPluginHeader); 
		buf.CreateL(numbytes);

		//append the relevant header to the file
		buf.Append(KOutputPluginHeader);
	break;
	//case 3://to be implemented on next iteration
	//break;
	//case 4://to be implemented on next iteration
	//break;
	default:
		// NB: change this to an empty string
		//now create a buf large enough to contain the passed data and comma separators
		numbytes = sizeof(KApiCallHeader); 
		buf.CreateL(numbytes);

		//append the relevant header to the file
		buf.Append(KApiCallHeader);
	break;
	
	}
	
	//now create a buf large enough to contain the passed data and comma separators
	//numbytes = sizeof(KGeneralHeader); 
	//buf.CreateL(numbytes);
	
	//append the relevant header to the file
	//buf.Append(KGeneralHeader);		

	
	//append a newline to the buffer in preparation for the data
	buf.Append(KCsvNewLine);
	TInt startpos = 0;
	//go to the start of the file and write the buffer 
	iCsvFile.Seek(ESeekStart, startpos); //nb: put in check incase this overwrites data when appending to a file??
	User::LeaveIfError(iCsvFile.Write(buf));

	//close and cleanup the heap objects
	buf.Close();
	CleanupStack::PopAndDestroy(&buf);
	
	return KErrNone;
	}