Revision: 201015 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 14 Apr 2010 17:14:05 +0300
branchRCL_3
changeset 14 4ccf8e394726
parent 13 0b0e9fce0b58
child 15 51722b10598b
Revision: 201015 Kit: 201015
commsfwsupport/commselements/ResponseMsg/src/ResponseMsg.cpp
commsfwsupport/commselements/factories/bwins/factoriesu.def
commsfwsupport/commselements/factories/eabi/factoriesu.def
commsfwutils/commsbufs/group/testmbuf.iby
datacommsserver/esockserver/bwins/esocksvrU.DEF
datacommsserver/esockserver/eabi/esocksvrU.DEF
datacommsserver/esockserver/inc/SS_conn.H
datacommsserver/esockserver/inc/ss_DataMonitoringProvider.h
datacommsserver/esockserver/inc/ss_connstates.h
datacommsserver/esockserver/inc/ss_nodemessages.h
datacommsserver/esockserver/inc/ss_nodemessages_legacy_internal.h
datacommsserver/esockserver/ssock/ss_DataMonitoringProvider.cpp
datacommsserver/esockserver/ssock/ss_conn.cpp
datacommsserver/esockserver/ssock/ss_connstates.cpp
datacommsserver/esockserver/ssock/ss_nodemessages.cpp
datacommsserver/esockserver/ssock/ss_nodemessages_legacy.cpp
datacommsserver/esockserver/ssock/ss_tiermanager.cpp
datacommsserver/esockserver/ssock/ss_tiermanagerutils.cpp
datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_004.script
datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_005.script
datacommsserver/esockserver/test/TE_RConnectionSuite/config/te_rconnectioncmmtests_NonConnection.script
datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionCMM.h
datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionStep.h
datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionCMM.cpp
datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionDummyNifTestSteps.cpp
datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionStep.cpp
datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionSuite.cpp
--- a/commsfwsupport/commselements/ResponseMsg/src/ResponseMsg.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/commsfwsupport/commselements/ResponseMsg/src/ResponseMsg.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -170,6 +170,10 @@
 	  		//That would usually be the fault of the client's CExtItfMsgPluginInfo.
 	  		//Depending on the state the client will be errored or panicked.
   			__DEBUGGER(); //diagnostic
+
+			// Mark the client buffer as read so that client can clean up gracefully
+			RMessage2::Write(iRequestMsgParam, KNullDesC8);
+
   			return NULL;
   			}
   		}
--- a/commsfwsupport/commselements/factories/bwins/factoriesu.def	Wed Mar 31 23:27:09 2010 +0300
+++ b/commsfwsupport/commselements/factories/bwins/factoriesu.def	Wed Apr 14 17:14:05 2010 +0300
@@ -29,4 +29,3 @@
 	?SignalDeletion@CFactoryBase@Factories@@AAEXAAVAFactoryObject@2@@Z @ 28 NONAME ; void Factories::CFactoryBase::SignalDeletion(class Factories::AFactoryObject &)
 	?Uid@CFactoryBase@Factories@@QBE?AVTUid@@XZ @ 29 NONAME ; class TUid Factories::CFactoryBase::Uid(void) const
 
-
--- a/commsfwsupport/commselements/factories/eabi/factoriesu.def	Wed Mar 31 23:27:09 2010 +0300
+++ b/commsfwsupport/commselements/factories/eabi/factoriesu.def	Wed Apr 14 17:14:05 2010 +0300
@@ -48,4 +48,3 @@
 	_ZTVN9Factories17CFactoryContainerE @ 47 NONAME
 	_ZTVN9Factories21CFactoryContainerNodeE @ 48 NONAME
 
-
--- a/commsfwutils/commsbufs/group/testmbuf.iby	Wed Mar 31 23:27:09 2010 +0300
+++ b/commsfwutils/commsbufs/group/testmbuf.iby	Wed Apr 14 17:14:05 2010 +0300
@@ -23,6 +23,7 @@
 
 file=ABI_DIR\DEBUG_DIR\TS_CTMBUFMGR.DLL						\System\libs\TS_CTMBUFMGR.DLL
 data=EPOCROOT##EPOC32\release\wins\udeb\z\TestData\scripts\mbuftest.script		\testdata\scripts\mbuftest.script
+data=EPOCROOT##EPOC32\release\wins\udeb\z\TestData\scripts\mbuftest.script		\testdata\scripts\mbuftest_zc.script
 data=EPOCROOT##EPOC32\release\wins\udeb\z\TestData\configs\MBufTest05-CopyIn.ini		\testdata\configs\MBufTest05-CopyIn.ini
 data=EPOCROOT##EPOC32\release\wins\udeb\z\TestData\configs\MBufTest05-CopyOut.ini	\testdata\configs\MBufTest05-CopyOut.ini
 data=EPOCROOT##EPOC32\release\wins\udeb\z\TestData\configs\MBufTest06-1st.ini		\testdata\configs\MBufTest06-1st.ini
--- a/datacommsserver/esockserver/bwins/esocksvrU.DEF	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/bwins/esocksvrU.DEF	Wed Apr 14 17:14:05 2010 +0300
@@ -1047,4 +1047,10 @@
 	?Self@PRClientLeft@PRClientLeftActivity@@SAABUTNodeActivity@MeshMachine@@XZ @ 1046 NONAME ; struct MeshMachine::TNodeActivity const & PRClientLeftActivity::PRClientLeft::Self(void)
 	?FirstTriple@PRClientLeft@PRClientLeftActivity@@SAABUTStateTriple@NetStateMachine@@XZ @ 1047 NONAME ; struct NetStateMachine::TStateTriple const & PRClientLeftActivity::PRClientLeft::FirstTriple(void)
 	?Accept@TAwaitingStop@CoreNetStates@@UAEHXZ @ 1048 NONAME ; int CoreNetStates::TAwaitingStop::Accept(void)
+	?GetVDataTable@TTierTypeIdFactoryQuery@ESock@@UBEPBUSVDataTableEntry@Meta@@XZ @ 1049 NONAME ; struct Meta::SVDataTableEntry const * ESock::TTierTypeIdFactoryQuery::GetVDataTable(void) const
+	?GetAttribPtr@TTierTypeIdFactoryQuery@ESock@@UBEPAEH@Z @ 1050 NONAME ; unsigned char * ESock::TTierTypeIdFactoryQuery::GetAttribPtr(int) const
+	??0TTierTypeIdFactoryQuery@ESock@@QAE@VTUid@@@Z @ 1051 NONAME ; ESock::TTierTypeIdFactoryQuery::TTierTypeIdFactoryQuery(class TUid)
+	??0TTierTypeIdFactoryQuery@ESock@@QAE@XZ @ 1052 NONAME ; ESock::TTierTypeIdFactoryQuery::TTierTypeIdFactoryQuery(void)
+	?Match@TTierTypeIdFactoryQuery@ESock@@MAE?AW4TMatchResult@MFactoryQuery@Factories@@AAUTFactoryObjectInfo@5@@Z @ 1053 NONAME ; enum Factories::MFactoryQuery::TMatchResult ESock::TTierTypeIdFactoryQuery::Match(struct Factories::TFactoryObjectInfo &)
+	?GetVDataTableStatic@TTierTypeIdFactoryQuery@ESock@@SAPBUSVDataTableEntry@Meta@@XZ @ 1054 NONAME ; struct Meta::SVDataTableEntry const * ESock::TTierTypeIdFactoryQuery::GetVDataTableStatic(void)
 
--- a/datacommsserver/esockserver/eabi/esocksvrU.DEF	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/eabi/esocksvrU.DEF	Wed Apr 14 17:14:05 2010 +0300
@@ -1948,4 +1948,15 @@
 	_ZN20PRClientLeftActivity12PRClientLeft11FirstTripleEv @ 1947 NONAME
 	_ZN20PRClientLeftActivity12PRClientLeft4SelfEv @ 1948 NONAME
 	_ZN13CoreNetStates13TAwaitingStop6AcceptEv @ 1949 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQuery19GetVDataTableStaticEv @ 1950 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQuery5MatchERN9Factories18TFactoryObjectInfoE @ 1951 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQueryC1E4TUid @ 1952 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQueryC1Ev @ 1953 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQueryC2E4TUid @ 1954 NONAME
+	_ZN5ESock23TTierTypeIdFactoryQueryC2Ev @ 1955 NONAME
+	_ZNK5ESock23TTierTypeIdFactoryQuery12GetAttribPtrEi @ 1956 NONAME
+	_ZNK5ESock23TTierTypeIdFactoryQuery13GetVDataTableEv @ 1957 NONAME
+	_ZTIN5ESock23TTierTypeIdFactoryQueryE @ 1958 NONAME
+	_ZTVN5ESock23TTierTypeIdFactoryQueryE @ 1959 NONAME
+	_ZThn4_N5ESock23TTierTypeIdFactoryQuery5MatchERN9Factories18TFactoryObjectInfoE @ 1960 NONAME
 
