Ejemplo n.º 1
0
// -----------------------------------------------------------------------------
// CRedirDesc::Configure
// Implementation for Configure the Media i.e. connect to stdio server
// -----------------------------------------------------------------------------
//
TInt CRedirDesc::Configure()
	{
	TInt ret;
	TBuf8<1> aDes;
	iStatus = ENoServer;
	ret = iSession.Connect(); 
	if( KErrNone  == ret)
		{
		ret = iSession.CheckMedia(aDes);
		if( KErrNone == ret)
			{
			iStatus = EConnected;
			//In case both the media is NONE the server would fail the connection and 
			//this block of the code in not executed. If any of media either read or 
			//write in NONE specified in config.ini file then the iReadNone and iWriteNone
			//flag is set to ETrue which is check in read and write functions.
			if( !aDes.Compare(_L8("R")) )
				{
				iReadNone = ETrue;
				}
			else
				{
				if( !aDes.Compare(_L8("W")) )
					{
					iWriteNone = ETrue;	
					}
				}
			}
		}
	return ret;
	}
Ejemplo n.º 2
0
void CTestUtilClass::TestUtilClass_Step2L()
	{
	//
	// Test AppendBinaryDataToAscii
	//

	TBuf8<10> testPdu;
	testPdu.Append(0x00);
	testPdu.Append(0x10);
	testPdu.Append(0x20);
	testPdu.Append(0x40);
	testPdu.Append(0xf3);
	testPdu.Append(0x7b);
	testPdu.Append(0x99);
	testPdu.Append(0x5e);
	testPdu.Append(0x01);
	testPdu.Append(0x02);

	TBuf8<400> buf;
	buf.Zero();
	INFO_PRINTF1(_L(".."));
	CATSmsUtils::AppendDataToAscii(buf,testPdu);

	if(buf.Compare(_L8("00102040f37b995e0102"))!=0)
		TESTL(KErrCorrupt);

	TBuf8<10> testPdu2;

	INFO_PRINTF1(_L(".."));
	TESTL(KErrNone == CATSmsUtils::ConvertAsciiToBinary(buf,testPdu2));
	if(testPdu.Compare(testPdu2)!=0)
		TESTL(KErrCorrupt);
	}
Ejemplo n.º 3
0
//Setting OOM testing
void CenrepSrvOOMTest::SetL()
	{
	TInt ret=KErrNone;
	TInt intValue=0;
	TReal realValue=0;

	//---------------SetL-----------------------------------
	//Setting an integer key
	ret = RepositorySingleSetL(*iServerRepo, 0x60, 600);
	TESTKErrNoneL(ret);
	ret=iServerRepo->Get(0x60,intValue);
	TESTL(intValue== 600);

	//Setting a real key
	ret = RepositorySingleSetL(*iServerRepo, 0x66, 99.99);
	TESTKErrNoneL(ret);
	ret=iServerRepo->Get(0x66,realValue);
	TESTL(realValue==99.99);

	//Setting a string key
	//Even ascii(8 bytes) are stored as 16 bytes!!!
	_LIT8(KString,"sixhundred");
	TBuf8<50> stringChangeValue=KString();
	ret = RepositorySingleSetL(*iServerRepo, 0x69, stringChangeValue);
	TESTKErrNoneL(ret);

	TBuf8<50> keyString;
	ret=iServerRepo->Get(0x69,keyString);
	TESTKErrNoneL(ret);
	TESTL(keyString.Compare(KString)==0);
	}
Ejemplo n.º 4
0
void CTestUtilClass::TestUtilClass_Step3L()
	{
	//
	// Test removal of SCA from a PDU
	//

	// Create a PDU
	RMobilePhone::TMobileAddress addr;
	addr.iTypeOfNumber=RMobilePhone::EInternationalNumber;
	addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan;
	addr.iTelNumber.Copy(_L("# * 44 7785 016 005"));

	TBuf8<400> buf;
	buf.Zero();	
	TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr));
	if(buf.CompareF(_L8("0e91ab01632960000"))!=0)
		TESTL(KErrCorrupt);

	_LIT8(KDummyData,"dummy data");		// must have even number of chars
	buf.Append(KDummyData);

	// fill data with garbage
	addr.iTypeOfNumber=RMobilePhone::EAbbreviatedNumber;
	addr.iNumberPlan=RMobilePhone::EPrivateNumberPlan;
	addr.iTelNumber.Copy(KTelNumberGarbage);

	// Get SCA from PDU and validate the output
	INFO_PRINTF1(_L(".."));
	TESTL(KErrNone == CATSmsUtils::ReadAndRemoveAddressFromAscii(buf,addr));
	if(addr.iTypeOfNumber!=RMobilePhone::EInternationalNumber ||
	   addr.iNumberPlan!=RMobilePhone::EIsdnNumberPlan || 
	   addr.iTelNumber.Compare(_L("#*01632960000"))!=0 ||
	   buf.Compare(KDummyData)!=0)
		TESTL(KErrCorrupt);
	}
TVerdict CTestStepUnitMMFVidClient::DoControllerCalled(TInt aFunction, const TDesC8& aText, TBool aExpected)
	{
	// Get the controller
	TInt err = KErrNone;
	RMMFController* controller = NULL;
	err = GetPlayerController(controller);
	if (err != KErrNone)
		{
		INFO_PRINTF2(_L("Error getting controller %d"), err);
		return EInconclusive;
		}

	// Check that the correct functions were called in the controller
	TBuf8<64> functionText;
	TUid uid = { KMmfVideoTestControllerUid };
	TMMFMessageDestination handleInfo(uid);
	TMMFMessageDestinationPckg message(handleInfo);

	TBuf<64> functionText16;
	err = controller->CustomCommandSync(message, aFunction, KNullDesC8, KNullDesC8, functionText);
	if (err == KErrNone ) 
		{
		functionText16.Copy(aText);
		
		if (aExpected)
			{
			INFO_PRINTF2(_L("Expect %S"), &functionText16);
			}
		else
			{
			INFO_PRINTF2(_L("Should not have %S"), &functionText16);
			}
			
		if ((functionText.Compare(aText) == 0 && aExpected) ||
			(functionText.Compare(aText) != 0 && !aExpected))
			{
			iTestStepResult = EPass;
			}
		else 
			{
			iTestStepResult = EFail;
			return iTestStepResult;
			}
		}
	return iTestStepResult;
	}
void CPreModifierPlugin::FsFileTempL(TFsPluginRequest& aRequest)
	{
	TBuf<256> testfilename1;

	//setting up test files
	testfilename1.Append(iDriveToTest);
	testfilename1.Append(_L(":\\Data\\"));

	if (aRequest.IsPostOperation())
		{
		_LOG(_L("CPreModifierPlugin::FsFileTempL, post intercept"));

		RFilePlugin fileplugin(aRequest);
		TInt err = fileplugin.AdoptFromClient();
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL
		
		//write to the newly created temp file
		TBuf8<64> wbuffer;
		wbuffer.Copy(_L8("TestTestTest"));
		err = fileplugin.Write(0, wbuffer);
		_LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Write to the newly created temp file returned %d"), err);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL

		TInt length = wbuffer.Length();
		HBufC8* tempBuf = HBufC8::NewMaxLC(length);
		TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
		err = fileplugin.Read(0, tempBufPtr);
		_LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Read returned %d"), err);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL
		
		fileplugin.Close();

		//testing the correct thing has been written to the drive
		err = wbuffer.Compare(tempBufPtr);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL
			
		CleanupStack::PopAndDestroy();
		}
	else
		{
		User::Invariant();
		}
	}
TInt CTestHistoryLog::SetGetAndResetAlertInfoL( CStifItemParser& /*aItem */)
{
	//Defining Constants
	const TInt KBufSize = 10;
  TBuf8<KBufSize> vendorInfo;
  vendorInfo.Copy(KVendorInfo);  	
	
	//Creating Object
	CSmlAlertInfo* info = CSmlAlertInfo::NewLC();

	//Setting Info 
	info->TaskIds().Append(1);
	info->TaskIds().Append(KTwo);
	info->TaskSyncTypes().Append( (TSmlSyncType)0);
	info->TaskSyncTypes().Append( (TSmlSyncType)1);
	info->SetConfirmation(EFalse);
	info->SetConnectionId(KUidNSmlMediumTypeInternet.iUid);
	info->SetErrorCode(KErrorEleven);
	info->SetJobControl(CSmlAlertInfo::ECreateJob);
	info->SetProfileId(KOne);
	info->SetProtocolType(ESmlDataSync);
	info->SetSessionId(KTwo);
	info->SetTransportId(KUidNSmlMediumTypeInternet.iUid);
	info->SetVendorSpecificInfoL(vendorInfo);
	info->SetUimode(KTwelve);
	
	//Verifying the info
	TL( info->Connection() == KUidNSmlMediumTypeInternet.iUid );
	TL( info->ErrorCode() == KErrorEleven );
	TL( info->JobControl() == CSmlAlertInfo::ECreateJob );
	TL( info->Profile() == KOne );
	TL( info->Protocol() == ESmlDataSync );
	TL( info->SessionId() == KTwo );
	TL( info->Transport() == KUidNSmlMediumTypeInternet.iUid );	
	TBuf8<KBufSize> getVendorInfo = info->VendorSpecificInfo();
	TL(!(vendorInfo.Compare(getVendorInfo)));
	TL( info->GetUimode() == KTwelve );
	TL( info->CreateSession() );
	
	//Reset
	info->Reset();
	
	//Verification after Reset
	TL( info->JobControl() == CSmlAlertInfo::EDoNotCreateJob );
	TL( !info->CreateSession() );
	TL( info->VendorSpecificInfo() == KNullDesC8 );
	
	//Destroy the object
	CleanupStack::PopAndDestroy(info);
	//Return no error if everything passes
  return KErrNone; 
}	
Ejemplo n.º 8
0
TInt CCallDummyBase::SetFaxSharedHeaderFile(const TTsyReqHandle aTsyReqHandle, CFaxSharedFileHandles* aFaxSharedFileHandles)
	{
	TBuf8<25> line;
	TInt ret = aFaxSharedFileHandles->File().Read(0, line);

	if(ret!=KErrNone || line.Compare(DACQ_MFAXFILE) != KErrNone)
		TsyPanic(KTsyPanicDataCorrupted);
	
	delete aFaxSharedFileHandles;
	aFaxSharedFileHandles = NULL;
	
	ReqCompleted(aTsyReqHandle,KErrNone);
	return KErrNone;
	}
