72
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - initial implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
#include <apgtask.h>
|
|
13 |
#include <apgcli.h>
|
|
14 |
|
|
15 |
#include "javasoftindicator.h"
|
|
16 |
|
|
17 |
// ----------------------------------------------------------------------------
|
|
18 |
// JavaSoftIndicator::JavaSoftIndicator
|
|
19 |
// @see javasoftindicator.h
|
|
20 |
// ----------------------------------------------------------------------------
|
|
21 |
JavaSoftIndicator::JavaSoftIndicator(const QString &indicatorType) :
|
|
22 |
HbIndicatorInterface(indicatorType,
|
|
23 |
HbIndicatorInterface::NotificationCategory, InteractionActivated)
|
|
24 |
{
|
|
25 |
}
|
|
26 |
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// JavaSoftIndicator::~JavaSoftIndicator
|
|
29 |
// @see javasoftindicator.h
|
|
30 |
// ----------------------------------------------------------------------------
|
|
31 |
JavaSoftIndicator::~JavaSoftIndicator()
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
// ----------------------------------------------------------------------------
|
|
36 |
// JavaSoftIndicator::handleInteraction
|
|
37 |
// @see javasoftindicator.h
|
|
38 |
// ----------------------------------------------------------------------------
|
|
39 |
bool JavaSoftIndicator::handleInteraction(InteractionType type)
|
|
40 |
{
|
|
41 |
bool handled = false;
|
|
42 |
if (type == InteractionActivated)
|
|
43 |
{
|
|
44 |
TRAP_IGNORE(StartJavaMidletL());
|
|
45 |
QVariantMap variantMap;
|
|
46 |
if (iParameter.isValid() && iParameter.canConvert(QVariant::List))
|
|
47 |
{
|
|
48 |
variantMap.insert("MidletId",iParameter.toList()[0].toUInt());
|
|
49 |
variantMap.insert("NotificationId",iParameter.toList()[1]);
|
|
50 |
}
|
|
51 |
emit userActivated(variantMap);
|
|
52 |
handled = true;
|
|
53 |
emit deactivate();
|
|
54 |
}
|
|
55 |
return handled;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ----------------------------------------------------------------------------
|
|
59 |
// JavaSoftIndicator::indicatorData
|
|
60 |
// @see javasoftindicator.h
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
QVariant JavaSoftIndicator::indicatorData(int role) const
|
|
63 |
{
|
|
64 |
switch (role)
|
|
65 |
{
|
|
66 |
case PrimaryTextRole:
|
|
67 |
{
|
|
68 |
QString text("");
|
|
69 |
if (iParameter.isValid() && iParameter.canConvert(QVariant::List))
|
|
70 |
{
|
|
71 |
if (iParameter.toList()[2].isValid())
|
|
72 |
{
|
|
73 |
text = iParameter.toList()[2].toString();
|
|
74 |
}
|
|
75 |
}
|
|
76 |
return text;
|
|
77 |
}
|
|
78 |
case SecondaryTextRole:
|
|
79 |
{
|
|
80 |
QString text("");
|
|
81 |
if (iParameter.isValid() && iParameter.canConvert(QVariant::List))
|
|
82 |
{
|
|
83 |
if (iParameter.toList()[3].isValid())
|
|
84 |
{
|
|
85 |
text = iParameter.toList()[3].toString();
|
|
86 |
}
|
|
87 |
}
|
|
88 |
return text;
|
|
89 |
}
|
|
90 |
case DecorationNameRole:
|
|
91 |
{
|
|
92 |
QVariant img;
|
|
93 |
if (iParameter.isValid() && iParameter.canConvert(QVariant::List))
|
|
94 |
{
|
|
95 |
if (iParameter.toList()[4].isValid())
|
|
96 |
{
|
|
97 |
img = iParameter.toList()[4].toString();
|
|
98 |
}
|
|
99 |
}
|
|
100 |
return img;
|
|
101 |
}
|
|
102 |
default:
|
|
103 |
return QVariant();
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
// ----------------------------------------------------------------------------
|
|
108 |
// JavaSoftIndicator::handleClientRequest
|
|
109 |
// ----------------------------------------------------------------------------
|
|
110 |
bool JavaSoftIndicator::handleClientRequest(RequestType type,
|
|
111 |
const QVariant ¶meter)
|
|
112 |
{
|
|
113 |
bool handled(false);
|
|
114 |
switch (type)
|
|
115 |
{
|
|
116 |
case RequestActivate:
|
|
117 |
{
|
|
118 |
if (iParameter != parameter)
|
|
119 |
{
|
|
120 |
iParameter = parameter;
|
|
121 |
}
|
|
122 |
emit dataChanged();
|
|
123 |
handled = true;
|
|
124 |
}
|
|
125 |
break;
|
|
126 |
case RequestDeactivate:
|
|
127 |
{
|
|
128 |
emit deactivate();
|
|
129 |
}
|
|
130 |
break;
|
|
131 |
default:
|
|
132 |
break;
|
|
133 |
}
|
|
134 |
return handled;
|
|
135 |
}
|
|
136 |
|
|
137 |
// ----------------------------------------------------------
|
|
138 |
// JavaSoftIndicator::StartJavaMidletL()
|
|
139 |
// ----------------------------------------------------------
|
|
140 |
void JavaSoftIndicator::StartJavaMidletL() const
|
|
141 |
{
|
|
142 |
if (iParameter.isValid() && iParameter.canConvert(QVariant::List))
|
|
143 |
{
|
|
144 |
if (iParameter.toList()[0].isValid())
|
|
145 |
{
|
|
146 |
TUint KJavaMidletUid = iParameter.toList()[0].toUInt();
|
|
147 |
|
|
148 |
RWsSession ws;
|
|
149 |
User::LeaveIfError(ws.Connect() == KErrNone);
|
|
150 |
TApaTaskList tasklist(ws);
|
|
151 |
TApaTask task = tasklist.FindApp(TUid::Uid(KJavaMidletUid));
|
|
152 |
if (task.Exists())
|
|
153 |
{
|
|
154 |
task.BringToForeground();
|
|
155 |
ws.Close();
|
|
156 |
}
|
|
157 |
else
|
|
158 |
{
|
|
159 |
ws.Close();
|
|
160 |
RApaLsSession appArcSession;
|
|
161 |
User::LeaveIfError(appArcSession.Connect());
|
|
162 |
TThreadId threadId;
|
|
163 |
appArcSession.StartDocument(_L(""),
|
|
164 |
TUid::Uid(KJavaMidletUid), threadId);
|
|
165 |
appArcSession.Close();
|
|
166 |
}
|
|
167 |
}
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|