|
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 |
|
18 #include <QtPlugin> |
|
19 #include <QVariant> |
|
20 #include <QDebug> |
|
21 #include <QProcess> |
|
22 |
|
23 #include "lcvtindicatorplugin.h" |
|
24 |
|
25 const static QString IndicatorType = "com.nokia.hb.indicator.lcvtindicatorplugin/1.0"; |
|
26 |
|
27 Q_EXPORT_PLUGIN(LcVtIndicatorPlugin) |
|
28 |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 LcVtIndicatorPlugin::LcVtIndicatorPlugin(): |
|
35 HbIndicatorInterface(IndicatorType, NotificationCategory, InteractionActivated), |
|
36 mError(0) |
|
37 { |
|
38 qDebug() << "LcVtIndicatorPlugin::LcVtIndicatorPlugin()"; |
|
39 mIndicatorTypes << IndicatorType; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 LcVtIndicatorPlugin::~LcVtIndicatorPlugin() |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 QStringList LcVtIndicatorPlugin::indicatorTypes() const |
|
55 { |
|
56 qDebug() << "LcVtIndicatorPlugin::indicatorTypes()"; |
|
57 return mIndicatorTypes; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 bool LcVtIndicatorPlugin::accessAllowed(const QString &indicatorType, |
|
65 const QVariantMap &securityInfo) const |
|
66 { |
|
67 Q_UNUSED(indicatorType); |
|
68 Q_UNUSED(securityInfo); |
|
69 qDebug() << "LcVtIndicatorPlugin::accessAllowed()"; |
|
70 return true; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 HbIndicatorInterface* LcVtIndicatorPlugin::createIndicator( |
|
78 const QString &indicatorType) |
|
79 { |
|
80 Q_UNUSED(indicatorType); |
|
81 return this; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 int LcVtIndicatorPlugin::error() const |
|
89 { |
|
90 return mError; |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 bool LcVtIndicatorPlugin::handleInteraction(InteractionType type) |
|
99 { |
|
100 qDebug() << "LcVtIndicatorPlugin::handleInteraction()"; |
|
101 bool handled = false; |
|
102 if (type == InteractionActivated) { |
|
103 handled = bringVtToForeground(); |
|
104 if (!handled) { |
|
105 qDebug() << "couldn't bring VT to FG, deactivating indicator!"; |
|
106 emit deactivate(); |
|
107 } |
|
108 } |
|
109 qDebug() << "LcVtIndicatorPlugin::handleInteraction(), exit"; |
|
110 return handled; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 QVariant LcVtIndicatorPlugin::indicatorData(int role) const |
|
118 { |
|
119 qDebug() << "LcVtIndicatorInterface::indicatorData()"; |
|
120 QVariantMap map = mParameter.value<QVariantMap>(); |
|
121 |
|
122 if (role == PrimaryTextRole) { |
|
123 return map.value( (QVariant(PrimaryTextRole)).toString()).toString(); |
|
124 } else if (role == MonoDecorationNameRole) { //status bar icon |
|
125 return map.value((QVariant(MonoDecorationNameRole)).toString()).toString(); |
|
126 } else if (role == DecorationNameRole) { |
|
127 return map.value( (QVariant(DecorationNameRole)).toString()).toString(); |
|
128 } |
|
129 return QVariant(); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 bool LcVtIndicatorPlugin::handleClientRequest(RequestType type, const QVariant ¶meter) |
|
137 { |
|
138 qDebug() << "LcVtIndicatorPlugin::handleClientRequest()"; |
|
139 bool handled(false); |
|
140 switch (type) { |
|
141 case RequestActivate: |
|
142 if (mParameter != parameter) { |
|
143 mParameter = parameter; |
|
144 emit dataChanged(); |
|
145 } |
|
146 handled = true; |
|
147 break; |
|
148 default: |
|
149 mParameter.clear(); |
|
150 } |
|
151 qDebug() << "LcVtIndicatorPlugin::handleClientRequest(), exit"; |
|
152 |
|
153 return handled; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 bool LcVtIndicatorPlugin::bringVtToForeground() |
|
161 { |
|
162 qDebug() << "LcVtIndicatorPlugin::bringVtToForeground()"; |
|
163 const QString AppName = "videotelui.exe"; |
|
164 return QProcess::startDetached(AppName); |
|
165 } |
|
166 |