|
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 |
|
18 #include <HbTranslator> |
|
19 #include <QLocale> |
|
20 #include <QtCore/qplugin.h> |
|
21 #include <QtCore/QString> |
|
22 #include <QtCore/QVariant> |
|
23 #include <QtCore/QMetaType> |
|
24 |
|
25 #include <HbLabel> |
|
26 #include <hbglobal.h> |
|
27 #include <hbapplication.h> |
|
28 #include <hbindicatorplugininterface.h> |
|
29 #include <hbindicatorinterface.h> |
|
30 #include "wlanindicatorplugin.h" |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "wlanindicatorpluginTraces.h" |
|
34 #endif |
|
35 |
|
36 Q_EXPORT_PLUGIN(WlanIndicatorPlugin) |
|
37 |
|
38 const static char IndicatorType[] = "com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0"; |
|
39 |
|
40 |
|
41 /*! |
|
42 WlanIndicatorPlugin constructor. |
|
43 */ |
|
44 WlanIndicatorPlugin::WlanIndicatorPlugin() : |
|
45 HbIndicatorInterface(IndicatorType, SettingCategory, InteractionActivated), |
|
46 mError(0) |
|
47 { |
|
48 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_WLANINDICATORPLUGIN_ENTRY, this); |
|
49 mIndicatorTypes << "com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0"; |
|
50 OstTraceFunctionExit1(WLANINDICATORPLUGIN_WLANINDICATORPLUGIN_ENTRY_EXIT, this); |
|
51 } |
|
52 |
|
53 /*! |
|
54 WlanIndicatorPlugin destructor. |
|
55 */ |
|
56 WlanIndicatorPlugin::~WlanIndicatorPlugin() |
|
57 { |
|
58 OstTraceFunctionEntry1(DUP1_WLANINDICATORPLUGIN_WLANINDICATORPLUGIN_ENTRY, this); |
|
59 OstTraceFunctionExit1(DUP1_WLANINDICATORPLUGIN_WLANINDICATORPLUGIN_EXIT, this); |
|
60 } |
|
61 |
|
62 /*! |
|
63 The indicatorTypes returns type of indicator. In this case it is wlanindicatorplugin. |
|
64 */ |
|
65 QStringList WlanIndicatorPlugin::indicatorTypes() const |
|
66 { |
|
67 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_INDICATORTYPES_ENTRY, this); |
|
68 OstTraceFunctionExit1(WLANINDICATORPLUGIN_INDICATORTYPES_EXIT, this); |
|
69 |
|
70 return mIndicatorTypes; |
|
71 } |
|
72 |
|
73 /*! |
|
74 The handleClientRequest handles client request to change indicators parameters. |
|
75 */ |
|
76 bool WlanIndicatorPlugin::accessAllowed(const QString &indicatorType, |
|
77 const QVariantMap &securityInfo) const |
|
78 { |
|
79 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_ACCESSALLOWED_ENTRY, this); |
|
80 |
|
81 Q_UNUSED(indicatorType) |
|
82 Q_UNUSED(securityInfo) |
|
83 |
|
84 OstTraceFunctionExit1(WLANINDICATORPLUGIN_ACCESSALLOWED_EXIT, this); |
|
85 |
|
86 return true; |
|
87 } |
|
88 |
|
89 /*! |
|
90 The createIndicator creates indicator plugin instance. |
|
91 */ |
|
92 HbIndicatorInterface* WlanIndicatorPlugin::createIndicator( |
|
93 const QString &indicatorType) |
|
94 { |
|
95 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_CREATEINDICATOR_ENTRY, this); |
|
96 Q_UNUSED(indicatorType) |
|
97 |
|
98 // Install localization |
|
99 mTranslator = QSharedPointer<HbTranslator>(new HbTranslator("wlanindicatorplugin")); |
|
100 |
|
101 OstTraceFunctionExit1(WLANINDICATORPLUGIN_CREATEINDICATOR_EXIT, this); |
|
102 return this; |
|
103 } |
|
104 |
|
105 /*! |
|
106 The error returns indicator error to HbIndicatorPluginInterface. |
|
107 */ |
|
108 int WlanIndicatorPlugin::error() const |
|
109 { |
|
110 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_ERROR_ENTRY, this); |
|
111 OstTrace1( WLANINDICATORPLUGIN_ERR,ERROR,"WlanIndicatorPlugin error %u", mError); |
|
112 OstTraceFunctionExit1(WLANINDICATORPLUGIN_ERROR_EXIT, this); |
|
113 return mError; |
|
114 } |
|
115 |
|
116 /*! |
|
117 The handleInteraction is used launch WLAN list view. |
|
118 */ |
|
119 bool WlanIndicatorPlugin::handleInteraction(InteractionType type) |
|
120 { |
|
121 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_HANDLEINTERACTION_ENTRY, this); |
|
122 |
|
123 bool handled = false; |
|
124 QVariantMap data; |
|
125 switch (type) { |
|
126 case InteractionActivated: |
|
127 // Emit a signal that will inform the client to start the wlan list view |
|
128 emit userActivated(data); |
|
129 handled = true; |
|
130 break; |
|
131 default: |
|
132 break; |
|
133 } |
|
134 |
|
135 OstTraceFunctionExit1(WLANINDICATORPLUGIN_HANDLEINTERACTION_EXIT, this); |
|
136 |
|
137 return handled; |
|
138 } |
|
139 |
|
140 /*! |
|
141 The handleClientRequest handles client request to change indicators paramters. |
|
142 */ |
|
143 bool WlanIndicatorPlugin::handleClientRequest(RequestType type, const QVariant ¶meter) |
|
144 { |
|
145 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_CLIENTREQUEST_ENTRY, this); |
|
146 |
|
147 Q_UNUSED(parameter) |
|
148 bool handled(false); |
|
149 switch (type) { |
|
150 case RequestActivate: |
|
151 if (mParameter != parameter) { |
|
152 mParameter = parameter; |
|
153 emit dataChanged(); |
|
154 } |
|
155 handled = true; |
|
156 break; |
|
157 default: |
|
158 mParameter.clear(); |
|
159 } |
|
160 |
|
161 OstTraceFunctionExit1(WLANINDICATORPLUGIN_CLIENTREQUEST_EXIT, this); |
|
162 return handled; |
|
163 } |
|
164 |
|
165 /*! |
|
166 The indicatorData takes care of showing indicator's data. |
|
167 */ |
|
168 QVariant WlanIndicatorPlugin::indicatorData(int role) const |
|
169 { |
|
170 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_INDICATORDATA_ENTRY, this); |
|
171 |
|
172 QVariant qvariant(""); |
|
173 QList<QVariant> indicatorText; |
|
174 bool validParameters = false; |
|
175 |
|
176 switch (role) { |
|
177 case PrimaryTextRole: |
|
178 qvariant = QString(hbTrId("txt_occ_dblist_indi_menu_wireless_lan")); |
|
179 break; |
|
180 case SecondaryTextRole: |
|
181 if (mParameter.isValid() && mParameter.type() == QVariant::List) { |
|
182 |
|
183 indicatorText = mParameter.toList(); |
|
184 validParameters = true; |
|
185 } |
|
186 if (validParameters && (indicatorText.size() > 0)) { |
|
187 |
|
188 if (indicatorText[0] == wlanNotConnected){ |
|
189 qvariant = QString(hbTrId("txt_occ_dblist_wireless_lan_val_not_connected")); |
|
190 } |
|
191 |
|
192 else if (indicatorText[0] == wlanConnected){ |
|
193 qvariant = indicatorText[1].toString(); |
|
194 } |
|
195 } |
|
196 else |
|
197 { |
|
198 OstTrace0( WLANINDICATORPLUGIN_ERR,INVALID_PARAMS,"Invalid indicator parameters"); |
|
199 } |
|
200 break; |
|
201 // this is the statusbar icon, which is shown only when a connection is active |
|
202 case MonoDecorationNameRole: |
|
203 OstTraceFunctionExit1(DUP1_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
|
204 |
|
205 if (mParameter.isValid() && mParameter.type() == QVariant::List) { |
|
206 indicatorText = mParameter.toList(); |
|
207 if ((indicatorText.size() > 0) && (indicatorText[0] == wlanConnected)) { |
|
208 qvariant = QString("qtg_status_wlan"); |
|
209 } |
|
210 } |
|
211 break; |
|
212 // this is the icon in the indicator |
|
213 case DecorationNameRole: |
|
214 OstTraceFunctionExit1(DUP2_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
|
215 qvariant = QString("qtg_small_wlan"); |
|
216 break; |
|
217 default: |
|
218 OstTraceFunctionExit1(DUP3_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
|
219 break; |
|
220 } |
|
221 return qvariant; |
|
222 } |
|
223 |