1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/comms-infras/ss_connprov.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,298 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalComponent
1.22 +*/
1.23 +
1.24 +#if !defined(__SS_CONNPROV_H__)
1.25 +#define __SS_CONNPROV_H__
1.26 +
1.27 +#include <e32def.h>
1.28 +#include <elements/metadata.h>
1.29 +#include <ss_select.h>
1.30 +#include <elements/factorynotify.h>
1.31 +#include <es_sock.h> //TNifProgressBuf & co
1.32 +#include <es_prot.h> //TConnStartType &co
1.33 +#include <comms-infras/ss_mmcommsprov.h>
1.34 +#include <comms-infras/ss_metaconnprov.h> //For TProviderInfo which may need to be moved to a different header in case of a circular dep.
1.35 +#include <comms-infras/ss_nodemessages_cpr.h>
1.36 +#include <comms-infras/ss_nodemessages_internal.h>
1.37 +
1.38 +#include <comms-infras/ss_common.h>
1.39 +#include <comms-infras/ss_commsprov.h>
1.40 +#include <comms-infras/ss_fact_internal.h>
1.41 +
1.42 +namespace ESock
1.43 +{
1.44 +
1.45 +const TInt KConnInfoPart = 8; //TODO: delete with TConnectionInfo
1.46 +
1.47 +class CConnection;
1.48 +class CCommsFactoryBase;
1.49 +class CConnectionProviderBase;
1.50 +class CSubConnectionProviderBase;
1.51 +
1.52 +const TInt KProtocolAny = 0xffffff1; //cooked-up constant for any protocol
1.53 +const TInt KConnectionFactoryInterfaceUid = 0x102070EE;
1.54 +
1.55 +class XConnectionProviderInfoQuery : public Factories::MFactoryQuery
1.56 +/** Class implementing MCommsFactoryQuery to find a connection provider by
1.57 + * using iProviderInfo
1.58 +
1.59 +@internalTechnology
1.60 +*/
1.61 + {
1.62 +public:
1.63 + explicit XConnectionProviderInfoQuery(const TProviderInfo aProviderInfo)
1.64 + : iProviderInfo(aProviderInfo)
1.65 + {
1.66 + }
1.67 + explicit XConnectionProviderInfoQuery(const TUint32 aAPid)
1.68 + : iAPid(aAPid)
1.69 + {
1.70 + }
1.71 +
1.72 + IMPORT_C virtual TMatchResult Match(Factories::TFactoryObjectInfo& aProviderInfo);
1.73 +
1.74 + TProviderInfo iProviderInfo;
1.75 + TUint32 iAPid;
1.76 +
1.77 +protected:
1.78 + explicit XConnectionProviderInfoQuery()
1.79 + : iProviderInfo(TProviderInfo::NullProviderInfo())
1.80 + {
1.81 + }
1.82 + };
1.83 +
1.84 +class CConnectionProviderFactoryBase;
1.85 +class CConnectionProviderBase;
1.86 +class CConnectionFactoryContainer : public CCommsFactoryContainer
1.87 +/** Container for connection provider factories.
1.88 +Note that there is a 1-1 mapping between aProtocolId and aFactoryId at the moment
1.89 +
1.90 +@internalTechnology
1.91 +@released Since 9.1 */
1.92 + {
1.93 + friend class CConnectionProviderFactoryBase;
1.94 +#ifdef __X86GCC__
1.95 +protected:
1.96 + // gcc-mingw does not support declaring friends from different namespaces so we define proxy
1.97 + // functions to do the cast.
1.98 + friend CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject);
1.99 + friend const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject);
1.100 +
1.101 + enum
1.102 + {
1.103 + EId = EConnectionFactoryContainer
1.104 + };
1.105 +#elif defined(__GCCXML__)
1.106 +public:
1.107 + enum
1.108 + {
1.109 + EId = EConnectionFactoryContainer
1.110 + };
1.111 +#else
1.112 +protected:
1.113 + friend CConnectionProviderBase* Factories::factoryobject_cast<CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject);
1.114 + friend const CConnectionProviderBase* Factories::factoryobject_cast<const CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject);
1.115 +
1.116 + enum
1.117 + {
1.118 + EId = EConnectionFactoryContainer
1.119 + };
1.120 +#endif
1.121 +
1.122 +public:
1.123 + IMPORT_C static CConnectionFactoryContainer* NewL();
1.124 +
1.125 + CConnectionProviderFactoryBase* Factory( TInt aIndex ) const;
1.126 + IMPORT_C static CConnectionFactoryContainer& Singleton();
1.127 + virtual ~CConnectionFactoryContainer();
1.128 +
1.129 +protected:
1.130 + CConnectionFactoryContainer();
1.131 + virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
1.132 + };
1.133 +
1.134 +class CConnectionProviderBase;
1.135 +class CConnectionProviderFactoryBase : public CCommsFactoryBase
1.136 +/** Base class for all connection provider factories. Specifies the interface
1.137 + that all connection provider factories must implement. It also providers the
1.138 + ECOM framework (via CCommsFactoryBase) to load connection provider factories
1.139 + from other Dynamic Linked Libraries.
1.140 +
1.141 +@internalTechnology
1.142 +@released Since 9.1 */
1.143 + {
1.144 + friend class CConnectionProviderBase;
1.145 +public:
1.146 + IMPORT_C static CConnectionProviderFactoryBase* NewL(const TDesC8& aName, CConnectionFactoryContainer& aParentContainer);
1.147 + IMPORT_C virtual ~CConnectionProviderFactoryBase();
1.148 +
1.149 + IMPORT_C ACommsFactoryNodeId* CreateL(TFactoryQueryBase& aQuery); //sync
1.150 +
1.151 +protected:
1.152 + IMPORT_C CConnectionProviderFactoryBase(TUid aFactoryId, CConnectionFactoryContainer& aParentContainer);
1.153 +
1.154 + IMPORT_C ACommsFactoryNodeId* DoFindOrCreateObjectL(TFactoryQueryBase& aQuery);
1.155 + /** Override this to create a new instance of CConnectionProviderBase
1.156 +
1.157 + @return Pointer to the newly created provider
1.158 + @exception Leaves in out of memory conditions */
1.159 + IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery);
1.160 +
1.161 +protected:
1.162 + struct TInternalData
1.163 + {
1.164 + };
1.165 +
1.166 +protected:
1.167 + TInternalData* iInternalData;
1.168 + };
1.169 +
1.170 +//
1.171 +// CConnectionProviderBase
1.172 +class CConnectionSettings;
1.173 +class CConnectionProviderBase : public CMMCommsProviderBase, public TCFCpr
1.174 +/** Base class specifying the interfaces required to implement a connection provider.
1.175 + Contains collections of control and data clients and defines operations on them
1.176 +
1.177 +@internalTechnology
1.178 +@released Since 9.1 */
1.179 + {
1.180 + friend class CConnectionProviderFactoryBase;
1.181 +#ifdef __X86GCC__
1.182 + // gcc-mingw does not support declaring friends from different namespaces so we define proxy
1.183 + // functions to do the cast.
1.184 + friend CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode);
1.185 + friend CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode);
1.186 +#elif !defined(__GCCXML__)
1.187 + friend CConnectionProviderBase* mcfnode_cast<CConnectionProviderBase>(Messages::ANode* aNode);
1.188 + friend CConnectionProviderBase& mcfnode_cast<CConnectionProviderBase>(Messages::ANode& aNode);
1.189 +#endif
1.190 +
1.191 +public:
1.192 + inline const TProviderInfo& ProviderInfo() const
1.193 + {
1.194 + const TProviderInfoExt* providerInfo = static_cast<const TProviderInfoExt*>(AccessPointConfig().FindExtension(
1.195 + STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId)));
1.196 + ASSERT(providerInfo);
1.197 + return providerInfo->iProviderInfo;
1.198 + }
1.199 +
1.200 + Messages::RNodeInterface* DefaultSubConnectionProvider() const
1.201 + {
1.202 + return MeshMachine::AMMNodeBase::GetFirstClient<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(TCFClientType::EData,TCFClientType::EDefault));
1.203 + }
1.204 +
1.205 +protected:
1.206 + IMPORT_C CConnectionProviderBase(CConnectionProviderFactoryBase& aFactory,
1.207 + const MeshMachine::TNodeActivityMap& aActivityMap);
1.208 + IMPORT_C virtual Messages::RNodeInterface* NewClientInterfaceL(const Messages::TClientType& aClientType, TAny* aClientInfo = NULL);
1.209 + IMPORT_C ~CConnectionProviderBase();
1.210 + };
1.211 +
1.212 +#ifdef __X86GCC__
1.213 + // gcc-mingw does not support declaring friends from different namespaces so we define proxy
1.214 + // functions to do the cast...
1.215 +
1.216 + inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Messages::ANode* aNode)
1.217 + {
1.218 + return static_cast<CConnectionProviderBase*>(aNode);
1.219 + }
1.220 +
1.221 + inline CConnectionProviderBase& __x86gcc_connection_provider_base_cast(Messages::ANode& aNode)
1.222 + {
1.223 + return static_cast<CConnectionProviderBase&>(aNode);
1.224 + }
1.225 +
1.226 + inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject)
1.227 + {
1.228 + return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
1.229 + static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
1.230 + }
1.231 +
1.232 + inline const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject)
1.233 + {
1.234 + return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
1.235 + static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
1.236 + }
1.237 +#endif
1.238 +}//namespace ESock
1.239 +
1.240 +
1.241 +#ifdef __X86GCC__
1.242 + namespace Messages
1.243 + {
1.244 + // gcc-mingw does not support declaring friends from different namespaces so we define proxy
1.245 + // functions to do the cast.
1.246 + template <>
1.247 + inline ESock::CConnectionProviderBase* mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode* aNode)
1.248 + {
1.249 + return ESock::__x86gcc_connection_provider_base_cast(aNode);
1.250 + }
1.251 +
1.252 + template <>
1.253 + inline ESock::CConnectionProviderBase& mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode& aNode)
1.254 + {
1.255 + return ESock::__x86gcc_connection_provider_base_cast(aNode);
1.256 + }
1.257 + }
1.258 +#endif
1.259 +
1.260 +
1.261 +namespace Factories
1.262 +{
1.263 +
1.264 +#ifdef __X86GCC__
1.265 + // gcc-mingw does not support declaring friends from different namespaces so we define proxy
1.266 + // functions to do the cast.
1.267 + template<>
1.268 + inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
1.269 + {
1.270 + return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
1.271 + }
1.272 +
1.273 + template<>
1.274 + inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
1.275 + {
1.276 + return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject);
1.277 + }
1.278 +#else
1.279 + // RVCT does not allow the specialisation of template functions in a different namespace from the original
1.280 + // so we declare them in the Factories namespace.
1.281 + template<>
1.282 + inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject)
1.283 + {
1.284 + return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
1.285 + static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
1.286 + }
1.287 +
1.288 + template<>
1.289 + inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject)
1.290 + {
1.291 + return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
1.292 + static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL;
1.293 + }
1.294 +#endif
1.295 +
1.296 +}//namespace Factories
1.297 +
1.298 +#endif // __SS_CONNPROV_H__
1.299 +
1.300 +
1.301 +