/**
@SYMTestCaseID			PDS-STORE-UT-4056
@SYMTestCaseDesc		Test for DEF141471 - STORE, new stream performance tests.
						PREQ2505 Insturmentation of PDS.
						RBufWriteStream & RBufReadStream performance tests.
@SYMTestPriority		High
@SYMTestActions			Test for DEF141471 - STORE, new stream performance tests.
@SYMTestExpectedResults Test must not fail
@SYMDEF					DEF141471
*/
void BufStreamTestL()
	{
	CBufFlat* bufFlat = CBufFlat::NewL(KTestDataLen);
	CleanupStack::PushL(bufFlat);
	
	//RBufWriteStream::Open()
	RBufWriteStream strm1;
	CleanupClosePushL(strm1);
	TUint32 fc = User::FastCounter();
	strm1.Open(*bufFlat);
	TUint32 openFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Open(), Time=%d us\r\n"), openFc);
	DoStreamWriteTestL(strm1);
	CleanupStack::PopAndDestroy(&strm1);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());

	//RBufWriteStream::Append()
	RBufWriteStream strm2;
	CleanupClosePushL(strm2);
	fc = User::FastCounter();
	strm2.Append(*bufFlat);
	TUint32 appendFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Append(), Time=%d us\r\n"), appendFc);
	DoStreamWriteTestL(strm2);
	CleanupStack::PopAndDestroy(&strm2);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	//RBufWriteStream::Insert()
	RBufWriteStream strm3;
	CleanupClosePushL(strm3);
	fc = User::FastCounter();
	strm3.Insert(*bufFlat, KBufSize);
	TUint32 insertFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Insert(), Time=%d us\r\n"), insertFc);
	DoStreamWriteTestL(strm3);
	CleanupStack::PopAndDestroy(&strm3);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	//RBufWriteStream::Truncate()
	RBufWriteStream strm4;
	CleanupClosePushL(strm4);
	fc = User::FastCounter();
	strm4.Truncate(*bufFlat);
	TUint32 truncateFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Truncate(), Time=%d us\r\n"), truncateFc);
	DoStreamWriteTestL(strm4);
	CleanupStack::PopAndDestroy(&strm4);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	RBufReadStream strm5;
	CleanupClosePushL(strm5);
	fc = User::FastCounter();
	strm5.Open(*bufFlat);
	openFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufReadStream::Open(), Time=%d us\r\n"), openFc);
	DoStreamReadTestL(strm5);
	CleanupStack::PopAndDestroy(&strm5);
	
	CleanupStack::PopAndDestroy(bufFlat);
	}
// ---------------------------------------------------------
// CDownloadDataClient::MarshalDataL()
// ---------------------------------------------------------
//
HBufC8* CDownloadDataClient::MarshalDataL() const
    {
    TInt bufLen = Bytes();      // Size of class including iMediaArray elements.
                                //  Note that this includes actual bytes occupied by
                                //  contents of descriptors and pointers.
                                
    bufLen += sizeof(TInt);  // We include the count of elements in iMediaArray
                                //  while externalizing.
                                
    bufLen += sizeof(TInt) * iMediaArray.Count();
                                // iMediaArray has an array iTypes. We are including
                                //  count of elements in iTypes array while externalizing
                                //  each element of iMediaArray.
    
    // Dynamic data buffer
    CBufFlat* buf = CBufFlat::NewL(bufLen);
    CleanupStack::PushL(buf);
    // Stream over the buffer
    RBufWriteStream stream(*buf);
    CleanupClosePushL(stream);
    
    ExternalizeL(stream);
    CleanupStack::PopAndDestroy(); //stream
    
    // Create a heap descriptor from the buffer
    HBufC8* des = HBufC8::NewL(buf->Size());
    TPtr8 ptr(des->Des());
    buf->Read(0, ptr, buf->Size());
    CleanupStack::PopAndDestroy(); //buf
    
    return des;
    }
示例#3
0
void CReferenceHandler::CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfObjects = 2;
    aObjectBuf.ResizeL(KNumOfObjects * 20);
    //populate the buffer...
    _LIT8(KRefDesc2, "*Reference Object 2*");
    TUint i;
    for (i=0; i<KNumOfObjects; i++)
    {
        aObjectBuf.Write(20*i, KRefDesc2);
    }
    //populate the object
    aObject.SetNameL(KRef2Name);
    aObject.SetTypeL(KRefType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef2Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
    aObject.SetTimeL(KRef2Time);

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    ASSERT(descBuf);
    TPtr ptr(descBuf->Des());
    ptr.Zero();
    for (i=0; i<KDescLength; i++)
    {
        ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    }
    aObject.SetDescriptionL(ptr);
    CleanupStack::PopAndDestroy(descBuf);
    aObject.SetTargetL(KRefIrMCTarget);
    aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
}
示例#4
0
// Creates and returns a heap descriptor which holds contents of ’this’
EXPORT_C HBufC8* CRTSecMgrRegisterScriptMsg::PackMsgL() const
	{
	// Dynamic data buffer
	CBufFlat* buf = CBufFlat::NewL(KMaxMsgLength);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf); // Stream over the buffer
	CleanupClosePushL(stream);
	ExternalizeL(stream);
	CleanupStack::PopAndDestroy(&stream);
	// Create a heap descriptor from the buffer
	HBufC8* des = HBufC8::NewL(buf->Size());
	TPtr8 ptr(des->Des());
	buf->Read(0, ptr, buf->Size());
	CleanupStack::PopAndDestroy(buf); // Finished with the buffer
	return (des);
	}
