int main()
{
    __UHEAP_MARK;
    int retval =ESuccess;
    wchar_t* mywcharstring = NULL;
    RBuf8 myRBuf;
    myRBuf.CreateL(10);
    myRBuf.CleanupClosePushL();
    retval = WcharToRbuf8 (mywcharstring, myRBuf);

    if (retval == EInvalidPointer)
    {
    printf("wchartorbuf8 negative1 Passed\n");
    }
    else
    {
    assert_failed = true;
    printf("wchartorbuf8 negative1 Failed\n");
    }      
    CleanupStack::PopAndDestroy(1);
    __UHEAP_MARKEND;
    testResultXml("test_wchartorbuf8_negative1");
	
	return 0;
}
CResourceFile* CSsmCommandListResourceReaderImpl::CInitialiser::OpenResourceFileL(const TDesC& aFileName)
	{
	// open the resource file
	RFile file;
	CleanupClosePushL(file);
	User::LeaveIfError(file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly));

	// read entire resource file into a buffer
	TInt fileSize(0);
	User::LeaveIfError(file.Size(fileSize));
	RBuf8 buf;
	buf.CreateL(fileSize);
	CleanupClosePushL(buf);
	User::LeaveIfError(file.Read(buf));

	// create a CResourceFile from the buffer and add it to array (the CResourceFile takes its own copy of the buffer)
	CResourceFile* const resourceFile = CResourceFile::NewL(buf);
	CleanupStack::PushL(resourceFile);
	iResourcePool.AppendL(resourceFile);
	CleanupStack::Pop(resourceFile);
	iResourcePool.AppendL(aFileName);
	CleanupStack::PopAndDestroy(&buf);
	CleanupStack::PopAndDestroy(&file);
	return resourceFile;
	}
HBufC8* CNcdRequestBase::ExternalizeL() 
    {
    DLTRACEIN((""));
    
    const TXmlEngSerializationOptions KSerializationOptions = 
        TXmlEngSerializationOptions( 0x09, KSerializationOptionUtf8 );
    
#ifndef RD_XML_ENGINE_API_CHANGE
    TXmlEngString str;
    iDocument.SaveL(str, iRoot, KSerializationOptions);
    
    str.PushL();
    
    HBufC8* buf = HBufC8::NewL( str.Size() );
    *buf = str.PtrC8();
   
    // Free the original C-string
    CleanupStack::PopAndDestroy();        
#else
    
    RBuf8 rbuf;
    iDocument.SaveL( rbuf, iRoot, KSerializationOptions );

    CleanupClosePushL( rbuf );
    HBufC8* buf = rbuf.AllocL();
    CleanupStack::PopAndDestroy();  // rbuf

#endif
    
    DLTRACEOUT((""));
    return buf;
    }
Exemple #4
0
void CConnection::GetParametersResponseL(TBool aReturnLength)
	{
    if (ServiceProvider() == NULL || !iCommsDataObject)
        {
    	SetReturn(KErrNotReady);
    	return;
        }

    if (aReturnLength)
    	{
    	// Client requesting required buffer length for the serialised object
    	iCommsDataObjectLength = iCommsDataObject->Length();
    	SetReturn(iCommsDataObjectLength);
    	}
    else
    	{
		RBuf8 cdoBuffer;
		cdoBuffer.CreateL(iCommsDataObjectLength);
		CleanupClosePushL(cdoBuffer);
		User::LeaveIfError(iCommsDataObject->Store(cdoBuffer));
		Message().WriteL(0, cdoBuffer);
		CleanupStack::PopAndDestroy();	// queryBundleBuffer

		delete iCommsDataObject;
		iCommsDataObject = NULL;
		iCommsDataObjectLength = 0;

		SetReturn(KErrNone);
    	}
	}
