13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QTranslator> |
18 #include <HbTranslator> |
19 #include <QLocale> |
19 #include <QLocale> |
20 #include <QtCore/qplugin.h> |
20 #include <QtCore/qplugin.h> |
21 #include <QtCore/QString> |
21 #include <QtCore/QString> |
22 #include <QtCore/QVariant> |
22 #include <QtCore/QVariant> |
23 #include <QtCore/QMetaType> |
23 #include <QtCore/QMetaType> |
94 { |
94 { |
95 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_CREATEINDICATOR_ENTRY, this); |
95 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_CREATEINDICATOR_ENTRY, this); |
96 Q_UNUSED(indicatorType) |
96 Q_UNUSED(indicatorType) |
97 |
97 |
98 // Install localization |
98 // Install localization |
99 QTranslator *translator = new QTranslator(this); |
99 HbTranslator *translator(new HbTranslator("wlanindicatorplugin")); |
100 QString lang = QLocale::system().name(); |
|
101 QString path = "Z:/resource/qt/translations/"; |
|
102 translator->load("wlanindicatorplugin_" + lang, path); |
|
103 qApp->installTranslator(translator); |
|
104 |
100 |
105 OstTraceFunctionExit1(WLANINDICATORPLUGIN_CREATEINDICATOR_EXIT, this); |
101 OstTraceFunctionExit1(WLANINDICATORPLUGIN_CREATEINDICATOR_EXIT, this); |
106 return this; |
102 return this; |
107 } |
103 } |
108 |
104 |
123 bool WlanIndicatorPlugin::handleInteraction(InteractionType type) |
119 bool WlanIndicatorPlugin::handleInteraction(InteractionType type) |
124 { |
120 { |
125 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_HANDLEINTERACTION_ENTRY, this); |
121 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_HANDLEINTERACTION_ENTRY, this); |
126 |
122 |
127 bool handled = false; |
123 bool handled = false; |
|
124 QVariantMap data; |
128 switch (type) { |
125 switch (type) { |
129 case InteractionActivated: |
126 case InteractionActivated: |
130 //connect error() to slot processError() to get error, |
127 // Emit a signal that will inform the client to start the wlan list view |
131 QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)), |
128 emit userActivated(data); |
132 this, SLOT(processError(QProcess::ProcessError))); |
|
133 |
|
134 // Show WLAN list view |
|
135 process.start("WlanSniffer"); |
|
136 handled = true; |
129 handled = true; |
137 break; |
130 break; |
138 default: |
131 default: |
139 break; |
132 break; |
140 } |
133 } |
195 if (indicatorText[0] == wlanNotConnected){ |
188 if (indicatorText[0] == wlanNotConnected){ |
196 qvariant = QString(hbTrId("txt_occ_dblist_wireless_lan_val_not_connected")); |
189 qvariant = QString(hbTrId("txt_occ_dblist_wireless_lan_val_not_connected")); |
197 } |
190 } |
198 |
191 |
199 else if (indicatorText[0] == wlanConnected){ |
192 else if (indicatorText[0] == wlanConnected){ |
200 QString iapName = indicatorText[1].toString(); |
193 qvariant = indicatorText[1].toString(); |
201 QString str = QString(hbTrId("txt_occ_dblist_wireless_lan_val_1_connected")); |
|
202 qvariant = str.arg(iapName); |
|
203 } |
194 } |
204 } |
195 } |
205 else |
196 else |
206 { |
197 { |
207 OstTrace0( WLANINDICATORPLUGIN_ERR,INVALID_PARAMS,"Invalid indicator parameters"); |
198 OstTrace0( WLANINDICATORPLUGIN_ERR,INVALID_PARAMS,"Invalid indicator parameters"); |
212 OstTraceFunctionExit1(DUP1_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
203 OstTraceFunctionExit1(DUP1_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
213 |
204 |
214 if (mParameter.isValid() && mParameter.type() == QVariant::List) { |
205 if (mParameter.isValid() && mParameter.type() == QVariant::List) { |
215 indicatorText = mParameter.toList(); |
206 indicatorText = mParameter.toList(); |
216 if ((indicatorText.size() > 0) && (indicatorText[0] == wlanConnected)) { |
207 if ((indicatorText.size() > 0) && (indicatorText[0] == wlanConnected)) { |
217 qvariant = HbIcon("qtg_status_wlan"); |
208 qvariant = QString("qtg_status_wlan"); |
218 } |
209 } |
219 } |
210 } |
220 break; |
211 break; |
221 // this is the icon in the indicator |
212 // this is the icon in the indicator |
222 case DecorationNameRole: |
213 case DecorationNameRole: |
223 OstTraceFunctionExit1(DUP2_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
214 OstTraceFunctionExit1(DUP2_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
224 qvariant = HbIcon("qtg_small_wlan"); |
215 qvariant = QString("qtg_small_wlan"); |
225 break; |
216 break; |
226 default: |
217 default: |
227 OstTraceFunctionExit1(DUP3_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
218 OstTraceFunctionExit1(DUP3_WLANINDICATORPLUGIN_INDICATORDATA_EXIT, this); |
228 break; |
219 break; |
229 } |
220 } |
230 return qvariant; |
221 return qvariant; |
231 } |
222 } |
232 |
223 |
233 /*! |
|
234 The processError is a handler for error codes. |
|
235 */ |
|
236 void WlanIndicatorPlugin::processError(QProcess::ProcessError err) |
|
237 { |
|
238 OstTraceFunctionEntry1(WLANINDICATORPLUGIN_PROCESSERROR_ENTRY, this); |
|
239 |
|
240 switch (err) { |
|
241 case QProcess::FailedToStart: |
|
242 case QProcess::Crashed: |
|
243 case QProcess::Timedout: |
|
244 case QProcess::ReadError: |
|
245 case QProcess::WriteError: |
|
246 case QProcess::UnknownError: |
|
247 OstTrace1( WLANINDICATORPLUGIN_ERR,PROCESSERROR_KNOWN,"Process Error %u", err); |
|
248 break; |
|
249 default: |
|
250 OstTrace1( WLANINDICATORPLUGIN_ERR,PROCESSERROR_UNKNOWN,"Unknown Process Error %u", err); |
|
251 break; |
|
252 } |
|
253 OstTraceFunctionExit1(WLANINDICATORPLUGIN_PROCESSERROR_EXIT, this); |
|
254 } |
|