示例#5
0
void CReferenceHandler::CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 200;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object

    aObject.SetNameL(KRef7Name);
    aObject.SetTypeL(KRefImageJpegType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
    aObject.SetTimeL(KRef5Time);

    _LIT8(KRef1HTTP, "Accept: text/*");
    _LIT8(KRef2HTTP, "Location: http://www.w3.org");
    _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");

    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);


    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    /*	ASSERT(descBuf);
    	TPtr ptr(descBuf->Des());
    	ptr.Zero();
    	for (i=0; i<KDescLength; i++)
    		{
    		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    		}
    	aObject.SetDescriptionL(ptr);
    */
    CleanupStack::PopAndDestroy(descBuf);

    aObject.SetTargetL(KRefSyncMLTarget);
    aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget);
}
示例#6
0
EXPORT_C HBufC8* CSTBencodedList::BencodeL() const
{
	CBufFlat* buf = CBufFlat::NewL(128);
	CleanupStack::PushL(buf);
	
	buf->InsertL(0, _L8("l"));
	
	for (TInt i=0; i<iItems.Count(); i++)
	{
		HBufC8* bencodedItem = iItems[i]->BencodeL();
		CleanupStack::PushL(bencodedItem);
		buf->InsertL(buf->Size(), *bencodedItem);
		CleanupStack::PopAndDestroy(); // bencodedItem		
	}
	
	buf->InsertL(buf->Size(), _L8("e"));
	
	HBufC8* bencodedData = buf->Ptr(0).AllocL();
	CleanupStack::PopAndDestroy(); // buf	
	
	return bencodedData;
}
示例#7
0
// --------------------------------------------------------------------------
// CUpnpAVDevice::ToDes8L
// See upnpavdevice.h
// --------------------------------------------------------------------------
EXPORT_C HBufC8* CUpnpAVDevice::ToDes8L() const
    {
    // serialize object
    CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity );
    CleanupStack::PushL( tempFlatBuf );

    RBufWriteStream stream( *tempFlatBuf );
    CleanupClosePushL( stream );
    
    stream << *this;
    
    // create heap descriptor
    HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() );
    TPtr8 ptr( tempBuf->Des() );
    tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() );
    
    // clean up
    CleanupStack::Pop( tempBuf );
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( tempFlatBuf );
    
    return tempBuf;
    }
// ---------------------------------------------------------------------------
// Data package from CatalogsPCConnectivityPlugin
// ---------------------------------------------------------------------------
//
void RCatalogsPCConnectivityClient::PutDataL( 
    const TDataType& aMimeType, const CBufFlat& aData )
    {
    TInt size = aData.Size();
    
    RBuf8 desData;
    desData.CreateL( size );
    desData.CleanupClosePushL();
    aData.Read( 0, desData, size );
    TPckgBuf<TDataType> pckgMIME( aMimeType );

    User::LeaveIfError( SendReceive( 
            ECatalogsPCConnectivityPutData, 
            TIpcArgs( &pckgMIME, &desData, size ) ) );

    CleanupStack::Pop(); //desData
    desData.Close();
    }
void CCntFileManagerMsgHandler::DefinitionsOfExistingViewsL(const RMessage2& aMessage)
	{
	TFileName fileName;
	ReadL(aMessage,KSlot0,fileName);
	if (fileName.Length() == 0)
		{
		Server().Controller().DefaultDatabaseL(fileName);
		}
	
	RPointerArray<CContactDefaultViewDefinition> viewDefs;
	CleanupResetAndDestroyPushL(viewDefs);		
	CCntDbManager* manager = Server().Controller().DbManagerL(fileName);
	if (manager)
		{
		manager->ViewManagerL().GetDefinitionsOfExistingViewsL(viewDefs);
		}
	
	// Compute the size of the buffer that is needed.
	CBufFlat* buffer = CBufFlat::NewL(32);
	CleanupStack::PushL(buffer);
	RBufWriteStream writeStream(*buffer);
	CleanupClosePushL(writeStream);
	
	const TInt32 count = viewDefs.Count();
	writeStream << count;
	for (TInt i = 0; i < count; i++)
		{
		writeStream << *viewDefs[i];
		}	

	// Check that the client-side write buffer is large enough.
	TInt length = buffer->Size();
	if(aMessage.GetDesMaxLength(1) >= length)
		{
		aMessage.WriteL(1, buffer->Ptr(0)); 
		aMessage.Complete(KErrNone);
		}
	else
		{
		aMessage.Complete(length);
		}	
	CleanupStack::PopAndDestroy(3, &viewDefs); // writeStream, buffer, viewDefs
	}