Ejemplo n.º 9
0
TBool ShaUtils::ValidateSha(const TDesC8& aBuffer, const TDesC8& aSha)
	{
	//calculate sha on buffer
	TBuf8<20> bufferSha;
	CSHA1* payloadSha1 = CSHA1::NewL();
	CleanupStack::PushL(payloadSha1);
	payloadSha1->Update(aBuffer);
	bufferSha.Copy(payloadSha1->Final());
	CleanupStack::PopAndDestroy(payloadSha1);
	
	if(bufferSha.Compare(aSha) == 0)
		return ETrue;
	else
		return EFalse;
	}
Ejemplo n.º 10
0
static void VerifyFileContent(const TDesC8& aPattern, TInt64 aFilePos)
	{
	__ASSERT_DEBUG(aFilePos >= 0, User::Invariant());
	
	TheBuf.Zero();
	
	RFile64 file;
	TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters);
	TEST2(err, KErrNone);

	err = file.Read(aFilePos, TheBuf, aPattern.Length());
	TEST2(err, KErrNone);
	
	file.Close();
	
	err = TheBuf.Compare(aPattern);
	TEST2(err, 0);
	}
//-----------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::IsOperatorProfile
// 
//-----------------------------------------------------------------------------
//
TBool CNSmlDsProvisioningAdapter::IsOperatorProfile( const CNSmlDsProfileElement& aProfile )
    {
    TBuf8<KMaxValueLength> value;
    CRepository* rep = NULL;
    TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncInternalKeys ) );
    if ( err == KErrNone )
        {
        rep->Get( KNsmlOpDsOperatorSyncServerId, value );
        delete rep;
        }
    
    if ( aProfile.iServerId )
    	{
        if ( value.Compare( *aProfile.iServerId ) == 0 )
            {
            return ETrue;
            }
    	}
    return EFalse;
    }
Ejemplo n.º 12
0
static void VerifyFileContent(const TDesC8& aPattern)
	{
	TheBuf.Zero();
	
	RFile64 file;
	TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters);
	TEST2(err, KErrNone);

	TInt64 fsize;
	err = file.Size(fsize);
	TEST2(err, KErrNone);
	TEST2((TInt)fsize, aPattern.Length());
	
	err = file.Read(TheBuf, aPattern.Length());
	TEST2(err, KErrNone);
	
	file.Close();
	
	err = TheBuf.Compare(aPattern);
	TEST2(err, 0);
	}
TInt CStreamControl::LaunchController()
    {
    TInt status(KErrNotReady);
    // KUidMediaTypeAudio need to be part of source
    ConfigureControllerLoader(KUidMediaTypeAudio,
            CMMFFindAndOpenController::EPlayback);
    // if Streaming case

    if (!iSourceControl || !iSinkControl)
        return KErrNotReady;
   CSourceBase *sourceBase=(dynamic_cast<CSourceBase*>(iSourceControl));
   TUid sourceUID ;

   if (sourceBase)
      {
       sourceUID = sourceBase->GetSourceUid();
      }
   else
       {
       return KErrNotReady;
       }

   CSinkBase *sinkBase=(dynamic_cast<CSinkBase*>(iSinkControl));
   TUid sinkUID;

   if(sinkBase)
      sinkUID = sinkBase ->GetSinkUid();
   else
      return KErrNotReady;

    if (iSourceControl->Type() == KDataBufferSourceControl)
        {
        MDataBufferSource* streamingSource =
                static_cast<MDataBufferSource*>(iSourceControl);
        iFindAndOpenController->ConfigureSourceSink(
                CMMFFindAndOpenController::TSourceSink( /*TUid::Uid(0x10207AF3)*/sourceUID),
                CMMFFindAndOpenController::TSourceSink( /*KUidMmfAudioOutput*/sinkUID) );
        TBuf8<KMaxMimeLength> mimeType;
        status = streamingSource->GetMimeType(mimeType);
        if (status == KErrNone)
            {

            // This Flag is defined so that if the Helix Controller Supports
            // the playback of Local Media for WMA, then the HTTP Streaming still
            // goes through the Old WMA Controller( AdvancedAudioController)                
            // We are launching the Old WMA Controller using the UID.

#ifdef __WINDOWS_MEDIA                
#ifndef RD_PD_FOR_AUDIO_CONTENT_VIA_HELIX_ENGINE
            if(!mimeType.Compare(KWMAMimeType()))
                {
                iFindAndOpenController->OpenByControllerUid(TUid::Uid(0x10207A9B),KNullUid);
                }
            else
#endif
#endif
                {
                iFindAndOpenController->OpenByMimeType(mimeType);
                }
            }
        }

    if (iSourceControl->Type() == KFileSourceControl)
        {
        MFileSource* fileSource = static_cast<MFileSource*>(iSourceControl);

        HBufC* fileName = HBufC::NewLC(KMaxPath);
        TPtr fileNamePtr = fileName->Des();

        TInt err = fileSource->GetFileName(fileNamePtr);

        HBufC8* fileName1 = HBufC8::NewLC(KMaxPath);
        TPtr8 fileNamePtr1 = fileName1->Des();
        fileNamePtr1.Copy(fileNamePtr);

        HBufC8* mimeType = HBufC8::NewLC(KMaxMimeLength);
        TPtr8 mimeTypePtr = mimeType->Des();

        status = iSourceControl->GetMimeType(mimeTypePtr);

        iFindAndOpenController->ConfigureSourceSink(
                CMMFFindAndOpenController::TSourceSink(sourceUID,
                        fileNamePtr1),
                CMMFFindAndOpenController::TSourceSink(sinkUID));

        TMMFileSource source(fileNamePtr,
                ContentAccess::KDefaultContentObject, ContentAccess::EPlay);
        iFindAndOpenController->OpenByFileSource(source);

        CleanupStack::PopAndDestroy(mimeType); // mimeType
        CleanupStack::PopAndDestroy(fileName1); // fileName
        CleanupStack::PopAndDestroy(fileName); // fileName
        }

    if (iSourceControl->Type() == KDescriptorSourceControl)
        {
        MDescriptorSource* descriptorSource =
                static_cast<MDescriptorSource*>(iSourceControl);
        iFindAndOpenController->ConfigureSourceSink(
                CMMFFindAndOpenController::TSourceSink( /*TUid::Uid(0x10207AF3)*/sourceUID),
                CMMFFindAndOpenController::TSourceSink( /*KUidMmfAudioOutput*/sinkUID) );
        TBuf8<KMaxMimeLength> mimeType;
        status = descriptorSource->GetMimeType(mimeType);
        if (status == KErrNone)
            {
            // This Flag is defined so that if the Helix Controller Supports
            // the playback of Local Media for WMA, then the HTTP Streaming still
            // goes through the Old WMA Controller( AdvancedAudioController)                
            // We are launching the Old WMA Controller using the UID.

            iFindAndOpenController->OpenByMimeType(mimeType);
            }
        }
    return status;
    }
Ejemplo n.º 14
0
void CPreModifierPlugin::FsFileReplaceL(TFsPluginRequest& aRequest)
	{
	TFileName filename;
	TParse parse;
	
	filename = aRequest.Src().FullName();

	TUint mode;
	TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
	iLastError = err;
	iLineNumber = __LINE__;
	if(err!=KErrNone)
		User::Leave(err); //trapped in DoRequestL

	parse.Set(filename, NULL, NULL);
	TPtrC extension(parse.Ext());

	_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, file: %S"), &filename);
	
	if (aRequest.IsPostOperation())
		{
		_LOG(_L("CPreModifierPlugin::FsFileReplaceL, post intercept"));
		if ((extension.CompareF(_L(".tst")) == 0) && (aRequest.Message().Int1() != 0))
			{
			//write to the newly replaced file
			TBuf8<64> wbuffer;
			wbuffer.Copy(_L8("TestTestTest"));

			RFilePlugin fileplugin(aRequest);
			TInt err = fileplugin.AdoptFromClient();
			iLastError = err;
			iLineNumber = __LINE__;
			if(err!=KErrNone)
				User::Leave(err); //trapped in DoRequestL

    		err = fileplugin.Write(0, wbuffer);
			_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Write to the newly created file returned %d"), err);
			iLastError = err;
			iLineNumber = __LINE__;
			if(err!=KErrNone)
				User::Leave(err); //trapped in DoRequestL

			TInt length = wbuffer.Length();
			HBufC8* tempBuf = HBufC8::NewMaxLC(length);
			TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
			err = fileplugin.Read(0, tempBufPtr);
			_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Read returned %d"), err);
			iLastError = err;
			iLineNumber = __LINE__;
			if(err!=KErrNone)
				User::Leave(err); //trapped in DoRe

			//testing the correct thing has been written to the drive
			err = wbuffer.Compare(tempBufPtr);
			iLastError = err;
			iLineNumber = __LINE__;
			if(err!=KErrNone)
				User::Leave(err); //trapped in DoRequestL
			
			fileplugin.Close();
			CleanupStack::PopAndDestroy();
			}
		}
	else
		{
		User::Invariant();
		}
	}
