|
1 // Copyright (c) 2006-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 // Dummy PR Factories class definition. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <ecom/implementationproxy.h> |
|
24 #include <in_sock.h> |
|
25 #include <ss_glob.h> |
|
26 #include <comms-infras/ss_log.h> |
|
27 #include "dummypr_factory.h" |
|
28 #include "dummypr_subconnprov.h" |
|
29 #include "dummypr_connprov.h" |
|
30 #include "dummypr_metaconnprov.h" |
|
31 #include "dummypr_tiermanager.h" |
|
32 #include "dummypr_network_flow.h" |
|
33 |
|
34 #include <comms-infras/ss_msgintercept.h> |
|
35 |
|
36 #ifdef __CFLOG_ACTIVE |
|
37 #define KDummyTierManagerTag KESockTierTag |
|
38 #define KDummyCPRTag KESockConnectionTag |
|
39 #define KDummySCPRTag KESockSubConnectionTag |
|
40 #define KDummyExtendedSCPRTag KESockSubConnectionTag |
|
41 #define KDummyMCPRTag KESockMetaConnectionTag |
|
42 #endif |
|
43 |
|
44 using namespace ESock; |
|
45 |
|
46 |
|
47 const TInt KProtocolInetDummy = 253; |
|
48 |
|
49 const TInt KDummyMajorVersionNumber = 0; |
|
50 const TInt KDummyMinorVersionNumber = 1; |
|
51 const TInt KDummyBuildVersionNumber = 1; |
|
52 |
|
53 |
|
54 //-========================================================= |
|
55 // |
|
56 // ECOM data |
|
57 // |
|
58 //-========================================================= |
|
59 const TImplementationProxy ImplementationTable[] = |
|
60 { |
|
61 IMPLEMENTATION_PROXY_ENTRY(CDummyTierManagerFactory::iUid, CDummyTierManagerFactory::NewL), |
|
62 IMPLEMENTATION_PROXY_ENTRY(CDummyMetaConnectionProviderFactory::iUid, CDummyMetaConnectionProviderFactory::NewL), |
|
63 IMPLEMENTATION_PROXY_ENTRY(CDummyConnectionProviderFactory::iUid, CDummyConnectionProviderFactory::NewL), |
|
64 IMPLEMENTATION_PROXY_ENTRY(CDummyHangingConnectionProviderFactory::iUid, CDummyHangingConnectionProviderFactory::NewL), |
|
65 IMPLEMENTATION_PROXY_ENTRY(CDummySubConnectionProviderFactory::iUid, CDummySubConnectionProviderFactory::NewL), |
|
66 IMPLEMENTATION_PROXY_ENTRY(CDummyExtendedSubConnectionProviderFactory::iUid, CDummyExtendedSubConnectionProviderFactory::NewL), |
|
67 |
|
68 // Flow and flow description |
|
69 IMPLEMENTATION_PROXY_ENTRY(CDummyNetworkFlowFactory::iUid, CDummyNetworkFlowFactory::NewL), |
|
70 }; |
|
71 |
|
72 /** |
|
73 ECOM Implementation Factory |
|
74 */ |
|
75 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
76 { |
|
77 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
78 return ImplementationTable; |
|
79 } |
|
80 |
|
81 //-========================================================= |
|
82 // |
|
83 // CDummyTierManagerFactory methods |
|
84 // |
|
85 //-========================================================= |
|
86 CDummyTierManagerFactory* CDummyTierManagerFactory::NewL(TAny* aParentContainer) |
|
87 { |
|
88 return new (ELeave) CDummyTierManagerFactory(TUid::Uid(CDummyTierManagerFactory::iUid),TUid::Uid(CDummyTierManagerFactory::iUid),*(reinterpret_cast<CTierManagerFactoryContainer*>(aParentContainer))); |
|
89 } |
|
90 |
|
91 CDummyTierManagerFactory::CDummyTierManagerFactory(TUid aTierTypeId,TUid aFactoryUid, CTierManagerFactoryContainer& aParentContainer) |
|
92 : CTierManagerFactoryBase(aTierTypeId,aFactoryUid,aParentContainer) |
|
93 { |
|
94 //LOG_NODE_CREATE(KDummyTierManagerTag, CDummyTierManagerFactory); |
|
95 } |
|
96 |
|
97 ESock::ACommsFactoryNodeId* CDummyTierManagerFactory::DoCreateObjectL(TFactoryQueryBase& /* aQuery */) |
|
98 { |
|
99 return CDummyTierManager::NewL(*this); |
|
100 } |
|
101 |
|
102 //-========================================================= |
|
103 // |
|
104 // CDummyMetaConnectionProviderFactory implementation |
|
105 // |
|
106 //-========================================================= |
|
107 CDummyMetaConnectionProviderFactory* CDummyMetaConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
108 { |
|
109 return new (ELeave) CDummyMetaConnectionProviderFactory(TUid::Uid(CDummyMetaConnectionProviderFactory::iUid), *(reinterpret_cast<CMetaConnectionFactoryContainer*>(aParentContainer))); |
|
110 } |
|
111 |
|
112 CDummyMetaConnectionProviderFactory::CDummyMetaConnectionProviderFactory(TUid aFactoryUid, CMetaConnectionFactoryContainer& aParentContainer) |
|
113 : CMetaConnectionProviderFactoryBase(aFactoryUid,aParentContainer) |
|
114 { |
|
115 //LOG_NODE_CREATE(KDummyMCPRTag, CDummyMetaConnectionProviderFactory); |
|
116 } |
|
117 |
|
118 ESock::ACommsFactoryNodeId* CDummyMetaConnectionProviderFactory::DoCreateObjectL(TFactoryQueryBase& aQuery) |
|
119 { |
|
120 const TMetaConnectionFactoryQuery& query = static_cast<const TMetaConnectionFactoryQuery&>(aQuery); |
|
121 return CDummyMetaConnectionProvider::NewL(*this,query.iProviderInfo); |
|
122 } |
|
123 |
|
124 //-========================================================= |
|
125 // |
|
126 // CDummyConnectionProviderFactory methods |
|
127 // |
|
128 //-========================================================= |
|
129 CDummyConnectionProviderFactory* CDummyConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
130 { |
|
131 return new (ELeave) CDummyConnectionProviderFactory(TUid::Uid(CDummyConnectionProviderFactory::iUid), *reinterpret_cast<ESock::CConnectionFactoryContainer*>(aParentContainer)); |
|
132 } |
|
133 |
|
134 CDummyConnectionProviderFactory::CDummyConnectionProviderFactory(TUid aFactoryId, ESock::CConnectionFactoryContainer& aParentContainer) |
|
135 : ESock::CConnectionProviderFactoryBase(aFactoryId, aParentContainer) |
|
136 { |
|
137 //LOG_NODE_CREATE(KDummyCPRTag, CDummyConnectionProviderFactory); |
|
138 } |
|
139 |
|
140 ACommsFactoryNodeId* CDummyConnectionProviderFactory::DoCreateObjectL(TFactoryQueryBase& /* aQuery */) |
|
141 { |
|
142 CConnectionProviderBase* provider = CDummyConnectionProvider::NewL(*this, CDummyConnectionProvider::EConnIncoming); |
|
143 |
|
144 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
145 |
|
146 return provider; |
|
147 } |
|
148 |
|
149 CDummyHangingConnectionProviderFactory* CDummyHangingConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
150 { |
|
151 return new (ELeave) CDummyHangingConnectionProviderFactory(TUid::Uid(CDummyHangingConnectionProviderFactory::iUid), *reinterpret_cast<ESock::CConnectionFactoryContainer*>(aParentContainer)); |
|
152 } |
|
153 |
|
154 CDummyHangingConnectionProviderFactory::CDummyHangingConnectionProviderFactory(TUid aFactoryId, ESock::CConnectionFactoryContainer& aParentContainer) |
|
155 : ESock::CConnectionProviderFactoryBase(aFactoryId, aParentContainer) |
|
156 { |
|
157 //LOG_NODE_CREATE(KDummyCPRTag, CDummyHangingConnectionProviderFactory); |
|
158 } |
|
159 |
|
160 ACommsFactoryNodeId* CDummyHangingConnectionProviderFactory::DoCreateObjectL(TFactoryQueryBase& /* aQuery */) |
|
161 { |
|
162 CConnectionProviderBase* provider = CDummyConnectionProvider::NewL(*this, CDummyConnectionProvider::EConnNoIncoming); |
|
163 |
|
164 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
165 |
|
166 return provider; |
|
167 } |
|
168 |
|
169 //-========================================================= |
|
170 // |
|
171 // CDummySubConnectionProviderFactory methods |
|
172 // |
|
173 //-========================================================= |
|
174 CDummySubConnectionProviderFactory* CDummySubConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
175 { |
|
176 return new (ELeave) CDummySubConnectionProviderFactory(TUid::Uid(CDummySubConnectionProviderFactory::iUid), |
|
177 *reinterpret_cast<ESock::CSubConnectionFactoryContainer*>(aParentContainer)); |
|
178 } |
|
179 |
|
180 CDummySubConnectionProviderFactory::CDummySubConnectionProviderFactory(TUid aFactoryId, ESock::CSubConnectionFactoryContainer& aParentContainer) |
|
181 : CSubConnectionProviderFactoryBase(aFactoryId, aParentContainer) |
|
182 { |
|
183 //LOG_NODE_CREATE(KDummySCPRTag, CDummySubConnectionProviderFactory); |
|
184 } |
|
185 |
|
186 ACommsFactoryNodeId* CDummySubConnectionProviderFactory::DoCreateObjectL(TFactoryQueryBase& aQuery) |
|
187 { |
|
188 const TDefaultSCPRFactoryQuery& query = static_cast<const TDefaultSCPRFactoryQuery&>(aQuery); |
|
189 CSubConnectionProviderBase* provider = NULL; |
|
190 if (query.iSCPRType == RSubConnection::EAttachToDefault) |
|
191 { |
|
192 provider = CDummySubConnectionProvider::NewL(*this); |
|
193 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
194 } |
|
195 else if (query.iSCPRType == RSubConnection::ECreateNew) |
|
196 { |
|
197 provider = CDummySubConnectionProvider::NewL(*this); |
|
198 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
199 } |
|
200 else |
|
201 { |
|
202 User::Leave(KErrNotSupported); |
|
203 } |
|
204 return provider; |
|
205 } |
|
206 |
|
207 //-========================================================= |
|
208 // |
|
209 // CDummyExtendedSubConnectionProviderFactory methods |
|
210 // |
|
211 //-========================================================= |
|
212 namespace ESock |
|
213 { |
|
214 CDummyExtendedSubConnectionProviderFactory* CDummyExtendedSubConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
215 { |
|
216 return new (ELeave) CDummyExtendedSubConnectionProviderFactory(TUid::Uid(CDummyExtendedSubConnectionProviderFactory::iUid), |
|
217 *reinterpret_cast<ESock::CSubConnectionFactoryContainer*>(aParentContainer)); |
|
218 } |
|
219 |
|
220 CDummyExtendedSubConnectionProviderFactory::CDummyExtendedSubConnectionProviderFactory(TUid aFactoryId, ESock::CSubConnectionFactoryContainer& aParentContainer) |
|
221 : CSubConnectionProviderFactoryBase(aFactoryId, aParentContainer) |
|
222 { |
|
223 //LOG_NODE_CREATE(KDummyExtendedSCPRTag, CDummyExtendedSubConnectionProviderFactory); |
|
224 } |
|
225 |
|
226 ACommsFactoryNodeId* CDummyExtendedSubConnectionProviderFactory::DoCreateObjectL(TFactoryQueryBase& aQuery) |
|
227 { |
|
228 const TDefaultSCPRFactoryQuery& query = static_cast<const TDefaultSCPRFactoryQuery&>(aQuery); |
|
229 CSubConnectionProviderBase* provider = NULL; |
|
230 |
|
231 if ((query.iSCPRType == RSubConnection::EAttachToDefault) || (query.iSCPRType == RSubConnection::ECreateNew)) |
|
232 { |
|
233 provider = ESock::CDummyExtendedSubConnectionProvider::NewL(*this); |
|
234 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
235 } |
|
236 else |
|
237 { |
|
238 User::Leave(KErrNotSupported); |
|
239 } |
|
240 return provider; |
|
241 } |
|
242 } |
|
243 |
|
244 //-========================================================= |
|
245 // |
|
246 // CDummyNetworkFlowFactory methods |
|
247 // |
|
248 //-========================================================= |
|
249 namespace ESock |
|
250 { |
|
251 CDummyNetworkFlowFactory* CDummyNetworkFlowFactory::NewL(TAny* aConstructionParameters) |
|
252 { |
|
253 CDummyNetworkFlowFactory* fact = new (ELeave) CDummyNetworkFlowFactory( |
|
254 TUid::Uid(iUid), |
|
255 *(reinterpret_cast<CSubConnectionFlowFactoryContainer*>(aConstructionParameters))); |
|
256 return fact; |
|
257 } |
|
258 |
|
259 CDummyNetworkFlowFactory::CDummyNetworkFlowFactory(TUid aFactoryId, CSubConnectionFlowFactoryContainer& aParentContainer) |
|
260 : CSubConnectionFlowFactoryBase(aFactoryId, aParentContainer) |
|
261 { |
|
262 //LOG_NODE_CREATE(KESockDataFactTag, CDummyNetworkFlowFactory) |
|
263 } |
|
264 |
|
265 CDummyNetworkFlowFactory::~CDummyNetworkFlowFactory() |
|
266 { |
|
267 //LOG_NODE_DESTROY(KESockDataFactTag, CDummyNetworkFlowFactory) |
|
268 } |
|
269 |
|
270 CSubConnectionFlowBase* CDummyNetworkFlowFactory::DoCreateFlowL(CProtocolIntfBase* aProtocolIntf, TFactoryQueryBase& aQuery) |
|
271 { |
|
272 const TDefaultFlowFactoryQuery& query = static_cast<const TDefaultFlowFactoryQuery&>(aQuery); |
|
273 return CDummyNetworkFlow::NewL(*this, query.iSCprId, aProtocolIntf); |
|
274 } |
|
275 |
|
276 ACommsFactoryNodeId* CDummyNetworkFlowFactory::DoFindOrCreateObjectL(TFactoryQueryBase& aQuery) |
|
277 { |
|
278 const TDefaultFlowFactoryQuery& query = static_cast<const TDefaultFlowFactoryQuery&>(aQuery); |
|
279 if(query.iMessageId != TCFServiceProvider::TCommsBinderRequest::Id()) |
|
280 { |
|
281 //the factory only reacts to creation triggered by TCommsBinderRequest |
|
282 //otherwise it bails out - flow not needed for the stack setup. |
|
283 return NULL; |
|
284 } |
|
285 // Find or create the ProtocolIntf instance corresponding to the Flow. If there is no ProtocolIntf instance, then fail. |
|
286 TDefaultProtocolIntfFactoryQuery queryProto(query.iCprId); |
|
287 CProtocolIntfBase* protocolInterface = SockManGlobals::Get()->iProtocolIntfFactories->FindOrCreateProtocolIntfL(Uid(), queryProto); |
|
288 if (protocolInterface == NULL) |
|
289 { |
|
290 LOG( ESockLog::Printf(KESockDataFactTag, _L8("CDummyNetworkFlowFactory %08x:\tCreateFlowL(protocolId '%08x') Cannot find protocol interface, bailing out"), this, Uid()) ); |
|
291 User::Leave(KErrNotFound); |
|
292 } |
|
293 |
|
294 // The type of flow created is protocol id specific |
|
295 CSubConnectionFlowBase* flow = NULL; |
|
296 switch(query.iProtocolType) |
|
297 { |
|
298 case KProtocolInetDummy: |
|
299 flow = CDummyNetworkFlow::NewL(*this, query.iSCprId, protocolInterface); |
|
300 break; |
|
301 |
|
302 default: |
|
303 User::Leave(KErrNotFound); |
|
304 break; |
|
305 } |
|
306 |
|
307 LOG( ESockLog::Printf( |
|
308 KESockDataFactTag, |
|
309 _L8("CDummyNetworkFlowFactory %08x:\tCreateFlowL(protocolId '%08x'): flow %08x"), |
|
310 this, |
|
311 Uid(), |
|
312 &flow)); |
|
313 |
|
314 // The factory takes ultimate custody of the new flow |
|
315 CleanupStack::PushL(flow); |
|
316 AddManagedObjectL(*flow); |
|
317 CleanupStack::Pop(flow); |
|
318 |
|
319 return flow; |
|
320 } |
|
321 |
|
322 /** |
|
323 Description of the protocol this factory creates |
|
324 */ |
|
325 TServerProtocolDesc* CDummyNetworkFlowFactory::DoCreateFlowDescriptionL(TInt aProtocol) |
|
326 { |
|
327 TServerProtocolDesc* protocolDescription = new(ELeave) TServerProtocolDesc(); |
|
328 |
|
329 // Poached from udp and modified to represent an rtp like protocol |
|
330 switch(aProtocol) |
|
331 { |
|
332 case KProtocolInetDummy: |
|
333 protocolDescription->iName = KDummyProtocolName; |
|
334 protocolDescription->iAddrFamily = KAfInet; |
|
335 protocolDescription->iSockType = KSockDatagram; |
|
336 protocolDescription->iProtocol = KProtocolInetDummy; |
|
337 protocolDescription->iVersion = TVersion(KDummyMajorVersionNumber, |
|
338 KDummyMinorVersionNumber, |
|
339 KDummyBuildVersionNumber); |
|
340 protocolDescription->iByteOrder = EBigEndian; |
|
341 protocolDescription->iServiceInfo = KSIConnectionLess | KSIDatagram | |
|
342 KSIGracefulClose | KSIPeekData | |
|
343 KSIRequiresOwnerInfo; |
|
344 protocolDescription->iNamingServices = KNSNameResolution | KNSRequiresConnectionStartup; |
|
345 protocolDescription->iSecurity = KSocketNoSecurity; |
|
346 protocolDescription->iMessageSize = 65536-128; /*KSocketMessageSizeUndefined;*/ |
|
347 protocolDescription->iServiceTypeInfo = ESocketSupport | ETransport | |
|
348 EPreferMBufChains | ENeedMBufs | |
|
349 EUseCanSend; |
|
350 protocolDescription->iNumSockets = KUnlimitedSockets; |
|
351 break; |
|
352 |
|
353 default: |
|
354 User::Leave(KErrGeneral); |
|
355 break; |
|
356 } |
|
357 |
|
358 return protocolDescription; |
|
359 } |
|
360 } |
|
361 |