void CTcpClientTestUPnP13::NewData(TUint aCount)
	{
	RMBufChain data;
	RBuf8 resData;
	
	iLogger.WriteFormat(_L("<i>NewData..... </i>"));
	iSSP->GetOption(1,KCHMaxLength,resData);
	resData.Create( aCount );
	iSSP->GetOption(KCHOptionLevel,KCHMaxLength,resData);
	TInt len = *(TUint*) resData.Ptr();
	resData.Close();
	
	iSSPData->GetData(data,aCount,0);
	resData.Create( aCount );
	data.CopyOut(resData);
	resData.Close();
	resData.Create( aCount );
	iSSP->GetOption(KCHOptionLevel,KCHLastMessage,resData);
	TBool isLastMsg = *(TUint*) resData.Ptr();
	resData.Close();
	data.Init();
	
	if(isLastMsg)
		{
		iLogger.WriteFormat(_L("<i>NewData.LastMsg.... </i>"));
		CompleteSelf ( KErrNone );
		}
	}
/*
	Tests whether Publishing a Service/Device is performing as specified in UPnP specifications.
	@param			aOperationType is reference to a section name in ini file where required parameters
					needs to be referred for this operation.
	@return			None.
 */
void CTestRControlChannel::PublishServiceL (const TDesC& aOperationType)
	{
	_LIT(KInfoLogFile, "CTestRControlChannel::PublishServiceL ().... \n");
	INFO_PRINTF1(KInfoLogFile);
	CRControlChannelObserver* upnpObserver = CRControlChannelObserver::NewL(this);
	CleanupStack::PushL( upnpObserver );
	iObserverArray.Append(upnpObserver);

	RPnPParameterBundle pnpBundle ;
	pnpBundle.Open();
    CleanupClosePushL( pnpBundle );
    pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
    RParameterFamily family = pnpBundle.CreateFamilyL(EUPnPServiceRegisterParamSet);
   	CUPnPServiceRegisterParamSet* registerServiceParamSet = CUPnPServiceRegisterParamSet::NewL(family );

   	_LIT(KParentDeviceUid, "ParentDeviceUid");
   	TPtrC parentDeviceUid;
	GetStringFromConfig(aOperationType, KParentDeviceUid, parentDeviceUid);

	RBuf8 parentDeviceUidBuf;
	parentDeviceUidBuf.Create(parentDeviceUid.Length());
	parentDeviceUidBuf.Copy(parentDeviceUid);
	registerServiceParamSet->SetDeviceUidL (parentDeviceUidBuf);


	TPtrC serviceType;
	GetStringFromConfig(aOperationType, KServiceType, serviceType);
	RBuf8 serviceTypeBuf;
	serviceTypeBuf.Create(serviceType.Length());
	serviceTypeBuf.Copy(serviceType);
	registerServiceParamSet->SetUriL ( serviceTypeBuf );


	TInt duration;
	GetIntFromConfig(aOperationType, KCacheControl, duration);
	registerServiceParamSet->SetCacheControlData (duration);

	ExtractServiceDescriptionL (aOperationType, *registerServiceParamSet);

	_LIT8(KInitialMessage, "Initial notification message");
	registerServiceParamSet->SetInitialMessageL(KInitialMessage);
	
	OpenPublisherL();

	iPublisher.Publish( pnpBundle );
	CActiveScheduler::Start();

	serviceTypeBuf.Close();
	parentDeviceUidBuf.Close();
	CleanupStack::PopAndDestroy( &pnpBundle );
	CleanupStack::Pop( upnpObserver );
	
	InitiateControlL();
	_LIT(KInfoLogFile1, "CTestRControlChannel::PublishServiceL () Stop.... \n");
	INFO_PRINTF1(KInfoLogFile1);
	
	}
