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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #if !defined(__SS_CONNPROV_H__)
22 #define __SS_CONNPROV_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>
35 #include <comms-infras/ss_common.h>
36 #include <comms-infras/ss_commsprov.h>
37 #include <comms-infras/ss_fact_internal.h>
42 const TInt KConnInfoPart = 8; //TODO: delete with TConnectionInfo
45 class CCommsFactoryBase;
46 class CConnectionProviderBase;
47 class CSubConnectionProviderBase;
49 const TInt KProtocolAny = 0xffffff1; //cooked-up constant for any protocol
50 const TInt KConnectionFactoryInterfaceUid = 0x102070EE;
52 class XConnectionProviderInfoQuery : public Factories::MFactoryQuery
53 /** Class implementing MCommsFactoryQuery to find a connection provider by
60 explicit XConnectionProviderInfoQuery(const TProviderInfo aProviderInfo)
61 : iProviderInfo(aProviderInfo)
64 explicit XConnectionProviderInfoQuery(const TUint32 aAPid)
69 IMPORT_C virtual TMatchResult Match(Factories::TFactoryObjectInfo& aProviderInfo);
71 TProviderInfo iProviderInfo;
75 explicit XConnectionProviderInfoQuery()
76 : iProviderInfo(TProviderInfo::NullProviderInfo())
81 class CConnectionProviderFactoryBase;
82 class CConnectionProviderBase;
83 class CConnectionFactoryContainer : public CCommsFactoryContainer
84 /** Container for connection provider factories.
85 Note that there is a 1-1 mapping between aProtocolId and aFactoryId at the moment
88 @released Since 9.1 */
90 friend class CConnectionProviderFactoryBase;
93 // gcc-mingw does not support declaring friends from different namespaces so we define proxy
94 // functions to do the cast.
95 friend CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject);
96 friend const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject);
100 EId = EConnectionFactoryContainer
102 #elif defined(__GCCXML__)
106 EId = EConnectionFactoryContainer
110 friend CConnectionProviderBase* Factories::factoryobject_cast<CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject);
111 friend const CConnectionProviderBase* Factories::factoryobject_cast<const CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject);
115 EId = EConnectionFactoryContainer
120 IMPORT_C static CConnectionFactoryContainer* NewL();
122 CConnectionProviderFactoryBase* Factory( TInt aIndex ) const;
123 IMPORT_C static CConnectionFactoryContainer& Singleton();
124 virtual ~CConnectionFactoryContainer();
127 CConnectionFactoryContainer();
128 virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
131 class CConnectionProviderBase;
132 class CConnectionProviderFactoryBase : public CCommsFactoryBase
133 /** Base class for all connection provider factories. Specifies the interface
134 that all connection provider factories must implement. It also providers the
135 ECOM framework (via CCommsFactoryBase) to load connection provider factories
136 from other Dynamic Linked Libraries.
139 @released Since 9.1 */
141 friend class CConnectionProviderBase;
143 IMPORT_C static CConnectionProviderFactoryBase* NewL(const TDesC8& aName, CConnectionFactoryContainer& aParentContainer);
144 IMPORT_C virtual ~CConnectionProviderFactoryBase();
146 IMPORT_C ACommsFactoryNodeId* CreateL(TFactoryQueryBase& aQuery); //sync
149 IMPORT_C CConnectionProviderFactoryBase(TUid aFactoryId, CConnectionFactoryContainer& aParentContainer);
151 IMPORT_C ACommsFactoryNodeId* DoFindOrCreateObjectL(TFactoryQueryBase& aQuery);
152 /** Override this to create a new instance of CConnectionProviderBase
154 @return Pointer to the newly created provider
155 @exception Leaves in out of memory conditions */
156 IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery);
164 TInternalData* iInternalData;
168 // CConnectionProviderBase
169 class CConnectionSettings;
170 class CConnectionProviderBase : public CMMCommsProviderBase, public TCFCpr
171 /** Base class specifying the interfaces required to implement a connection provider.
172 Contains collections of control and data clients and defines operations on them
175 @released Since 9.1 */
177 friend class CConnectionProviderFactoryBase;
179 // gcc-mingw does not support declaring friends from different namespaces so we define proxy
180 // functions to do the cast.
181 friend CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode);
182 friend CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode);
183 #elif !defined(__GCCXML__)
184 friend CConnectionProviderBase* mcfnode_cast<CConnectionProviderBase>(Messages::ANode* aNode);
185 friend CConnectionProviderBase& mcfnode_cast<CConnectionProviderBase>(Messages::ANode& aNode);
189 inline const TProviderInfo& ProviderInfo() const
191 const TProviderInfoExt* providerInfo = static_cast<const TProviderInfoExt*>(AccessPointConfig().FindExtension(
192 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId)));
193 ASSERT(providerInfo);
194 return providerInfo->iProviderInfo;
197 Messages::RNodeInterface* DefaultSubConnectionProvider() const
199 return MeshMachine::AMMNodeBase::GetFirstClient<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(TCFClientType::EData,TCFClientType::EDefault));
203 IMPORT_C CConnectionProviderBase(CConnectionProviderFactoryBase& aFactory,
204 const MeshMachine::TNodeActivityMap& aActivityMap);
205 IMPORT_C virtual Messages::RNodeInterface* NewClientInterfaceL(const Messages::TClientType& aClientType, TAny* aClientInfo = NULL);
206 IMPORT_C ~CConnectionProviderBase();
210 // gcc-mingw does not support declaring friends from different namespaces so we define proxy
211 // functions to do the cast...
213 inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode)
215 return static_cast<CConnectionProviderBase*>(aNode);
218 inline CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode)
220 return static_cast<CConnectionProviderBase&>(aNode);
223 inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject)
225 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
226 static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
229 inline const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject)
231 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
232 static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
241 // gcc-mingw does not support declaring friends from different namespaces so we define proxy
242 // functions to do the cast.
244 inline ESock::CConnectionProviderBase* mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode* aNode)
246 return ESock::__x86gcc_connection_provider_base_cast(aNode);
250 inline ESock::CConnectionProviderBase& mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode& aNode)
252 return ESock::__x86gcc_connection_provider_base_cast(aNode);
262 // gcc-mingw does not support declaring friends from different namespaces so we define proxy
263 // functions to do the cast.
265 inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
267 return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
271 inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
273 return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
276 // RVCT does not allow the specialisation of template functions in a different namespace from the original
277 // so we declare them in the Factories namespace.
279 inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
281 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
282 static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
286 inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
288 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
289 static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
293 }//namespace Factories
295 #endif // __SS_CONNPROV_H__