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