Exemplo n.º 3
0
/*!
  Implementation for traverse so always true.
*/
bool SdFixture::execute(void * objectInstance, QString actionName, QHash<QString, QString> parameters, QString & stdOut)
{
    debug("SdFixture::execute");
    bool returnValue = true;
#ifdef Q_OS_SYMBIAN
    const TUid fixtureUid = TUid::Uid(0x20026F7E);    
    THashFunction32<RBuf8> hashFunc( RBufHashFunction );
    TIdentityRelation<RBuf8> idFunc( RBufIdentityFunction );
    RHashMap<RBuf8, RBuf8> paramPairs( hashFunc, idFunc );
    CleanupClosePushL( paramPairs );
    debug("SdFixture::execute read params");
    QHashIterator<QString, QString> i(parameters);
    while (i.hasNext()) {
        i.next();
        if(!i.key().isEmpty() && !i.value().isEmpty() && i.key() != OBJECT_TYPE){
            debug("parametrit: " + i.key()+";"+ i.value());
            debug("SdFixture::execute read key");
            RBuf8 keyBuf;
            RBuf8 valueBuf;
            TPtrC16 keyStr(reinterpret_cast<const TUint16*>(i.key().utf16()));
            TPtrC16 valueStr(reinterpret_cast<const TUint16*>(i.value().utf16()));
            keyBuf.Create(keyStr.Length());
            valueBuf.Create(valueStr.Length());
            keyBuf.Copy(keyStr);
            valueBuf.Copy(valueStr);
            debug("SdFixture::execute insert to hash");    
            paramPairs.InsertL( keyBuf, valueBuf );
            debug("SdFixture::execute pop hbufs");    
        }
    }
    debug("SdFixture::execute make fixture");
    CTasFixturePluginInterface* fixture = CTasFixturePluginInterface::NewL( fixtureUid );
    CleanupStack::PushL( fixture );
    debug("SdFixture::execute conver actionname");
    TPtrC16 actionStr(reinterpret_cast<const TUint16*>(actionName.utf16()));
    RBuf8 actionBuf;
    actionBuf.Create(actionStr.Length());
    CleanupClosePushL( actionBuf );
    actionBuf.Copy(actionStr);
    debug("SdFixture::execute execute fixture");
    RBuf8 response;
    CleanupClosePushL( response );
    if(fixture->Execute( NULL, actionBuf, paramPairs, response ) != KErrNone){
        returnValue = false;
    }
    debug("SdFixture::execute convert response");
    stdOut  = XQConversions::s60Desc8ToQString(response);
    CleanupStack::PopAndDestroy( 4 );//response, fixture, paramPairs
#endif    
    debug("SdFixture::execute done");
    return returnValue;
}
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;
}
/** 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;
	}
/**
 * @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();
	}
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;
}
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);
}
bool ChatSessionImpl::sendChatData(QString newChatData)
{
	TPtrC16 dataPtr(reinterpret_cast<const TUint16*>(newChatData.utf16()));
	RBuf8 chatData;
	chatData.Create(300);
	chatData.Copy(dataPtr);

	mMessageSource->SendDataL(chatData);

	chatData.Close();

	return true;
}
void CTestRControlChannel::ExtractServiceDescriptionL (const TDesC& aConfigSection, CUPnPServiceRegisterParamSet& aServiceRegisterParamSet)
	{
	RFs fs;
	RFile file;
	RBuf8 buf;

	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TPtrC descriptionPath;
	_LIT(KDescriptionPath, "Description_Path");
	GetStringFromConfig(aConfigSection, KDescriptionPath, descriptionPath);

	TInt err = file.Open(fs, descriptionPath, EFileShareReadersOnly);
	
	// For Hardware system path is c:, so descriptionPath value present in '.ini' is referring 'c:'
	if ( err == KErrPathNotFound )
		{				
		RBuf fileName;
		TDriveName aSystemDrive;
		TDriveUnit driveunit(RFs::GetSystemDrive());
		aSystemDrive.Zero();
		aSystemDrive=driveunit.Name();				
		fileName.CreateL ( descriptionPath.Length () );
		fileName.Zero();
		fileName.Append(aSystemDrive);
		fileName.Append ( descriptionPath.Mid ( aSystemDrive.Length () ) );				
		
		err = file.Open(fs, fileName, EFileShareReadersOnly);
		}
	if (err != KErrNone)
		{
		User::LeaveIfError(err);
		}

	CleanupClosePushL(file);
	TInt fileSize = 0;
	file.Size(fileSize);

	buf.Create(fileSize);

	err = file.Read(buf, fileSize);
	aServiceRegisterParamSet.SetServiceDescriptionL ( buf );

	CleanupStack::PopAndDestroy(2 );
	buf.Close();
	_LIT(KInfoLogFile, "CRControlChannelObserver::ExtractServiceDescriptionL End.... \n");
	INFO_PRINTF1(KInfoLogFile);
	}
Exemplo n.º 12
0
void CSmfCredMgrClientSymbian::authenticatedPluginListL(
		QString RegistrationToken, QStringList& List)
	{
	CSmfPluginIDListParams* fetchPluginListParams =
			new (ELeave) CSmfPluginIDListParams;
	CleanupStack::PushL(fetchPluginListParams);

	//fill input params
	fetchPluginListParams->iRegistrationToken = qt_QString2HBufC(
			RegistrationToken);

	//create buffer to serialize data
	CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	fetchPluginListParams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr1 = buf->Ptr(0);
	TIpcArgs args;
	args.Set(0, &bufPtr1);

	// to get the data from server, we create a space.
	HBufC8* retBuf = HBufC8::NewL(KMaxBufSize);
	CleanupStack::PushL(retBuf);

	TPtr8 outputptr = retBuf->Des();
	args.Set(1, &outputptr);

	iSession.RequestService(ESendPluginIDList, args);

	//create buffer to read data received
	RBuf8 dataBuf;
	CleanupClosePushL(dataBuf);
	dataBuf.Create(outputptr);

	fetchPluginListParams->InternalizeL(dataBuf);

	smfcredmgrclientutil::convertToQStringList(
			fetchPluginListParams->iPluginList, List);

	CleanupStack::PopAndDestroy(&dataBuf);
	CleanupStack::PopAndDestroy(retBuf);
	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::PopAndDestroy(fetchPluginListParams);
	}
// The client application has signaled that all attributes have been returned so 
// response can now be sent
EXPORT_C void CRemConMediaInformationTarget::Completed()
	{
	if (!iInProgress)
		{
		return;
		}
	// Finalise response; update number of attributes returned
	iResponse->iNumberAttributes = iResponse->iAttributes.Count();

	//Check the bound of the number of attributes, zero is not permitted
	if (iResponse->iNumberAttributes == 0)
		{
		return SendError(KErrAvrcpMetadataInternalError);
		}
	
	// Allocate a buffer for the formatted message
	RBuf8 messageBuffer;
	if ( messageBuffer.Create(iResponse->Size()) != KErrNone )
		{
		// On OOM drop the message
		iResponse->Close();
		return;
		}
		
	// send the result back to the CT
	TInt error = KErrNone;
	TRAP(error, iResponse->WriteL(messageBuffer));
	if (error == KErrNone)
		{
		InterfaceSelector().SendUnreliable(TUid::Uid(KRemConMediaInformationApiUid),
								EGetElementAttributes, ERemConResponse, messageBuffer);
		}
	
	// Make sure attribute list is reset for next time
	iResponse->Close();
	messageBuffer.Close();
	
	iInProgress = EFalse;
	if (!iMsgQueue.IsEmpty())
		{
		iNextMessageCallBack->CallBack();
		}
	
	}
// from MRemConInterfaceIf
void CRemConMediaInformationTarget::SendError(TInt aError)
	{
	RBuf8 outBuf;
	if (outBuf.Create(KAVCFrameMaxLength) != KErrNone)
		{
		// On OOM drop the message
		return;
		}
	
	TInt error = 0;
	RAvrcpIPCError response;
	response.iError = aError;
	TRAP(error, response.WriteL(outBuf));   // Don't send error if OOM
	if (error == KErrNone)
		{
		InterfaceSelector().SendUnreliable(TUid::Uid(KRemConMediaInformationApiUid),
							EGetElementAttributes, ERemConResponse, outBuf);
		}
	outBuf.Close();
	}
int ILibSocketWrapper_recvfrom(int socketObject, char *buffer, int bufferLength, struct sockaddr *src)
{
	RSocket *s = (RSocket*)SocketArray[socketObject];
	TRequestStatus status;
	TInetAddr addr;
	int RetVal=0;
	RBuf8 *buf = new RBuf8();
	
	if(buf->Create(bufferLength)==KErrNone)
	{
		TProtocolDesc aProtocol;
		
		s->Info(aProtocol);
		if(aProtocol.iSockType==KSockStream)
		{
			s->RemoteName(addr);
			((struct in_addr*)src->sa_data)->s_addr = ntohl(addr.Address());
			src->sa_port = htons(addr.Port());
			RetVal = ILibSocketWrapper_recv(socketObject, buffer, bufferLength);
		}
		else
		{
			s->RecvFrom(*buf,addr,(unsigned int)0,status);
			User::WaitForRequest(status);
			if(status!=KErrNone)
			{
				RetVal = 0;
			}
			else
			{
				((struct in_addr*)src->sa_data)->s_addr = ntohl(addr.Address());
				src->sa_port = htons(addr.Port());
				Mem::Copy(buffer,buf->Ptr(),buf->Length());
				RetVal = buf->Length();
			}
		}
	}
	buf->Close();
	delete buf;
	return(RetVal);
}
Exemplo n.º 16
0
	TInt GetRecogniserInfo(TUid aImplementationUid, RArray<TDataType>& aMimeTypes)
		{
		TInt size = SendReceive(EGetRecog, TIpcArgs(aImplementationUid.iUid));
		if (size < 0) return size;
		TInt err = aMimeTypes.Reserve(size/sizeof(TDataType));
		if (err) return err;
		RBuf8 buf;
		err = buf.Create(size);
		if (err) return err;
		err = SendReceive(EGetRecog2, TIpcArgs(&buf));
		if (err) { buf.Close(); return err; }

		const TDataType* ptr = (const TDataType*)buf.Ptr();
		for (TInt i = 0; i < size/sizeof(TDataType); i++)
			{
			err = aMimeTypes.Append(ptr[i]);
			if (err) break;
			}
		buf.Close();
		return err;
		}
Exemplo n.º 17
0
int TransferTestThread(TAny* aData) {

    // This delay is needed to make sure this thread starts only after
    // receive data function is called from the main thread.

    TData& data = *(TData *)aData;

    // Wait On the semaphore.
    // This is to make sure that this thread do not start untill main thread
    // calls ReceiveData method.
    data.iSem1->Wait();

    testTransferThread.Start(_L("Start Transfer Thread\n"));
    RExDriverChannel  *iLdd2;

    iLdd2= data.iLdd;

    RBuf8 rxBuf;

    TInt r=rxBuf.Create(1000);

    testTransferThread.Printf(_L("Check Multiple receive request on same channel : "));
    // Try calling Receive Data again from the same channel when already another
    // receive data request is pending.
    // It should return KErrInUse.
    r = iLdd2->ReceiveData(rxBuf);
    testTransferThread(r == KErrInUse);
    testTransferThread.Printf(_L("Fails : As Expected \n"));

    r = iLdd2->TransmitData(*data.iTxData);
    testTransferThread(r == KErrNone);

    testTransferThread.Printf(_L("Data Transfer Complete.\n"));

    testTransferThread.End();
    testTransferThread.Close();

    return KErrNone;

}
void CUPnPRControlChannelAO::ExtractSoapResponse(RBuf8& aSoapResponse)
	{
	aSoapResponse.Create(iCompleteBuffer);
	}
Exemplo n.º 19
0
void ScrShotsGenUtils::DumpJsFileL(CScrShotsSettings* scrShotsSettings)
{
    CGetImei* getImei = CGetImei::NewL();
    CleanupStack::PushL(getImei);
    RBuf8 formatBuf;
    formatBuf.Create(256);
    formatBuf.CleanupClosePushL();
    TFileName infoFile;
    
    User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(infoFile));
    infoFile.Append( KDeviceJSFile );
    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName());
    infoFile.Insert(0, KCDriveWithColon);
    
    RFs fsConn;
    User::LeaveIfError(fsConn.Connect());
    CleanupClosePushL(fsConn);
    RFile jsFile;
    if(BaflUtils::FileExists(fsConn, infoFile)){
        BaflUtils::DeleteFile(fsConn, infoFile);
    }
    //now create the file
    User::LeaveIfError(jsFile.Create(fsConn, infoFile, EFileWrite));
    CleanupClosePushL(jsFile);
    
//    User::LeaveIfError(jsFile.Write(KFunctionBlockStart));
    RBuf8 values;
    values.Create(256);
    for(int i = 0; i < KDeviceParamsCount ; i++){
        formatBuf.Zero();
        TInt sizeOfItem = User::StringLength((TText8 *)DeviceParams [i]);
        TPtr8 item((unsigned char*)DeviceParams [i],sizeOfItem ,sizeOfItem );
        switch(i){
            //device_model
            case 0:{
                CDeviceTypeInformation* devInfo = SysUtil::GetDeviceTypeInfoL();
                CleanupStack::PushL(devInfo);
                TPtrC manufName, modelCode, modelName;
                devInfo->GetManufacturerName(manufName);
                devInfo->GetModelCode(modelCode);
                devInfo->GetModelName(modelName);
                RBuf8 manufName8, modelName8, modelCode8;
                manufName8.Create(128); modelName8.Create(128); modelCode8.Create(128);
                manufName8.CleanupClosePushL(); modelName8.CleanupClosePushL(); modelCode8.CleanupClosePushL();
                manufName8.Copy(manufName);
                modelName8.Copy(modelName);
                modelCode8.Copy(modelCode);
                values.Format(KModelNameFormatString, &manufName8, &modelName8, &modelCode8);
                CleanupStack::PopAndDestroy(4);
                break;
            }
            //firmware_version
            case 1:{
                RBuf swVersion;
                swVersion.Create(128);
                SysUtil::GetSWVersion(swVersion);
                values.Copy(swVersion);
                TInt pos = 0;
                while((pos = values.Find(_L8("\n"))) != KErrNotFound){
                    //values.Delete(pos,1);
                    values.Replace(pos,1,_L8("_"));
                }
                swVersion.Close();
                break;
            }
            
            //ram_info
            case 2:{
                TInt totalram= 0;
                HAL::Get(HALData::EMemoryRAM, totalram);
                totalram /= 1024;
                values.Num(totalram);
                break;
            }
            
            //uptime
            case 3:{
                TTimeIntervalMicroSeconds32 iTickPeriod;
                UserHal::TickPeriod(iTickPeriod);
                TUint tickCount = User::TickCount();
                TUint noOfTicksPerSecond = (1000 * 1000) / iTickPeriod.Int();
                TInt noOfSecsSinceStartUp = tickCount / noOfTicksPerSecond;//noOfMicroSecsSinceStartup / (1000 * 1000);
                values.Num(noOfSecsSinceStartUp);
                break;
            }
            
            //scrshot count
            case 4:{
                values.Num(scrShotsSettings->TotalScrShotCount());
                break;
            }
            
            //symbian version
            case 5:{
                TVersion epocver = User::Version();
                values.Copy(epocver.Name());            
                break;
            }
            
            //series 60 version
            case 6:{
                VersionInfo::TPlatformVersion platformVersion;
                VersionInfo::GetVersion(platformVersion);
                TInt aMajor = platformVersion.iMajorVersion;
                TInt aMinor = platformVersion.iMinorVersion;
                values.Format(_L8("%d.%d"),aMajor, aMinor);
                break;
            }
            //country code
            case 7:{
            
                TLocale loc;
                int code = loc.CountryCode();
                values.Num(code);
                break;
            }
            //imei hash
            case 8:{
                TBuf8<256> inputimei;
                TBuf8<256> outimeihash;
                if(getImei->IsImeiFetched()){
                    getImei->GetImei(inputimei);
                    GetWhirlPoolHash(outimeihash,inputimei);
                    values.Copy(outimeihash);
                }
            }
            break;

        }
        
        formatBuf.Format(KStringVariableDeclaration, 
                &item, 
                &values);
        TRACE_ON(RDebug::Printf((const char*)formatBuf.PtrZ()));
        jsFile.Write(formatBuf);
    }
    values.Close();
    CleanupStack::PopAndDestroy(4);
    //TODO: This code should be commented in final release build
#if BRAHMA_DEBUG
    //code to copy the js file just created to the c:\ so that it can be analyzed
    _LIT(KTargetFileName, "c:\\device_info.js");
    BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(),infoFile, KTargetFileName);
#endif
}
Exemplo n.º 20
0
/**
 * Write the file to the hard drive.
 * 
 * @param aFileName 
 * @param aBodyPartArray
 */ 
