author | Simon Howkins <simonh@symbian.org> |
Mon, 29 Nov 2010 11:18:43 +0000 | |
branch | RCL_3 |
changeset 37 | 7506649dda4d |
parent 34 | e7f34e614544 |
permissions | -rw-r--r-- |
29 | 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 |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <e32def.h> |
|
21 |
#include <cchserver.h> |
|
22 |
#include <cchclient.h> |
|
23 |
#include <spsettings.h> |
|
24 |
#include <spproperty.h> |
|
25 |
#include "cimcvenginefactory.h" |
|
26 |
||
27 |
#include "cimcvenginecchhandler.h" |
|
28 |
#include "imcvuiliterals.h" |
|
29 |
||
30 |
#include "imcvlogger.h" |
|
31 |
||
32 |
// CONSTANTS |
|
33 |
||
34 |
// ================= MEMBER FUNCTIONS ======================= |
|
35 |
||
36 |
// --------------------------------------------------------------------------- |
|
37 |
// CIMCVEngineCchHandler::CIMCVEngineCchHandler |
|
38 |
// --------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
CIMCVEngineCchHandler::CIMCVEngineCchHandler(TUint aServiceId, |
|
41 |
CIMCVEngine& aEngine) |
|
42 |
: iServiceId(aServiceId), |
|
43 |
iEngine(aEngine) |
|
44 |
{ |
|
45 |
} |
|
46 |
||
47 |
// --------------------------------------------------------------------------- |
|
48 |
// CIMCVEngineCchHandler::ConstructL |
|
49 |
// --------------------------------------------------------------------------- |
|
50 |
// |
|
51 |
void CIMCVEngineCchHandler::ConstructL( ) |
|
52 |
{ |
|
53 |
// Create service selection here |
|
54 |
iCchClient = CCch::NewL(); |
|
55 |
||
56 |
if (iCchClient) |
|
57 |
{ |
|
58 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
59 |
||
60 |
if( service ) |
|
61 |
{ |
|
62 |
service->SetObserver( *this ); |
|
63 |
} |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
64 |
} |
29 | 65 |
|
66 |
} |
|
67 |
||
68 |
// --------------------------------------------------------------------------- |
|
69 |
// CIMCVEngineCchHandler::NewL |
|
70 |
// --------------------------------------------------------------------------- |
|
71 |
// |
|
72 |
CIMCVEngineCchHandler* |
|
73 |
CIMCVEngineCchHandler::NewL( TUint aServiceId, CIMCVEngine& aEngine ) |
|
74 |
{ |
|
75 |
CIMCVEngineCchHandler* self = NewLC(aServiceId, aEngine); |
|
76 |
CleanupStack::Pop(self); |
|
77 |
return self; |
|
78 |
} |
|
79 |
||
80 |
// --------------------------------------------------------------------------- |
|
81 |
// CIMCVEngineCchHandler::NewLC |
|
82 |
// --------------------------------------------------------------------------- |
|
83 |
// |
|
84 |
CIMCVEngineCchHandler* |
|
85 |
CIMCVEngineCchHandler::NewLC(TUint aServiceId, CIMCVEngine& aEngine ) |
|
86 |
{ |
|
87 |
CIMCVEngineCchHandler* self = |
|
88 |
new (ELeave) CIMCVEngineCchHandler(aServiceId, aEngine); |
|
89 |
CleanupStack::PushL(self); |
|
90 |
self->ConstructL( ); |
|
91 |
return self; |
|
92 |
} |
|
93 |
||
94 |
// --------------------------------------------------------------------------- |
|
95 |
// CIMCVEngineCchHandler::~CIMCVEngineCchHandler |
|
96 |
// --------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
CIMCVEngineCchHandler::~CIMCVEngineCchHandler() |
|
99 |
{ |
|
100 |
||
101 |
if(iCchClient) |
|
102 |
{ |
|
103 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
104 |
if( service ) |
|
105 |
{ |
|
106 |
service->RemoveObserver(); |
|
107 |
} |
|
108 |
delete iCchClient; |
|
109 |
} |
|
110 |
||
111 |
} |
|
112 |
||
113 |
||
114 |
||
115 |
// --------------------------------------------------------------------------- |
|
116 |
// CIMCVEngineCchHandler::GetServiceState |
|
117 |
// --------------------------------------------------------------------------- |
|
118 |
// |
|
119 |
TInt CIMCVEngineCchHandler::GetServiceState( |
|
120 |
TCCHSubserviceState& aCCHState |
|
121 |
) |
|
122 |
{ |
|
123 |
TInt err = KErrNone; |
|
124 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
125 |
TCchServiceStatus status; |
|
126 |
status.SetState(ECCHUninitialized); |
|
127 |
||
128 |
if( service ) |
|
129 |
{ |
|
130 |
// Get status from the client |
|
131 |
err = service->GetStatus( ECCHIMSub, status ); |
|
132 |
} |
|
133 |
||
134 |
aCCHState = status.State(); |
|
135 |
||
136 |
return err; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
// --------------------------------------------------------------------------- |
|
141 |
// CIMCVEngineCchHandler::EnableService |
|
142 |
// --------------------------------------------------------------------------- |
|
143 |
// |
|
144 |
TInt CIMCVEngineCchHandler::EnableService() |
|
145 |
{ |
|
146 |
||
147 |
// Retrieve service interface from the CCH client to be used to |
|
148 |
// enable aServiceType |
|
149 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
150 |
//Allowing Connectivity Dialogs for cch |
|
151 |
iCchClient->SetConnectivityDialogsAllowed( ETrue ); |
|
152 |
||
153 |
// By default set to fault value; if service pointer is valid then we |
|
154 |
// return the disable value, otherwise we return KErrNotFound |
|
155 |
TInt error = KErrNotFound; |
|
156 |
if( service ) |
|
157 |
{ |
|
158 |
||
159 |
error = service->Enable( ECCHUnknown ); |
|
160 |
||
161 |
} |
|
162 |
||
163 |
||
164 |
return error; |
|
165 |
} |
|
166 |
||
167 |
// --------------------------------------------------------------------------- |
|
168 |
// CIMCVEngineCchHandler::GetAdapterUidL() |
|
169 |
// --------------------------------------------------------------------------- |
|
170 |
// |
|
171 |
TInt CIMCVEngineCchHandler::GetAdapterUidL() |
|
172 |
{ |
|
173 |
TInt ret = KErrNotFound; |
|
174 |
CSPProperty* property = CSPProperty::NewLC(); |
|
175 |
CSPSettings* settings = CSPSettings::NewLC(); |
|
176 |
TInt err = settings->FindPropertyL( iServiceId, |
|
177 |
EPropertyPCSPluginId,*property ); |
|
178 |
if (KErrNone == err) |
|
179 |
{ |
|
180 |
property->GetValue( ret ); |
|
181 |
} |
|
182 |
CleanupStack::PopAndDestroy( settings ); |
|
183 |
CleanupStack::PopAndDestroy( property ); |
|
184 |
return ret; |
|
185 |
} |
|
186 |
||
187 |
// --------------------------------------------------------------------------- |
|
188 |
// CIMCVEngineCchHandler::GetUserIdL |
|
189 |
// --------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
HBufC* CIMCVEngineCchHandler::GetUserIdL() |
|
192 |
{ |
|
193 |
HBufC* temp = NULL; |
|
194 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
195 |
// By default set to fault value; if service pointer is valid then we |
|
196 |
// return the disable value, otherwise we return KErrNotFound |
|
197 |
TInt error = KErrNotFound; |
|
198 |
if( service ) |
|
199 |
{ |
|
200 |
RBuf username; |
|
201 |
username.Create(KMAXUSERIDLENGTH); |
|
202 |
CleanupClosePushL( username ); |
|
203 |
error = service->GetConnectionParameter(ECCHIMSub,ECchUsername,username); |
|
204 |
User::LeaveIfError( error); |
|
205 |
if( username.Length() > 0) |
|
206 |
{ |
|
207 |
temp = username.AllocL(); // ownership transferred |
|
208 |
} |
|
209 |
CleanupStack::PopAndDestroy( &username ); |
|
210 |
} |
|
211 |
return temp; |
|
212 |
} |
|
213 |
||
214 |
||
215 |
||
216 |
// --------------------------------------------------------------------------- |
|
217 |
// CIMCVEngineCchHandler::DisableService |
|
218 |
// --------------------------------------------------------------------------- |
|
219 |
// |
|
220 |
TInt CIMCVEngineCchHandler::DisableService() |
|
221 |
{ |
|
222 |
||
223 |
// Retrieve service interface from the CCH client to be used to |
|
224 |
// enable aServiceType |
|
225 |
CCchService* service = iCchClient->GetService( iServiceId ); |
|
226 |
// By default set to fault value; if service pointer is valid then we |
|
227 |
// return the disable value, otherwise we return KErrNotFound |
|
228 |
TInt error = KErrNotFound; |
|
229 |
if( service ) |
|
230 |
{ |
|
231 |
error = service->Disable( ECCHUnknown ); |
|
232 |
} |
|
233 |
||
234 |
||
235 |
return error; |
|
236 |
} |
|
237 |
||
238 |
||
239 |
// --------------------------------------------------------------------------- |
|
240 |
// CIMCVEngineCchHandler::IsServiceLoggedIn |
|
241 |
// --------------------------------------------------------------------------- |
|
242 |
// |
|
243 |
TBool CIMCVEngineCchHandler::IsServiceLoggedIn() |
|
244 |
{ |
|
245 |
TCCHSubserviceState serviceState = ECCHUninitialized; |
|
246 |
||
247 |
TInt error = GetServiceState( serviceState ); |
|
248 |
||
249 |
if ( !error && ECCHEnabled == serviceState ) |
|
250 |
{ |
|
251 |
return ETrue; |
|
252 |
} |
|
253 |
||
254 |
return EFalse; |
|
255 |
||
256 |
} |
|
257 |
||
258 |
||
259 |
// --------------------------------------------------------------------------- |
|
260 |
// CIMCVEngineCchHandler::ServiceStatusChanged |
|
261 |
// --------------------------------------------------------------------------- |
|
262 |
// |
|
263 |
void CIMCVEngineCchHandler::ServiceStatusChanged( |
|
264 |
TInt aServiceId, |
|
265 |
const TCCHSubserviceType aType, |
|
266 |
const TCchServiceStatus& aServiceStatus ) |
|
267 |
{ |
|
268 |
TRAP_IGNORE(DoHandleServiceStatusChangedL(aServiceId, aType, aServiceStatus)); |
|
269 |
} |
|
270 |
||
271 |
||
272 |
// --------------------------------------------------------------------------- |
|
273 |
// CIMCVEngineCchHandler::DoHandleServiceStatusChanged |
|
274 |
// --------------------------------------------------------------------------- |
|
275 |
// |
|
276 |
void CIMCVEngineCchHandler::DoHandleServiceStatusChangedL( |
|
277 |
TInt aServiceId, |
|
278 |
const TCCHSubserviceType aType, |
|
279 |
const TCchServiceStatus& aServiceStatus ) |
|
280 |
{ |
|
281 |
||
282 |
IM_CV_LOGS(TXT("CVEngineCCHHnadler::DoHandleServiceStatusChangedL ") ); |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
283 |
|
29 | 284 |
if (aType == ECCHPresenceSub) |
285 |
{ |
|
286 |
/* SIP Adaptation -- sends error in Network Lost. This is added so that once we get it, we will unbindL and delete the context |
|
287 |
* This happens only in case of SIP as it does not send the event in IM Subservice. |
|
288 |
*/ |
|
289 |
if (aServiceStatus.Error() && ECCHDisabled != aServiceStatus.State()) |
|
290 |
{ |
|
291 |
iEngine.ReleaseConnectionL (); |
|
292 |
iEngine.DeleteContextL (); |
|
293 |
} |
|
294 |
} |
|
295 |
else if (aType == ECCHIMSub) |
|
296 |
{ |
|
297 |
MIMCVEngineCCHObserver::TServiceState notifyEvent = |
|
298 |
MIMCVEngineCCHObserver::ENotLoggedIn; |
|
299 |
switch (aServiceStatus.State()) |
|
300 |
{ |
|
301 |
case ECCHUninitialized: |
|
302 |
{ |
|
303 |
//Nothing to be done |
|
304 |
break; |
|
305 |
} |
|
306 |
case ECCHDisabled: |
|
307 |
{ |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
308 |
IM_CV_LOGS(TXT("CVEngineCCHHnadler::DoHandleServiceStatusChangedL DISABLED")); |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
309 |
iEngine.CloseAllOpenChatsL (); |
29 | 310 |
iEngine.ReleaseConnectionL(); |
311 |
iEngine.DeleteContextL (); |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
312 |
|
29 | 313 |
break; |
314 |
} |
|
315 |
case ECCHConnecting: |
|
316 |
{ |
|
317 |
notifyEvent = MIMCVEngineCCHObserver::EConnecting; |
|
318 |
break; |
|
319 |
} |
|
320 |
case ECCHEnabled: |
|
321 |
{ |
|
322 |
notifyEvent = MIMCVEngineCCHObserver::ELogin; |
|
323 |
iEngine.CreateContextL(); |
|
324 |
break; |
|
325 |
} |
|
326 |
case ECCHDisconnecting: |
|
327 |
{ |
|
328 |
// If NetworkErrorLost error is received by CCH on this state, then do not close all chats |
|
329 |
// as user would loose all the on-going conversation when the network connection is |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
330 |
// restored. |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
331 |
if (aServiceStatus.Error () != KCCHErrorNetworkLost ) |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
332 |
{ |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
333 |
iEngine.CloseAllOpenChatsL(); |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
334 |
iEngine.ReleaseConnectionL (); |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
335 |
iEngine.DeleteContextL (); |
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
336 |
} |
29 | 337 |
notifyEvent = MIMCVEngineCCHObserver::EDisconnecting; |
338 |
break; |
|
339 |
} |
|
340 |
default: |
|
341 |
{ |
|
342 |
break; |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
if (iObserver) |
|
347 |
{ |
|
348 |
iObserver->ServiceStatusChanged( aServiceId, |
|
349 |
notifyEvent ); |
|
350 |
||
351 |
} |
|
352 |
||
353 |
} |
|
354 |
} |
|
355 |
||
356 |
// --------------------------------------------------------------------------- |
|
357 |
// CIMCVEngineCchHandler::RegisterObserver |
|
358 |
// --------------------------------------------------------------------------- |
|
359 |
// |
|
360 |
void CIMCVEngineCchHandler::RegisterObserver(MIMCVEngineCCHObserver* aObserver) |
|
361 |
{ |
|
362 |
if (aObserver) |
|
363 |
{ |
|
364 |
iObserver = aObserver; |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
||
369 |
||
370 |
// --------------------------------------------------------------------------- |
|
371 |
// CIMCVEngineCchHandler::UnRegisterObserver |
|
372 |
// --------------------------------------------------------------------------- |
|
373 |
// |
|
374 |
void CIMCVEngineCchHandler::UnRegisterObserver() |
|
375 |
{ |
|
376 |
iObserver = NULL; |
|
377 |
} |
|
378 |
||
379 |
||
380 |
// End of file |
|
381 |