diff -r 1505405bc645 -r b01c07dfcf84 systemsettings/accindicatorplugin/tsrc/utaccindicatorplugin/CTCHTML/indexD1.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/systemsettings/accindicatorplugin/tsrc/utaccindicatorplugin/CTCHTML/indexD1.html Thu Oct 07 06:25:45 2010 +0300 @@ -0,0 +1,295 @@ + +
+Start/ | End/ | |||
True | False | - | Line | Source |
1 | /* | |||
2 | * Copyright (c) 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 | * | |||
16 | */ | |||
17 | #include "accindicator.h" | |||
18 | ||||
19 | #include <QtPlugin> | |||
20 | #include <QProcess> | |||
21 | #include <accpolgenericiddefinitions.h> | |||
22 | ||||
Top | ||||
0 | 0 | - | 23 | Q_EXPORT_PLUGIN(AccIndicatorPlugin) |
0 | - | 23 | return qt_plugin_verification_data | |
Top | ||||
0 | 0 | - | 23 | FUNCTION qt_plugin_instance() |
0 | 0 | - | 23 | if (! _instance) |
0 | - | 23 | return _instance | |
24 | const static char IndicatorType[] = "com.nokia.accessory.indicatorplugin/1.0"; | |||
25 | QString KAccMode = "AccMode"; | |||
26 | QString KAccType = "AccType"; | |||
27 | ||||
Top | ||||
6 | 6 | 28 | AccIndicatorPlugin::AccIndicatorPlugin() : | |
29 | HbIndicatorInterface(IndicatorType, | |||
30 | HbIndicatorInterface::SettingCategory, | |||
31 | InteractionActivated) | |||
32 | { | |||
33 | mIndicatorTypes << "com.nokia.accessory.indicatorplugin/1.0"; | |||
34 | } | |||
35 | ||||
Top | ||||
0 | 0 | - | 36 | AccIndicatorPlugin::~AccIndicatorPlugin() |
37 | { | |||
38 | } | |||
39 | ||||
40 | // ---------------------------------------------------------------------------- | |||
41 | // AccIndicatorPlugin::indicatorTypes | |||
42 | // returns the indicator types handled by this plugin | |||
43 | // ---------------------------------------------------------------------------- | |||
44 | ||||
Top | ||||
1 | 0 | 45 | QStringList AccIndicatorPlugin::indicatorTypes() const | |
46 | { | |||
1 | 47 | return mIndicatorTypes; | ||
48 | } | |||
49 | ||||
50 | // ---------------------------------------------------------------------------- | |||
51 | // AccIndicatorPlugin::createIndicator | |||
52 | // creates an indicator. | |||
53 | // ---------------------------------------------------------------------------- | |||
54 | ||||
Top | ||||
1 | 0 | 55 | HbIndicatorInterface* AccIndicatorPlugin::createIndicator( | |
56 | const QString &indicatorType) | |||
57 | { | |||
58 | Q_UNUSED(indicatorType) | |||
1 | 59 | return this; | ||
60 | } | |||
61 | ||||
62 | // ---------------------------------------------------------------------------- | |||
63 | // AccIndicatorPlugin::error | |||
64 | // returns the error code. | |||
65 | // ---------------------------------------------------------------------------- | |||
66 | ||||
Top | ||||
0 | 0 | - | 67 | int AccIndicatorPlugin::error() const |
68 | { | |||
0 | - | 69 | return mError; | |
70 | } | |||
71 | ||||
72 | // ---------------------------------------------------------------------------- | |||
73 | // AccIndicatorPlugin::accessAllowed | |||
74 | // check for the access rights of the client. As there are no restrictions for | |||
75 | // this plugin it always returns true. | |||
76 | // ---------------------------------------------------------------------------- | |||
77 | ||||
Top | ||||
1 | 0 | 78 | bool AccIndicatorPlugin::accessAllowed(const QString &indicatorType,const QVariantMap &securityInfo) const | |
79 | { | |||
80 | Q_UNUSED(indicatorType) | |||
81 | Q_UNUSED(securityInfo) | |||
82 | ||||
1 | 83 | return true; | ||
84 | } | |||
85 | ||||
86 | // ---------------------------------------------------------------------------- | |||
87 | // AccIndicator::handleInteraction | |||
88 | // called when the user interacts with the indicator.Enable the interaction only | |||
89 | // for headset,tty and tv-out for user to change the settings. | |||
90 | // ---------------------------------------------------------------------------- | |||
Top | ||||
4 | 0 | 91 | bool AccIndicatorPlugin::handleInteraction(InteractionType type) | |
92 | { | |||
93 | bool handled = false; | |||
2 | 2 | 94 | if (type == InteractionActivated) | |
95 | { | |||
96 | // If it is 3-pole ( i.e., HeadSet or TTY ) and TV-Out enable the handleInteraction() to change the settings. | |||
2 | 0 | - | 97 | if(mAccMode == EAccModeWiredHeadset || mAccMode == EAccModeWirelessHeadset || mAccMode == EAccModeTextDevice || mAccMode == EAccModeTVOut ) |
98 | { | |||
99 | QObject::connect( &mProcess, SIGNAL(error(QProcess::ProcessError)), | |||
100 | this, SLOT(processError(QProcess::ProcessError))); | |||
101 | ||||
102 | QVariant mode,type; | |||
103 | mode.setValue((int)mAccMode); | |||
104 | type.setValue((int)mAccType); | |||
105 | mArgs.append(mode.toString()); | |||
106 | mArgs.append(type.toString()); | |||
107 | ||||
108 | // Launch the process to show the view. | |||
109 | mProcess.start("accindicatorsettings" , mArgs); | |||
110 | handled = true; | |||
111 | } | |||
112 | } | |||
4 | 113 | return handled; | ||
114 | } | |||
115 | ||||
116 | // ---------------------------------------------------------------------------- | |||
117 | // AccIndicator::indicatorData | |||
118 | // returns the name and icon to be displayed in the universal indicator menu. | |||
119 | // ---------------------------------------------------------------------------- | |||
Top | ||||
3 | 0 | 120 | QVariant AccIndicatorPlugin::indicatorData(int role) const | |
121 | { | |||
122 | switch(role) | |||
123 | { | |||
124 | //for displaying the string in indicator. | |||
2 | 125 | case PrimaryTextRole: | ||
126 | { | |||
127 | QString type(mDisplayName); | |||
2 | 128 | return type; | ||
129 | } | |||
130 | //for displaying the icon in indicator. | |||
1 | 131 | case MonoDecorationNameRole: | ||
132 | { | |||
133 | QString iconName; | |||
1 | 0 | - | 134 | if(mAccType == KPCWired || mAccType == KPCUSB) |
135 | { | |||
136 | iconName = QString("z:/resource/accindicator/wired_accessory.svg"); | |||
137 | } | |||
0 | 0 | - | 138 | else if (mAccType == KPCBluetooth || mAccType == KPCInfraRed) |
139 | { | |||
140 | iconName = QString("z:/resource/accindicator/wireless_accessory.svg"); | |||
141 | } | |||
1 | 142 | return iconName; | ||
143 | } | |||
0 | - | 144 | default: | |
0 | - | 145 | return QVariant(); | |
146 | } | |||
147 | } | |||
148 | ||||
149 | // ---------------------------------------------------------------------------- | |||
150 | // AccIndicatorPlugin::handleClientRequest | |||
151 | // this function gets called when client activates plugin | |||
152 | // ---------------------------------------------------------------------------- | |||
Top | ||||
4 | 0 | 153 | bool AccIndicatorPlugin::handleClientRequest( RequestType type, | |
154 | const QVariant ¶meter) | |||
155 | { | |||
156 | bool handled(false); | |||
157 | switch (type) { | |||
3 | 158 | case RequestActivate: | ||
159 | { | |||
160 | // Get the params(acctype and mode) from the hbindicator.activate() which is called from sysap. | |||
161 | ||||
162 | QVariantMap mapValues = parameter.toMap(); | |||
3 | 0 | - | 163 | if(mapValues.contains(KAccMode)) |
164 | { | |||
165 | mAccMode = static_cast<TAccMode>(mapValues.value(KAccMode).toInt()); | |||
166 | } | |||
3 | 0 | - | 167 | if(mapValues.contains(KAccType)) |
168 | { | |||
169 | mAccType = mapValues.value(KAccType).toInt(); | |||
170 | } | |||
171 | ||||
172 | // prepare the name to be displayed in the universal indicator menu. | |||
173 | prepareDisplayName(); | |||
174 | emit dataChanged(); | |||
175 | handled = true; | |||
176 | } | |||
3 | 177 | break; | ||
1 | 178 | case RequestDeactivate: | ||
179 | { | |||
180 | // reset data | |||
181 | mDisplayName = QString(); | |||
182 | emit deactivate(); | |||
183 | } | |||
1 | 184 | break; | ||
0 | - | 185 | default: | |
0 | - | 186 | break; | |
187 | } | |||
4 | 188 | return handled; | ||
189 | } | |||
190 | ||||
191 | // ---------------------------------------------------------------------------- | |||
192 | // AccIndicator::prepareDisplayName | |||
193 | // prepare the name to be displayed in the indicator menu. | |||
194 | // ---------------------------------------------------------------------------- | |||
Top | ||||
3 | 3 | 195 | void AccIndicatorPlugin::prepareDisplayName() | |
196 | { | |||
197 | mDisplayName.clear(); | |||
198 | switch(mAccMode) | |||
199 | { | |||
2 | 200 | case EAccModeWiredHeadset: | ||
201 | mDisplayName.append(QString("Wired Headset")); | |||
2 | 202 | break; | ||
0 | - | 203 | case EAccModeWirelessHeadset: | |
204 | mDisplayName.append(QString("Wireless Headset")); | |||
0 | - | 205 | break; | |
0 | - | 206 | case EAccModeWiredCarKit: | |
207 | mDisplayName.append(QString("Wired CarKit")); | |||
0 | - | 208 | break; | |
0 | - | 209 | case EAccModeWirelessCarKit: | |
210 | mDisplayName.append(QString("Wireless Carkit")); | |||
0 | - | 211 | break; | |
0 | - | 212 | case EAccModeTextDevice: | |
213 | mDisplayName.append(QString("TTY")); | |||
0 | - | 214 | break; | |
0 | - | 215 | case EAccModeLoopset: | |
216 | mDisplayName.append(QString("LoopSet")); | |||
0 | - | 217 | break; | |
0 | - | 218 | case EAccModeMusicStand: | |
219 | mDisplayName.append(QString("Music Stand")); | |||
0 | - | 220 | break; | |
1 | 221 | case EAccModeTVOut: | ||
222 | mDisplayName.append(QString("TV Out")); | |||
1 | 223 | break; | ||
0 | - | 224 | case EAccModeHeadphones: | |
225 | mDisplayName.append(QString("Head Phones")); | |||
0 | - | 226 | break; | |
0 | - | 227 | default : | |
228 | mDisplayName.append(QString("Unknown")); | |||
229 | } | |||
230 | } | |||
231 | ||||
232 | // ---------------------------------------------------------------------------- | |||
233 | // AccIndicator::processError | |||
234 | // handle the error conditions reurned by the QProcess. | |||
235 | // ---------------------------------------------------------------------------- | |||
236 | ||||
Top | ||||
0 | 0 | - | 237 | void AccIndicatorPlugin::processError(QProcess::ProcessError err) |
238 | { | |||
239 | switch (err) { | |||
0 | - | 240 | case QProcess::FailedToStart: | |
0 | - | 241 | case QProcess::Crashed: | |
0 | - | 242 | case QProcess::Timedout: | |
0 | - | 243 | case QProcess::ReadError: | |
0 | - | 244 | case QProcess::WriteError: | |
0 | - | 245 | case QProcess::UnknownError: | |
0 | - | 246 | break; | |
0 | - | 247 | default: | |
0 | - | 248 | break; | |
249 | } | |||
250 | } | |||
***TER 41% (31/75) of SOURCE FILE accindicator.cpp |