|
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 // Reference (empty) implementation file for a Connection Provider |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "ReferenceCPR_connProv.h" |
|
24 |
|
25 _LIT(KPanicReferenceCPRText,"Reference CPR not filled in properly"); |
|
26 |
|
27 #ifdef _DEBUG |
|
28 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
29 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
30 _LIT(KSpecAssert_RefCprConProv, "RefCprConProv"); |
|
31 #endif |
|
32 |
|
33 //-========================================================= |
|
34 // Custom methods |
|
35 //-========================================================= |
|
36 CReferenceConnectionProvider* CReferenceConnectionProvider::NewL(CConnectionProviderFactoryBase& aFactory) |
|
37 { |
|
38 CReferenceConnectionProvider* p = new (ELeave) CReferenceConnectionProvider(aFactory); |
|
39 return p; |
|
40 } |
|
41 |
|
42 CReferenceConnectionProvider::CReferenceConnectionProvider(CConnectionProviderFactoryBase& aFactory) |
|
43 :CConnectionProviderBase(aFactory), |
|
44 iNextLayer(NULL) |
|
45 { |
|
46 __FLOG_OPEN(KReferenceLogTag1, KReferenceLogTag2); |
|
47 } |
|
48 |
|
49 CReferenceConnectionProvider::~CReferenceConnectionProvider() |
|
50 { |
|
51 __FLOG_CLOSE; |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 //-========================================================= |
|
57 // MConnectionControlClient methods |
|
58 //-========================================================= |
|
59 void CReferenceConnectionProvider::ConnectionGoingDown(CConnectionProviderBase& aConnProvider) |
|
60 { |
|
61 __FLOG_2(_L("CReferenceConnectionProvider %08x:\tConnectionGoingDown(aConnProvider %08x)"), this, &aConnProvider); |
|
62 if (&aConnProvider == iNextLayer) |
|
63 { |
|
64 iNextLayer = NULL; |
|
65 DeleteMeNow(); |
|
66 } |
|
67 } |
|
68 |
|
69 void CReferenceConnectionProvider::ProgressNotification(TInt aStage, TInt aError) |
|
70 { |
|
71 __FLOG_3(_L("CReferenceConnectionProvider %08x:\tProgressNotification(aStage %d aError %d)"), this, aStage, aError); |
|
72 TInt max = iControlClients.Count(); |
|
73 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
74 { |
|
75 iControlClients[i]->ProgressNotification(aStage, aError); |
|
76 } |
|
77 } |
|
78 |
|
79 void CReferenceConnectionProvider::ConnectionError(TInt aStage, TInt aError) |
|
80 { |
|
81 __FLOG_3(_L("CReferenceConnectionProvider %08x:\tConnectionError(aStage %d aError %d)"), this, aStage, aError); |
|
82 TInt max = iControlClients.Count(); |
|
83 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
84 { |
|
85 iControlClients[i]->ConnectionError(aStage, aError); |
|
86 } |
|
87 max = iDataClients.Count(); |
|
88 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
89 { |
|
90 iDataClients[i]->ConnectionError(aStage, aError); |
|
91 } |
|
92 } |
|
93 |
|
94 void CReferenceConnectionProvider::ServiceChangeNotification(TUint32 aId, const TDesC& aType) |
|
95 { |
|
96 __FLOG_3(_L("CReferenceConnectionProvider %08x:\tServiceChangeNotification(aId %u aType %s)"), this, aId, &aType); |
|
97 TInt max = iControlClients.Count(); |
|
98 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
99 { |
|
100 iControlClients[i]->ServiceChangeNotification(aId, aType); |
|
101 } |
|
102 } |
|
103 |
|
104 void CReferenceConnectionProvider::SubConnectionEvent(CSubConnectionProviderBase* aSubConnNextLayerProvider, const TSubConnectionEvent& aSubConnectionEvent) |
|
105 { |
|
106 TInt max = iControlClients.Count(); |
|
107 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
108 { |
|
109 iControlClients[i]->SubConnectionEvent(aSubConnNextLayerProvider, aSubConnectionEvent); |
|
110 } |
|
111 } |
|
112 |
|
113 void CReferenceConnectionProvider::LayerUp(TInt aError) |
|
114 { |
|
115 TInt max = iControlClients.Count(); |
|
116 for (TInt i = max - 1 ; i >= 0 ; --i) |
|
117 { |
|
118 iControlClients[i]->LayerUp(aError); |
|
119 } |
|
120 |
|
121 // broadcast the event to the data clients also, sideways |
|
122 max = iDataClients.Count(); |
|
123 for (TInt j = max - 1; j >= 0 ; --j) |
|
124 { |
|
125 iDataClients[j]->Notify(MConnectionDataClient::ENotifyLayerUp, this, aError, NULL); |
|
126 } |
|
127 } |
|
128 |
|
129 MConnectionControlClient::TCtlType CReferenceConnectionProvider::CtlType() const |
|
130 { |
|
131 return MConnectionControlClient::ENormal; |
|
132 } |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 //-========================================================= |
|
140 // CConnectionProviderBase methods |
|
141 //-========================================================= |
|
142 void CReferenceConnectionProvider::DoDataClientJoiningL(MConnectionDataClient& /*aDataClient*/) |
|
143 { |
|
144 __FLOG_2(_L("CReferenceConnectionProvider %08x:\tDoDataClientJoiningL number %d"), this, iDataClients.Count()); |
|
145 //TODO: fill up with handling code if applicable. |
|
146 } |
|
147 |
|
148 void CReferenceConnectionProvider::DoDataClientLeaving(MConnectionDataClient& /*aDataClient*/) |
|
149 { |
|
150 __FLOG_2(_L("CReferenceConnectionProvider %08x:\tDoDataClientLeaving number %d"), this, iDataClients.Count()); |
|
151 //TODO: fill up with handling code if applicable. |
|
152 } |
|
153 |
|
154 void CReferenceConnectionProvider::DoControlClientJoiningL(MConnectionControlClient& /*aControlClient*/) |
|
155 { |
|
156 __FLOG_2(_L("CReferenceConnectionProvider %08x:\tDoControlClientJoiningL number %d"), this, iControlClients.Count()); |
|
157 //TODO: fill up with handling code if applicable. |
|
158 } |
|
159 |
|
160 void CReferenceConnectionProvider::DoControlClientLeaving(MConnectionControlClient& /*aControlClient*/) |
|
161 { |
|
162 __FLOG_2(_L("CReferenceConnectionProvider %08x:\tDoControlClientLeaving number %d"), this, iControlClients.Count()); |
|
163 //TODO: fill up with handling code if applicable. |
|
164 } |
|
165 |
|
166 void CReferenceConnectionProvider::DoStartL(Meta::SMetaData& aParams, const RMessagePtr2* aMessage) |
|
167 { |
|
168 //TODO: start this connection |
|
169 if (NULL != iNextLayer) |
|
170 { |
|
171 iNextLayer->StartL(aParams, aMessage); |
|
172 } |
|
173 } |
|
174 |
|
175 TInt CReferenceConnectionProvider::DoStop(TInt aError, const RMessagePtr2* aMessage) |
|
176 { |
|
177 if (NULL != iNextLayer) |
|
178 { |
|
179 //The next layer present. We'll now stop it here and anticipate ConnectionGoingDown() called on 'this' |
|
180 //when indeed, the connection is stopped. |
|
181 return iNextLayer->Stop(aError, aMessage); |
|
182 } |
|
183 else |
|
184 { |
|
185 //No next layer present, we're just need to delete this connection to complete the Stop message. |
|
186 DeleteMeNow(); |
|
187 } |
|
188 return KErrNotReady; |
|
189 } |
|
190 |
|
191 void CReferenceConnectionProvider::DoProgressL(Meta::SMetaData& aBuffer) const |
|
192 { |
|
193 //TODO: update the progress info. |
|
194 if (NULL != iNextLayer) |
|
195 { |
|
196 iNextLayer->ProgressL(aBuffer); |
|
197 } |
|
198 } |
|
199 |
|
200 void CReferenceConnectionProvider::DoLastProgressError(Meta::SMetaData& aBuffer) |
|
201 { |
|
202 //TODO: return the last error actually ocurred. |
|
203 if (NULL != iNextLayer) |
|
204 { |
|
205 return iNextLayer->LastProgressError(aBuffer); |
|
206 } |
|
207 } |
|
208 |
|
209 void CReferenceConnectionProvider::DoRequestServiceChangeNotificationL() |
|
210 { |
|
211 if (NULL != iNextLayer) |
|
212 { |
|
213 iNextLayer->RequestServiceChangeNotificationL(); |
|
214 } |
|
215 } |
|
216 |
|
217 void CReferenceConnectionProvider::DoCancelServiceChangeNotification() |
|
218 { |
|
219 if (NULL != iNextLayer) |
|
220 { |
|
221 iNextLayer->CancelServiceChangeNotification(); |
|
222 } |
|
223 } |
|
224 |
|
225 void CReferenceConnectionProvider::DoControlL(TUint aOptionLevel, TUint aOptionName, Meta::SMetaData& aOption, const RMessagePtr2* aMessage) |
|
226 { |
|
227 if (NULL != iNextLayer) |
|
228 { |
|
229 return iNextLayer->ControlL(aOptionLevel, aOptionName, aOption, aMessage); |
|
230 } |
|
231 } |
|
232 |
|
233 TInt CReferenceConnectionProvider::DoEnumerateSubConnectionsL(TUint& /*aCount*/) |
|
234 { |
|
235 return KErrNotReady; |
|
236 //TODO: fill up aCount with the number of subconnections active. |
|
237 } |
|
238 |
|
239 TUint CReferenceConnectionProvider::DoEnumerateClientsL(HBufC8*& aClientInfoBuffer, TEnumClients aClientType) |
|
240 /** |
|
241 Returns information about the clients of this Interface |
|
242 |
|
243 @param aCount on return contains the number of clients using this Interface |
|
244 @param aClientInfoBuffer on return contains a TPckg<> containing information about each client |
|
245 @exception leaves with KErrNoMemory if memory allocation fails |
|
246 */ |
|
247 { |
|
248 const TInt KInfoBufMaxLength = 1024; //is this large enough? |
|
249 TBuf8<KInfoBufMaxLength> infoBuf; |
|
250 |
|
251 TUint count = 0; |
|
252 STypeId tid(KConnectionClientExtUid,EConnectionClientDesc); |
|
253 TInt max = iControlClients.Count(); |
|
254 for ( TInt n = 0; n < max; n++ ) |
|
255 { |
|
256 MConnectionClientDesc* intf = reinterpret_cast<MConnectionClientDesc*>(iControlClients[n]->FetchInterfaceInstanceL(*this,tid)); |
|
257 if ( intf ) |
|
258 { |
|
259 TConnectionProcessInfo cinfo; |
|
260 cinfo.GetInfoL(aClientType, count, *intf, infoBuf); |
|
261 } |
|
262 } |
|
263 STypeId tid2(KConnectionClientExtUid,EConnectionEnumerateClients); |
|
264 max = iDataClients.Count(); |
|
265 for ( TInt n = 0; n < max; n++ ) |
|
266 { |
|
267 MConnectionEnumerateClients* intf = reinterpret_cast<MConnectionEnumerateClients*>(iDataClients[n]->FetchInterfaceInstanceL(*this,tid2)); |
|
268 if ( intf ) |
|
269 { |
|
270 intf->EnumerateClientsL(count, infoBuf, aClientType); |
|
271 } |
|
272 } |
|
273 |
|
274 aClientInfoBuffer = infoBuf.AllocL(); |
|
275 return count; |
|
276 } |
|
277 |
|
278 void CReferenceConnectionProvider::DoConnectionControlActivityL( CConnectionProviderBase::TControlActivity /*aControlActivity*/, const Meta::SMetaData* /*aData*/, const RMessagePtr2* /*aMessage*/ ) |
|
279 { |
|
280 //TODO: |
|
281 } |
|
282 |
|
283 CConnectionSettings& CReferenceConnectionProvider::DoSettingsAccessL() |
|
284 { |
|
285 //TODO: If no lower layer, derive your own CConnectionSettings |
|
286 //class and return a reference to an instance of it here. |
|
287 if (NULL != iNextLayer) |
|
288 { |
|
289 return iNextLayer->SettingsAccessL(); |
|
290 } |
|
291 User::Panic(KPanicReferenceCPRText, KErrNotFound); |
|
292 |
|
293 CConnectionSettings* null = NULL; |
|
294 return *static_cast<CConnectionSettings*>(null); |
|
295 } |
|
296 |
|
297 TInt CReferenceConnectionProvider::DoAllSubConnectionNotificationEnable() |
|
298 { |
|
299 if (NULL != iNextLayer) |
|
300 { |
|
301 return iNextLayer->AllSubConnectionNotificationEnable(); |
|
302 } |
|
303 return KErrNotReady; |
|
304 } |
|
305 |
|
306 TInt CReferenceConnectionProvider::DoCancelAllSubConnectionNotification() |
|
307 { |
|
308 if (NULL != iNextLayer) |
|
309 { |
|
310 return iNextLayer->CancelAllSubConnectionNotification(); |
|
311 } |
|
312 return KErrNotReady; |
|
313 } |
|
314 |
|
315 void CReferenceConnectionProvider::DoSendIoctlMessageL(const RMessage2& aMessage) |
|
316 { |
|
317 if (NULL != iNextLayer) |
|
318 { |
|
319 iNextLayer->SendIoctlMessageL(aMessage); |
|
320 } |
|
321 } |
|
322 |
|
323 void CReferenceConnectionProvider::DoSendCancelIoctl() |
|
324 { |
|
325 if (NULL != iNextLayer) |
|
326 { |
|
327 iNextLayer->SendCancelIoctl(); |
|
328 } |
|
329 } |
|
330 |
|
331 TInt CReferenceConnectionProvider::DoCanDoSubConnection(RSubConnection::TSubConnType /*aSubConnType*/) const |
|
332 { |
|
333 return ETrue; |
|
334 } |
|
335 |
|
336 void CReferenceConnectionProvider::DoJoinNextLayerL(CConnectionProviderBase* aNextLayer) |
|
337 { |
|
338 __ASSERT_DEBUG(( !iNextLayer && aNextLayer), User::Panic(KSpecAssert_RefCprConProv, 1)); |
|
339 iNextLayer = aNextLayer; |
|
340 SetConnectionInfo(iNextLayer->ConnectionInfo()); |
|
341 // join ourselves as a connection control client to the lower provider |
|
342 iNextLayer->JoinL(*this); |
|
343 } |
|
344 |
|
345 CConnectionProviderBase* CReferenceConnectionProvider::DoNextLayer() const |
|
346 { |
|
347 return iNextLayer; |
|
348 } |
|
349 |
|
350 |