|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 */ |
|
16 |
|
17 // System includes |
|
18 |
|
19 #include <HbGlobal> |
|
20 |
|
21 // User includes |
|
22 |
|
23 #include "wlanqtutils.h" |
|
24 #include "wlanqtutilswlaniap.h" |
|
25 |
|
26 #include "wlanstatusinfo.h" |
|
27 |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "wlanstatusinfoTraces.h" |
|
31 #endif |
|
32 |
|
33 /*! |
|
34 \class WlanStatusInfo |
|
35 \brief Class for maintaining and updating the WLAN status for the WLAN |
|
36 Status Control Panel Plugin. |
|
37 |
|
38 */ |
|
39 |
|
40 // External function prototypes |
|
41 |
|
42 // Local constants |
|
43 |
|
44 // ======== LOCAL FUNCTIONS ======== |
|
45 |
|
46 // ======== MEMBER FUNCTIONS ======== |
|
47 |
|
48 /*! |
|
49 Constructor. |
|
50 */ |
|
51 |
|
52 WlanStatusInfo::WlanStatusInfo(QObject *parent) : |
|
53 QObject(parent), |
|
54 mWlanQtUtils(new WlanQtUtils()), |
|
55 mStatusText(""), |
|
56 mStatus(WlanStatusOff) |
|
57 { |
|
58 OstTraceFunctionEntry1(WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); |
|
59 |
|
60 // Listen for WLAN ON/OFF switching |
|
61 bool connectStatus = connect( |
|
62 mWlanQtUtils, |
|
63 SIGNAL(masterWlanStatus(bool)), |
|
64 this, |
|
65 SLOT(updateStatus())); |
|
66 Q_ASSERT(connectStatus == true); |
|
67 |
|
68 // Listen for WLAN connection statuses |
|
69 connectStatus = connect( |
|
70 mWlanQtUtils, |
|
71 SIGNAL(wlanNetworkOpened(int)), |
|
72 this, |
|
73 SLOT(updateStatus())); |
|
74 Q_ASSERT(connectStatus == true); |
|
75 connectStatus = connect( |
|
76 mWlanQtUtils, |
|
77 SIGNAL(wlanNetworkClosed(int)), |
|
78 this, |
|
79 SLOT(updateStatus())); |
|
80 Q_ASSERT(connectStatus == true); |
|
81 |
|
82 // Set initial status |
|
83 updateStatus(); |
|
84 |
|
85 OstTraceFunctionExit1(WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); |
|
86 } |
|
87 |
|
88 /*! |
|
89 Destructor. |
|
90 */ |
|
91 |
|
92 WlanStatusInfo::~WlanStatusInfo() |
|
93 { |
|
94 OstTraceFunctionEntry1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); |
|
95 |
|
96 delete mWlanQtUtils; |
|
97 |
|
98 OstTraceFunctionExit1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); |
|
99 } |
|
100 |
|
101 /*! |
|
102 Function for getting current WLAN status value (WlanStatusInfo::WlanStatus*). |
|
103 */ |
|
104 |
|
105 int WlanStatusInfo::status() |
|
106 { |
|
107 OstTraceFunctionEntry1(WLANSTATUSINFO_STATUS_ENTRY, this); |
|
108 OstTraceFunctionExit1(WLANSTATUSINFO_STATUS_EXIT, this); |
|
109 return mStatus; |
|
110 } |
|
111 |
|
112 /*! |
|
113 Returns the current WLAN status text. |
|
114 */ |
|
115 |
|
116 QString WlanStatusInfo::statusText() |
|
117 { |
|
118 OstTraceFunctionEntry1(WLANSTATUSINFO_STATUSTEXT_ENTRY, this); |
|
119 OstTraceFunctionExit1(WLANSTATUSINFO_STATUSTEXT_EXIT, this); |
|
120 return mStatusText; |
|
121 } |
|
122 |
|
123 /*! |
|
124 Slot used for updating the WLAN status. |
|
125 */ |
|
126 |
|
127 void WlanStatusInfo::updateStatus() |
|
128 { |
|
129 OstTraceFunctionEntry1(WLANSTATUSINFO_UPDATESTATUS_ENTRY, this); |
|
130 |
|
131 // Backup old status to detect changes |
|
132 QString oldStatusText = mStatusText; |
|
133 int connectedIapId = mWlanQtUtils->connectedWlanId(); |
|
134 |
|
135 // Figure out current WLAN status |
|
136 if (mWlanQtUtils->masterWlan() == false) { |
|
137 // WLAN is switched OFF. |
|
138 mStatus = WlanStatusOff; |
|
139 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_off"); |
|
140 } else if (connectedIapId != WlanQtUtilsInvalidIapId) { |
|
141 mStatus = WlanStatusConnected; |
|
142 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_connected_to_1") |
|
143 .arg(mWlanQtUtils->iap(connectedIapId)->name()); |
|
144 } else { |
|
145 mStatus = WlanStatusIdle; |
|
146 mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_wlan_is_on"); |
|
147 } |
|
148 |
|
149 // Inform about update if the status really changed. |
|
150 if (oldStatusText != mStatusText) { |
|
151 emit statusUpdated(); |
|
152 } |
|
153 |
|
154 OstTraceFunctionExit1(WLANSTATUSINFO_UPDATESTATUS_EXIT, this); |
|
155 } |