|
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_PROTFLOW_H_INCLUDED_) |
|
22 #define SS_PROTFLOW_H_INCLUDED_ |
|
23 |
|
24 #include <e32def.h> |
|
25 #include <e32base.h> |
|
26 #include <ss_fact.h> |
|
27 #include <comms-infras/ss_fact_internal.h> |
|
28 |
|
29 /***********************************************************************************/ |
|
30 // ProtocolIntf related classes |
|
31 |
|
32 namespace ESock |
|
33 { |
|
34 class CConnectionProviderBase; |
|
35 |
|
36 |
|
37 class CProtocolIntfFactoryBase; |
|
38 class CSubConnectionFlowBase; |
|
39 |
|
40 // ========================================================================================= |
|
41 |
|
42 class CProtocolIntfBase : public CBase, public Factories::AFactoryObject |
|
43 /** CProtocolIntf class |
|
44 |
|
45 @internalTechnology |
|
46 @released Since 9.3 */ |
|
47 { |
|
48 friend class CProtocolIntfFactoryBase; |
|
49 |
|
50 public: |
|
51 void FlowCreated(CSubConnectionFlowBase& aFlow); |
|
52 TBool FlowBeingDeleted(CSubConnectionFlowBase& aFlow); |
|
53 |
|
54 virtual void DoFlowCreated(CSubConnectionFlowBase& aFlow) = 0; |
|
55 virtual void DoFlowBeingDeleted(CSubConnectionFlowBase& aFlow) = 0; |
|
56 |
|
57 const Messages::TNodeId& ControlProviderId() const |
|
58 { |
|
59 return iCprId; |
|
60 } |
|
61 |
|
62 protected: |
|
63 IMPORT_C CProtocolIntfBase(CProtocolIntfFactoryBase& aFactory, const Messages::TNodeId& aCprId); |
|
64 IMPORT_C virtual ~CProtocolIntfBase(); |
|
65 |
|
66 private: |
|
67 Messages::TNodeId iCprId; // Connection Provider cookie |
|
68 TInt iFlowCount; // count of Flows associated with this ProtocolIntf |
|
69 }; |
|
70 |
|
71 class CProtocolIntfFactoryBase; |
|
72 |
|
73 // ========================================================================================= |
|
74 |
|
75 class CProtocolIntfFactoryContainer : public CCommsFactoryContainer |
|
76 /** Container for protocol2 factories |
|
77 |
|
78 @internalTechnology |
|
79 @released Since 9.3 */ |
|
80 { |
|
81 #ifdef __X86GCC__ |
|
82 protected: |
|
83 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
84 // functions to do the cast. |
|
85 friend CProtocolIntfBase* __x86gcc_protocol_intf_base_cast(Factories::AFactoryObject* aFactoryObject); |
|
86 friend const CProtocolIntfBase* __x86gcc_protocol_intf_base_cast(const Factories::AFactoryObject* aFactoryObject); |
|
87 |
|
88 enum |
|
89 { |
|
90 EId = EProtocolIntfFactoryContainer |
|
91 }; |
|
92 #elif defined(__GCCXML__) |
|
93 public: |
|
94 enum |
|
95 { |
|
96 EId = EProtocolIntfFactoryContainer |
|
97 }; |
|
98 #else |
|
99 protected: |
|
100 friend CProtocolIntfBase* Factories::factoryobject_cast<CProtocolIntfBase>(Factories::AFactoryObject* aFactoryObject); |
|
101 friend const CProtocolIntfBase* Factories::factoryobject_cast<const CProtocolIntfBase>(const Factories::AFactoryObject* aFactoryObject); |
|
102 enum |
|
103 { |
|
104 EId = EProtocolIntfFactoryContainer |
|
105 }; |
|
106 #endif |
|
107 |
|
108 public: |
|
109 static CProtocolIntfFactoryContainer* NewL(); |
|
110 IMPORT_C CProtocolIntfFactoryBase* FindOrCreateFactoryL(TUid aFactoryUid); |
|
111 IMPORT_C CProtocolIntfBase* FindOrCreateProtocolIntfL(TUid aFactoryId, TFactoryQueryBase& aQuery); |
|
112 ~CProtocolIntfFactoryContainer(); |
|
113 |
|
114 protected: |
|
115 CProtocolIntfFactoryContainer(); |
|
116 }; |
|
117 |
|
118 // ========================================================================================= |
|
119 |
|
120 class CProtocolIntfFactoryBase : public Factories::CFactoryBase |
|
121 /** Base class for all ProtocolIntf factories. |
|
122 |
|
123 @internalTechnology |
|
124 @released Since 9.3 */ |
|
125 { |
|
126 public: |
|
127 IMPORT_C CProtocolIntfBase* FindOrCreateProtocolIntfL(TFactoryQueryBase& aQuery); |
|
128 IMPORT_C CProtocolIntfBase* FindProtocolIntf(TFactoryQueryBase& aQuery); |
|
129 IMPORT_C CProtocolIntfBase* CreateProtocolIntfL(TFactoryQueryBase& aQuery); |
|
130 |
|
131 protected: |
|
132 IMPORT_C CProtocolIntfFactoryBase(TUid aFactoryId, CProtocolIntfFactoryContainer& aParentContainer); |
|
133 |
|
134 /** Override this to provide your own implementation for creating a flow |
|
135 |
|
136 @param aSubConnectionProviderBase The sub-connection provider for the flow to be attached to could be NULL |
|
137 meaning that sub-connection is yet be found(selected). |
|
138 Until than all calls are KErrNotReady except JoinL |
|
139 @param aSubConnType The creation type */ |
|
140 virtual CProtocolIntfBase* DoCreateProtocolIntfL(TFactoryQueryBase& aQuery) =0; |
|
141 }; |
|
142 |
|
143 |
|
144 #ifdef __X86GCC__ |
|
145 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
146 // functions to do the cast. |
|
147 inline CProtocolIntfBase* __x86gcc_protocol_intf_base_cast(Factories::AFactoryObject* aFactoryObject) |
|
148 { |
|
149 return ESock::CProtocolIntfFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
150 static_cast<ESock::CProtocolIntfBase*>(aFactoryObject) : NULL; |
|
151 } |
|
152 |
|
153 inline const CProtocolIntfBase* __x86gcc_protocol_intf_base_cast(const Factories::AFactoryObject* aFactoryObject) |
|
154 { |
|
155 return ESock::CProtocolIntfFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
156 static_cast<const ESock::CProtocolIntfBase*>(aFactoryObject) : NULL; |
|
157 } |
|
158 #endif |
|
159 } // namespace ESock |
|
160 |
|
161 namespace Factories |
|
162 { |
|
163 |
|
164 #ifdef __X86GCC__ |
|
165 // gcc-mingw does not support declaring friends from different namespaces so we define proxy |
|
166 // functions to do the cast. |
|
167 template<> |
|
168 inline ESock::CProtocolIntfBase* factoryobject_cast<ESock::CProtocolIntfBase>(Factories::AFactoryObject* aFactoryObject) |
|
169 { |
|
170 return ESock::__x86gcc_protocol_intf_base_cast(aFactoryObject); |
|
171 } |
|
172 |
|
173 template<> |
|
174 inline const ESock::CProtocolIntfBase* factoryobject_cast<const ESock::CProtocolIntfBase>(const Factories::AFactoryObject* aFactoryObject) |
|
175 { |
|
176 return ESock::__x86gcc_protocol_intf_base_cast(aFactoryObject); |
|
177 } |
|
178 #else |
|
179 // RVCT does not allow the specialisation of template functions in a different namespace from the original |
|
180 // so we declare them in the Factories namespace. |
|
181 template<> |
|
182 inline ESock::CProtocolIntfBase* factoryobject_cast<ESock::CProtocolIntfBase>(Factories::AFactoryObject* aFactoryObject) |
|
183 { |
|
184 return ESock::CProtocolIntfFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
185 static_cast<ESock::CProtocolIntfBase*>(aFactoryObject) : NULL; |
|
186 } |
|
187 |
|
188 template<> |
|
189 inline const ESock::CProtocolIntfBase* factoryobject_cast<const ESock::CProtocolIntfBase>(const Factories::AFactoryObject* aFactoryObject) |
|
190 { |
|
191 return ESock::CProtocolIntfFactoryContainer::EId == static_cast<ESock::CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId? |
|
192 static_cast<const ESock::CProtocolIntfBase*>(aFactoryObject) : NULL; |
|
193 } |
|
194 #endif |
|
195 |
|
196 } // namespace Factories |
|
197 |
|
198 #endif // SS_PROTFLOW_H_INCLUDED_ |
|
199 |