void CSifTransportServer::ConstructL(const TDesC& aServerName, TInt aShutdownPeriodUs)
/**
	Second-phase construction initializes the superclass and
	starts the server.
 */
	{
	// Define a key (KSifOperationKey) which would be used to notify the client of any new operations.
    TInt ret = RProperty::Define(KUidSystemCategory, KSifOperationKey, RProperty::EByteArray, KSecurityPolicyWDD, KSecurityPolicyNone,(sizeof(TInt) * KMaxNumberOfOperations));
    if (ret != KErrAlreadyExists && ret != KErrNone)
        {
        User::Leave(ret);
        }

    if(ret == KErrNone)
        {
        // Create a empty CSifOperationKey object and publish it.
        CSifOperationKey* nullKey = CSifOperationKey::NewL();
        CleanupStack::PushL(nullKey);
        RBuf8 nullKeyBuffer;
        nullKeyBuffer.CleanupClosePushL();
        ExternalizeRefObjectL(*nullKey, nullKeyBuffer);
        User::LeaveIfError(RProperty::Set(KUidSystemCategory, KSifOperationKey, nullKeyBuffer));
		CleanupStack::PopAndDestroy(2, nullKey);
        }
    
    CScsServer::ConstructL(aShutdownPeriodUs);
	StartL(aServerName);
	}
int main()
{
    __UHEAP_MARK;
    int retval =ESuccess;
    char* mycharstring = "Hello Char String";
    int char_length= strlen(mycharstring);
    RBuf8 myRBuf;
    myRBuf.CreateL(30);
    myRBuf.CleanupClosePushL();
    retval = CharToRbuf8 (mycharstring, myRBuf);

    int buf_len = myRBuf.Length();
    if (retval ==ESuccess &&\
    char_length == buf_len &&\
    strncmp("Hello Char String",(char*)myRBuf.Ptr() , 17) ==0 )
    {
    printf("CharToRbuf8 content check Passed\n");
    }
    else
    {
    assert_failed = true;
    printf("CharToRbuf8 content check Failed\n");
    }      
    CleanupStack::PopAndDestroy(1);
    __UHEAP_MARKEND;
    testResultXml("test_chartorbuf8_content_check");
	return 0;
}
int ILibSocketWrapper_recv(int socketObject, char *buffer, int bufferLength)
{
	RSocket *s = (RSocket*)SocketArray[socketObject];
	RBuf8 *buf = new RBuf8();
	
	TRequestStatus status;
	TSockXfrLength aLen;
	int RetVal=0;
	
	if(buf->Create(bufferLength)==KErrNone)
	{
		s->RecvOneOrMore(*buf,0,status,aLen);
		User::WaitForRequest(status);
		if(status!=KErrNone)
		{
			RetVal = 0;
		}
		else
		{
			RetVal = aLen();
			Mem::Copy(buffer,(void*)buf->Ptr(),RetVal);
		}
	}
	buf->Close();
	delete buf;
	return(RetVal);
}
/** 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);

	}
// -------------------------------------------------------------------------------------
// CUpnpTmClientProfileService::SetClientProfileActionL
// @param aAction  Pointer to UPnP action object
// @return Returns upnp error code
// ---------------------------------------------------------------------------------
//
TUpnpErrorCode CUpnpTmClientProfileService::SetClientProfileActionL( CUpnpAction* aAction )
{
    OstTraceFunctionEntry0( CUPNPTMCLIENTPROFILESERVICE_SETCLIENTPROFILEACTIONL_ENTRY );
    TUint profileIdInt;
    // Fetch the value for profile ID argument
    TLex8 lex( aAction->ArgumentValue(KProfileId) );
    lex.Val(profileIdInt);
    OstTrace1( TRACE_ERROR, CUPNPTMCLIENTPROFILESERVICE_SETCLIENTPROFILEACTIONL, "CUpnpTmClientProfileService::SetClientProfileActionL;profileIdInt=%d", profileIdInt );

    // Fetch the value for client profile argument
    const TDesC8& clientProfile = aAction->ArgumentValue(KClientProfile);

    RBuf8 resultProfileBuf;
    TTerminalModeErrorCode ret = iTmServerImpl.SetClientProfile( profileIdInt,clientProfile,resultProfileBuf );
    if ( ret != ETerminalModeSuccess )
    {
        resultProfileBuf.Close();
        OstTrace0( TRACE_ERROR, DUP1_CUPNPTMCLIENTPROFILESERVICE_SETCLIENTPROFILEACTIONL, "CUpnpTmClientProfileService::SetClientProfileActionL" );
        return TUpnpErrorCode( ret );
    }
    CleanupClosePushL(resultProfileBuf);
    aAction->SetArgumentL( KResultProfile , resultProfileBuf );
    CleanupStack::PopAndDestroy(&resultProfileBuf);
    OstTraceFunctionExit0( CUPNPTMCLIENTPROFILESERVICE_SETCLIENTPROFILEACTIONL_EXIT );
    return EHttpOk;
}
/**
 * @SYMTestCaseID BA-CTSYD-DIS-SMS-NEGATIVE-UN0001
 * @SYMComponent telephony_ctsy
 * @SYMTestCaseDesc Test handing in CTSY dispatch when the NackSmsStored API is disabled 
 * @SYMTestPriority High
 * @SYMTestActions Disable API, call API, check correct error returned
 * @SYMTestExpectedResults Pass
 * @SYMTestType CT
 */