Ejemplo n.º 15
0
TVerdict CPPPMinMaxMMU::doTestStepL()
	{
	const TInt KMaxMMU = 4000;
	const TInt KMinMMU = 1;

	TBuf8<KMaxMMU> *sendBuf = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(sendBuf);
	
	TBuf8<KMaxMMU> *recvBuf = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(recvBuf);
	
	TBuf8<KMaxMMU> *recvBuf2 = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(recvBuf2);

    //initialize COMM
    //CommInitL(EFalse);
    
	//Start Comms server
// 	_LIT(KPhbkSyncCMI, "phbsync.cmi");
//    (void)StartC32WithCMISuppressions(KPhbkSyncCMI);
	
	SetTestStepResult(EPass);
    INFO_PRINTF1(_L("Starting: Socket Server\n"));
    
    RSocketServ ss;

    // Start the socket server
    TEST(KErrNone == ss.Connect());
    RSocket sock;
    TRequestStatus sta;
	INFO_PRINTF1(_L("Open a socket\n"));
    
    // Get the test address
    TInetAddr RemAddr(7);
    TPtrC testAddr;
	TEST(GetStringFromConfig(_L("AddressInfo"), _L("TestPPPIPAddr"), testAddr));
	
    if(testAddr.Length())
		{
		RemAddr.Input(testAddr); 
		}
    else
		{
		INFO_PRINTF1(_L("Test FAILED\nMissing address information in config file: "));
		return EFail;
		}
    
    // Open a socket
    TEST(KErrNone == sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp)); 
    INFO_PRINTF1(_L("Connecting Socket to:"));
	
    TBuf<30> printAddr;
    RemAddr.Output(printAddr);
	
    INFO_PRINTF1(printAddr);
	
    // Connect a socket
    sock.Connect(RemAddr,sta);
	
    // Wait for Connect to complete
    User::WaitForRequest(sta);
    TEST(sta.Int() == 0);
    
    TInt iterEnd;
	GetIntFromConfig(_L("MMUInfo"), _L("TestPPPmaxMMU"), iterEnd);
    if (iterEnd > KMaxMMU)
		iterEnd = KMaxMMU;
	
    TInt iterStart;
	GetIntFromConfig(_L("MMUInfo"), _L("TestPPPminMMU"), iterStart);
    if (iterStart < KMinMMU)
		iterStart = KMinMMU;
	
    TInt i,j;
    TSockXfrLength recvLen;
    INFO_PRINTF1(_L("Send/Recv frames"));
    for(j=iterStart;j<=iterEnd;j++)
		{
		sendBuf->Zero();
		
		for (i=0;i<j;i++)
			sendBuf->Append(Math::Random() & 0x7f);
		
		INFO_PRINTF2(_L("Sending Packet of Size: %d"),j);
		// Send data to echo port
		sock.Write(*sendBuf,sta);
		User::WaitForRequest(sta);
		TEST(sta.Int() == 0);
		i=0;
		recvBuf->Zero();
		
		while(i<j)
			{
			// Receive data from echo port
			sock.RecvOneOrMore(*recvBuf2,0,sta,recvLen); 
			User::WaitForRequest(sta);
			TEST(sta.Int() == 0);
			i += recvBuf2->Length();
			recvBuf->Append(*recvBuf2);
			}
		
		TEST(KErrNone == recvBuf->Compare(*sendBuf));
		INFO_PRINTF1(_L("   Received echoed Packet"));
		}
    
    sock.Shutdown(RSocket::EStopOutput,sta);
    User::WaitForRequest(sta);
    TEST(sta.Int() == 0);
    sock.Close();
    ss.Close();

	CleanupStack::PopAndDestroy(3);

	return TestStepResult();
	}
Ejemplo n.º 16
0
TVerdict CEsockTest29::easyTestStepL()
	{

	// Open Sockets, one to manipulate mBufPool and one to send/revieve with tcp or udp
	TESTL( OpenSockets() == KErrNone );

	// Bind Test Socket To local Address
	TInetAddr local;
	SetPort( local, KPort, KLocal );
	iTestSocket.Bind( local );
	
	// Connect Test Socket to LoopBack Address
	TInetAddr loopBack;
	SetPort( loopBack, KPort, KLoopback );
	ConnectSocketL( iTestSocket, loopBack );
	
	// Gobble all the Buf's in the MBuf Pool return the number of mBufs in Use
	TInt totalUsedBufs = iDummySocket.SetOpt( KDummyOptionSetGobbleMBufs, 0, 0 );
	TInt bufsToBeFreed = 0;
	
	// Data to be used during socket Send
	GetIntFromConfig(KSection29, KBufSize, iBufSize);
	TBool keepSending = ETrue;
	TBuf8<4500> recvBuf;
	TBuf8<4500> sendData;
	sendData.Fill(TChar('z'), iBufSize );
	TRequestStatus sendStatus;
	TRequestStatus recvStatus;
	const TInt KOneSecond = 1000000;
	
	
	
	for( TInt freeBufCounter = 0; freeBufCounter < totalUsedBufs && keepSending; freeBufCounter += bufsToBeFreed )
	// OOB loop that will gradually release more MBufs
		{
		
		// release some mBufs and send
		iDummySocket.SetOpt( KDummyOptionSetFreeSomeMBufs, bufsToBeFreed , 0);
		iTestSocket.Send( sendData, 0, sendStatus );
		
		// Wait for a second to allow time for server/protocol to send
		User::After( KOneSecond );
		
		// Cancel the send and start to recv
		iTestSocket.CancelSend();
		User::WaitForRequest(sendStatus);
		
		iTestSocket.Recv(recvBuf, 0, recvStatus);
		
		// Wait for a second to allow time for server/protocol to recieve
		User::After( KOneSecond );
		iTestSocket.CancelRecv();
		User::WaitForRequest( recvStatus );
		
		if( freeBufCounter % 5 == 0 )
			{
			INFO_PRINTF2( _L("freeBufs now >= %d "),  freeBufCounter );
			}
		
		if( recvBuf.Compare(sendData) == 0 )
		// if we have recieved data then exit the loop
			{
			keepSending = EFalse;
			}
			
		bufsToBeFreed = 2;
		
		}
	
	// Now do a regular send for good measure to make sure everything is ok
	sendData.Fill(TChar('c'), iBufSize );
	INFO_PRINTF1( _L("End of Loop, Now sending....") );
	iTestSocket.Send( sendData, 0, sendStatus );
	User::WaitForRequest( sendStatus );
	INFO_PRINTF2( _L("Send Returned %d, now recieving...."), sendStatus.Int() );
	iTestSocket.Recv( recvBuf, 0, recvStatus );
	User::After( KOneSecond ); 
	iTestSocket.CancelRecv();
	User::WaitForRequest( recvStatus );
	
	INFO_PRINTF2( _L("Recieve returned %d ") , recvStatus.Int() );
	if( recvBuf.Compare(sendData) != 0 )
		{
		return EFail;
		}
	
	return EPass;
	
	}
/**
 *
 * Do the test step.
 * Each test step must supply an implementation for DoTestStepL.
 *
 * @return	"TVerdict"
 *			The result of the test step
 *
 * @xxxx
 * 
 */
TVerdict CTestStepRecorderSendCustomCommandAsync::DoTestStepL()
	{
	TInt err;
	err = KErrNone;
	iTestStepResult = EFail;

	iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this);
	
	TUid testController= TUid::Uid(KUidTestController);
	
	TRAP(err, iRecorder->OpenFileL(iFileName,
									testController,
									testController,
									KNullUid));
	if (err!=KErrNone)
		return EInconclusive;
		
	CActiveScheduler::Start();
	
	if (iError!=KErrNone)
		return EInconclusive;	

	TUid uid;
	uid = TUid::Uid(0x101f72B4);
	// destinationPckg can be temporary as the asynchronous custom command returns before the temporary variable goes out of scope
	TMMFMessageDestinationPckg destinationPckg(uid);
	
	// test without a return value
	iRecorder->RecordControllerCustomCommandAsync(destinationPckg,
								EMMFTestCustomCommandGeneralAsynchronous,
								KFirstParameter,
								KSecondParameter,
								iAsyncObserver->ActiveStatus());

	CActiveScheduler::Start();	
	if (iAsyncObserver->iStatus.Int() !=KTestCustomCommandSuccess)
		return EFail;
								
	TBuf8<256> buf;
		
	iRecorder->RecordControllerCustomCommandAsync(destinationPckg,
								EMMFTestCustomCommandGeneralAsynchronousWithReturn,
								KFirstParameter,
								KSecondParameter,
								buf,
								iAsyncObserver->ActiveStatus());

	CActiveScheduler::Start();	
	if (iAsyncObserver->iStatus.Int() !=KTestCustomCommandSuccess)
		return EFail;
		
	if (buf.Compare(KReturnParameter)==0)
		iTestStepResult = EPass;
	else
		iTestStepResult = EFail;
		
		// test without a return value
	iRecorder->PlayControllerCustomCommandAsync(destinationPckg,
								EMMFTestCustomCommandGeneralAsynchronous,
								KFirstParameter,
								KSecondParameter,
								iAsyncObserver->ActiveStatus());

	CActiveScheduler::Start();	
	if (iAsyncObserver->iStatus.Int() !=KTestCustomCommandSuccess)
		return EFail;
								
	iRecorder->PlayControllerCustomCommandAsync(destinationPckg,
								EMMFTestCustomCommandGeneralAsynchronousWithReturn,
								KFirstParameter,
								KSecondParameter,
								buf,
								iAsyncObserver->ActiveStatus());

	CActiveScheduler::Start();	
	if (iAsyncObserver->iStatus.Int() !=KTestCustomCommandSuccess)
		return EFail;
		
	if (buf.Compare(KReturnParameter)==0)
		iTestStepResult = EPass;
	else
		iTestStepResult = EFail;
		
	delete iRecorder;
	iRecorder = NULL;


	INFO_PRINTF1(_L("finished with this test step"));
	// test steps return a result
	return iTestStepResult;
	}
