datacommsserver/esockserver/inc/SS_conn.H
changeset 0 dfb7c4ff071f
child 1 21d2ab05f085
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef SS_CONN_H
       
    17 #define SS_CONN_H
       
    18 
       
    19 #include <comms-infras/ss_mcprnodemessages.h>
       
    20 #include <comms-infras/ss_connprov.h>
       
    21 #include <comms-infras/ss_connlegacy.h>
       
    22 #include <comms-infras/ss_platsec_apiext.h>
       
    23 #include <ss_std.h>
       
    24 #include <comms-infras/ss_mmnode.h>
       
    25 #include <comms-infras/ss_mmnode_subsess.h>
       
    26 
       
    27 class TSockOpt;
       
    28 
       
    29 
       
    30 namespace ConnStates
       
    31 {
       
    32 	class TEmptyProgressQueueMutex;
       
    33 
       
    34 	class TParseECNStart;
       
    35 	class TClearProgressQueue;
       
    36 	class TRequestCSRCreation;
       
    37 	class TProcessStateChange;
       
    38 	class TProcessIncomingConnection;
       
    39 	class TProcessProgressRequest;
       
    40 	class TParseECNAttach;
       
    41 	class TJoinReceivedCpr;
       
    42 	class TProcessBinderResponseForCpr;
       
    43 	class TCompleteLegacyAttach;
       
    44 	class TProcessEnumResponse;
       
    45 	
       
    46 	class TGenerateConnectionUpProgress;
       
    47 	class TGenerateConnectionDownProgress;
       
    48 
       
    49 	class TNoTagOrCancelAllInterfaceWorker;
       
    50 	class TCancelAllInterfaceNotificationWorker;
       
    51 }
       
    52 
       
    53 namespace AllInterfaceNotificationActivity
       
    54 {
       
    55 class TStartLinkNotification;
       
    56 class TEnqueueNotification;
       
    57 class TSendErrorToConnection;
       
    58 }
       
    59 
       
    60 namespace EnumerateConnectionsActivity
       
    61 {
       
    62 class TQueryTierStatus;
       
    63 class TCacheConnectionInfo;
       
    64 class TCompleteClient;
       
    65 }
       
    66 
       
    67 namespace ConnSubConnEventsActivity
       
    68 {
       
    69 class TProcessSubConnEvent;
       
    70 }
       
    71 
       
    72 namespace ESock
       
    73 {
       
    74 class TCprRetrieveProgress;
       
    75 class TCprRetrieveLastProgressError;
       
    76 
       
    77 class CConnectionInfo : public Meta::SMetaData
       
    78 /**
       
    79 @internalTechnology
       
    80 */
       
    81 	{
       
    82 public:
       
    83     enum { ETypeId = 0, EUid = 0x10283005 };
       
    84 
       
    85 	static CConnectionInfo* NewL(const Den::TSubSessionUniqueId& aSubSessionId);
       
    86 
       
    87 	virtual ~CConnectionInfo()
       
    88 			{}
       
    89 
       
    90 	Den::TSubSessionUniqueId SubSessionId() const
       
    91 			{
       
    92 			return iSubSessionId;
       
    93 			}
       
    94 
       
    95 	void SetSubSessionId(const Den::TSubSessionUniqueId& aSubSessionId)
       
    96 			{
       
    97 			iSubSessionId = aSubSessionId;
       
    98 			}
       
    99 
       
   100 	DATA_VTABLE
       
   101 
       
   102 protected:
       
   103 	inline CConnectionInfo(const Den::TSubSessionUniqueId& aSubSessionId)
       
   104 		:	iSubSessionId(aSubSessionId)
       
   105 			{
       
   106 			}
       
   107 
       
   108 	Den::TSubSessionUniqueId iSubSessionId;
       
   109 	};
       
   110 
       
   111 struct TCommsControlBinder;
       
   112 struct TErrContext;
       
   113 class XCommsDataObject;
       
   114 
       
   115 /**
       
   116 Server side class representing an RConnection
       
   117 @internalComponent
       
   118 */
       
   119 NONSHARABLE_CLASS(CConnection) : public CMMSockSubSession,
       
   120                                  private ASubSessionPlatsecApiExt,
       
   121                                  public ITFHIERARCHY_LINK_1(CConnection, MeshMachine::AMMNodeBase, MPlatsecApiExt)
       
   122 	{
       
   123 	friend class CSockSession;
       
   124 	friend class ConnStates::TEmptyProgressQueueMutex;
       
   125 #ifdef __X86GCC__
       
   126  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   127  	// functions to do the cast.
       
   128     friend  CConnection* __x86gcc_connection_cast(Messages::ANode* aNode);
       
   129     friend  CConnection& __x86gcc_connection_cast(Messages::ANode& aNode);
       
   130 #elif !defined(__GCCXML__)
       
   131     friend  CConnection* mcfnode_cast<CConnection>(Messages::ANode* aNode);
       
   132 	friend  CConnection& mcfnode_cast<CConnection>(Messages::ANode& aNode);
       
   133 #endif
       
   134 
       
   135 	//Friendly activities:
       
   136 
       
   137 	//Friendly transitions and states:
       
   138 	friend class ConnStates::TParseECNStart;
       
   139 	friend class ConnStates::TClearProgressQueue;
       
   140 	friend class ConnStates::TRequestCSRCreation;
       
   141 	friend class ConnStates::TProcessStateChange;
       
   142 	friend class ConnStates::TProcessIncomingConnection;
       
   143 	friend class ConnStates::TProcessProgressRequest;
       
   144 	friend class ConnStates::TParseECNAttach;
       
   145 	friend class ConnStates::TJoinReceivedCpr;
       
   146 	friend class ConnStates::TProcessBinderResponseForCpr;
       
   147 	friend class ConnStates::TCompleteLegacyAttach;
       
   148 	friend class ConnStates::TProcessEnumResponse;
       
   149 	friend class ESock::TCprRetrieveLastProgressError;
       
   150 	friend class ESock::TCprRetrieveProgress;
       
   151 	friend class EnumerateConnectionsActivity::TQueryTierStatus;
       
   152 	friend class EnumerateConnectionsActivity::TCacheConnectionInfo;
       
   153 	friend class EnumerateConnectionsActivity::TCompleteClient;
       
   154 	friend class AllInterfaceNotificationActivity::TEnqueueNotification;
       
   155 	friend class ConnSubConnEventsActivity::TProcessSubConnEvent;
       
   156 
       
   157 	friend class ConnStates::TGenerateConnectionUpProgress;
       
   158 	friend class ConnStates::TGenerateConnectionDownProgress;
       
   159 
       
   160 	friend class ConnStates::TNoTagOrCancelAllInterfaceWorker;
       
   161 	friend class ConnStates::TCancelAllInterfaceNotificationWorker;
       
   162 	
       
   163 
       
   164 public:
       
   165 	typedef ITFHIERARCHY_LINK_1(CConnection, MeshMachine::AMMNodeBase, MPlatsecApiExt) TIfStaticFetcherNearestInHierarchy;
       
   166 
       
   167 public:
       
   168 	// methods for creating CConnection instances
       
   169 	static CConnection* NewLC(CSockSession *aSession, CPlayer* aPlayer, TUid aTierId, const Den::TSubSessionUniqueId aSubSessionUniqueId);
       
   170 	static CConnection* NewLC(CSockSession *aSession, CPlayer* aPlayer, const CConnection& aExistingConnection, const Den::TSubSessionUniqueId aSubSessionUniqueId);
       
   171 
       
   172 	virtual Den::TSubSessInfo Type() const
       
   173 		{
       
   174 		return TCFSubSessInfo(TCFSubSessInfo::EConnection);
       
   175 		}
       
   176 
       
   177 	//Attached to interface in monitor mode?
       
   178 	inline TBool IsMonitor() const
       
   179 		{
       
   180 		return iIsMonitor;
       
   181 		}
       
   182 
       
   183     void ReturnInterfacePtrL(MPlatsecApiExt*& aInterface);
       
   184     Messages::RNodeInterface* DefaultSubConnectionServiceProvider();
       
   185     TInt CheckCloneOpenPolicy(const RMessagePtr2& aMessage) const;
       
   186 	inline CConnectionInfo* ConnectionInfo() const
       
   187 			{
       
   188 			return iConnectionInfo;
       
   189 			}
       
   190 
       
   191 protected:
       
   192 	void Received(MeshMachine::TNodeContextBase& aContext);
       
   193 	void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aCFMessage); //Messages::ANode
       
   194 
       
   195 //Signals from CSockSubSession
       
   196 	virtual void FinalCompleteAllBlockedMessages(TInt aResult); //Always KErrAbort
       
   197 	virtual void ProcessMessageL(); //IPC message arrived
       
   198 
       
   199 private: //Utility functions
       
   200 	void ForwardToServiceProviderL(const Messages::TSignalBase& aCFMessage);
       
   201 	inline void ResetLastProgressError();
       
   202 	void SetCloneOpenPolicyL(TUint aOptionName);
       
   203 
       
   204 private:
       
   205 	virtual ~CConnection(); //Only my friend or subsess can delete me
       
   206 
       
   207 protected:
       
   208 	CConnection(CSockSession* aSession, CPlayer* aPlayer, TUid aTierId, const Den::TSubSessionUniqueId aSubSessionUniqueId);
       
   209 	void ConstructL();
       
   210 	void CloneL(const CConnection& aExistingConnection);
       
   211 
       
   212 private: // Underlying implementations of individual RConnection methods
       
   213 	void GetReferenceL();
       
   214 	void ControlL();
       
   215 	void ProgressL();
       
   216 	void LastProgressErrorL();
       
   217 	void GetOrSetParametersL();
       
   218 	void GetParametersResponseL(TBool aReturnLength);
       
   219 	void CancelIoctl();
       
   220 
       
   221 private:
       
   222 	TUint iSelectedProgressStage;			// the particular stage required for selected progress requests.
       
   223 	TProgressQueue iProgressQueue;			// queue of progress notifications received
       
   224 	Elements::TStateChange iLastProgress;		// last progress notified, so we can filter duplicates
       
   225 	Elements::TStateChange iLastProgressError;	// last progress received which had an error
       
   226 
       
   227 	TUid iTierId;
       
   228 	TSecurityPolicy	iCloneOpenPolicy;       // used for security checking during RConnection::Open(..., TName&)
       
   229     TBool iCloneOpenEnabled   :1;  			// flag indicating that iCloneOpenPolicy is initialized and "clone" open is enabled
       
   230     TBool iIsMonitor          :1;
       
   231 	XCommsDataObject* iCommsDataObject;
       
   232 	TUint iCommsDataObjectLength;	// output query length
       
   233 	
       
   234 protected:
       
   235 
       
   236 	//-=============================================
       
   237 	//Legacy function
       
   238 	friend class AConnectionLegacy;
       
   239 	AConnectionLegacy iLegacyConnection;
       
   240 	//-=============================================
       
   241 
       
   242 	CConnectionInfo *iConnectionInfo;
       
   243 	};
       
   244 
       
   245 
       
   246 //inline TBool CConnection::IsConnectionActive() const
       
   247 //	{ return iConnectionProvider.Type() == RNodeInterface::EServProvider; } //WHO ADDS THIS THINGS?????????????
       
   248 
       
   249 inline void CConnection::ResetLastProgressError()
       
   250 	{ iLastProgressError.iError = KErrNone; iLastProgressError.iStage = KConnectionUninitialised; };
       
   251 
       
   252 #ifdef __X86GCC__
       
   253  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   254  	// functions to do the cast.
       
   255 	inline CConnection* __x86gcc_connection_cast(Messages::ANode* aNode)
       
   256     	{
       
   257     	return static_cast<CConnection*>(aNode);
       
   258     	}
       
   259 
       
   260 	inline CConnection& __x86gcc_connection_cast(Messages::ANode& aNode)
       
   261     	{
       
   262     	return static_cast<CConnection&>(aNode);
       
   263     	}
       
   264 #endif
       
   265 } // namespace ESock
       
   266 
       
   267 
       
   268 #ifdef __X86GCC__
       
   269 	namespace Messages
       
   270 	{
       
   271  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   272  	// functions to do the cast.
       
   273 	template <>
       
   274 	inline ESock::CConnection* mnode_cast<ESock::CConnection>(Messages::ANode* aNode)
       
   275 		{
       
   276 		return ESock::__x86gcc_connection_cast(aNode);
       
   277 		}
       
   278 
       
   279 	template <>
       
   280 	inline ESock::CConnection& mnode_cast<ESock::CConnection>(Messages::ANode& aNode)
       
   281 		{
       
   282 		return ESock::__x86gcc_connection_cast(aNode);
       
   283 		}
       
   284 	}
       
   285 #endif
       
   286 
       
   287 
       
   288 NONSHARABLE_CLASS(CAllInterfaceNotificationWorker) :
       
   289 	public CBase, public ESock::ACFMMNodeIdBase
       
   290 	{
       
   291 friend class AllInterfaceNotificationActivity::TStartLinkNotification;
       
   292 friend class AllInterfaceNotificationActivity::TEnqueueNotification;
       
   293 friend class AllInterfaceNotificationActivity::TSendErrorToConnection;
       
   294 
       
   295 public:
       
   296     CAllInterfaceNotificationWorker(ESock::CConnection& aConnection);
       
   297     virtual ~CAllInterfaceNotificationWorker();
       
   298     void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
   299 
       
   300 private:
       
   301     void Received(MeshMachine::TNodeContextBase& aContext);
       
   302 
       
   303 	ESock::CConnection& iConnection;
       
   304 	};
       
   305 
       
   306 
       
   307 #endif
       
   308 // SS_CONN_H