--- a/datacommsserver/esockserver/inc/SS_conn.H	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/inc/SS_conn.H	Wed Apr 14 17:14:05 2010 +0300
@@ -35,6 +35,8 @@
 	class TClearProgressQueue;
 	class TRequestCSRCreation;
 	class TProcessStateChange;
+    class TEnqueueStateChange;	
+	class TAwaitingStateChange;
 	class TProcessIncomingConnection;
 	class TProcessProgressRequest;
 	class TParseECNAttach;
@@ -42,10 +44,8 @@
 	class TProcessBinderResponseForCpr;
 	class TCompleteLegacyAttach;
 	class TProcessEnumResponse;
-
 	class TGenerateConnectionUpProgress;
 	class TGenerateConnectionDownProgress;
-
 	class TNoTagOrCancelAllInterfaceWorker;
 	class TCancelAllInterfaceNotificationWorker;
 }
@@ -139,6 +139,8 @@
 	friend class ConnStates::TClearProgressQueue;
 	friend class ConnStates::TRequestCSRCreation;
 	friend class ConnStates::TProcessStateChange;
+	friend class ConnStates::TAwaitingStateChange;
+	friend class ConnStates::TEnqueueStateChange;  
 	friend class ConnStates::TProcessIncomingConnection;
 	friend class ConnStates::TProcessProgressRequest;
 	friend class ConnStates::TParseECNAttach;
--- a/datacommsserver/esockserver/inc/ss_DataMonitoringProvider.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/inc/ss_DataMonitoringProvider.h	Wed Apr 14 17:14:05 2010 +0300
@@ -172,7 +172,7 @@
 public:
 	TNotificationRequest(CDataMonitoringResponder* aResponder, TSubSessionUniqueId aClientId) 
 		: iThreshold(0), iResponder(aResponder), iClientId(aClientId), iCancelled(EFalse), iWrapped(EFalse)
-		{		
+		{
 		}
 	
 	TUint32 Threshold() const
@@ -205,7 +205,7 @@
 		
 	void SetCancelled()
 		{
-		iCancelled = ETrue;
+	    iCancelled = ETrue;
 		}
 	
 	TBool Wrapped() const
@@ -220,6 +220,7 @@
 
 	static TInt CompareThresholds(const TNotificationRequest& aFirst, const TNotificationRequest& aSecond);
 	static TBool CompareClientIds(const TNotificationRequest& aFirst, const TNotificationRequest& aSecond);
+	static TBool CompareClientIdsAndCancelledFlag(const TNotificationRequest& aFirst, const TNotificationRequest& aSecond);
 	
 private:
 	TUint32 iThreshold;	
--- a/datacommsserver/esockserver/inc/ss_connstates.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/inc/ss_connstates.h	Wed Apr 14 17:14:05 2010 +0300
@@ -235,10 +235,18 @@
 
 //
 //Progress & Progress Request
+DECLARE_SMELEMENT_HEADER( TAwaitingStateChange, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext )
+    virtual TBool Accept();
+DECLARE_SMELEMENT_FOOTER( TAwaitingStateChange )
+
 DECLARE_SMELEMENT_HEADER( TProcessStateChange, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext ) //From the framework
 	virtual void DoL();
 DECLARE_SMELEMENT_FOOTER( TProcessStateChange )
 
+DECLARE_SMELEMENT_HEADER( TEnqueueStateChange, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext ) //From the framework
+    virtual void DoL();
+DECLARE_SMELEMENT_FOOTER( TEnqueueStateChange )
+
 DECLARE_SMELEMENT_HEADER( TProcessProgressRequest, SubSessStates::TECABStateTransitionBase<TContext>, NetStateMachine::MStateTransition, TContext ) //From the client
 	virtual void DoL();
 DECLARE_SMELEMENT_FOOTER( TProcessProgressRequest )
@@ -258,7 +266,9 @@
 	virtual void DoL();
 DECLARE_SMELEMENT_FOOTER( TGenerateConnectionDownProgress )
 	
-
+DECLARE_SMELEMENT_HEADER( TGenerateConnectionUninitialisedProgress,  MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext ) //From the framework
+    virtual void DoL();
+DECLARE_SMELEMENT_FOOTER( TGenerateConnectionUninitialisedProgress )
 
 
 
--- a/datacommsserver/esockserver/inc/ss_nodemessages.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/inc/ss_nodemessages.h	Wed Apr 14 17:14:05 2010 +0300
@@ -115,6 +115,23 @@
 	EXPORT_DATA_VTABLE_AND_FN
 	};
 
+class TTierTypeIdFactoryQuery : public TFactoryQueryBase
+    {
+public:
+    IMPORT_C TTierTypeIdFactoryQuery();
+
+    IMPORT_C explicit TTierTypeIdFactoryQuery(const TUid aTierTypeId);
+
+protected:
+    IMPORT_C virtual Factories::MFactoryQuery::TMatchResult Match(Factories::TFactoryObjectInfo& aFactoryObjectInfo);
+
+public:
+    TUid iTierTypeId;
+
+    DECLARE_MVIP_CTR(TTierTypeIdFactoryQuery)
+    EXPORT_DATA_VTABLE_AND_FN
+    };
+
 class TDefaultConnectionFactoryQuery : public TFactoryQueryBase
 /** Class implementing MFactoryQuery to find a connection provider.
 
--- a/datacommsserver/esockserver/inc/ss_nodemessages_legacy_internal.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/inc/ss_nodemessages_legacy_internal.h	Wed Apr 14 17:14:05 2010 +0300
@@ -319,6 +319,10 @@
 	virtual void DoDataSentNotification(TUint32 aSentBytes);
 	virtual void DoDataReceivedNotification(TUint32 aReceivedBytes);
 
+protected:
+   virtual void DoComplete(TInt aError);
+
+
 private:
 	IMPORT_C static CLegacyDataMonitoringResponder* NewL(ESock::RLegacyResponseMsg& aResponseMsg);
 	CLegacyDataMonitoringResponder(ESock::RLegacyResponseMsg& aResponseMsg);
--- a/datacommsserver/esockserver/ssock/ss_DataMonitoringProvider.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_DataMonitoringProvider.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -114,8 +114,8 @@
 
 	// Ensure this client has not registered before or if it has, any outstanding requests are
 	// marked as cancelled.
-	TInt requestIdx = iReceivedNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
-	if(requestIdx != KErrNotFound && !iReceivedNotificationRequests[requestIdx]->Cancelled())
+	TInt requestIdx = iReceivedNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
+	if(requestIdx != KErrNotFound)
 		{
 		delete notificationRequest;
 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
@@ -162,14 +162,17 @@
 	TNotificationRequest exemplarRequest(NULL, aClientId);
 	
 	// Locate the request matching the specified client ID
-	TInt requestIdx = iReceivedNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));	
-	if(requestIdx != KErrNotFound && !iReceivedNotificationRequests[requestIdx]->Cancelled())
+	TInt requestIdx = iReceivedNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));	
+	if(requestIdx != KErrNotFound)
 		{
 		TNotificationRequest* notificationRequest = iReceivedNotificationRequests[requestIdx];
 		
 		// Cancel it and complete the client
 		notificationRequest->SetCancelled();
 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
+		
+		iReceivedNotificationRequests.Remove(requestIdx); 
+        delete notificationRequest;
 		}
 	}
 
@@ -187,8 +190,8 @@
 	
 	// Ensure this client has not registered before or if it has, any outstanding requests are
 	// marked as cancelled.
-	TInt requestIdx = iSentNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
-	if(requestIdx != KErrNotFound && !iSentNotificationRequests[requestIdx]->Cancelled())
+	TInt requestIdx = iSentNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
+	if(requestIdx != KErrNotFound)
 		{
 		delete notificationRequest;
 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
@@ -235,14 +238,17 @@
 	TNotificationRequest exemplarRequest(NULL, aClientId);
 	
 	// Locate the request matching the specified client id
-	TInt requestIdx = iSentNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
-	if(requestIdx != KErrNotFound && !iSentNotificationRequests[requestIdx]->Cancelled())
+	TInt requestIdx = iSentNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
+	if(requestIdx != KErrNotFound)
 		{
 		TNotificationRequest* notificationRequest = iSentNotificationRequests[requestIdx];
 		
 		// Cancel it and complete the client
 		notificationRequest->SetCancelled();
 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
+
+		iSentNotificationRequests.Remove(requestIdx);
+		delete notificationRequest;
 		}
 	}
 
@@ -527,6 +533,21 @@
 		}
 	}
 
+/**
+    Compares two TNotificationRequest objects using their client ids and the cancelled flag as the criteria.
+*/
+TBool TNotificationRequest::CompareClientIdsAndCancelledFlag(const TNotificationRequest& aFirst, const TNotificationRequest& aSecond)
+    {
+    if(aFirst.ClientId() == aSecond.ClientId())
+        {
+        return aFirst.Cancelled() == aSecond.Cancelled();
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TDataMonitoringProvisioningInfoBase, TDataMonitoringProvisioningInfoBase::iUid, TDataMonitoringProvisioningInfoBase::iId)
 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iDataVolumesPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iThresholdsPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
--- a/datacommsserver/esockserver/ssock/ss_conn.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_conn.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -151,8 +151,8 @@
 	THROUGH_NODEACTIVITY_ENTRY(KErrorTag, ConnActivities::CStartAttachActivity::TSetIdleIfStopOutstanding, MeshMachine::TErrorTag)
 
 	NODEACTIVITY_ENTRY(KErrorTag, CoreNetStates::TSendClientLeavingRequestToServiceProviders, MeshMachine::TAwaitingLeaveComplete, MeshMachine::TNoTag)
-	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSetIdleIfNoServiceProviders, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
-	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
+	NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
+	LAST_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TGenerateConnectionUninitialisedProgress)
 NODEACTIVITY_END()
 }
 