示例#10
0
void CReferenceHandler::CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 200;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object

    aObject.SetNameL(KRef4Name);
    aObject.SetLengthL(aObjectBuf.Size());

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    ASSERT(descBuf);
    TPtr ptr(descBuf->Des());
    ptr.Zero();
    for (i=0; i<KDescLength; i++)
    {
        ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    }
    aObject.SetDescriptionL(ptr);
    CleanupStack::PopAndDestroy(descBuf);
    aObject.SetTargetL(KRefTarget);

    TBuf8<40> param;
    param.Copy(_L("\x04"));
    param.Append(_L("\x03"));
    param.Append(_L("App params 456"));
    aObject.SetAppParamL(param);

    aObject.SetHeaderMask(KObexHdrName | KObexHdrLength | KObexHdrDescription | KObexHdrTarget | KObexHdrAppParam);
}
void CCntFileManagerMsgHandler::ListDatabasesL(const RMessage2& aMessage)
	{
	// Non file-specific. Does not require manager instance.
	// Client request to list contact databases on a specific or all system
	// drives.
	// Return parameter for serialized CDesCArray.
	CBufFlat* listBuffer;
	// IPC args thus:
	// 0 (Return param)	- Address of our return buffer
	// 1 (Param)		- The drive number 0 - 25 or ECntAllDrives
	// 2 (Return param)	- The size of buffer we are returning or want to return
	TInt driveNumber = aMessage.Int1();
	// Call controller to retrieve list of databases.
	if(driveNumber == ECntAllDrives)
		{
		Server().Controller().ListDatabasesL(listBuffer);
		}
	else
		{
		Server().Controller().ListDatabasesL(listBuffer,(TDriveUnit*)&driveNumber);
		}
	// Controller will have filled the listBuffer with a serialized
	// CDesCArray.
	CleanupStack::PushL(listBuffer);
	// Size of the buffer we want to return to client.
	TInt size = listBuffer->Size(); 
	TPckg<TInt> pckg(size);
	// Write return buffer size to client.
	aMessage.WriteL(2,pckg);
	// Only write if client has provided large enough buffer.  Client can
	// call us again with a larger buffer if contents are too large.
	if(aMessage.GetDesMaxLength(0) >= size)
		{
		aMessage.WriteL(0,listBuffer->Ptr(0));
		}
	aMessage.Complete(KErrNone);
	CleanupStack::PopAndDestroy(listBuffer);	
	}
/**
Returns the commandlist to the client from swppolicy.
@return A pointer to commandlist.
*/
void CSsmSwpPolicyServer::CallCommandListL(const RMessage2& aMessage, TInt aSessionIndex)
	{
	DEBUGPRINT1(_L("CSsmSwpPolicyServer: CallCommandListL"));
	__ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid));
	__ASSERT_DEBUG(iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion != NULL, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicyServerError4));
		// CommandList should be called only after preparing the command list, so the active object state should be EPrepareCommandList.
	__ASSERT_DEBUG(iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->CurrentStep() == CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::EPrepareCommandList, 
			PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError3));
	
	// CSsmSwpPolicyFrame checks whether initialize is called before CallCommandList is called, so no need to check
	// for valid iSsmSwpPolicyStepCompletion pointer.
	// Sets the current step to CallCommandList
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->SetCurrentStep(CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::ECallCommandList);
	CSsmCommandList* ssmCmdList = (iSessionInfoArray[aSessionIndex].iSwpPolicy)->CommandList();
	CleanupStack::PushL(ssmCmdList);
	CBufFlat* buf = CBufFlat::NewL(KSsmSwpPolicyStreamBufMaxSize);
	CleanupStack::PushL(buf);
	
	RBufWriteStream writeStream(*buf);
	CleanupClosePushL(writeStream);
	
	DEBUGPRINT1(_L("CSsmSwpPolicyServer: Externalizes the commandlist"));
	ssmCmdList->ExternalizeL(writeStream);

	// Ensure any memory that might already have been allocated  is disposed of. 
	// Transfer the streamed cmd list from the CBuf.
	RBuf8 cmdListBuf;
	cmdListBuf.CreateL(buf->Size());
	CleanupClosePushL(cmdListBuf);	
	buf->Read(0, cmdListBuf);
	
	aMessage.WriteL(0, cmdListBuf);
	
	aMessage.Complete(KErrNone);
	CleanupStack::PopAndDestroy(4, ssmCmdList);	//	buf, writeStream and cmdListBuf
	}