Ejemplo n.º 18
0
enum TVerdict CEsockTest29_10::easyTestStepL( void )
	{
	SetTestStepResult(EFail);
	TInt ret;
	const TUint KOneSecond = 1000000;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connect socket
	TSockAddr addr;
	TRequestStatus connStat;
	sock.Connect(addr, connStat);
	User::WaitForRequest(connStat);
	TESTL(KErrNone == connStat.Int());
	
	// send packet 1
	TRequestStatus stat;
	Logger().WriteFormat(_L("Attempting to create a packet to receive later"));	
	_LIT8(sendDataOne, "First Send");
	sock.Send(sendDataOne,0,stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	// wait for packets to go through esock
	User::After(KOneSecond * 2);
	// gobble mBufs
	TInt nFree = 0;
	sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
	while (nFree > 0)
		{
		ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
		sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
		}
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
	
	// we are running in high priority and allocating in a loop.
	// so kernel may not be able to enlarge the pools.
	// wait for kernel to enlarge the pool
	// We have to come out from the loop as well.
    User::After(KOneSecond * 2);
	
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }

	
	// send packet 2
	User::After(KOneSecond);
	TRequestStatus stat2;
	_LIT8(sendDataTwo, "Second Send");
	Logger().WriteFormat(_L("Sending Data - Should never complete"));             
	sock.Send(sendDataTwo,0,stat2);

	User::After(KOneSecond);
	Logger().WriteFormat(_L("Now cancel the Send"));     
	sock.CancelSend();
	User::WaitForRequest(stat2);
	TESTL(stat2 == KErrCancel);
	
	Logger().WriteFormat(_L("Receiving Data -- expected to pick up sendDataOne"));
	TBuf8<100> buf;          
	TRequestStatus stat3;
	sock.Recv(buf, 0, stat3);
	User::After(KOneSecond);
	User::WaitForRequest(stat3);
	TESTL(buf.Compare(sendDataOne) == 0);
		
	// send packet 3
	_LIT8(sendDataThree, "Third Send");
	Logger().WriteFormat(_L("Sending Data ... again"));             
	TRequestStatus stat4;
	sock.Send(sendDataThree,0,stat4);
	User::After(1000);
			
	// free memory
	Logger().WriteFormat(_L("Now free memory - should get send and receive completion"));	
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	TESTL(KErrNone == ret);	

	Logger().WriteFormat(_L("Sending Data - Should now complete"));             
	User::WaitForRequest(stat4);
	TESTL(stat4.Int() == KErrNone);

	// recieve data and compare contents to sent data
	Logger().WriteFormat(_L("Receiving Data"));
	sock.Recv(buf, 0, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Recv has returned %d"), stat.Int());
	TBuf<100> buf16;
	buf16.Copy(buf);
	if(buf.Compare(sendDataThree) == 0)
		{
		SetTestStepResult(EPass);
		}
		
	Logger().WriteFormat(_L("Data Recv'ed is '%S'"), &buf16);
	sock.Close();
	ss.Close();
	return TestStepResult();
	}
Ejemplo n.º 19
0
enum TVerdict CEsockTest29_11::easyTestStepL( void )
	{
	TVerdict verdict = EFail;
	TInt ret;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
	CleanupClosePushL(ss);
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connecti socket
	TSockAddr addr;
	TRequestStatus stat;
	sock.Connect(addr, stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	
	// drain MBuf Pool
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	
	// send data and wait for 1/10 seconds
	Logger().WriteFormat(_L("Sending Data"));     
	_LIT8( sendData, "bla bla bla bla");        
	sock.Send(sendData,0,stat);
	const TUint KTenMilliSecs = 10000; 
	User::After(KTenMilliSecs);
	
	// free all mbufs
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	TESTL(ret == KErrNone);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);

	// wait for send to return
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Send has returned %d"), stat.Int());
	if(stat.Int() != KErrNone)
		{
		verdict = EFail;
		}
	
	// recieve data and verify that it is the same as send data
	TBuf8<20> recvBuf;
	TRequestStatus recvStatus;
	sock.Recv(recvBuf, 0, recvStatus);
	User::WaitForRequest(recvStatus);
	Logger().WriteFormat(_L("recieving data on PDummy3 has returned %d"), recvStatus.Int());
	if(recvStatus.Int() != KErrNone)
		{
		verdict = EFail;
		}
	Logger().WriteFormat(_L("Comparing Recieved data and Sent data"), recvStatus.Int());		
	if(recvBuf.Compare(sendData) == 0)
		{
		verdict = EPass; 
		}
	
	sock.Close();
	CleanupStack::PopAndDestroy(&ss);
    SetTestStepResult(verdict);
	return verdict;

	}
Ejemplo n.º 20
0
/*
HELPER:
The actual step thta does the encryption and decryption

*/
TVerdict CTlsProvTestActive::EncryptAndDecryptL(CTLSSession* aPtrTlsSession, CTlsProvStep* /*aStep*/)
	{
	
	RFs filesys;
	filesys.Connect();
	RFile fileTmp_t;
	
	TBuf8<1024> TempPrint;
	TDriveUnit sysDrive (filesys.GetSystemDrive());
	TDriveName sysDriveName (sysDrive.Name());
	
	TBuf<128> fileName (sysDriveName);
	fileName.Append(_L("\\data\\ActualAppData.bin"));
	
	TInt result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
		
  	INFO_PRINTF1(_L("EncryptAndDecryptL 1"));
	if(!result_t)
		fileTmp_t.Read( TempPrint );
	fileTmp_t.Close();	

	
	iStatus = KRequestPending;
	HBufC8* Output = NULL;
	TRecordProtocol RecType;
	RecType= EHandshake;
	TInt64 ASeqNumber = 0;
	Output = HBufC8::NewL(TempPrint.Length() + 24);
	aPtrTlsSession->EncryptL( 
		TempPrint, 
		Output, 
		ASeqNumber,RecType) ;
	
  	INFO_PRINTF1(_L("EncryptAndDecryptL 2"));
  	
  	fileName.Copy(sysDriveName);
  	fileName.Append(_L("\\data\\EncryptOutput.bin"));
	
	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
	
	TBuf8<1024> ActualOutput;	
	if(!result_t)
		fileTmp_t.Read(ActualOutput);
	fileTmp_t.Close();
	if(ActualOutput.Compare(Output->Des()) != 0)
		return EFail;

	//Test Decryption here

  	INFO_PRINTF1(_L("EncryptAndDecryptL 3"));
  	
  	fileName.Copy(sysDriveName);
  	fileName.Append(_L("\\data\\DecryptionInput.bin"));
	
	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
	
	if(!result_t)
		fileTmp_t.Read( ActualOutput );
	fileTmp_t.Close();


	iStatus = KRequestPending;
	HBufC8* OutputDe = NULL;
	
	RecType= EHandshake;
	TInt64 ASeqNumberDe = 0;
	OutputDe = HBufC8::NewL(ActualOutput.Length());
	aPtrTlsSession->DecryptAndVerifyL( 
		ActualOutput, 
		OutputDe, 
		ASeqNumberDe,RecType) ;

	fileName.Copy (sysDriveName);
	fileName.Append(_L("\\data\\DecryptionOutputNoMac.bin"));
	
	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
	
	if(!result_t)
		fileTmp_t.Read(ActualOutput);
	fileTmp_t.Close();
	
  	INFO_PRINTF1(_L("EncryptAndDecryptL 4"));
	if(ActualOutput.Compare(OutputDe->Des()) != 0)
   {
	   iLogInfo.Copy(_L("	EncryptDecr Fail"));
		return EFail;
   }
	else
   {
	   iLogInfo.Copy(_L("	EncryptDecr Success"));
		return EPass;
   }
	}
Ejemplo n.º 21
0
/* ???
LOCAL_C void PrintBuf(TDes8 &aBuf)
//
// Print the contents of a buffer
//
	{

	TInt len=aBuf.Length();
	for (TInt i=0;i<=len/8;i++)
		{
		test.Printf(_L("%4d: "),i*8);

		for (TInt j=0;j<8;j++)
			{
			if ((i*8)+j>=len)
				break;
			TInt v=aBuf[(i*8)+j];
			test.Printf(_L("%02x "),v);
			}
		test.Printf(_L("\n\r"));
		}
	}
*/
LOCAL_C void testLoopBack(TLineRate aLineRate,TBps aBaudRate)
//
// Perform an analogue loopback test at the specified linerate
//
{

    TInt err;
    TBuf<64> b;
    TPtrC bd=BaudRateInText(aBaudRate);
    b.Format(_L("Loopback test(%S)"),&bd);
    test.Start(b);

    TBuf8<KBlockSize> txBuf;
    theSerialPort->ResetBuffers();
    txBuf.Format(_L8("AT&F+MS=%d,0,%d,%d\\N0&K3&D2M0\r"),LineModeData[aLineRate],LineRateData[aLineRate],LineRateData[aLineRate]);
    test(theSerialPort->WriteS(txBuf)==KErrNone);

    TBuf8<KBlockSize> rxBuf;
    User::After(2000000);		  // 2Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    TRequestStatus rxStat;
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
//	test.Printf(_L("   Rx(%d):"),rxStat); // ???
    test(rxStat==KErrNone);
    txBuf.Append(_L("\r\nOK\r\n"));
    err=rxBuf.Compare(txBuf);
//	test(TranslateCrLf(rxBuf)==KErrNone); // ???
//  test.Printf(_L(" %S\r\n"),&rxBuf); // ???
    test(err==0);

    test.Next(_L("Get loopback"));
    txBuf.Format(_L8("AT&T1\r"));
    test(theSerialPort->WriteS(txBuf)==KErrNone);
    User::After(5000000);		  // 5Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
    test.Printf(_L("   Rx(%d):"),rxStat);
    test(rxStat==KErrNone);
    txBuf.AppendFormat(_L8("\r\nCONNECT %d\r\n"),LineConnectData[aLineRate]);
    err=rxBuf.Compare(txBuf);
    test(TranslateCrLf(rxBuf)==KErrNone);
    test.Printf(_L(" %S\r\n"),&rxBuf); // Print what we got back (without CR/LF etc).
    // Sometimes get extra character as modem goes on-line so just look for command echo + connect
    test(err>=0);
    User::After(2000000);		  // 2Secs

    TInt totalBlocksToTransfer;
    if (aBaudRate<EBps1200||aLineRate<EV22_1200)
        totalBlocksToTransfer=KBlocksShort;
    else if (aBaudRate<EBps4800||aLineRate<EV32_4800)
        totalBlocksToTransfer=KBlocksMedium;
    else if (aLineRate<EV34_28800)
        totalBlocksToTransfer=KBlocksLong;
    else
        totalBlocksToTransfer=KBlocksVeryLong;
    b.Format(_L("Transfering data(%dK)"),(totalBlocksToTransfer*KBlockSize)/1024);
    test.Next(b);
    TInt loopBackFail=KErrGeneral;
    TRequestStatus txStat;
    txBuf.SetLength(KBlockSize);
    TInt i;
    for (i=0; i<KBlockSize; i++)
        txBuf[i]=(TUint8)i;
    theSerialPort->Write(txStat,txBuf,KBlockSize);
    TInt txBlks=(totalBlocksToTransfer-1);
    rxBuf.Fill(0,KBlockSize);
    theSerialPort->Read(rxStat,rxBuf,KBlockSize);
    TInt rxBlks=0;
    TRequestStatus tStat;
    RTimer tim;
    test(tim.CreateLocal()==KErrNone);
    tim.After(tStat,40000000);  // 40Secs
    test.Printf(_L(">"));
    FOREVER
    {
        User::WaitForAnyRequest();
        if (tStat!=KRequestPending)
        {
//			test.Printf(_L("t"));   // Timed out
            theSerialPort->ReadCancel(); // Cancel serial read
            User::WaitForRequest(rxStat);
            if (txBlks>0)
            {
                theSerialPort->WriteCancel(); // Cancel serial write
                User::WaitForRequest(txStat);
            }
            loopBackFail=KErrTimedOut; // Test failed
            break;
        }
        else if (rxStat!=KRequestPending)
        {
//			test.Printf(_L("r"));   // Serial rx request complete
            if (rxStat!=0)
            {
                loopBackFail=rxStat.Int(); // Test failed
                goto endSerial;
            }
            for (i=0; i<KBlockSize; i++)
            {
                if (rxBuf[i]!=i)
                {
                    loopBackFail=KErrCorrupt; // Test failed
                    rxBuf[KBlockSize-1]=0;
//					PrintBuf(rxBuf); // ???
//					goto endSerial; // !!!Ignore compare fails for now!!!
                }
            }
            test.Printf(_L("<"));
            if (++rxBlks<totalBlocksToTransfer)
            {
                rxBuf.Fill(0,KBlockSize);
                theSerialPort->Read(rxStat,rxBuf,KBlockSize);
            }
            else
            {
                loopBackFail=KErrNone;
endSerial:
                tim.Cancel(); // Cancel timer request.
                User::WaitForRequest(tStat);
                if (txBlks>0)
                {
                    theSerialPort->WriteCancel(); // Cancel serial write
                    User::WaitForRequest(txStat);
                }
                break;
            }
        }
        else if (txStat!=KRequestPending)
        {
//			test.Printf(_L("s")); // Serial tx request complete
            if (txBlks>0)
            {
                theSerialPort->Write(txStat,txBuf,KBlockSize);
                test.Printf(_L(">"));
                txBlks--;
            }
        }
        else
        {
//			test.Printf(_L("?")); // Stray signal - cancel everything
            theSerialPort->ReadCancel(); // Cancel serial read
            User::WaitForRequest(rxStat);
            tim.Cancel(); // Cancel timer request.
            User::WaitForRequest(tStat);
            if (txBlks>0)
            {
                theSerialPort->WriteCancel(); // Cancel serial write
                User::WaitForRequest(txStat);
            }
            loopBackFail=KErrDied;
            break;
        }
    }
    test.Printf(_L(" (%d)\r\n"),loopBackFail);
    // !!! At this point RTS may or may not be asserted following the write cancel. The
    // following seems necessary to make sure RTS is asserted so any remaining Rx data
    // can be received.and thrown away
    User::After(2000000);
    theSerialPort->ResetBuffers();
    User::After(1000000);		   // Wait 1Secs for any remaining Rx data
    tim.Close();

    test.Next(_L("Disconnect"));
    theSerialPort->ResetBuffers(); // Through away any remaining Rx data.
    txBuf.Format(_L8("+++"));
    test(theSerialPort->WriteS(txBuf)==KErrNone);
    User::After(2000000);		  // 2Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
    test(rxStat==KErrNone);
    txBuf.Append(_L("\r\nOK\r\n"));
    err=rxBuf.Compare(txBuf);
//  test(TranslateCrLf(rxBuf)==KErrNone); // ???
//  test.Printf(_L("   %S\r\n"),&rxBuf); // ???
    test(err==0);

    txBuf.Format(_L8("ATH0\r"));
    test(theSerialPort->WriteS(txBuf)==KErrNone);
    User::After(4000000);		  // 4Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
    test(rxStat==KErrNone);
    txBuf.Append(_L("\r\nOK\r\n"));
    err=rxBuf.Compare(txBuf);
//  test(TranslateCrLf(rxBuf)==KErrNone); // ???
//  test.Printf(_L("   %S\r\n"),&rxBuf); // ???
    test(err==0);

    test.Next(_L("Check result"));
    test(loopBackFail==KErrNone || loopBackFail==KErrCorrupt); // !!!Ignore compare fails for now!!!
//	test(loopBackFail==KErrNone);

    test.End();
}
Ejemplo n.º 22
0
/**
@internalComponent
 */
void CStacked3Plugin::FsFileWriteL(TFsPluginRequest& aRequest)
	{
	TInt length = 0;
	TInt64 pos = 0;
	TFileName filename;
	TParse parse;

	TInt err = aRequest.FileName(filename);
	iLastError = err;
	iLineNumber = __LINE__;
	if(err!=KErrNone)
		User::Leave(err); //trapped in DoRequestL

	err = aRequest.Read(TFsPluginRequest::ELength, length);
	iLastError = err;
	iLineNumber = __LINE__;
	if(err!=KErrNone)
		User::Leave(err); //trapped in DoRequestL
	
	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
	iLastError = err;
	iLineNumber = __LINE__;
	if(err!=KErrNone)
		User::Leave(err); //trapped in DoRequestL
	
	parse.Set(filename, NULL, NULL);

	_LOG4(_L("CStacked3Plugin::FsFileWriteL, file: %S, pos: %d, length: %d"), &filename,  pos, length);

	if (aRequest.IsPostOperation())
		{
		_LOG(_L("CStacked3Plugin::FsFileWriteL, post intercept"));
		}
	else
		{
		_LOG(_L("CStacked3Plugin::FsFileWriteL, pre intercept"));	

		//set up test data for plugin
		TBuf8<20> wbuffer;			
		wbuffer.Copy(_L8("HELLO WORLD  SYMBIAN"));
		TInt length = wbuffer.Length();

		HBufC8* tempBuf = HBufC8::NewMaxLC(length);
		TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);

		RFilePlugin fileplugin(aRequest);
		err = fileplugin.AdoptFromClient();
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL
		
		//write to file
		err = fileplugin.Write(pos, wbuffer);
		_LOG2(_L("CStacked3Plugin::FsFileWriteL, RFilePlugin::Write returned %d"), err);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL

		//read from file		
		err = fileplugin.Read(pos, tempBufPtr);
		_LOG2(_L("CStackedPlugin::FsFileWriteL, RFilePlugin::Read returned %d"), err);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL

		//testing the correct thing has been written to the drive
		err = wbuffer.Compare(tempBufPtr);
		iLastError = err;
		iLineNumber = __LINE__;
		if(err!=KErrNone)
			User::Leave(err); //trapped in DoRequestL

		fileplugin.Close();
		CleanupStack::PopAndDestroy();	

		// send request down the stack
		User::Leave(KErrCompletion);	
		}
	}