@@ -204,10 +204,10 @@
     THROUGH_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TGenerateConnectionDownProgress, MeshMachine::TNoTag)
 
 	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendClientLeavingRequestToServiceProviders, MeshMachine::TAwaitingLeaveComplete, MeshMachine::TNoTag)
-	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSetIdleIfNoServiceProviders, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
+	NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
 	
 	LAST_NODEACTIVITY_ENTRY(CoreNetStates::KNoBearer, MeshMachine::TDoNothing)
-	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
+	LAST_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TGenerateConnectionUninitialisedProgress)
 NODEACTIVITY_END()
 }
 
@@ -269,22 +269,35 @@
     THROUGH_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TCancelAllLegacyRMessage2Activities, ConnStates::TNoTagBlockedByLegacyRMessage2Activities)
 	NODEACTIVITY_ENTRY(KNoTag, ConnStates::TProcessClose, TECABState<MeshMachine::TAwaitingLeaveComplete>, MeshMachine::TNoTag)
 	//TDestroyAwaitingLeaveCompleteLoop loops back to its own triple if more SPs
-	NODEACTIVITY_ENTRY(KNoTag, TECABTransition<CoreNetStates::TSetIdleIfNoServiceProviders>, TECABState<MeshMachine::TAwaitingLeaveComplete>, CoreActivities::CDestroyActivity::TNoTagOrNoTagBackwards)
-	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing) //Never gets here
+	NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing, TECABState<MeshMachine::TAwaitingLeaveComplete>, CoreActivities::CDestroyActivity::TNoTagOrNoTagBackwards)
+	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
 NODEACTIVITY_END()
 }
 
+//--------------------------------------------------
+//Progress/TStateChange activities.
+//ConnectionStateChangeNotificationActivity acts on the subscription and completes the client with progresses
+//ConnectionStateChangeActivity acts on TStateChange coming from the stack.
 namespace ConnectionStateChangeNotificationActivity
 {
 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityConnectionStateChangeRequest, ConnectionStateChangeNotification, TCFInternalEsock::TSubSess, CESockClientActivityBase::NewL)
 	FIRST_NODEACTIVITY_ENTRY(SubSessStates::TAwaitingIPC<ECNProgressNotification>, MeshMachine::TNoTag)
 	THROUGH_NODEACTIVITY_ENTRY(KNoTag, SubSessStates::TAcquireMessageOwnership, MeshMachine::TNoTag)
-	//TAwaitingStateChangeLoop also cancels the activity when requested
-	NODEACTIVITY_ENTRY(KNoTag, ConnStates::TProcessProgressRequest, TECABState<MeshMachine::TAwaitingMessageState<TCFMessage::TStateChange> >, 		MeshMachine::TNoTagBackward)
+	NODEACTIVITY_ENTRY(KNoTag, ConnStates::TProcessProgressRequest, TECABState<ConnStates::TAwaitingStateChange >, MeshMachine::TNoTag)
+	
+	NODEACTIVITY_ENTRY(KNoTag, ConnStates::TProcessStateChange, TECABState<ConnStates::TAwaitingStateChange >, MeshMachine::TNoTagBackward)
 	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing) //Never gets here
 NODEACTIVITY_END()
 }
 
+namespace ConnectionStateChangeActivity
+{
+DECLARE_DEFINE_NODEACTIVITY(ECFActivityStateChange, ConnectionStateChange, TCFMessage::TStateChange)
+    NODEACTIVITY_ENTRY(KNoTag, ConnStates::TEnqueueStateChange, ConnStates::TAwaitingStateChange, MeshMachine::TNoTag)
+NODEACTIVITY_END()
+}
+
+
 namespace ConnectionWaitForIncomingActivity
 { //Synchronised, waits for Start to complete
 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityConnectionWaitForIncoming, ConnectionWaitForIncoming, TCFInternalEsock::TSubSess, CStartAttachActivity::NewWaitForIncomingConnectionActivityL)
@@ -297,27 +310,18 @@
 NODEACTIVITY_END()
 }
 
-//
-//Activities serving framework requests
-namespace ConnectionStateChangeActivity
-{
-DECLARE_DEFINE_NODEACTIVITY(ECFActivityStateChange, ConnectionStateChange, TCFMessage::TStateChange)
-	NODEACTIVITY_ENTRY(KNoTag, ConnStates::TProcessStateChange, MeshMachine::TAwaitingMessageState<TCFMessage::TStateChange>, MeshMachine::TNoTag)
-NODEACTIVITY_END()
-}
-
 
 namespace ConnectionGoingDownActivity
 {
 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityGoneDown, ConnectionGoingDown, TCFControlClient::TGoneDown, PRActivities::CGoneDownActivity::NewL)
 	FIRST_NODEACTIVITY_ENTRY(ConnStates::TAwaitingGoneDown, MeshMachine::TNoTag)
 	THROUGH_NODEACTIVITY_ENTRY(KNoTag, ConnectionGoingDownActivity::TStoreGoneDownError, MeshMachine::TNoTag)
-	THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TCancelAndCloseZone0ClientExtIfaces, MeshMachine::TNoTag)
+	THROUGH_NODEACTIVITY_ENTRY(KNoTag, SubSessStates::TCancelAndCloseClientExtIfaces, MeshMachine::TNoTag)
     THROUGH_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TCancelAllLegacyRMessage2Activities, ConnStates::TNoTagBlockedByLegacyRMessage2Activities)
     THROUGH_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TGenerateConnectionDownProgress, MeshMachine::TNoTag)
 	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendClientLeavingRequestToServiceProviders, MeshMachine::TAwaitingLeaveComplete, MeshMachine::TNoTag)
-	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSetIdleIfNoServiceProviders, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
-    LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
+	NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing, MeshMachine::TAwaitingLeaveComplete, ConnectionCleanupActivities::TNoTagOrNoTagBackwards)
+    LAST_NODEACTIVITY_ENTRY(KNoTag, ConnStates::TGenerateConnectionUninitialisedProgress)
 NODEACTIVITY_END()
 }
 
--- a/datacommsserver/esockserver/ssock/ss_connstates.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_connstates.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -625,6 +625,160 @@
     return EFalse;
 	}
 