void CNcdProtocolDefaultObserver::ConfigurationActionRequestL( 
    MNcdConfigurationProtocolActionRequest* aActionRequest ) 
    {
    DLTRACEIN((""));

    CleanupDeletePushL( aActionRequest );
    
    if( aActionRequest->Type() == MNcdConfigurationProtocolActionRequest::ETypeUpdate &&
        aActionRequest->UpdateDetails() )
    	{
    	DLTRACE(( "Update" ));

    	DLINFO(( _L("Target: %S"), &aActionRequest->Target() ));
       	DLINFO(( _L("Id: %S"), &aActionRequest->UpdateDetails()->Id() ));
    	DLINFO(( _L("Version: %S"), &aActionRequest->UpdateDetails()->Version() ));
    	DLINFO(( _L("Uri: %S"), &aActionRequest->UpdateDetails()->Uri() ));
    	DLINFO(( "Forced: %d", aActionRequest->Force() ));

    	DLINFO(( "Client SID %08x", iContext.SecureId().iId ));    	
    	
    	if ( aActionRequest->Target() == KNcdActionTargetMasterServerUri && 
    	     aActionRequest->UpdateDetails()->Uri().Length() ) 
    	    {
    	    const TDesC& currentMaster( iConfigurationManager.MasterServerAddressL( 
    	        iContext ) );
    	        
    	    // Ensure that request was received from the master server
    	    if ( *iServerUri == currentMaster )
    	        {    	        
    	        /**
    	         * @ Improve this check to notice missing '/' at the end of the URIs
    	         */
    	        if ( aActionRequest->UpdateDetails()->Uri() != currentMaster )
    	            {    	            
            	    DLINFO(("Updating MasterServerUri")); 
            	       
            	    iConfigurationManager.SetMasterServerAddressL( iContext,
            	        aActionRequest->UpdateDetails()->Uri(), 0 );    	    
    	            }
    	        else
    	            {
    	            DLINFO(("MasterServerUri didn't change"));
    	            }
    	        }
    	    else
    	        {
    	        DLERROR(( _L("Invalid update request source! Request source: %S"),
    	            iServerUri ));
    	        }
    	    }
    	else if( aActionRequest->Target() == KNcdActionTargetSkin || 
    	         aActionRequest->Target() == KNcdActionTargetClient ) 
    	    {
        	HBufC* msgQueueName = HBufC::NewLC( KCatalogsUpdateQueueNameFormat().Length() + 8 );
        	msgQueueName->Des().Format( KCatalogsUpdateQueueNameFormat, iContext.SecureId().iId );
        	
        	DLINFO(( _L("Opening client's update message queue: %S"), msgQueueName ));
        	RMsgQueueBase queue;
        	
        	TInt err = queue.OpenGlobal( *msgQueueName );
        	if( err == KErrNone )
        	    {        	    
        	    CleanupClosePushL( queue );
                TInt msgSize = queue.MessageSize();

                // Prepare a buffer to write to update information P&S variable.
                CBufFlat* buffer = CBufFlat::NewL( KCatalogsUpdateInformationMaxSize + msgSize );
                CleanupStack::PushL( buffer );
                
                // Externalize the info to the buffer.
                RBufWriteStream stream( *buffer );
                CleanupClosePushL( stream );
                stream << (TInt32)(aActionRequest->Target().Size() + 
                                   aActionRequest->UpdateDetails()->Id().Size() + 
                                   aActionRequest->UpdateDetails()->Version().Size() +
                                   aActionRequest->UpdateDetails()->Uri().Size() +
                                   sizeof( TInt32 ));
                stream << aActionRequest->Target();
                stream << aActionRequest->UpdateDetails()->Id();
            	stream << aActionRequest->UpdateDetails()->Version();
                stream << aActionRequest->UpdateDetails()->Uri();
                stream << (TInt32)aActionRequest->Force();
                
                // Write the update information to the client's update message queue.
                TInt bytesToSend = buffer->Size();
                for( TInt sendPos = 0; sendPos < bytesToSend; sendPos += msgSize )
                    {
                    const TUint8* sendPtr = buffer->Ptr( sendPos ).Ptr();
                    queue.SendBlocking( sendPtr, msgSize );
                    }
                
                DLINFO(( "Update information sent to message queue" ));
                
                CleanupStack::PopAndDestroy( 3, &queue ); // stream-close, buffer, queue
        	    }
            
            // Clean up the local info buffer.
            CleanupStack::PopAndDestroy( msgQueueName ); 
    	    }
    	else
    	    {
    	    DLINFO(("Unknown Action target"));
    	    }
    	}
    // Action request no longer needed, delete it.
    CleanupStack::PopAndDestroy( aActionRequest );
    }
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetRunningProcessesL
// ----------------------------------------------------------------------------------------
CBufFlat* CTerminalControlServer::GetRunningProcessesL( )
{
    RDEBUG("CTerminalControlServer::GetRunningProcessesL");

    TFullName    processName;
    TFindProcess findProcess;
    CBufFlat *buffer = CBufFlat::NewL(128);
    iProcessInfoArray->Reset();

    while( KErrNone == findProcess.Next( processName ) )
    {
        TTcProcessInfo info;
        RProcess process;

        if( KErrNone == process.Open( findProcess ) )
        {
            //
            // Add process information to local array
            //
            info.iProcessName = processName;
            info.iFileName    = process.FileName();

            info.iHandle      = process.Handle();
            info.iId          = process.Id();
            info.iSecureId    = process.SecureId();

            info.iProtected   = EFalse;

            process.GetMemoryInfo( info.iMemoryInfo );

            User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            if( !info.iCodeInRom )
            {
                User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            }

            iProcessInfoArray->AppendL( info );

            //
            // Add process also to return buffer
            //
            /*
            TInt appendPosition = buffer->Size();
            if(iProcessInfoArray->Count() >= 2)
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, proName);
                }
            else
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, proName);
                }
            }

            */

            // Enumerate names from 1
            TInt appendPosition = buffer->Size();
            TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
            TBuf8<sizeof(KFormatProcessNamePrefix)+20> nameBuf;

            numBuf.Num(iProcessInfoArray->Count());
            nameBuf.Zero();
            nameBuf.Append(KFormatProcessNamePrefix);
            nameBuf.Append(numBuf);

            if(iProcessInfoArray->Count() >= 2)
            {
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, nameBuf);
            }
            else
            {
                buffer->InsertL(appendPosition, nameBuf);
            }
        }
    }
    /*
    	TUint32 flags = Exec::ProcessFlags(KCurrentProcessHandle);
    	if (flags & KProcessFlagSystemPermanent)
    		return ESystemPermanent;
    	if (flags & KProcessFlagSystemCritical)
    		return ESystemCritical;
    	if (flags & KThreadFlagProcessPermanent)
    		return EAllThreadsCritical;
    	return ENotCritical;
    */
    return buffer;
}
示例#15
0
// ---------------------------------------------------------
// CMmsSession::SendMessageL
// ---------------------------------------------------------
//
EXPORT_C void CMmsSession::SendMessageL( 
    const TDesC& aUri,
    CBufFlat& aMessageBuffer,                            
    MMmsCodecDataSupplier&  aDataSupplier,
    MMmsCodecDataSink&      aDataSink,
    TRequestStatus& aStatus )
    {
    LOG( _L("CMmsSession::SendMessageL ") );
    __ASSERT_DEBUG( iSessionStatus == ESessionIdle, gPanic(EMmsAlreadyBusy) );
  
    TInt method = HTTP::EPOST; 
   
    iDataSupplier = &aDataSupplier;
    iDataSink = &aDataSink;
    iRequestStatus = &aStatus;

    // Check if the buffer is empty

    if ( aMessageBuffer.Size() == 0 )
        {
        aStatus = KRequestPending;
        User::RequestComplete( iRequestStatus, KMmsErrorBufferEmpty );
        }

    // Check if we are connected
    
    else if ( !iConnected )
        {        
        aStatus = KRequestPending;
        User::RequestComplete( iRequestStatus, KMmsErrorSessionNotOpen );
        }
       
    else
        {
        // Start the sending procedures
       
        if ( !iTransaction )
            {
            iTransaction = CMmsTransaction::NewL();
            }

        iTransaction->ExecuteL(
            iHTTPSession,
            *iTransferControl,
            aUri,
            method,
            aMessageBuffer,
            iTransactionTimeout,
            iMaxReceiveSize,
            0, // "expected receive size" not needed for sending
            *iDataSupplier,
            *iDataSink,
            iStatus );
        
        aStatus = KRequestPending;
        
        iSessionStatus = ESessionSending;

        SetActive();
        }
    }