Ejemplo n.º 23
0
// -----------------------------------------------------------------------------
// CLogPlayerManager::ContinueExecutionL()
// -----------------------------------------------------------------------------
//
void CLogPlayerManager::ContinueExecutionL()
    {
    _LIT8( KOpenDb, "OPENDB" );
    _LIT8( KDefineVolume, "DEFINEVOLUME" );
    _LIT8( KReset, "RESET" );
    _LIT8( KFlush, "FLUSH" );
    _LIT8( KAdd, "ADD" );
    _LIT8( KUpdate, "UPDATE" );
    _LIT8( KDelete, "DELETE" );
    _LIT8( KSearch, "SEARCH" );
    _LIT8( KGet, "GET" );
    _LIT8( KCancel, "CANCEL" );
    _LIT8( KHouseKeep, "HOUSEKEEP" );


    // Note: Huge descriptor from stack. Re-use this if possible.
	// TODO: Remove and use member variable iTextBuffer
	TBuf8<KLogPlayerMaxTextLength> textBuffer;

	// Read command
	ReadTextL(iReadStream, textBuffer);

	// Command: OPENDB
	if (textBuffer.Compare(KOpenDb) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("OPENDB\n"));
            }
		TInt index = 0;
		TBool isSearcher = EFalse;
		HBufC* baseAppClass = ReadOpenDbL(iReadStream, index, isSearcher);
		CleanupStack::PushL( baseAppClass );

		if ( index == iHandle )
		{
			if ( isSearcher )
			{
				TRAP_IGNORE( iSearcher->OpenDatabaseL(*baseAppClass) );
			}
			else
			{
				TRAP_IGNORE( iIndexer->OpenDatabaseL(*baseAppClass) );
			}
		}
		CleanupStack::PopAndDestroy( baseAppClass );

		// Check if handler for this index is created
		if ( iHandle == -1 && !IsHandlerCreated( index ) )
		{
			THandleInformation handleInformation;
			handleInformation.iLogFileName = iLogFileName;
			handleInformation.iFilePosition = iStartPosition.Offset();
			handleInformation.iHandleId = index;
			handleInformation.iStartTime = iStartTime;

			iHandleInformationArray.Append( handleInformation );

			// Create new thread for this new handler
			// Thread name: "LogManager_" + handle id
			TBuf<KMaxFileName> threadName;
			_LIT( KThreadNameBase, "LogManager_" );
			threadName.Append( KThreadNameBase );
			threadName.AppendNum( index );

			// Create thread
			RThread thread;
			thread.Create( threadName,
					ThreadFunction,
					1024*10,
					0,
					&iHandleInformationArray[iHandleInformationArray.Count()-1] );
			thread.Resume();
		}
	}
	// Command: DEFINEVOLUME
	else if (textBuffer.Compare(KDefineVolume) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("DEFINEVOLUME\n"));
            }

		// Get QualifiedBaseAppClass
		ReadTextL(iReadStream, textBuffer, KDefineVolumeSeparator);
		HBufC* qualifiedBaseAppClass = HBufC::NewLC(textBuffer.Length());
		TUint textBufferLen = textBuffer.Length() - 1; // Remove separator at end
		qualifiedBaseAppClass->Des().Copy( textBuffer.Left( textBufferLen ) );
		qualifiedBaseAppClass->Des().Trim();

		// Get Index path
		ReadTextL(iReadStream, textBuffer, KLogPlayerFieldSeparatorEndLine);
		HBufC* indexDbPath = HBufC::NewLC(textBuffer.Length());
		indexDbPath->Des().Copy(textBuffer);

		if ( iHandle == -1 )
		{
			iSession.DefineVolume(*qualifiedBaseAppClass, *indexDbPath);
		}

		CleanupStack::PopAndDestroy(indexDbPath);
		CleanupStack::PopAndDestroy(qualifiedBaseAppClass);
	}
	// Command: RESET
	else if (textBuffer.Compare(KReset) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("RESET\n"));
            }

		TInt index = 0;
		ReadResetL(iReadStream, index);
		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->ResetL() );
		}
	}
	// Command: FLUSH
	else if (textBuffer.Compare(KFlush) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("FLUSH\n"));
            }

		TInt index = 0;
		ReadFlushL(iReadStream, index);
		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->FlushL() );
		}
	}
	// Command: ADD
	else if (textBuffer.Compare(KAdd) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("ADD\n"));
            }

		TInt index = 0;
		CSearchDocument* doc = ReadAddL(iReadStream, index);
		CleanupStack::PushL(doc);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->AddL(*doc) );
		}

		CleanupStack::PopAndDestroy(doc);
	}
	// Command: UPDATE
	else if (textBuffer.Compare(KUpdate) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("UPDATE\n"));
            }

		TInt index = 0;
		CSearchDocument* doc = ReadAddL(iReadStream, index);
		CleanupStack::PushL(doc);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->UpdateL(*doc) );
		}

		CleanupStack::PopAndDestroy(doc);
	}
	// Command: DELETE
	else if (textBuffer.Compare(KDelete) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("DELETE\n"));
            }

		TInt index = 0;
		HBufC* docUid = ReadDeleteL(iReadStream, index);
		CleanupStack::PushL(docUid);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->DeleteL(*docUid) );
		}

		CleanupStack::PopAndDestroy(docUid);
	}
	// Command: SEARCH
	else if (textBuffer.Compare(KSearch) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("SEARCH\n"));
            }

		TInt index = 0;
		HBufC* searchQuery = ReadSearchL(iReadStream, index);
		CleanupStack::PushL(searchQuery);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iSearcher->SearchL(*this, *searchQuery) );
		}

		CleanupStack::PopAndDestroy(searchQuery);
	}
	// Command: GET
	else if (textBuffer.Compare(KGet) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("GET\n"));
            }

		TInt index = 0;
		TInt docIndex = ReadGetL(iReadStream, index);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iSearcher->GetDocumentL(docIndex, *this) );
		}
	}
	// Command: CANCEL
	else if (textBuffer.Compare(KCancel) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("CANCEL\n"));
            }

		TInt index = 0;
		ReadCancelL(iReadStream, index);

		if ( index == iHandle )
		{
			iSearcher->Cancel();
		}
	}
	// Command: HOUSEKEEP
	else if (textBuffer.Compare(KHouseKeep) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("HOUSEKEEP\n"));
            }

		ReadHouseKeepingL(iReadStream);
		if ( iHandle == -1 )
		{
			iSession.ForceHouseKeeping();
		}
	}
	else
	{
		iWait->AsyncStop();
		return;
	}
	
	ReadTimeAndWait();
}
Ejemplo n.º 24
0
void CImageLoader::LoadFileL( CVideoEntry *aEntry )
	{
	if( IsActive() )
		{
		iCallback.ImageLoadedL( KErrInUse );
		return;
		}
	
	if( aEntry->ImageLoaded() )
		{
		iCallback.ImageLoadedL( KErrAlreadyExists );
		return;
		}
		
	iBitmap = aEntry->Bitmap();

	delete iDecoder;
	iDecoder = NULL;
	
	delete iFileData;
	iFileData = NULL;

	RFile file;
	TInt err = file.Open( iFs, aEntry->ThumbnailFile(), EFileRead | EFileStream | EFileShareAny );
	if( err == KErrNone )
		{
		TBuf8<4> hdr;
		file.Read( hdr );
		if( !hdr.Compare( _L8("emtb") ) )
			{
			TInt pos = 4;
			file.Seek( ESeekCurrent, pos );

			TInt size;
			file.Size( size );
			iFileData = HBufC8::NewL( size - 4 );
			iDesc.Set( iFileData->Des() );
			file.Read( iDesc );
			file.Close();
			TRAP( err, iDecoder = CImageDecoder::DataNewL( iFs, iDesc ) );
			}
		else
			{
			file.Close();
			TRAP( err, iDecoder = CImageDecoder::FileNewL( iFs, aEntry->ThumbnailFile() ) );
			}
		}

	if( err != KErrNone )
		{
		iCallback.ImageLoadedL( err );
		return;
		}

	iFrameInfo = iDecoder->FrameInfo( 0 );
	TRect bitmapSize = iFrameInfo.iFrameCoordsInPixels;
	iBitmap->Resize(bitmapSize.Size());

	// Decode as bitmap.
	iDecoder->Convert(&iStatus, *iBitmap, 0 );
	SetActive();

#if 0
	iWait.Start();
//	iCallback.ImageLoadedL( iStatus.Int() );
#endif
	}
