enum TVerdict CSocketTest8_2::InternalDoTestStepL( void )
	{
	TVerdict verdict = EPass;
	
	Logger().WriteFormat(_L("Test Purpose: Ioctl observes InternalOptionBit"));
	
	// connect to esock
	Logger().WriteFormat(_L("Attempting to connect to socket server"));
    RSocketServ ss;
	TInt ret = OptimalConnect(ss);
	CleanupClosePushL(ss);
	Logger().WriteFormat(_L("Connect returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// get a protocol
	Logger().WriteFormat(_L("Attempting to FindProtocol dummy protocol 1"));
	TProtocolDesc protoInfo;
	ret = ss.FindProtocol(_L("Dummy Protocol 1"), protoInfo);
	Logger().WriteFormat(_L("FindProtocol returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// check internal options bit
	RSocket socket;
	Logger().WriteFormat(_L("Opening a new socket"));
	ret = socket.Open(ss, protoInfo.iAddrFamily, protoInfo.iSockType, protoInfo.iProtocol);
	Logger().WriteFormat(_L("Open returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	Logger().WriteFormat(_L("Trying Ioctl on internal options bit"));
	TRequestStatus stat;
	socket.Ioctl(KInternalIoctlBit, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrAccessDenied == stat.Int());
	
	Logger().WriteFormat(_L("Trying to SetOpt internal options bit"));
	ret = socket.SetOpt(KSocketInternalOptionBit, KSOLSocket);
	Logger().WriteFormat(_L("SetOpt returned %S"), &EpocErrorToText(ret));
	TESTL(KErrAccessDenied == ret);
	
	Logger().WriteFormat(_L("Trying to GetOpt internal options bit"));
	TPckgBuf<TBool> boolean;
	ret = socket.GetOpt(KSocketInternalOptionBit, KSOLSocket, boolean);
	Logger().WriteFormat(_L("GetOpt returned %S"), &EpocErrorToText(ret));
	TESTL(KErrAccessDenied == ret);
	
	Logger().WriteFormat(_L("Testing StartL() with Ioctl KDummyIoctlCheckStarted"));
	socket.Ioctl(KDummyIoctlCheckStarted, stat, NULL, KIoctlDummyLevel);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrNone == stat.Int());
	
	CleanupStack::Pop(&ss);
	ss.Close();
	
	SetTestStepResult(verdict);
	return verdict;
	}
enum TVerdict CSocketTest8_3::InternalDoTestStepL( void )
	{
	TVerdict verdict = EPass;
	
	Logger().WriteFormat(_L("Test Purpose: Ioctl auto bind and check started"));
	
	// connect to esock
	Logger().WriteFormat(_L("Attempting to connect to socket server"));
    RSocketServ ss;
	TInt ret = OptimalConnect(ss);
	CleanupClosePushL(ss);
	Logger().WriteFormat(_L("Connect returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// get a protocol
	Logger().WriteFormat(_L("Attempting to FindProtocol dummy protocol 1"));
	TProtocolDesc protoInfo;
	ret = ss.FindProtocol(_L("Dummy Protocol 1"), protoInfo);
	Logger().WriteFormat(_L("FindProtocol returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	Logger().WriteFormat(_L("Opening a new socket"));
	RSocket socket;
	ret = socket.Open(ss, protoInfo.iAddrFamily, protoInfo.iSockType, protoInfo.iProtocol);
	Logger().WriteFormat(_L("Open returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	Logger().WriteFormat(_L("Testing StartL() with Ioctl KDummyIoctlCheckStarted"));
	TRequestStatus stat;
	socket.Ioctl(KDummyIoctlCheckStarted, stat, NULL, KIoctlDummyLevel);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrNone == stat.Int());
	
	Logger().WriteFormat(_L("Testing AutoBind()"));
	TSockAddr addr;
	Logger().WriteFormat(_L("Trying to Connect socket"));
	socket.Connect(addr, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Connect returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrNone == stat.Int());
	
	Logger().WriteFormat(_L("Checking bound status with Ioctl"));
	socket.Ioctl(KDummyIoctlCheckBound, stat, NULL, KIoctlDummyLevel);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrNone == stat.Int());
	
	CleanupStack::Pop(&ss);
	ss.Close();
	
	SetTestStepResult(verdict);
	return verdict;
	}
enum TVerdict CSocketTest8_5::InternalDoTestStepL( void )
	{
	TVerdict verdict = EPass;
	
	Logger().WriteFormat(_L("Test Purpose: Ioctl returns not started on null socket"));
	
	// connect to esock
	Logger().WriteFormat(_L("Attempting to connect to socket server"));
    RSocketServ ss;
	TInt ret = OptimalConnect(ss);
    CleanupClosePushL(ss);
	Logger().WriteFormat(_L("Connect returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// Added test for defect: DEF043787 	SAP never gets told to cancel an Ioctl if client calls RSocket::CancelAll().
	_LIT(KSomeProtocol, "Dummy Protocol 1");
	RSocket socket;
	ret = socket.Open(ss, KSomeProtocol);
	CleanupClosePushL(socket);
	Logger().WriteFormat(_L("Open returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// Do test IOCTL thats never completes, then cancel it
	Logger().WriteFormat(_L("Do IOCTL/CancelALL."));
	TRequestStatus stat;
	socket.Ioctl(KDummyIoctlIgnore, stat);
	socket.CancelAll();
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrCancel == stat.Int());
	
	// Now query for the result of the previous IOCtl.
	socket.Ioctl(KDummyIoctlCancelled, stat);
	User::WaitForRequest(stat);
	if(stat==KErrNotFound)
		{
		Logger().WriteFormat(_L("Ioctl returned with status %S: CancelAll failed to cancel previous IOCTL."), &EpocErrorToText(stat.Int()));
		}
	else
		{
		Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
		}
	TESTL(KErrNone == stat.Int());
	
	CleanupStack::PopAndDestroy(2,&ss); // socket, ss
	SetTestStepResult(verdict);
	return verdict;
	}
void ILibChainLink::Select(int socketHandle, int Read, int Write, int Error, ILibChainLinkObserver *obs)
{
	RSocket *s = (RSocket*)ILibSocketWrapper_GetSocketFromHandle(socketHandle);
	flags() = 0;
   	
   	if(Read)
   	{
   		flags() |= KSockSelectRead;
   	}
   	if(Write)
   	{
   		flags() |= KSockSelectWrite;
   	}
   	if(Error)
   	{
   		flags() |= KSockSelectExcept;
   	}
   	
   	internalSocket = s;
   	internalSocketHandle = socketHandle;
   	observer = obs;
   	if(s!=NULL)
   	{
		s->Ioctl(KIOctlSelect,iStatus ,&flags, KSOLSocket); 
		SetActive();
   	}
   	else
   	{
   		//
   		// Why is this null?
   		//
   		internalSocket = NULL;
   	}
}
TVerdict CSmsCapsSmsIoctlDeleteSms::doTestStepL()
	{

	RSocket socket;
	TRequestStatus status;
	TInt ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	if(ret!=KErrNone)
		User::Leave(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrRecvAny);
	ret=socket.Bind(smsaddr);

	if(RProcess().HasCapability(ECapabilityWriteUserData, ECapabilityNetworkServices) && RProcess().HasCapability(ECapabilityReadUserData))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult() ;
		}



	// Create message with SRR
	_LIT(KText,"This is a simple SMS!");
	CSmsMessage* msg=CreateSmsMessageL(KText,TSmsDataCodingScheme::ESmsAlphabet7Bit);
	CleanupStack::PushL(msg);

	RSmsSocketWriteStream writestream(socket);
	writestream << *msg;
	writestream.CommitL();
	CleanupStack::PopAndDestroy(msg);

	socket.Ioctl(KIoctlDeleteSmsMessage, status, NULL, KSolSmsProv);
	User::WaitForRequest(status);

	if(RProcess().HasCapability(ECapabilityWriteUserData))
		{
		TEST(status.Int() != KErrPermissionDenied);
		}
	else
		{
		TEST(status.Int() == KErrPermissionDenied);
		}

	CleanupStack::PopAndDestroy(&socket);

	return TestStepResult();
	}
TVerdict CSmsCapsSmsIoctlReadParamsSms::doTestStepL()
	{
	TInt testNo=13;

	RProperty testNumberProperty;
	User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber));
	CleanupClosePushL(testNumberProperty);

	TRequestStatus status;
	testNumberProperty.Subscribe(status);
	User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNo));
	User::WaitForRequest(status);
	TEST(status.Int() == KErrNone);
	TInt testNumberCheck;
	User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
	if (testNo != testNumberCheck)
		User::Leave(KErrNotFound);

	CleanupStack::PopAndDestroy(&testNumberProperty);

	RSocket socket;
	TInt ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	if(ret!=KErrNone)
		User::Leave(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrLocalOperation);

	ret=socket.Bind(smsaddr);

	if(RProcess().HasCapability(ECapabilityNetworkServices))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult() ;
		}


	socket.Ioctl(KIoctlReadSmsParams,status,NULL,KSolSmsProv);
	User::WaitForRequest(status);

	TEST(status.Int() != KErrPermissionDenied);

	CleanupStack::PopAndDestroy(&socket);

	return	TestStepResult() ;
	}
示例#7
0
文件: netImpl.cpp 项目: Felard/MoSync
SYSCALL(int, maConnGetAddr(MAHandle conn, MAConnAddr* addr)) {
	LOGST("maConnGetAddr(%i, 0x%08X)", conn, addr);
	if(conn == HANDLE_LOCAL) {
		if(addr->family == CONN_FAMILY_BT) {
			TBTDevAddr btaddr;
			//TPckgBuf<TBTDevAddr> pckg(btaddr);

			//old style, might work on Symbian 7.0 and earlier
			//update: doesn't work on 6630.
#if 0//!defined(__SERIES60_3X__)
			RSocket socket;
			socket.Open(gSocketServ, KBTAddrFamily, KSockSeqPacket, KL2CAP);
			TRequestStatus status;
			socket.Ioctl(KHCILocalAddressIoctl, status, &pckg, KSolBtHCI);
			User::WaitForRequest(status);
			LOG("KHCILocalAddressIoctl result: %i\n", status.Int());
			socket.Close();
			if(status != KErrNone) {
				return CONNERR_GENERIC;
			}
#else
#if 0	//doesn't work; bug in Symbian.
			int result = RProperty::Get(KUidSystemCategory,
				KPropertyKeyBluetoothGetLocalDeviceAddress, pckg);
			LOG("KPropertyKeyBluetoothGetLocalDeviceAddress result: %i\n", result);
			if(result != KErrNone) {
				return CONNERR_GENERIC;
			}
#else
			//open a server socket and read its address.
			RSocket socket;
			socket.Open(gSocketServ, KBTAddrFamily, KSockStream, KRFCOMM);
			int channel;
			LHEL_BASE(socket.GetOpt(KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, channel),
				return CONNERR_GENERIC);
			TBTSockAddr btsockaddr;
			btsockaddr.SetPort(channel);
			LHEL_BASE(socket.Bind(btsockaddr), return CONNERR_GENERIC);
			socket.LocalName(btsockaddr);
			socket.Close();
			btaddr = btsockaddr.BTAddr();
#endif	//0
#endif	//0//__SERIES60_3X__
			storeBtAddr(btaddr, addr);
			return 1;
		} else {	//TCP server
			return CONNERR_INTERNAL;
TVerdict CSmsCapsSmsIoctlEnumerateSms::doTestStepL()
	{
	RSocket socket;
	TRequestStatus status;
	TInt ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	CleanupClosePushL(socket);

	if(ret!=KErrNone)
		User::Leave(ret);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrRecvAny);
	ret=socket.Bind(smsaddr);

	if(RProcess().HasCapability(ECapabilityWriteUserData, ECapabilityNetworkServices) && RProcess().HasCapability(ECapabilityReadUserData))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult() ;
		}


	TPckgBuf<TUint> sbuf;
	sbuf()=0;

	// test cancel first - due to Lubbock problems canceled out
	socket.Ioctl(KIoctlEnumerateSmsMessages,status,&sbuf, KSolSmsProv);

	User::WaitForRequest(status);

	if(RProcess().HasCapability(ECapabilityReadUserData))
		{
		TEST(status.Int() != KErrPermissionDenied);
		}
	else
		{
		TEST(status.Int() == KErrPermissionDenied);
		}

	CleanupStack::PopAndDestroy(&socket);

	return	TestStepResult() ;
	}
// Gets the local device class.
// Arguments:
//  - aDeviceData - object to hold the retrieved class data.
//
// Returns an error code.
//static TInt GetLocalDeviceClass(TDeviceData& aDeviceData)
static TInt GetLocalDeviceClass(TBTDeviceClass& aDeviceClass)
{
    TInt err = KErrNone;

#if defined(__SYMBIAN_9__)
    TInt cod;
    err = RProperty::Get(KPropertyUidBluetoothCategory,
                  KPropertyKeyBluetoothGetDeviceClass,
                  cod);
    if (err == KErrNone) {
        aDeviceClass = TBTDeviceClass(cod);
    }
#elif defined(__SYMBIAN_8__)
    TInt cod;
    err = RProperty::Get(KPropertyUidBluetoothCategory,
                  KPropertyKeyBluetoothDeviceClass,
                  cod);
    if (err == KErrNone) {
        aDeviceClass = TBTDeviceClass(cod);
    }    
#else

    RSocketServ socketServ;
    RSocket sock;
    
    err = socketServ.Connect();
    if (!err) {
        err = sock.Open(socketServ, KBTAddrFamily, KSockSeqPacket, KL2CAP);
        if (!err) {
            THCIDeviceClassBuf codBuf;
            TRequestStatus status;
            
            sock.Ioctl(KHCIReadDeviceClassIoctl, status, &codBuf, KSolBtHCI);
            User::WaitForRequest(status);
            
            if (status.Int() == KErrNone) {
                aDeviceClass = TBTDeviceClass(codBuf().iMajorServiceClass,
                                              codBuf().iMajorDeviceClass,
                                              codBuf().iMinorDeviceClass);
			}	  
            sock.Close();
        }
        socketServ.Close();
    }
#endif
    return err;
}
// from PDIS miso library 
// Gets the local device address.
// Arguments:
//  - aAddress - object to hold the retrieved address.
//
// Returns an error code.
static TInt GetLocalAddress(TBTDevAddr& aAddress)
{
    TInt err = KErrNone;

#if defined(__SYMBIAN_9__)
    TPtr8 ptr(aAddress.Des());
    err = RProperty::Get(KPropertyUidBluetoothCategory,
                         KPropertyKeyBluetoothGetLocalDeviceAddress,
                         ptr);
#elif defined(__SYMBIAN_8__)
    TPtr8 ptr(aAddress.Des());
    err = RProperty::Get(KPropertyUidBluetoothCategory,
                         KPropertyKeyBluetoothLocalDeviceAddress,
                         ptr);
#else
    RSocketServ socketServ;
    err = socketServ.Connect();
    if (err)
        return err;
    
    // this solution comes from the "bthci" Series 60 example;
    // does not work on Symbian 8-up
    RSocket socket;
    err = socket.Open(socketServ, KBTAddrFamily, KSockSeqPacket, KL2CAP);
    if (!err) {
        TPckgBuf<TBTDevAddr> btDevAddrPckg;
        TRequestStatus status;
        socket.Ioctl(KHCILocalAddressIoctl, status, &btDevAddrPckg, KSolBtHCI);
        User::WaitForRequest(status);
        err = status.Int();
        if (!err) {
            TPtrC8 src(btDevAddrPckg().Des());
            TPtr8 dest(aAddress.Des());
            dest.Copy(src);
        }
    
        socket.Close();
    }
    
    socketServ.Close();
#endif

    return err;
}
示例#11
0
TVerdict CSmsCapsWapIoctl::doTestStepL()
	{

	RSocket wapsock;
	TRequestStatus status;
	TInt ret=wapsock.Open(iSocketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol);
	User::LeaveIfError(ret);
	CleanupClosePushL(wapsock);

	TWapAddr wapAddr;

	wapAddr.SetWapPort(TWapPortNumber(9204));
	ret=wapsock.Bind(wapAddr);

	if(RProcess().HasCapability(ECapabilityNetworkServices))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&wapsock);
		return TestStepResult() ;
		}

	TPckgBuf<TInt> length;
	//
	//	Issue Ioctl for getting the length of the message (should fail)
	//
	wapsock.Ioctl(KSOGetLength, status, &length, KSolWapProv);
	User::WaitForRequest(status);

	TEST(status.Int() != KErrPermissionDenied);

	CleanupStack::PopAndDestroy(&wapsock);

	return	TestStepResult() ;
	}
enum TVerdict CSocketTest8_1::InternalDoTestStepL( void )
	{
	TVerdict verdict = EPass;
	
	Logger().WriteFormat(_L("Test Purpose: Ioctl returns not started on null socket"));
	
	// connect to esock
	Logger().WriteFormat(_L("Attempting to connect to socket server"));
    RSocketServ ss;
	TInt ret = OptimalConnect(ss);
	CleanupClosePushL(ss);
	Logger().WriteFormat(_L("Connect returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	//PG 14/02/2001
	//Added test for defect: TOD-4QLDXY - Ioctl on incorrectly opened socket crashes socket server.
	Logger().WriteFormat(_L("Opening a socket with no protocol"));
	RSocket socketNoProtoDefined;
	ret = socketNoProtoDefined.Open(ss);
	Logger().WriteFormat(_L("Open returned %S"), &EpocErrorToText(ret));
	TESTL(KErrNone == ret);
	
	// see if it's started
	Logger().WriteFormat(_L("Check Ioctl fails"));
	TRequestStatus stat;
	socketNoProtoDefined.Ioctl(KDummyIoctlCheckStarted, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Ioctl returned with status %S"), &EpocErrorToText(stat.Int()));
	TESTL(KErrNotSupported == stat.Int());
	socketNoProtoDefined.Close();
	
	CleanupStack::Pop(&ss);
	ss.Close();
	
	SetTestStepResult(verdict);
	return verdict;
	}
示例#13
0
TVerdict CSmsCapsSmsIoctlWriteParamsSms::doTestStepL()
	{

	RSocket socket;
	TRequestStatus status;
	TInt ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	if(ret!=KErrNone)
		User::Leave(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrLocalOperation);
	ret=socket.Bind(smsaddr);
	if(RProcess().HasCapability(ECapabilityWriteUserData, ECapabilityNetworkServices) && RProcess().HasCapability(ECapabilityReadUserData))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult();
		}



	CMobilePhoneSmspList* smspList=CMobilePhoneSmspList::NewL();
	CleanupStack::PushL(smspList);

	RMobileSmsMessaging::TMobileSmspEntryV1 entryToTsy;

	entryToTsy.iText = SMSCAPS_STORE_TEXT1;
	entryToTsy.iValidParams = SMSCAPS_STORE_VALID_PARAMS1;
    entryToTsy.iDestination.iTypeOfNumber = SMSCAPS_MESSAGE_DESTINATION_TON_0;
    entryToTsy.iDestination.iNumberPlan = SMSCAPS_MESSAGE_DESTINATION_NP_0;
	entryToTsy.iDestination.iTelNumber = SMSCAPS_MESSAGE_DESTINATION_TEL_NUMBER_0;
	entryToTsy.iValidityPeriod = SMSCAPS_STORE_VALIDITY1;
    entryToTsy.iServiceCentre.iTypeOfNumber = SMSCAPS_MESSAGE_GSMSERVICECENTRE_TON_1;
    entryToTsy.iServiceCentre.iNumberPlan = SMSCAPS_MESSAGE_GSMSERVICECENTRE_NP_1;
	entryToTsy.iServiceCentre.iTelNumber = SMSCAPS_MESSAGE_GSMSERVICECENTRE_TEL_NUMBER_1;
	entryToTsy.iProtocolId = SMSCAPS_STORE_PID1;
	entryToTsy.iDcs = SMSCAPS_STORE_DCS1;

	entryToTsy.iIndex = 0;
	smspList->AddEntryL(entryToTsy);

	RSmsSocketWriteStream writestream(socket);
	TRAP(ret,writestream << *smspList);
	User::LeaveIfError(ret);
	TRAP(ret,writestream.CommitL());
	User::LeaveIfError(ret);

	socket.Ioctl(KIoctlWriteSmsParams,status,NULL, KSolSmsProv);
 	User::WaitForRequest(status);

	if(RProcess().HasCapability(ECapabilityWriteDeviceData))
			{
			TEST(status.Int() != KErrPermissionDenied);
			}
		else
			{
			TEST(status.Int() == KErrPermissionDenied);
			}

	CleanupStack::PopAndDestroy(smspList);
	CleanupStack::PopAndDestroy(&socket);

	return	TestStepResult() ;
	}
示例#14
0
TVerdict CSmsCapsSmsIoctlCompleteReadParamsSms::doTestStepL()
	{

	TInt ret;
	//
	// Set TSY to the test case that has read message
	// #TestSimpleRxL in tsmsprt-config.txt
	//
	TInt testNo=13;

	RProperty testNumberProperty;
	User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber));
	CleanupClosePushL(testNumberProperty);

	TRequestStatus status;
	testNumberProperty.Subscribe(status);
	User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNo));
	User::WaitForRequest(status);
	TEST(status.Int() == KErrNone);
	TInt testNumberCheck;
	User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
	if (testNo != testNumberCheck)
		User::Leave(KErrNotFound);

	CleanupStack::PopAndDestroy(&testNumberProperty);

	RSocket socket;
	ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	User::LeaveIfError(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrLocalOperation);

	ret=socket.Bind(smsaddr);
	if(RProcess().HasCapability(ECapabilityNetworkServices))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult();
		}

	// Small delay to allow the SMS Stack PRT to initialise...
	User::After(1*1000000);

	RSmsSocketReadStream readstream(socket);

	//Create the smspList
	CMobilePhoneSmspList* smspList = CMobilePhoneSmspList::NewL();
	CleanupStack::PushL(smspList);

    // Make read SMS params request to the SMS Stack.
    socket.Ioctl(KIoctlReadSmsParams,status,NULL, KSolSmsProv);
    User::WaitForRequest(status);

    // Read list from stream and make acknowledgement to the SMS Stack
    readstream >> *smspList;
    socket.Ioctl(KIoctlCompleteReadSmsParams, status, NULL,KSolSmsProv);
    User::WaitForRequest(status);

	TEST(status.Int() != KErrPermissionDenied);

	CleanupStack::PopAndDestroy(smspList);
	CleanupStack::PopAndDestroy(&socket);

	return	TestStepResult() ;
	}
示例#15
0
TVerdict CSmsCapsSmsIoctlWriteSms::doTestStepL()
	{

	TInt ret;
	//
	// Set TSY to the test case
	//
	//
	TInt testNo=13;

	RProperty testNumberProperty;
	User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber));
	CleanupClosePushL(testNumberProperty);

	TRequestStatus status;
	testNumberProperty.Subscribe(status);
	User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNo));
	User::WaitForRequest(status);
	TEST(status.Int() == KErrNone);
	TInt testNumberCheck;
	User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
	if (testNo != testNumberCheck)
		User::Leave(KErrNotFound);

	CleanupStack::PopAndDestroy(&testNumberProperty);
	//

	RSocket socket;
	ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	if(ret!=KErrNone)
		User::Leave(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrRecvAny);
	ret=socket.Bind(smsaddr);

	if(RProcess().HasCapability(ECapabilityWriteUserData, ECapabilityNetworkServices) && RProcess().HasCapability(ECapabilityReadUserData))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult() ;
		}


	// Create message with SRR
	_LIT(KText,"This is a simple SMS!");
	CSmsMessage* msg=CreateSmsMessageL(KText,TSmsDataCodingScheme::ESmsAlphabet7Bit);
	CleanupStack::PushL(msg);


	// Send message
	RSmsSocketWriteStream writestream(socket);
	TRAP(ret,writestream << *msg);
	User::LeaveIfError(ret);
	TRAP(ret,writestream.CommitL());
	User::LeaveIfError(ret);

	socket.Ioctl(KIoctlWriteSmsMessage,status,NULL, KSolSmsProv);
	User::WaitForRequest(status);

	if(RProcess().HasCapability(ECapabilityWriteUserData))
			{
			TEST(status.Int() != KErrPermissionDenied);
			}
		else
			{
			TEST(status.Int() == KErrPermissionDenied);
			}

	CleanupStack::PopAndDestroy(msg);
	CleanupStack::PopAndDestroy(&socket);

	return	TestStepResult() ;
	}