// ---------------------------------------------------------
// CT_LbsClientPosTp261::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp261::StartL()
    {
    _LIT(KService1, "Service1");
    _LIT(KService2, "Service2");
    _LIT(KService3, "Service3");

    _LIT(KContact1, "Contact1");
    _LIT(KContact2, "Contact2");
    _LIT(KContact3, "Contact3");

    CRequestor* serviceId1 = 
		CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService1);

    CRequestor* serviceId2 = 
        CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService2);

    CRequestor* serviceId3 = 
        CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService3);

    CRequestor* contactId1 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatTelephone, 
                    KContact1);

    CRequestor* contactId2 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatUrl, 
                    KContact2);

    CRequestor* contactId3 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatMail, 
                    KContact3);

    RRequestorStack stack = RRequestorStack();
    CleanupStack::PushL(TCleanupItem(CleanOp ,&stack));

    CleanupStack::PushL(serviceId1);
    CleanupStack::PushL(serviceId2);
    CleanupStack::PushL(serviceId3);
    CleanupStack::PushL(contactId1);
    CleanupStack::PushL(contactId2);
    CleanupStack::PushL(contactId3);
    
    ConnectL();
    OpenPositioner();
    
    stack.Append(serviceId1);
    stack.Append(contactId1);
    stack.Append(contactId2);
    stack.Append(serviceId2);
    stack.Append(contactId3);
    stack.Append(serviceId3);

    CleanupStack::Pop(contactId3);
    CleanupStack::Pop(contactId2);
    CleanupStack::Pop(contactId1);
    CleanupStack::Pop(serviceId3);
    CleanupStack::Pop(serviceId2);
    CleanupStack::Pop(serviceId1);

    TInt err = iPositioner.SetRequestor(stack);
    if (err != KErrNone)
    	{
    	_LIT(KErrorAndLeave, "Problems setting requestorstack");
    	LogErrorAndLeaveL(KErrorAndLeave);
    	}
    	
    const TInt KPosBufFlatExpandSize = 100;
    
    //ExternalizeL
    CBufFlat* bufFlat = CBufFlat::NewL(KPosBufFlatExpandSize);
    CleanupStack::PushL(bufFlat);
    
    RBufWriteStream stream(*bufFlat);
    CleanupClosePushL(stream);        
    stack.ExternalizeL(stream);
    
    TPtr8 dataPtr((TUint8*)NULL, 0);
    dataPtr.Set(bufFlat->Ptr(0));    

    CleanupStack::PopAndDestroy(&stream);                

    HBufC8* tempBuf = HBufC8::NewLC(bufFlat->Size());
    TPtr8 ptr = tempBuf->Des();
    ptr = dataPtr;
    
    //Internalize
    bufFlat->InsertL(0, ptr);
    
    RBufReadStream rstream(*bufFlat);
    CleanupClosePushL(rstream);
    
    RRequestorStack stack2 = RRequestorStack();
    CleanupStack::PushL(TCleanupItem(CleanOp ,&stack2));

    stack2.InternalizeL(rstream);
    
    // Verify the requestor stack
    VerifyRequestorStackL(stack2);
    _LIT(KResult, "The RequestorStack is correct after Externalize/Internalize");
    INFO_PRINTF1(KResult);

    CleanupStack::PopAndDestroy(1); // CleanupOp stack2

    CleanupStack::PopAndDestroy(&rstream);
    CleanupStack::PopAndDestroy(tempBuf);
    CleanupStack::PopAndDestroy(bufFlat);
    CleanupStack::PopAndDestroy(1); // CleanupOp stack1

    ClosePositioner();
    Disconnect();
    }