void CMultipartTestContainer::WriteFileL( const TDesC& aFileName,
                                           RPointerArray<CBodyPart>& aBodyPartArray )
    {
    RFs fs;
    fs.Connect();
    CleanupClosePushL(fs);
    RFile output;
    TInt err = output.Open(fs, aFileName, EFileWrite);
    if (err == KErrNotFound)
    	{
			User::LeaveIfError(output.Create(fs, aFileName, EFileWrite));
			}		
    
    // output file
    TInt size = aBodyPartArray.Count();
    TInt i;
		_LIT8(KEol, "\r\n");
    for (i = 0; i < size; i++)
        {

        CBodyPart* bodyPart = aBodyPartArray[i];

        if( bodyPart->Url().Ptr() )
            {
            output.Write(_L8("***************Ur"));
            output.Write(KEol);
			RBuf8 narrow;
			err = narrow.Create(bodyPart->Url().Length()*2);
			if (err != KErrNone)
				{
				INFO_PRINTF1(_L("Error printing Url to output file; continueing..."));
				}						
			narrow.Copy(bodyPart->Url());
            output.Write(narrow.Left(narrow.Length()));
            output.Write(KEol);
            }
        if( bodyPart->ContentID().Ptr() )
            {
            output.Write(_L8("***************ContentID"));
            output.Write(KEol);
            output.Write(bodyPart->ContentID() );
            output.Write(KEol);
            }
        if( bodyPart->Charset().Ptr() )
            {
            output.Write(_L8("***************Charset"));
            output.Write(KEol);
            output.Write( bodyPart->Charset() );
            output.Write(KEol);
            }
        if( bodyPart->ContentType().Ptr() )
            {
            output.Write(_L8("***************ContentType"));
            output.Write(KEol);
            output.Write( bodyPart->ContentType() );
            output.Write(KEol);
            }
        if( bodyPart->Headers().Ptr() )
            {
            output.Write(_L8("***************Headers"));
            output.Write(KEol);
            output.Write(bodyPart->Headers() );
            output.Write(KEol);
            }
        if( bodyPart->Body().Ptr() )
            {
            output.Write(_L8("***************Body"));
            output.Write(KEol);
            output.Write(bodyPart->Body() );
            output.Write(KEol);
            }
        output.Write(_L8("=========================================part ends"));
        output.Write(KEol);

        } // end of loop
    
    output.Close();
    CleanupStack::PopAndDestroy(1, &fs);
    fs.Close();
		}