+
+
+//----------------------------------------------------
+//Handling Progress/TStateChange
+DEFINE_SMELEMENT(ConnStates::TAwaitingStateChange, NetStateMachine::MState, ConnStates::TContext)
+TBool ConnStates::TAwaitingStateChange::Accept()
+    {
+    TCFMessage::TStateChange* progressMsg = message_cast<TCFMessage::TStateChange>(&iContext.iMessage);
+    if (progressMsg)
+        {
+        TStateChange& progress = progressMsg->iStateChange;
+        
+        if (iContext.iSender != iContext.Node().Id())
+            {
+            //CConnection trusts that locally generated progresses are to be trusted,
+            //but some of the legacy progresses coming from the stack need some filtering.
+            //Here's the filtering.
+        
+            // Check whether KDataTransferUnblocked is received and if yes, then traslate it to KConnectionUp (== KLinkLayerOpen)
+            // the log only sees the translated version, this goes into the queue, so it alright I suppose.
+            if (progress.iStage == KDataTransferUnblocked )
+                {
+                progress.iStage = KConnectionUp;    // KLinkLayerOpen
+                }
+            if (progress.iError == KErrForceDisconnected)
+                {
+                progress.iError = KErrDisconnected;
+                }
+            
+            if (progress.iStage == KConnectionUninitialised)
+                {
+                //KConnectionUninitialised has been deprecated in the stack and it will be ignored
+                //when reported by it. It is still valid towards the application. Here it is being reported by the stack.
+                //The original KConnectionUninitialised denoted CAgentReference destruction and as such speculated too
+                //much about the sturcture of the stack (notably: there isn't necesserily an agent anymore.
+                //As defined KConnectionUninitialised would need to be reported after TCFControlClient::TGoneDown or TCFServiceProvider::TStopped,
+                //except the stack decomposes after TCFControlClient::TGoneDown or TCFServiceProvider::TStopped and the progress path along with
+                //it. It is therefore impossible for the stack to generate KConnectionUninitialised after
+                //TCFControlClient::TGoneDown or TCFServiceProvider::TStopped. CConnection takes over and will generate KConnectionUninitialised
+                //when detatching from the service providers (see ConnStates::TGenerateConnectionUninitialisedProgress)
+                LOG( ESockLog::Printf(KESockConnectionTag, _L("CConnection %08x:\tProgressNotification(TInt aStage %d, TInt aError %d) - deprecated progress, ignoring"),
+                        &(iContext.Node()), progress.iStage, progress.iError) );
+                progressMsg->ClearMessageId();
+                return EFalse;
+                }   
+            }
+        LOG( ESockLog::Printf(KESockConnectionTag, _L("CConnection %08x:\tProgressNotification(TInt aStage %d, TInt aError %d)"),
+            &(iContext.Node()), progress.iStage, progress.iError) );
+        
+        CConnection& cc = iContext.Node();
+        if (cc.iLastProgress == progress)
+            {
+            progressMsg->ClearMessageId();            
+            return EFalse; //ignore this duplicate
+            }
+        cc.iLastProgress = progress;
+
+        if (progress.iError != KErrNone)
+            {
+            cc.iLastProgressError = progress; //Save last progress in error for use by LastProgressErrorL()
+            }
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+//Progress & Progress Request
+DEFINE_SMELEMENT(ConnStates::TEnqueueStateChange, NetStateMachine::MStateTransition, ConnStates::TContext)
+void ConnStates::TEnqueueStateChange::DoL()
+    {
+    TStateChange& progress = message_cast<TCFMessage::TStateChange>(iContext.iMessage).iStateChange;
+    //Diagnostic assertion.
+    
+    //If ECFActivityConnectionStateChangeRequest is running, it has not been
+    //presented with the TStateChange message (channel activity id != 0?) which is a serious mistake.
+    __ASSERT_DEBUG(iContext.Node().CountActivities(ECFActivityConnectionStateChangeRequest)==0, User::Panic(KSpecAssert_ESockSSockscnsts, 9));
+
+    CConnection& cc = iContext.Node();
+#ifdef ESOCK_LOGGING_ACTIVE
+    // Check to see if the progress queue is full causing older progress to be discarded.
+    // This has the potential to cause problems if a critical progress item is lost.
+    // Normally the queue is large enough such that this doesn't happen but this log entry
+    // serves as a warning if it ever does.
+    if( cc.iProgressQueue.IsFull() )
+        {
+        LOG( ESockLog::Printf(KESockConnectionTag, _L("CConnection %08x:\tThe maximum progress queue size of %d has been exceeded - discarding old progress to make space for new item"), this, KMaxProgressQueueLength); )
+        }
+#endif
+    
+    //Add the progress to queue
+    cc.iProgressQueue.Enque(progress);
+    }
+
+
+DEFINE_SMELEMENT(ConnStates::TProcessProgressRequest, NetStateMachine::MStateTransition, ConnStates::TContext)
+void ConnStates::TProcessProgressRequest::DoL()
+    {
+    __ASSERT_DEBUG(iContext.iNodeActivity, ConnPanic(KPanicNoActivity));
+    CESockClientActivityBase& ac = static_cast<CESockClientActivityBase&>(*iContext.iNodeActivity);
+    TUint selectedProgressStage = ac.Int1();
+    TStateChange progress;
+    TBool found = EFalse;
+
+    __ASSERT_DEBUG((subsessmessage_cast<ECNProgressNotification>(&iContext.iMessage)), ConnPanic(KPanicIncorrectMessage));
+    
+    //Process the queue looking for the progress of interest
+    found = iContext.Node().iProgressQueue.Deque(progress);
+    if (found && selectedProgressStage != KConnProgressDefault)
+        {
+        // For a selected progress request, dequeue entries until we find one which
+        // matches the criteria.  If we dequeue all entries, fall through without
+        // completing the message.  It it not considered useful to retain un-matching
+        // entries on the queue if a selected progress request is pending.
+        while (found)
+            {
+            if (progress.iStage == selectedProgressStage || progress.iError != KErrNone)
+                {
+                break;
+                }
+            found = iContext.Node().iProgressQueue.Deque(progress);
+            }
+        }
+
+    if (found)
+        {
+        //We have found a progress of interest, finish
+        TPckg<TStateChange> progressPkg(progress);
+        ac.WriteL(0,progressPkg);
+        ac.SetIdle(); //We are done
+        }
+    }
+
+DEFINE_SMELEMENT(ConnStates::TProcessStateChange, NetStateMachine::MStateTransition, ConnStates::TContext)
+void ConnStates::TProcessStateChange::DoL()
+    {
+    __ASSERT_DEBUG(iContext.iNodeActivity, ConnPanic(KPanicNoActivity));
+    CESockClientActivityBase& ac = static_cast<CESockClientActivityBase&>(*iContext.iNodeActivity);
+    TUint selectedProgressStage = ac.Int1();
+
+    //Are we here as a result of receiving TStateChange (rather than ECNProgressNotification)?
+    TCFMessage::TStateChange& progress = message_cast<TCFMessage::TStateChange>(iContext.iMessage);
+
+    if (selectedProgressStage == KConnProgressDefault || 
+        selectedProgressStage == progress.iStateChange.iStage || 
+        KErrNone != progress.iStateChange.iError)
+        {
+        //We have found a progress of interest, finish
+        TPckg<TStateChange> progressPkg(progress.iStateChange);
+        ac.WriteL(0,progressPkg);
+        ac.SetIdle(); //We are done
+        }
+    }
+
+
 DEFINE_SMELEMENT(ConnStates::TGenerateConnectionUpProgress, NetStateMachine::MStateTransition, ConnStates::TContext)
 void ConnStates::TGenerateConnectionUpProgress::DoL()
 	{
@@ -657,124 +811,19 @@
 		}
 	}
 
-//
-//Progress & Progress Request
-DEFINE_SMELEMENT(ConnStates::TProcessStateChange, NetStateMachine::MStateTransition, ConnStates::TContext)
-void ConnStates::TProcessStateChange::DoL()
-	{
-	TStateChange& progress = message_cast<TCFMessage::TStateChange>(iContext.iMessage).iStateChange;
-
-	//Check whether KDataTransferUnblocked is received and if yes, then traslate it to KConnectionUp (== KLinkLayerOpen)
-	// the log only sees the translated version, this goes into the queue, so it alright I suppose.
-	if (progress.iStage == KDataTransferUnblocked )
-		{
-		progress.iStage = KConnectionUp;	// KLinkLayerOpen
-		}
-	if (progress.iError == KErrForceDisconnected)
-		{
-		progress.iError = KErrDisconnected;
-		}
-
-	LOG( ESockLog::Printf(KESockConnectionTag, _L("CConnection %08x:\tProgressNotification(TInt aStage %d, TInt aError %d)"),
-		&(iContext.Node()), progress.iStage, progress.iError) );
-
-	//Diagnostic assertion.
-	//If ECFActivityConnectionStateChangeRequest is running, it has not been
-	//presented with the TStateChange message (channel activity id != 0?) which is a serious mistake.
-	__ASSERT_DEBUG(iContext.Node().CountActivities(ECFActivityConnectionStateChangeRequest)==0, User::Panic(KSpecAssert_ESockSSockscnsts, 9));
-
-	CConnection& cc = iContext.Node();
-	if (cc.iLastProgress == progress)
-		{
-		return; //ignore this duplicate
-		}
-	cc.iLastProgress = progress;
-
-	if (progress.iError != KErrNone)
-		{
-        cc.iLastProgressError = progress; //Save last progress in error for use by LastProgressErrorL()
-    	}
-
-	#ifdef ESOCK_LOGGING_ACTIVE
-		// Check to see if the progress queue is full causing older progress to be discarded.
-		// This has the potential to cause problems if a critical progress item is lost.
-		// Normally the queue is large enough such that this doesn't happen but this log entry
-		// serves as a warning if it ever does.
-		if( cc.iProgressQueue.IsFull() )
-			{
-			LOG( ESockLog::Printf(KESockConnectionTag, _L("CConnection %08x:\tThe maximum progress queue size of %d has been exceeded - discarding old progress to make space for new item"), this, KMaxProgressQueueLength); )
-			}
-	#endif
-
-	//Add the progress to queue
-	cc.iProgressQueue.Enque(progress);
-	}
-
-DEFINE_SMELEMENT(ConnStates::TProcessProgressRequest, NetStateMachine::MStateTransition, ConnStates::TContext)
-void ConnStates::TProcessProgressRequest::DoL()
-	{
-	__ASSERT_DEBUG(iContext.iNodeActivity, ConnPanic(KPanicNoActivity));
-	CESockClientActivityBase& ac = static_cast<CESockClientActivityBase&>(*iContext.iNodeActivity);
-	TUint selectedProgressStage = ac.Int1();
-
-	TStateChange progress;
-	TBool found = EFalse;
-
-	//Are we here as a result of receiving TStateChange (rather than ECNProgressNotification)?
-	TCFMessage::TStateChange* msg = message_cast<TCFMessage::TStateChange>(&iContext.iMessage);
-	if (msg)
-		{ //Yes, we have been triggered by a TStateChange message
-		//Check if this is the progress we are waiting for, otherwise dump the progress
-		//Check whether KDataTransferUnblocked is received and if yes, then traslate it to KConnectionUp (== KLinkLayerOpen)
-		if (msg->iStateChange.iStage == KDataTransferUnblocked )
-			{
-			msg->iStateChange.iStage = KConnectionUp;	// KLinkLayerOpen
-			}
-		//TODO: Verify if this (connection) is the right place to translate the error
-		if (msg->iStateChange.iError == KErrForceDisconnected)
-			{
-            msg->iStateChange.iError = KErrDisconnected;
-			}
-		if (selectedProgressStage == KConnProgressDefault
-			|| selectedProgressStage == msg->iStateChange.iStage
-				|| KErrNone != msg->iStateChange.iError)
-			{
-			progress = msg->iStateChange;
-			found = ETrue;
-			}
-		}
-	else
-		{ //No, we must have been triggered by a ECNProgressNotification message
-		__ASSERT_DEBUG((subsessmessage_cast<ECNProgressNotification>(&iContext.iMessage)), ConnPanic(KPanicIncorrectMessage));
-
-		//Process the queue looking for the progress of interest
-		found = iContext.Node().iProgressQueue.Deque(progress);
-		if (found && selectedProgressStage != KConnProgressDefault)
-			{
-			// For a selected progress request, dequeue entries until we find one which
-			// matches the criteria.  If we dequeue all entries, fall through without
-			// completing the message.  It it not considered useful to retain un-matching
-			// entries on the queue if a selected progress request is pending.
-			while (found)
-				{
-				if (progress.iStage == selectedProgressStage || progress.iError != KErrNone)
-					{
-					break;
-					}
-				found = iContext.Node().iProgressQueue.Deque(progress);
-				}
-			}
-		}
-
-	if (found)
-		{
-		//We have found a progress of interest, finish
-		TPckg<TStateChange> progressPkg(progress);
-		ac.WriteL(0,progressPkg);
-		ac.SetIdle(); //We are done
-		}
-	}
-
+DEFINE_SMELEMENT(ConnStates::TGenerateConnectionUninitialisedProgress, NetStateMachine::MStateTransition, ConnStates::TContext)
+void ConnStates::TGenerateConnectionUninitialisedProgress::DoL()
+    {
+    if (iContext.Node().CountActivities(ECFActivityDestroy) == 0)
+        {//TGenerateConnectionUninitialisedProgress is called when the stack goes away 
+         //below the CConnection's feet and it sometimes goes away because CConnection is
+         //being ECNClosed and therefore sitting on an electric chair. It is risky, but
+         //above all uselsess to send the progress when when app clearly doesn't want
+         //to see it.
+        TCFMessage::TStateChange msg(TStateChange(KConnectionUninitialised, KErrNone));
+        RNodeInterface::OpenPostMessageClose(iContext.Node().Id(), iContext.Node().Id(), msg);
+        }
+    }
 
 //
 //Legacy enumeration
@@ -1602,8 +1651,6 @@
     {
 	if ( iContext.iMessage.IsMessage<TEPeer::TLeaveComplete>() )
 		{
-//		__ASSERT_DEBUG(iContext.Node().GetClientIter(RNodeInterface::ECtrl|RNodeInterface::EData)[0] == NULL,
-//		User::Panic(KCorePRPanic, KPanicClientsStillPresent));
 		if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TCFClientType(TCFClientType::EServProvider)) == NULL)
 			{ // This was the last service provider
 			return NetStateMachine::EForward | MeshMachine::KNoTag;
--- a/datacommsserver/esockserver/ssock/ss_nodemessages.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_nodemessages.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -134,6 +134,7 @@
 	EDefaultSCPRFactoryQuery		=1010,
 	EDefaultFlowFactoryQuery		=1011,
 	EDefaultProtocolIntfFactoryQuery =1012,	
+	ETierTypeIdFactoryQuery     =1013,
 	};
 
 //no need to serialise return value
@@ -263,6 +264,10 @@
 	REGISTER_ATTRIBUTE(TMetaConnectionFactoryQuery, iTierImplUid, TMeta<TUint>)  
 END_ATTRIBUTE_TABLE()
 
+EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TTierTypeIdFactoryQuery, KESockInternalMessagesImplementationUid, ETierTypeIdFactoryQuery)  
+    REGISTER_ATTRIBUTE(TTierTypeIdFactoryQuery, iTierTypeId, TMeta<TUint>)  
+END_ATTRIBUTE_TABLE()
+
 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TDefaultConnectionFactoryQuery, KESockInternalMessagesImplementationUid, EDefaultConnectionFactoryQuery)	
 	REGISTER_ATTRIBUTE(TDefaultConnectionFactoryQuery, iMCprId, TMeta<TNodeId>)	
 END_ATTRIBUTE_TABLE()