Ejemplo n.º 25
0
GLDEF_C TInt E32Main()
	{
#if defined (__WINS__)
	// Connect to all the local drives first as will be the case in ARM
	TBusLocalDrive Drive[KMaxLocalDrives];
	TBool ChangedFlag[KMaxLocalDrives];
	TInt i;
	for (i=0;i<KMaxLocalDrives;i++)
		Drive[i].Connect(i,ChangedFlag[i]);
#endif

	test.Title();
//
	test.Start(_L("Load/open logical device"));
	TInt r;
	r=User::LoadLogicalDevice(_L("D_PCCDIF"));
	test(r==KErrNone||r==KErrAlreadyExists);
	RPcCardCntrlIf pccdDrv;
	r=pccdDrv.Open(KSocket,pccdDrv.VersionRequired());
	test(r==KErrNone);
//
	test.Next(_L("Power card and configure."));
	UserSvr::ForceRemountMedia(ERemovableMedia0); // Media change - ensures test always starts from same state
	User::After(300000);	// Allow 0.3s after power down for controller to detect door closed.
    pccdDrv.Reset();
	TRequestStatus mrs;
	test(pccdDrv.RegisterEvent(EPcCardEvMediaChange,&mrs)==KErrNone);
	TRequestStatus prs;
	pccdDrv.PwrUp(&prs);
	User::WaitForRequest(prs);
	test(prs.Int()==KErrNone);
	TPcCardStatus s;
	TSocketSignals ind;
	test(pccdDrv.SocketInfo(s,ind)==KErrNone);
	test(s==EPcCardReady);

	TPcCardTypePckg tyBuf;
	TPcCardType &ty=tyBuf();
	test(pccdDrv.CardInfo(&tyBuf)==KErrNone);
	test(ty.iFuncType[0]==EFFixedDiskCard);
	test(pccdDrv.ReqConfig(KFunc,1)==KErrNone);

	// Test we can get the same chunk as the controllers attrib. chunk (its shareable).
	test.Next(_L("Request 64K attribute chunk at 0H."));
	TPcCardChnk ch;
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0;
	ch.iMemLen=0x10000;
	TInt win0,win1,win2;
	test(pccdDrv.ReqMem(ch,EAccSpeed600nS,win0)==KErrNone);
	TBuf8<8> rdBuf;
	rdBuf.Fill(0,8);
	test(pccdDrv.ReadMem(win0,0,8,rdBuf)==KErrNone);
//	test(rdBuf.Compare(_L("\x01\xFF\x04\xFF\xDF\xFF\x72\xFF"))==0);
	test(rdBuf[0]==0x01&&rdBuf[2]==0x04&&rdBuf[4]==0xDF&&rdBuf[6]==0x72);

	// Test we can get small chunk within the controllers attrib. chunk (Win0 already allocated).
	test.Next(_L("Request 16byte attribute chunk at 10H."));
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0x10;
	ch.iMemLen=0x10;
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrAccessDenied); // 1st chunk isn't shared
	pccdDrv.RelMem(win0);
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrNone);
	rdBuf.Fill(0,8);
	test(pccdDrv.ReadMem(win1,0,8,rdBuf)==KErrNone);
//	test(rdBuf.Compare(_L("\x03\xFF\xD9\xFF\x01\xFF\xFF\xFF"))==0);
	test(rdBuf[0]==0x03&&rdBuf[2]==0xD9&&rdBuf[4]==0x01&&rdBuf[6]==0xFF);

	// Test we can get a second small chunk, also within the controllers attrib. chunk but
	// not clashing with previous chunk (Win1 already allocated).
	test.Next(_L("Request 16byte attribute chunk at 20H."));
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0x20;
	ch.iMemLen=0x10;
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win0)==KErrNone);
	rdBuf.Fill(0,8);	
	test(pccdDrv.ReadMem(win0,0,8,rdBuf)==KErrNone);
