|
1 /* |
|
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CCCHServiceInfo implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cchserviceinfo.h" |
|
21 #include "cchsubserviceinfo.h" |
|
22 #include "cchserverbase.h" |
|
23 #include "cchpluginhandler.h" |
|
24 #include "cchrequeststorage.h" |
|
25 #include "cchspshandler.h" |
|
26 #include "cchservicehandler.h" |
|
27 #include "cchlogger.h" |
|
28 #include "cchpluginhandler.h" |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 // None |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 // None |
|
35 |
|
36 // CONSTANTS |
|
37 // None |
|
38 |
|
39 // MACROS |
|
40 // None |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 // None |
|
44 |
|
45 // MODULE DATA STRUCTURES |
|
46 // None |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 // None |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 // None |
|
53 |
|
54 // =========================== LOCAL FUNCTIONS =============================== |
|
55 |
|
56 // ============================ MEMBER FUNCTIONS ============================= |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CCCHServiceInfo::CCCHServiceInfo |
|
60 // C++ default constructor can NOT contain any code, that might leave. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CCCHServiceInfo::CCCHServiceInfo( CCCHServerBase& aServer ): |
|
64 iServer( aServer ), |
|
65 iReserved( ETrue ) |
|
66 { |
|
67 // No implementation required |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CCCHServiceInfo::NewL |
|
72 // Two-phased constructor. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CCCHServiceInfo* CCCHServiceInfo::NewL( CCCHServerBase& aServer ) |
|
76 { |
|
77 CCCHServiceInfo* self = CCCHServiceInfo::NewLC( aServer ); |
|
78 CleanupStack::Pop( self ); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CCCHServiceInfo::NewLC |
|
84 // Two-phased constructor. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CCCHServiceInfo* CCCHServiceInfo::NewLC( CCCHServerBase& aServer ) |
|
88 { |
|
89 CCCHServiceInfo* self = new (ELeave) CCCHServiceInfo( aServer ); |
|
90 CleanupStack::PushL( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // Destructor |
|
95 CCCHServiceInfo::~CCCHServiceInfo() |
|
96 { |
|
97 iSubservices.ResetAndDestroy(); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CCCHServiceInfo::GetServiceId |
|
102 // (other items were commented in a header). |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 TUint32 CCCHServiceInfo::GetServiceId() const |
|
106 { |
|
107 return iServiceId; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CCCHServiceInfo::SetServiceId |
|
112 // (other items were commented in a header). |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CCCHServiceInfo::SetServiceId( TUint32 aServiceId ) |
|
116 { |
|
117 iServiceId = aServiceId; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CCCHServiceInfo::GetName |
|
122 // (other items were commented in a header). |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 const TDesC CCCHServiceInfo::GetName() const |
|
126 { |
|
127 return iServiceName; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CCCHServiceInfo::SetName |
|
132 // (other items were commented in a header). |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CCCHServiceInfo::SetName( const TDesC& aName ) |
|
136 { |
|
137 iServiceName.Copy( aName ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CCCHServiceInfo::EnableL |
|
142 // (other items were commented in a header). |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CCCHServiceInfo::EnableL( |
|
146 const TCCHSubserviceType aServiceType, |
|
147 const TBool aConnectivityCheck, |
|
148 MCCHServiceNotifier* aNotifier ) |
|
149 { |
|
150 CCHLOGSTRING( "CCCHServiceInfo::EnableL: IN" ); |
|
151 CCHLOGSTRING2( "CCCHServiceInfo::EnableL: ServiceId = %d", iServiceId ); |
|
152 CCHLOGSTRING2( "CCCHServiceInfo::EnableL: iType %d", aServiceType ); |
|
153 CCHLOGSTRING2( "CCCHServiceInfo::EnableL: connectivitycheck %d", |
|
154 aConnectivityCheck ); |
|
155 |
|
156 RArray<TUid> uids; |
|
157 CleanupClosePushL( uids ); |
|
158 |
|
159 TUid pluginUid( KNullUid ); |
|
160 TBool found( EFalse ); |
|
161 TUint iapId( 0 ); |
|
162 |
|
163 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
164 { |
|
165 pluginUid = iSubservices[ i ]->GetPluginUid(); |
|
166 |
|
167 found = ( KErrNotFound != uids.Find( pluginUid ) ); |
|
168 |
|
169 if ( !found && pluginUid != KNullUid && |
|
170 ( ECCHUnknown == aServiceType || |
|
171 aServiceType == iSubservices[ i ]->Type() ) ) |
|
172 { |
|
173 uids.Append( pluginUid ); |
|
174 } |
|
175 } |
|
176 |
|
177 0 < uids.Count() ? iServer.PluginHandler().EnableServiceL( |
|
178 iServiceId, uids, aServiceType, aNotifier, iapId, aConnectivityCheck ) : |
|
179 User::Leave( KErrNotFound ); |
|
180 |
|
181 CleanupStack::PopAndDestroy( &uids ); |
|
182 |
|
183 // Update service table |
|
184 if ( ECCHUnknown != aServiceType ) |
|
185 { |
|
186 iServer.SPSHandler().SetLoadAtStartUpL( iServiceId, |
|
187 aServiceType, ETrue ); |
|
188 } |
|
189 else |
|
190 { |
|
191 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
192 { |
|
193 iServer.SPSHandler().SetLoadAtStartUpL( iServiceId, |
|
194 iSubservices[ i ]->Type(), ETrue ); |
|
195 } |
|
196 } |
|
197 CCHLOGSTRING( "CCCHServiceInfo::EnableL: OUT" ); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CCCHServiceInfo::DisableL |
|
202 // (other items were commented in a header). |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CCCHServiceInfo::DisableL( const TCCHSubserviceType aServiceType ) |
|
206 { |
|
207 CCHLOGSTRING( "CCCHServiceInfo::DisableL: IN" ); |
|
208 CCHLOGSTRING2( "CCCHServiceInfo::DisableL: ServiceId = %d", iServiceId ); |
|
209 CCHLOGSTRING2( "CCCHServiceInfo::DisableL: iType %d", aServiceType ); |
|
210 |
|
211 RArray<TUid> uids; |
|
212 CleanupClosePushL( uids ); |
|
213 |
|
214 TUid pluginUid( KNullUid ); |
|
215 TBool found( EFalse ); |
|
216 |
|
217 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
218 { |
|
219 pluginUid = iSubservices[ i ]->GetPluginUid(); |
|
220 |
|
221 found = ( KErrNotFound != uids.Find( pluginUid ) ); |
|
222 |
|
223 if ( !found && pluginUid != KNullUid && |
|
224 ( ECCHUnknown == aServiceType || |
|
225 aServiceType == iSubservices[ i ]->Type() ) ) |
|
226 { |
|
227 uids.Append( pluginUid ); |
|
228 } |
|
229 } |
|
230 |
|
231 0 < uids.Count() ? iServer.PluginHandler().DisableServiceL( |
|
232 iServiceId, uids, aServiceType ) : User::Leave( KErrNotFound ); |
|
233 |
|
234 CleanupStack::PopAndDestroy( &uids ); |
|
235 |
|
236 // Update service table |
|
237 if ( ECCHUnknown != aServiceType ) |
|
238 { |
|
239 iServer.SPSHandler().SetLoadAtStartUpL( iServiceId, |
|
240 aServiceType, EFalse ); |
|
241 } |
|
242 else |
|
243 { |
|
244 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
245 { |
|
246 iServer.SPSHandler().SetLoadAtStartUpL( iServiceId, |
|
247 iSubservices[ i ]->Type(), EFalse ); |
|
248 } |
|
249 } |
|
250 |
|
251 CCHLOGSTRING( "CCCHServiceInfo::DisableL: OUT" ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CCCHServiceInfo::SetConnectionInfoL |
|
256 // (other items were commented in a header). |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CCCHServiceInfo::SetConnectionInfoL( |
|
260 const TServiceConnectionInfo aServiceConnInfo ) |
|
261 { |
|
262 CCHLOGSTRING( "CCCHServiceInfo::SetConnectionInfoL: IN" ); |
|
263 |
|
264 RArray<TUid> uids; |
|
265 CleanupClosePushL( uids ); |
|
266 |
|
267 TUid pluginUid( KNullUid ); |
|
268 TBool found( EFalse ); |
|
269 |
|
270 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
271 { |
|
272 pluginUid = iSubservices[ i ]->GetPluginUid(); |
|
273 |
|
274 found = ( KErrNotFound != uids.Find( pluginUid ) ); |
|
275 |
|
276 if ( !found && pluginUid != KNullUid && |
|
277 ( ECCHUnknown == aServiceConnInfo.iServiceSelection.iType || |
|
278 aServiceConnInfo.iServiceSelection.iType == |
|
279 iSubservices[ i ]->Type() ) ) |
|
280 { |
|
281 uids.Append( pluginUid ); |
|
282 } |
|
283 // Set connection information to subservice |
|
284 if ( ECCHUnknown == aServiceConnInfo.iServiceSelection.iType || |
|
285 aServiceConnInfo.iServiceSelection.iType == |
|
286 iSubservices[ i ]->Type() ) |
|
287 { |
|
288 iSubservices[ i ]->SetIapId( aServiceConnInfo.iIapId ); |
|
289 iSubservices[ i ]->SetSNAPId( aServiceConnInfo.iSNAPId ); |
|
290 } |
|
291 } |
|
292 |
|
293 if ( 0 == uids.Count() ) |
|
294 { |
|
295 User::Leave( KErrNotFound ); |
|
296 } |
|
297 |
|
298 if ( !aServiceConnInfo.iIapId && aServiceConnInfo.iSNAPId ) |
|
299 { |
|
300 iServer.PluginHandler().SetSnapIdL( |
|
301 aServiceConnInfo.ServiceId(), uids, |
|
302 aServiceConnInfo.Type(), |
|
303 aServiceConnInfo.iSNAPId ); |
|
304 } |
|
305 else if ( aServiceConnInfo.iIapId && !aServiceConnInfo.iSNAPId ) |
|
306 { |
|
307 iServer.PluginHandler().SetIapIdL( |
|
308 aServiceConnInfo.ServiceId(), uids, |
|
309 aServiceConnInfo.Type(), |
|
310 aServiceConnInfo.iIapId ); |
|
311 } |
|
312 else if ( aServiceConnInfo.iIapId && aServiceConnInfo.iSNAPId ) |
|
313 { |
|
314 iServer.PluginHandler().SetIapIdL( |
|
315 aServiceConnInfo.ServiceId(), uids, |
|
316 aServiceConnInfo.Type(), |
|
317 aServiceConnInfo.iIapId ); |
|
318 iServer.PluginHandler().SetSnapIdL( |
|
319 aServiceConnInfo.ServiceId(), uids, |
|
320 aServiceConnInfo.Type(), |
|
321 aServiceConnInfo.iSNAPId ); |
|
322 } |
|
323 |
|
324 // username must not be empty. And check this field should be set |
|
325 if ( aServiceConnInfo.iServiceSelection.iParameter == ECchUsername && |
|
326 aServiceConnInfo.iUsername.Length() ) |
|
327 { |
|
328 iServer.PluginHandler().SetUsernameL( |
|
329 aServiceConnInfo.ServiceId(), uids, |
|
330 aServiceConnInfo.Type(), |
|
331 aServiceConnInfo.iUsername ); |
|
332 } |
|
333 |
|
334 // empty password is ok. And check this field should be set |
|
335 if ( aServiceConnInfo.iServiceSelection.iParameter == ECchPassword ) |
|
336 { |
|
337 iServer.PluginHandler().SetPasswordL( |
|
338 aServiceConnInfo.ServiceId(), uids, |
|
339 aServiceConnInfo.Type(), |
|
340 aServiceConnInfo.iPassword ); |
|
341 } |
|
342 |
|
343 if ( aServiceConnInfo.iServiceSelection.iParameter == ECchReserved ) |
|
344 { |
|
345 iReserved = aServiceConnInfo.iReserved; |
|
346 CCHLOGSTRING2( "CCCHServiceInfo::SetConnectionInfoL: reserved no action=%d", iReserved ); |
|
347 } |
|
348 |
|
349 CleanupStack::PopAndDestroy( &uids ); |
|
350 |
|
351 CCHLOGSTRING( "CCCHServiceInfo::SetConnectionInfoL: OUT" ); |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CCCHServiceInfo::GetConnectionInfoL |
|
356 // (other items were commented in a header). |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 void CCCHServiceInfo::GetConnectionInfoL( |
|
360 TServiceConnectionInfo& aServiceConnInfo ) const |
|
361 { |
|
362 CCHLOGSTRING( "CCCHServiceInfo::GetConnectionInfoL: IN" ); |
|
363 |
|
364 TUid pluginUid( KNullUid ); |
|
365 TInt index( KErrNone ); |
|
366 |
|
367 if ( aServiceConnInfo.iServiceSelection.iType != ECCHUnknown ) |
|
368 { |
|
369 index = FindSubservice( aServiceConnInfo.iServiceSelection.iType ); |
|
370 } |
|
371 |
|
372 |
|
373 if ( KErrNotFound != index && iSubservices.Count() ) |
|
374 { |
|
375 |
|
376 pluginUid = iSubservices[ index ]->GetPluginUid(); |
|
377 |
|
378 if( aServiceConnInfo.iServiceSelection.iParameter == ECchUsername ) |
|
379 { |
|
380 const CCCHPluginHandler& ch = iServer.PluginHandler(); |
|
381 const TServiceConnectionInfo& css = aServiceConnInfo; |
|
382 |
|
383 RBuf buffer; |
|
384 buffer.CreateL(KCCHMaxProtocolNameLength); |
|
385 iServer.PluginHandler().GetConnectionParameter( |
|
386 pluginUid, |
|
387 css.iServiceSelection, |
|
388 buffer ); |
|
389 |
|
390 aServiceConnInfo.iUsername = buffer; |
|
391 buffer.Close(); |
|
392 } |
|
393 else if( aServiceConnInfo.iServiceSelection.iParameter == |
|
394 ECchReserved ) |
|
395 { |
|
396 CCHLOGSTRING2( "CCCHServiceInfo::GetConnectionInfoL: reserved no action=%d", iReserved ); |
|
397 aServiceConnInfo.iReserved = iReserved; |
|
398 } |
|
399 else |
|
400 { |
|
401 User::LeaveIfError( iServer.PluginHandler().GetServiceNetworkInfo( |
|
402 aServiceConnInfo.ServiceId(), pluginUid, aServiceConnInfo.Type(), |
|
403 aServiceConnInfo.iSNAPId, aServiceConnInfo.iIapId, |
|
404 aServiceConnInfo.iSNAPLocked, aServiceConnInfo.iPasswordSet ) ); } |
|
405 } |
|
406 else |
|
407 { |
|
408 User::Leave( KErrNotFound ); |
|
409 } |
|
410 |
|
411 CCHLOGSTRING( "CCCHServiceInfo::GetConnectionInfoL: OUT" ); |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CCCHServiceInfo::ReserveServiceL |
|
416 // (other items were commented in a header). |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CCCHServiceInfo::ReserveServiceL( |
|
420 const TCCHSubserviceType aServiceType ) |
|
421 { |
|
422 CCHLOGSTRING( "CCCHServiceInfo::ReserveServiceL: IN" ); |
|
423 |
|
424 TUid pluginUid( KNullUid ); |
|
425 TInt index( FindSubservice( aServiceType ) ); |
|
426 if ( KErrNotFound != index ) |
|
427 { |
|
428 pluginUid = iSubservices[ index ]->GetPluginUid(); |
|
429 User::LeaveIfError( iServer.PluginHandler().ReserveService( |
|
430 iServiceId, pluginUid, aServiceType )); |
|
431 } |
|
432 else |
|
433 { |
|
434 User::Leave( KErrNotFound ); |
|
435 } |
|
436 |
|
437 CCHLOGSTRING( "CCCHServiceInfo::ReserveServiceL: OUT" ); |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------------------------- |
|
441 // CCCHServiceInfo::FreeServiceL |
|
442 // (other items were commented in a header). |
|
443 // --------------------------------------------------------------------------- |
|
444 // |
|
445 void CCCHServiceInfo::FreeServiceL( |
|
446 const TCCHSubserviceType aServiceType ) |
|
447 { |
|
448 CCHLOGSTRING( "CCCHServiceInfo::FreeServiceL: IN" ); |
|
449 |
|
450 TUid pluginUid( KNullUid ); |
|
451 TInt index( FindSubservice( aServiceType ) ); |
|
452 if ( KErrNotFound != index ) |
|
453 { |
|
454 pluginUid = iSubservices[ index ]->GetPluginUid(); |
|
455 User::LeaveIfError( iServer.PluginHandler().FreeService( |
|
456 iServiceId, pluginUid, aServiceType )); |
|
457 } |
|
458 else |
|
459 { |
|
460 User::Leave( KErrNotFound ); |
|
461 } |
|
462 |
|
463 CCHLOGSTRING( "CCCHServiceInfo::FreeServiceL: OUT" ); |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------------------------- |
|
467 // CCCHServiceInfo::IsReservedL |
|
468 // (other items were commented in a header). |
|
469 // --------------------------------------------------------------------------- |
|
470 // |
|
471 TBool CCCHServiceInfo::IsReservedL( |
|
472 const TCCHSubserviceType aServiceType ) const |
|
473 { |
|
474 CCHLOGSTRING( "CCCHServiceInfo::IsReservedL: IN" ); |
|
475 |
|
476 TBool ret(EFalse); |
|
477 TUid pluginUid( KNullUid ); |
|
478 TInt index( FindSubservice( aServiceType ) ); |
|
479 if ( KErrNotFound != index ) |
|
480 { |
|
481 pluginUid = iSubservices[ index ]->GetPluginUid(); |
|
482 User::LeaveIfError( ret = iServer.PluginHandler().IsReserved( |
|
483 iServiceId, pluginUid, aServiceType )); |
|
484 } |
|
485 else |
|
486 { |
|
487 User::Leave( KErrNotFound ); |
|
488 } |
|
489 |
|
490 CCHLOGSTRING( "CCCHServiceInfo::IsReservedL: OUT" ); |
|
491 return ret; |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 // CCCHServiceInfo::IsEnabled |
|
496 // (other items were commented in a header). |
|
497 // --------------------------------------------------------------------------- |
|
498 // |
|
499 TBool CCCHServiceInfo::IsEnabled() const |
|
500 { |
|
501 return iIsEnabled; |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // CCCHServiceInfo::AddSubservice |
|
506 // (other items were commented in a header). |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CCCHServiceInfo::AddSubserviceL( TCCHSubservice& aSubservice ) |
|
510 { |
|
511 CCHLOGSTRING( "CCCHServiceInfo::AddSubserviceL: IN" ); |
|
512 |
|
513 CCCHSubserviceInfo* subserviceInfo = NULL; |
|
514 if ( ECCHUnknown != aSubservice.iConnectionInfo.iServiceSelection.iType ) |
|
515 { |
|
516 // Create new instance and set service id |
|
517 subserviceInfo = |
|
518 CCCHSubserviceInfo::NewLC( aSubservice.iConnectionInfo.iServiceSelection.iServiceId, iServer ); |
|
519 // Set subserviceID |
|
520 subserviceInfo->SetSubserviceId( aSubservice.iSubserviceId ); |
|
521 |
|
522 // Get plugin uid from service table |
|
523 TUid pUid( KNullUid ); |
|
524 |
|
525 iServer.SPSHandler().GetConnectivityPluginUidL( |
|
526 aSubservice.iConnectionInfo.iServiceSelection.iServiceId, aSubservice.iConnectionInfo.iServiceSelection.iType, pUid ); |
|
527 subserviceInfo->SetPluginUid( pUid ); |
|
528 |
|
529 subserviceInfo->SetState( aSubservice.iState ); |
|
530 subserviceInfo->SetType( aSubservice.iConnectionInfo.iServiceSelection.iType ); |
|
531 subserviceInfo->SetIapId( aSubservice.iConnectionInfo.iIapId ); |
|
532 subserviceInfo->SetSNAPId( aSubservice.iConnectionInfo.iSNAPId ); |
|
533 TBool startupFlag( EFalse ); |
|
534 iServer.SPSHandler().LoadAtStartUpL( aSubservice.iConnectionInfo.iServiceSelection.iServiceId, |
|
535 aSubservice.iConnectionInfo.iServiceSelection.iType, startupFlag ); |
|
536 subserviceInfo->SetStartupFlag( startupFlag ); |
|
537 // Append pointer to array |
|
538 iSubservices.Append( subserviceInfo ); |
|
539 CleanupStack::Pop( subserviceInfo ); |
|
540 } |
|
541 |
|
542 CCHLOGSTRING( "CCCHServiceInfo::AddSubserviceL: OUT" ); |
|
543 } |
|
544 |
|
545 // --------------------------------------------------------------------------- |
|
546 // CCCHServiceInfo::UpdateL |
|
547 // (other items were commented in a header). |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 void CCCHServiceInfo::UpdateL( TBool aReadServiceTable ) |
|
551 { |
|
552 CCHLOGSTRING( "CCCHServiceInfo::UpdateL: IN" ); |
|
553 |
|
554 iIsEnabled = EFalse; |
|
555 if ( aReadServiceTable ) |
|
556 { |
|
557 TUint validSubserviceCount( 0 ); |
|
558 TInt index( KErrNotFound ); |
|
559 TCCHService service; |
|
560 // Read service information from service table |
|
561 iServer.SPSHandler().GetServiceInfoL( iServiceId , service ); |
|
562 |
|
563 for ( TInt i( 0 ); i < service.iSubservices.Count(); i++ ) |
|
564 { |
|
565 TCCHSubservice subservice = service.iSubservices[ i ]; |
|
566 |
|
567 if ( KErrNotFound != ( index = FindSubservice( |
|
568 subservice.iConnectionInfo.iServiceSelection.iType ) ) ) |
|
569 { |
|
570 TBool startupFlag( EFalse ); |
|
571 iServer.SPSHandler().LoadAtStartUpL( subservice.iConnectionInfo.iServiceSelection.iServiceId, |
|
572 subservice.iConnectionInfo.iServiceSelection.iType, startupFlag ); |
|
573 iSubservices[ index ]->SetStartupFlag( startupFlag ); |
|
574 iSubservices[ index ]->Update(); |
|
575 if ( !iIsEnabled ) |
|
576 { |
|
577 iIsEnabled = iSubservices[ index ]->IsEnabled(); |
|
578 } |
|
579 |
|
580 validSubserviceCount++; |
|
581 } |
|
582 else if ( ECCHUnknown != subservice.iConnectionInfo.iServiceSelection.iType ) |
|
583 { |
|
584 AddSubserviceL( subservice ); |
|
585 validSubserviceCount++; |
|
586 } |
|
587 else |
|
588 { |
|
589 // do nothing |
|
590 } |
|
591 } |
|
592 |
|
593 // Check that all subservices really exist in service table |
|
594 if ( validSubserviceCount < iSubservices.Count() ) |
|
595 { |
|
596 CCHLOGSTRING( "CCCHServiceInfo::UpdateL: check subservices -> need update" ); |
|
597 |
|
598 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
599 { |
|
600 TBool found( EFalse ); |
|
601 TCCHSubserviceType type = iSubservices[ i ]->Type(); |
|
602 |
|
603 for ( TInt j( 0 ) ; j < service.iSubservices.Count() && !found ; j++ ) |
|
604 { |
|
605 CCHLOGSTRING2( "CCCHServiceInfo::UpdateL: type 1=%d", type ); |
|
606 CCHLOGSTRING2( "CCCHServiceInfo::UpdateL: type 2=%d", |
|
607 service.iSubservices[ j ].iConnectionInfo.iServiceSelection.iType ); |
|
608 |
|
609 if ( service.iSubservices[ j ].iConnectionInfo.iServiceSelection.iType == type ) |
|
610 { |
|
611 CCHLOGSTRING( "CCCHServiceInfo::UpdateL: check subservices -> found" ); |
|
612 found = ETrue; |
|
613 } |
|
614 } |
|
615 |
|
616 if ( !found ) |
|
617 { |
|
618 CCHLOGSTRING( "CCCHServiceInfo::UpdateL: remove subservice" ); |
|
619 |
|
620 delete iSubservices[ i ]; |
|
621 iSubservices.Remove( i ); |
|
622 i--; |
|
623 } |
|
624 } |
|
625 } |
|
626 } |
|
627 else |
|
628 { |
|
629 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
630 { |
|
631 iSubservices[ i ]->Update(); |
|
632 if ( !iIsEnabled ) |
|
633 { |
|
634 iIsEnabled = iSubservices[ i ]->IsEnabled(); |
|
635 } |
|
636 } |
|
637 } |
|
638 |
|
639 CCHLOGSTRING( "CCCHServiceInfo::UpdateL: OUT" ); |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // CCCHServiceInfo::SetStateL |
|
644 // (other items were commented in a header). |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 void CCCHServiceInfo::SetStateL( |
|
648 const TCCHSubserviceType aType, |
|
649 const TInt aState ) |
|
650 { |
|
651 CCHLOGSTRING( "CCCHServiceInfo::SetStateL IN" ); |
|
652 |
|
653 TInt index( FindSubservice( aType ) ); |
|
654 if ( KErrNotFound != index ) |
|
655 { |
|
656 iSubservices[ index ]->SetState( |
|
657 static_cast<TCCHSubserviceState>( aState ) ); |
|
658 } |
|
659 else |
|
660 { |
|
661 User::Leave( index ); |
|
662 } |
|
663 |
|
664 // Before we update our clients handle exception error cases |
|
665 HandleErrorExceptions(); |
|
666 UpdateL(); |
|
667 CCHLOGSTRING( "CCCHServiceInfo::SetStateL :OUT" ); |
|
668 } |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // CCCHServiceInfo::SetStateL |
|
672 // (other items were commented in a header). |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 void CCCHServiceInfo::SetStateL( |
|
676 const TUid& aPluginUid, |
|
677 const TCCHSubserviceState& aState ) |
|
678 { |
|
679 CCHLOGSTRING( "CCCHServiceInfo::SetStateL IN" ); |
|
680 |
|
681 |
|
682 for ( TInt i( 0 ); i < iSubservices.Count() && |
|
683 i < KCCHMaxSubservicesCount; i++ ) |
|
684 { |
|
685 if( aPluginUid == GetUidL( i ) ) |
|
686 { |
|
687 iSubservices[ i ]->SetState( aState ); |
|
688 } |
|
689 } |
|
690 |
|
691 UpdateL(); |
|
692 CCHLOGSTRING( "CCCHServiceInfo::SetStateL :OUT" ); |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CCCHServiceInfo::SetErrorL |
|
697 // (other items were commented in a header). |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 void CCCHServiceInfo::SetErrorL( |
|
701 const TCCHSubserviceType aType, |
|
702 const TInt aError ) |
|
703 { |
|
704 CCHLOGSTRING( "CCCHServiceInfo::SetErrorL IN" ); |
|
705 |
|
706 TInt index( FindSubservice( aType ) ); |
|
707 if ( KErrNotFound != index ) |
|
708 { |
|
709 iSubservices[ index ]->SetError( aError ); |
|
710 } |
|
711 else |
|
712 { |
|
713 User::Leave( index ); |
|
714 } |
|
715 CCHLOGSTRING( "CCCHServiceInfo::SetErrorL :OUT" ); |
|
716 } |
|
717 |
|
718 // --------------------------------------------------------------------------- |
|
719 // CCCHServiceInfo::SubserviceCount |
|
720 // (other items were commented in a header). |
|
721 // --------------------------------------------------------------------------- |
|
722 // |
|
723 TInt CCCHServiceInfo::SubserviceCount() const |
|
724 { |
|
725 return iSubservices.Count(); |
|
726 } |
|
727 |
|
728 // --------------------------------------------------------------------------- |
|
729 // CCCHServiceInfo::GetUidL |
|
730 // (other items were commented in a header). |
|
731 // --------------------------------------------------------------------------- |
|
732 // |
|
733 TUid CCCHServiceInfo::GetUidL( TInt aSubserviceIndex ) const |
|
734 { |
|
735 if ( aSubserviceIndex > iSubservices.Count() ) |
|
736 { |
|
737 User::Leave( KErrNotFound ); |
|
738 } |
|
739 return iSubservices[ aSubserviceIndex ]->GetPluginUid(); |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------------------------- |
|
743 // CCCHServiceInfo::FillServiceInfo |
|
744 // (other items were commented in a header). |
|
745 // --------------------------------------------------------------------------- |
|
746 // |
|
747 void CCCHServiceInfo::FillServiceInfo( TCCHService& service ) |
|
748 { |
|
749 CCHLOGSTRING( "CCCHServiceInfo::FillServiceInfo: IN" ); |
|
750 service.iServiceId = iServiceId; |
|
751 service.iServiceName.Copy( iServiceName ); |
|
752 |
|
753 for ( TInt i( 0 ); i < iSubservices.Count() && |
|
754 i < KCCHMaxSubservicesCount; i++ ) |
|
755 { |
|
756 iSubservices[ i ]->FillSubserviceInfo( service.iSubservices.At( i ) ); |
|
757 } |
|
758 |
|
759 CCHLOGSTRING( "CCCHServiceInfo::FillServiceInfo: OUT" ); |
|
760 } |
|
761 |
|
762 // --------------------------------------------------------------------------- |
|
763 // CCCHServiceInfo::GetStatus |
|
764 // (other items were commented in a header). |
|
765 // --------------------------------------------------------------------------- |
|
766 // |
|
767 TInt CCCHServiceInfo::GetStatus( |
|
768 TCCHSubserviceType aType, TCCHSubserviceState& aState ) const |
|
769 { |
|
770 TInt error = KErrNone; |
|
771 TInt index( FindSubservice( aType ) ); |
|
772 |
|
773 if( index == KErrNotFound ) |
|
774 { |
|
775 error = KErrNotFound; |
|
776 } |
|
777 else |
|
778 { |
|
779 aState = iSubservices[ index ]->GetState(); |
|
780 } |
|
781 |
|
782 return error; |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------------------------- |
|
786 // CCCHServiceInfo::GetState |
|
787 // (other items were commented in a header). |
|
788 // --------------------------------------------------------------------------- |
|
789 // |
|
790 TCCHSubserviceState CCCHServiceInfo::GetState() const |
|
791 { |
|
792 TCCHSubserviceState ret( ECCHUninitialized ); |
|
793 |
|
794 for ( TInt i( 0 ); i < iSubservices.Count() && !ret; i++ ) |
|
795 { |
|
796 if( iSubservices[ i ]->GetState() > ret ) |
|
797 { |
|
798 ret = iSubservices[ i ]->GetState(); |
|
799 } |
|
800 } |
|
801 |
|
802 CCHLOGSTRING2( "CCCHServiceHandler::GetState: %d", ret ); |
|
803 return ret; |
|
804 } |
|
805 |
|
806 // --------------------------------------------------------------------------- |
|
807 // CCCHServiceInfo::GetError |
|
808 // (other items were commented in a header). |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 TInt CCCHServiceInfo::GetError( |
|
812 TCCHSubserviceType aType ) const |
|
813 { |
|
814 TInt index( FindSubservice( aType ) ); |
|
815 return ( KErrNotFound != index ) ? iSubservices[ index ]->GetError() : |
|
816 KErrNone; |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------------------------- |
|
820 // CCCHServiceInfo::GetServiceInfoL |
|
821 // (other items were commented in a header). |
|
822 // --------------------------------------------------------------------------- |
|
823 // |
|
824 void CCCHServiceInfo::GetServiceInfoL( |
|
825 TDes& aBuffer, |
|
826 TCCHSubserviceType aType ) const |
|
827 { |
|
828 TUid pluginUid( KNullUid ); |
|
829 TInt index( FindSubservice( aType ) ); |
|
830 if ( KErrNotFound != index ) |
|
831 { |
|
832 pluginUid = iSubservices[ index ]->GetPluginUid(); |
|
833 |
|
834 User::LeaveIfError( iServer.PluginHandler().GetServiceInfo( |
|
835 iServiceId, pluginUid, aType, aBuffer ) ); |
|
836 } |
|
837 else |
|
838 { |
|
839 User::Leave( KErrNotFound ); |
|
840 } |
|
841 } |
|
842 |
|
843 // --------------------------------------------------------------------------- |
|
844 // CCCHServiceInfo::SubserviceExist |
|
845 // (other items were commented in a header). |
|
846 // --------------------------------------------------------------------------- |
|
847 // |
|
848 TBool CCCHServiceInfo::SubserviceExist( TCCHSubserviceType aType ) const |
|
849 { |
|
850 // If subservice is specified then check if it really exist. |
|
851 // Otherwise return ETrue |
|
852 return ( ECCHUnknown != aType ) ? |
|
853 ( ( KErrNotFound != FindSubservice( aType ) ) ? ETrue : EFalse ) : |
|
854 ETrue; |
|
855 } |
|
856 |
|
857 // --------------------------------------------------------------------------- |
|
858 // CCCHServiceInfo::FindSubservice |
|
859 // (other items were commented in a header). |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 TInt CCCHServiceInfo::FindSubservice( TCCHSubserviceType aType ) const |
|
863 { |
|
864 TInt index( KErrNotFound ); |
|
865 TBool exist( EFalse ); |
|
866 for ( TInt i( 0 ); i < iSubservices.Count() && |
|
867 i < KCCHMaxSubservicesCount && !exist; i++ ) |
|
868 { |
|
869 exist = iSubservices[ i ]->Type() == aType; |
|
870 index = i; |
|
871 } |
|
872 return !exist ? KErrNotFound : index; |
|
873 } |
|
874 |
|
875 // --------------------------------------------------------------------------- |
|
876 // CCCHServiceInfo::StartupFlagSet |
|
877 // (other items were commented in a header). |
|
878 // --------------------------------------------------------------------------- |
|
879 // |
|
880 TBool CCCHServiceInfo::StartupFlagSet() const |
|
881 { |
|
882 TBool ret( EFalse ); |
|
883 for ( TInt i( 0 ); i < iSubservices.Count() && !ret; i++ ) |
|
884 { |
|
885 ret = iSubservices[ i ]->GetStartUpFlag(); |
|
886 } |
|
887 CCHLOGSTRING2( "CCCHServiceInfo::StartupFlagSet: %d", ret ); |
|
888 return ret; |
|
889 } |
|
890 |
|
891 // --------------------------------------------------------------------------- |
|
892 // CCCHServiceInfo::StartupFlagSet |
|
893 // (other items were commented in a header). |
|
894 // --------------------------------------------------------------------------- |
|
895 // |
|
896 TBool CCCHServiceInfo::StartupFlagSet( TInt aSubserviceIndex ) const |
|
897 { |
|
898 return aSubserviceIndex > iSubservices.Count() ? EFalse : |
|
899 iSubservices[ aSubserviceIndex ]->GetStartUpFlag(); |
|
900 } |
|
901 |
|
902 // --------------------------------------------------------------------------- |
|
903 // CCCHServiceInfo::SetStartupFlag |
|
904 // (other items were commented in a header). |
|
905 // --------------------------------------------------------------------------- |
|
906 // |
|
907 TInt CCCHServiceInfo::SetStartupFlag( |
|
908 TCCHSubserviceType aType, |
|
909 TBool aLoadAtStartUp ) const |
|
910 { |
|
911 TInt exist( KErrNotFound ); |
|
912 for ( TInt i( 0 ); i < iSubservices.Count() && |
|
913 i < KCCHMaxSubservicesCount; i++ ) |
|
914 { |
|
915 if ( iSubservices[ i ]->Type() == aType ) |
|
916 { |
|
917 iSubservices[ i ]->SetStartupFlag( aLoadAtStartUp ); |
|
918 exist = KErrNone; |
|
919 break; |
|
920 } |
|
921 } |
|
922 return exist; |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // CCCHServiceInfo::GetSubserviceType |
|
927 // (other items were commented in a header). |
|
928 // --------------------------------------------------------------------------- |
|
929 // |
|
930 TCCHSubserviceType CCCHServiceInfo::GetSubserviceType( |
|
931 TInt aSubserviceIndex ) const |
|
932 { |
|
933 return aSubserviceIndex > iSubservices.Count() ? ECCHUnknown : |
|
934 iSubservices[ aSubserviceIndex ]->Type(); |
|
935 } |
|
936 |
|
937 // --------------------------------------------------------------------------- |
|
938 // CCCHServiceInfo::GetSubserviceL |
|
939 // (other items were commented in a header). |
|
940 // --------------------------------------------------------------------------- |
|
941 // |
|
942 CCCHSubserviceInfo& CCCHServiceInfo::GetSubserviceL( |
|
943 TCCHSubserviceType aType ) const |
|
944 { |
|
945 TInt index( FindSubservice( aType ) ); |
|
946 if ( KErrNotFound == index ) |
|
947 { |
|
948 User::Leave( index ); |
|
949 } |
|
950 |
|
951 return *iSubservices[ index ]; |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------------------------- |
|
955 // CCCHServiceInfo::HandleErrorExceptions |
|
956 // (other items were commented in a header). |
|
957 // --------------------------------------------------------------------------- |
|
958 // |
|
959 void CCCHServiceInfo::HandleErrorExceptions() |
|
960 { |
|
961 CCHLOGSTRING( "CCCHServiceInfo::HandleErrorExceptions IN" ); |
|
962 |
|
963 for ( TInt i( 0 ); i < iSubservices.Count(); i++ ) |
|
964 { |
|
965 switch ( iSubservices[ i ]->GetError() ) |
|
966 { |
|
967 |
|
968 // KErrCancel caused by CSIPProfileRegistry::ErrorOccurred(-3) |
|
969 // User has canceled connecting dialog and we have to remove |
|
970 // service from the load at startup list. |
|
971 // At last make sure that unnecessary wlan scan is OFF |
|
972 case KErrCancel: |
|
973 { |
|
974 TRAP_IGNORE( iServer.SPSHandler().SetLoadAtStartUpL( |
|
975 iServiceId, iSubservices[ i ]->Type(), EFalse ) ); |
|
976 iServer.ServiceHandler().DisableWlanScan(); |
|
977 } |
|
978 break; |
|
979 |
|
980 default: |
|
981 break; |
|
982 } |
|
983 |
|
984 } |
|
985 |
|
986 CCHLOGSTRING( "CCCHServiceInfo::HandleErrorExceptions :OUT" ); |
|
987 } |
|
988 |
|
989 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
|
990 |
|
991 // End of File |