34
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Helper for online/offline state handling
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <NetworkHandlingProxy.h>
|
|
20 |
#include <CNWSession.h>
|
|
21 |
#include <MProfileEngine.h>
|
|
22 |
#include <CProfileChangeNotifyHandler.h>
|
|
23 |
#include <ai3xmlui.rsg>
|
|
24 |
#include <AknQueryDialog.h>
|
|
25 |
#include <AknGlobalNote.h>
|
|
26 |
#include <StringLoader.h>
|
|
27 |
#include <cmmanagerkeys.h>
|
|
28 |
#include <AknGlobalConfirmationQuery.h>
|
|
29 |
#include <StringLoader.h> // StringLoader
|
|
30 |
#include <AknQueryDialog.h>
|
|
31 |
#include <ai3xmlui.rsg>
|
|
32 |
// User includes
|
|
33 |
#include <aifwstatehandler.h>
|
|
34 |
#include <aifwdefs.h>
|
|
35 |
#include <activeidle2domaincrkeys.h>
|
|
36 |
#include <hspublisherinfo.h>
|
|
37 |
#include "onlineofflinehelper.h"
|
|
38 |
#include "xmluicontroller.h"
|
|
39 |
#include "appui.h"
|
|
40 |
#include "ai3.hrh"
|
|
41 |
#include "globalqueryhandler.h"
|
|
42 |
|
|
43 |
// Constants
|
|
44 |
const TInt KOfflineProfileId( 5 );
|
|
45 |
|
|
46 |
using namespace AiXmlUiController;
|
|
47 |
|
|
48 |
#ifdef HS_NETWORK_MONITOR
|
|
49 |
#include <flogger.h>
|
|
50 |
_LIT( KLogFolder,"xnnetwork" );
|
|
51 |
_LIT( KLogDom, "networksettings.log" );
|
|
52 |
|
|
53 |
#define _LOG1( a ) RFileLogger::Write( \
|
|
54 |
KLogFolder, KLogDom, EFileLoggingModeAppend, ( a ) );
|
|
55 |
#define _LOG2( a, b ) RFileLogger::WriteFormat( \
|
|
56 |
KLogFolder, KLogDom, EFileLoggingModeAppend, ( a ), ( b ) )
|
|
57 |
#else
|
|
58 |
#define _LOG1
|
|
59 |
#define _LOG2
|
|
60 |
#endif
|
|
61 |
|
|
62 |
_LIT( KDisConnected, "disconnected");
|
|
63 |
_LIT( KConnected, "connected");
|
|
64 |
|
|
65 |
// ============================ LOCAL FUNCTIONS ==============================
|
|
66 |
|
|
67 |
// ============================ MEMBER FUNCTIONS =============================
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// COnlineOfflineHelper::NewL
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
COnlineOfflineHelper* COnlineOfflineHelper::NewL( CXmlUiController& aUiCtl )
|
|
73 |
{
|
|
74 |
COnlineOfflineHelper* self = new ( ELeave )COnlineOfflineHelper( aUiCtl );
|
|
75 |
CleanupStack::PushL( self );
|
|
76 |
self->ConstructL();
|
|
77 |
CleanupStack::Pop( self );
|
|
78 |
return self;
|
|
79 |
}
|
|
80 |
|
|
81 |
// ----------------------------------------------------------------------------
|
|
82 |
// COnlineOfflineHelper::COnlineOfflineHelper
|
|
83 |
// ----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
COnlineOfflineHelper::COnlineOfflineHelper( CXmlUiController& aUiCtl )
|
|
86 |
: iUiCtl( aUiCtl )
|
|
87 |
{
|
|
88 |
}
|
|
89 |
|
|
90 |
// ----------------------------------------------------------------------------
|
|
91 |
// COnlineOfflineHelper::ConstructL
|
|
92 |
// ----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void COnlineOfflineHelper::ConstructL()
|
|
95 |
{
|
|
96 |
//Create network handling engine session.
|
|
97 |
iSession = CreateL( *this, iInfo );
|
|
98 |
|
|
99 |
iHandler = CProfileChangeNotifyHandler::NewL( this );
|
|
100 |
|
|
101 |
MProfileEngine* engine( CreateProfileEngineL() );
|
|
102 |
|
|
103 |
if( engine->ActiveProfileId() == KOfflineProfileId )
|
|
104 |
{
|
|
105 |
iFlags.Set( EOfflineProfile );
|
|
106 |
}
|
|
107 |
|
|
108 |
engine->Release();
|
|
109 |
|
|
110 |
TInt value( 0 );
|
|
111 |
|
|
112 |
if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone )
|
|
113 |
{
|
|
114 |
if( value && iFlags.IsClear( EOfflineProfile ) )
|
|
115 |
{
|
|
116 |
iFlags.Set( EOnline );
|
|
117 |
}
|
|
118 |
}
|
|
119 |
|
|
120 |
// Update state manager
|
|
121 |
SetOnline( iFlags.IsSet( EOnline ) );
|
|
122 |
|
|
123 |
iCurrentNwStatus = ENWRegistrationUnknown;
|
|
124 |
iHomeNetwork = KErrNotFound;
|
|
125 |
iRoamingNetwork = KErrNotFound;
|
|
126 |
|
|
127 |
iNwSettingObserver = CCenRepObserver::NewL( this );
|
|
128 |
|
|
129 |
iGlobalQueryHandler = CGlobalQueryHandler::NewL(iUiCtl);
|
|
130 |
iGlobalConfirmationQuery = CAknGlobalConfirmationQuery::NewL();
|
|
131 |
|
|
132 |
}
|
|
133 |
|
|
134 |
// ----------------------------------------------------------------------------
|
|
135 |
// COnlineOfflineHelper::~COnlineOfflineHelper
|
|
136 |
// ----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
COnlineOfflineHelper::~COnlineOfflineHelper()
|
|
139 |
{
|
|
140 |
delete iHandler;
|
|
141 |
delete iSession;
|
|
142 |
delete iNwSettingObserver;
|
|
143 |
delete iGlobalQueryHandler;
|
|
144 |
delete iGlobalConfirmationQuery;
|
|
145 |
}
|
|
146 |
|
|
147 |
// ----------------------------------------------------------------------------
|
|
148 |
// COnlineOfflineHelper::CurrentCellularDataUsageChangedL
|
|
149 |
// ----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
void COnlineOfflineHelper::CurrentCellularDataUsageChangedL(const TInt aValue)
|
|
152 |
{
|
|
153 |
if ( iCurrentNwStatus == ENWRegisteredOnHomeNetwork )
|
|
154 |
{
|
|
155 |
iHomeNetwork = aValue;
|
|
156 |
}
|
|
157 |
else if ( iCurrentNwStatus == ENWRegisteredRoaming )
|
|
158 |
{
|
|
159 |
iRoamingNetwork = aValue;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// ----------------------------------------------------------------------------
|
|
164 |
// COnlineOfflineHelper::ShowOnlineItem
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
TBool COnlineOfflineHelper::ShowOnlineItem() const
|
|
168 |
{
|
|
169 |
TInt value ( KErrNotFound );
|
|
170 |
if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone )
|
|
171 |
{
|
|
172 |
return ( !value );
|
|
173 |
}
|
|
174 |
return EFalse;
|
|
175 |
}
|
|
176 |
|
|
177 |
// ----------------------------------------------------------------------------
|
|
178 |
// COnlineOfflineHelper::ShowOfflineItem
|
|
179 |
// ----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
TBool COnlineOfflineHelper::ShowOfflineItem() const
|
|
182 |
{
|
|
183 |
TInt value ( KErrNotFound );
|
|
184 |
if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone )
|
|
185 |
{
|
|
186 |
return ( value );
|
|
187 |
}
|
|
188 |
return EFalse;
|
|
189 |
}
|
|
190 |
|
|
191 |
// ----------------------------------------------------------------------------
|
|
192 |
// COnlineOfflineHelper::ProcessOnlineStateL
|
|
193 |
// ----------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
void COnlineOfflineHelper::ProcessOnlineStateL( TBool aOnline )
|
|
196 |
{
|
|
197 |
// User has selected online/offline item from menu
|
|
198 |
// Don't show R_YES_NO_HS_ONLINE query as user selected online
|
|
199 |
if ( aOnline )
|
|
200 |
{
|
|
201 |
iFlags.Set( EOnline );
|
|
202 |
if ( iCurrentNwStatus == ENWRegisteredRoaming )
|
|
203 |
{
|
|
204 |
// When user allready is in foreing network and sets
|
|
205 |
// HS online we want to disable automatic offline setting and not
|
|
206 |
// show note QTN_HS_AUTOMATIC_OFFLINE
|
|
207 |
iFlags.Set( ERoamingShown );
|
|
208 |
}
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
iFlags.Clear( EOnline );
|
|
213 |
}
|
|
214 |
|
|
215 |
SetOnline( aOnline );
|
|
216 |
}
|
|
217 |
|
|
218 |
// ----------------------------------------------------------------------------
|
|
219 |
// COnlineOfflineHelper::SetOnline
|
|
220 |
// ----------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
void COnlineOfflineHelper::SetOnline( TBool aOnline )
|
|
223 |
{
|
|
224 |
// Save state
|
|
225 |
iUiCtl.SettingsRepository().Set( KAIWebStatus, aOnline );
|
|
226 |
|
|
227 |
// Run state change.
|
|
228 |
iUiCtl.FwStateHandler()->ChangePluginState(
|
|
229 |
aOnline ? EAiFwOnline : EAiFwOffline );
|
|
230 |
}
|
|
231 |
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
// COnlineOfflineHelper::HandleNetworkMessage
|
|
234 |
// ----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void COnlineOfflineHelper::HandleNetworkMessage( const TNWMessages aMessage )
|
|
237 |
{
|
|
238 |
if ( HasNetworkInfoChanged( aMessage ) )
|
|
239 |
{
|
|
240 |
// Interpret new nw state
|
|
241 |
TRAP_IGNORE( InterpretNWMessageL( aMessage, iInfo ) );
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
// ----------------------------------------------------------------------------
|
|
246 |
// COnlineOfflineHelper::InterpretNWMessage
|
|
247 |
// ----------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
void COnlineOfflineHelper::InterpretNWMessageL( const TNWMessages aMessage,
|
|
250 |
const TNWInfo aNWInfo )
|
|
251 |
{
|
|
252 |
switch ( aMessage )
|
|
253 |
{
|
|
254 |
case MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange:
|
|
255 |
case MNWMessageObserver::ENWMessageCurrentHomeZoneMessage:
|
|
256 |
{
|
|
257 |
switch ( aNWInfo.iRegistrationStatus )
|
|
258 |
{
|
|
259 |
case ENWRegisteredRoaming:
|
|
260 |
_LOG1( _L(" Roaming Network Activated "));
|
|
261 |
iCurrentNwStatus = aNWInfo.iRegistrationStatus;
|
|
262 |
CurrentNetworkSetting();
|
|
263 |
if( ( iRoamingNetwork == ECmCellularDataUsageConfirm
|
|
264 |
|| iRoamingNetwork == ECmCellularDataUsageDisabled )
|
|
265 |
&& iFlags.IsSet( EOnline )
|
|
266 |
&& iFlags.IsClear( ERoamingShown ) )
|
|
267 |
{
|
|
268 |
// Process to offline state.
|
|
269 |
// Don't change the user selection.
|
|
270 |
SetOnline( EFalse );
|
|
271 |
// Show roaming notification
|
|
272 |
CAknGlobalNote* note = CAknGlobalNote::NewLC();
|
|
273 |
HBufC* msg( StringLoader::LoadLC(
|
|
274 |
R_QTN_HS_AUTOMATIC_OFFLINE ) );
|
|
275 |
note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);
|
|
276 |
note->ShowNoteL( EAknGlobalInformationNote, *msg );
|
|
277 |
CleanupStack::PopAndDestroy( 2, note ); // msg
|
|
278 |
|
|
279 |
// set roming shown flag. We want to show
|
|
280 |
// romign note only once while user stays in foreign
|
|
281 |
// network. If user sets the HS to online this note is
|
|
282 |
// not showed again and HS will stay online in foreign
|
|
283 |
// network.
|
|
284 |
iFlags.Set( ERoamingShown );
|
|
285 |
}
|
|
286 |
break;
|
|
287 |
|
|
288 |
case ENWRegisteredOnHomeNetwork:
|
|
289 |
_LOG1( _L(" Home Network Activated "));
|
|
290 |
if ( iFlags.IsSet( ERoamingShown ) )
|
|
291 |
{
|
|
292 |
// Clear ERoamingShown when user returns to home
|
|
293 |
// network.
|
|
294 |
iFlags.Clear( ERoamingShown );
|
|
295 |
}
|
|
296 |
|
|
297 |
iCurrentNwStatus = aNWInfo.iRegistrationStatus;
|
|
298 |
CurrentNetworkSetting();
|
|
299 |
if( iHomeNetwork == ECmCellularDataUsageAutomatic )
|
|
300 |
{
|
|
301 |
// Reset to user selection
|
|
302 |
SetOnline( iFlags.IsSet( EOnline ) );
|
|
303 |
}
|
|
304 |
break;
|
|
305 |
|
|
306 |
default:
|
|
307 |
// unknown state
|
|
308 |
iCurrentNwStatus = ENWRegistrationUnknown;
|
|
309 |
break;
|
|
310 |
}
|
|
311 |
}
|
|
312 |
}
|
|
313 |
}
|
|
314 |
|
|
315 |
// ----------------------------------------------------------------------------
|
|
316 |
// COnlineOfflineHelper::HandleNetworkError
|
|
317 |
// ----------------------------------------------------------------------------
|
|
318 |
//
|
|
319 |
void COnlineOfflineHelper::HandleNetworkError( const TNWOperation aOperation,
|
|
320 |
TInt /*aErrorCode*/ )
|
|
321 |
{
|
|
322 |
switch ( aOperation )
|
|
323 |
{
|
|
324 |
case MNWMessageObserver::ENWGetNetworkProviderName:
|
|
325 |
iReceivedMessageFlags |= ENetworkProviderNameReceived;
|
|
326 |
iReceivedMessageFlags &= ~ENetworkProviderNameOk;
|
|
327 |
iInfo.iNPName.Zero();
|
|
328 |
break;
|
|
329 |
case MNWMessageObserver::ENWGetProgrammableOperatorName:
|
|
330 |
iReceivedMessageFlags |= EProgrammableOperatorInfoReceived;
|
|
331 |
iReceivedMessageFlags &= ~EProgrammableOperatorInfoReceivedOk;
|
|
332 |
iInfo.iOperatorNameInfo.iName.Zero();
|
|
333 |
break;
|
|
334 |
case MNWMessageObserver::ENWGetServiceProviderName:
|
|
335 |
iReceivedMessageFlags |= EServiceProviderNameReceived;
|
|
336 |
iReceivedMessageFlags &= ~EServiceProviderNameOk;
|
|
337 |
iInfo.iServiceProviderNameDisplayReq = RMobilePhone::KDisplaySPNNotRequired;
|
|
338 |
iInfo.iSPName.Zero();
|
|
339 |
iInfo.iPLMNField.Zero();
|
|
340 |
break;
|
|
341 |
default:
|
|
342 |
break;
|
|
343 |
}
|
|
344 |
|
|
345 |
HandleNetworkMessage( TNWMessages( KErrGeneral ) );
|
|
346 |
}
|
|
347 |
|
|
348 |
// ----------------------------------------------------------------------------
|
|
349 |
// COnlineOfflineHelper::HasNetworkInfoChanged
|
|
350 |
// ----------------------------------------------------------------------------
|
|
351 |
//
|
|
352 |
TBool COnlineOfflineHelper::HasNetworkInfoChanged( const TNWMessages aMsg )
|
|
353 |
{
|
|
354 |
TBool result( ETrue );
|
|
355 |
|
|
356 |
// pass through
|
|
357 |
if ( aMsg == MNWMessageObserver::ENWMessageCurrentHomeZoneMessage ||
|
|
358 |
aMsg == MNWMessageObserver::ENWMessageNetworkConnectionFailure ||
|
|
359 |
aMsg == MNWMessageObserver::ENWMessageCurrentCellInfoMessage ||
|
|
360 |
aMsg == MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange )
|
|
361 |
{
|
|
362 |
return result;
|
|
363 |
}
|
|
364 |
|
|
365 |
result = ( iReceivedMessageFlags != iOldReceivedMessageFlags );
|
|
366 |
|
|
367 |
if ( !result )
|
|
368 |
{
|
|
369 |
result = iInfo.iRegistrationStatus != iOldInfo.iRegistrationStatus;
|
|
370 |
}
|
|
371 |
|
|
372 |
iOldReceivedMessageFlags = iReceivedMessageFlags;
|
|
373 |
iOldInfo = iInfo;
|
|
374 |
|
|
375 |
return result;
|
|
376 |
}
|
|
377 |
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
// COnlineOfflineHelper::HandleActiveProfileEventL
|
|
380 |
// ---------------------------------------------------------------------------
|
|
381 |
//
|
|
382 |
void COnlineOfflineHelper::HandleActiveProfileEventL(
|
|
383 |
TProfileEvent aProfileEvent, TInt aProfileId )
|
|
384 |
{
|
|
385 |
//Profile activated or modified.
|
|
386 |
if ( aProfileEvent == EProfileNewActiveProfile )
|
|
387 |
{
|
|
388 |
if( aProfileId == KOfflineProfileId )
|
|
389 |
{
|
|
390 |
iFlags.Set( EOfflineProfile );
|
|
391 |
// Don't change the user selection.
|
|
392 |
SetOnline( EFalse );
|
|
393 |
}
|
|
394 |
else
|
|
395 |
{
|
|
396 |
iFlags.Clear( EOfflineProfile );
|
|
397 |
// Reset to user selection
|
|
398 |
SetOnline( iFlags.IsSet( EOnline ) );
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
delete iHandler;
|
|
403 |
iHandler = NULL;
|
|
404 |
|
|
405 |
iHandler = CProfileChangeNotifyHandler::NewL( this );
|
|
406 |
}
|
|
407 |
|
|
408 |
// ---------------------------------------------------------------------------
|
|
409 |
// COnlineOfflineHelper::CurrentNetworkSetting
|
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
//
|
|
412 |
void COnlineOfflineHelper::CurrentNetworkSetting()
|
|
413 |
{
|
|
414 |
CRepository* repository( NULL );
|
|
415 |
|
|
416 |
TRAP_IGNORE( repository = CRepository::NewL( KCRUidCmManager ) )
|
|
417 |
|
|
418 |
if ( repository )
|
|
419 |
{
|
|
420 |
TInt value( 0 );
|
|
421 |
TInt err( repository->Get( KCurrentCellularDataUsage, value ) );
|
|
422 |
|
|
423 |
if ( err == KErrNone )
|
|
424 |
{
|
|
425 |
if ( iCurrentNwStatus == ENWRegisteredRoaming )
|
|
426 |
{
|
|
427 |
iRoamingNetwork = value;
|
|
428 |
_LOG2( _L("Roaming Network Setting <%d>"), value );
|
|
429 |
}
|
|
430 |
else if ( iCurrentNwStatus == ENWRegisteredOnHomeNetwork )
|
|
431 |
{
|
|
432 |
iHomeNetwork = value;
|
|
433 |
_LOG2( _L("Home Network Setting <%d>"), value );
|
|
434 |
}
|
|
435 |
}
|
|
436 |
}
|
|
437 |
delete repository;
|
|
438 |
}
|
|
439 |
|
|
440 |
// ---------------------------------------------------------------------------
|
|
441 |
// COnlineOfflineHelper::HandleConnectionQueryL
|
|
442 |
// ---------------------------------------------------------------------------
|
|
443 |
//
|
|
444 |
void COnlineOfflineHelper::HandleConnectionQueryL( const TDesC& aConnection)
|
|
445 |
{
|
|
446 |
if ( aConnection == KDisConnected() && ShowOfflineItem() )
|
|
447 |
{
|
|
448 |
ShowGlobalQueryL(R_QTN_HS_DISABLE_NETWORK, EFalse );
|
|
449 |
}
|
|
450 |
else if ( aConnection == KConnected() && ShowOnlineItem() )
|
|
451 |
{
|
|
452 |
ShowGlobalQueryL(R_QTN_HS_SWITCH_ONLINE, ETrue );
|
|
453 |
}
|
|
454 |
}
|
|
455 |
|
|
456 |
// ---------------------------------------------------------------------------
|
|
457 |
// COnlineOfflineHelper::ShowGlobalQueryL
|
|
458 |
// ---------------------------------------------------------------------------
|
|
459 |
//
|
|
460 |
void COnlineOfflineHelper::ShowGlobalQueryL( TInt aResourceId, TBool aSetOnline )
|
|
461 |
{
|
|
462 |
if ( !iGlobalQueryHandler->IsActive() )
|
|
463 |
{
|
|
464 |
HBufC* confirmationText = StringLoader::LoadLC(aResourceId);
|
|
465 |
iGlobalConfirmationQuery->ShowConfirmationQueryL(
|
|
466 |
iGlobalQueryHandler->iStatus,
|
|
467 |
*confirmationText,
|
|
468 |
R_AVKON_SOFTKEYS_YES_NO);
|
|
469 |
iGlobalQueryHandler->SetOnlineParamAndActivate(aSetOnline);
|
|
470 |
CleanupStack::PopAndDestroy(); //confirmationText
|
|
471 |
}
|
|
472 |
}
|
|
473 |
|
|
474 |
// End of file
|