28
|
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: 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 |
// Create new cch client for access the latest service info data.
|
|
144 |
CCchService* service =
|
|
145 |
CCch::NewLC()->GetService( aServiceId );
|
|
146 |
|
|
147 |
TBool supported( EFalse );
|
|
148 |
|
|
149 |
if ( service )
|
|
150 |
{
|
|
151 |
service->IsSupported( ECCHVoIPSub, supported );
|
|
152 |
aSupSubServices.iVoIP = supported;
|
|
153 |
|
|
154 |
service->IsSupported( ECCHPresenceSub, supported );
|
|
155 |
aSupSubServices.iPresence = supported;
|
|
156 |
|
|
157 |
service->IsSupported( ECCHIMSub, supported );
|
|
158 |
aSupSubServices.iIm = supported;
|
|
159 |
|
|
160 |
service->IsSupported( ECCHVMBxSub, supported );
|
|
161 |
aSupSubServices.iVmbx = supported;
|
|
162 |
}
|
|
163 |
|
|
164 |
CleanupStack::PopAndDestroy(); // cch
|
|
165 |
|
|
166 |
CSCENGDEBUG2(
|
|
167 |
"CCSCEngCCHHandler::SupportedSubServicesL VoIP=%d",
|
|
168 |
aSupSubServices.iVoIP );
|
|
169 |
CSCENGDEBUG2(
|
|
170 |
"CCSCEngCCHHandler::SupportedSubServicesL Presence=%d",
|
|
171 |
aSupSubServices.iPresence );
|
|
172 |
CSCENGDEBUG2(
|
|
173 |
"CCSCEngCCHHandler::SupportedSubServicesL IM=%d",
|
|
174 |
aSupSubServices.iIm );
|
|
175 |
CSCENGDEBUG2(
|
|
176 |
"CCSCEngCCHHandler::SupportedSubServicesL VMBX=%d",
|
|
177 |
aSupSubServices.iVmbx );
|
|
178 |
}
|
|
179 |
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
// Get cch connection parameter (RBuf).
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
EXPORT_C TInt CCSCEngCCHHandler::GetConnectionParameter(
|
|
185 |
TInt aServiceId,
|
|
186 |
TCchConnectionParameter aConnParam,
|
|
187 |
RBuf& aConnParamValue )
|
|
188 |
{
|
|
189 |
CSCENGDEBUG( "CCSCEngCCHHandler::GetConnectionParameter" );
|
|
190 |
|
|
191 |
CCchService* service =
|
|
192 |
iCchClientApi->GetService( aServiceId );
|
|
193 |
|
|
194 |
TInt err( KErrNone );
|
|
195 |
if ( service )
|
|
196 |
{
|
|
197 |
err = service->GetConnectionParameter(
|
|
198 |
ECCHUnknown, aConnParam, aConnParamValue );
|
|
199 |
}
|
|
200 |
else
|
|
201 |
{
|
|
202 |
err = KErrArgument;
|
|
203 |
}
|
|
204 |
|
|
205 |
return err;
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
// Get cch connection parameter (TInt).
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
EXPORT_C TInt CCSCEngCCHHandler::GetConnectionParameter(
|
|
214 |
TInt aServiceId,
|
|
215 |
TCchConnectionParameter aConnParam,
|
|
216 |
TInt& aConnParamValue )
|
|
217 |
{
|
|
218 |
CSCENGDEBUG( "CCSCEngCCHHandler::GetConnectionParameter" );
|
|
219 |
|
|
220 |
CCchService* service =
|
|
221 |
iCchClientApi->GetService( aServiceId );
|
|
222 |
|
|
223 |
|
|
224 |
TInt err( KErrNone );
|
|
225 |
if ( service )
|
|
226 |
{
|
|
227 |
err = service->GetConnectionParameter(
|
|
228 |
ECCHUnknown, aConnParam, aConnParamValue );
|
|
229 |
}
|
|
230 |
else
|
|
231 |
{
|
|
232 |
err = KErrArgument;
|
|
233 |
}
|
|
234 |
|
|
235 |
return err;
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
// Set cch connection parameter.
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
EXPORT_C TInt CCSCEngCCHHandler::SetConnectionParameter(
|
|
244 |
TInt aServiceId,
|
|
245 |
TCchConnectionParameter aConnParam,
|
|
246 |
const TDesC& aConnParamValue )
|
|
247 |
{
|
|
248 |
CSCENGDEBUG( "CCSCEngCCHHandler::SetConnectionParameter" );
|
|
249 |
|
|
250 |
CCchService* service =
|
|
251 |
iCchClientApi->GetService( aServiceId );
|
|
252 |
|
|
253 |
TInt err( KErrNone );
|
|
254 |
if ( service )
|
|
255 |
{
|
|
256 |
err =service->SetConnectionParameter(
|
|
257 |
ECCHUnknown, aConnParam, aConnParamValue );
|
|
258 |
}
|
|
259 |
else
|
|
260 |
{
|
|
261 |
err = KErrArgument;
|
|
262 |
}
|
|
263 |
|
|
264 |
return err;
|
|
265 |
}
|
|
266 |
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
// CCSCEngCCHHandler::IsDisabled
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
TBool CCSCEngCCHHandler::IsDisabled(
|
|
272 |
TInt aServiceId,
|
|
273 |
TCCHSubserviceType aType )
|
|
274 |
{
|
|
275 |
TBool disabled( EFalse );
|
|
276 |
|
|
277 |
CCchService* service =
|
|
278 |
iCchClientApi->GetService( aServiceId );
|
|
279 |
|
|
280 |
if ( service )
|
|
281 |
{
|
|
282 |
TCchServiceStatus status;
|
|
283 |
TInt err = service->GetStatus( aType, status );
|
|
284 |
|
|
285 |
if ( KErrNotFound == err ||
|
|
286 |
( KErrNone == err &&
|
|
287 |
( ECCHUninitialized == status.State() ||
|
|
288 |
ECCHDisabled == status.State() ) ) )
|
|
289 |
{
|
|
290 |
disabled = ETrue;
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
return disabled;
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// From class MCchServiceStatusObserver
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CCSCEngCCHHandler::ServiceStatusChanged(
|
|
302 |
TInt aServiceId,
|
|
303 |
TCCHSubserviceType aType,
|
|
304 |
const TCchServiceStatus& aServiceStatus )
|
|
305 |
{
|
|
306 |
CSCENGDEBUG( "CCSCEngCCHHandler::ServiceStatusChanged" );
|
|
307 |
|
|
308 |
if ( ECCHDisabled == aServiceStatus.State() )
|
|
309 |
{
|
|
310 |
CCchService* service =
|
|
311 |
iCchClientApi->GetService( aServiceId );
|
|
312 |
|
|
313 |
if ( service )
|
|
314 |
{
|
|
315 |
service->RemoveObserver();
|
|
316 |
}
|
|
317 |
}
|
|
318 |
|
|
319 |
iObserver.ServiceStatusChanged(
|
|
320 |
aServiceId,
|
|
321 |
aType,
|
|
322 |
aServiceStatus );
|
|
323 |
}
|