@@ -330,6 +335,7 @@
 DEFINE_MVIP_CTR(TDefaultSCPRFactoryQuery)
 DEFINE_MVIP_CTR(TDefaultFlowFactoryQuery)
 DEFINE_MVIP_CTR(TDefaultProtocolIntfFactoryQuery)
+DEFINE_MVIP_CTR(TTierTypeIdFactoryQuery)
 
 
 const TImplementationProxy SignatureImplementationTable[] =
@@ -373,6 +379,7 @@
 	MVIP_CTR_ENTRY(EDefaultSCPRFactoryQuery, TDefaultSCPRFactoryQuery), //1008	
 	MVIP_CTR_ENTRY(EDefaultFlowFactoryQuery, TDefaultFlowFactoryQuery),
 	MVIP_CTR_ENTRY(EDefaultProtocolIntfFactoryQuery, TDefaultProtocolIntfFactoryQuery),	
+	MVIP_CTR_ENTRY(ETierTypeIdFactoryQuery, TTierTypeIdFactoryQuery), //1013
 	};
 
 
@@ -641,6 +648,23 @@
 	return prov->ProviderInfo() == iProviderInfo? MFactoryQuery::EMatch : MFactoryQuery::EContinue;		
 	}
 
+EXPORT_C TTierTypeIdFactoryQuery::TTierTypeIdFactoryQuery()
+    {
+        
+    }
+
+EXPORT_C TTierTypeIdFactoryQuery::TTierTypeIdFactoryQuery(const TUid aTierTypeId)
+: iTierTypeId(aTierTypeId)
+    {
+    
+    }
+    
+EXPORT_C MFactoryQuery::TMatchResult TTierTypeIdFactoryQuery::Match(Factories::TFactoryObjectInfo& aFactoryObjectInfo)
+    {
+    CTierManagerBase* prov = static_cast<CTierManagerBase*>(aFactoryObjectInfo.iInfo.iFactoryObject);
+    return prov->TierId() == iTierTypeId ? MFactoryQuery::EMatch : MFactoryQuery::EContinue;     
+    }
+
 EXPORT_C TDefaultConnectionFactoryQuery::TDefaultConnectionFactoryQuery(const Messages::TNodeId& aMCprId)
 : iMCprId(aMCprId)
 	{
--- a/datacommsserver/esockserver/ssock/ss_nodemessages_legacy.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_nodemessages_legacy.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -508,6 +508,11 @@
     }
 
 