void CCTsySmsFUNegative::TestNackSmsStoredL()
	{
	TConfig config;
	config.SetSupportedValue(MLtsyDispatchSmsNackSmsStored::KLtsyDispatchSmsNackSmsStoredApiId, EFalse);
	config.PushL();

    OpenEtelServerL(EUseExtendedError);
    CleanupStack::PushL(TCleanupItem(Cleanup,this));
    OpenPhoneL();

    RMobileSmsMessaging messaging;
    TInt err = messaging.Open(iPhone);
    ASSERT_EQUALS(KErrNone, err);
    CleanupClosePushL(messaging);
 
    RBuf8 data;
    CleanupClosePushL(data);
    
    TRequestStatus reqStatus;
    TRequestStatus mockLtsyStatus;
    RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 receiveAttr;
    RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg receiveAttrPckg(receiveAttr);
  
    _LIT8(KMessage, "Happy New Year");
    TBuf8<100> forMsg;
  
    // receiving message:
    messaging.ReceiveMessage(reqStatus, forMsg, receiveAttrPckg);

    TSmsMsg smsMsg;
    TSmsMsg* smsMsgPtr(&smsMsg);
    TBool ind(EFalse);
    
    smsMsg.iSmsClass2 = ETrue;
    smsMsg.iDeleteAfterClientAck = ETrue;
    smsMsg.iSmsMsg.Copy(KMessage);

    TMockLtsyData2<TBool, TSmsMsg*> compTsyData(ind, smsMsgPtr);
    compTsyData.SerialiseL(data);

    iMockLTSY.CompleteL(KMockLtsyDispatchSmsNotifyReceiveSmsMessageIndId, KErrNone, data);
    
    User::WaitForRequest(reqStatus);    
    ASSERT_EQUALS(KErrNone, reqStatus.Int());
    AssertMockLtsyStatusL();
    
    TDesC8* msgPtr = const_cast<TDesC8*>(&KMessage);
    TInt rpCause(0);
    TMockLtsyData2<TDesC8*, TInt> expTsyData(msgPtr, rpCause);
    data.Close();
    expTsyData.SerialiseL(data);

    messaging.NackSmsStored(reqStatus, KMessage, rpCause); 

    User::WaitForRequest(reqStatus);
    ASSERT_EQUALS(KErrNotSupported, reqStatus.Int());
    AssertMockLtsyStatusL();
    
    CleanupStack::PopAndDestroy(4, &config);    //  messaging, this, data, config
	}
/**
 * @SYMTestCaseID BA-CTSYD-DIS-SIM-NEGATIVE-UN0016
 * @SYMComponent telephony_ctsy
 * @SYMTestCaseDesc Test handing in CTSY dispatch when the SendAPDUReq API is disabled 
 * @SYMTestPriority High
 * @SYMTestActions Disable API, call API, check correct error returned
 * @SYMTestExpectedResults Pass
 * @SYMTestType CT
 */
