datacommsserver/esockserver/inc/ss_connprov.h
changeset 0 dfb7c4ff071f
child 1 21d2ab05f085
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2005-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 /**
       
    17  @file
       
    18  @internalComponent 
       
    19 */
       
    20 
       
    21 #if !defined(__SS_CONNPROV_H__)
       
    22 #define __SS_CONNPROV_H__
       
    23 
       
    24 #include <e32def.h>
       
    25 #include <elements/metadata.h>
       
    26 #include <ss_select.h>
       
    27 #include <elements/factorynotify.h>
       
    28 #include <es_sock.h> //TNifProgressBuf & co
       
    29 #include <es_prot.h> //TConnStartType &co
       
    30 #include <comms-infras/ss_mmcommsprov.h>
       
    31 #include <comms-infras/ss_metaconnprov.h> //For TProviderInfo which may need to be moved to a different header in case of a circular dep.
       
    32 #include <comms-infras/ss_nodemessages_cpr.h>
       
    33 #include <comms-infras/ss_nodemessages_internal.h>
       
    34 
       
    35 #include <comms-infras/ss_common.h>
       
    36 #include <comms-infras/ss_commsprov.h>
       
    37 #include <comms-infras/ss_fact_internal.h>
       
    38 
       
    39 namespace ESock
       
    40 {
       
    41 
       
    42 const TInt KConnInfoPart = 8; //TODO: delete with TConnectionInfo
       
    43 
       
    44 class CConnection;
       
    45 class CCommsFactoryBase;
       
    46 class CConnectionProviderBase;
       
    47 class CSubConnectionProviderBase;
       
    48 
       
    49 const TInt KProtocolAny	= 0xffffff1; //cooked-up constant for any protocol
       
    50 const TInt KConnectionFactoryInterfaceUid = 0x102070EE;
       
    51 
       
    52 class XConnectionProviderInfoQuery : public Factories::MFactoryQuery
       
    53 /** Class implementing MCommsFactoryQuery to find a connection provider by
       
    54  * using iProviderInfo
       
    55 
       
    56 @internalTechnology
       
    57 */
       
    58 	{
       
    59 public:
       
    60 	explicit XConnectionProviderInfoQuery(const TProviderInfo aProviderInfo)
       
    61 	:	iProviderInfo(aProviderInfo)
       
    62 		{
       
    63 		}
       
    64 
       
    65 	IMPORT_C virtual TMatchResult Match(Factories::TFactoryObjectInfo& aProviderInfo);
       
    66 
       
    67 	TProviderInfo iProviderInfo;
       
    68 
       
    69 protected:
       
    70 	explicit XConnectionProviderInfoQuery()
       
    71 	:	iProviderInfo(TProviderInfo::NullProviderInfo())
       
    72 		{
       
    73 		}
       
    74 	};
       
    75 
       
    76 class CConnectionProviderFactoryBase;
       
    77 class CConnectionProviderBase;
       
    78 class CConnectionFactoryContainer : public CCommsFactoryContainer
       
    79 /** Container for connection provider factories.
       
    80 Note that there is a 1-1 mapping between aProtocolId and aFactoryId at the moment
       
    81 
       
    82 @internalTechnology
       
    83 @released Since 9.1 */
       
    84 	{
       
    85 	friend class CConnectionProviderFactoryBase;
       
    86 #ifdef __X86GCC__
       
    87 protected:
       
    88  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
    89  	// functions to do the cast.
       
    90     friend CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject);
       
    91     friend const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject);
       
    92 
       
    93     enum
       
    94         {
       
    95         EId = EConnectionFactoryContainer
       
    96         };
       
    97 #elif defined(__GCCXML__)
       
    98 public:
       
    99     enum
       
   100         {
       
   101         EId = EConnectionFactoryContainer
       
   102         };
       
   103 #else
       
   104 protected:
       
   105     friend CConnectionProviderBase* Factories::factoryobject_cast<CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject);
       
   106     friend const CConnectionProviderBase* Factories::factoryobject_cast<const CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject);
       
   107 
       
   108     enum
       
   109         {
       
   110         EId = EConnectionFactoryContainer
       
   111         };
       
   112 #endif
       
   113 
       
   114 public:
       
   115 	IMPORT_C static CConnectionFactoryContainer* NewL();
       
   116 
       
   117 	CConnectionProviderFactoryBase* Factory( TInt aIndex ) const;
       
   118     IMPORT_C static CConnectionFactoryContainer& Singleton();
       
   119 	virtual ~CConnectionFactoryContainer();
       
   120 
       
   121 protected:
       
   122 	CConnectionFactoryContainer();
       
   123 	virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
   124 	};
       
   125 
       
   126 class CConnectionProviderBase;
       
   127 class CConnectionProviderFactoryBase : public CCommsFactoryBase
       
   128 /** Base class for all connection provider factories. Specifies the interface
       
   129     that all connection provider factories must implement. It also providers the
       
   130 	ECOM framework (via CCommsFactoryBase) to load connection provider factories
       
   131 	from other Dynamic Linked Libraries.
       
   132 
       
   133 @internalTechnology
       
   134 @released Since 9.1 */
       
   135 	{
       
   136 	friend class CConnectionProviderBase;
       
   137 public:
       
   138 	IMPORT_C static CConnectionProviderFactoryBase* NewL(const TDesC8& aName, CConnectionFactoryContainer& aParentContainer);
       
   139 	IMPORT_C virtual ~CConnectionProviderFactoryBase();
       
   140 
       
   141 	IMPORT_C ACommsFactoryNodeId* CreateL(TFactoryQueryBase& aQuery); //sync
       
   142 
       
   143 protected:
       
   144 	IMPORT_C CConnectionProviderFactoryBase(TUid aFactoryId, CConnectionFactoryContainer& aParentContainer);
       
   145 
       
   146 	IMPORT_C ACommsFactoryNodeId* DoFindOrCreateObjectL(TFactoryQueryBase& aQuery);
       
   147 	/** Override this to create a new instance of CConnectionProviderBase
       
   148 
       
   149 	@return Pointer to the newly created provider
       
   150 	@exception Leaves in out of memory conditions */
       
   151 	IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery);
       
   152 
       
   153 protected:
       
   154 	struct TInternalData
       
   155 		{
       
   156 		};
       
   157 
       
   158 protected:
       
   159 	TInternalData* iInternalData;
       
   160 	};
       
   161 
       
   162 //
       
   163 // CConnectionProviderBase
       
   164 class CConnectionSettings;
       
   165 class CConnectionProviderBase : public CMMCommsProviderBase, public TCFCpr
       
   166 /**	Base class specifying the interfaces required to implement a connection provider.
       
   167 	Contains collections of control and data clients and defines operations on them
       
   168 
       
   169 @internalTechnology
       
   170 @released Since 9.1 */
       
   171 	{
       
   172 	friend class CConnectionProviderFactoryBase;
       
   173 #ifdef __X86GCC__
       
   174  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   175  	// functions to do the cast.
       
   176     friend  CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode);
       
   177     friend  CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode);
       
   178 #elif !defined(__GCCXML__)
       
   179     friend  CConnectionProviderBase* mcfnode_cast<CConnectionProviderBase>(Messages::ANode* aNode);
       
   180     friend  CConnectionProviderBase& mcfnode_cast<CConnectionProviderBase>(Messages::ANode& aNode);
       
   181 #endif
       
   182 
       
   183 public:
       
   184 	inline const TProviderInfo& ProviderInfo() const
       
   185 		{
       
   186 		const TProviderInfoExt* providerInfo = static_cast<const TProviderInfoExt*>(AccessPointConfig().FindExtension(
       
   187 				STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId)));
       
   188 		ASSERT(providerInfo);
       
   189 		return providerInfo->iProviderInfo;
       
   190 		}
       
   191 
       
   192     Messages::RNodeInterface* DefaultSubConnectionProvider() const
       
   193         {
       
   194         return MeshMachine::AMMNodeBase::GetFirstClient<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(TCFClientType::EData,TCFClientType::EDefault));
       
   195         }
       
   196 
       
   197 protected:
       
   198 	IMPORT_C CConnectionProviderBase(CConnectionProviderFactoryBase& aFactory,
       
   199 	                                 const MeshMachine::TNodeActivityMap& aActivityMap);
       
   200 	IMPORT_C virtual Messages::RNodeInterface* NewClientInterfaceL(const Messages::TClientType& aClientType, TAny* aClientInfo = NULL);
       
   201 	IMPORT_C ~CConnectionProviderBase();
       
   202 	};
       
   203 
       
   204 #ifdef __X86GCC__
       
   205  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   206  	// functions to do the cast...
       
   207 
       
   208 	inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode)
       
   209     	{
       
   210     	return static_cast<CConnectionProviderBase*>(aNode);
       
   211     	}
       
   212 
       
   213 	inline CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode)
       
   214     	{
       
   215     	return static_cast<CConnectionProviderBase&>(aNode);
       
   216     	}
       
   217 
       
   218 	inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject)
       
   219     	{
       
   220 	    return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   221 	    	static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
       
   222     	}
       
   223 
       
   224 	inline const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject)
       
   225     	{
       
   226 	    return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   227 	    	static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
       
   228     	}
       
   229 #endif
       
   230 }//namespace ESock
       
   231 
       
   232 
       
   233 #ifdef __X86GCC__
       
   234 	namespace Messages
       
   235 	{
       
   236  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   237  	// functions to do the cast.
       
   238 	template <>
       
   239 	inline ESock::CConnectionProviderBase* mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode* aNode)
       
   240 		{
       
   241 		return ESock::__x86gcc_connection_provider_base_cast(aNode);
       
   242 		}
       
   243 
       
   244 	template <>
       
   245 	inline ESock::CConnectionProviderBase& mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode& aNode)
       
   246 		{
       
   247 		return ESock::__x86gcc_connection_provider_base_cast(aNode);
       
   248 		}
       
   249 	}
       
   250 #endif
       
   251 
       
   252 
       
   253 namespace Factories
       
   254 {
       
   255 
       
   256 #ifdef __X86GCC__
       
   257  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   258  	// functions to do the cast.
       
   259 	template<>
       
   260 	inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
       
   261 	    {
       
   262 		return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
       
   263 	    }
       
   264 
       
   265 	template<>
       
   266 	inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
       
   267 	    {
       
   268 		return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
       
   269 	    }
       
   270 #else
       
   271 	// RVCT does not allow the specialisation of template functions in a different namespace from the original
       
   272 	// so we declare them in the Factories namespace.
       
   273 	template<>
       
   274 	inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
       
   275 	    {
       
   276 	    return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   277 	    	static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
       
   278 	    }
       
   279 
       
   280 	template<>
       
   281 	inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
       
   282 	    {
       
   283 	    return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   284 	    	static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
       
   285 	    }
       
   286 #endif
       
   287 
       
   288 }//namespace Factories
       
   289 
       
   290 #endif	// __SS_CONNPROV_H__
       
   291 
       
   292 
       
   293