|
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 <QtPlugin> |
|
19 #include <HbTranslator> |
|
20 #include <QLocale> |
|
21 #include <QList> |
|
22 #include <HbLabel> |
|
23 #include <HbDialog> |
|
24 #include <HbDocumentLoader> |
|
25 #include <HbPushButton> |
|
26 #include <HbView> |
|
27 #include <HbApplication> |
|
28 #include "cellularindicatorplugin.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "cellularindicatorpluginTraces.h" |
|
32 #endif |
|
33 |
|
34 Q_EXPORT_PLUGIN(CellularIndicatorPlugin) |
|
35 |
|
36 const static char IndicatorType[] = |
|
37 "com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0"; |
|
38 |
|
39 /*! |
|
40 CellularIndicatorPlugin::CellularIndicatorPlugin |
|
41 */ |
|
42 CellularIndicatorPlugin::CellularIndicatorPlugin() : |
|
43 HbIndicatorInterface(IndicatorType, SettingCategory, |
|
44 InteractionActivated), |
|
45 mError(0) |
|
46 { |
|
47 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_CELLULARINDICATORPLUGIN_ENTRY ); |
|
48 mIndicatorTypes << |
|
49 "com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0"; |
|
50 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_CELLULARINDICATORPLUGIN_EXIT ); |
|
51 } |
|
52 |
|
53 /*! |
|
54 CellularIndicatorPlugin::~CellularIndicatorPlugin |
|
55 */ |
|
56 CellularIndicatorPlugin::~CellularIndicatorPlugin() |
|
57 { |
|
58 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_DCELLULARINDICATORPLUGIN_ENTRY ); |
|
59 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_DCELLULARINDICATORPLUGIN_EXIT ); |
|
60 } |
|
61 |
|
62 /*! |
|
63 CellularIndicatorPlugin::indicatorTypes |
|
64 */ |
|
65 QStringList CellularIndicatorPlugin::indicatorTypes() const |
|
66 { |
|
67 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_INDICATORTYPES_ENTRY ); |
|
68 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_INDICATORTYPES_EXIT ); |
|
69 return mIndicatorTypes; |
|
70 } |
|
71 |
|
72 /*! |
|
73 CellularIndicatorPlugin::accessAllowed |
|
74 */ |
|
75 bool CellularIndicatorPlugin::accessAllowed(const QString &indicatorType, |
|
76 const QVariantMap &securityInfo) const |
|
77 { |
|
78 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_ACCESSALLOWED_ENTRY ); |
|
79 Q_UNUSED(indicatorType) |
|
80 Q_UNUSED(securityInfo) |
|
81 |
|
82 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_ACCESSALLOWED_EXIT ); |
|
83 return true; |
|
84 } |
|
85 |
|
86 /*! |
|
87 CellularIndicatorPlugin::createIndicator |
|
88 */ |
|
89 HbIndicatorInterface* CellularIndicatorPlugin::createIndicator( |
|
90 const QString &indicatorType) |
|
91 { |
|
92 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_ENTRY ); |
|
93 |
|
94 Q_UNUSED(indicatorType) |
|
95 |
|
96 // Install localization |
|
97 mTranslator = QSharedPointer<HbTranslator>(new HbTranslator("cellularindicatorplugin")); |
|
98 |
|
99 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_EXIT ); |
|
100 return this; |
|
101 } |
|
102 |
|
103 /*! |
|
104 CellularIndicatorPlugin::error |
|
105 */ |
|
106 int CellularIndicatorPlugin::error() const |
|
107 { |
|
108 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_ERROR_ENTRY ); |
|
109 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_ERROR_EXIT ); |
|
110 return mError; |
|
111 } |
|
112 |
|
113 /*! |
|
114 CellularIndicatorPlugin::handleClientRequest |
|
115 */ |
|
116 bool CellularIndicatorPlugin::handleClientRequest(RequestType type, |
|
117 const QVariant ¶meter) |
|
118 { |
|
119 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_HANDLECLIENTREQUEST_ENTRY ); |
|
120 |
|
121 bool handled(false); |
|
122 |
|
123 switch (type) { |
|
124 case RequestActivate: |
|
125 if (mParameter != parameter) { |
|
126 mParameter = parameter; |
|
127 emit dataChanged(); |
|
128 } |
|
129 handled = true; |
|
130 break; |
|
131 |
|
132 case RequestDeactivate: |
|
133 mParameter.clear(); |
|
134 break; |
|
135 |
|
136 default: |
|
137 // Do nothing |
|
138 break; |
|
139 } |
|
140 |
|
141 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_HANDLECLIENTREQUEST_EXIT ); |
|
142 return handled; |
|
143 } |
|
144 |
|
145 /*! |
|
146 CellularIndicatorPlugin::handleInteraction |
|
147 */ |
|
148 bool CellularIndicatorPlugin::handleInteraction(InteractionType type) |
|
149 { |
|
150 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_HANDLEINTERACTION_ENTRY ); |
|
151 |
|
152 Q_UNUSED(type) |
|
153 bool handled = false; |
|
154 QVariantMap data; |
|
155 |
|
156 switch(type) { |
|
157 case InteractionActivated: |
|
158 // Emit a signal that will inform the client to start the connectionview client |
|
159 emit userActivated(data); |
|
160 |
|
161 handled = true; |
|
162 break; |
|
163 |
|
164 default: |
|
165 break; |
|
166 } |
|
167 |
|
168 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_HANDLEINTERACTION_EXIT ); |
|
169 return handled; |
|
170 } |
|
171 |
|
172 /*! |
|
173 CellularIndicatorPlugin::indicatorData |
|
174 */ |
|
175 QVariant CellularIndicatorPlugin::indicatorData(int role) const |
|
176 { |
|
177 OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_INDICATORDATA_ENTRY ); |
|
178 QVariant ret = NULL; |
|
179 |
|
180 switch(role) { |
|
181 case PrimaryTextRole: |
|
182 ret = QString(hbTrId("txt_occ_dblist_cellular_data")); |
|
183 break; |
|
184 |
|
185 case SecondaryTextRole: |
|
186 if (mParameter.isValid() && (mParameter.type() == QVariant::List)) { |
|
187 |
|
188 QList<QVariant> indicatorInfo; |
|
189 indicatorInfo = mParameter.toList(); |
|
190 |
|
191 if (!indicatorInfo.count()) { |
|
192 // No entries on the list -> don't even try to use this |
|
193 break; |
|
194 } |
|
195 |
|
196 if ( (indicatorInfo[0].toInt() > 1) && indicatorInfo.count() ) { |
|
197 |
|
198 // More than one connection -> show number of connections |
|
199 QString str = QString(hbTrId("txt_occ_dblist_cellular_data_val_l1_connections")); |
|
200 ret = str.arg(indicatorInfo[0].toInt()); |
|
201 } |
|
202 else if ( indicatorInfo[0].toInt() && (indicatorInfo.count() >= 2)) { |
|
203 |
|
204 // Only one connection -> show name of the iap |
|
205 ret = indicatorInfo[1].toString(); |
|
206 } |
|
207 } |
|
208 break; |
|
209 |
|
210 case DecorationNameRole: |
|
211 // Return the icon |
|
212 ret = QString("qtg_small_gprs"); |
|
213 break; |
|
214 |
|
215 default: |
|
216 // Do nothing |
|
217 break; |
|
218 } |
|
219 |
|
220 OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_INDICATORDATA_EXIT ); |
|
221 return ret; |
|
222 } |
|
223 |