1 /* |
1 /* |
2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: CSysApOfflineModeController implementation |
14 * Description: |
15 * |
15 * CSysApOfflineModeController controls the offline mode. |
16 */ |
16 * It turns OFF RF, BT and WLAN when offline mode is enabled and turns them ON when |
|
17 * Offline mode is disabled |
|
18 * |
|
19 */ |
17 |
20 |
18 |
21 |
19 // INCLUDES |
22 // INCLUDES |
20 |
23 |
21 #include "SysApOfflineModeControllerImpl.h" |
24 #include "SysApOfflineModeControllerImpl.h" |
22 #include "SysApAppUi.h" |
25 #include "SysApAppUi.h" |
23 #include "SysAp.hrh" |
26 #include "SysAp.hrh" |
24 #include "DosSvrServices.h" |
27 #include "DosSvrServices.h" |
25 #include "SysApCenRepController.h" |
28 #include "SysApCenRepController.h" |
|
29 #include "sysapcenrepofflinemodeobserver.h" |
26 #include <startupdomainpskeys.h> |
30 #include <startupdomainpskeys.h> |
27 #include <PSVariables.h> |
31 #include <PSVariables.h> |
|
32 #include <wlandevicesettingsinternalcrkeys.h> // For Turning ON/OFF WLAN |
28 |
33 |
29 |
34 |
30 MSysApOfflineModeController* CreateSysApOfflineModeControllerL( CSysApAppUi& aSysApAppUi ) |
35 MSysApOfflineModeController* CreateSysApOfflineModeControllerL( CSysApAppUi& aSysApAppUi ) |
31 { |
36 { |
32 return CSysApOfflineModeController::NewL( aSysApAppUi ); |
37 return CSysApOfflineModeController::NewL( aSysApAppUi ); |
51 // CSysApOfflineModeController::ConstructL() |
56 // CSysApOfflineModeController::ConstructL() |
52 // ---------------------------------------------------------------------------- |
57 // ---------------------------------------------------------------------------- |
53 void CSysApOfflineModeController::ConstructL() |
58 void CSysApOfflineModeController::ConstructL() |
54 { |
59 { |
55 TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL") ) ); |
60 TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL") ) ); |
56 // Check the active profile |
61 |
57 TInt activeProfile( iSysApAppUi.ActiveProfileId() ); |
62 // create an observer for Offline Mode |
58 activeProfile = iSysApAppUi.ActiveProfileId(); |
63 TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL: trying CSysApCenRepOfflineModeObserver::NewL") ) ); |
59 if ( activeProfile == KOfflineModeProfileId ) |
64 iSysApCenRepOfflineModeObserver = CSysApCenRepOfflineModeObserver::NewL(*this ); |
60 { |
65 iOfflineModeActive = iSysApCenRepOfflineModeObserver->IsOffline(); |
61 iOfflineModeActive = ETrue; |
|
62 } |
|
63 } |
66 } |
64 |
67 |
65 // ---------------------------------------------------------------------------- |
68 // ---------------------------------------------------------------------------- |
66 // CSysApOfflineModeController::CSysApOfflineModeController() |
69 // CSysApOfflineModeController::CSysApOfflineModeController() |
67 // ---------------------------------------------------------------------------- |
70 // ---------------------------------------------------------------------------- |
68 CSysApOfflineModeController::CSysApOfflineModeController( CSysApAppUi& aSysApAppUi ) : |
71 CSysApOfflineModeController::CSysApOfflineModeController( CSysApAppUi& aSysApAppUi ) : |
69 iSysApAppUi( aSysApAppUi ), |
72 iSysApAppUi( aSysApAppUi ) |
70 iOfflineModeActive( EFalse ), |
|
71 iDoNotActivateRF( EFalse ) |
|
72 { |
73 { |
73 |
74 |
74 } |
75 } |
75 |
76 |
76 // ---------------------------------------------------------------------------- |
77 // ---------------------------------------------------------------------------- |
77 // CSysApOfflineModeController::~CSysApOfflineModeController() |
78 // CSysApOfflineModeController::~CSysApOfflineModeController() |
78 // ---------------------------------------------------------------------------- |
79 // ---------------------------------------------------------------------------- |
79 |
80 |
80 CSysApOfflineModeController::~CSysApOfflineModeController() |
81 CSysApOfflineModeController::~CSysApOfflineModeController() |
81 { |
82 { |
|
83 delete iSysApCenRepOfflineModeObserver; |
82 } |
84 } |
83 |
85 |
84 // ---------------------------------------------------------------------------- |
86 // ---------------------------------------------------------------------------- |
85 // CSysApOfflineModeController::OfflineModeActive() |
87 // CSysApOfflineModeController::OfflineModeActive() |
86 // ---------------------------------------------------------------------------- |
88 // ---------------------------------------------------------------------------- |
87 |
89 |
88 TBool CSysApOfflineModeController::OfflineModeActive() |
90 TBool CSysApOfflineModeController::OfflineModeActive() |
89 { |
91 { |
|
92 TRACES( RDebug::Print( _L("CSysApOfflineModeController::OfflineModeActive returns %d"), iOfflineModeActive ) ); |
90 return iOfflineModeActive; |
93 return iOfflineModeActive; |
91 } |
94 } |
92 |
95 |
93 // ---------------------------------------------------------------------------- |
96 // ---------------------------------------------------------------------------- |
94 // CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL() |
97 // CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL() |
95 // ---------------------------------------------------------------------------- |
98 // ---------------------------------------------------------------------------- |
96 |
99 |
97 void CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL() |
100 void CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL() |
98 { |
101 { |
99 TRACES( RDebug::Print( _L("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL") ) ); |
102 TRACES( RDebug::Print( _L("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL") ) ); |
|
103 |
100 TInt err ( 0 ); |
104 TInt err ( 0 ); |
101 |
105 |
102 // Set state to starter. Note that if state is same as the current state, then nothing happens. |
106 // Set state to starter. Note that if state is same as the current state, then nothing happens. |
103 err = iSysApAppUi.SetStarterState(RStarterSession::EOffline); |
107 err = iSysApAppUi.SetStarterState(RStarterSession::EOffline); |
104 |
108 |
105 if ( err ) |
109 if ( err ) |
106 { |
110 { |
107 iSysApAppUi.RestoreProfileL( EFalse ); |
|
108 iSysApAppUi.ShowUiNoteL( ECannotActivateOfflineModeNote ); |
111 iSysApAppUi.ShowUiNoteL( ECannotActivateOfflineModeNote ); |
109 } |
112 } |
110 else |
113 else |
111 { |
114 { |
112 iOfflineModeActive = ETrue; |
115 iOfflineModeActive = ETrue; |
117 { |
120 { |
118 err = iSysApAppUi.SetBtPowerState( EFalse ); // Switch BT off |
121 err = iSysApAppUi.SetBtPowerState( EFalse ); // Switch BT off |
119 SetBtActiveBeforeOfflineMode( ETrue ); // Update "BT active" setting |
122 SetBtActiveBeforeOfflineMode( ETrue ); // Update "BT active" setting |
120 TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) ); |
123 TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) ); |
121 } |
124 } |
122 |
125 /* Turn OFF WLAN */ |
123 iSysApAppUi.OfflineModeChangedL(); |
126 TInt err( KErrNone ); |
|
127 CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId ); |
|
128 err = repository->Set(KWlanOnOff, 0); |
|
129 delete repository; |
|
130 if(err) |
|
131 { |
|
132 TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL Could not disable WLAN") ); |
|
133 User::Leave(err); |
|
134 } |
|
135 else |
|
136 { |
|
137 TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL WLAN Disabled" ) ); |
|
138 } |
|
139 |
|
140 iSysApAppUi.OfflineModeChangedL(); |
124 } |
141 } |
125 } |
142 } |
126 |
143 |
127 // ---------------------------------------------------------------------------- |
144 // ---------------------------------------------------------------------------- |
128 // CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL() |
145 // CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL() |
157 err = iSysApAppUi.SetBtPowerState( ETrue ); // Switch BT on |
173 err = iSysApAppUi.SetBtPowerState( ETrue ); // Switch BT on |
158 SetBtActiveBeforeOfflineMode( EFalse ); // Update "BT active" setting |
174 SetBtActiveBeforeOfflineMode( EFalse ); // Update "BT active" setting |
159 TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) ); |
175 TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) ); |
160 } |
176 } |
161 |
177 |
|
178 /* Turn ON WLAN */ |
|
179 TInt err( KErrNone ); |
|
180 CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId ); |
|
181 err = repository->Set(KWlanOnOff, 1); |
|
182 delete repository; |
|
183 if(err) |
|
184 { |
|
185 TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL Could not enable WLAN") ); |
|
186 User::Leave(err); |
|
187 } |
|
188 else |
|
189 { |
|
190 TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL WLAN Enabled") ); |
|
191 } |
|
192 |
162 iSysApAppUi.OfflineModeChangedL(); |
193 iSysApAppUi.OfflineModeChangedL(); |
163 |
194 iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed ); |
164 iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed ); |
195 } |
165 } |
196 } |
166 } |
|
167 |
197 |
168 // ---------------------------------------------------------------------------- |
198 // ---------------------------------------------------------------------------- |
169 // CSysApOfflineModeController::CheckOfflineModeInitialStatusesL() |
199 // CSysApOfflineModeController::CheckOfflineModeInitialStatusesL() |
170 // ---------------------------------------------------------------------------- |
200 // ---------------------------------------------------------------------------- |
171 |
201 |
202 TInt simStatus = iSysApAppUi.StateOfProperty( KPSUidStartup, KPSSimStatus ); |
232 TInt simStatus = iSysApAppUi.StateOfProperty( KPSUidStartup, KPSSimStatus ); |
203 if ( ( !iSysApAppUi.SimSupported() ) || |
233 if ( ( !iSysApAppUi.SimSupported() ) || |
204 ( iSysApAppUi.BtSapEnabled() && simStatus != ESimNotPresent ) || |
234 ( iSysApAppUi.BtSapEnabled() && simStatus != ESimNotPresent ) || |
205 simStatus == ESimUsable ) |
235 simStatus == ESimUsable ) |
206 { |
236 { |
207 iSysApAppUi.ShowQueryL( ESysApLeaveOfflineModeQuery ); |
237 TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check PASSED") ); |
|
238 SwitchFromOfflineToOnlineModeL(); |
208 } |
239 } |
209 else |
240 else |
210 { |
241 { |
|
242 TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check FALIED" ) ); |
211 iSysApAppUi.ShowUiNoteL( EInsertSimNote ); |
243 iSysApAppUi.ShowUiNoteL( EInsertSimNote ); |
212 } |
244 } |
213 } |
245 } |
214 |
246 |
215 // ---------------------------------------------------------------------------- |
247 // ---------------------------------------------------------------------------- |