Exemplo n.º 21
0
TBool CSmfCredMgrClientSymbian::AuthDataSetL(QString RegToken,
		QDateTime Validity, SmfAuthParams& AuthTokenSet)
	{
	RDebug::Printf("+In AuthDataSetL()");
	CSmfFetchAuthTokenSet* fetchAuthTokenSetParams =
			new (ELeave) CSmfFetchAuthTokenSet;

	CleanupStack::PushL(fetchAuthTokenSetParams);

	//fill the input params
	fetchAuthTokenSetParams->iRegistrationToken = qt_QString2HBufC(RegToken);
	fetchAuthTokenSetParams->iValidity = Validity.toTime_t();

	//create buffer to serialize data
	CBufFlat* buf = CBufFlat::NewL(KMaxBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	fetchAuthTokenSetParams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr = buf->Ptr(0);

	TIpcArgs args;
	args.Set(0, &bufPtr);

	// to get the data from server, we create a space.
	HBufC8* retBuf = HBufC8::NewL(KMaxBufSize);
	CleanupStack::PushL(retBuf);

	TPtr8 outputptr = retBuf->Des();
	args.Set(1, &outputptr);

	iSession.RequestService(ESendAuthDataSet, args);

	//create buffer to read data sent by server
	RBuf8 dataBuf;
	CleanupClosePushL(dataBuf);
	dataBuf.Create(outputptr);

	fetchAuthTokenSetParams->InternalizeL(dataBuf);


	CleanupStack::PopAndDestroy(&dataBuf);
	CleanupStack::PopAndDestroy(retBuf);
	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);

	//return EFalse if count is 0
	if (fetchAuthTokenSetParams->iAuthTokenArray.Count() == 0)
		{
		CleanupStack::PopAndDestroy(fetchAuthTokenSetParams);
		RDebug::Printf("-In AuthDataSetL()");
		return EFalse;
		}

	smfcredmgrclientutil::RArrayToSmfAuthParams(
			fetchAuthTokenSetParams->iAuthTokenArray, AuthTokenSet);


	CleanupStack::PopAndDestroy(fetchAuthTokenSetParams);
	RDebug::Printf("-In AuthDataSetL()");
	return ETrue;
	}
