|
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 explicit XConnectionProviderInfoQuery(const TUint32 aAPid) |
|
65 : iAPid(aAPid) |
|
66 { |
|
67 } |
|
68 |
|
69 IMPORT_C virtual TMatchResult Match(Factories::TFactoryObjectInfo& aProviderInfo); |
|
70 |
|
71 TProviderInfo iProviderInfo; |
|
72 TUint32 iAPid; |
|
73 |
|
74 protected: |
|
75 explicit XConnectionProviderInfoQuery() |
|
76 : iProviderInfo(TProviderInfo::NullProviderInfo()) |
|
77 { |
|
78 } |
|
79 }; |
|
80 |
|
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 |
|
86 |
|
87 @internalTechnology |
|
88 @released Since 9.1 */ |
|
89 { |
|
90 friend class CConnectionProviderFactoryBase; |
|
91 #ifdef __X86GCC__ |
|
92 protected: |
|
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); |
|
97 |
|
98 enum |
|
99 { |
|
100 EId = EConnectionFactoryContainer |
|
101 }; |
|
102 #elif defined(__GCCXML__) |
|
103 public: |
|
104 enum |
|
105 { |
|
106 EId = EConnectionFactoryContainer |
|
107 }; |
|
108 #else |
|
109 protected: |
|
110 friend CConnectionProviderBase* Factories::factoryobject_cast<CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject); |
|
111 friend const CConnectionProviderBase* Factories::factoryobject_cast<const CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject); |
|
112 |
|
113 enum |
|
114 { |
|
115 EId = EConnectionFactoryContainer |
|
116 }; |
|
117 #endif |
|
118 |
|
119 public: |
|
120 IMPORT_C static CConnectionFactoryContainer* NewL(); |
|
121 |
|
122 CConnectionProviderFactoryBase* Factory( TInt aIndex ) const; |
|
123 IMPORT_C static CConnectionFactoryContainer& Singleton(); |
|
124 virtual ~CConnectionFactoryContainer(); |
|
125 |
|
126 protected: |
|
127 CConnectionFactoryContainer(); |
|
128 virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
|
129 }; |
|
130 |
|
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. |
|
137 |
|
138 @internalTechnology |
|
139 @released Since 9.1 */ |
|
140 { |
|
141 friend class CConnectionProviderBase; |
|
142 public: |
|
143 IMPORT_C static CConnectionProviderFactoryBase* NewL(const TDesC8& aName, CConnectionFactoryContainer& aParentContainer); |
|
144 IMPORT_C virtual ~CConnectionProviderFactoryBase(); |
|
145 |
|
146 IMPORT_C ACommsFactoryNodeId* CreateL(TFactoryQueryBase& aQuery); //sync |
|
147 |
|
148 protected: |
|
149 IMPORT_C CConnectionProviderFactoryBase(TUid aFactoryId, CConnectionFactoryContainer& aParentContainer); |
|
150 |
|
151 IMPORT_C ACommsFactoryNodeId* DoFindOrCreateObjectL(TFactoryQueryBase& aQuery); |
|
152 /** Override this to create a new instance of CConnectionProviderBase |
|
153 |
|
154 @return Pointer to the newly created provider |
|
155 @exception Leaves in out of memory conditions */ |
|
156 IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery); |
|
157 |
|
158 protected: |
|
159 struct TInternalData |
|
160 { |
|
161 }; |
|
162 |
|
163 protected: |
|
164 TInternalData* iInternalData; |
|
165 }; |
|
166 |
|
167 // |
|
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 |
|
173 |
|
174 @internalTechnology |
|
175 @released Since 9.1 */ |
|
176 { |
|
177 friend class CConnectionProviderFactoryBase; |
|
178 #ifdef __X86GCC__ |
|
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); |
|
186 #endif |
|
187 |
|
188 public: |
|
189 inline const TProviderInfo& ProviderInfo() const |
|
190 { |
|
191 const TProviderInfoExt* providerInfo = static_cast<const TProviderInfoExt*>(AccessPointConfig().FindExtension( |
|
192 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))); |
|
193 ASSERT(providerInfo); |
|
194 return providerInfo->iProviderInfo; |
|
195 } |
|
196 |
|
197 Messages::RNodeInterface* DefaultSubConnectionProvider() const |
|
198 { |
|
199 return MeshMachine::AMMNodeBase::GetFirstClient<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(TCFClientType::EData,TCFClientType::EDefault)); |
|
200 } |
|
201 |
|
202 protected: |
|
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(); |
|
207 }; |
|
208 |
|
209 #ifdef __X86GCC__ |
|
210 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
211 // functions to do the cast... |
|
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(Messages::ANode& aNode) |
|
219 { |
|
220 return static_cast<CConnectionProviderBase&>(aNode); |
|
221 } |
|
222 |
|
223 inline CConnectionProviderBase* __x86gcc_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject) |
|
224 { |
|
225 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
226 static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL; |
|
227 } |
|
228 |
|
229 inline const CConnectionProviderBase* __x86gcc_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject) |
|
230 { |
|
231 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
232 static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL; |
|
233 } |
|
234 #endif |
|
235 }//namespace ESock |
|
236 |
|
237 |
|
238 #ifdef __X86GCC__ |
|
239 namespace Messages |
|
240 { |
|
241 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
242 // functions to do the cast. |
|
243 template <> |
|
244 inline ESock::CConnectionProviderBase* mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode* aNode) |
|
245 { |
|
246 return ESock::__x86gcc_connection_provider_base_cast(aNode); |
|
247 } |
|
248 |
|
249 template <> |
|
250 inline ESock::CConnectionProviderBase& mnode_cast<ESock::CConnectionProviderBase>(Messages::ANode& aNode) |
|
251 { |
|
252 return ESock::__x86gcc_connection_provider_base_cast(aNode); |
|
253 } |
|
254 } |
|
255 #endif |
|
256 |
|
257 |
|
258 namespace Factories |
|
259 { |
|
260 |
|
261 #ifdef __X86GCC__ |
|
262 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
263 // functions to do the cast. |
|
264 template<> |
|
265 inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject) |
|
266 { |
|
267 return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject); |
|
268 } |
|
269 |
|
270 template<> |
|
271 inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject) |
|
272 { |
|
273 return ESock::__x86gcc_connection_provider_base_cast(aFactoryObject); |
|
274 } |
|
275 #else |
|
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. |
|
278 template<> |
|
279 inline ESock::CConnectionProviderBase* factoryobject_cast<ESock::CConnectionProviderBase>(Factories::AFactoryObject* aFactoryObject) |
|
280 { |
|
281 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
282 static_cast<ESock::CConnectionProviderBase*>(aFactoryObject) : NULL; |
|
283 } |
|
284 |
|
285 template<> |
|
286 inline const ESock::CConnectionProviderBase* factoryobject_cast<const ESock::CConnectionProviderBase>(const Factories::AFactoryObject* aFactoryObject) |
|
287 { |
|
288 return ESock::CConnectionFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
289 static_cast<const ESock::CConnectionProviderBase*>(aFactoryObject) : NULL; |
|
290 } |
|
291 #endif |
|
292 |
|
293 }//namespace Factories |
|
294 |
|
295 #endif // __SS_CONNPROV_H__ |
|
296 |
|
297 |
|
298 |