示例#17
0
void CSTTrackerConnection::CreateUriL()
{
	TInetAddr localAddress;
	TInt getAddressRes = KErrGeneral;
	// only send IP if we are connected via proxy
	//if (Preferences()->IncomingConnectionsMode() == EEnabledWithProxy)
	//	getAddressRes = iNetMgr->Address(localAddress);
	
	CBufFlat* uriBuf = CBufFlat::NewL(512);
	CleanupStack::PushL(uriBuf);
	
	//TPtrC8 activeTracker = iTorrent.AnnounceList()->ActiveAddress();
	//LWRITE(iLog, _L("Active tracker: "));
	//LWRITELN(iLog, activeTracker);
	
	uriBuf->InsertL(uriBuf->Size(), *iAddress);
	uriBuf->InsertL(uriBuf->Size(), _L8("?"));
	
	uriBuf->InsertL(uriBuf->Size(), _L8("info_hash="));	
	HBufC8* encoded = EscapeUtils::EscapeEncodeL(iTorrent.InfoHash(), EscapeUtils::EEscapeUrlEncoded);
	CleanupStack::PushL(encoded);
	uriBuf->InsertL(uriBuf->Size(), *encoded);
	CleanupStack::PopAndDestroy(); // encoded
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&peer_id="));
	encoded = EscapeUtils::EscapeEncodeL(TorrentMgr()->PeerId(), EscapeUtils::EEscapeUrlEncoded);
	CleanupStack::PushL(encoded);
	uriBuf->InsertL(uriBuf->Size(), *encoded);
	CleanupStack::PopAndDestroy(); // encoded
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&key="));
	TBuf8<32> keyBuf;
	keyBuf.Num(TorrentMgr()->Key());
	uriBuf->InsertL(uriBuf->Size(), keyBuf);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&port="));
	TBuf8<32> portBuf;
	if (getAddressRes == KErrNone)
		portBuf.Num(localAddress.Port());
	else
		portBuf.Num(Preferences()->IncomingPort());
	uriBuf->InsertL(uriBuf->Size(), portBuf);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&uploaded="));
	TBuf8<24> bytesUploaded;
	bytesUploaded.Num(iTorrent.BytesUploaded());
	uriBuf->InsertL(uriBuf->Size(), bytesUploaded);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&downloaded="));
	TBuf8<24> bytesDownloaded;
	bytesDownloaded.Num(iTorrent.BytesDownloaded());
	uriBuf->InsertL(uriBuf->Size(), bytesDownloaded);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&left="));
	TBuf8<24> bytesLeft;
	bytesLeft.Num(iTorrent.BytesLeft());
	uriBuf->InsertL(uriBuf->Size(), bytesLeft);

	// it seems that some trackers support only compact responses
	uriBuf->InsertL(uriBuf->Size(), _L8("&compact=1"));

	if (iEvent != ETrackerEventNotSpecified)
	{
		uriBuf->InsertL(uriBuf->Size(), _L8("&event="));
		
		switch (iEvent)
		{
			case ETrackerEventStarted:
				uriBuf->InsertL(uriBuf->Size(), _L8("started"));
			break;
			
			case ETrackerEventStopped:
				uriBuf->InsertL(uriBuf->Size(), _L8("stopped"));
			break;
			
			case ETrackerEventCompleted:
				uriBuf->InsertL(uriBuf->Size(), _L8("completed"));
			break;
			
			default:
			break;
		}
	}
	
	if (getAddressRes == KErrNone)
	{
		TBuf<64> ipBuf;
		localAddress.Output(ipBuf);
		TBuf8<64> ipBuf8;
		ipBuf8.Copy(ipBuf);
		
		uriBuf->InsertL(uriBuf->Size(), _L8("&ip="));
		uriBuf->InsertL(uriBuf->Size(), ipBuf8);
		
		#ifdef LOG_TO_FILE
		// debug info
		LWRITE(iLog, _L("Sent to tracker: "));
		LWRITE(iLog, ipBuf);
		TBuf8<32> portBuf;
		portBuf.Num(localAddress.Port());
		LWRITE(iLog, _L(":"));
		LWRITELN(iLog, portBuf);
		#endif
		//		
	}
	
	iUri = uriBuf->Ptr(0).AllocL();
	CleanupStack::PopAndDestroy(); // uriBuf
	
	//iLog->WriteL(_L("[Trackerconnection] GET "));
	//iLog->WriteLineL(*iUri);
}
示例#18
0
void CReferenceHandler::CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 1000;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object
    aObject.SetNameL(KRef3Name);
    aObject.SetTypeL(KRefRichTextType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
    aObject.SetTimeL(KRef3Time);

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    ASSERT(descBuf);
    TPtr ptr(descBuf->Des());
    ptr.Zero();
    for (i=0; i<KDescLength; i++)
    {
        ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    }
    aObject.SetDescriptionL(ptr);
    CleanupStack::PopAndDestroy(descBuf);
    aObject.SetTargetL(KRefTarget);

    CObexHeader* header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x30, KRef1Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x36, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x3F, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xB0, 0x03);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xBF, 0x12);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xF0, 0x54);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