+void CLegacyDataMonitoringResponder::DoComplete(TInt aError)
+    {
+    iLegacyResponseMsg.Complete(aError);
+    }
+
 void CLegacyDataMonitoringResponder::DoCancelRequest()
 	{
 	iLegacyResponseMsg.Complete(KErrCancel);
@@ -731,9 +736,9 @@
 	RLegacyResponseMsg responseMsg(aContext, iMessage, iMessage.Int0());
 	CDataMonitoringResponder* responder = CLegacyDataMonitoringResponder::NewL(responseMsg);
 
-    	ADataMonitoringProtocolReq& dataMonItf = *static_cast<ADataMonitoringProtocolReq*>(interface);
-    	switch(iDirection)
-    		{
+    ADataMonitoringProtocolReq& dataMonItf = *static_cast<ADataMonitoringProtocolReq*>(interface);
+    switch(iDirection)
+        {
 		case ESent:
 			dataMonItf.RequestDataSentNotification(responder, delta, volume, iClientId);
 			break;
@@ -741,19 +746,20 @@
 		case EReceived:
 			dataMonItf.RequestDataReceivedNotification(responder, delta, volume, iClientId);
 			break;
+		
 		default:
 			delete responder;
-    		}
+        }
 	// coverity [leaked_storage] - responder is owned by dataMonItf.RequestDataSentNotification, dataMonItf.RequestDataReceivedNotification
 	// therefore we don't need to push them onto the cleanup stack.
-    	}
+	}
 
 void TLegacyDataMonitoringNotificationRequest::Cancel(MeshMachine::TNodeContextBase& aContext)
 	{
 	TAny* interface = FetchInterfaceL(aContext.Node(), EDataMonitoringApiExt);
 	ASSERT(interface);
 	
-	if (interface)
+    if (interface)
     	{
     	ADataMonitoringProtocolReq& dataMonItf = *static_cast<ADataMonitoringProtocolReq*>(interface);
 		
--- a/datacommsserver/esockserver/ssock/ss_tiermanager.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_tiermanager.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -113,13 +113,21 @@
 	if (aMessage.IsMessage<TCFInternalEsock::TCreateCSR>())
 		{
 		TCFInternalEsock::TCreateCSR& msg = message_cast<TCFInternalEsock::TCreateCSR>(aMessage);
-		// Maps Tier to ImplId For ECOM since ImplId is used in Factory
-		CommsDat::CMDBSession* dbs = CommsDat::CMDBSession::NewLC(KCDVersion1_2);
-		msg.iUid= TierManagerUtils::MapTierIdtoTierImplIdL(msg.iUid, *dbs);
-		CleanupStack::PopAndDestroy(dbs);
-		CCommsFactoryBase* factory = static_cast<CCommsFactoryBase*>(FindOrCreateFactoryL(msg.iUid));
-		TAlwaysFindFactoryQuery query;
-		CSelectionRequest* sr = CSelectionRequest::NewL(address_cast<TNodeId>(aSender), factory->FindOrCreateObjectL(query)->Id());
+		TTierTypeIdFactoryQuery tierTypeQuery(msg.iUid);
+		ACommsFactoryNodeId* obj = Find(tierTypeQuery);   // match the address family to tierTypeId in factory container
+		if (!obj)
+	        {
+            // object not found, use the commsdat to find the Tier Manager
+            CommsDat::CMDBSession* dbs = CommsDat::CMDBSession::NewLC(KCDVersion1_2);
+            // Maps Tier to ImplId For ECOM since ImplId is used in Factory
+            msg.iUid= TierManagerUtils::MapTierIdtoTierImplIdL(msg.iUid, *dbs);
+            CleanupStack::PopAndDestroy(dbs);
+            CCommsFactoryBase* factory = static_cast<CCommsFactoryBase*>(FindOrCreateFactoryL(msg.iUid));
+            TAlwaysFindFactoryQuery query;  // since there is only one Tier Manager per Tier Manager factory, return the first one
+            obj = factory->FindOrCreateObjectL(query);
+	        }
+		
+		CSelectionRequest* sr = CSelectionRequest::NewL(address_cast<TNodeId>(aSender), obj->Id());
 		RClientInterface::OpenPostMessageClose(Id(), aSender, TCFInternalEsock::TCSRCreated(sr->Id()).CRef());
 		aMessage.ClearMessageId();
 		}
--- a/datacommsserver/esockserver/ssock/ss_tiermanagerutils.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_tiermanagerutils.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -738,27 +738,25 @@
 EXPORT_C TUid TierManagerUtils::MapTierIdtoTierImplIdL(TUid aTierUid,CommsDat::CMDBSession& aDbs )
 /** mapping TM Id to TM ImplId in Commsdat */
 	{
-	TUid ImplUid;
-	// if it does not exist, it returns tier id
-	ImplUid = aTierUid;
+    TUid ImplUid;
+    // if it does not exist, it returns tier id
+    ImplUid = aTierUid;
+
+    CCDTierRecord* tierRec = static_cast<CCDTierRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdTierRecord));
+    CleanupStack::PushL(tierRec);
+    tierRec->iRecordTag = aTierUid.iUid;
+
+    TBool found = tierRec->FindL(aDbs);
 
-	CMDBRecordSet<CCDTierRecord>* recSet = new (ELeave) CMDBRecordSet<CCDTierRecord>(KCDTIdTierRecord);
-	CleanupStack::PushL(recSet);
-	recSet->LoadL(aDbs);
-	const TInt recCnt = recSet->iRecords.Count();
-	
-	for(TInt i = 0; i < recCnt; i++)
-		{
-		CCDTierRecord* rec = static_cast<CCDTierRecord*>(recSet->iRecords[i]);
-		if(rec->iRecordTag == aTierUid.iUid)
-			{
-			ImplUid.iUid = rec->iTierImplUid;
-			}
-		}
-	
-	CleanupStack::PopAndDestroy(recSet);	
-	return ImplUid;
-	}
+    if (found)
+        {
+        ImplUid.iUid = tierRec->iTierImplUid;
+        }
+
+    CleanupStack::PopAndDestroy(tierRec);   
+    return ImplUid;
+
+    }
 //
 // CCommsDatIapView
 //
--- a/datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_004.script	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_004.script	Wed Apr 14 17:14:05 2010 +0300
@@ -2,7 +2,7 @@
 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
-// under the terms of the License "Eclipse Public License v1.0"
+// under the terms of "Eclipse Public License v1.0"
 // which accompanies this distribution, and is available
 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
 //
--- a/datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_005.script	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_DummyProvider/scripts/te_dummyprovider_005.script	Wed Apr 14 17:14:05 2010 +0300
@@ -2,7 +2,7 @@
 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
-// under the terms of the License "Eclipse Public License v1.0"
+// under the terms of "Eclipse Public License v1.0"
 // which accompanies this distribution, and is available
 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
 //
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/config/te_rconnectioncmmtests_NonConnection.script	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/config/te_rconnectioncmmtests_NonConnection.script	Wed Apr 14 17:14:05 2010 +0300
@@ -274,6 +274,64 @@
 test_complete
 END_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0622
 
+
+
+START_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0481
+//! @SYMTestCaseID		COMINF-ESOCK-RConnectionSuite-CMM-0481
+//!@SYMTestCaseDesc     Data Monitoring cancellation test - sent data notification
+// 						NOTE: If this test fails it can bring down esock when the connection stops (because of the original defect in esock)
+run_script z:\TestData\scripts\te_esock_test_unloadesockForced.script
+run_script z:\TestData\scripts\te_esock_test_loadesock.script
+heap_mark
+run_test_step 100, TE_RConnectionSuite Test481 c:\rconnectiontest.ini
+heap_markend
+test_complete
+END_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0481
+
+
+
+START_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0482
+//! @SYMTestCaseID		COMINF-ESOCK-RConnectionSuite-CMM-0482
+//!@SYMTestCaseDesc     Data Monitoring cancellation test - received data notification 
+// 						NOTE: If this test fails it can bring down esock when the connection stops (because of the original defect in esock)
+run_script z:\TestData\scripts\te_esock_test_unloadesockForced.script
+run_script z:\TestData\scripts\te_esock_test_loadesock.script
+heap_mark
+run_test_step 100, TE_RConnectionSuite Test482 c:\rconnectiontest.ini
+heap_markend
+test_complete
+END_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0482
+
+
+
+START_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0483
+//! @SYMTestCaseID		COMINF-ESOCK-RConnectionSuite-CMM-0483
+//!@SYMTestCaseDesc     Data Monitoring cancellation test - sent data notification 
+// 						NOTE: If this test fails it can bring down esock when the connection stops (because of the original defect in esock)
+run_script z:\TestData\scripts\te_esock_test_unloadesockForced.script
+run_script z:\TestData\scripts\te_esock_test_loadesock.script
+heap_mark
+run_test_step 100, TE_RConnectionSuite Test483 c:\rconnectiontest.ini
+heap_markend
+test_complete
+END_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0483
+
+
+
+START_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0484
+//! @SYMTestCaseID		COMINF-ESOCK-RConnectionSuite-CMM-0484
+//!@SYMTestCaseDesc     Data Monitoring cancellation test - received data notification 
+// 						NOTE: If this test fails it can bring down esock when the connection stops (because of the original defect in esock)
+run_script z:\TestData\scripts\te_esock_test_unloadesockForced.script
+run_script z:\TestData\scripts\te_esock_test_loadesock.script
+heap_mark
+run_test_step 100, TE_RConnectionSuite Test484 c:\rconnectiontest.ini
+heap_markend
+test_complete
+END_TESTCASE			COMINF-ESOCK-RConnectionSuite-CMM-0484
+
+
+
 run_script z:\TestData\scripts\te_esock_test_unloadesockForced.script
 
 run_utils MakeReadWrite c:\rconnectiontest.ini
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionCMM.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionCMM.h	Wed Apr 14 17:14:05 2010 +0300
@@ -861,6 +861,31 @@
 	virtual enum TVerdict doTestStepL ();
 };
 