//	test(rdBuf.Compare(_L("\x20\xFF\x06\xFF\x45\xFF"))==2&&rdBuf[6]==0x00&&rdBuf[7]==0xFF); // 'Null causes problems with compare
	test(rdBuf[0]==0x20&&rdBuf[2]==0x06&&rdBuf[4]==0x45&&rdBuf[6]==0x00);

	// Test that requesting a chunk which lies partly but not entirely within the controllers
	// chunk fails (Win0/Win1 already allocated).
	test.Next(_L("Request 64K attribute chunk at 800H."));
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win2)==KErrInUse);
	pccdDrv.RelMem(win1);
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0x800;
	ch.iMemLen=0x10000;
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrAccessDenied);

	// Test we can get a small chunk beyond the controllers chunk (Win0 already allocated).
	test.Next(_L("Request 16byte attribute chunk at 10800H."));
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0x10800;
	ch.iMemLen=0x10;
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrNone);
	pccdDrv.RelMem(win1);

	// Test we can get a large chunk beyond the controllers chunk (Win0 already allocated).
	test.Next(_L("Request 4K attribute chunk at 10800H."));
	ch.iMemType=EPcCardAttribMem;
	ch.iMemBaseAddr=0x10800;
	ch.iMemLen=0x1000;
	test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrNone);
	pccdDrv.RelMem(win1);

	// Test we can get a chunk in a different memory type (Win0 already allocated).
	test.Next(_L("Request 16byte IO chunk at 0H."));
	ch.iMemType=EPcCardIo8Mem;
	ch.iMemBaseAddr=0;
	ch.iMemLen=0x10;
//	test(pccdDrv.ReqMem(ch,EAccSpeed200nS,win1)==KErrNone); // ???
	test(pccdDrv.ReqMem(ch,EAccSpeed250nS,win1)==KErrNone);

	// Win0/Win1 allocated
	TBuf8<8> wrBuf;
	TInt reg=0;
	test.Next(_L("Write/Read from ATA registers."));
	test(pccdDrv.ReadConfigReg(KFunc,0,reg)==KErrNone); // Check its still configured
	test(reg==1);
	wrBuf.Copy(_L("\x04\x03\x02\x01"));
	wrBuf.SetLength(4);
	test(pccdDrv.WriteMem(win1,2,wrBuf)==KErrNone); // 4 bytes starting at Sector count
	rdBuf.Fill(0,4);	
	test(pccdDrv.ReadMem(win1,2,4,rdBuf)==KErrNone);
	test(rdBuf.Compare(_L8("\x04\x03\x02\x01"))==0);

	// Win0/Win1 allocated
	test.Next(_L("Attempt to access window after power down."));
	RTimer timer;
	TRequestStatus trs;
	test(timer.CreateLocal()==KErrNone);
	TTime tim;
	tim.HomeTime();
	tim+=TTimeIntervalSeconds(8);
	timer.At(trs,tim);
	UserHal::SwitchOff();
	User::WaitForRequest(trs);
	test(trs.Int()==KErrNone);
	pccdDrv.PwrUp(&prs);
	User::WaitForRequest(prs);
	test(prs.Int()==KErrNone);
	// Check its been re-configured
	reg=0;
	test(pccdDrv.ReadConfigReg(KFunc,0,reg)==KErrNone);
	test(reg==1);
	// Check that window still OK after power down
	test(pccdDrv.WriteMem(win1,2,wrBuf)==KErrNone); // 4 bytes starting at Sector count
	rdBuf.Fill(0,4);	
	test(pccdDrv.ReadMem(win1,2,4,rdBuf)==KErrNone);
	test(rdBuf.Compare(_L8("\x04\x03\x02\x01"))==0);

	// Win0/Win1 allocated
	test.Next(_L("Attempt to access window after media change."));
	UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
	User::WaitForRequest(mrs);
	if (mrs.Int()!=KErrNone)
		{
	    pccdDrv.Close();
		test(0);
		} 
	User::After(300000);	// Allow 0.3s after power down for controller to detect door closed.
	pccdDrv.PwrUp(&prs);
	User::WaitForRequest(prs);
	if (prs.Int()!=KErrNone)
		{
	    pccdDrv.Close();
		test(0);
		}
	// First access following media change must be supervisor call
	if (pccdDrv.CardInfo(&tyBuf)!=KErrNone)
		{
	    pccdDrv.Close();
		test(0);
		}
	// Check its not been re-configured
	if (pccdDrv.ReadConfigReg(KFunc,0,reg)!=KErrGeneral) 
		{
	    pccdDrv.Close();
		test(0);
		} 
	if (pccdDrv.ReadMem(win1,2,4,rdBuf)!=KErrNotReady)
		{
	    pccdDrv.Close();
		test(0);
		}

	pccdDrv.Close();
	r=User::FreeLogicalDevice(_L("PccdIf"));
	test(r==KErrNone);

	test.End();

#if defined (__WINS__)
	for (i=0;i<KMaxLocalDrives;i++)
		Drive[i].Disconnect();
#endif
	return(0);
	}
// -----------------------------------------------------------------------------
// CWimJavaProvisioning::InitializePathsAndSizes
// Initializes the path and size data members
// -----------------------------------------------------------------------------
//
void CWimJavaProvisioning::InitializePathsAndSizes()
    {
    _WIMTRACE(_L("WIM | WIMServer | CWimJavaProvisioning::InitializePathsAndSizesL | Begin"));

    // Do initialization only if initialization is not done
    if ( !iFileInfosInitialized )
        {
        TUint16 callStatus = KErrNone;

        TBuf8<KWimProvACIFFileOidLength> ACIFOid;
        
        ACIFOid.Copy( KWimProvACIFFileOID, KWimProvACIFFileOidLength );

        TBuf8<KWimProvACIFFileOidLengthTaged> ACIFOidTaged;

        ACIFOidTaged.Copy( KWimProvACIFFileOIDTaged,
                                KWimProvACIFFileOidLengthTaged );
        
        WIMI_BinData_t path;
        path.pb_buf = NULL;
        path.ui_buf_length = 0;

        WIMI_File_Info* fileInfos = NULL;

        TUint16 fileCount = 0;

        WIMI_BinData_t fileOid;
        fileOid.pb_buf = NULL;
        fileOid.ui_buf_length = 0;

        // Get WIM reference, reader is always 0
        if ( iWimRef )
            {
            free_WIMI_Ref_t( iWimRef );
            iWimRef = NULL;
            }
        iWimRef = WIMI_GetWIMRef( 0 );

        if ( !iWimRef )
            {
            callStatus = WIMI_ERR_BadReference;
            }
    
        if ( callStatus == KErrNone )
            {

            // Get Java file info from Wimlib
            callStatus = WIMI_JAVAFileInfo( iWimRef,
                                           &fileInfos,
                                           &fileCount );
            }

        if ( callStatus == KErrNone )
            {
            TBuf8<KWimJavaOidLengthTaged> oidBuf; // Buffer for OID

            // Loop all file infos and safe path to each file
            for ( TInt i = 0; i < fileCount; i++ )
                {
                // Get file OID from infos
                fileOid.pb_buf = fileInfos[i].t_oid.pb_buf;
                fileOid.ui_buf_length = fileInfos[i].t_oid.ui_buf_length;
                oidBuf.FillZ();
                oidBuf.Copy( fileOid.pb_buf, fileOid.ui_buf_length );

                // File path
                path.pb_buf = fileInfos[i].b_path.pb_buf;
                path.ui_buf_length = fileInfos[i].b_path.ui_buf_length;

                // Compare OIDs
                if ( !oidBuf.Compare( ACIFOid ) 
                    || !oidBuf.Compare( ACIFOidTaged ) ) // ACIF File
                    {
                    // Copy file path to member
                    iPathACIF.Copy( path.pb_buf, path.ui_buf_length );
                    
                    // Set file size
                    iACIFFileSize = fileInfos[i].ui_file_size;

                    // Check if path is given but size not. If path exists and
                    // size == 0 then parse size from fetched file
                    if ( iPathACIF.Length() > 0 &&
                         iACIFFileSize == 0 )
                        {
                        WIMI_BinData_t pt_path;

                        WIMI_BinData_t fileContent;
                        
                        pt_path.ui_buf_length = ( TUint16 )iPathACIF.Length();
                        pt_path.pb_buf = ( TUint8* )iPathACIF.Ptr();
        
                        fileContent.pb_buf = NULL;
                        fileContent.ui_buf_length = 0;
    
                        //Get ACIF file
                        WIMI_STAT callStatus = WIMI_GetJAVAFile(iWimRef,
                                                                 &pt_path,      
                                                                 &fileContent );
                       iACIFFileSize = fileContent.ui_buf_length;
                       }
                    }
                
                }
            }
        iFileInfosInitialized = ETrue;
        }
    }