// 0x2F header doesnt have a FourByte HI Type.
    /*	header = CObexHeader::NewL();
    	CleanupStack::PushL(header);
    	header->SetFourByte(0x2F, 0x54);
    	aObject.AddHeaderL(*header);
    	CleanupStack::Pop(header);
    */

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xFF, 0x43);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByteSeqL(0x73, KRefTarget);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrUserDefined);
}
示例#19
0
void CReferenceHandler::CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 2;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object
    aObject.SetNameL(KRef2Name); // check the deletecurrentheader method
    aObject.SetNameL(KRef1Name);

    _LIT8(KRef1HTTP, "Accept: text/*");
    _LIT8(KRef2HTTP, "Location: http://www.w3.org");
    _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");

    // add Http header using old API
    //
    /*	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef3HTTP);

    	// USE THE HEADER MASK TO REMOVE HTTP HEADERS FROM HEADERSET
    	// THIS DOES NOT REMOVE THE ITEMS FROM iHttp LIST - this tests
    	// the Http() function which should remove items from iHttp list
    	//

    	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
    	headerMask->SetHeader(TObexInternalHeader::EName);
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	aObject.HeaderSet().SetMask(NULL);
    	delete headerMask;

    */
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);

    /*	if (aObject.Http())
    		{
    		NULL;
    		}
    */
    // add a Count header using new API
    //
    CObexHeader* tempheader = CObexHeader::NewL();
    CleanupStack::PushL(tempheader);
    tempheader->SetFourByte(TObexInternalHeader::ECount, 0xFE22FF54);
    aObject.AddHeaderL(*tempheader);
    CleanupStack::Pop(tempheader);

    // add an Http header using new API
    //
    tempheader = CObexHeader::NewL();
    CleanupStack::PushL(tempheader);
    tempheader->SetByteSeqL(TObexInternalHeader::EHttp, KRef1HTTP);
    aObject.AddHeaderL(*tempheader);
    CleanupStack::Pop(tempheader);

    aObject.SetTypeL(KRefType);
    // set again to check header update functionality
    aObject.SetTypeL(KRefType);
    aObject.SetLengthL(aObjectBuf.Size());
    // set again to check header update functionality
    aObject.SetLengthL(aObjectBuf.Size());

    TBuf8<40> param;
    param.Copy(_L("\x04"));
    param.Append(_L("\x03"));
    param.Append(_L("App params 123"));
    aObject.SetAppParamL(param);
    // set again to check header update functionality
    aObject.SetAppParamL(param);

    const TTime KRef1Time = TDateTime(2003, EApril, 29, 10, 10, 10, 0);
    aObject.SetTimeL(KRef1Time);
    // set again to check header update functionality
    aObject.SetTimeL(KRef1Time);

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    ASSERT(descBuf);
    TPtr ptr(descBuf->Des());
    ptr.Zero();
    for (i=0; i<KDescLength; i++)
    {
        ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    }
    aObject.SetDescriptionL(ptr);
    // set again to check header update functionality
    aObject.SetDescriptionL(ptr);

    CleanupStack::PopAndDestroy(descBuf);

    aObject.SetTargetL(KRefTarget);
    // set again to check header update functionality
    aObject.SetTargetL(KRefTarget);

    CObexHeader* header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x30, KRef1Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(TObexInternalHeader::ECreatorID, 0x5F3A2343);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x36, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByteSeqL(TObexInternalHeader::EWanUUID, KRefTarget);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x3F, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xB0, 0x03);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xBF, 0x12);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xBE, 0x12);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xF0, 0x54545454);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
