|
1 /* |
|
2 * Copyright (c) 2008 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: Class handling the use of Cch - All CCH Events go thro this class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32def.h> |
|
22 #include <cchserver.h> |
|
23 #include <cchclient.h> |
|
24 |
|
25 #include "cvimpstenginecchhandler.h" |
|
26 #include "tvimpstconsts.h" |
|
27 |
|
28 #include "f32file.h" |
|
29 #include "vimpstdebugtrace.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CVIMPSTEngineCchHandler::CVIMPSTEngineCchHandler |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CVIMPSTEngineCchHandler::CVIMPSTEngineCchHandler(TUint aServiceId, MVIMPSTEngineCchUiEventObserver& aCchUiEventObserver) |
|
40 : iServiceId(aServiceId),iCchUiEventObserver(aCchUiEventObserver) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CVIMPSTEngineCchHandler::ConstructL |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void CVIMPSTEngineCchHandler::ConstructL( ) |
|
49 { |
|
50 TRACE( T_LIT("CVIMPSTEngineCchHandler::ConstructL")); |
|
51 |
|
52 // Create service selection here |
|
53 iCchClient = CCch::NewL(); |
|
54 |
|
55 iSettingsStore = CVIMPSTSettingsStore::NewL(); |
|
56 |
|
57 if (iCchClient) |
|
58 { |
|
59 CCchService* service = iCchClient->GetService( iServiceId ); |
|
60 |
|
61 if( service ) |
|
62 { |
|
63 service->SetObserver( *this ); |
|
64 } |
|
65 } |
|
66 |
|
67 //Configure CCHUI notes |
|
68 MCchUi& cchUiApi = iCchClient->CchUiApi(); |
|
69 |
|
70 // Set observer to listen cchui events for change connection. |
|
71 cchUiApi.AddObserverL( *this ); // parameter is MCchUiObserver |
|
72 |
|
73 // Configure CCHUI API to show all notes/dialogs except connecting note. |
|
74 // Also configure that only VoIP and IM subservices are allowed (notes are |
|
75 // shown only for those). |
|
76 RArray<MCchUiObserver::TCchUiDialogType> allowedNotes; |
|
77 RArray<TCCHSubserviceType> allowedSubServices; |
|
78 CleanupClosePushL( allowedNotes ); |
|
79 CleanupClosePushL( allowedSubServices ); |
|
80 |
|
81 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeUsernamePasswordFailed ); |
|
82 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeAuthenticationFailed ); |
|
83 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeNoConnectionDefined ); |
|
84 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable ); |
|
85 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeConfirmChangeConnection ); |
|
86 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeChangeConnection ); |
|
87 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeDefectiveSettings ); |
|
88 allowedNotes.AppendL( MCchUiObserver::ECchUiDialogTypeErrorInConnection ); |
|
89 |
|
90 allowedSubServices.AppendL( ECCHUnknown ); |
|
91 allowedSubServices.AppendL( ECCHVoIPSub ); |
|
92 allowedSubServices.AppendL( ECCHIMSub ); |
|
93 allowedSubServices.AppendL( ECCHPresenceSub ); |
|
94 |
|
95 cchUiApi.ConfigureVisualizationL( |
|
96 allowedNotes, allowedSubServices ); |
|
97 |
|
98 CleanupStack::PopAndDestroy( &allowedSubServices ); |
|
99 CleanupStack::PopAndDestroy( &allowedNotes ); |
|
100 |
|
101 TRACE( T_LIT("CVIMPSTEngineCchHandler::ConstructL")); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CVIMPSTEngineCchHandler::NewL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CVIMPSTEngineCchHandler* CVIMPSTEngineCchHandler::NewL(TUint aServiceId, |
|
109 MVIMPSTEngineCchUiEventObserver& aCchUiEventObserver ) |
|
110 { |
|
111 TRACE( T_LIT("CVIMPSTEngineCchHandler::NewL start")); |
|
112 TRACE( T_LIT("ServiceId: %d"), aServiceId ); |
|
113 |
|
114 CVIMPSTEngineCchHandler* self = NewLC(aServiceId, aCchUiEventObserver ); |
|
115 CleanupStack::Pop(self); |
|
116 TRACE( T_LIT("CVIMPSTEngineCchHandler::NewL end")); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CVIMPSTEngineCchHandler::NewLC |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CVIMPSTEngineCchHandler* CVIMPSTEngineCchHandler::NewLC(TUint aServiceId ,MVIMPSTEngineCchUiEventObserver& aCchUiEventObserver) |
|
125 { |
|
126 CVIMPSTEngineCchHandler* self = |
|
127 new (ELeave) CVIMPSTEngineCchHandler(aServiceId, aCchUiEventObserver); |
|
128 |
|
129 TRACE( T_LIT("CVIMPSTEngineCchHandler::NewLC start")); |
|
130 TRACE( T_LIT("ServiceId: %d"), aServiceId ); |
|
131 |
|
132 CleanupStack::PushL(self); |
|
133 self->ConstructL( ); |
|
134 TRACE( T_LIT("CVIMPSTEngineCchHandler::NewLC end")); |
|
135 return self; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CVIMPSTEngineCchHandler::~CVIMPSTEngineCchHandler |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 CVIMPSTEngineCchHandler::~CVIMPSTEngineCchHandler() |
|
143 { |
|
144 TRACE( T_LIT("CVIMPSTEngineCchHandler::~CVIMPSTEngineCchHandler start") ); |
|
145 |
|
146 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
147 if(iCchClient) |
|
148 { |
|
149 CCchService* service = iCchClient->GetService( iServiceId ); |
|
150 if( service ) |
|
151 { |
|
152 service->RemoveObserver(); |
|
153 } |
|
154 } |
|
155 delete iCchClient; |
|
156 delete iSettingsStore; |
|
157 iObserverStructure.Reset(); |
|
158 iObserverStructure.Close(); |
|
159 TRACE( T_LIT("CVIMPSTEngineCchHandler::~CVIMPSTEngineCchHandler end")); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CVIMPSTEngineCchHandler::ShutdownCch |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 //TODO: not used any where.. need to be removed. |
|
167 void CVIMPSTEngineCchHandler::ShutdownCch() |
|
168 { |
|
169 TRACE( T_LIT("CVIMPSTEngineCchHandler::ShutdownCch start")); |
|
170 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
171 |
|
172 if ( iCchClient ) |
|
173 { |
|
174 delete iCchClient; |
|
175 iCchClient = NULL; |
|
176 } |
|
177 |
|
178 TRACE( T_LIT("CVIMPSTEngineCchHandler::ShutdownCch end")); |
|
179 } |
|
180 |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CVIMPSTEngineCchHandler::GetServiceState |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 TInt CVIMPSTEngineCchHandler::GetServiceState(TUint aServiceId, |
|
187 TInt aSubServiceType, |
|
188 TCCHSubserviceState& aCCHState |
|
189 ) |
|
190 { |
|
191 TRACE( T_LIT("CVIMPSTEngineCchHandler::GetServiceState")); |
|
192 |
|
193 TRACE( T_LIT("GetServiceState ServiceId: %d, SubServiceType:%d"), |
|
194 aServiceId, aSubServiceType ); |
|
195 |
|
196 TInt err = KErrNotFound; |
|
197 if ( iCchClient ) |
|
198 { |
|
199 CCchService* service = iCchClient->GetService( aServiceId ); |
|
200 TCchServiceStatus status; |
|
201 status.SetState(ECCHUninitialized); |
|
202 |
|
203 if( service ) |
|
204 { |
|
205 // Get status from the client |
|
206 err = service->GetStatus( TCCHSubserviceType(aSubServiceType), status ); |
|
207 if (KErrNone == err) |
|
208 { |
|
209 aCCHState = status.State(); |
|
210 } |
|
211 } |
|
212 } |
|
213 TRACE( T_LIT("GetServiceState - aCCHState: (%d)"), aCCHState ); |
|
214 |
|
215 TRACE( T_LIT("CVIMPSTEngineCchHandler::GetServiceState")); |
|
216 |
|
217 return err; |
|
218 } |
|
219 |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CVIMPSTEngineCchHandler::EnableService |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 TInt CVIMPSTEngineCchHandler::EnableService() |
|
226 { |
|
227 TRACE( T_LIT("CVIMPSTEngineCchHandler::EnableService start")); |
|
228 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
229 |
|
230 TInt error = KErrNotFound; |
|
231 if ( iCchClient ) |
|
232 { |
|
233 iCchClient->SetConnectivityDialogsAllowed( ETrue ); |
|
234 |
|
235 CCchService* service = iCchClient->GetService( iServiceId ); |
|
236 if( service ) |
|
237 { |
|
238 TRACE( T_LIT("EnableService - CCHClient->Enable") ); |
|
239 error = service->Enable( ECCHUnknown ); |
|
240 } |
|
241 } |
|
242 |
|
243 TRACE( T_LIT("EnableService - stat: (%d)"), error ); |
|
244 |
|
245 TRACE( T_LIT("CVIMPSTEngineCchHandler::EnableService")); |
|
246 |
|
247 return error; |
|
248 |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CVIMPSTEngineCchHandler::DisableService |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 TInt CVIMPSTEngineCchHandler::DisableService() |
|
256 { |
|
257 TRACE( T_LIT( |
|
258 "CVIMPSTEngineCchHandler::DisableService start")); |
|
259 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
260 |
|
261 TInt error = KErrNotFound; |
|
262 |
|
263 if(iCchClient) |
|
264 { |
|
265 CCchService* service = iCchClient->GetService( iServiceId ); |
|
266 if( service ) |
|
267 { |
|
268 TRACE( T_LIT("DisableService - CCHClient->Disable") ); |
|
269 error = service->Disable( ECCHUnknown ); |
|
270 } |
|
271 } |
|
272 |
|
273 TRACE( T_LIT("DisableService - stat: (%d)"), error ); |
|
274 |
|
275 TRACE( T_LIT("CVIMPSTEngineCchHandler::DisableService end")); |
|
276 |
|
277 return error; |
|
278 |
|
279 } |
|
280 |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CVIMPSTEngineCchHandler::ServiceStatusChanged |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 void CVIMPSTEngineCchHandler::ServiceStatusChanged( |
|
287 TInt aServiceId, |
|
288 const TCCHSubserviceType aType, |
|
289 const TCchServiceStatus& aServiceStatus ) |
|
290 { |
|
291 |
|
292 TRACE( T_LIT("CVIMPSTEngineCchHandler::ServiceStatusChanged start")); |
|
293 // Disable the service only if the login to one of the subservices fails |
|
294 // 1.ECCHVoIPSub |
|
295 // 2.ECCHPresenceSub |
|
296 // 3.ECCHIMSub |
|
297 if( aServiceStatus.Error() == KCCHErrorLoginFailed && |
|
298 (ECCHVoIPSub == aType || |
|
299 ECCHPresenceSub == aType || |
|
300 ECCHIMSub == aType)) |
|
301 { |
|
302 DisableService(); |
|
303 } |
|
304 |
|
305 if((aServiceStatus.Error() == KCCHErrorAuthenticationFailed )||(aServiceStatus.Error() == KCCHErrorLoginFailed)) |
|
306 { |
|
307 TInt loginfailed = 0; |
|
308 TRAP_IGNORE( iSettingsStore->SetL(iServiceId ,EServiceSuccessfullLogin ,loginfailed) ); |
|
309 } |
|
310 TInt count = iObserverStructure.Count(); |
|
311 for(TInt i = 0; i< count; i++) |
|
312 { |
|
313 if(aType == iObserverStructure[i].iSubserviceType ) |
|
314 { |
|
315 TRAP_IGNORE(iObserverStructure[i].iObserver->CchEventOccuredL( |
|
316 aServiceId, |
|
317 aServiceStatus.State(), |
|
318 aServiceStatus.Error() )); |
|
319 } |
|
320 } |
|
321 |
|
322 TRACE( T_LIT("CVIMPSTEngineCchHandler::ServiceStatusChanged end")); |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CVIMPSTEngineCchHandler::RegisterCchObserverL |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 void CVIMPSTEngineCchHandler::RegisterCchObserverL(MVIMPSTEngineCchHandlerObserver* aObserver, |
|
330 TCCHSubserviceType aSubServiceType ) |
|
331 { |
|
332 TRACE( T_LIT("CVIMPSTEngineCchHandler::RegisterCchObserverL start" )); |
|
333 if(aObserver) |
|
334 { |
|
335 TObserverStructure obsstruct; |
|
336 obsstruct.iObserver = aObserver; |
|
337 obsstruct.iSubserviceType = aSubServiceType; |
|
338 iObserverStructure.Append(obsstruct); |
|
339 } |
|
340 |
|
341 TRACE( T_LIT("CVIMPSTEngineCchHandler::RegisterCchObserverL end")); |
|
342 } |
|
343 // --------------------------------------------------------------------------- |
|
344 // CVIMPSTEngineCchHandler::UnRegisterCchObserver |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 void CVIMPSTEngineCchHandler::UnRegisterCchObserver(TCCHSubserviceType aSubServiceType ) |
|
348 { |
|
349 TRACE( T_LIT("CVIMPSTEngineCchHandler::UnRegisterCchObserver start" )); |
|
350 TInt count = iObserverStructure.Count(); |
|
351 for(TInt i = 0; i < count; i++) |
|
352 { |
|
353 if(aSubServiceType == iObserverStructure[i].iSubserviceType) |
|
354 { |
|
355 iObserverStructure[i].iObserver = NULL; |
|
356 iObserverStructure.Remove(i); |
|
357 iObserverStructure.Compress(); |
|
358 break; |
|
359 } |
|
360 } |
|
361 TRACE( T_LIT("CVIMPSTEngineCchHandler::UnRegisterCchObserver end")); |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CVIMPSTEngineCchHandler::GetConParametersL |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 HBufC* CVIMPSTEngineCchHandler::GetConParametersL( |
|
369 TCchConnectionParameter aConnParam ) |
|
370 { |
|
371 TRACE( T_LIT("CVIMPSTEngineCchHandler::GetConParametersL start")); |
|
372 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
373 TRACE( T_LIT("GetConParametersL - TCchConnectionParameter aConnParam: (%d)"), aConnParam ); |
|
374 |
|
375 HBufC* temp = NULL; |
|
376 TInt error = KErrNotFound; |
|
377 if(iCchClient) |
|
378 { |
|
379 CCchService* service = iCchClient->GetService( iServiceId ); |
|
380 if( service ) |
|
381 { |
|
382 RBuf buffer; |
|
383 CleanupClosePushL( buffer ); |
|
384 buffer.CreateL(KVIMPSTUISPSMaxPropertyLength); |
|
385 |
|
386 TRACE( T_LIT("GetConParametersL - CCHClient->GetConnectionParameter") ); |
|
387 error = service->GetConnectionParameter(ECCHUnknown,aConnParam,buffer); |
|
388 User::LeaveIfError( error); |
|
389 |
|
390 //extract only the user id in case |
|
391 // Check for prefix and remove if found |
|
392 TInt prefixLocation = buffer.Locate( ':' ); |
|
393 if ( KErrNotFound != prefixLocation && ECchUsername == aConnParam ) |
|
394 { |
|
395 TRACE( T_LIT("[CVIMPSTStorageContact::GetServiceFieldsL] -> Prefix found -> remove")); |
|
396 temp = buffer.Mid(prefixLocation+1 ).AllocL(); // ownership transferred |
|
397 } |
|
398 else |
|
399 { |
|
400 TRACE( T_LIT("[CVIMPSTStorageContact::GetServiceFieldsL] -> No Prefix found")); |
|
401 temp = buffer.AllocL(); // ownership transferred |
|
402 } |
|
403 TRACE( T_LIT("GetConParametersL - Return Value: Error: %d "), error ); |
|
404 CleanupStack::PopAndDestroy( &buffer ); |
|
405 } |
|
406 } |
|
407 TRACE( T_LIT("CVIMPSTEngineCchHandler::GetConParametersL")); |
|
408 return temp; |
|
409 } |
|
410 |
|
411 |
|
412 // --------------------------------------------------------------------------- |
|
413 // Set cch connection parameter. |
|
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 TInt CVIMPSTEngineCchHandler::SetConnectionParameter( |
|
417 TCchConnectionParameter aConnParam, |
|
418 const TDesC& aConnParamValue ) |
|
419 { |
|
420 TRACE( T_LIT("CVIMPSTEngineCchHandler::SetConnectionParameter start")); |
|
421 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
422 TRACE( T_LIT("SetConnectionParameter - TCchConnectionParameter aConnParam: (%d)"), aConnParam ); |
|
423 |
|
424 TInt error = KErrNotFound; |
|
425 if(iCchClient) |
|
426 { |
|
427 CCchService* service = iCchClient->GetService( iServiceId ); |
|
428 TRACE( T_LIT("SetConnectionParameter - CCHClient->SetConnectionParameter") ); |
|
429 |
|
430 if (service) |
|
431 { |
|
432 error = service->SetConnectionParameter( |
|
433 ECCHUnknown, aConnParam, aConnParamValue ); |
|
434 } |
|
435 } |
|
436 TRACE( T_LIT("SetConnectionParameter - error: %d"), error ); |
|
437 TRACE( T_LIT("CVIMPSTEngineCchHandler::SetConnectionParameter end")); |
|
438 return error; |
|
439 } |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // CVIMPSTEngineCchHandler::ChangeConnectionL |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CVIMPSTEngineCchHandler::ChangeConnectionL() |
|
449 { |
|
450 TRACE( T_LIT("CVIMPSTEngineCchHandler::ChangeConnection start") ); |
|
451 TRACE( T_LIT("ServiceId: %d"), iServiceId ); |
|
452 |
|
453 TInt err = KErrNone; |
|
454 if (iCchClient) |
|
455 { |
|
456 MCchUi& cchUiApi = iCchClient->CchUiApi(); |
|
457 TRAP(err, cchUiApi.ShowDialogL(iServiceId, |
|
458 MCchUiObserver::ECchUiDialogTypeChangeConnection);); |
|
459 } |
|
460 TRACE( T_LIT("CVIMPSTEngineCchHandler::ChangeConnection end ")); |
|
461 |
|
462 return err; |
|
463 } |
|
464 |
|
465 |
|
466 // --------------------------------------------------------------------------- |
|
467 // CchUiApi |
|
468 // --------------------------------------------------------------------------- |
|
469 // |
|
470 MCchUi& CVIMPSTEngineCchHandler::CchUiApi() const |
|
471 { |
|
472 return iCchClient->CchUiApi(); |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------------------------- |
|
476 // CVIMPSTEngineCchHandler::IsPasswordAvailableL |
|
477 // To check whether password available in settings or not |
|
478 // Returns true if password is present in the settings else returns false |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 TBool CVIMPSTEngineCchHandler::IsPasswordAvailable(TCchConnectionParameter aConnParam ) |
|
482 { |
|
483 TRACE( T_LIT("CVIMPSTEngineCchHandler::IsPasswordAvailableL start")); |
|
484 TRACE( T_LIT("IsPasswordAvailableL - TCchConnectionParameter aConnParam: (%d)"), aConnParam ); |
|
485 TInt passwordSet = EFalse; |
|
486 if(iCchClient) |
|
487 { |
|
488 CCchService* service = iCchClient->GetService( iServiceId ); |
|
489 if( service ) |
|
490 { |
|
491 TRACE( T_LIT("GetConParametersL - CCHClient->GetConnectionParameter") ); |
|
492 service->GetConnectionParameter( ECCHUnknown,aConnParam,passwordSet ); |
|
493 } |
|
494 } |
|
495 TRACE( T_LIT("CVIMPSTEngineCchHandler::IsPasswordAvailableL end")); |
|
496 return passwordSet; |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CVIMPSTEngineCchHandler::ConnectivityDialogsCompletedL |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 |
|
504 void CVIMPSTEngineCchHandler::ConnectivityDialogsCompletedL( |
|
505 TInt aServiceId, MCchUiObserver::TCchUiOperationResult aOperationResult ) |
|
506 { |
|
507 if((iServiceId == aServiceId)&&(aOperationResult == ECchUiClientOperationResultConnectionChanged)) |
|
508 { |
|
509 iCchUiEventObserver.HandleChangeConnectionEventL(); |
|
510 } |
|
511 } |
|
512 |
|
513 // End of file |
|
514 |