void CCTsySimFUNegative::TestSendAPDUReqL()
	{
	TConfig config;
	config.SetSupportedValue(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId, EFalse);
	config.PushL();
	
	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RMmCustomAPI customApi;
	OpenCustomApiLC(customApi);
	
	TBuf8<3> info;
	info.Append(1);
	info.Append(1);
	info.Append(1);
	
	RBuf8 dataBuf;
	CleanupClosePushL(dataBuf);
	_LIT8(KApduDataExp,"APDU DATA EXP ");
	dataBuf.CreateL(KApduDataExp);
	
	RMmCustomAPI::TApdu apdu(info,dataBuf);
	
	TRequestStatus status;
	customApi.SendAPDUReq(status, apdu);
	User::WaitForRequest(status);
	ASSERT_EQUALS(status.Int(), KErrNotSupported);

	AssertMockLtsyStatusL();
	config.Reset();
	CleanupStack::PopAndDestroy(4, &config);	// dataBuf, customApi, this, config		
	}
/**
Inserts the data into the URITbl. 

@param aUri URI object
@param [out] aUriId The URI will be filled upon successful insertion. This ID
	uniquelly indentifies the URI.

@return Returns the number of rows inserted. Normally 1. Otherwise returns with
		system-wide error code.
*/
TInt CUriListInterface::InsertIntoUriTblL ( const TUriC8& aUri, TInt& aUriId )
	{
	const TDesC8& id ( iStringPool.String (URILIST::EId,URILIST::Table).DesC() );
	aUriId = GetMaxIdValueL ( KUriTblName(), id ) + 1;
	_LIT8 ( KUriTblInsertStmt, "INSERT INTO %S VALUES (:V1, :V2, :V3, :V4, :V5, :V6, :V7, :V8)" );
	
	RBuf8 sqlStmt;
	sqlStmt.CreateL ( KMaxDbStmtLen );
	CleanupClosePushL ( sqlStmt );
	sqlStmt.Format ( KUriTblInsertStmt(), &(KUriTblName()) );
	MDBTransaction* dbTrans = iDbAccessor->PrepareTransactionL ( sqlStmt );
	CleanupStack::PopAndDestroy (); // sqlStmt
	CleanupStack::PushL ( TCleanupItem ( CUriListInterface::DestroyTransObj, dbTrans ) );
	// We are having 8 parameters for this query. First bind the query with parameter position 0 
	// and so on
	dbTrans->BindIntL ( URILIST::EId, aUriId ); 
	dbTrans->BindTextL ( URILIST::EScheme, aUri.IsPresent(EUriScheme) ? aUri.Extract ( EUriScheme ) : KNullDesC8() );
	dbTrans->BindTextL ( URILIST::EUserInfo, aUri.IsPresent(EUriUserinfo) ? aUri.Extract ( EUriUserinfo ) : KNullDesC8() );
	dbTrans->BindTextL ( URILIST::EHost, aUri.IsPresent(EUriHost) ? aUri.Extract ( EUriHost ) : KNullDesC8() ); 
	dbTrans->BindTextL ( URILIST::EPort, aUri.IsPresent(EUriPort) ? aUri.Extract ( EUriPort ) : KNullDesC8() );
	dbTrans->BindTextL ( URILIST::EPath, aUri.IsPresent(EUriPath) ? aUri.Extract ( EUriPath ) : KNullDesC8() ); 
	dbTrans->BindTextL ( URILIST::EQuery, aUri.IsPresent(EUriQuery) ? aUri.Extract ( EUriQuery ) : KNullDesC8() );  
	dbTrans->BindTextL ( URILIST::EFragments, aUri.IsPresent(EUriFragment) ? aUri.Extract ( EUriFragment ) : KNullDesC8() );  				

	TInt result = dbTrans->ExecuteL ();
	CleanupStack::PopAndDestroy (); //dbTrans
	return result;
	}