// 0x2F header doesnt have a FourByte HI Type.
    /*	header = CObexHeader::NewL();
    	CleanupStack::PushL(header);
    	header->SetFourByte(0x2F, 0x54);
    	aObject.AddHeaderL(*header);
    	CleanupStack::Pop(header);
    */
    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xFF, 0x00111243);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByteSeqL(0x73, KRefTarget);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByteSeqL(TObexInternalHeader::EObjectClass, KRefTarget);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    aObject.SetHeaderMask(KObexHdrName |KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrHttp | KObexHdrCount | KObexHdrAppParam | KObexHdrUserDefined | KObexHdrObjectClass | KObexHdrWanUUID  | KObexHdrCreatorID);

}
示例#20
0
void CReferenceHandler::CreateReferenceObject6L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 200;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object

    aObject.SetNameL(KRef6Name);
    aObject.SetTypeL(KRefImageJpegType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
    aObject.SetTimeL(KRef5Time);

    _LIT8(KRef1HTTP, "Accept: text/*");
    _LIT8(KRef2HTTP, "Location: http://www.w3.org");
    _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
    /*
    	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;

    	headerMask->SetHeader(TObexInternalHeader::EName);
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	if (aObject.Http())
    		{
    		NULL;
    		}
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	if (aObject.Http())
    		{
    		NULL;
    		}
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);


    	if (aObject.Http())
    		{
    		NULL;
    		}

    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	delete headerMask;
    */

    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef2HTTP);

    /*
    	if (aObject.Http())
    		{
    		NULL;
    		}


    	aObject.HeaderSet().SetMask(NULL);
    */

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    /*	ASSERT(descBuf);
    	TPtr ptr(descBuf->Des());
    	ptr.Zero();
    	for (i=0; i<KDescLength; i++)
    		{
    		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    		}
    	aObject.SetDescriptionL(ptr);
    */	CleanupStack::PopAndDestroy(descBuf);

    aObject.SetTargetL(KRefTarget);

    CObexHeader* header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x30, KRef1Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x36, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetUnicodeL(0x3F, KRef5Name);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xB0, 0x03);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByte(0xBF, 0x12);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xF0, 0x54);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
// 0x2F header doesnt have a FourByte HI Type.
    /*	header = CObexHeader::NewL();
    	CleanupStack::PushL(header);
    	header->SetFourByte(0x2F, 0x54);
    	aObject.AddHeaderL(*header);
    	CleanupStack::Pop(header);
    */

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetFourByte(0xFF, 0x43);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    header = CObexHeader::NewL();
    CleanupStack::PushL(header);
    header->SetByteSeqL(0x73, KRefTarget);
    aObject.AddHeaderL(*header);
    CleanupStack::Pop(header);

    aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget | KObexHdrUserDefined );
}