9 * Nokia Corporation - initial implementation |
9 * Nokia Corporation - initial implementation |
10 *******************************************************************************/ |
10 *******************************************************************************/ |
11 |
11 |
12 #include <apgtask.h> |
12 #include <apgtask.h> |
13 #include <apgcli.h> |
13 #include <apgcli.h> |
14 |
14 #include <memory> |
15 #include "javasoftindicator.h" |
15 #include <javastorageentry.h> |
|
16 #include <javastorage.h> |
|
17 #include <javastoragenames.h> |
|
18 #include <JavaCommonUtils.h> |
|
19 #include <logger.h> |
|
20 #include <QFile.h> |
|
21 |
|
22 #include "javasoftindicator.h" |
|
23 |
|
24 using namespace std; |
|
25 using namespace java::storage; |
|
26 using namespace java::util; |
16 |
27 |
17 // ---------------------------------------------------------------------------- |
28 // ---------------------------------------------------------------------------- |
18 // JavaSoftIndicator::JavaSoftIndicator |
29 // JavaSoftIndicator::JavaSoftIndicator |
19 // @see javasoftindicator.h |
30 // @see javasoftindicator.h |
20 // ---------------------------------------------------------------------------- |
31 // ---------------------------------------------------------------------------- |
39 bool JavaSoftIndicator::handleInteraction(InteractionType type) |
50 bool JavaSoftIndicator::handleInteraction(InteractionType type) |
40 { |
51 { |
41 bool handled = false; |
52 bool handled = false; |
42 if (type == InteractionActivated) |
53 if (type == InteractionActivated) |
43 { |
54 { |
|
55 // get midlet to foreground or lauch if it is not open |
44 TRAP_IGNORE(StartJavaMidletL()); |
56 TRAP_IGNORE(StartJavaMidletL()); |
45 QVariantMap variantMap; |
57 QVariantMap variantMap; |
46 if (iParameter.isValid() && iParameter.canConvert(QVariant::List)) |
58 if (iParameter.isValid() && iParameter.canConvert(QVariant::List)) |
47 { |
59 { |
48 variantMap.insert("MidletId",iParameter.toList()[0].toUInt()); |
60 variantMap.insert("MidletId",iParameter.toList()[0].toUInt()); |
49 variantMap.insert("NotificationId",iParameter.toList()[1]); |
61 variantMap.insert("NotificationId",iParameter.toList()[1].toInt()); |
50 } |
62 } |
|
63 // send user activated signal to indicator observer |
51 emit userActivated(variantMap); |
64 emit userActivated(variantMap); |
52 handled = true; |
65 handled = true; |
|
66 // remove softnote from database |
|
67 RemoveSoftNoteFromStorage(); |
|
68 // remove indicator from status menu |
53 emit deactivate(); |
69 emit deactivate(); |
|
70 // remove image from public directoy |
|
71 QFile imgFile(iParameter.toList()[4].toString()); |
|
72 if(imgFile.exists()) |
|
73 { |
|
74 imgFile.remove(); |
|
75 } |
54 } |
76 } |
55 return handled; |
77 return handled; |
56 } |
78 } |
57 |
79 |
58 // ---------------------------------------------------------------------------- |
80 // ---------------------------------------------------------------------------- |
141 { |
169 { |
142 if (iParameter.isValid() && iParameter.canConvert(QVariant::List)) |
170 if (iParameter.isValid() && iParameter.canConvert(QVariant::List)) |
143 { |
171 { |
144 if (iParameter.toList()[0].isValid()) |
172 if (iParameter.toList()[0].isValid()) |
145 { |
173 { |
146 TUint KJavaMidletUid = iParameter.toList()[0].toUInt(); |
174 TUint javaMidletUid = iParameter.toList()[0].toUInt(); |
147 |
175 |
148 RWsSession ws; |
176 RWsSession ws; |
149 User::LeaveIfError(ws.Connect() == KErrNone); |
177 User::LeaveIfError(ws.Connect() == KErrNone); |
150 TApaTaskList tasklist(ws); |
178 TApaTaskList tasklist(ws); |
151 TApaTask task = tasklist.FindApp(TUid::Uid(KJavaMidletUid)); |
179 TApaTask task = tasklist.FindApp(TUid::Uid(javaMidletUid)); |
152 if (task.Exists()) |
180 if (task.Exists()) |
153 { |
181 { |
154 task.BringToForeground(); |
182 task.BringToForeground(); |
155 ws.Close(); |
183 ws.Close(); |
156 } |
184 } |
159 ws.Close(); |
187 ws.Close(); |
160 RApaLsSession appArcSession; |
188 RApaLsSession appArcSession; |
161 User::LeaveIfError(appArcSession.Connect()); |
189 User::LeaveIfError(appArcSession.Connect()); |
162 TThreadId threadId; |
190 TThreadId threadId; |
163 appArcSession.StartDocument(_L(""), |
191 appArcSession.StartDocument(_L(""), |
164 TUid::Uid(KJavaMidletUid), threadId); |
192 TUid::Uid(javaMidletUid), threadId); |
165 appArcSession.Close(); |
193 appArcSession.Close(); |
166 } |
194 } |
167 } |
195 } |
168 } |
196 } |
169 } |
197 } |
170 |
198 |
|
199 // ---------------------------------------------------------- |
|
200 // JavaSoftIndicator::RemoveSoftNoteFromStorage() |
|
201 // ---------------------------------------------------------- |
|
202 void JavaSoftIndicator::RemoveSoftNoteFromStorage() |
|
203 { |
|
204 std::auto_ptr<JavaStorage> js(JavaStorage::createInstance()); |
|
205 try |
|
206 { |
|
207 js->open(JAVA_DATABASE_NAME); |
|
208 |
|
209 JavaStorageApplicationEntry_t entries; |
|
210 JavaStorageEntry attribute; |
|
211 |
|
212 std::wstring midletId = JavaCommonUtils::intToWstring( |
|
213 iParameter.toList()[0].toUInt()); |
|
214 attribute.setEntry(SOFTNOTE_MIDLET_ID, midletId, |
|
215 JavaStorageEntry::STRING); |
|
216 entries.insert(attribute); |
|
217 |
|
218 std::wstring notificationId = JavaCommonUtils::intToWstring( |
|
219 iParameter.toList()[1].toInt()); |
|
220 attribute.setEntry(SOFTNOTE_ID, notificationId, JavaStorageEntry::INT); |
|
221 entries.insert(attribute); |
|
222 |
|
223 js->remove(JAVA_SOFTNOTE_TABLE, entries); |
|
224 js->close(); |
|
225 entries.clear(); |
|
226 } |
|
227 catch (JavaStorageException& ex) |
|
228 { |
|
229 LOG1(EJavaStorage, EInfo," JavaSoftNote Exception %s", ex.toString()); |
|
230 } |
|
231 } |
|
232 |