1 /* |
|
2 * Copyright (c) 2007-2007 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: For handling interactions betweed UI and CCH. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cch.h> |
|
20 |
|
21 #include "cscenglogger.h" |
|
22 #include "cscengcchhandler.h" |
|
23 #include "mcscengcchobserver.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CCSCEngCCHHandler::CCSCEngCCHHandler( MCSCEngCCHObserver& aObserver ) : |
|
31 iObserver( aObserver ) |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 void CCSCEngCCHHandler::ConstructL() |
|
40 { |
|
41 CSCENGDEBUG( "CCSCEngCCHHandler::ConstructL - begin" ); |
|
42 |
|
43 iCchClientApi = CCch::NewL(); |
|
44 |
|
45 CSCENGDEBUG( "CCSCEngCCHHandler::ConstructL - end" ); |
|
46 } |
|
47 |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CCSCEngCCHHandler* CCSCEngCCHHandler::NewL( |
|
53 MCSCEngCCHObserver& aObserver ) |
|
54 { |
|
55 CCSCEngCCHHandler* self = new ( ELeave ) CCSCEngCCHHandler( aObserver ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CCSCEngCCHHandler::~CCSCEngCCHHandler() |
|
67 { |
|
68 CSCENGDEBUG( "CCSCEngCCHHandler::~CCSCEngCCHHandler - begin" ); |
|
69 |
|
70 delete iCchClientApi; |
|
71 |
|
72 CSCENGDEBUG( "CCSCEngCCHHandler::~CCSCEngCCHHandler - end" ); |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Disable service. |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C TInt CCSCEngCCHHandler::DisableService( TInt aServiceId ) |
|
81 { |
|
82 CCchService* service = iCchClientApi->GetService( aServiceId ); |
|
83 |
|
84 TInt err( KErrNone ); |
|
85 if ( service ) |
|
86 { |
|
87 service->SetObserver( *this ); |
|
88 err = service->Disable( ECCHUnknown ); |
|
89 } |
|
90 else |
|
91 { |
|
92 err = KErrArgument; |
|
93 } |
|
94 |
|
95 return err; |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Check is service disabled |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C TBool CCSCEngCCHHandler::IsServiceDisabled( TInt aServiceId ) |
|
104 { |
|
105 TBool disabled( ETrue ); |
|
106 |
|
107 if ( !IsDisabled( aServiceId, ECCHVoIPSub ) ) return EFalse; |
|
108 if ( !IsDisabled( aServiceId, ECCHPresenceSub ) ) return EFalse; |
|
109 if ( !IsDisabled( aServiceId, ECCHIMSub ) ) return EFalse; |
|
110 if ( !IsDisabled( aServiceId, ECCHVMBxSub ) ) return EFalse; |
|
111 |
|
112 return disabled; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Check is service is valid |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C TBool CCSCEngCCHHandler::IsServiceValidL( TInt aServiceId ) |
|
120 { |
|
121 TBool validService( EFalse ); |
|
122 |
|
123 TSupportedSubServices supportedSubServices; |
|
124 SupportedSubServicesL( aServiceId, supportedSubServices ); |
|
125 |
|
126 // Service is valid if some subservice is supported |
|
127 if ( supportedSubServices.iVoIP || supportedSubServices.iIm || |
|
128 supportedSubServices.iPresence || supportedSubServices.iVmbx ) |
|
129 { |
|
130 validService = ETrue; |
|
131 } |
|
132 |
|
133 return validService; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Get supported subservices. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C void CCSCEngCCHHandler::SupportedSubServicesL( |
|
141 TInt aServiceId, TSupportedSubServices& aSupSubServices ) |
|
142 { |
|
143 CCchService* service = |
|
144 iCchClientApi->GetService( aServiceId ); |
|
145 |
|
146 TBool supported( EFalse ); |
|
147 |
|
148 if ( service ) |
|
149 { |
|
150 service->IsSupported( ECCHVoIPSub, supported ); |
|
151 aSupSubServices.iVoIP = supported; |
|
152 |
|
153 service->IsSupported( ECCHPresenceSub, supported ); |
|
154 aSupSubServices.iPresence = supported; |
|
155 |
|
156 service->IsSupported( ECCHIMSub, supported ); |
|
157 aSupSubServices.iIm = supported; |
|
158 |
|
159 service->IsSupported( ECCHVMBxSub, supported ); |
|
160 aSupSubServices.iVmbx = supported; |
|
161 } |
|
162 |
|
163 CSCENGDEBUG2( |
|
164 "CCSCEngCCHHandler::SupportedSubServicesL VoIP=%d", |
|
165 aSupSubServices.iVoIP ); |
|
166 CSCENGDEBUG2( |
|
167 "CCSCEngCCHHandler::SupportedSubServicesL Presence=%d", |
|
168 aSupSubServices.iPresence ); |
|
169 CSCENGDEBUG2( |
|
170 "CCSCEngCCHHandler::SupportedSubServicesL IM=%d", |
|
171 aSupSubServices.iIm ); |
|
172 CSCENGDEBUG2( |
|
173 "CCSCEngCCHHandler::SupportedSubServicesL VMBX=%d", |
|
174 aSupSubServices.iVmbx ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Get cch connection parameter (RBuf). |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TInt CCSCEngCCHHandler::GetConnectionParameter( |
|
182 TInt aServiceId, |
|
183 TCchConnectionParameter aConnParam, |
|
184 RBuf& aConnParamValue ) |
|
185 { |
|
186 CSCENGDEBUG( "CCSCEngCCHHandler::GetConnectionParameter" ); |
|
187 |
|
188 CCchService* service = |
|
189 iCchClientApi->GetService( aServiceId ); |
|
190 |
|
191 TInt err( KErrNone ); |
|
192 if ( service ) |
|
193 { |
|
194 err = service->GetConnectionParameter( |
|
195 ECCHUnknown, aConnParam, aConnParamValue ); |
|
196 } |
|
197 else |
|
198 { |
|
199 err = KErrArgument; |
|
200 } |
|
201 |
|
202 return err; |
|
203 } |
|
204 |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // Get cch connection parameter (TInt). |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C TInt CCSCEngCCHHandler::GetConnectionParameter( |
|
211 TInt aServiceId, |
|
212 TCchConnectionParameter aConnParam, |
|
213 TInt& aConnParamValue ) |
|
214 { |
|
215 CSCENGDEBUG( "CCSCEngCCHHandler::GetConnectionParameter" ); |
|
216 |
|
217 CCchService* service = |
|
218 iCchClientApi->GetService( aServiceId ); |
|
219 |
|
220 |
|
221 TInt err( KErrNone ); |
|
222 if ( service ) |
|
223 { |
|
224 err = service->GetConnectionParameter( |
|
225 ECCHUnknown, aConnParam, aConnParamValue ); |
|
226 } |
|
227 else |
|
228 { |
|
229 err = KErrArgument; |
|
230 } |
|
231 |
|
232 return err; |
|
233 } |
|
234 |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Set cch connection parameter. |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C TInt CCSCEngCCHHandler::SetConnectionParameter( |
|
241 TInt aServiceId, |
|
242 TCchConnectionParameter aConnParam, |
|
243 const TDesC& aConnParamValue ) |
|
244 { |
|
245 CSCENGDEBUG( "CCSCEngCCHHandler::SetConnectionParameter" ); |
|
246 |
|
247 CCchService* service = |
|
248 iCchClientApi->GetService( aServiceId ); |
|
249 |
|
250 TInt err( KErrNone ); |
|
251 if ( service ) |
|
252 { |
|
253 err =service->SetConnectionParameter( |
|
254 ECCHUnknown, aConnParam, aConnParamValue ); |
|
255 } |
|
256 else |
|
257 { |
|
258 err = KErrArgument; |
|
259 } |
|
260 |
|
261 return err; |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CCSCEngCCHHandler::IsDisabled |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 TBool CCSCEngCCHHandler::IsDisabled( |
|
269 TInt aServiceId, |
|
270 TCCHSubserviceType aType ) |
|
271 { |
|
272 TBool disabled( EFalse ); |
|
273 |
|
274 CCchService* service = |
|
275 iCchClientApi->GetService( aServiceId ); |
|
276 |
|
277 if ( service ) |
|
278 { |
|
279 TCchServiceStatus status; |
|
280 TInt err = service->GetStatus( aType, status ); |
|
281 |
|
282 if ( KErrNotFound == err || |
|
283 ( KErrNone == err && |
|
284 ( ECCHUninitialized == status.State() || |
|
285 ECCHDisabled == status.State() ) ) ) |
|
286 { |
|
287 disabled = ETrue; |
|
288 } |
|
289 } |
|
290 |
|
291 return disabled; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // From class MCchServiceStatusObserver |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 void CCSCEngCCHHandler::ServiceStatusChanged( |
|
299 TInt aServiceId, |
|
300 TCCHSubserviceType aType, |
|
301 const TCchServiceStatus& aServiceStatus ) |
|
302 { |
|
303 CSCENGDEBUG( "CCSCEngCCHHandler::ServiceStatusChanged" ); |
|
304 |
|
305 if ( ECCHDisabled == aServiceStatus.State() ) |
|
306 { |
|
307 CCchService* service = |
|
308 iCchClientApi->GetService( aServiceId ); |
|
309 |
|
310 if ( service ) |
|
311 { |
|
312 service->RemoveObserver(); |
|
313 } |
|
314 } |
|
315 |
|
316 iObserver.ServiceStatusChanged( |
|
317 aServiceId, |
|
318 aType, |
|
319 aServiceStatus ); |
|
320 } |
|