Exemplo n.º 22
0
QString CSmfCredMgrClientSymbian::storeAuthDataL(SmfAuthParams Set,
		QDateTime Validity, QList<QUrl> URLList, QStringList PluginList,
		QString AuthAppAID, bool Flag)
	{
	RDebug::Printf("+In storeAuthDataL()");
	CSmfStoreAuthParams* authenticationProcessData =
			new (ELeave) CSmfStoreAuthParams;
	CleanupStack::PushL(authenticationProcessData);

	//create space for iRegistrationToken
	authenticationProcessData->iRegistrationToken = HBufC::NewL(
			KMaxRegistrationTokenLength);


	//fill the input params
	smfcredmgrclientutil::SmfAuthParamstoRArray(Set,
			authenticationProcessData->iAuthTokenArray);
	authenticationProcessData->pluginIDEnabled = Flag;
	//set iValidity
	authenticationProcessData->iValidity = Validity.toTime_t();


	//set authappid
	authenticationProcessData->iAuthAppID = qt_QString2HBufC(AuthAppAID);
	//set the lists
	authenticationProcessData->iURLList
			= smfcredmgrclientutil::convertToSymbianURLList(URLList);
	authenticationProcessData->iPluginIDList
			= smfcredmgrclientutil::convertToSymbianPluginList(
					PluginList);

	//create buffer to serialize data
	CBufFlat* buf = CBufFlat::NewL(KMaxBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	authenticationProcessData->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr = buf->Ptr(0);

	TIpcArgs args;
	args.Set(0, &bufPtr);

	
	// to get the data from server, we create a space.
	HBufC8* retBuf = HBufC8::NewL(KMaxBufSize);
	CleanupStack::PushL(retBuf);

	TPtr8 outputptr = retBuf->Des();
	args.Set(1, &outputptr);

	iSession.RequestService(EStoreAuthData, args);

	//create buffer to read data received
	RBuf8 dataBuf;
	CleanupClosePushL(dataBuf);
	dataBuf.Create(outputptr);

	authenticationProcessData->InternalizeL(dataBuf);

	TPtr regTokenPtr(
			authenticationProcessData->iRegistrationToken->Des());

	//convert and return
	QString regString = qt_TDes2QString( regTokenPtr );

	CleanupStack::PopAndDestroy(&dataBuf);
	CleanupStack::PopAndDestroy(retBuf);
	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::Pop();

	return regString;
	}
Exemplo n.º 23
0
/**
 Test the driver data flow path by loopback,
 i.e Transmit the data and receive same data back.
 It runs the device @ default configuration

 @param		aLoopback
 				Loopback mode as internal or external
 			aTxData
 				Transmit Data buffer
 			aRxSize
 				Receive data size
 */
void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize)
{
    TInt r;
    TRequestStatus stat;


    iTest.Printf(_L("Test Concurrent Synchronous Requests - Tx/Rx\n"));

    // Open channel
    r=iLdd.Open(KUnit1);
    iTest(r==KErrNone);

    // Create a buffer that has to be filled and returned by the driver
    RBuf8 rxBuf;
    r=rxBuf.Create(aRxSize);
    iTest(r==KErrNone);

    r=iLdd.SetIntLoopback(aLoopback);
    iTest(r==KErrNone);


    TData TData(&iLdd,&aTxData,&iSem1);


    // Call ldd interface ReceiveData() API to get data to rxBuf
    RThread		TransferThread;
    _LIT(KThreadName, "TestThread");

    TInt ret = TransferThread.Create(		KThreadName, 		// Thread name
                                            TransferTestThread,		// Function to be called
                                            KDefaultStackSize,
                                            KHeapSize,
                                            KHeapSize,
                                            (TAny *)&TData
                                    );


    iTest.Printf(_L("Receive Data\n"));

    TransferThread.Logon(stat);

    TransferThread.Resume();

    iSem1.Signal();
    r = iLdd.ReceiveData(rxBuf);
    // In case of zero length request
    if (aRxSize==0)
    {
        // Driver should return error immediately
        iTest(r!=KErrNone);

        TransferThread.Kill(KErrNone);
        TransferThread.Close();

        // Close the RBuf
        rxBuf.Close();
        // Close channel
        iLdd.Close();
        return;
    }

    // Print the receive data to display.
    // It automatically checks the Tx and Rx data. Fails if not matched.
    //
    TInt i;
    iTest.Printf(_L("Received Data of size (%d):"),rxBuf.Size());
    for (i=0; i<rxBuf.Size(); i++)
    {
        iTest.Printf(_L("%c"),(rxBuf.Ptr())[i]);
        if ((TUint8)(rxBuf.Ptr())[i] != aTxData[i])
        {
            iTest.Printf(_L("Transmit and Receive data do not match\n"));
            iTest(EFalse);
        }
    }
    iTest.Printf(_L("\n"));


    User::WaitForRequest(stat);

    TransferThread.Close();
    // Free the receive buffer
    rxBuf.Close();
    // Close channel
    iLdd.Close();
}
Exemplo n.º 24
0
/**
 Test the driver data flow path by loopback, 
 i.e Transmit the data and receive same data back.  
 It runs the device @ default configuration
 
 @param		aLoopback
 				Loopback mode as internal or external
 			aTxData
 				Transmit Data buffer
 			aRxSize
 				Receive data size 
 */	
