|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Provider access to CCH |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cchuilogger.h" |
|
20 #include "cchuicchhandler.h" |
|
21 |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 CCchUiCchHandler::CCchUiCchHandler( CCch& aCch ): |
|
26 iCchClientApi( aCch ) |
|
27 { |
|
28 } |
|
29 |
|
30 CCchUiCchHandler* CCchUiCchHandler::NewL( CCch& aCch ) |
|
31 { |
|
32 CCchUiCchHandler* self = |
|
33 new ( ELeave ) CCchUiCchHandler( aCch ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CCchUiCchHandler::~CCchUiCchHandler() |
|
38 { |
|
39 CCHUIDEBUG( "CCchUiCchHandler::~CCchUiCchHandler - IN" ); |
|
40 CCHUIDEBUG( "CCchUiCchHandler::~CCchUiCchHandler - OUT" ); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Gets snap that service uses. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void CCchUiCchHandler::GetConnectionSnapIdL( |
|
48 TInt aServiceId, TInt& aSnapId, TInt& aErr ) |
|
49 { |
|
50 CCHUIDEBUG( "CCchUiCchHandler::GetConnectionSnapIdL - IN" ); |
|
51 |
|
52 CCchService* service = |
|
53 iCchClientApi.GetService( aServiceId ); |
|
54 |
|
55 User::LeaveIfNull( service ); |
|
56 |
|
57 aErr = service->GetConnectionParameter( |
|
58 ECCHUnknown, ECchSnapId, aSnapId ); |
|
59 |
|
60 CCHUIDEBUG( "CCchUiCchHandler::GetConnectionSnapIdL - OUT" ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Sets snap for service. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CCchUiCchHandler::SetConnectionSnapIdL( |
|
68 TInt aServiceId, TInt aSnapId, TInt& aErr ) |
|
69 { |
|
70 CCHUIDEBUG( "CCchUiCchHandler::SetConnectionSnapIdL - IN" ); |
|
71 |
|
72 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
73 User::LeaveIfNull( service ); |
|
74 |
|
75 aErr = service->SetConnectionParameter( |
|
76 ECCHUnknown, ECchSnapId, aSnapId ); |
|
77 |
|
78 CCHUIDEBUG( "CCchUiCchHandler::SetConnectionSnapIdL - OUT" ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Gets service username. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CCchUiCchHandler::GetUsernameL( |
|
86 TInt aServiceId, RBuf& aUserName, TInt& aErr ) |
|
87 { |
|
88 CCHUIDEBUG( "CCchUiCchHandler::GetUsernameL - IN" ); |
|
89 |
|
90 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
91 User::LeaveIfNull( service ); |
|
92 |
|
93 aErr = service->GetConnectionParameter( |
|
94 ECCHUnknown, ECchUsername, aUserName ); |
|
95 |
|
96 CCHUIDEBUG( "CCchUiCchHandler::GetUsernameL - OUT" ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Sets username for service. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CCchUiCchHandler::SetUsernameL( |
|
104 TCCHUiNotifierParams aResultParams, TInt& aErr ) |
|
105 { |
|
106 CCHUIDEBUG( "CCchUiCchHandler::SetUsernameL - IN" ); |
|
107 |
|
108 CCchService* service = |
|
109 iCchClientApi.GetService( aResultParams.iServiceId ); |
|
110 User::LeaveIfNull( service ); |
|
111 |
|
112 aErr = service->SetConnectionParameter( |
|
113 ECCHUnknown, ECchUsername, aResultParams.iUsername ); |
|
114 |
|
115 CCHUIDEBUG( "CCchUiCchHandler::SetUsernameL - OUT" ); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Sets password for service. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CCchUiCchHandler::SetPasswordL( |
|
123 TCCHUiNotifierParams aResultParams, TInt& aErr ) |
|
124 { |
|
125 CCHUIDEBUG( "CCchUiCchHandler::SetPasswordL - IN" ); |
|
126 |
|
127 CCchService* service = |
|
128 iCchClientApi.GetService( aResultParams.iServiceId ); |
|
129 User::LeaveIfNull( service ); |
|
130 |
|
131 aErr = service->SetConnectionParameter( |
|
132 ECCHUnknown, ECchPassword, aResultParams.iPwd ); |
|
133 |
|
134 CCHUIDEBUG( "CCchUiCchHandler::SetPasswordL - OUT" ); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // Starts observing for service events |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CCchUiCchHandler::StartObservingL( |
|
142 TUint aServiceId, MCchServiceStatusObserver& aObserver ) |
|
143 { |
|
144 CCHUIDEBUG2( "CCchUiCchHandler::StartObservingL: service: %d", |
|
145 aServiceId ); |
|
146 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
147 User::LeaveIfNull( service ); |
|
148 |
|
149 TInt err = service->AddObserver( aObserver ); |
|
150 |
|
151 if ( KErrNone != err && KErrAlreadyExists != err ) |
|
152 { |
|
153 CCHUIDEBUG2( "CCchUiCchHandler::StartObservingL: ERR: %d", |
|
154 err ); |
|
155 |
|
156 User::Leave( err ); |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // Enables service |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CCchUiCchHandler::EnableL( TUint aServiceId ) |
|
165 { |
|
166 CCHUIDEBUG( "CCchUiCchHandler::EnableL - IN" ); |
|
167 |
|
168 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
169 User::LeaveIfNull( service ); |
|
170 service->Enable( ECCHUnknown ); |
|
171 |
|
172 CCHUIDEBUG( "CCchUiCchHandler::EnableL - OUT" ); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // Disables service |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CCchUiCchHandler::DisableL( TUint aServiceId ) |
|
180 { |
|
181 CCHUIDEBUG( "CCchUiCchHandler::DisableL - IN" ); |
|
182 |
|
183 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
184 User::LeaveIfNull( service ); |
|
185 service->Disable( ECCHUnknown ); |
|
186 |
|
187 CCHUIDEBUG( "CCchUiCchHandler::DisableL - OUT" ); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CCchUiCchHandler::AllSubservicesInStateL |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 TBool CCchUiCchHandler::AllSubservicesInStateL( |
|
195 TUint aServiceId, |
|
196 TCCHSubserviceState aState ) |
|
197 { |
|
198 CCHUIDEBUG( "CCchUiCchHandler::AllSubservicesInStateL - IN" ); |
|
199 CCHUIDEBUG2( "CCchUiCchHandler::AllSubservicesInStateL : %d", aState ); |
|
200 |
|
201 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
202 User::LeaveIfNull( service ); |
|
203 |
|
204 RArray<TCCHSubserviceType> types; |
|
205 CleanupClosePushL( types ); |
|
206 types.AppendL( ECCHVoIPSub ); |
|
207 types.AppendL( ECCHPresenceSub ); |
|
208 types.AppendL( ECCHIMSub ); |
|
209 types.AppendL( ECCHVMBxSub ); |
|
210 |
|
211 TBool response( ETrue ); |
|
212 |
|
213 for ( TInt i( 0 ) ; i < types.Count() ; i++ ) |
|
214 { |
|
215 TBool supported( EFalse ); |
|
216 TInt err = service->IsSupported( types[ i ], supported ); |
|
217 |
|
218 if ( supported && !err ) |
|
219 { |
|
220 TCCHSubserviceState state = |
|
221 GetServiceStateL( aServiceId, types[ i ], err ); |
|
222 |
|
223 if ( aState != state && !err ) |
|
224 { |
|
225 response = EFalse; |
|
226 i = types.Count(); // End loop |
|
227 } |
|
228 } |
|
229 } |
|
230 |
|
231 CleanupStack::PopAndDestroy( &types ); |
|
232 |
|
233 CCHUIDEBUG2( "CCchUiCchHandler::AllSubservicesInStateL : %d", response ); |
|
234 CCHUIDEBUG( "CCchUiCchHandler::AllSubservicesInStateL - OUT" ); |
|
235 return response; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // Stops observing for specific service |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CCchUiCchHandler::StopObservingL( |
|
243 TUint aServiceId, MCchServiceStatusObserver& aObserver ) |
|
244 { |
|
245 CCHUIDEBUG( "CCchUiCchHandler::StopObservingL - IN" ); |
|
246 |
|
247 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
248 User::LeaveIfNull( service ); |
|
249 |
|
250 TInt err = service->RemoveObserver( aObserver ); |
|
251 |
|
252 if ( KErrNone != err && KErrNotFound != err ) |
|
253 { |
|
254 CCHUIDEBUG2( "CCchUiCchHandler::StopObservingL: ERR: %d", |
|
255 err ); |
|
256 |
|
257 User::Leave( err ); |
|
258 } |
|
259 |
|
260 CCHUIDEBUG( "CCchUiCchHandler::StopObservingL - OUT"); |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // For checking service state. |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 TCCHSubserviceState CCchUiCchHandler::GetServiceStateL( |
|
268 TUint aServiceId, TCCHSubserviceType aSubServiceType, TInt& aErr ) |
|
269 { |
|
270 CCHUIDEBUG( "CCchUiCchHandler::GetServiceStateL"); |
|
271 |
|
272 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
273 User::LeaveIfNull( service ); |
|
274 |
|
275 TCchServiceStatus serviceStatus; |
|
276 aErr = service->GetStatus( aSubServiceType, serviceStatus ); |
|
277 |
|
278 CCHUIDEBUG2( "GetServiceStateL STATE=%d", serviceStatus.State() ); |
|
279 |
|
280 return serviceStatus.State(); |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // For getting current connections iap id. |
|
285 // --------------------------------------------------------------------------- |
|
286 // |
|
287 void CCchUiCchHandler::GetCurrentConnectionIapIdL( |
|
288 TUint aServiceId, |
|
289 TCCHSubserviceType aSubServiceType, |
|
290 TInt& aIapId, |
|
291 TInt& aErr ) |
|
292 { |
|
293 CCHUIDEBUG( "CCchUiCchHandler::GetCurrentConnectionIapIdL - IN" ); |
|
294 |
|
295 CCchService* service = iCchClientApi.GetService( aServiceId ); |
|
296 User::LeaveIfNull( service ); |
|
297 |
|
298 aErr = service->GetConnectionParameter( |
|
299 aSubServiceType, |
|
300 ECchIapId, |
|
301 aIapId ); |
|
302 |
|
303 // Check that atleast some subservice is really in enabled state |
|
304 //(connection exists), if not set iap id to 0 |
|
305 if ( aIapId ) |
|
306 { |
|
307 TBool enabledSubServiceFound( EFalse ); |
|
308 |
|
309 RArray<TCCHSubserviceType> types; |
|
310 CleanupClosePushL( types ); |
|
311 types.AppendL( ECCHVoIPSub ); |
|
312 types.AppendL( ECCHPresenceSub ); |
|
313 types.AppendL( ECCHIMSub ); |
|
314 types.AppendL( ECCHVMBxSub ); |
|
315 |
|
316 for ( TInt i( 0 ) ; i < types.Count() ; i++ ) |
|
317 { |
|
318 TBool supported( EFalse ); |
|
319 TInt err = service->IsSupported( types[ i ], supported ); |
|
320 |
|
321 if ( supported && !err ) |
|
322 { |
|
323 TCCHSubserviceState state = GetServiceStateL( |
|
324 aServiceId, types[ i ], err ); |
|
325 |
|
326 if ( ECCHEnabled == state && !err ) |
|
327 { |
|
328 // Enabled subservice found, end loop |
|
329 enabledSubServiceFound = ETrue; |
|
330 i = types.Count(); |
|
331 } |
|
332 } |
|
333 } |
|
334 |
|
335 // Set aIapId to zero if no subservices in enabled state |
|
336 if ( !enabledSubServiceFound ) |
|
337 { |
|
338 aIapId = 0; |
|
339 } |
|
340 |
|
341 CleanupStack::PopAndDestroy( &types ); |
|
342 } |
|
343 |
|
344 CCHUIDEBUG( "CCchUiCchHandler::GetCurrentConnectionIapIdL - OUT" ); |
|
345 } |