/**
 * @see GetInfoCpm test case NET-CONFIGURATOR-I-0018-HP
 *
 * doTestStepL virtual function does the below action
 * Connect to a configurator
 * Configurator get the module inidata section. Inidata section contains
   module initialisation information in the module's configuration file.
 * close the connection to configuator
 * Expected:-GetInfoCpm return kerrNone
*/
TVerdict CGetInfoCpm::doTestStepL()
	{

	SetTestStepResult(EFail);
	_LIT8(KNameDummyCpm,"DummyCpm");

	RBuf8 data;
	data.Create(100);
	TInt actualdatasize;

	//Configurator call to get the module inidata section
	TInt error = iConfigurator.GetModuleIniData(KNameDummyCpm(), data, actualdatasize);
	if (error == KErrOverflow)
		{
		INFO_PRINTF2(_L("GetModuleIniData returned KErrOverflow (%d)  \n"), error);
		data.ReAlloc(actualdatasize);
	    error = iConfigurator.GetModuleIniData(KNameDummyCpm(), data, actualdatasize);
	  	}
	else if (error == KErrRSModuleUnknown )
		{
		INFO_PRINTF2(_L("GetModuleIniData returned KErrRSModuleUnknown (%d)  \n"), error);
		}
	else if (error == KErrNone)
		{
	    INFO_PRINTF1(_L("GetModuleIniData Sucessful"));
	    SetTestStepResult(EPass);
		}
	else
		{
		INFO_PRINTF2(_L("GetModuleIniData  (DummyCpm) returned Error (%d)  \n"), error);
		}

    data.Close();
	return TestStepResult();
	}
Exemple #14
0
/**
Upcall from the Agent
*/
void CPppAgentNotificationHandler::ConnectCompleteL()
	{
	TBool pop = EFalse;
	CPppProvisionInfo* pppInfo = const_cast<CPppProvisionInfo*>(static_cast<const CPppProvisionInfo*>(GetExtension(STypeId::CreateSTypeId(CPppProvisionInfo::EUid, CPppProvisionInfo::ETypeId))));
	if (!pppInfo) // not provisioned yet
		{
		pppInfo = new (ELeave) CPppProvisionInfo;
		CleanupStack::PushL(pppInfo);
		pop = ETrue;
		}

	const TInt KMaxExcessData = 1503 * 2; // from PPP HDLC
	RBuf8 excessData;
	CleanupClosePushL(excessData);
	excessData.CreateL(KMaxExcessData);

	(void)ReadExcessData(excessData);
	User::LeaveIfError(pppInfo->SetExcessData(excessData));

	CleanupStack::PopAndDestroy(&excessData);

	pppInfo->SetIsDialIn(QueryIsDialIn());

	if (pop)
		{
		AppendExtensionL(pppInfo);
		CleanupStack::Pop(pppInfo);
		}
	}
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);
		
	}
int main()
{
    __UHEAP_MARK;
    RBuf8 myrbuf;
    TBufC8<5> myTBufC (_L8("hello"));
    myrbuf.Create(myTBufC);
    myrbuf.CleanupClosePushL();
    char *des= new char[5];
    int retval=ESuccess;
    int size=5;
    retval= Rbuf8ToChar(myrbuf,des,size);

    if(retval ==ESuccess)
    {
    printf("Test_rbuf8tochar_minsize passed\n");
    }
    else
    {
    assert_failed = true;
    printf("Test_rbuf8tochar_minsize FAILURE\n");
    }
    delete[] des;
    des=NULL;
    CleanupStack::PopAndDestroy(1);
    __UHEAP_MARKEND;
    testResultXml("Test_rbuf8tochar_minsize");
	return 0;
}
// -----------------------------------------------------------------------------
// XIMPRBuf8Helper::GrowIfNeededL()
// -----------------------------------------------------------------------------
//
EXPORT_C void XIMPRBuf8Helper::GrowIfNeededL( RBuf8& aBuf, const TInt aMaxLength )
    {
    if ( aBuf.MaxLength() < aMaxLength )
        {
        aBuf.ReAllocL( aMaxLength );
        }
    }
void CPlayStatusWatcher::ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData)
	{
	LOG_FUNC;

	// Read 4 byte Big-Endian error code before the payload
	RAvrcpIPCError errorResponse;
	TRAPD(err, errorResponse.ReadL(aData));
	err = err ? err : errorResponse.iError;

	RRemConPlayerInformationGetPlayStatusUpdateResponse response;
	if(!err)
		{
		// Parse the rest of the response (minus error code)
		TRAP(err, response.ReadL(aData.RightTPtr(aData.Length() - KLengthErrorResponse)));
		}

	aData.Close(); // data has been used now

	if(!err)
		{
		iObserver.MpsoPlayStatusChanged(aClientId, response.iStatus);
		SendPlayStatusUpdateRequest(aCommand, aClientId, response.iStatus);
		}
	else
		{
		// Should never get here with a valid player.  This client is
		// sending us junk.
		iObserver.MpsoError(aClientId);
		}
	}