示例#16
0
TVerdict CSmsCapsSmsIoctlReadFailedSms::doTestStepL()
	{

	TInt ret;
	//
	// Set TSY to the test case that has read message
	// #TestSimpleRxL in tsmsprt-config.txt
	//
	TInt testNo=6;

	RProperty testNumberProperty;
	User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber));
	CleanupClosePushL(testNumberProperty);

	TRequestStatus status;
	testNumberProperty.Subscribe(status);
	User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNo));
	User::WaitForRequest(status);
	TEST(status.Int() == KErrNone);
	TInt testNumberCheck;
	User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
	if (testNo != testNumberCheck)
		User::Leave(KErrNotFound);

	CleanupStack::PopAndDestroy(&testNumberProperty);
	//

	RSocket socket;
	ret=socket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
	if(ret!=KErrNone)
		User::Leave(ret);
	CleanupClosePushL(socket);

	TSmsAddr smsaddr;
	smsaddr.SetSmsAddrFamily(ESmsAddrRecvAny);
	ret=socket.Bind(smsaddr);

	if(RProcess().HasCapability(ECapabilityWriteUserData, ECapabilityNetworkServices) && RProcess().HasCapability(ECapabilityReadUserData))
		{
		TESTL(ret != KErrPermissionDenied);
		}
	else
		{
		// skip this one
		CleanupStack::PopAndDestroy(&socket);
		return TestStepResult() ;
		}


	//
	CSmsBuffer* buffer=CSmsBuffer::NewL();
	CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit,buffer);
	CleanupStack::PushL(smsMessage);

	RSmsSocketReadStream readstream(socket);
	TRequestStatus timerStatus;
	RTimer timer;
	timer.CreateLocal();
	timer.After(timerStatus, TTimeIntervalMicroSeconds32(20000000));

	TPckgBuf<TUint> sbuf;
	sbuf()=KSockSelectRead;
	socket.Ioctl(KIOctlSelect, status, &sbuf, KSOLSocket);
	User::WaitForRequest(timerStatus, status);
	if(status.Int() != KErrNone)
		{
		socket.CancelIoctl();
    	User::WaitForRequest(status);
        ret = EFalse;
		}
    else
        {
        timer.Cancel();
    	User::WaitForRequest(timerStatus);
        ret = ETrue;
        }
    timer.Close();

	if(ret)
	{
		TRAP(ret,readstream >> *smsMessage);
		User::LeaveIfError(ret);
		socket.Ioctl(KIoctlReadMessageFailed, status, NULL, KSolSmsProv);
		User::WaitForRequest(status);

		if(RProcess().HasCapability(ECapabilityReadUserData))
			{
			TEST(status.Int() != KErrPermissionDenied);
			}
		else
			{
			TEST(status.Int() == KErrPermissionDenied);
			}
	}

	CleanupStack::PopAndDestroy(smsMessage);
	CleanupStack::PopAndDestroy(&socket);
	return	TestStepResult() ;
	}