void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize)
	{
	TInt r;	
	
 	// Request status object for transmit and receive. These object will be 
 	// used to read the status of asynchronous requests after the notification
 	// of request completion 
 	//
 	TRequestStatus txStatus;
 	TRequestStatus rxStatus;
 	
 	// Timers and their respective status objects for Tx and Rx
 	RTimer timerTx;
	RTimer timerRx;
	TRequestStatus timeStatusTx;
	TRequestStatus timeStatusRx;
	
	iTest.Printf(_L("Test Concurrent Asynchronous Requests - Tx/Rx\n"));
	
	// Open channel 	
	r=iLdd.Open(KUnit1);
	iTest(r==KErrNone);
	
 	// Create a buffer that has to be filled and returned by the driver		
 	RBuf8 rxBuf; 	
 	r=rxBuf.Create(aRxSize); 	
 	iTest(r==KErrNone);	
	 	
	r=iLdd.SetIntLoopback(aLoopback);
	iTest(r==KErrNone);
	 	
 	// Create the timer that is relative to the thread 
 	r = timerTx.CreateLocal();
 	iTest(r==KErrNone);
 	r = timerRx.CreateLocal();
 	iTest(r==KErrNone);
  	 	 	 	
 	// Trigger timerRx expiry after KTimeOutTxRx. The status should be pending
	timerRx.After(timeStatusRx,KTimeOutTxRx);
	iTest(timeStatusRx==KRequestPending);
	 	  			
 	// Call ldd interface ReceiveData() API to get data to rxBuf
 	r = iLdd.ReceiveData(rxStatus, rxBuf);
 	// In case of zero length request
 	if (aRxSize==0)
 		{
 		 // Driver should return error immediately
 		iTest(r!=KErrNone); 		
 		// Close the RBuf
 		rxBuf.Close(); 		
 		// Close channel
		iLdd.Close();
 		return;
 		}
 	else
 		{
 		// Asynchronous request should be pending, with request message
 		// posted to driver successfully
 		//
 		iTest((r==KErrNone)&&(rxStatus.Int()==KRequestPending));
 		}
 		
   	// Trigger timerTx expiry after KTimeOutTxRx. The status should be pending   	
	timerTx.After(timeStatusTx,KTimeOutTxRx);
	iTest(timeStatusTx==KRequestPending);
		
 	// Call ldd interface TransmitData() API test data descriptor as parameter
 	r = iLdd.TransmitData(txStatus, aTxData);
 	// In case of zero length request
 	if (aTxData.Size()==0)
 		{
 		// Driver should return error immediately
 		iTest(r!=KErrNone);
 		// Close the RBuf
		rxBuf.Close();
		// Close channel
		iLdd.Close(); 	
		return;
 		}
 	else
 		{
 		// Asynchronous request should be pending, with request message
 		// posted to driver successfully
 		//
 		iTest(r==KErrNone);
 		}
 		 	    	 	
 	// Wait till the request is complete on rxStatus and txStatus. User thread
 	// is blocked with this call, till it is notified about the request 
 	// completion.
 	//
 	if(txStatus.Int()==KRequestPending)
 		User::WaitForRequest(txStatus,timeStatusTx);
 	if(rxStatus.Int()==KRequestPending)
 		User::WaitForRequest(rxStatus,timeStatusRx);
 	
 	// if transmit has occured correctly, the iTimeStatus will not be KErrNone, else
 	// no transmit complete has occured and iTimer has expired
 	iTest (timeStatusTx!=KErrNone);
 	iTest (timeStatusRx!=KErrNone);
 	
 	// Cancel the iTimer request
 	timerTx.Cancel();
 	timerRx.Cancel();
 	
 	// txStatus holds the request completion. TRequestStatus::Int() returns the
 	// completion code. It will be KErrNone in case of successful completion
 	//
 	r = txStatus.Int();
 	iTest((r==KErrNone)||(r==KErrTimedOut));
 	r = rxStatus.Int();
 	iTest((r==KErrNone)||(r==KErrTimedOut));
 	
 	// Close the handle to the timerTx and timerRx
 	timerTx.Close();
 	timerRx.Close();
 	
 	// Print the recieve data to display and verify the data received manually.
 	TInt i;
 	iTest.Printf(_L("Received Data of size (%d):"),rxBuf.Size());
 	for (i=0;i<rxBuf.Size();i++)
	 	{
	 	iTest.Printf(_L("%c"),(TUint8*)(rxBuf.Ptr())[i]);	
	 	if ((rxBuf.Ptr())[i] != aTxData[i])
 			{
 			iTest.Printf(_L("Transmit and Receive data do not match\n"));		
 			iTest(EFalse);
 			}
	 	}
	 	
 	iTest.Printf(_L("\n"));
 	
 	// Free the receive buffer
 	rxBuf.Close();
 	
	// Close channel
	iLdd.Close();
	}