void CMockPowerEngine::QueueProcessedEventL(const TInt aCommandId, const TUint8 aTransId, TDesC8& aData)
	{
	// Request
	RBuf8 buffer;
	
	// Request
	
	FurtherProcessEventL(aCommandId, aData);

	TMockHwrmPluginData reqData(aTransId,aData);
	reqData.SerialiseL(buffer);
	// copy serialised data to a HBufC8 pointer
	HBufC8* req = HBufC8::New(buffer.Length());
	TPtr8 reqPtr = req->Des();
	reqPtr = buffer;
	// queue that as expected request (take ownership of req)
	CMockSYEngine::DoQueueEventL(TMockSYEvent::EMessage,aCommandId,req,KErrNone,EFalse,0);
	buffer.Close();
	
	QueueProcessedCompletionL(aCommandId, aTransId, buffer, aData);
	// copy serialised data to a HBufC8 pointer
	HBufC8* resp = HBufC8::New(buffer.Length());
	TPtr8 respPtr = resp->Des();
	respPtr = buffer;
	// queue that as response (take ownership of req)
	CMockSYEngine::DoQueueEventL(TMockSYEvent::ECompletion,aCommandId,resp,KErrNone,EFalse,1);
	buffer.Close();
	}
/**
Auxilary function should be called only when we need to generate hash values from the screen and returns its hex format.
@param aHexString the output MD5 hash hex string obtained from iBitmapDevice
*/
EXPORT_C void CTHashReferenceImages::GenerateHashAndReturnInHexFormatL(TDes &aHexString)
	{
	TInt bufLen = CFbsBitmap::ScanLineLength(iBitmapDevice->SizeInPixels().iWidth, iBitmapDevice->DisplayMode());
	RBuf8 buff;
	buff.CreateL(bufLen);
	CleanupClosePushL(buff);	
	CMD5 *md = CMD5::NewL();
	CleanupStack::PushL(md);
	for (TPoint pos(0, 0); pos.iY < iBitmapDevice->SizeInPixels().iHeight; pos.iY++)
		{
		iBitmapDevice->GetScanLine(buff,pos,iBitmapDevice->SizeInPixels().iWidth,iBitmapDevice->DisplayMode());
		md->Update(buff);
		}

	TBuf8<KLengthOfHashValue> hashString;
	//md will be reset after calling CMD5::Final() as Final will call Reset.
	hashString.Copy(md->Final());
	aHexString.Zero();

	for(TInt icount=0; icount < hashString.Length(); icount++)
		{
		aHexString.AppendNumFixedWidth(hashString[icount], EHex, 4);
		}
	CleanupStack::PopAndDestroy(2, &buff);
	}
