22
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: Provider access to SNAPs
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <cmmanagerdef.h>
|
|
20 |
#include <cmpluginwlandef.h> // bearer type
|
|
21 |
#include <cmdestinationext.h>
|
|
22 |
#include <cmconnectionmethoddef.h>
|
|
23 |
#include <cmconnectionmethodext.h>
|
|
24 |
#include <cmpluginpacketdatadef.h>
|
|
25 |
|
|
26 |
#include "cchuilogger.h"
|
|
27 |
#include "cchuinotifconnectionhandler.h"
|
|
28 |
|
|
29 |
// ======== MEMBER FUNCTIONS ========
|
|
30 |
|
|
31 |
CCchUiNotifConnectionHandler::CCchUiNotifConnectionHandler()
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
void CCchUiNotifConnectionHandler::ConstructL()
|
|
36 |
{
|
|
37 |
iCmManagerExt.OpenL();
|
|
38 |
}
|
|
39 |
|
|
40 |
CCchUiNotifConnectionHandler* CCchUiNotifConnectionHandler::NewL()
|
|
41 |
{
|
|
42 |
CCchUiNotifConnectionHandler* self = NewLC();
|
|
43 |
CleanupStack::Pop(self);
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
CCchUiNotifConnectionHandler* CCchUiNotifConnectionHandler::NewLC()
|
|
48 |
{
|
|
49 |
CCchUiNotifConnectionHandler* self =
|
|
50 |
new (ELeave) CCchUiNotifConnectionHandler();
|
|
51 |
CleanupStack::PushL(self);
|
|
52 |
self->ConstructL();
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
CCchUiNotifConnectionHandler::~CCchUiNotifConnectionHandler()
|
|
57 |
{
|
|
58 |
iCmManagerExt.Close();
|
|
59 |
}
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// Gets GPRS access points from Internet SNAP
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
TUint32 CCchUiNotifConnectionHandler::GetGprsAccessPointsL(
|
|
66 |
CDesCArray& aIaps, RArray<TUint32>& aIapIds )
|
|
67 |
{
|
|
68 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::GetGprsAccessPointsL - IN" );
|
|
69 |
|
|
70 |
TUint32 internetSnapId = KErrNone;
|
|
71 |
RArray<TUint32> destIds = RArray<TUint32>( 1 );
|
|
72 |
CleanupClosePushL( destIds );
|
|
73 |
iCmManagerExt.AllDestinationsL( destIds );
|
|
74 |
|
|
75 |
for ( TInt index = 0 ; index < destIds.Count() ; index++ )
|
|
76 |
{
|
|
77 |
RCmDestinationExt refDestination =
|
|
78 |
iCmManagerExt.DestinationL( destIds[index] );
|
|
79 |
CleanupClosePushL( refDestination );
|
|
80 |
|
|
81 |
if ( refDestination.MetadataL( CMManager::ESnapMetadataInternet ) )
|
|
82 |
{
|
|
83 |
// Get all GPRS access point from this destination
|
|
84 |
GetGprsAccessPointsFromSnapL( aIaps, aIapIds, refDestination );
|
|
85 |
internetSnapId = refDestination.Id();
|
|
86 |
}
|
|
87 |
CleanupStack::PopAndDestroy( &refDestination );
|
|
88 |
}
|
|
89 |
CleanupStack::PopAndDestroy( &destIds );
|
|
90 |
|
|
91 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::GetGprsAccessPointsL - OUT" );
|
|
92 |
|
|
93 |
return internetSnapId;
|
|
94 |
}
|
|
95 |
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
// Gets connection name.
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
void CCchUiNotifConnectionHandler::ConnectionNameL(
|
|
101 |
TUint aIapId, TDesC& aServiceName, RBuf& aIapName )
|
|
102 |
{
|
|
103 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::ConnectionNameL - IN" );
|
|
104 |
|
|
105 |
if ( aIapId )
|
|
106 |
{
|
|
107 |
RCmConnectionMethodExt connMethod =
|
|
108 |
iCmManagerExt.ConnectionMethodL( aIapId );
|
|
109 |
CleanupClosePushL( connMethod );
|
|
110 |
|
|
111 |
HBufC* connName = connMethod.GetStringAttributeL(
|
|
112 |
CMManager::ECmName );
|
|
113 |
CleanupStack::PushL( connName );
|
|
114 |
|
|
115 |
aIapName.CreateL( connName->Des().Length() );
|
|
116 |
aIapName.Copy( connName->Des() );
|
|
117 |
|
|
118 |
CleanupStack::PopAndDestroy( connName );
|
|
119 |
CleanupStack::PopAndDestroy( &connMethod );
|
|
120 |
}
|
|
121 |
else
|
|
122 |
{
|
|
123 |
RArray<TUint32> destinationIds;
|
|
124 |
CleanupClosePushL( destinationIds );
|
|
125 |
iCmManagerExt.AllDestinationsL( destinationIds );
|
|
126 |
|
|
127 |
for ( TInt i( 0 ) ; i < destinationIds.Count() ; i++ )
|
|
128 |
{
|
|
129 |
RCmDestinationExt dest =
|
|
130 |
iCmManagerExt.DestinationL( destinationIds[ i ] );
|
|
131 |
CleanupClosePushL( dest );
|
|
132 |
|
|
133 |
HBufC* destName = dest.NameLC();
|
|
134 |
if ( destName->Des().Compare( aServiceName ) == 0 )
|
|
135 |
{
|
|
136 |
// Get highest priority connecton method from snap
|
|
137 |
RCmConnectionMethodExt cm = dest.ConnectionMethodL( 0 );
|
|
138 |
CleanupClosePushL( cm );
|
|
139 |
|
|
140 |
HBufC* cmName = NULL;
|
|
141 |
cmName = cm.GetStringAttributeL( CMManager::ECmName );
|
|
142 |
|
|
143 |
if ( cmName )
|
|
144 |
{
|
|
145 |
CleanupStack::PushL( cmName );
|
|
146 |
aIapName.CreateL( cmName->Des().Length() );
|
|
147 |
aIapName.Copy( cmName->Des() );
|
|
148 |
CleanupStack::PopAndDestroy( cmName );
|
|
149 |
}
|
|
150 |
|
|
151 |
CleanupStack::PopAndDestroy( &cm );
|
|
152 |
}
|
|
153 |
|
|
154 |
CleanupStack::PopAndDestroy( destName );
|
|
155 |
CleanupStack::PopAndDestroy( &dest );
|
|
156 |
}
|
|
157 |
|
|
158 |
CleanupStack::PopAndDestroy( &destinationIds );
|
|
159 |
}
|
|
160 |
|
|
161 |
CCHUIDEBUG2( "ConnectionNameL - NAME=%S", &aIapName );
|
|
162 |
|
|
163 |
CCHUIDEBUG(
|
|
164 |
"CCchUiNotifConnectionHandler::ConnectionNameL - OUT" );
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
// Gets all but specified service´s destinations.
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CCchUiNotifConnectionHandler::GetDestinationsL(
|
|
172 |
TDesC& aServiceName, RArray<TUint32>& aDestinationIds )
|
|
173 |
{
|
|
174 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::GetDestinationsL - IN" );
|
|
175 |
|
|
176 |
iCmManagerExt.AllDestinationsL( aDestinationIds );
|
|
177 |
|
|
178 |
// Remove our services destination from destination ids.
|
|
179 |
for ( TInt i( 0 ) ; i < aDestinationIds.Count() ; i++ )
|
|
180 |
{
|
|
181 |
RCmDestinationExt refDestination =
|
|
182 |
iCmManagerExt.DestinationL( aDestinationIds[ i ] );
|
|
183 |
CleanupClosePushL( refDestination );
|
|
184 |
|
|
185 |
HBufC* destName = refDestination.NameLC();
|
|
186 |
|
|
187 |
if ( destName->Des().Compare( aServiceName ) == 0 )
|
|
188 |
{
|
|
189 |
CCHUIDEBUG(
|
|
190 |
"GetDestinationsL - remove current service´s destination" );
|
|
191 |
|
|
192 |
aDestinationIds.Remove( i );
|
|
193 |
aDestinationIds.Compress();
|
|
194 |
}
|
|
195 |
|
|
196 |
CleanupStack::PopAndDestroy( destName );
|
|
197 |
CleanupStack::PopAndDestroy( &refDestination );
|
|
198 |
}
|
|
199 |
|
|
200 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::GetDestinationsL - OUT" );
|
|
201 |
}
|
|
202 |
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
// CCchUiNotifConnectionHandler::GetDestinationL
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CCchUiNotifConnectionHandler::GetDestinationL(
|
|
208 |
TUint aIapId, TInt& aError, TUint32& aDestinationId )
|
|
209 |
{
|
|
210 |
CCHUIDEBUG2(
|
|
211 |
"CCchUiNotifConnectionHandler::GetDestinationL - IN aIapID = %d", &aIapId );
|
|
212 |
|
|
213 |
aError = KErrNotFound;
|
|
214 |
RArray<TUint32> destinationIds;
|
|
215 |
CleanupClosePushL( destinationIds );
|
|
216 |
|
|
217 |
iCmManagerExt.AllDestinationsL( destinationIds );
|
|
218 |
|
|
219 |
// Find our service destination from Iap ids.
|
|
220 |
for ( TInt i( 0 ) ; i < destinationIds.Count() && KErrNone != aError; i++ )
|
|
221 |
{
|
|
222 |
RCmDestinationExt refDestination =
|
|
223 |
iCmManagerExt.DestinationL( destinationIds[ i ] );
|
|
224 |
CleanupClosePushL( refDestination );
|
|
225 |
|
|
226 |
HBufC* destName = refDestination.NameLC();
|
|
227 |
RCmConnectionMethodExt connectionMethod;
|
|
228 |
CleanupClosePushL( connectionMethod );
|
|
229 |
|
|
230 |
TRAPD( error, connectionMethod =
|
|
231 |
refDestination.ConnectionMethodByIDL( aIapId ) );
|
|
232 |
|
|
233 |
if ( KErrNone == error )
|
|
234 |
{
|
|
235 |
CCHUIDEBUG(
|
|
236 |
"GetDestinationsL - IapID found from destination" );
|
|
237 |
aDestinationId = destinationIds[ i ];
|
|
238 |
aError = KErrNone;
|
|
239 |
}
|
|
240 |
CleanupStack::PopAndDestroy( &connectionMethod );
|
|
241 |
CleanupStack::PopAndDestroy( destName );
|
|
242 |
CleanupStack::PopAndDestroy( &refDestination );
|
|
243 |
}
|
|
244 |
|
|
245 |
CleanupStack::PopAndDestroy( &destinationIds );
|
|
246 |
|
|
247 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::GetDestinationL - OUT" );
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// Gets all access point ids from SNAP.
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
void CCchUiNotifConnectionHandler::GetAccessPointsFromSnapL(
|
|
255 |
RArray<TUint32>& aIapIds, TUint32 aDestinationId )
|
|
256 |
{
|
|
257 |
CCHUIDEBUG(
|
|
258 |
"CCchUiNotifConnectionHandler::GetAccessPointsFromSnapL - IN" );
|
|
259 |
|
|
260 |
CleanupClosePushL(aIapIds);
|
|
261 |
|
|
262 |
RCmDestinationExt destination =
|
|
263 |
iCmManagerExt.DestinationL( aDestinationId );
|
|
264 |
CleanupClosePushL( destination );
|
|
265 |
|
|
266 |
for ( TInt index = 0 ;
|
|
267 |
index < destination.ConnectionMethodCount() ; index++ )
|
|
268 |
{
|
|
269 |
RCmConnectionMethodExt connMethod =
|
|
270 |
destination.ConnectionMethodL( index );
|
|
271 |
CleanupClosePushL( connMethod );
|
|
272 |
TUint32 iapId = connMethod.GetIntAttributeL( CMManager::ECmIapId );
|
|
273 |
aIapIds.AppendL( iapId );
|
|
274 |
CleanupStack::PopAndDestroy( &connMethod );
|
|
275 |
}
|
|
276 |
|
|
277 |
CleanupStack::PopAndDestroy( &destination );
|
|
278 |
CleanupStack::Pop();
|
|
279 |
|
|
280 |
CCHUIDEBUG(
|
|
281 |
"CCchUiNotifConnectionHandler::GetAccessPointsFromSnapL - OUT" );
|
|
282 |
}
|
|
283 |
|
|
284 |
// ---------------------------------------------------------------------------
|
|
285 |
// Gets GPRS access points from Internet SNAP
|
|
286 |
// ---------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void CCchUiNotifConnectionHandler::GetGprsAccessPointsFromSnapL(
|
|
289 |
CDesCArray& aIaps,
|
|
290 |
RArray<TUint32>& aIapIds,
|
|
291 |
RCmDestinationExt& aDestination )
|
|
292 |
{
|
|
293 |
CCHUIDEBUG(
|
|
294 |
"CCchUiNotifConnectionHandler::GetGprsAccessPointsFromSnapL - IN" );
|
|
295 |
|
|
296 |
__ASSERT_ALWAYS( aDestination.ConnectionMethodCount(),
|
|
297 |
User::Leave( KErrNotFound ) );
|
|
298 |
|
|
299 |
for ( TInt index = 0 ;
|
|
300 |
index < aDestination.ConnectionMethodCount() ; index++ )
|
|
301 |
{
|
|
302 |
RCmConnectionMethodExt connMethod =
|
|
303 |
aDestination.ConnectionMethodL( index );
|
|
304 |
CleanupClosePushL( connMethod );
|
|
305 |
|
|
306 |
if ( KUidPacketDataBearerType == connMethod.GetIntAttributeL(
|
|
307 |
CMManager::ECmBearerType ) )
|
|
308 |
{
|
|
309 |
HBufC* connName =
|
|
310 |
connMethod.GetStringAttributeL( CMManager::ECmName );
|
|
311 |
CleanupStack::PushL( connName );
|
|
312 |
|
|
313 |
CCHUIDEBUG( "GetGprsAccessPointsFromSnapL - iap name ok" );
|
|
314 |
|
|
315 |
aIaps.AppendL( *connName );
|
|
316 |
CleanupStack::PopAndDestroy( connName );
|
|
317 |
TUint32 iapId = connMethod.GetIntAttributeL( CMManager::ECmIapId );
|
|
318 |
aIapIds.AppendL( iapId );
|
|
319 |
|
|
320 |
CCHUIDEBUG2( "GetGprsAccessPointsFromSnapL - iap id: %d", iapId );
|
|
321 |
}
|
|
322 |
CleanupStack::PopAndDestroy( &connMethod );
|
|
323 |
}
|
|
324 |
|
|
325 |
CCHUIDEBUG(
|
|
326 |
"CCchUiNotifConnectionHandler::GetGprsAccessPointsFromSnapL - OUT" );
|
|
327 |
}
|
|
328 |
|
|
329 |
// ---------------------------------------------------------------------------
|
|
330 |
// CCchUiNotifConnectionHandler::GetGprsAccessPointsSetToServiceSnapL
|
|
331 |
// ---------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
TInt CCchUiNotifConnectionHandler::GetGprsAccessPointsSetToServiceSnapL(
|
|
334 |
CDesCArray& aIaps, RArray<TUint32>& aIapIds, TUint aIapId )
|
|
335 |
{
|
|
336 |
CCHUIDEBUG2(
|
|
337 |
"CCchUiNotifConnectionHandler::GetGprsAccessPointsSetToServiceSnapL - IN aIapId = %d", aIapId );
|
|
338 |
|
|
339 |
TUint32 destinationId = 0;
|
|
340 |
TInt error;
|
|
341 |
GetDestinationL( aIapId, error, destinationId );
|
|
342 |
if ( KErrNone == error )
|
|
343 |
{
|
|
344 |
CCHUIDEBUG2(
|
|
345 |
"GetGprsAccessPointsSetToServiceSnapL - destinationId = %d", destinationId );
|
|
346 |
|
|
347 |
RCmDestinationExt refDestination;
|
|
348 |
CleanupClosePushL( refDestination );
|
|
349 |
TRAPD( error,
|
|
350 |
refDestination = iCmManagerExt.DestinationL( destinationId ) );
|
|
351 |
CCHUIDEBUG2(
|
|
352 |
"GetGprsAccessPointsSetToServiceSnapL -Destination error %d", error );
|
|
353 |
|
|
354 |
if ( KErrNone == error )
|
|
355 |
{
|
|
356 |
GetGprsAccessPointsFromSnapL( aIaps, aIapIds, refDestination );
|
|
357 |
}
|
|
358 |
CleanupStack::PopAndDestroy( &refDestination );
|
|
359 |
}
|
|
360 |
|
|
361 |
CCHUIDEBUG2(
|
|
362 |
"CCchUiNotifConnectionHandler::GetGprsAccessPointsSetToServiceSnapL -return %d", error );
|
|
363 |
|
|
364 |
return error;
|
|
365 |
}
|
|
366 |
|
|
367 |
// ---------------------------------------------------------------------------
|
|
368 |
// CCchUiNotifConnectionHandler::IsConnectionMethodSimilarL
|
|
369 |
// ---------------------------------------------------------------------------
|
|
370 |
//
|
|
371 |
TBool CCchUiNotifConnectionHandler::IsConnectionMethodSimilarL(
|
|
372 |
TUint32 aIapId, TUint32 aIapIdToCompare )
|
|
373 |
{
|
|
374 |
CCHUIDEBUG( "CCchUiNotifConnectionHandler::IsConnectionMethodSimilarL - IN" );
|
|
375 |
|
|
376 |
TBool returnVal = EFalse;
|
|
377 |
TUint32 bearerType = iCmManagerExt.GetConnectionMethodInfoIntL(
|
|
378 |
aIapId, CMManager::ECmBearerType );
|
|
379 |
if ( bearerType == iCmManagerExt.GetConnectionMethodInfoIntL(
|
|
380 |
aIapIdToCompare, CMManager::ECmBearerType ) )
|
|
381 |
{
|
|
382 |
HBufC* buffer = NULL;
|
|
383 |
HBufC* bufferToCompare = NULL;
|
|
384 |
|
|
385 |
switch( bearerType )
|
|
386 |
{
|
|
387 |
case KUidWlanBearerType:
|
|
388 |
CCHUIDEBUG( "IsConnectionMethodSimilarL - KUidWlanBearerType" );
|
|
389 |
buffer = iCmManagerExt.GetConnectionMethodInfoStringL(
|
|
390 |
aIapId, CMManager::EWlanSSID );
|
|
391 |
CCHUIDEBUG( "GetConnectionMethodInfoStringL - aIapId EWlanSSID OUT" );
|
|
392 |
CleanupStack::PushL( buffer );
|
|
393 |
bufferToCompare = iCmManagerExt.GetConnectionMethodInfoStringL(
|
|
394 |
aIapIdToCompare, CMManager::EWlanSSID );
|
|
395 |
if ( buffer->Compare( *bufferToCompare ) == 0 )
|
|
396 |
{
|
|
397 |
returnVal = ETrue;
|
|
398 |
}
|
|
399 |
CleanupStack::PopAndDestroy( buffer );
|
|
400 |
delete bufferToCompare;
|
|
401 |
bufferToCompare = NULL;
|
|
402 |
break;
|
|
403 |
case KUidPacketDataBearerType:
|
|
404 |
CCHUIDEBUG( "IsConnectionMethodSimilarL - KUidPacketDataBearerType" );
|
|
405 |
buffer = iCmManagerExt.GetConnectionMethodInfoStringL(
|
|
406 |
aIapId, CMManager::EPacketDataAPName );
|
|
407 |
CleanupStack::PushL( buffer );
|
|
408 |
bufferToCompare = iCmManagerExt.GetConnectionMethodInfoStringL(
|
|
409 |
aIapIdToCompare, CMManager::EPacketDataAPName );
|
|
410 |
if ( buffer->Compare( *bufferToCompare ) == 0 )
|
|
411 |
{
|
|
412 |
returnVal = ETrue;
|
|
413 |
}
|
|
414 |
CleanupStack::PopAndDestroy( buffer );
|
|
415 |
delete bufferToCompare;
|
|
416 |
bufferToCompare = NULL;
|
|
417 |
break;
|
|
418 |
default:
|
|
419 |
CCHUIDEBUG( "IsConnectionMethodSimilarL - Bearer type unknown" );
|
|
420 |
break;
|
|
421 |
}
|
|
422 |
}
|
|
423 |
CCHUIDEBUG2(
|
|
424 |
"CCchUiNotifConnectionHandler::IsConnectionMethodSimilarL -return = %d", returnVal );
|
|
425 |
|
|
426 |
return returnVal;
|
|
427 |
}
|