36 */ |
38 */ |
37 |
39 |
38 // External function prototypes |
40 // External function prototypes |
39 |
41 |
40 // Local constants |
42 // Local constants |
41 /** Default value for Scan Interval. */ |
43 |
42 const int KDefaultScanInterval = 5; |
44 //! Device Power Saving Mode setting key |
43 |
45 static const XQSettingsKey devicePowerSavingKey( |
|
46 XQSettingsKey::TargetCentralRepository, |
|
47 KCRUidPowerSaveMode.iUid, |
|
48 KPsmCurrentMode); |
|
49 |
44 // ======== MEMBER FUNCTIONS ======== |
50 // ======== MEMBER FUNCTIONS ======== |
45 |
51 |
46 /*! |
52 /*! |
47 Constructor. |
53 Constructor. |
48 */ |
54 */ |
49 |
55 |
50 WlanSettings::WlanSettings() : |
56 WlanSettings::WlanSettings() : |
51 QObject(), mPsmKeyValue(0) |
57 QObject(), |
52 { |
58 mSettingsManager(new XQSettingsManager(this)), |
53 |
59 mDevicePowerSavingMode(0), |
54 OstTraceFunctionEntry1(WLANSETTINGS_WLANSETTINGS_ENTRY, this); |
60 mDevicePowerSavingModeUpToDate(false) |
55 OstTraceFunctionExit1(WLANSETTINGS_WLANSETTINGS_EXIT, this); |
61 { |
|
62 OstTraceFunctionEntry0( WLANSETTINGS_WLANSETTINGS_ENTRY ); |
|
63 OstTraceFunctionExit0( WLANSETTINGS_WLANSETTINGS_EXIT ); |
56 } |
64 } |
57 |
65 |
58 /*! |
66 /*! |
59 Destructor. |
67 Destructor. |
60 */ |
68 */ |
61 |
69 |
62 WlanSettings::~WlanSettings() |
70 WlanSettings::~WlanSettings() |
63 { |
71 { |
64 OstTraceFunctionEntry1(DUP1_WLANSETTINGS_WLANSETTINGS_ENTRY, this); |
72 OstTraceFunctionEntry0( DUP1_WLANSETTINGS_WLANSETTINGS_ENTRY ); |
65 |
73 |
66 delete mImpl; |
74 delete d_ptr; |
67 |
75 |
68 OstTraceFunctionExit1(DUP1_WLANSETTINGS_WLANSETTINGS_EXIT, this); |
76 OstTraceFunctionExit0( DUP1_WLANSETTINGS_WLANSETTINGS_EXIT ); |
69 } |
77 } |
70 |
78 |
71 /*! |
79 /*! |
72 Creates the CWlanSettingsImpl object for reading/writing settings. |
80 Creates the CWlanSettingsImpl object for reading/writing settings. |
73 \return Error code. |
81 \return Error code. |
74 */ |
82 */ |
75 |
83 |
76 int WlanSettings::init() |
84 int WlanSettings::init() |
77 { |
85 { |
78 OstTraceFunctionEntry1(WLANSETTINGS_INIT_ENTRY, this); |
86 OstTraceFunctionEntry0( WLANSETTINGS_INIT_ENTRY ); |
79 |
87 |
80 readPsmKey(); |
88 // Listen for changes in the key value |
81 |
89 bool connectStatus = connect( |
82 TRAPD(error,(mImpl = CWlanSettingsPrivate::NewL(mPsmKeyValue))); |
90 mSettingsManager, |
83 |
91 SIGNAL(valueChanged(XQSettingsKey, QVariant)), |
84 OstTraceFunctionExit1(WLANSETTINGS_INIT_EXIT, this); |
92 this, |
85 return error; |
93 SLOT(devicePowerSavingKeyChanged())); |
86 } |
94 Q_ASSERT(connectStatus); |
87 |
95 mSettingsManager->startMonitoring(devicePowerSavingKey); |
88 |
96 |
89 void WlanSettings::readPsmKey() |
97 TRAPD(error,(d_ptr = CWlanSettingsPrivate::NewL(this))); |
90 { |
98 |
91 OstTraceFunctionEntry1(WLANSETTINGS_READPSMKEY_ENTRY, this); |
99 OstTraceFunctionExit0( WLANSETTINGS_INIT_EXIT ); |
92 |
100 return error; |
93 QScopedPointer<XQSettingsManager> settingsManager; |
101 } |
94 settingsManager.reset(new XQSettingsManager()); |
102 |
95 |
103 /*! |
96 XQSettingsKey key(XQSettingsKey::TargetCentralRepository, |
104 Reads the value of the Device Power Saving Mode setting. |
97 KCRUidPowerSaveMode.iUid, KPsmCurrentMode); |
105 */ |
98 |
106 |
99 QVariant keyValue = settingsManager->readItemValue(key); |
107 void WlanSettings::readDevicePowerSavingKey() |
100 |
108 { |
101 mPsmKeyValue = keyValue.toInt(); |
109 OstTraceFunctionEntry0( WLANSETTINGS_READDEVICEPOWERSAVINGKEY_ENTRY ); |
102 |
110 |
103 OstTraceFunctionExit1(WLANSETTINGS_READPSMKEY_EXIT, this); |
111 mDevicePowerSavingMode = |
|
112 mSettingsManager->readItemValue(devicePowerSavingKey).toInt(); |
|
113 |
|
114 mDevicePowerSavingModeUpToDate = true; |
|
115 |
|
116 OstTrace1( |
|
117 TRACE_NORMAL, |
|
118 WLANSETTINGS_READDEVICEPOWERSAVINGKEY, |
|
119 "WlanSettings::readDevicePowerSavingKey;powerSaving=%d", |
|
120 mDevicePowerSavingMode ); |
|
121 |
|
122 OstTraceFunctionExit0( WLANSETTINGS_READDEVICEPOWERSAVINGKEY_EXIT ); |
|
123 } |
|
124 |
|
125 /*! |
|
126 Slot for handling updates in the Device Power Saving Mode setting. |
|
127 */ |
|
128 |
|
129 void WlanSettings::devicePowerSavingKeyChanged() |
|
130 { |
|
131 OstTraceFunctionEntry0( WLANSETTINGS_DEVICEPOWERSAVINGKEYCHANGED_ENTRY ); |
|
132 |
|
133 // Remember that we need to read the setting value again before |
|
134 // using it, and notify UI of the change. |
|
135 mDevicePowerSavingModeUpToDate = false; |
|
136 emit devicePowerSavingUpdated(); |
|
137 |
|
138 OstTraceFunctionExit0( WLANSETTINGS_DEVICEPOWERSAVINGKEYCHANGED_EXIT ); |
104 } |
139 } |
105 |
140 |
106 /*! |
141 /*! |
107 Reads the WLAN setting values. |
142 Reads the WLAN setting values. |
108 \return Error code. |
143 \return Error code. |
109 */ |
144 */ |
110 |
145 |
111 int WlanSettings::loadSettings() |
146 int WlanSettings::loadSettings() |
112 { |
147 { |
113 OstTraceFunctionEntry1(WLANSETTINGS_LOADSETTINGS_ENTRY, this); |
148 OstTraceFunctionEntry0( WLANSETTINGS_LOADSETTINGS_ENTRY ); |
114 |
149 |
115 TRAPD(error, mImpl->LoadDBSettingsL()); |
150 TRAPD(error, d_ptr->LoadDBSettingsL()); |
116 |
151 |
117 OstTraceFunctionExit1(WLANSETTINGS_LOADSETTINGS_EXIT, this); |
152 OstTrace1( |
|
153 TRACE_NORMAL, |
|
154 WLANSETTINGS_LOADSETTINGS, |
|
155 "WlanSettings::loadSettings;error=%d", |
|
156 error ); |
|
157 |
|
158 OstTraceFunctionExit0( WLANSETTINGS_LOADSETTINGS_EXIT ); |
118 return error; |
159 return error; |
119 } |
160 } |
120 |
161 |
121 /*! |
162 /*! |
122 Function to get the scan network type. |
163 Function to get the scan network type. |
123 \return ScanNetworkType which is automatic or user-defined. |
164 \return ScanNetworkType which is automatic or user-defined. |
124 */ |
165 */ |
125 |
166 |
126 WlanSettings::ScanNetworkType WlanSettings::scanNetworkType() |
167 WlanSettings::ScanNetworkType WlanSettings::scanNetworkType() |
127 { |
168 { |
128 OstTraceFunctionEntry1(WLANSETTINGS_SCANNETWORKTYPE_ENTRY, this); |
169 OstTraceFunctionEntry0( WLANSETTINGS_SCANNETWORKTYPE_ENTRY ); |
129 |
170 |
130 ScanNetworkType scanType; |
171 ScanNetworkType scanType; |
131 uint scanInterval = mImpl->ScanInterval(); |
172 if (d_ptr->ScanInterval() == ScanNetworkAuto) { |
132 |
|
133 if (scanInterval == KWlanSettingsScanNetworkAuto) { |
|
134 scanType = EScanNetworkAuto; |
173 scanType = EScanNetworkAuto; |
135 } |
174 } else { |
136 else { |
|
137 scanType = EScanNetworkUserDefined; |
175 scanType = EScanNetworkUserDefined; |
138 } |
176 } |
139 |
177 |
140 OstTraceFunctionExit1(WLANSETTINGS_SCANNETWORKTYPE_EXIT, this); |
178 OstTrace1( |
|
179 TRACE_NORMAL, |
|
180 WLANSETTINGS_SCANNETWORKTYPE, |
|
181 "WlanSettings::scanNetworkType;scanType=%d", |
|
182 scanType ); |
|
183 |
|
184 OstTraceFunctionExit0( WLANSETTINGS_SCANNETWORKTYPE_EXIT ); |
141 return scanType; |
185 return scanType; |
142 } |
186 } |
143 |
187 |
144 /*! |
188 /*! |
145 Function to get the scan interval. |
189 Function to get the scan interval. |
146 \return Scan interval in minutes. |
190 \return Scan interval in minutes. |
147 */ |
191 */ |
148 |
192 |
149 uint WlanSettings::scanInterval() |
193 uint WlanSettings::scanInterval() |
150 { |
194 { |
151 OstTraceFunctionEntry1(WLANSETTINGS_SCANINTERVAL_ENTRY, this); |
195 OstTraceFunctionEntry0( WLANSETTINGS_SCANINTERVAL_ENTRY ); |
152 |
196 |
153 uint scanInterval = mImpl->ScanInterval(); |
197 uint scanInterval = d_ptr->ScanInterval(); |
154 |
198 |
155 if (scanInterval == KWlanSettingsScanNetworkAuto) { |
199 OstTrace1( |
156 scanInterval = KDefaultScanInterval; |
200 TRACE_NORMAL, |
157 } |
201 WLANSETTINGS_SCANINTERVAL, |
158 |
202 "WlanSettings::scanInterval;scanInterval=%u", |
159 OstTraceFunctionExit1(WLANSETTINGS_SCANINTERVAL_EXIT, this); |
203 scanInterval ); |
|
204 |
|
205 OstTraceFunctionExit0( WLANSETTINGS_SCANINTERVAL_EXIT ); |
160 return scanInterval; |
206 return scanInterval; |
161 } |
207 } |
162 |
208 |
163 /*! |
209 /*! |
164 Function to get Power Saving Option. |
210 Function to get Wlan Power Saving Option. |
165 \return True if Power Saving option is enabled, otherwise False. |
211 \return True if Power Saving option is enabled, otherwise False. |
166 */ |
212 */ |
167 |
213 |
168 int WlanSettings::isPowerSavingEnabled() const |
214 bool WlanSettings::isWlanPowerSavingEnabled() const |
169 { |
215 { |
170 return mImpl->PowerSaving(); |
216 OstTraceFunctionEntry0( WLANSETTINGS_ISWLANPOWERSAVINGENABLED_ENTRY ); |
|
217 OstTraceFunctionExit0( WLANSETTINGS_ISWLANPOWERSAVINGENABLED_EXIT ); |
|
218 return d_ptr->PowerSaving(); |
171 } |
219 } |
172 |
220 |
173 /*! |
221 /*! |
174 Function to set Power Saving Option. |
222 Function to set Power Saving Option. |
175 \param powerSavingOption True to enable or false to disable power saving option. |
223 \param powerSavingOption True to enable or false to disable power saving option. |
176 \return Error code. |
224 \return Error code. |
177 */ |
225 */ |
178 |
226 |
179 int WlanSettings::setWlanPowerSaving(int powerSavingOption) |
227 int WlanSettings::setWlanPowerSaving(int powerSavingOption) |
180 { |
228 { |
181 OstTraceFunctionEntry1(WLANSETTINGS_SETWLANPOWERSAVING_ENTRY, this); |
229 OstTraceFunctionEntry0( WLANSETTINGS_SETWLANPOWERSAVING_ENTRY ); |
182 |
230 |
183 mImpl->SetPowerSaving(powerSavingOption); |
231 d_ptr->SetPowerSaving(powerSavingOption); |
184 TRAPD(error, mImpl->SaveDBSettingsL(CWlanSettingsPrivate::EWlanPowerSaving)); |
232 TRAPD(error, d_ptr->SaveDBSettingsL(CWlanSettingsPrivate::EWlanPowerSaving)); |
185 |
233 |
186 OstTraceFunctionExit1(WLANSETTINGS_SETWLANPOWERSAVING_EXIT, this); |
234 OstTraceFunctionExit0( WLANSETTINGS_SETWLANPOWERSAVING_EXIT ); |
187 return error; |
235 return error; |
188 } |
236 } |
189 |
237 |
190 /*! |
238 /*! |
191 Function to set Scan interval. |
239 Function to set Scan interval. |
193 \return Error code. |
241 \return Error code. |
194 */ |
242 */ |
195 |
243 |
196 int WlanSettings::setWlanScanInterval(uint scanInterval) |
244 int WlanSettings::setWlanScanInterval(uint scanInterval) |
197 { |
245 { |
198 OstTraceFunctionEntry1(WLANSETTINGS_SETWLANSCANINTERVAL_ENTRY, this); |
246 OstTraceFunctionEntry0( WLANSETTINGS_SETWLANSCANINTERVAL_ENTRY ); |
199 |
247 |
200 mImpl->SetScanInterval(scanInterval); |
248 d_ptr->SetScanInterval(scanInterval); |
201 TRAPD(error, mImpl->SaveDBSettingsL(CWlanSettingsPrivate::EWlanScanInterval)); |
249 TRAPD(error, d_ptr->SaveDBSettingsL(CWlanSettingsPrivate::EWlanScanInterval)); |
202 |
250 |
203 OstTraceFunctionExit1(WLANSETTINGS_SETWLANSCANINTERVAL_EXIT, this); |
251 OstTraceFunctionExit0( WLANSETTINGS_SETWLANSCANINTERVAL_EXIT ); |
204 return error; |
252 return error; |
205 } |
253 } |
206 |
254 |
207 /*! |
255 /*! |
208 Function to get Join WLAN networks option. |
256 Function to get Join WLAN networks option. |
209 \return 0 for Known, 1 for Manual. |
257 \return 0 for Known, 1 for Manual. |
210 */ |
258 */ |
211 |
259 |
212 int WlanSettings::joinWlanMode() const |
260 int WlanSettings::joinWlanMode() const |
213 { |
261 { |
214 return mImpl->JoinWlanMode(); |
262 OstTraceFunctionEntry0( WLANSETTINGS_JOINWLANMODE_ENTRY ); |
|
263 OstTraceFunctionExit0( WLANSETTINGS_JOINWLANMODE_EXIT ); |
|
264 return d_ptr->JoinWlanMode(); |
215 } |
265 } |
216 |
266 |
217 /*! |
267 /*! |
218 Function to set Join WLAN networks option. |
268 Function to set Join WLAN networks option. |
219 \param mode 0 for Known, 1 for Manual. |
269 \param mode 0 for Known, 1 for Manual. |
220 \return Error code. |
270 \return Error code. |
221 */ |
271 */ |
222 |
272 |
223 int WlanSettings::setJoinWlanMode(int mode) |
273 int WlanSettings::setJoinWlanMode(int mode) |
224 { |
274 { |
225 OstTraceFunctionEntry1(WLANSETTINGS_SETJOINWLANMODE_ENTRY, this); |
275 OstTraceFunctionEntry0( WLANSETTINGS_SETJOINWLANMODE_ENTRY ); |
226 |
276 |
227 TRAPD(error, mImpl->SaveJoinWlanSettingL(mode)); |
277 TRAPD(error, d_ptr->SaveJoinWlanSettingL(mode)); |
228 |
278 |
229 OstTraceFunctionExit1(WLANSETTINGS_SETJOINWLANMODE_EXIT, this); |
279 OstTraceFunctionExit0( WLANSETTINGS_SETJOINWLANMODE_EXIT ); |
230 return error; |
280 return error; |
231 } |
281 } |
232 |
282 |
233 /*! |
283 /*! |
234 Function to get Power Saving status of the device. |
284 Function to get Power Saving status of the device. |
235 \return True if Power Saving is enabled. |
285 \return True if Power Saving is enabled. |
236 */ |
286 */ |
237 |
287 |
238 int WlanSettings::isPsmEnabled() const |
288 bool WlanSettings::isDevicePowerSavingEnabled() |
239 { |
289 { |
240 return mImpl->IsPsmEnabled(); |
290 OstTraceFunctionEntry0( WLANSETTINGS_ISDEVICEPOWERSAVINGENABLED_ENTRY ); |
241 } |
291 |
|
292 if (!mDevicePowerSavingModeUpToDate) { |
|
293 readDevicePowerSavingKey(); |
|
294 } |
|
295 if (mDevicePowerSavingMode == EPsmsrvModeNormal) { |
|
296 OstTraceFunctionExit0( WLANSETTINGS_ISDEVICEPOWERSAVINGENABLED_EXIT ); |
|
297 return false; |
|
298 } else { |
|
299 OstTraceFunctionExit0( DUP1_WLANSETTINGS_ISDEVICEPOWERSAVINGENABLED_EXIT ); |
|
300 return true; |
|
301 } |
|
302 } |