Ejemplo n.º 27
0
/**
@SYMTestCaseID			SYSLIB-SQL-UT-4097
@SYMTestCaseDesc		Testing incremental blob reads and writes on a secure database.
						The test application's capabilities allow read and write access to the blobs.
						Verify that both reads and writes are allowed.
@SYMTestPriority		Medium
@SYMTestActions			Testing incremental blob reads and writes on a secure database.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ5794
*/	
void ReadWriteBlobTestL()
	{
	// Current database data:
	// TABLE A: {1, x'41414141414141414141'}, {2, x'42424242424242424242'}, {3, x'43434343434343434343'}, {4, x'44444444444444444444'}
	// TABLE B: {4, "DEF", x'46464646464646464646'} <- ROWID = 2, {2, "ABC", x'45454545454545454545'} <- ROWID = 3, {6, "GHI", x'47474747474747474747'} <- ROWID = 4

	RSqlDatabase db;
	TInt err = TheDb.Open(KTestDbName);
	TEST2(err, KErrNone);
			
	// Attempt to read the blobs in tables A and B
	RSqlBlobReadStream rdStrm;
	CleanupClosePushL(rdStrm);
	TBuf8<20> data;
	TRAP(err, rdStrm.OpenL(TheDb, _L("A"), _L("B1"), 1));
	TEST2(err, KErrNone);
	TRAP(err, rdStrm.ReadL(data, 3));
	TEST2(err, KErrNone);
	TEST(data.Compare(_L8("AAA")) == 0);
	rdStrm.Close();
	TRAP(err, rdStrm.OpenL(TheDb, _L("B"), _L("B2"), 3));
	TEST2(err, KErrNone);
	TRAP(err, rdStrm.ReadL(data, 10));
	TEST2(err, KErrNone);
	TEST(data.Compare(_L8("EEEEEEEEEE")) == 0);
	CleanupStack::PopAndDestroy(&rdStrm);	

	HBufC8* wholeBuf = TSqlBlob::GetLC(TheDb, _L("A"), _L("B1"), 4);
	TEST(wholeBuf->Des().Compare(_L8("DDDDDDDDDD")) == 0);	
	CleanupStack::PopAndDestroy(wholeBuf);
	wholeBuf = TSqlBlob::GetLC(TheDb, _L("B"), _L("B2"), 2);
	TEST(wholeBuf->Des().Compare(_L8("FFFFFFFFFF")) == 0);	
	CleanupStack::PopAndDestroy(wholeBuf);

	HBufC8* buf = HBufC8::NewLC(10);	
	TPtr8 bufPtr(buf->Des());	  
	err = TSqlBlob::Get(TheDb, _L("A"), _L("B1"), bufPtr, 2);
	TEST2(err, KErrNone); 
	TEST(bufPtr.Compare(_L8("BBBBBBBBBB")) == 0);	
	err = TSqlBlob::Get(TheDb, _L("B"), _L("B2"), bufPtr, 4);
	TEST2(err, KErrNone); 
	TEST(bufPtr.Compare(_L8("GGGGGGGGGG")) == 0);
	CleanupStack::PopAndDestroy(buf); 
	
	// Attempt to write the blobs in tables A and B
	RSqlBlobWriteStream wrStrm;
	CleanupClosePushL(wrStrm);
	TRAP(err, wrStrm.OpenL(TheDb, _L("A"), _L("B1"), 1));
	TEST2(err, KErrNone);
	TRAP(err, wrStrm.WriteL(_L8("ZZZ")));
	TEST2(err, KErrNone);
	wrStrm.Close();
	TRAP(err, wrStrm.OpenL(TheDb, _L("B"), _L("B2"), 2));
	TEST2(err, KErrNone);
	TRAP(err, wrStrm.WriteL(_L8("XXXXXXXXX")));
	TEST2(err, KErrNone);
	CleanupStack::PopAndDestroy(&wrStrm);	

	TRAP(err, TSqlBlob::SetL(TheDb, _L("A"), _L("B1"), _L8("UUUUUUUU"), 4));
	TEST2(err, KErrNone);
	TRAP(err, TSqlBlob::SetL(TheDb, _L("B"), _L("B2"), _L8("TT"), 2));
	TEST2(err, KErrNone);
	
	// SQLite and system tables
	
	// Attempt to read from and write to the SQLite master table -
	// reads should be permitted because read capability is enough for this, 
	// writes should not be permitted because schema capability is required for this
	CleanupClosePushL(rdStrm);
	TRAP(err, rdStrm.OpenL(TheDb, _L("sqlite_master"), _L("tbl_name"), 1)); // TEXT column
	TEST2(err, KErrNone);
	TRAP(err, rdStrm.ReadL(data, 1));
	TEST2(err, KErrNone);
	CleanupStack::PopAndDestroy(&rdStrm); 	

	wholeBuf = TSqlBlob::GetLC(TheDb, _L("sqlite_master"), _L("tbl_name"), 1);
	TEST(wholeBuf->Length() > 0);	
	CleanupStack::PopAndDestroy(wholeBuf);  	

	buf = HBufC8::NewLC(100);
	bufPtr.Set(buf->Des());	 	  
	err = TSqlBlob::Get(TheDb, _L("sqlite_master"), _L("tbl_name"), bufPtr, 1);
	TEST2(err, KErrNone); 
	TEST(bufPtr.Length() > 0);	
	CleanupStack::PopAndDestroy(buf); 
	
	CleanupClosePushL(wrStrm);
	TRAP(err, wrStrm.OpenL(TheDb, _L("sqlite_master"), _L("tbl_name"), 1));
	TEST2(err, KErrPermissionDenied);
	CleanupStack::PopAndDestroy(&wrStrm);	

	TRAP(err, TSqlBlob::SetL(TheDb, _L("sqlite_master"), _L("tbl_name"), _L8("VVVV"), 1));
	TEST2(err, KErrPermissionDenied);

	// Attempt to read from and write to the system tables - neither reads nor writes should be permitted
	CleanupClosePushL(rdStrm);
	TRAP(err, rdStrm.OpenL(TheDb, _L("symbian_security"), _L("PolicyData"), 1)); // BLOB column
	TEST2(err, KErrPermissionDenied);
	CleanupStack::PopAndDestroy(&rdStrm);	

	TRAP(err, wholeBuf = TSqlBlob::GetLC(TheDb, _L("symbian_security"), _L("PolicyData"), 1));
	TEST2(err, KErrPermissionDenied);

	buf = HBufC8::NewLC(100);	
	bufPtr.Set(buf->Des());	  
	err = TSqlBlob::Get(TheDb, _L("symbian_security"), _L("PolicyData"), bufPtr, 1);
	TEST2(err, KErrPermissionDenied); 
	CleanupStack::PopAndDestroy(buf); 
	
	CleanupClosePushL(wrStrm);
	TRAP(err, wrStrm.OpenL(TheDb, _L("symbian_security"), _L("PolicyData"), 1));
	TEST2(err, KErrPermissionDenied);
	CleanupStack::PopAndDestroy(&wrStrm);	

	TRAP(err, TSqlBlob::SetL(TheDb, _L("symbian_security"), _L("PolicyData"), _L8("VVVV"), 1));
	TEST2(err, KErrPermissionDenied);
	
	TheDb.Close();
	}
Ejemplo n.º 28
0
//Getting various information and security policy from the repository
//TInt 				CServerRepository::Get(TUint32 aId,T& aVal)
//TServerSetting* 	CServerRepository::GetSetting(TUint32 aId)
void CenrepSrvOOMTest::GetL()
	{
	TInt err=KErrNone;
	TInt keyInt=0;
	TServerSetting* srvsetting;
	//----------Getting the TInt(1-15)-----------------------------
	for (TInt i=1;i<=15;i++)
		{
		err=iServerRepo->Get(i,keyInt);
		//Remember the policy check is done at the session level
		TESTKErrNoneL(err);
		TESTL(i==keyInt);
		srvsetting=iServerRepo->GetSetting(i);
		TESTL(srvsetting->Key()==static_cast<TUint32>(i));
		}
	//---------Getting the TReal(16-19)---------------------------
	TReal keyValue;
	err=iServerRepo->Get(16,keyValue);
	TESTKErrNoneL(err);
	TESTL(keyValue==10.1010);
	srvsetting=iServerRepo->GetSetting(16);
	TESTL(srvsetting->Key()==16);

	err=iServerRepo->Get(19,keyValue);
	TESTKErrNoneL(err);
	TESTL(keyValue==13.1313);

	//----------Getting the String(20-23)-----------------------
	TBuf8<50> keyString;
	_LIT(KFourteen,"fourteen");
	err=iServerRepo->Get(20,keyString);
	TESTKErrNoneL(err);
	//Even ascii(8 bytes) are stored as 16 bytes!!!
	TPtr16 str16((TUint16*) keyString.Ptr(),keyString.Length()/2,keyString.Length()/2);
	TESTL(str16.Compare(KFourteen)==0);
	srvsetting=iServerRepo->GetSetting(20);
	TESTL(srvsetting->Key()==20);

	//---------Getting the String8(0x79)------------------------
	TBuf8<50> keyString8;
	_LIT8(KString8,"string8");
	err=iServerRepo->Get(0x79,keyString8);
	TESTKErrNoneL(err);
	TESTL(keyString8.Compare(KString8)==0);
	srvsetting=iServerRepo->GetSetting(0x79);
	TESTL(srvsetting->Key()==0x79);

	//---------Getting the binary(0x82)-------------------------
	TBuf8<50> keyBinary;
	_LIT8(KBinary8,"\x12\x34\xAB\xCD");
	err=iServerRepo->Get(0x82,keyBinary);
	TESTKErrNoneL(err);
	//temporarily added to solve coverage problem in WINSCW
#ifdef __EPOC32__
	TESTL(keyBinary.Compare(KBinary8)==0);
#endif
	srvsetting=iServerRepo->GetSetting(0x82);
	TESTL(srvsetting->Key()==0x82);

	//----------Getting individual policy-----------------------
	//Current Exe has caps AllFiles+WriteDeviceData+ReadDeviceData
	RThread currentThread;
	TSecurityPolicy secPolicy;
	//default policy
	secPolicy=iServerRepo->GetDefaultReadAccessPolicy();
	TESTL(secPolicy.CheckPolicy(currentThread)==1);
	secPolicy=iServerRepo->GetDefaultWriteAccessPolicy();
	TESTL(secPolicy.CheckPolicy(currentThread)==1);

	//check settings policies
	//0x2 int 2 1 cap_rd=CommDD cap_wr=WriteDeviceData
	//0x19 int 25 0 //defined in range policies with cap_rd=NetworkServices
	secPolicy=iServerRepo->GetReadAccessPolicy(2);
	TESTL(secPolicy.CheckPolicy(currentThread)==0);
	secPolicy=iServerRepo->GetWriteAccessPolicy(2);
	TESTL(secPolicy.CheckPolicy(currentThread)==1);
	secPolicy=iServerRepo->GetReadAccessPolicy(25);
	TESTL(secPolicy.CheckPolicy(currentThread)==0);

	}