18 // System includes |
18 // System includes |
19 #include <NetworkHandlingProxy.h> |
19 #include <NetworkHandlingProxy.h> |
20 #include <CNWSession.h> |
20 #include <CNWSession.h> |
21 #include <MProfileEngine.h> |
21 #include <MProfileEngine.h> |
22 #include <CProfileChangeNotifyHandler.h> |
22 #include <CProfileChangeNotifyHandler.h> |
23 #include <aifweventhandler.h> |
|
24 #include <ai3xmlui.rsg> |
23 #include <ai3xmlui.rsg> |
25 #include <AknQueryDialog.h> |
24 #include <AknQueryDialog.h> |
26 #include <AknGlobalNote.h> |
25 #include <AknGlobalNote.h> |
27 #include <StringLoader.h> |
26 #include <StringLoader.h> |
28 |
27 #include <cmmanagerkeys.h> |
|
28 #include <AknGlobalConfirmationQuery.h> |
|
29 #include <StringLoader.h> // StringLoader |
|
30 #include <AknQueryDialog.h> |
|
31 #include <ai3xmlui.rsg> |
29 // User includes |
32 // User includes |
|
33 #include <aifwstatehandler.h> |
|
34 #include <aifwdefs.h> |
30 #include <activeidle2domaincrkeys.h> |
35 #include <activeidle2domaincrkeys.h> |
|
36 #include <hspublisherinfo.h> |
31 #include "onlineofflinehelper.h" |
37 #include "onlineofflinehelper.h" |
32 #include "xmluicontroller.h" |
38 #include "xmluicontroller.h" |
33 #include "appui.h" |
39 #include "appui.h" |
|
40 #include "ai3.hrh" |
|
41 #include "globalqueryhandler.h" |
34 |
42 |
35 // Constants |
43 // Constants |
36 const TInt KOfflineProfileId( 5 ); |
44 const TInt KOfflineProfileId( 5 ); |
37 |
45 |
38 using namespace AiXmlUiController; |
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"); |
39 |
64 |
40 // ============================ LOCAL FUNCTIONS ============================== |
65 // ============================ LOCAL FUNCTIONS ============================== |
41 |
66 |
42 // ============================ MEMBER FUNCTIONS ============================= |
67 // ============================ MEMBER FUNCTIONS ============================= |
43 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
90 { |
115 { |
91 iFlags.Set( EOnline ); |
116 iFlags.Set( EOnline ); |
92 } |
117 } |
93 } |
118 } |
94 |
119 |
95 // Update repository |
120 // Update state manager |
96 iUiCtl.SettingsRepository().Set( KAIWebStatus, iFlags.IsSet( EOnline ) ); |
121 SetOnline( iFlags.IsSet( EOnline ) ); |
97 |
122 |
98 iCurrentNwStatus = ENWRegistrationUnknown; |
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 |
99 } |
132 } |
100 |
133 |
101 // ---------------------------------------------------------------------------- |
134 // ---------------------------------------------------------------------------- |
102 // COnlineOfflineHelper::~COnlineOfflineHelper |
135 // COnlineOfflineHelper::~COnlineOfflineHelper |
103 // ---------------------------------------------------------------------------- |
136 // ---------------------------------------------------------------------------- |
104 // |
137 // |
105 COnlineOfflineHelper::~COnlineOfflineHelper() |
138 COnlineOfflineHelper::~COnlineOfflineHelper() |
106 { |
139 { |
107 delete iHandler; |
140 delete iHandler; |
108 delete iSession; |
141 delete iSession; |
109 // Whether the user choice EOnline should be stored in cenrep ? |
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 } |
110 } |
161 } |
111 |
162 |
112 // ---------------------------------------------------------------------------- |
163 // ---------------------------------------------------------------------------- |
113 // COnlineOfflineHelper::ShowOnlineItem |
164 // COnlineOfflineHelper::ShowOnlineItem |
114 // ---------------------------------------------------------------------------- |
165 // ---------------------------------------------------------------------------- |
115 // |
166 // |
116 TBool COnlineOfflineHelper::ShowOnlineItem() const |
167 TBool COnlineOfflineHelper::ShowOnlineItem() const |
117 { |
168 { |
118 if ( iFlags.IsSet( EUtilizeOnline ) ) |
169 if ( iUiCtl.FwStateHandler()->OnlineStateInUse() ) |
119 { |
170 { |
120 TInt value ( KErrNotFound ); |
171 TInt value ( KErrNotFound ); |
121 if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone ) |
172 if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone ) |
122 { |
173 { |
123 return ( !value ); |
174 return ( !value ); |
130 // COnlineOfflineHelper::ShowOfflineItem |
181 // COnlineOfflineHelper::ShowOfflineItem |
131 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
132 // |
183 // |
133 TBool COnlineOfflineHelper::ShowOfflineItem() const |
184 TBool COnlineOfflineHelper::ShowOfflineItem() const |
134 { |
185 { |
135 if ( iFlags.IsSet( EUtilizeOnline ) ) |
186 if ( iUiCtl.FwStateHandler()->OnlineStateInUse() ) |
136 { |
187 { |
137 TInt value ( KErrNotFound ); |
188 TInt value ( KErrNotFound ); |
138 if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone ) |
189 if ( iUiCtl.SettingsRepository().Get( KAIWebStatus, value ) == KErrNone ) |
139 { |
190 { |
140 return ( value ); |
191 return ( value ); |
145 |
196 |
146 // ---------------------------------------------------------------------------- |
197 // ---------------------------------------------------------------------------- |
147 // COnlineOfflineHelper::ProcessOnlineStateL |
198 // COnlineOfflineHelper::ProcessOnlineStateL |
148 // ---------------------------------------------------------------------------- |
199 // ---------------------------------------------------------------------------- |
149 // |
200 // |
150 void COnlineOfflineHelper::ProcessOnlineStateL( |
|
151 RPointerArray< CXnNodeAppIf >& aList ) |
|
152 { |
|
153 _LIT( KOnlineOffline, "online_offline" ); |
|
154 |
|
155 iFlags.Clear( EUtilizeOnline ); |
|
156 |
|
157 // Check if data plugins are using online_offline |
|
158 for ( TInt i = 0; i < aList.Count(); i++ ) |
|
159 { |
|
160 TAiPublisherInfo info; |
|
161 |
|
162 iUiCtl.PublisherInfoL( *aList[i], info ); |
|
163 |
|
164 if( iUiCtl.FwEventHandler()->HasMenuItemL( info, KOnlineOffline() ) ) |
|
165 { |
|
166 iFlags.Set( EUtilizeOnline ); |
|
167 break; |
|
168 } |
|
169 } |
|
170 |
|
171 if( iFlags.IsSet( EUtilizeOnline ) ) |
|
172 { |
|
173 TInt value( 0 ); |
|
174 iUiCtl.SettingsRepository().Get( KAIWebStatus, value ); |
|
175 |
|
176 if ( value ) |
|
177 { |
|
178 // Switch to online |
|
179 SetOnlineL( ETrue ); |
|
180 } |
|
181 else |
|
182 { |
|
183 // Switch to offline |
|
184 SetOnlineL( EFalse ); |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 // ---------------------------------------------------------------------------- |
|
190 // COnlineOfflineHelper::ProcessOnlineStateL |
|
191 // ---------------------------------------------------------------------------- |
|
192 // |
|
193 void COnlineOfflineHelper::ProcessOnlineStateL( TBool aOnline ) |
201 void COnlineOfflineHelper::ProcessOnlineStateL( TBool aOnline ) |
194 { |
202 { |
195 // User has selected online/offline item from menu |
203 // User has selected online/offline item from menu |
196 if( iFlags.IsSet( EUtilizeOnline ) ) |
204 if( iUiCtl.FwStateHandler()->OnlineStateInUse() ) |
197 { |
205 { |
198 // Don't show R_YES_NO_HS_ONLINE query as user selected online |
206 // Don't show R_YES_NO_HS_ONLINE query as user selected online |
199 if (aOnline ) |
207 if ( aOnline ) |
200 { |
208 { |
201 iFlags.Set( EOnline ); |
209 iFlags.Set( EOnline ); |
202 // Save state |
|
203 iUiCtl.SettingsRepository().Set( KAIWebStatus, ETrue ); |
|
204 // Run state change. |
|
205 iUiCtl.FwEventHandler()->ProcessStateChange( EAifwOnline ); |
|
206 } |
210 } |
207 else |
211 else |
208 { |
212 { |
209 iFlags.Clear( EOnline ); |
213 iFlags.Clear( EOnline ); |
210 // Save state |
214 } |
211 iUiCtl.SettingsRepository().Set( KAIWebStatus, EFalse ); |
215 |
212 // Run state change. |
216 SetOnline( aOnline ); |
213 iUiCtl.FwEventHandler()->ProcessStateChange( EAifwOffline ); |
|
214 } |
|
215 } |
217 } |
216 } |
218 } |
217 |
219 |
218 // ---------------------------------------------------------------------------- |
220 // ---------------------------------------------------------------------------- |
219 // COnlineOfflineHelper::SetOnline |
221 // COnlineOfflineHelper::SetOnline |
220 // ---------------------------------------------------------------------------- |
222 // ---------------------------------------------------------------------------- |
221 // |
223 // |
222 void COnlineOfflineHelper::SetOnlineL( TBool aOnline ) |
224 void COnlineOfflineHelper::SetOnline( TBool aOnline ) |
223 { |
225 { |
224 |
|
225 // Save state |
226 // Save state |
226 iUiCtl.SettingsRepository().Set( KAIWebStatus, aOnline ); |
227 iUiCtl.SettingsRepository().Set( KAIWebStatus, aOnline ); |
227 |
228 |
228 if( aOnline ) |
229 // Run state change. |
229 { |
230 iUiCtl.FwStateHandler()->ChangePluginState( |
230 // Run state change. |
231 aOnline ? EAiFwOnline : EAiFwOffline ); |
231 iUiCtl.FwEventHandler()->ProcessStateChange( EAifwOnline ); |
|
232 } |
|
233 else |
|
234 { |
|
235 // Run state change. |
|
236 iUiCtl.FwEventHandler()->ProcessStateChange( EAifwOffline ); |
|
237 } |
|
238 } |
232 } |
239 |
233 |
240 // ---------------------------------------------------------------------------- |
234 // ---------------------------------------------------------------------------- |
241 // COnlineOfflineHelper::HandleNetworkMessage |
235 // COnlineOfflineHelper::HandleNetworkMessage |
242 // ---------------------------------------------------------------------------- |
236 // ---------------------------------------------------------------------------- |
263 case MNWMessageObserver::ENWMessageCurrentHomeZoneMessage: |
257 case MNWMessageObserver::ENWMessageCurrentHomeZoneMessage: |
264 { |
258 { |
265 switch ( aNWInfo.iRegistrationStatus ) |
259 switch ( aNWInfo.iRegistrationStatus ) |
266 { |
260 { |
267 case ENWRegisteredRoaming: |
261 case ENWRegisteredRoaming: |
268 if( iFlags.IsSet( EOnline ) ) |
262 _LOG1( _L(" Roaming Network Activated ")); |
|
263 iCurrentNwStatus = aNWInfo.iRegistrationStatus; |
|
264 CurrentNetworkSetting(); |
|
265 if( ( iRoamingNetwork == ECmCellularDataUsageConfirm |
|
266 || iRoamingNetwork == ECmCellularDataUsageDisabled ) |
|
267 && iFlags.IsSet( EOnline ) ) |
269 { |
268 { |
270 // Process to offline state. |
269 // Process to offline state. |
271 // Don't change the user selection. |
270 // Don't change the user selection. |
272 SetOnlineL ( EFalse ); |
271 SetOnline( EFalse ); |
273 // Show roaming notification |
272 // Show roaming notification |
274 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
273 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
275 HBufC* msg( StringLoader::LoadLC( R_QTN_HS_AUTOMATIC_OFFLINE ) ); |
274 HBufC* msg( StringLoader::LoadLC( R_QTN_HS_AUTOMATIC_OFFLINE ) ); |
276 note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
275 note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
277 note->ShowNoteL( EAknGlobalInformationNote, *msg ); |
276 note->ShowNoteL( EAknGlobalInformationNote, *msg ); |
278 CleanupStack::PopAndDestroy( 2, note ); // msg |
277 CleanupStack::PopAndDestroy( 2, note ); // msg |
279 } |
278 } |
280 |
279 break; |
|
280 |
|
281 case ENWRegisteredOnHomeNetwork: |
|
282 _LOG1( _L(" Home Network Activated ")); |
281 iCurrentNwStatus = aNWInfo.iRegistrationStatus; |
283 iCurrentNwStatus = aNWInfo.iRegistrationStatus; |
282 break; |
284 CurrentNetworkSetting(); |
283 case ENWRegisteredOnHomeNetwork: |
285 if( iHomeNetwork == ECmCellularDataUsageAutomatic ) |
284 // Reset to user selection |
286 { |
285 SetOnlineL(iFlags.IsSet( EOnline ) ); |
287 // Reset to user selection |
286 |
288 SetOnline( iFlags.IsSet( EOnline ) ); |
287 iCurrentNwStatus = aNWInfo.iRegistrationStatus; |
289 } |
288 break; |
290 break; |
|
291 |
289 default: |
292 default: |
290 // unknown state |
293 // unknown state |
291 iCurrentNwStatus = ENWRegistrationUnknown; |
294 iCurrentNwStatus = ENWRegistrationUnknown; |
292 break; |
295 break; |
293 } |
296 } |
370 { |
373 { |
371 if( aProfileId == KOfflineProfileId ) |
374 if( aProfileId == KOfflineProfileId ) |
372 { |
375 { |
373 iFlags.Set( EOfflineProfile ); |
376 iFlags.Set( EOfflineProfile ); |
374 // Don't change the user selection. |
377 // Don't change the user selection. |
375 SetOnlineL( EFalse ); |
378 SetOnline( EFalse ); |
376 } |
379 } |
377 else |
380 else |
378 { |
381 { |
379 iFlags.Clear( EOfflineProfile ); |
382 iFlags.Clear( EOfflineProfile ); |
380 // Reset to user selection |
383 // Reset to user selection |
381 SetOnlineL(iFlags.IsSet( EOnline ) ); |
384 SetOnline( iFlags.IsSet( EOnline ) ); |
382 } |
385 } |
383 } |
386 } |
384 |
387 |
385 delete iHandler; |
388 delete iHandler; |
386 iHandler = NULL; |
389 iHandler = NULL; |
387 |
390 |
388 iHandler = CProfileChangeNotifyHandler::NewL( this ); |
391 iHandler = CProfileChangeNotifyHandler::NewL( this ); |
389 } |
392 } |
390 |
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // COnlineOfflineHelper::CurrentNetworkSetting |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void COnlineOfflineHelper::CurrentNetworkSetting() |
|
399 { |
|
400 CRepository* repository( NULL ); |
|
401 |
|
402 TRAP_IGNORE( repository = CRepository::NewL( KCRUidCmManager ) ) |
|
403 |
|
404 if ( repository ) |
|
405 { |
|
406 TInt value( 0 ); |
|
407 TInt err( repository->Get( KCurrentCellularDataUsage, value ) ); |
|
408 |
|
409 if ( err == KErrNone ) |
|
410 { |
|
411 if ( iCurrentNwStatus == ENWRegisteredRoaming ) |
|
412 { |
|
413 iRoamingNetwork = value; |
|
414 _LOG2( _L("Roaming Network Setting <%d>"), value ); |
|
415 } |
|
416 else if ( iCurrentNwStatus == ENWRegisteredOnHomeNetwork ) |
|
417 { |
|
418 iHomeNetwork = value; |
|
419 _LOG2( _L("Home Network Setting <%d>"), value ); |
|
420 } |
|
421 } |
|
422 } |
|
423 delete repository; |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // COnlineOfflineHelper::HandleConnectionQueryL |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 void COnlineOfflineHelper::HandleConnectionQueryL( const TDesC& aConnection) |
|
431 { |
|
432 if ( aConnection == KDisConnected() ) |
|
433 { |
|
434 ShowGlobalQueryL(R_QTN_HS_DISABLE_NETWORK, EFalse ); |
|
435 } |
|
436 else if ( aConnection == KConnected() ) |
|
437 { |
|
438 ShowGlobalQueryL(R_QTN_HS_SWITCH_ONLINE, ETrue ); |
|
439 } |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // COnlineOfflineHelper::ShowGlobalQueryL |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void COnlineOfflineHelper::ShowGlobalQueryL( TInt aResourceId, TBool aSetOnline ) |
|
447 { |
|
448 if ( !iGlobalQueryHandler->IsActive() ) |
|
449 { |
|
450 HBufC* confirmationText = StringLoader::LoadLC(aResourceId); |
|
451 iGlobalConfirmationQuery->ShowConfirmationQueryL( |
|
452 iGlobalQueryHandler->iStatus, |
|
453 *confirmationText, |
|
454 R_AVKON_SOFTKEYS_YES_NO); |
|
455 iGlobalQueryHandler->SetOnlineParamAndActivate(aSetOnline); |
|
456 CleanupStack::PopAndDestroy(); //confirmationText |
|
457 } |
|
458 } |
|
459 |
391 // End of file |
460 // End of file |
392 |
|