/** 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 CCTsyCallControlMultipartyFUNegative::DriverCreateConferenceCallL(RMobilePhone::TMobileService aMobileService, TInt aCallId1, TInt aCallId2)
	{
	RBuf8 data;
	CleanupClosePushL(data);

	DriverDialAndHoldFirstCallDialSecondCallL(aMobileService, aCallId1, aCallId2);

	TMockLtsyData2<TInt, TInt> createConfData(aCallId1, aCallId2);
	createConfData.SerialiseL(data);
	iMockLTSY.ExpectL(MLtsyDispatchCallControlMultipartyCreateConference::KLtsyDispatchCallControlMultipartyCreateConferenceApiId, data);

    RMobileCall::TMobileCallStatus callStatus = RMobileCall::EStatusConnected;
    TMockLtsyCallData1<RMobileCall::TMobileCallStatus> mockCallData(
    		aCallId1, RMobilePhone::EServiceUnspecified, callStatus);
    data.Close();
    mockCallData.SerialiseL(data);
    iMockLTSY.CompleteL(KMockLtsyDispatchCallControlNotifyCallStatusChangeIndId, KErrNone, data);

    TMockLtsyCallData1<RMobileCall::TMobileCallStatus> mockCallData2(
    		aCallId2, RMobilePhone::EServiceUnspecified, callStatus);
    data.Close();
    mockCallData2.SerialiseL(data);
    iMockLTSY.CompleteL(KMockLtsyDispatchCallControlNotifyCallStatusChangeIndId, KErrNone, data);

    CleanupStack::PopAndDestroy(1, &data);
	} // CCTsyCallControlMultipartyFUNegative::DriverCreateConferenceCallL
// ---------------------------------------------------------------------------------
// CUpnpTmAppServerService::LaunchAppActionL
// @param aAction pointer to upnp action object
// @return Returns upnp error code
// ---------------------------------------------------------------------------------
//
TUpnpErrorCode CUpnpTmAppServerService::LaunchAppActionL( CUpnpAction* aAction )
   {
   OstTraceFunctionEntry0( CUPNPTMAPPSERVERSERVICE_LAUNCHAPPACTIONL_ENTRY );
   TUint appIdInt;  
   TUint profileIdInt;
   // Validates the input parameters
   if ( ( ConvertDescriptorToInt( aAction->ArgumentValue(KAppId), appIdInt ) != KErrNone )
       || ( ConvertDescriptorToInt( aAction->ArgumentValue(KProfileId), profileIdInt ) != KErrNone ))
        {
        OstTraceExt2( TRACE_ERROR, CUPNPTMAPPSERVERSERVICE_LAUNCHAPPACTIONL, "CUpnpTmAppServerService::LaunchAppActionL;appIdInt=%u;profileIdInt=%u", appIdInt, profileIdInt );
        return EInvalidArgs;   // either invalid app ID or invalid profile ID  
        }

   RBuf8 launchUrl;
   TTerminalModeErrorCode ret = iTmServerImpl.LaunchApp( appIdInt,profileIdInt,launchUrl );
   
   if ( ret != ETerminalModeSuccess )
       {
       // Error is returned
       launchUrl.Close();
       OstTrace0( TRACE_ERROR, DUP1_CUPNPTMAPPSERVERSERVICE_LAUNCHAPPACTIONL, "CUpnpTmAppServerService::LaunchAppActionL" );   
       return TUpnpErrorCode( ret );
       }
   CleanupClosePushL(launchUrl);
   aAction->SetArgumentL( KAppLaunchUri , launchUrl );
   
   CleanupStack::PopAndDestroy(&launchUrl);
   OstTraceFunctionExit0( CUPNPTMAPPSERVERSERVICE_LAUNCHAPPACTIONL_EXIT );
   return EHttpOk;  
   }
void CTcpClientTestUPnP1::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage )
	{
	if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () )
		{
		const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage );
		iClientId = msg.iNodeId;
		CompleteSelf ( KErrNone );
		}
	else if ( aMessage.IsMessage<TUpnpMessage::TResponse > () )
		{
		TUpnpMessage::TResponse& msg = message_cast< TUpnpMessage::TResponse >(aMessage);
		
		RBuf8 responseBodyData;
		responseBodyData.CreateMax ( msg.iBodyData.Length () );
		responseBodyData.FillZ ( msg.iBodyData.Length () );
		msg.iBodyData.CopyOut ( responseBodyData );	
		responseBodyData.Close ();
		msg.iBodyData.Free ();
		
		CompleteSelf(EPass);
		}
	else if ( aMessage.IsMessage<TEBase::TError > () )
		{
		iLogger.WriteFormat(_L("<i>TEBase::TError..... </i>"));
		CompleteSelf(EFail);
		}

	}
int main()
{
    __UHEAP_MARK;
    RBuf8 myrbuf;
    TBufC8<20> myTBufC (_L8(""));
    myrbuf.Create(myTBufC);
    myrbuf.CleanupClosePushL();
    wchar_t * des= new wchar_t [20]; 
    int size=20;
    int retval =ESuccess;
    retval= Rbuf8ToWchar(myrbuf,des,size);

    if(retval == EDescriptorNoData)
    {
    printf("Test_rbuf8towchar_nodata passed\n");
    }
    else
    {
    assert_failed = true;
    printf("Test_rbuf8towchar_nodata FAILURE\n");
    }
    delete[] des;
    des = NULL;
    CleanupStack::PopAndDestroy(1);
    __UHEAP_MARKEND;
    testResultXml("test_rbuf8towchar_nodata");
	return 0;
}
int main()
{
    int retval =ESuccess;
    wstring des;
    __UHEAP_MARK;
    RBuf8  buf;
    buf.Create(10);
    buf.Copy((TUint8 *)"Hello", 5);
    buf.CleanupClosePushL();
    //int size =15;
    retval = Rbuf8ToWstring(buf, des  );

    int rbuf_len = buf.Length();
    int string_len = des.length();
    if (retval ==ESuccess && rbuf_len == string_len && rbuf_len == 5 && string_len == 5)
    {
        printf("test rbuf8towstring boundary2 Passed\n");
    }
    else
    {
        assert_failed = true;
        printf("test rbuf8towstring boundary2 Failed\n");
    }
    CleanupStack::PopAndDestroy(1);
    __UHEAP_MARKEND;
    testResultXml("test_rbuf8towstring_boundary2");
    return 0;
}
// ---------------------------------------------------------------------------
// Data request from CatalogsPCConnectivityPlugin
// First ask the size from server, then give correct size CBufFlat
// ---------------------------------------------------------------------------
//
void RCatalogsPCConnectivityClient::GetDataL( 
    TDataType& aMimeType, CBufFlat& aData )
    {
    TPckgBuf<TInt> pckgSize;
    TPckgBuf<TDataType> pckgMIME;
    
    User::LeaveIfError( SendReceive( 
            ECatalogsPCConnectivityGetSize, 
            TIpcArgs( &pckgMIME, &pckgSize ) ) );
    
    TInt size = pckgSize();
    aMimeType = pckgMIME();
    
    RBuf8 desData;
    desData.CreateL( size );
    desData.CleanupClosePushL();
    
    User::LeaveIfError( SendReceive( 
            ECatalogsPCConnectivityGetData, 
            TIpcArgs( &desData ) ) );
    
    aData.Reset();
    aData.ExpandL( 0, size );
    aData.Write( 0, desData, size );        
            
    CleanupStack::Pop(); //desData
    desData.Close();
    }
// -----------------------------------------------------------------------------
// XIMPTestPresenceDataUtils::InsertPrefixL
// -----------------------------------------------------------------------------
//
EXPORT_C void XIMPTestPresenceDataUtils::InsertPrefixL( const TDesC8* aPrefix, RBuf8& buf )
    {
    if ( aPrefix )
        {
        XIMPRBuf8Helper::GrowIfNeededL( buf, aPrefix->Length() + buf.Length() );
        buf.Insert( 0, *aPrefix );
        }
    }
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 CTestAppUi::ConstructL()
	{
	// Complete the UI framework's construction of the App UI.
	BaseConstructL(CEikAppUi::ENoAppResourceFile);

	iPropertyObs = new(ELeave) CPropertyObserver;
	iPropertyObs->StartL();

    //Signal that application is started
    RSemaphore sem;
    TInt err = sem.OpenGlobal(KStartShmaTestAppGood);
    if(err == KErrNone)
        {
        sem.Signal();
        sem.Close();
        }

	RFs fs;
	err = fs.Connect();
	User::LeaveIfError(err);
	CleanupClosePushL(fs);
	
	RFile file;
	err = file.Open(fs, KPanicFile, EFileRead);
	if (err == KErrNotFound)
		{
		CleanupStack::PopAndDestroy(&fs);
		// We are not using the file, so just return
		return;
		}
	else
		{
		User::LeaveIfError(err);
		CleanupClosePushL(file);
		
		TBuf8<30> buf;
		err = file.Read(buf);
		User::LeaveIfError(err);

		CleanupStack::PopAndDestroy(&file);
		err = fs.Delete(KPanicFile);

		RBuf8 writableArgs;
		writableArgs.CreateL(buf, 30);
		CleanupClosePushL(writableArgs);
		TPtr16 args16 = writableArgs.Expand();
	
		_LIT(KTestGoodProcPanic, "Panic");
	 	if (args16 == KPanicCommandLineOption1)
	 		User::Panic(KTestGoodProcPanic, KProcPanic);
	 	else if (args16 == KPanicCommandLineOption2)
			User::Panic(KTestGoodProcPanic, KErrNone);
	 	
	 	CleanupStack::PopAndDestroy(2, &fs);
		}
	}