+class TE_RConnectionTest481 : public TE_RConnectionStep
+{
+public:
+    virtual enum TVerdict doTestStepL();
+};
+
+class TE_RConnectionTest482 : public TE_RConnectionStep
+{
+public:
+    virtual enum TVerdict doTestStepL();
+};
+
+class TE_RConnectionTest483 : public TE_RConnectionStep
+{
+public:
+    virtual enum TVerdict doTestStepL();
+};
+
+class TE_RConnectionTest484 : public TE_RConnectionStep
+{
+public:
+    virtual enum TVerdict doTestStepL();
+};
+
+
 class TE_RConnectionTest319 : public TE_RConnectionStep
 {
 public:
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionStep.h	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/inc/TE_RConnectionStep.h	Wed Apr 14 17:14:05 2010 +0300
@@ -238,6 +238,13 @@
 	
 	
 	void WaitForRelevantProgress(RConnection& aConn, TNifProgressBuf& aProgress, TInt aRelevantProgress);
+	
+	/**
+	@param aStatus The TRequestStatus you want to wait on
+	@param aTimeOut The time in microseconds to wait for the request to complete before returning
+	@return ETrue if the request completed, EFalse if the timeout happened first 
+	*/
+	TBool WaitForRequestOrTimeOutL(TRequestStatus& aStatus, TInt aTimeOut);
 
 protected:
 	// this is the config data read from the .ini file in ReadIniFile().
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionCMM.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionCMM.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -26,6 +26,7 @@
 #include <inet6err.h>
 #include <in6_opt.h>
 
+
 /**
  * Subconnection Management API extensions
  * 
@@ -7269,5 +7270,445 @@
 } // TE_RConnectionTest319
 
 
+
+enum TVerdict TE_RConnectionTest481::doTestStepL(void)
+/**
+ * Test 481
+ * Test DataSentNotificationRequest() cancellation
+ * Added for defect ou1cimx1#305124.
+ * Tests that cancellation of the request does indeed cancel the request
+ * Defect summary: was the case that the first cancel cancelled the request but left
+ * a notification structure in existence. The second cancel would see the structure
+ * and think that the cancellation had already been done leaving the request outstanding.
+ * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
+ */
+{
+    TInt err;
+    TRequestStatus status1;
+
+    RSocketServ ss;
+    err = OpenSocketServer(ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(ss);
+
+    //********** connection creation ***********
+    RConnection conn1;
+    err = OpenConnection(conn1, ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(conn1);
+
+    // start the dummynif
+    err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
+    TESTEL(KErrNone == err, err);
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
+    TESTEL(KErrNone == err, err);
+
+    RSocket sock1;
+    err = OpenUdpSocketExplicitL(sock1, ss, conn1);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(sock1);
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest"));
+    // Request DataSentNotificationRequest
+    TUint volume1(0); 
+    TPckg<TUint> volume1Des(volume1);
+    TUint threshold1(KLowThresholdSize);
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
+
+    // Send some data but not enough to trigger the notification 
+    TUint currentVol(0);
+    while (currentVol < threshold1 / 2)
+        {
+        err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
+        TESTEL(KErrNone == err, err);
+        TESTEL(KRequestPending == status1.Int(), status1.Int());
+        currentVol += KSmallBufferUdpTestPacketSize;
+        }
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest still outstanding (as expected) - now cancelling"));
+
+    // Cancel the request and expect the completion
+    conn1.DataSentNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest completed with KErrCancel"));
+    
+    // The first cancellation has worked, repeat the above steps for the second cancellation
+    INFO_PRINTF1(_L("Second DataSentNotificationRequest"));
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
+
+    // NOTE: It is a deliberate that no data is transfered this time.
+	//       Transmitting data and crossing the threshold for the first (cancelled) notification
+	//       would cause the object to be cleaned up and therefore mask this issue
+    
+    // Cancel the request and expect the completion
+    conn1.DataSentNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Second DataSentNotificationRequest completed with KErrCancel"));
+    
+    // NOTE: Reaching here successfully does NOT mean the test has passed. If the data monitoring structures
+    //       have been left behind esock will panic when the connection is stopped  
+    
+    
+    //********** turn the idle timers back on now we are finished ***********
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
+    TESTEL(KErrNone == err, err);
+
+    //********** clean up ***********
+    DestroyUdpSocket(sock1);
+    CleanupStack::Pop(&sock1);
+
+    err = conn1.Stop();
+    TESTEL(KErrNone == err, err);
+
+    CloseConnection(conn1);
+    CleanupStack::Pop(&conn1);
+
+    CloseSocketServer(ss);
+    CleanupStack::Pop(&ss);
+
+    return TestStepResult();
+
+} // TE_RConnectionTest481
+
+
+
+enum TVerdict TE_RConnectionTest482::doTestStepL(void)
+/**
+ * Test 482
+ * Test DataReceivedNotificationRequest() cancellation
+ * Added for defect ou1cimx1#305124.
+ * Tests that cancellation of the request does indeed cancel the request
+ * Defect summary: was the case that the first cancel cancelled the request but left
+ * a notification structure in existence. The second cancel would see the structure
+ * and think that the cancellation had already been done leaving the request outstanding.
+ * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
+ */
+{
+    TInt err;
+    TRequestStatus status1;
+
+    RSocketServ ss;
+    err = OpenSocketServer(ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(ss);
+
+    //********** connection creation ***********
+    RConnection conn1;
+    err = OpenConnection(conn1, ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(conn1);
+
+    // start the dummynif
+    err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
+    TESTEL(KErrNone == err, err);
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
+    TESTEL(KErrNone == err, err);
+
+    RSocket sock1;
+    err = OpenUdpSocketExplicitL(sock1, ss, conn1);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(sock1);
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest"));
+    // Request DataSentNotificationRequest
+    TUint volume1(0); 
+    TPckg<TUint> volume1Des(volume1);
+    TUint threshold1(KLowThresholdSize);
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
+
+    // Send some data but not enough to trigger the notification 
+    TUint currentVol(0);
+    while (currentVol < threshold1 / 2)
+        {
+        err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
+        TESTEL(KErrNone == err, err);
+        TESTEL(KRequestPending == status1.Int(), status1.Int());
+        currentVol += KSmallBufferUdpTestPacketSize;
+        }
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest still outstanding (as expected) - now cancelling"));
+
+    // Cancel the request and expect the completion
+    conn1.DataReceivedNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest completed with KErrCancel"));
+    
+    // The first cancellation has worked, repeat the above steps for the second cancellation
+    INFO_PRINTF1(_L("Second DataReceivedNotificationRequest"));
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
+
+    // NOTE: It is a deliberate that no data is transfered this time.
+	//       Transmitting data and crossing the threshold for the first (cancelled) notification
+	//       would cause the object to be cleaned up and therefore mask this issue
+    
+    // Cancel the request and expect the completion
+    conn1.DataReceivedNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Second DataReceivedNotificationRequest completed with KErrCancel"));
+
+    // NOTE: Reaching here successfully does NOT mean the test has passed. If the data monitoring structures
+    //       have been left behind esock will panic when the connection is stopped  
+
+    
+    //********** turn the idle timers back on now we are finished ***********
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
+    TESTEL(KErrNone == err, err);
+
+    //********** clean up ***********
+    DestroyUdpSocket(sock1);
+    CleanupStack::Pop(&sock1);
+
+    err = conn1.Stop();
+    TESTEL(KErrNone == err, err);
+
+    CloseConnection(conn1);
+    CleanupStack::Pop(&conn1);
+
+    CloseSocketServer(ss);
+    CleanupStack::Pop(&ss);
+
+    return TestStepResult();
+
+} // TE_RConnectionTest482
+
+
+
+enum TVerdict TE_RConnectionTest483::doTestStepL(void)
+/**
+ * Test 483
+ * Test DataSentNotificationRequest() cancellation
+ * Added for defect ou1cimx1#305124.
+ * Tests that cancellation of the request does indeed cancel the request
+ * Defect summary: If the state described in Test481 occurs, it would have been possible to
+ * request more than one DataSentNotificationRequest per RConnection. This should not be possible.
+ * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
+ */
+{
+    TInt err;
+    TRequestStatus status1;
+
+    RSocketServ ss;
+    err = OpenSocketServer(ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(ss);
+
+    //********** connection creation ***********
+    RConnection conn1;
+    err = OpenConnection(conn1, ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(conn1);
+
+    // start the dummynif
+    err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
+    TESTEL(KErrNone == err, err);
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
+    TESTEL(KErrNone == err, err);
+
+    RSocket sock1;
+    err = OpenUdpSocketExplicitL(sock1, ss, conn1);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(sock1);
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest"));
+    // Request DataSentNotificationRequest
+    TUint volume1(0); 
+    TPckg<TUint> volume1Des(volume1);
+    TUint threshold1(KLowThresholdSize);
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
+
+    // Send some data but not enough to trigger the notification 
+    TUint currentVol(0);
+    while (currentVol < threshold1 / 2)
+        {
+        err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
+        TESTEL(KErrNone == err, err);
+        TESTEL(KRequestPending == status1.Int(), status1.Int());
+        currentVol += KSmallBufferUdpTestPacketSize;
+        }
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest still outstanding (as expected) - now cancelling"));
+
+    // Cancel the request and expect the completion
+    conn1.DataSentNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+
+    INFO_PRINTF1(_L("First DataSentNotificationRequest completed with KErrCancel"));
+    
+    // The first cancellation has worked, repeat the above steps for the second cancellation
+    INFO_PRINTF1(_L("Second DataSentNotificationRequest"));
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
+
+    // NOTE: It is a deliberate that no data is transfered this time.
+	//       Transmitting data and crossing the threshold for the first (cancelled) notification
+	//       would cause the object to be cleaned up and therefore mask this issue
+    
+    // Cancel the request and expect the completion
+    conn1.DataSentNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Second DataSentNotificationRequest completed with KErrCancel"));
+    
+    
+    INFO_PRINTF1(_L("Third DataSentNotificationRequest"));
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
+    
+
+    INFO_PRINTF1(_L("Fourth DataSentNotificationRequest"));
+    TRequestStatus status2;
+    conn1.DataSentNotificationRequest(threshold1, volume1Des, status2);
+    TBool requestCompleted = WaitForRequestOrTimeOutL(status2, KOneSecondDelay);
+    TESTL(requestCompleted);
+    TESTEL(status2.Int() == KErrInUse, status2.Int());
+    INFO_PRINTF1(_L("Fourth DataSentNotificationRequest failed with KErrInUse as expected"));
+    
+    conn1.DataSentNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Third DataSentNotificationRequest completed with KErrCancel"));
+    
+    //********** turn the idle timers back on now we are finished ***********
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
+    TESTEL(KErrNone == err, err);
+
+    //********** clean up ***********
+    DestroyUdpSocket(sock1);
+    CleanupStack::Pop(&sock1);
+
+    err = conn1.Stop();
+    TESTEL(KErrNone == err, err);
+
+    CloseConnection(conn1);
+    CleanupStack::Pop(&conn1);
+
+    CloseSocketServer(ss);
+    CleanupStack::Pop(&ss);
+
+    return TestStepResult();
+
+} // TE_RConnectionTest483
+
+
+enum TVerdict TE_RConnectionTest484::doTestStepL(void)
+/**
+ * Test 484
+ * Test DataReceivedNotificationRequest() cancellation
+ * Added for defect ou1cimx1#305124.
+ * Tests that cancellation of the request does indeed cancel the request
+ * Defect summary: If the state described in Test482 occurs, it would have been possible to
+ * request more than one DataReceivedNotificationRequest per RConnection. This should not be possible.
+ * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
+ */
+{
+    TInt err;
+    TRequestStatus status1;
+
+    RSocketServ ss;
+    err = OpenSocketServer(ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(ss);
+
+    //********** connection creation ***********
+    RConnection conn1;
+    err = OpenConnection(conn1, ss);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(conn1);
+
+    // start the dummynif
+    err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
+    TESTEL(KErrNone == err, err);
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
+    TESTEL(KErrNone == err, err);
+
+    RSocket sock1;
+    err = OpenUdpSocketExplicitL(sock1, ss, conn1);
+    TESTEL(KErrNone == err, err);
+    CleanupClosePushL(sock1);
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest"));
+    // Request DataReceivedNotificationRequest
+    TUint volume1(0); 
+    TPckg<TUint> volume1Des(volume1);
+    TUint threshold1(KLowThresholdSize);
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
+
+    // Send some data but not enough to trigger the notification 
+    TUint currentVol(0);
+    while (currentVol < threshold1 / 2)
+        {
+        err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
+        TESTEL(KErrNone == err, err);
+        TESTEL(KRequestPending == status1.Int(), status1.Int());
+        currentVol += KSmallBufferUdpTestPacketSize;
+        }
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest still outstanding (as expected) - now cancelling"));
+
+    // Cancel the request and expect the completion
+    conn1.DataReceivedNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+
+    INFO_PRINTF1(_L("First DataReceivedNotificationRequest completed with KErrCancel"));
+    
+    // The first cancellation has worked, repeat the above steps for the second cancellation
+    INFO_PRINTF1(_L("Second DataReceivedNotificationRequest"));
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
+
+    // NOTE: It is a deliberate that no data is transfered this time.
+	//       Transmitting data and crossing the threshold for the first (cancelled) notification
+	//       would cause the object to be cleaned up and therefore mask this issue
+    
+    // Cancel the request and expect the completion
+    conn1.DataReceivedNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Second DataReceivedNotificationRequest completed with KErrCancel"));
+    
+    
+    INFO_PRINTF1(_L("Third DataReceivedNotificationRequest"));
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
+
+    INFO_PRINTF1(_L("Fourth DataReceivedNotificationRequest"));
+    TRequestStatus status2;
+    conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status2);
+    TBool requestCompleted = WaitForRequestOrTimeOutL(status2, KOneSecondDelay);
+    TESTL(requestCompleted);
+    TESTEL(status2.Int() == KErrInUse, status2.Int());
+    INFO_PRINTF1(_L("Fourth DataReceivedNotificationRequest failed with KErrInUse as expected"));
+    
+    conn1.DataReceivedNotificationCancel();
+    User::WaitForRequest(status1);
+    TESTEL(status1.Int() == KErrCancel, status1.Int());
+    INFO_PRINTF1(_L("Third DataReceivedNotificationRequest completed with KErrCancel"));
+    
+    //********** turn the idle timers back on now we are finished ***********
+    err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
+    TESTEL(KErrNone == err, err);
+
+    //********** clean up ***********
+    DestroyUdpSocket(sock1);
+    CleanupStack::Pop(&sock1);
+
+    err = conn1.Stop();
+    TESTEL(KErrNone == err, err);
+
+    CloseConnection(conn1);
+    CleanupStack::Pop(&conn1);
+
+    CloseSocketServer(ss);
+    CleanupStack::Pop(&ss);
+
+    return TestStepResult();
+
+} // TE_RConnectionTest484
+
+
 // EOF TE_RConnectionCMM.cpp
 
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionDummyNifTestSteps.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionDummyNifTestSteps.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -232,7 +232,6 @@
 void CConnectionTest1b::Start()
 	{
 	INFO_PRINTF1(_L("Starting Connection"));
-
 	iConnection.Start(iStatus);
 	SetActive();
 	}
@@ -1948,6 +1947,10 @@
 
 	TESTEL(KErrNone == progress().iError, progress().iError);
 	TESTEL(ECsdStartingHangUp == progress().iStage, progress().iStage);
+	
+	INFO_PRINTF1(_L("Waiting for KConnectionDown and KConnectionUninitialised. If the test times-out they didn't come (in the right seq)."));
+    WaitForRelevantProgress(conn1, progress, KConnectionDown);
+    WaitForRelevantProgress(conn1, progress, KConnectionUninitialised); 
 
 	CloseConnection(conn1);
 	CleanupStack::Pop();
@@ -5088,6 +5091,10 @@
 
 	TESTEL(KErrNone == progress().iError, progress().iError);
 	TESTEL(ECsdStartingHangUp == progress().iStage, progress().iStage);
+	
+    INFO_PRINTF1(_L("Waiting for KConnectionDown and KConnectionUninitialised. If the test times-out they didn't come (in the right seq)."));	
+    WaitForRelevantProgress(conn1, progress, KConnectionDown);
+    WaitForRelevantProgress(conn1, progress, KConnectionUninitialised);	
 
 	CloseConnection(conn1);
 	CleanupStack::Pop();
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionStep.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionStep.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -1732,6 +1732,27 @@
 }
 
 
+TBool TE_RConnectionStep::WaitForRequestOrTimeOutL(TRequestStatus& aStatus, TInt aTimeOut)
+    {
+    RTimer timer;
+    User::LeaveIfError(timer.CreateLocal());
+
+    TRequestStatus timerStatus;
+    timer.After(timerStatus, aTimeOut);
+    User::WaitForRequest(aStatus, timerStatus);
+    TBool requestCompleted = EFalse;
+    
+    if (timerStatus == KRequestPending)
+        {
+        timer.Cancel();
+        User::WaitForRequest(timerStatus);
+        requestCompleted = ETrue;
+        }
+    
+    timer.Close();
+    return requestCompleted;
+    }
+
 
 /*
  * Now the stuff for the peculiar tests that need to use QoS
--- a/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionSuite.cpp	Wed Mar 31 23:27:09 2010 +0300
+++ b/datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionSuite.cpp	Wed Apr 14 17:14:05 2010 +0300
@@ -655,6 +655,14 @@
 		testStep=new TE_RConnectionTest479();
 	else if(aStepName.Compare(_L("Test480")) == 0)
 		testStep=new TE_RConnectionTest480();
+    else if(aStepName.Compare(_L("Test481")) == 0)
+        testStep=new TE_RConnectionTest481();
+    else if(aStepName.Compare(_L("Test482")) == 0)
+        testStep=new TE_RConnectionTest482();
+    else if(aStepName.Compare(_L("Test483")) == 0)
+        testStep=new TE_RConnectionTest483();
+    else if(aStepName.Compare(_L("Test484")) == 0)
+        testStep=new TE_RConnectionTest484();
 
 	return testStep;
 	}