|
1 // Copyright (c) 2004-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_SUBCONNFLOW_H__) |
|
22 #define __SS_SUBCONNFLOW_H__ |
|
23 |
|
24 #include <e32def.h> |
|
25 #include <es_sock.h> |
|
26 #include <comms-infras/ss_subconnprov.h> |
|
27 #include <comms-infras/ss_nodeinterfaces.h> |
|
28 |
|
29 class TSockAddr; |
|
30 class CPlayer; |
|
31 |
|
32 namespace ESock |
|
33 { |
|
34 class CConnectionProviderBase; |
|
35 class CSubConnectionProviderBase; |
|
36 class CSubConnectionFlowFactoryBase; |
|
37 class CSubConnectionFlowBase; |
|
38 |
|
39 // ========================================================================================= |
|
40 |
|
41 class CSubConnectionFlowFactoryContainer : public CCommsFactoryContainer |
|
42 /** Container for sub-connection flow factories |
|
43 |
|
44 @internalTechnology |
|
45 @released Since 9.2 */ |
|
46 { |
|
47 #ifdef __X86GCC__ |
|
48 protected: |
|
49 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
50 // functions to do the cast. |
|
51 friend CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(Factories::AFactoryObject* aFactoryObject); |
|
52 friend const CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(const Factories::AFactoryObject* aFactoryObject); |
|
53 |
|
54 enum |
|
55 { |
|
56 EId = ESubConnectionFlowFactoryContainer |
|
57 }; |
|
58 #elif defined(__GCCXML__) |
|
59 public: |
|
60 enum |
|
61 { |
|
62 EId = ESubConnectionFlowFactoryContainer |
|
63 }; |
|
64 #else |
|
65 protected: |
|
66 friend CSubConnectionFlowBase* Factories::factoryobject_cast<CSubConnectionFlowBase>(Factories::AFactoryObject* aFactoryObject); |
|
67 friend const CSubConnectionFlowBase* Factories::factoryobject_cast<const CSubConnectionFlowBase>(const Factories::AFactoryObject* aFactoryObject); |
|
68 enum |
|
69 { |
|
70 EId = ESubConnectionFlowFactoryContainer |
|
71 }; |
|
72 #endif |
|
73 |
|
74 public: |
|
75 static CSubConnectionFlowFactoryContainer* NewL(); |
|
76 ~CSubConnectionFlowFactoryContainer(); |
|
77 |
|
78 protected: |
|
79 CSubConnectionFlowFactoryContainer(); |
|
80 virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
|
81 |
|
82 }; |
|
83 |
|
84 const TInt KSubConnectionFlowFactoryInterfaceUid = 0x10281C33; |
|
85 |
|
86 class CSubConnectionProviderBase; |
|
87 class CProtocolIntfFactoryBase; |
|
88 class CProtocolIntfBase; |
|
89 class CProtocolIntfFactoryContainer; |
|
90 |
|
91 // ========================================================================================= |
|
92 |
|
93 class CSubConnectionFlowFactoryBase : public CCommsFactoryBase |
|
94 /** Base class for all flow factories. Specifies the interface |
|
95 that all flow factories must implement. It also providers the |
|
96 ECOM framework (via CCommsFactoryBase) to load flow factories |
|
97 from other Dynamic Linked Libraries. |
|
98 |
|
99 @internalTechnology |
|
100 @released Since 9.2 */ |
|
101 { |
|
102 friend class CProtocolIntfFactoryContainer; |
|
103 friend class CSubConnectionFlowFactoryContainer; |
|
104 public: |
|
105 IMPORT_C virtual ~CSubConnectionFlowFactoryBase(); |
|
106 |
|
107 |
|
108 /** Obtain protocol description of the flow - caller takes custody |
|
109 @param aProtocol Protocol id of the flow type for which a description is being requested. |
|
110 */ |
|
111 IMPORT_C TServerProtocolDesc* CreateFlowDescriptionL(TInt aProtocol); |
|
112 |
|
113 protected: |
|
114 IMPORT_C CSubConnectionFlowFactoryBase(TUid aFactoryId, CSubConnectionFlowFactoryContainer& aParentContainer); |
|
115 |
|
116 /** Override this to provide your own implementation for creating a flow |
|
117 |
|
118 @param aSubConnectionProviderBase The sub-connection provider for the flow to be attached to could be NULL |
|
119 meaning that sub-connection is yet be found(selected). |
|
120 Until than all calls are KErrNotReady except JoinL |
|
121 @param aSubConnType The creation type */ |
|
122 IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery); |
|
123 virtual CSubConnectionFlowBase* DoCreateFlowL(CProtocolIntfBase* aProtocolIntf, TFactoryQueryBase& aQuery) =0; |
|
124 |
|
125 /** Override this to provide your own implementation of the ProtocolInft factory. |
|
126 |
|
127 @param aParentContainer The protocol factory container 'this' is expected to insert self to */ |
|
128 IMPORT_C virtual CProtocolIntfFactoryBase* CreateProtocolIntfFactoryL(CProtocolIntfFactoryContainer& aParentContainer); |
|
129 |
|
130 /** Override this to provide flow specific "protocol" description |
|
131 @param aProtocol Protocol id of the flow type for which a description is being requested. |
|
132 */ |
|
133 IMPORT_C virtual TServerProtocolDesc* DoCreateFlowDescriptionL(TInt aProtocol); |
|
134 }; |
|
135 |
|
136 // ========================================================================================= |
|
137 |
|
138 // ========================================================================================= |
|
139 class MFlowBinderControl; |
|
140 //!!!instance goes down when iSubConnection instance goes down => all clients of iSubConnection leave |
|
141 class CSubConnectionFlowBase : public CCommsProviderBase, |
|
142 public ACommsFactoryNodeId |
|
143 /** Base class specifying the interfaces required to implement a flow. |
|
144 Contains collections of sub connection control and data clients and defines operations on them |
|
145 Instance of the object dies when the coresponding instance of CSubConnectionProvider goes |
|
146 |
|
147 @internalTechnology |
|
148 @released Since 9.2 */ |
|
149 { |
|
150 friend class CSubConnectionFlowFactoryBase; |
|
151 friend class CSubConnectionFlowFactoryContainer; |
|
152 #ifdef __X86GCC__ |
|
153 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
154 // functions to do the cast. |
|
155 friend CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(Messages::ANode* aNode); |
|
156 friend CSubConnectionFlowBase& __x86gcc_subconnection_flow_base_cast(Messages::ANode& aNode); |
|
157 #elif !defined(__GCCXML__) |
|
158 friend CSubConnectionFlowBase* mcfnode_cast<CSubConnectionFlowBase>(Messages::ANode* aNode); |
|
159 friend CSubConnectionFlowBase& mcfnode_cast<CSubConnectionFlowBase>(Messages::ANode& aNode); |
|
160 #endif |
|
161 |
|
162 // Downcalls from clients |
|
163 public: |
|
164 IMPORT_C MFlowBinderControl* GetBinderControlL(); |
|
165 |
|
166 CSubConnectionFlowFactoryBase& Factory() const |
|
167 { |
|
168 return static_cast<CSubConnectionFlowFactoryBase&>(AFactoryObject::Factory()); |
|
169 } |
|
170 |
|
171 const Messages::RNodeInterface& ControlProvider() const |
|
172 { |
|
173 return iSubConnectionProvider; |
|
174 } |
|
175 |
|
176 /** Legacy flows have no permanent control plane, giving them more responsibility for the layer below |
|
177 */ |
|
178 TBool HasControlPlane() const |
|
179 { |
|
180 return iSubConnectionProvider.IsOpen(); |
|
181 } |
|
182 |
|
183 protected: |
|
184 IMPORT_C CSubConnectionFlowBase(CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, |
|
185 CProtocolIntfBase* aProtocolIntf); |
|
186 |
|
187 // Don't allow clients to invoke the destructor. |
|
188 // (Only the CCommsFactoryBase should do this) |
|
189 IMPORT_C virtual ~CSubConnectionFlowBase(); |
|
190 |
|
191 virtual MFlowBinderControl* DoGetBinderControlL() = 0; |
|
192 IMPORT_C void DeleteThisFlow(); |
|
193 IMPORT_C CProtocolIntfBase* ProtocolIntf() const; |
|
194 |
|
195 |
|
196 protected: |
|
197 IMPORT_C virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
|
198 IMPORT_C virtual NetInterfaces::TInterfaceControl* FetchNodeInterfaceControlL(TInt aInterfaceId); |
|
199 IMPORT_C void SubConnectionGoingDown(); |
|
200 |
|
201 protected: |
|
202 |
|
203 Messages::RNodeInterface iSubConnectionProvider; |
|
204 Messages::RRequestOriginator iLastRequestOriginator; |
|
205 CProtocolIntfBase* iProtocolIntf; |
|
206 }; |
|
207 |
|
208 #ifdef __X86GCC__ |
|
209 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
210 // functions to do the cast. |
|
211 inline CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(Messages::ANode* aNode) |
|
212 { |
|
213 return static_cast<CSubConnectionFlowBase*>(aNode); |
|
214 } |
|
215 |
|
216 inline CSubConnectionFlowBase& __x86gcc_subconnection_flow_base_cast(Messages::ANode& aNode) |
|
217 { |
|
218 return static_cast<CSubConnectionFlowBase&>(aNode); |
|
219 } |
|
220 |
|
221 inline CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(Factories::AFactoryObject* aFactoryObject) |
|
222 { |
|
223 return ESock::CSubConnectionFlowFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
224 static_cast<ESock::CSubConnectionFlowBase*>(aFactoryObject) : NULL; |
|
225 } |
|
226 |
|
227 inline const CSubConnectionFlowBase* __x86gcc_subconnection_flow_base_cast(const Factories::AFactoryObject* aFactoryObject) |
|
228 { |
|
229 return ESock::CSubConnectionFlowFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
230 static_cast<const ESock::CSubConnectionFlowBase*>(aFactoryObject) : NULL; |
|
231 } |
|
232 #endif |
|
233 //========================================================================================== |
|
234 } //namespace ESock |
|
235 |
|
236 |
|
237 #ifdef __X86GCC__ |
|
238 namespace Messages |
|
239 { |
|
240 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
241 // functions to do the cast. |
|
242 template <> |
|
243 inline ESock::CSubConnectionFlowBase* mnode_cast<ESock::CSubConnectionFlowBase>(Messages::ANode* aNode) |
|
244 { |
|
245 return ESock::__x86gcc_subconnection_flow_base_cast(aNode); |
|
246 } |
|
247 |
|
248 template <> |
|
249 inline ESock::CSubConnectionFlowBase& mnode_cast<ESock::CSubConnectionFlowBase>(Messages::ANode& aNode) |
|
250 { |
|
251 return ESock::__x86gcc_subconnection_flow_base_cast(aNode); |
|
252 } |
|
253 } |
|
254 #endif |
|
255 |
|
256 |
|
257 namespace Factories |
|
258 { |
|
259 |
|
260 #ifdef __X86GCC__ |
|
261 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
262 // functions to do the cast. |
|
263 template<> |
|
264 inline ESock::CSubConnectionFlowBase* factoryobject_cast<ESock::CSubConnectionFlowBase>(Factories::AFactoryObject* aFactoryObject) |
|
265 { |
|
266 return ESock::__x86gcc_subconnection_flow_base_cast(aFactoryObject); |
|
267 } |
|
268 |
|
269 template<> |
|
270 inline const ESock::CSubConnectionFlowBase* factoryobject_cast<const ESock::CSubConnectionFlowBase>(const Factories::AFactoryObject* aFactoryObject) |
|
271 { |
|
272 return ESock::__x86gcc_subconnection_flow_base_cast(aFactoryObject); |
|
273 } |
|
274 #else |
|
275 // RVCT does not allow the specialisation of template functions in a different namespace from the original |
|
276 // so we declare them in the Factories namespace... |
|
277 template<> |
|
278 inline ESock::CSubConnectionFlowBase* factoryobject_cast<ESock::CSubConnectionFlowBase>(Factories::AFactoryObject* aFactoryObject) |
|
279 { |
|
280 return ESock::CSubConnectionFlowFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
281 static_cast<ESock::CSubConnectionFlowBase*>(aFactoryObject) : NULL; |
|
282 } |
|
283 |
|
284 template<> |
|
285 inline const ESock::CSubConnectionFlowBase* factoryobject_cast<const ESock::CSubConnectionFlowBase>(const Factories::AFactoryObject* aFactoryObject) |
|
286 { |
|
287 return ESock::CSubConnectionFlowFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
288 static_cast<const ESock::CSubConnectionFlowBase*>(aFactoryObject) : NULL; |
|
289 } |
|
290 #endif |
|
291 |
|
292 } //namespace Factories |
|
293 |
|
294 #endif // __SS_SUBCONNFLOW_H__ |
|
295 |
|
296 |
|
297 |