|
1 /* |
|
2 * Copyright (c) 2009-2010 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 * WLAN Entry plugin item data implementation. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 #include <HbApplication> |
|
21 #include <HbLabel> |
|
22 #include <HbDataForm> |
|
23 |
|
24 #ifdef WLANENTRYPLUGIN_SERVICETRACES |
|
25 #include <xqservicelog.h> |
|
26 #endif |
|
27 #include <xqaiwdecl.h> |
|
28 #include <xqaiwdeclplat.h> |
|
29 |
|
30 #include <cpitemdatahelper.h> |
|
31 #include <cpbasesettingview.h> |
|
32 |
|
33 // User includes |
|
34 |
|
35 #include "wlanstatusinfo.h" |
|
36 #include "cpwlanentryitemdata.h" |
|
37 |
|
38 #include "OstTraceDefinitions.h" |
|
39 #ifdef OST_TRACE_COMPILER_IN_USE |
|
40 #include "cpwlanentryitemdataTraces.h" |
|
41 #endif |
|
42 |
|
43 /*! |
|
44 \class CpWlanEntryItemData |
|
45 \brief Implementation of WLAN Status Plugin entry item data. |
|
46 |
|
47 */ |
|
48 |
|
49 // External function prototypes |
|
50 |
|
51 // Local constants |
|
52 |
|
53 // ======== LOCAL FUNCTIONS ======== |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 /*! |
|
58 Constructor. |
|
59 |
|
60 @param[in,out] itemDataHelper Control Panel item data helper object. |
|
61 */ |
|
62 |
|
63 CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) : |
|
64 CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")), |
|
65 mWlanStatusInfo(new WlanStatusInfo(this)), |
|
66 mProcessing(false), |
|
67 mRequest(0) |
|
68 { |
|
69 OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY); |
|
70 |
|
71 // Listen for WLAN status updates |
|
72 bool connectStatus = connect( |
|
73 mWlanStatusInfo, |
|
74 SIGNAL(statusUpdated()), |
|
75 this, |
|
76 SLOT(statusUpdate())); |
|
77 Q_ASSERT(connectStatus); |
|
78 |
|
79 // Update to show initial WLAN status. |
|
80 statusUpdate(); |
|
81 |
|
82 OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT); |
|
83 } |
|
84 |
|
85 /*! |
|
86 Destructor. |
|
87 */ |
|
88 |
|
89 CpWlanEntryItemData::~CpWlanEntryItemData() |
|
90 { |
|
91 OstTraceFunctionEntry0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY); |
|
92 delete mRequest; |
|
93 OstTraceFunctionExit0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT); |
|
94 } |
|
95 |
|
96 void CpWlanEntryItemData::handleOk(const QVariant &result) |
|
97 { |
|
98 OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_HANDLEOK_ENTRY); |
|
99 Q_UNUSED(result); |
|
100 mProcessing = false; |
|
101 |
|
102 delete mRequest; |
|
103 mRequest = NULL; |
|
104 |
|
105 #ifdef WLANENTRYPLUGIN_SERVICETRACES |
|
106 XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::handleOk() service request completed OK"); |
|
107 #endif |
|
108 OstTraceFunctionExit0(CPWLANENTRYITEMDATA_HANDLEOK_EXIT); |
|
109 } |
|
110 |
|
111 |
|
112 void CpWlanEntryItemData::handleError(int errorCode, const QString& errorMessage) |
|
113 { |
|
114 OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_HANDLEERROR_ENTRY); |
|
115 TPtrC tmp(errorMessage.utf16(),errorMessage.length()); |
|
116 OstTraceExt2(TRACE_FLOW, CPWLANENTRYITEMDATA_HANDLEERROR, "CpWlanEntryItemData::handleError;errorCode=%d;errorMessage=%S", errorCode, tmp); |
|
117 |
|
118 mProcessing = false; |
|
119 |
|
120 delete mRequest; |
|
121 mRequest = NULL; |
|
122 |
|
123 #ifdef WLANENTRYPLUGIN_SERVICETRACES |
|
124 XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::handleOk() service request completed with error"); |
|
125 #endif |
|
126 OstTraceFunctionExit0(CPWLANENTRYITEMDATA_HANDLEERROR_EXIT); |
|
127 } |
|
128 |
|
129 |
|
130 /*! |
|
131 Function for handling the entry item click. |
|
132 */ |
|
133 |
|
134 CpBaseSettingView *CpWlanEntryItemData::createSettingView() const |
|
135 { |
|
136 OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY); |
|
137 |
|
138 if (mProcessing) { |
|
139 OstTrace0(TRACE_NORMAL, CPWLANENTRYITEMDATA_CREATESETTINGVIEW, "CpWlanEntryItemData::createSettingView:already processing, return"); |
|
140 return 0; |
|
141 } |
|
142 mProcessing = true; |
|
143 |
|
144 #ifdef WLANENTRYPLUGIN_SERVICETRACES |
|
145 qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); |
|
146 XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView requesting listView()"); |
|
147 #endif |
|
148 |
|
149 // Execute asynchronous WLAN Sniffer list view |
|
150 mRequest = mAiwMgr.create( |
|
151 "wlansniffer", |
|
152 XQI_WLAN_SNIFFER, |
|
153 XQOP_WLAN_SNIFFER, |
|
154 true); |
|
155 |
|
156 // The WLAN Sniffer service must always exist |
|
157 Q_ASSERT(mRequest); |
|
158 |
|
159 // The service is asynchronous & embedded |
|
160 mRequest->setSynchronous(false); |
|
161 |
|
162 // Window title needs to be set to "Control Panel" |
|
163 XQRequestInfo reqInfo; |
|
164 reqInfo.setInfo(XQINFO_KEY_WINDOW_TITLE, hbTrId("txt_cp_title_control_panel")); |
|
165 mRequest->setInfo(reqInfo); |
|
166 |
|
167 connect(mRequest, SIGNAL(requestOk(QVariant)), SLOT( handleOk(QVariant)), Qt::QueuedConnection); |
|
168 connect(mRequest, SIGNAL(requestError(int, QString)), SLOT(handleError(int, QString))); |
|
169 |
|
170 bool status = mRequest->send(); |
|
171 #ifdef WLANENTRYPLUGIN_SERVICETRACES |
|
172 XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request sent"); |
|
173 #endif |
|
174 Q_ASSERT(status); |
|
175 |
|
176 OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT); |
|
177 return 0; |
|
178 } |
|
179 |
|
180 /*! |
|
181 Slot for updating the status shown by the plugin. |
|
182 Updates both the text and icon. |
|
183 */ |
|
184 void CpWlanEntryItemData::statusUpdate() |
|
185 { |
|
186 OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY); |
|
187 |
|
188 // Build icon with (possible) badge |
|
189 HbIcon wlanIcon; |
|
190 switch (mWlanStatusInfo->status()) { |
|
191 case WlanStatusInfo::WlanStatusIdle: |
|
192 wlanIcon = HbIcon("qtg_large_wlan"); |
|
193 break; |
|
194 |
|
195 case WlanStatusInfo::WlanStatusOff: |
|
196 wlanIcon = HbIcon("qtg_large_wlan_off"); |
|
197 break; |
|
198 |
|
199 case WlanStatusInfo::WlanStatusConnected: |
|
200 wlanIcon = HbIcon("qtg_large_wlan"); |
|
201 wlanIcon.addBadge( |
|
202 Qt::AlignBottom | Qt::AlignRight, |
|
203 HbIcon("qtg_small_connection")); |
|
204 break; |
|
205 |
|
206 #ifndef QT_NO_DEBUG |
|
207 default: |
|
208 // Unsupported status type detected |
|
209 Q_ASSERT(0); |
|
210 break; |
|
211 #endif |
|
212 } |
|
213 |
|
214 // Set the updated WLAN status |
|
215 this->setEntryItemIcon(wlanIcon); |
|
216 this->setDescription(mWlanStatusInfo->statusText()); |
|
217 |
|
218 OstTraceFunctionExit0(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT); |
|
219 } |