50 */ |
63 */ |
51 |
64 |
52 WlanStatusInfo::WlanStatusInfo(QObject *parent) : |
65 WlanStatusInfo::WlanStatusInfo(QObject *parent) : |
53 QObject(parent), |
66 QObject(parent), |
54 mWlanQtUtils(new WlanQtUtils()), |
67 mWlanQtUtils(new WlanQtUtils()), |
|
68 mSettingsManager(new XQSettingsManager(this)), |
55 mStatusText(""), |
69 mStatusText(""), |
56 mStatus(WlanStatusOff) |
70 mStatus(WlanStatusOff) |
57 { |
71 { |
58 OstTraceFunctionEntry1(WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); |
72 OstTraceFunctionEntry0(WLANSTATUSINFO_WLANSTATUSINFO_ENTRY); |
59 |
73 |
60 // Listen for WLAN ON/OFF switching |
74 // Listen for WLAN ON/OFF switching |
61 bool connectStatus = connect( |
75 bool connectStatus = connect( |
62 mWlanQtUtils, |
76 mSettingsManager, |
63 SIGNAL(masterWlanStatus(bool)), |
77 SIGNAL(valueChanged(XQSettingsKey, QVariant)), |
64 this, |
78 this, |
65 SLOT(updateStatus())); |
79 SLOT(updateStatus())); |
66 Q_ASSERT(connectStatus == true); |
80 Q_ASSERT(connectStatus); |
|
81 mSettingsManager->startMonitoring(masterWlanKey); |
|
82 mSettingsManager->startMonitoring(wlanForceKey); |
67 |
83 |
68 // Listen for WLAN connection statuses |
84 // Listen for WLAN connection statuses |
69 connectStatus = connect( |
85 connectStatus = connect( |
70 mWlanQtUtils, |
86 mWlanQtUtils, |
71 SIGNAL(wlanNetworkOpened(int)), |
87 SIGNAL(wlanNetworkOpened(int)), |
72 this, |
88 this, |
73 SLOT(updateStatus())); |
89 SLOT(updateStatus())); |
74 Q_ASSERT(connectStatus == true); |
90 Q_ASSERT(connectStatus == true); |
75 connectStatus = connect( |
91 connectStatus = connect( |
76 mWlanQtUtils, |
92 mWlanQtUtils, |
77 SIGNAL(wlanNetworkClosed(int)), |
93 SIGNAL(wlanNetworkClosed(int, int)), |
78 this, |
94 this, |
79 SLOT(updateStatus())); |
95 SLOT(updateStatus())); |
80 Q_ASSERT(connectStatus == true); |
96 Q_ASSERT(connectStatus == true); |
81 |
97 |
82 // Set initial status |
98 // Set initial status |
83 updateStatus(); |
99 updateStatus(); |
84 |
100 |
85 OstTraceFunctionExit1(WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); |
101 OstTraceFunctionExit0(WLANSTATUSINFO_WLANSTATUSINFO_EXIT); |
86 } |
102 } |
87 |
103 |
88 /*! |
104 /*! |
89 Destructor. |
105 Destructor. |
90 */ |
106 */ |
91 |
107 |
92 WlanStatusInfo::~WlanStatusInfo() |
108 WlanStatusInfo::~WlanStatusInfo() |
93 { |
109 { |
94 OstTraceFunctionEntry1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); |
110 OstTraceFunctionEntry0(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_ENTRY); |
95 |
111 |
96 delete mWlanQtUtils; |
112 delete mWlanQtUtils; |
97 |
113 |
98 OstTraceFunctionExit1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); |
114 OstTraceFunctionExit0(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_EXIT); |
99 } |
115 } |
100 |
116 |
101 /*! |
117 /*! |
102 Function for getting current WLAN status value (WlanStatusInfo::WlanStatus*). |
118 Function for getting current WLAN status value (WlanStatusInfo::WlanStatus*). |
103 */ |
119 */ |
104 |
120 |
105 int WlanStatusInfo::status() |
121 int WlanStatusInfo::status() const |
106 { |
122 { |
107 OstTraceFunctionEntry1(WLANSTATUSINFO_STATUS_ENTRY, this); |
123 OstTraceFunctionEntry0(WLANSTATUSINFO_STATUS_ENTRY); |
108 OstTraceFunctionExit1(WLANSTATUSINFO_STATUS_EXIT, this); |
124 OstTraceFunctionExit0(WLANSTATUSINFO_STATUS_EXIT); |
109 return mStatus; |
125 return mStatus; |
110 } |
126 } |
111 |
127 |
112 /*! |
128 /*! |
113 Returns the current WLAN status text. |
129 Returns the current WLAN status text. |
114 */ |
130 */ |
115 |
131 |
116 QString WlanStatusInfo::statusText() |
132 QString WlanStatusInfo::statusText() const |
117 { |
133 { |
118 OstTraceFunctionEntry1(WLANSTATUSINFO_STATUSTEXT_ENTRY, this); |
134 OstTraceFunctionEntry0(WLANSTATUSINFO_STATUSTEXT_ENTRY); |
119 OstTraceFunctionExit1(WLANSTATUSINFO_STATUSTEXT_EXIT, this); |
135 OstTraceFunctionExit0(WLANSTATUSINFO_STATUSTEXT_EXIT); |
120 return mStatusText; |
136 return mStatusText; |
|
137 } |
|
138 |
|
139 /*! |
|
140 Function for checking if WLAN is ON. |
|
141 WLAN is enabled if the WLAN OnOff key is true and the force disable |
|
142 wlan key is false. |
|
143 |
|
144 @return Returns true if WLAN is ON. |
|
145 */ |
|
146 |
|
147 bool WlanStatusInfo::isWlanOn() const |
|
148 { |
|
149 OstTraceFunctionEntry0(WLANSTATUSINFO_ISWLANON_ENTRY); |
|
150 |
|
151 bool wlanOn = mSettingsManager->readItemValue(masterWlanKey).toBool(); |
|
152 bool forcedOff = mSettingsManager->readItemValue(wlanForceKey).toBool(); |
|
153 |
|
154 OstTraceExt2( |
|
155 TRACE_NORMAL, |
|
156 WLANSTATUSINFO_ISWLANON, |
|
157 "WlanStatusInfo::isWlanOn;wlanOn=%hhu;forcedOff=%hhu", |
|
158 wlanOn, |
|
159 forcedOff); |
|
160 |
|
161 OstTraceFunctionExit0(WLANSTATUSINFO_ISWLANON_EXIT); |
|
162 return wlanOn && !forcedOff; |
121 } |
163 } |
122 |
164 |
123 /*! |
165 /*! |
124 Slot used for updating the WLAN status. |
166 Slot used for updating the WLAN status. |
125 */ |
167 */ |
126 |
168 |
127 void WlanStatusInfo::updateStatus() |
169 void WlanStatusInfo::updateStatus() |
128 { |
170 { |
129 OstTraceFunctionEntry1(WLANSTATUSINFO_UPDATESTATUS_ENTRY, this); |
171 OstTraceFunctionEntry0(WLANSTATUSINFO_UPDATESTATUS_ENTRY); |
130 |
172 |
131 // Backup old status to detect changes |
173 // Backup old status to detect changes |
132 QString oldStatusText = mStatusText; |
174 QString oldStatusText = mStatusText; |
133 int connectedIapId = mWlanQtUtils->connectedWlanId(); |
175 |
134 |
|
135 // Figure out current WLAN status |
176 // Figure out current WLAN status |
136 if (mWlanQtUtils->masterWlan() == false) { |
177 if (!isWlanOn()) { |
137 // WLAN is switched OFF. |
178 // WLAN is switched OFF. |
138 mStatus = WlanStatusOff; |
179 mStatus = WlanStatusOff; |
139 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_off"); |
180 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_off"); |
140 } else if (connectedIapId != WlanQtUtilsInvalidIapId) { |
181 } else if (mWlanQtUtils->connectionStatus() == WlanQtUtils::ConnStatusConnected) { |
141 mStatus = WlanStatusConnected; |
182 mStatus = WlanStatusConnected; |
142 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_connected_to_1") |
183 mStatusText = mWlanQtUtils->iapName(mWlanQtUtils->activeIap()); |
143 .arg(mWlanQtUtils->iap(connectedIapId)->name()); |
|
144 } else { |
184 } else { |
145 mStatus = WlanStatusIdle; |
185 mStatus = WlanStatusIdle; |
146 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_wlan_is_on"); |
186 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_wlan_is_on"); |
147 } |
187 } |
148 |
188 |
149 // Inform about update if the status really changed. |
189 // Inform about update if the status really changed. |
150 if (oldStatusText != mStatusText) { |
190 if (oldStatusText != mStatusText) { |
151 emit statusUpdated(); |
191 emit statusUpdated(); |
152 } |
192 } |
153 |
193 |
154 OstTraceFunctionExit1(WLANSTATUSINFO_UPDATESTATUS_EXIT, this); |
194 OstTraceFunctionExit0(WLANSTATUSINFO_UPDATESTATUS_EXIT); |
155 } |
195 } |