|
1 /* |
|
2 * Copyright (c) 2008 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 |
|
19 #include <list> |
|
20 #include <memory> |
|
21 #include <string> |
|
22 #include <time.h> |
|
23 |
|
24 #include "pushregistryhandler.h" |
|
25 #include "coreinterface.h" |
|
26 #include "rtcinterface.h" |
|
27 #include "commsendpoint.h" |
|
28 #include "commsmessage.h" |
|
29 #include "pushregistrymessages.h" |
|
30 #include "javacommonutils.h" |
|
31 #include "logger.h" |
|
32 #include "pushconstant.h" |
|
33 #include "pushexception.h" |
|
34 #include "pusherrorcodes.h" |
|
35 #include "pushdbhandler.h" |
|
36 #include "pushdatacontainer.h" |
|
37 #include "pushalarmhandler.h" |
|
38 #include "javauid.h" |
|
39 #include "booteventprovidermessages.h" |
|
40 #include "mmceventprovidermessages.h" |
|
41 |
|
42 using namespace java::push; |
|
43 using namespace java::captain; |
|
44 using namespace java::comms; |
|
45 using namespace java::util; |
|
46 using namespace java::fileutils; |
|
47 using namespace std; |
|
48 |
|
49 /*extern "C"*/ |
|
50 #ifdef __SYMBIAN32__ |
|
51 ExtensionPluginInterface* getExtensionPlugin() |
|
52 { |
|
53 #else |
|
54 extern "C" ExtensionPluginInterface* getExtensionPlugin() |
|
55 { |
|
56 #endif |
|
57 return new PushRegistryHandler(); |
|
58 } |
|
59 |
|
60 /** |
|
61 * |
|
62 */ |
|
63 OS_EXPORT PushRegistryHandler::PushRegistryHandler() |
|
64 :mCore(NULL),mPushDbHandler(new PushDBHandler()),mPushDataContainer(NULL), |
|
65 mPushAlarmHandler(NULL),mConnCompletedTimerContainer(NULL) |
|
66 { |
|
67 JELOG2(EJavaPush); |
|
68 //LOG1(EJavaPush,EInfo,"PushRegistryHandler(), this: %d",this); |
|
69 } |
|
70 |
|
71 /** |
|
72 * |
|
73 */ |
|
74 OS_EXPORT PushRegistryHandler::~PushRegistryHandler() |
|
75 { |
|
76 JELOG2(EJavaPush); |
|
77 mDriveInfo.clear(); |
|
78 //LOG1(EJavaPush,EInfo,"~PushRegistryHandler(), this: %d",this); |
|
79 } |
|
80 |
|
81 /** |
|
82 * |
|
83 */ |
|
84 void PushRegistryHandler::startPlugin(java::captain::CoreInterface* aCore) |
|
85 { |
|
86 JELOG2(EJavaPush); |
|
87 |
|
88 try |
|
89 { |
|
90 mCore = aCore; |
|
91 mCore->getComms()->registerListener(PLUGIN_ID_PUSH_REGISTRY_C,this); |
|
92 mPushDataContainer.reset(new PushDataContainer(*mCore,*mPushDbHandler)); |
|
93 mPushAlarmHandler.reset(new PushAlarmHandler(*mCore,*this,*mPushDbHandler)); |
|
94 mConnCompletedTimerContainer.reset |
|
95 (new PushConnCompletedTimerContainer(*aCore->getTimerServer(),*this)); |
|
96 } |
|
97 catch (...) |
|
98 { |
|
99 ELOG(EJavaPush,"ERROR!!! Exception caught in the PushRegistryHandler::start() operation"); |
|
100 } |
|
101 } |
|
102 |
|
103 /** |
|
104 * |
|
105 */ |
|
106 void PushRegistryHandler::stopPlugin() |
|
107 { |
|
108 JELOG2(EJavaPush); |
|
109 |
|
110 mCore->getComms()->unregisterListener(PLUGIN_ID_PUSH_REGISTRY_C,this); |
|
111 } |
|
112 |
|
113 /** |
|
114 * |
|
115 */ |
|
116 ApplicationRuntimeEventsInterface* PushRegistryHandler::getApplicationRuntimeListener() |
|
117 { |
|
118 return this; |
|
119 } |
|
120 |
|
121 /** |
|
122 * |
|
123 */ |
|
124 ApplicationManagementEventsInterface* PushRegistryHandler::getApplicationManagementListener() |
|
125 { |
|
126 return this; |
|
127 } |
|
128 |
|
129 /** |
|
130 * |
|
131 */ |
|
132 EventConsumerInterface* PushRegistryHandler::getEventConsumer() |
|
133 { |
|
134 return this; |
|
135 } |
|
136 |
|
137 /** |
|
138 * |
|
139 */ |
|
140 void PushRegistryHandler::processMessage(CommsMessage& aMessage) |
|
141 { |
|
142 JELOG2(EJavaPush); |
|
143 |
|
144 switch (aMessage.getMessageId()) |
|
145 { |
|
146 case IPC_PR_GET_ALL_PUSH_REGS: |
|
147 { |
|
148 handleGetAllPushRegsMsg(aMessage); |
|
149 break; |
|
150 } |
|
151 case IPC_PR_REGISTER_DYNAMIC_PUSH_CONN: |
|
152 { |
|
153 handleRegDynamicPushConnMsg(aMessage); |
|
154 break; |
|
155 } |
|
156 case IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN: |
|
157 { |
|
158 handleUnregDynamicPushConnMsg(aMessage); |
|
159 break; |
|
160 } |
|
161 case IPC_PR_REGISTER_ALARM: |
|
162 { |
|
163 handleRegisterAlarmMsg(aMessage); |
|
164 break; |
|
165 } |
|
166 case IPC_PR_ALL_CONNS_FAILED: |
|
167 { |
|
168 handleAllConnsFailedMsg(aMessage); |
|
169 break; |
|
170 } |
|
171 case IPC_PR_PENDING_STATUS: |
|
172 { |
|
173 handlePendingStatusMsg(aMessage); |
|
174 break; |
|
175 } |
|
176 case IPC_PR_LIST_CONNECTIONS: |
|
177 { |
|
178 handleListConnectionsMsg(aMessage); |
|
179 break; |
|
180 } |
|
181 case IPC_PR_DATA_OF_PUSH_CONN_QUERY: |
|
182 { |
|
183 handleDataOfPushConnQueryMsg(aMessage); |
|
184 break; |
|
185 } |
|
186 case IPC_PR_PUSH_URI_STARTS_WITH_QUERY: |
|
187 { |
|
188 handlePushUriStartsWithQueryMsg(aMessage); |
|
189 break; |
|
190 } |
|
191 case IPC_PR_CONN_COMPLETED: |
|
192 { |
|
193 handleConnCompletedMsg(aMessage); |
|
194 break; |
|
195 } |
|
196 |
|
197 default: |
|
198 ELOG1(EJavaPush, "ERROR!!! Unsupported method arrives to processMessage(): %d", |
|
199 aMessage.getMessageId()); |
|
200 }//end switch |
|
201 } |
|
202 |
|
203 /** |
|
204 * |
|
205 */ |
|
206 void PushRegistryHandler::arLaunched(const Uid& /*aUID*/, const int& /*aRuntimeCommsAddress*/) |
|
207 { |
|
208 JELOG2(EJavaPush); |
|
209 //Launch of the application does not interest push framework. |
|
210 } |
|
211 |
|
212 /** |
|
213 * |
|
214 */ |
|
215 void PushRegistryHandler::arTerminated(const Uid& aUID, const int& aExitCode) |
|
216 { |
|
217 JELOG2(EJavaPush); |
|
218 |
|
219 LOG1WSTR(EJavaPush,EInfo,"arTerminated(), Uid: %s",aUID.toString()); |
|
220 LOG1(EJavaPush,EInfo,"arTerminated(), aExitCode: %d",aExitCode); |
|
221 |
|
222 //MIDlet has been terminated so pending status of all its push connections |
|
223 //can be set to "not active" state. |
|
224 mPushDataContainer->clearPendingStatusesOfMidlet(aUID); |
|
225 |
|
226 bool flag = mPushDataContainer->isPushConnections(aUID); |
|
227 if (true == flag) |
|
228 { |
|
229 //aExitCode is non-zero if runtime has crashed. In that case MIDlet |
|
230 //is not launched as listening mode. |
|
231 if (0 != aExitCode) |
|
232 { |
|
233 ELOG1(EJavaPush,"ERROR!!! arTerminated(), aExitCode: %d",aExitCode); |
|
234 mPushDataContainer->setMidletDoNotLaunchList(aUID); |
|
235 } |
|
236 if (false == mPushDataContainer->isMidletInDoNotLaunchList(aUID)) |
|
237 { |
|
238 //Launching an application. |
|
239 LOG(EJavaPush,EInfo,"arTerminated(), launching application in push mode"); |
|
240 launchMidlet(aUID,java::captain::RTC_LAUNCH_TYPE_PUSH_C); |
|
241 } |
|
242 }//end if(true == flag) |
|
243 } |
|
244 |
|
245 /** |
|
246 * |
|
247 */ |
|
248 void PushRegistryHandler::amAdded(const uids_t& aUids) |
|
249 { |
|
250 JELOG2(EJavaPush); |
|
251 |
|
252 //JavaCaptain calls this method when new application has been installed or |
|
253 //application's uid has been changed in the upgrade. |
|
254 for (uids_t::const_iterator iter = aUids.begin(); iter != aUids.end(); ++iter) |
|
255 { |
|
256 //Alarm case have to be checked in this situation because uid of the alarm might |
|
257 //be changed in the upgrade. |
|
258 readAppData((*iter),true); |
|
259 }//end for |
|
260 } |
|
261 |
|
262 /** |
|
263 * |
|
264 */ |
|
265 void PushRegistryHandler::amUpdated(const uids_t& aUids) |
|
266 { |
|
267 JELOG2(EJavaPush); |
|
268 |
|
269 //JavaCaptain calls this operation when application's data has been updated |
|
270 //by Installer. In this situation uid of the appplication has not been updated. |
|
271 for (uids_t::const_iterator iter = aUids.begin(); iter != aUids.end(); ++iter) |
|
272 { |
|
273 deleteAppData((*iter),false); |
|
274 //Alarm does not have to be checked in this situation because uid of the |
|
275 //application has not been changed and Installer has not changed alarm. |
|
276 readAppData((*iter),false); |
|
277 } |
|
278 } |
|
279 |
|
280 /** |
|
281 * |
|
282 */ |
|
283 void PushRegistryHandler::amDeleted(const uids_t& aUids) |
|
284 { |
|
285 JELOG2(EJavaPush); |
|
286 |
|
287 //JavaCaptain calls this method when application has been uninstalled. |
|
288 //Note: This is called also in the upgrade of the application if application's |
|
289 //uid has been changed. |
|
290 for (uids_t::const_iterator iter = aUids.begin(); iter != aUids.end(); ++iter) |
|
291 { |
|
292 deleteAppData((*iter),true); |
|
293 }//end for |
|
294 } |
|
295 |
|
296 /** |
|
297 * |
|
298 */ |
|
299 void PushRegistryHandler::event(const std::string& eventProvider, |
|
300 java::comms::CommsMessage& aMsg) |
|
301 { |
|
302 JELOG2(EJavaPush); |
|
303 try |
|
304 { |
|
305 if (eventProvider == BOOT_EVENT_PROVIDER) |
|
306 { |
|
307 LOG(EJavaPush, EInfo, "PushRegistryHandler::event() boot event received"); |
|
308 int bootType = 0; |
|
309 getBootMessageParams(aMsg, bootType); |
|
310 //Read initial drive status. After that drive info status is updated |
|
311 //when mmc is inserted/deleted. JavaCaptain sends MMC_EVENT_PROVIDER event when mmc |
|
312 //status changes. |
|
313 mDriveInfo.clear(); |
|
314 DriveUtilities::getAccesibleDrives(mDriveInfo); |
|
315 startPushMidlets(); |
|
316 mPushAlarmHandler->readAndStartAlarms(); |
|
317 } |
|
318 else if (eventProvider == MMC_EVENT_PROVIDER) |
|
319 { |
|
320 int operation = 0; |
|
321 driveInfo di; |
|
322 getMmcChangedMessageParams(aMsg, operation, di); |
|
323 LOG1( |
|
324 EJavaCaptain, |
|
325 EInfo, |
|
326 "PushRegistryHandler::event() mmc event received (operation=%d)", |
|
327 operation); |
|
328 |
|
329 switch (operation) |
|
330 { |
|
331 case DriveListenerInterface::REMOVABLE_MEDIA_INSERTED_C: |
|
332 manageDriveInsertion(di); |
|
333 break; |
|
334 case DriveListenerInterface::REMOVABLE_MEDIA_REMOVED_C: |
|
335 manageDriveRemoval(di); |
|
336 break; |
|
337 } |
|
338 } |
|
339 } |
|
340 catch (ExceptionBase& ex) |
|
341 { |
|
342 ELOG1(EJavaPush,"ERROR!!! PushRegistryHandler::event(): %s",ex.toString().c_str()); |
|
343 } |
|
344 catch (...) |
|
345 { |
|
346 ELOG(EJavaPush,"ERROR!!! Exception caught in the PushRegistryHandler::event() operation"); |
|
347 } |
|
348 } |
|
349 |
|
350 /** |
|
351 * |
|
352 */ |
|
353 void PushRegistryHandler::connCompletedTimerExpired(const java::comms::CommsMessage& aMsg) |
|
354 { |
|
355 JELOG2(EJavaPush); |
|
356 |
|
357 try |
|
358 { |
|
359 CommsMessage unRegCompleted; |
|
360 unRegCompleted.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
361 unRegCompleted.setReceiver(aMsg.getSender()); |
|
362 unRegCompleted.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
363 unRegCompleted.setMessageId(IPC_PR_CONN_MANAGED_BY_OTHER_MIDLET); |
|
364 int retValue = mCore->getComms()->send(unRegCompleted); |
|
365 if (0 != retValue) |
|
366 { |
|
367 //Exception is not thrown from this situation. |
|
368 std::string errTxt("Sending IPC_PR_CONN_MANAGED_BY_OTHER_MIDLET comms request failed: "); |
|
369 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
370 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
371 } |
|
372 } |
|
373 catch (...) |
|
374 { |
|
375 ELOG(EJavaPush, |
|
376 "ERROR!!! Exception caught in the PushRegistryHandler::connCompletedTimerExpired() operation"); |
|
377 } |
|
378 } |
|
379 |
|
380 /** |
|
381 * |
|
382 */ |
|
383 void PushRegistryHandler::handleGetAllPushRegsMsg(CommsMessage& aMsg) |
|
384 { |
|
385 JELOG2(EJavaPush); |
|
386 |
|
387 Uid uid; |
|
388 try |
|
389 { |
|
390 readUidArg(aMsg,"IPC_PR_GET_ALL_PUSH_REGS",uid); |
|
391 std::list<PushRegData> listOfPushRegs; |
|
392 mPushDataContainer->getPushRegsOfMidlet(uid,listOfPushRegs); |
|
393 |
|
394 CommsMessage listOfPushRegsMsg; |
|
395 listOfPushRegsMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
396 listOfPushRegsMsg.setReceiver(aMsg.getSender()); |
|
397 listOfPushRegsMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
398 listOfPushRegsMsg.setMessageId(IPC_PR_LIST_OF_ALL_PUSH_REGS); |
|
399 listOfPushRegsMsg.setMessageRef(aMsg.getMessageRef()); |
|
400 |
|
401 listOfPushRegsMsg << uid; |
|
402 listOfPushRegsMsg << NO_ERROR; |
|
403 listOfPushRegsMsg << ""; |
|
404 std::list<PushRegData>::iterator iter; |
|
405 for (iter = listOfPushRegs.begin(); iter != listOfPushRegs.end(); ++iter) |
|
406 { |
|
407 LOG1(EJavaPush,EInfo, "handleGetAllPushRegsMsg() URI: %S",iter->mUri.c_str()); |
|
408 listOfPushRegsMsg << iter->mUri; |
|
409 listOfPushRegsMsg << iter->mFilter; |
|
410 }//end for |
|
411 |
|
412 int retValue = mCore->getComms()->send(listOfPushRegsMsg); |
|
413 if (0 != retValue) |
|
414 { |
|
415 //Exception is not thrown from this situation. |
|
416 std::string errTxt("Sending IPC_PR_LIST_OF_ALL_PUSH_REGS comms request failed: "); |
|
417 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
418 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
419 } |
|
420 } |
|
421 catch (ExceptionBase& ex) |
|
422 { |
|
423 sendCommsResponseInErrorCase(ex,IPC_PR_LIST_OF_ALL_PUSH_REGS,uid,aMsg.getSender(), |
|
424 aMsg.getMessageRef()); |
|
425 } |
|
426 catch (...) |
|
427 { |
|
428 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
429 __FILE__,__FUNCTION__,__LINE__); |
|
430 sendCommsResponseInErrorCase(tmpBase,IPC_PR_LIST_OF_ALL_PUSH_REGS,uid,aMsg.getSender(), |
|
431 aMsg.getMessageRef()); |
|
432 } |
|
433 } |
|
434 |
|
435 /** |
|
436 * |
|
437 */ |
|
438 void PushRegistryHandler::handleRegDynamicPushConnMsg(CommsMessage& aMsg) |
|
439 { |
|
440 JELOG2(EJavaPush); |
|
441 Uid uid; |
|
442 try |
|
443 { |
|
444 readUidArg(aMsg,"IPC_PR_REGISTER_DYNAMIC_PUSH_CONN",uid); |
|
445 |
|
446 std::wstring pushUri; |
|
447 readWStrArg(aMsg,"IPC_PR_REGISTER_DYNAMIC_PUSH_CONN",pushUri); |
|
448 |
|
449 std::wstring midletName; |
|
450 readWStrArg(aMsg,"IPC_PR_REGISTER_DYNAMIC_PUSH_CONN",midletName); |
|
451 |
|
452 std::wstring filter; |
|
453 readWStrArg(aMsg,"IPC_PR_REGISTER_DYNAMIC_PUSH_CONN",filter); |
|
454 |
|
455 int isUidOfThisMidlet = readIntAsBooleanArg(aMsg,"IPC_PR_REGISTER_DYNAMIC_PUSH_CONN"); |
|
456 |
|
457 mPushDataContainer->storeDynamicPushRegistration(uid,pushUri,midletName,filter); |
|
458 |
|
459 if (0 == isUidOfThisMidlet) |
|
460 { |
|
461 LOG1WSTR(EJavaPush,EInfo,"handleRegDynamicPushConnMsg() Uid: %s",uid.toString()); |
|
462 mConnCompletedTimerContainer->setTimer(pushUri,aMsg); |
|
463 launchMidlet(uid,java::captain::RTC_LAUNCH_TYPE_PUSH_C); |
|
464 } |
|
465 |
|
466 sendCommsResponseInSuccessCase(IPC_PR_REGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
467 aMsg.getMessageRef()); |
|
468 } |
|
469 catch (ExceptionBase& ex) |
|
470 { |
|
471 sendCommsResponseInErrorCase(ex,IPC_PR_REGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
472 aMsg.getMessageRef()); |
|
473 } |
|
474 catch (...) |
|
475 { |
|
476 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
477 __FILE__,__FUNCTION__,__LINE__); |
|
478 sendCommsResponseInErrorCase(tmpBase,IPC_PR_REGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
479 aMsg.getMessageRef()); |
|
480 } |
|
481 } |
|
482 |
|
483 /** |
|
484 * |
|
485 */ |
|
486 void PushRegistryHandler::handleUnregDynamicPushConnMsg(CommsMessage& aMsg) |
|
487 { |
|
488 JELOG2(EJavaPush); |
|
489 Uid uid; |
|
490 try |
|
491 { |
|
492 readUidArg(aMsg,"IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN",uid); |
|
493 std::wstring pushUri; |
|
494 readWStrArg(aMsg,"IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN",pushUri); |
|
495 int isUidOfThisMidlet = readIntAsBooleanArg(aMsg,"IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN"); |
|
496 |
|
497 mPushDataContainer->unregisterDynamicPushRegistration(uid,pushUri); |
|
498 |
|
499 if (0 == isUidOfThisMidlet) |
|
500 { |
|
501 LOG1WSTR(EJavaPush,EInfo,"handleUnregDynamicPushConnMsg() Uid: %s",uid.toString()); |
|
502 mConnCompletedTimerContainer->setTimer(pushUri,aMsg); |
|
503 launchMidlet(uid,java::captain::RTC_LAUNCH_TYPE_PUSH_C); |
|
504 } |
|
505 |
|
506 sendCommsResponseInSuccessCase(IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
507 aMsg.getMessageRef()); |
|
508 } |
|
509 catch (ExceptionBase& ex) |
|
510 { |
|
511 sendCommsResponseInErrorCase(ex,IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
512 aMsg.getMessageRef()); |
|
513 } |
|
514 catch (...) |
|
515 { |
|
516 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
517 __FILE__,__FUNCTION__,__LINE__); |
|
518 sendCommsResponseInErrorCase(tmpBase,IPC_PR_UNREGISTER_DYNAMIC_PUSH_CONN_REPLY,uid,aMsg.getSender(), |
|
519 aMsg.getMessageRef()); |
|
520 } |
|
521 } |
|
522 |
|
523 /** |
|
524 * |
|
525 */ |
|
526 void PushRegistryHandler::handleRegisterAlarmMsg(CommsMessage& aMsg) |
|
527 { |
|
528 JELOG2(EJavaPush); |
|
529 Uid suiteUid; |
|
530 long long retWakeupTime = -1LL; |
|
531 try |
|
532 { |
|
533 readUidArg(aMsg,"IPC_PR_REGISTER_ALARM",suiteUid); |
|
534 |
|
535 long long alarmTime = readLongLongArg(aMsg,"IPC_PR_REGISTER_ALARM"); |
|
536 |
|
537 std::wstring classNameOfMidlet; |
|
538 readWStrArg(aMsg,"IPC_PR_REGISTER_ALARM",classNameOfMidlet); |
|
539 |
|
540 int isUidOfThisMidlet = readIntAsBooleanArg(aMsg,"IPC_PR_REGISTER_ALARM"); |
|
541 bool isUidOfThisMidletAsBool = false; |
|
542 if (1 == isUidOfThisMidlet) |
|
543 isUidOfThisMidletAsBool = true; |
|
544 |
|
545 const java::util::Uid& midletUid = mPushDataContainer->getMidletUid(suiteUid,classNameOfMidlet); |
|
546 retWakeupTime = mPushAlarmHandler->setAlarm(midletUid,alarmTime,isUidOfThisMidletAsBool); |
|
547 sendRegisterAlarmReply(aMsg.getSender(),suiteUid,retWakeupTime,aMsg.getMessageRef()); |
|
548 } |
|
549 catch (ExceptionBase& ex) |
|
550 { |
|
551 sendRegisterAlarmReplyInErrorCase(ex,aMsg.getSender(),suiteUid,aMsg.getMessageRef()); |
|
552 } |
|
553 catch (...) |
|
554 { |
|
555 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
556 __FILE__,__FUNCTION__,__LINE__); |
|
557 sendRegisterAlarmReplyInErrorCase(tmpBase,aMsg.getSender(),suiteUid,aMsg.getMessageRef()); |
|
558 } |
|
559 } |
|
560 |
|
561 /** |
|
562 * |
|
563 */ |
|
564 void PushRegistryHandler::handleAllConnsFailedMsg(CommsMessage& aMsg) |
|
565 { |
|
566 JELOG2(EJavaPush); |
|
567 |
|
568 try |
|
569 { |
|
570 Uid uid; |
|
571 readUidArg(aMsg,"IPC_PR_ALL_CONNS_FAILED",uid); |
|
572 mPushDataContainer->setMidletDoNotLaunchList(uid); |
|
573 RtcInterface* rtc = mCore->getRtc(); |
|
574 rtc->terminate(uid); |
|
575 } |
|
576 catch (...) |
|
577 { |
|
578 ELOG(EJavaPush,"ERROR!!! Exception occurs in the handling a IPC_PR_ALL_CONNS_FAILED comms msg"); |
|
579 } |
|
580 } |
|
581 |
|
582 /** |
|
583 * |
|
584 */ |
|
585 void PushRegistryHandler::handlePendingStatusMsg(CommsMessage& aMsg) |
|
586 { |
|
587 JELOG2(EJavaPush); |
|
588 |
|
589 try |
|
590 { |
|
591 Uid uid; |
|
592 readUidArg(aMsg,"IPC_PR_PENDING_STATUS",uid); |
|
593 |
|
594 std::wstring pushUri; |
|
595 readWStrArg(aMsg,"IPC_PR_PENDING_STATUS",pushUri); |
|
596 |
|
597 int msgWaitsHandling = readIntAsBooleanArg(aMsg,"IPC_PR_PENDING_STATUS"); |
|
598 bool msgWaitsHandlingFlag = false; |
|
599 if (1 == msgWaitsHandling) |
|
600 msgWaitsHandlingFlag = true; |
|
601 |
|
602 mPushDataContainer->setPendingStatusOfConn(uid,pushUri,msgWaitsHandlingFlag); |
|
603 } |
|
604 catch (...) |
|
605 { |
|
606 ELOG(EJavaPush,"ERROR!!! Exception occurs in the handling a IPC_PR_PENDING_STATUS comms msg"); |
|
607 } |
|
608 } |
|
609 |
|
610 /** |
|
611 * |
|
612 */ |
|
613 void PushRegistryHandler::handleListConnectionsMsg(CommsMessage& aMsg) |
|
614 { |
|
615 JELOG2(EJavaPush); |
|
616 |
|
617 Uid uid; |
|
618 try |
|
619 { |
|
620 readUidArg(aMsg,"IPC_PR_LIST_CONNECTIONS",uid); |
|
621 int availableConns = readIntAsBooleanArg(aMsg,"IPC_PR_LIST_CONNECTIONS"); |
|
622 bool allConnsFlag = true; |
|
623 if (1 == availableConns) |
|
624 allConnsFlag = false; |
|
625 |
|
626 std::list<std::wstring> listOfPushUris; |
|
627 mPushDataContainer->getPushRegsOfMidletSuite(uid,allConnsFlag,listOfPushUris); |
|
628 |
|
629 CommsMessage listConnsReply; |
|
630 listConnsReply.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
631 listConnsReply.setReceiver(aMsg.getSender()); |
|
632 listConnsReply.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
633 listConnsReply.setMessageId(IPC_PR_LIST_CONNECTIONS_REPLY); |
|
634 listConnsReply.setMessageRef(aMsg.getMessageRef()); |
|
635 listConnsReply << uid; |
|
636 listConnsReply << NO_ERROR; |
|
637 listConnsReply << ""; |
|
638 std::list<std::wstring>::iterator iter; |
|
639 for (iter = listOfPushUris.begin(); iter != listOfPushUris.end(); ++iter) |
|
640 { |
|
641 LOG1WSTR(EJavaPush,EInfo,"handleListConnectionsMsg() URI: %s",(*iter)); |
|
642 listConnsReply << (*iter); |
|
643 }//end for |
|
644 |
|
645 int retValue = mCore->getComms()->send(listConnsReply); |
|
646 if (0 != retValue) |
|
647 { |
|
648 //Exception is not thrown from this situation. |
|
649 std::string errTxt("Sending IPC_PR_LIST_CONNECTIONS_REPLY comms request failed: "); |
|
650 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
651 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
652 } |
|
653 } |
|
654 catch (ExceptionBase& ex) |
|
655 { |
|
656 sendCommsResponseInErrorCase(ex,IPC_PR_LIST_CONNECTIONS_REPLY,uid,aMsg.getSender(), |
|
657 aMsg.getMessageRef()); |
|
658 } |
|
659 catch (...) |
|
660 { |
|
661 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
662 __FILE__,__FUNCTION__,__LINE__); |
|
663 sendCommsResponseInErrorCase(tmpBase,IPC_PR_LIST_CONNECTIONS_REPLY,uid,aMsg.getSender(), |
|
664 aMsg.getMessageRef()); |
|
665 } |
|
666 } |
|
667 |
|
668 /** |
|
669 * |
|
670 */ |
|
671 void PushRegistryHandler::handleDataOfPushConnQueryMsg(CommsMessage& aMsg) |
|
672 { |
|
673 JELOG2(EJavaPush); |
|
674 |
|
675 Uid suiteUid; |
|
676 string nameOfMsg("IPC_PR_DATA_OF_PUSH_CONN_QUERY"); |
|
677 try |
|
678 { |
|
679 readUidArg(aMsg,nameOfMsg,suiteUid); |
|
680 std::wstring uriAsStr; |
|
681 readWStrArg(aMsg,nameOfMsg,uriAsStr); |
|
682 int queryArg = readIntArg(aMsg,nameOfMsg); |
|
683 |
|
684 std::wstring retStr; |
|
685 if (FILTER_OF_PUSH_CONN == (EPushInfoQueryParams) queryArg) |
|
686 retStr = mPushDataContainer->getFilterOfPushConn(suiteUid,uriAsStr); |
|
687 else if (CLASSNAME_OF_PUSH_CONN == (EPushInfoQueryParams) queryArg) |
|
688 retStr = mPushDataContainer->getClassNameOfPushConn(suiteUid,uriAsStr); |
|
689 else |
|
690 { |
|
691 throw PushException(INCORRECT_COMMS_MSG,"Incorrect value in the query param", |
|
692 __FILE__,__FUNCTION__,__LINE__); |
|
693 } |
|
694 |
|
695 CommsMessage replyMsg; |
|
696 replyMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
697 replyMsg.setReceiver(aMsg.getSender()); |
|
698 replyMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
699 replyMsg.setMessageId(IPC_PR_DATA_OF_PUSH_CONN_QUERY_REPLY); |
|
700 replyMsg.setMessageRef(aMsg.getMessageRef()); |
|
701 replyMsg << suiteUid; |
|
702 replyMsg << NO_ERROR; |
|
703 replyMsg << ""; |
|
704 replyMsg << retStr; |
|
705 |
|
706 int retValue = mCore->getComms()->send(replyMsg); |
|
707 if (0 != retValue) |
|
708 { |
|
709 //Exception is not thrown from this situation. |
|
710 std::string errTxt("Sending IPC_PR_DATA_OF_PUSH_CONN_QUERY_REPLY comms request failed: "); |
|
711 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
712 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
713 } |
|
714 } |
|
715 catch (ExceptionBase& ex) |
|
716 { |
|
717 sendCommsResponseInErrorCase(ex,IPC_PR_DATA_OF_PUSH_CONN_QUERY_REPLY,suiteUid, |
|
718 aMsg.getSender(),aMsg.getMessageRef()); |
|
719 } |
|
720 catch (...) |
|
721 { |
|
722 ExceptionBase tmpBase(UNKNOWN_ERROR,"Unknown exception caught", |
|
723 __FILE__,__FUNCTION__,__LINE__); |
|
724 sendCommsResponseInErrorCase(tmpBase,IPC_PR_DATA_OF_PUSH_CONN_QUERY_REPLY,suiteUid, |
|
725 aMsg.getSender(),aMsg.getMessageRef()); |
|
726 } |
|
727 } |
|
728 |
|
729 /** |
|
730 * |
|
731 */ |
|
732 void PushRegistryHandler::handlePushUriStartsWithQueryMsg(CommsMessage& aMsg) |
|
733 { |
|
734 JELOG2(EJavaPush); |
|
735 |
|
736 try |
|
737 { |
|
738 std::wstring uriAsStr; |
|
739 readWStrArg(aMsg,"IPC_PR_PUSH_URI_STARTS_WITH_QUERY",uriAsStr); |
|
740 |
|
741 Uid suiteUid; |
|
742 bool uriFound = mPushDataContainer->getSuiteUidByBaseUri(uriAsStr,suiteUid); |
|
743 int status = -1; |
|
744 if (true == uriFound) |
|
745 status = 0; |
|
746 |
|
747 CommsMessage replyMsg; |
|
748 replyMsg.replyTo(aMsg); |
|
749 replyMsg.setMessageId(IPC_PR_PUSH_URI_STARTS_WITH_QUERY_REPLY); |
|
750 replyMsg << status; |
|
751 if (0 == status) |
|
752 replyMsg << suiteUid; |
|
753 int retValue = mCore->getComms()->send(replyMsg); |
|
754 if (0 != retValue) |
|
755 { |
|
756 //Exception is not thrown from this situation. |
|
757 std::string errTxt("Sending IPC_PR_PUSH_URI_STARTS_WITH_QUERY_REPLY comms request failed: "); |
|
758 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
759 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
760 } |
|
761 } |
|
762 catch (...) |
|
763 { |
|
764 //Exceptions should not been thrown in this operation. |
|
765 sendPushUriStartsWithQueryReplyInErrorCase(aMsg); |
|
766 } |
|
767 } |
|
768 |
|
769 /** |
|
770 * |
|
771 */ |
|
772 void PushRegistryHandler::handleConnCompletedMsg(CommsMessage& aMsg) |
|
773 { |
|
774 JELOG2(EJavaPush); |
|
775 |
|
776 std::wstring pushUri; |
|
777 readWStrArg(aMsg,"IPC_PR_UNREG_COMPLETED",pushUri); |
|
778 |
|
779 mConnCompletedTimerContainer->cancelTimer(pushUri); |
|
780 } |
|
781 |
|
782 /** |
|
783 * |
|
784 */ |
|
785 void PushRegistryHandler::sendCommsResponseInSuccessCase(int aMsgId,const Uid& aUid, |
|
786 int aSenderOfOrigMsg,int aMsgRef) |
|
787 { |
|
788 JELOG2(EJavaPush); |
|
789 |
|
790 CommsMessage replyMsg; |
|
791 replyMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
792 replyMsg.setReceiver(aSenderOfOrigMsg); |
|
793 replyMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
794 replyMsg.setMessageId(aMsgId); |
|
795 replyMsg.setMessageRef(aMsgRef); |
|
796 |
|
797 replyMsg << aUid; |
|
798 replyMsg << NO_ERROR; |
|
799 replyMsg << ""; |
|
800 int retValue = mCore->getComms()->send(replyMsg); |
|
801 if (0 != retValue) |
|
802 { |
|
803 std::string errTxt("Sending a comms request failed: "); |
|
804 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
805 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
806 } |
|
807 } |
|
808 |
|
809 /** |
|
810 * |
|
811 */ |
|
812 void PushRegistryHandler::sendRegisterAlarmReply(int aSenderOfOrigMsg,const Uid& aUid, |
|
813 const long long& aTimeInMilliSecs,int aMsgRef) |
|
814 { |
|
815 JELOG2(EJavaPush); |
|
816 |
|
817 CommsMessage replyMsg; |
|
818 replyMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
819 replyMsg.setReceiver(aSenderOfOrigMsg); |
|
820 replyMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
821 replyMsg.setMessageId(IPC_PR_REGISTER_ALARM_REPLY); |
|
822 replyMsg.setMessageRef(aMsgRef); |
|
823 |
|
824 replyMsg << aUid; |
|
825 replyMsg << NO_ERROR; |
|
826 replyMsg << ""; |
|
827 replyMsg << aTimeInMilliSecs; |
|
828 int retValue = mCore->getComms()->send(replyMsg); |
|
829 if (0 != retValue) |
|
830 { |
|
831 std::string errTxt("Sending a comms request failed: "); |
|
832 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
833 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
834 } |
|
835 } |
|
836 |
|
837 /** |
|
838 * |
|
839 */ |
|
840 void PushRegistryHandler::sendRegisterAlarmReplyInErrorCase(ExceptionBase& aException, |
|
841 int aSenderOfOrigMsg, |
|
842 const Uid& aUid, |
|
843 int aMsgRef) |
|
844 { |
|
845 JELOG2(EJavaPush); |
|
846 std::string errTxt = aException.toString(); |
|
847 int errCode = aException.mErrCode; |
|
848 |
|
849 CommsMessage replyMsg; |
|
850 replyMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
851 replyMsg.setReceiver(aSenderOfOrigMsg); |
|
852 replyMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
853 replyMsg.setMessageId(IPC_PR_REGISTER_ALARM_REPLY); |
|
854 replyMsg.setMessageRef(aMsgRef); |
|
855 |
|
856 long long tmpTimeValue = 0LL; |
|
857 replyMsg << aUid; |
|
858 replyMsg << errCode; |
|
859 replyMsg << errTxt; |
|
860 replyMsg << tmpTimeValue; |
|
861 int retValue = mCore->getComms()->send(replyMsg); |
|
862 if (0 != retValue) |
|
863 { |
|
864 std::string errTxt("Sending an IPC_PR_REGISTER_ALARM_REPLY request failed: "); |
|
865 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
866 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
867 } |
|
868 } |
|
869 |
|
870 /** |
|
871 * |
|
872 */ |
|
873 void PushRegistryHandler::sendCommsResponseInErrorCase(ExceptionBase& aException, |
|
874 int aMsgId,const Uid& aUid, |
|
875 int aSenderOfOrigMsg, |
|
876 int aMsgRef) |
|
877 { |
|
878 JELOG2(EJavaPush); |
|
879 std::string errTxt = aException.toString(); |
|
880 int errCode = aException.mErrCode; |
|
881 |
|
882 CommsMessage replyMsg; |
|
883 replyMsg.setSender(IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
884 replyMsg.setReceiver(aSenderOfOrigMsg); |
|
885 replyMsg.setModuleId(PLUGIN_ID_PUSH_CONTROLLER_C); |
|
886 replyMsg.setMessageId(aMsgId); |
|
887 replyMsg.setMessageRef(aMsgRef); |
|
888 |
|
889 replyMsg << aUid; |
|
890 replyMsg << errCode; |
|
891 replyMsg << errTxt; |
|
892 //This error is ignored because original error is wanted to show to the user. |
|
893 int retValue = mCore->getComms()->send(replyMsg); |
|
894 if (0 != retValue) |
|
895 { |
|
896 std::string errTxt("Sending a comms request failed: "); |
|
897 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
898 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
899 } |
|
900 } |
|
901 |
|
902 /** |
|
903 * |
|
904 */ |
|
905 void PushRegistryHandler::sendPushUriStartsWithQueryReplyInErrorCase(CommsMessage& aMsg) |
|
906 { |
|
907 JELOG2(EJavaPush); |
|
908 |
|
909 try |
|
910 { |
|
911 CommsMessage replyMsg; |
|
912 replyMsg.replyTo(aMsg); |
|
913 replyMsg.setMessageId(IPC_PR_PUSH_URI_STARTS_WITH_QUERY_REPLY); |
|
914 replyMsg << (int) -1; |
|
915 int retValue = mCore->getComms()->send(replyMsg); |
|
916 if (0 != retValue) |
|
917 { |
|
918 //Exception is not thrown from this situation. |
|
919 std::string errTxt("Sending IPC_PR_PUSH_URI_STARTS_WITH_QUERY_REPLY comms request failed: "); |
|
920 errTxt.append(java::util::JavaCommonUtils::intToString(retValue)); |
|
921 ELOG1(EJavaPush, "ERROR!!! %s",errTxt.c_str()); |
|
922 } |
|
923 } |
|
924 catch (...) |
|
925 { |
|
926 ELOG(EJavaPush,"ERROR!!! Unexpected exception caught in sendPushUriStartsWithQueryReplyInErrorCase() operation"); |
|
927 } |
|
928 } |
|
929 |
|
930 /** |
|
931 * |
|
932 */ |
|
933 void PushRegistryHandler::startPushMidlets() |
|
934 { |
|
935 JELOG2(EJavaPush); |
|
936 //Retrieving all push registrations from the db. |
|
937 std::set<Uid> uidList; |
|
938 mPushDataContainer->getIdsOfMidlets(uidList); |
|
939 std::set<Uid>::iterator iter; |
|
940 for (iter = uidList.begin(); iter != uidList.end(); ++iter) |
|
941 { |
|
942 LOG1WSTR(EJavaPush,EInfo,"startPushMidlets() Uid: %s",iter->toString()); |
|
943 launchMidlet((*iter),java::captain::RTC_LAUNCH_TYPE_PUSH_C); |
|
944 } |
|
945 } |
|
946 |
|
947 /** |
|
948 * |
|
949 */ |
|
950 void PushRegistryHandler::deleteAppData(const java::util::Uid& aUid,const bool& aDeleteAlarm) |
|
951 { |
|
952 JELOG2(EJavaPush); |
|
953 if (true == aDeleteAlarm) |
|
954 { |
|
955 //Cancelling pending alarm. |
|
956 mPushAlarmHandler->cancelAlarm(aUid); |
|
957 } |
|
958 //Removing push registrations of the application from the internal cache. |
|
959 mPushDataContainer->removeApp(aUid); |
|
960 } |
|
961 |
|
962 /** |
|
963 * |
|
964 */ |
|
965 void PushRegistryHandler::readAppData(const java::util::Uid& aUid,const bool& aUpdateAlarm) |
|
966 { |
|
967 JELOG2(EJavaPush); |
|
968 if (true == aUpdateAlarm) |
|
969 { |
|
970 mPushAlarmHandler->readAndStartAlarms(aUid); |
|
971 } |
|
972 mPushDataContainer->readAppDataFromDb(aUid); |
|
973 bool isPushConns = mPushDataContainer->isPushConnections(aUid); |
|
974 if (true == isPushConns) |
|
975 { |
|
976 LOG1WSTR(EJavaPush,EInfo,"readAppData() Uid: %s",aUid.toString()); |
|
977 launchMidlet(aUid,java::captain::RTC_LAUNCH_TYPE_PUSH_C); |
|
978 } |
|
979 } |
|
980 |
|
981 /** |
|
982 * |
|
983 */ |
|
984 void PushRegistryHandler::manageDriveInsertion(const driveInfo& aDriveInfo) |
|
985 { |
|
986 JELOG2(EJavaPush); |
|
987 |
|
988 //On the safe side, first is checked whether a new drive already exists |
|
989 //in the mDriveInfo container. This should not never happened. |
|
990 removeDriveFromContainer(aDriveInfo); |
|
991 |
|
992 //Next a new drive is added to the mDriveInfo container. |
|
993 mDriveInfo.push_back(aDriveInfo); |
|
994 |
|
995 //Managing MIDlets which alarm was expired when added drive was not in the device. |
|
996 mPushAlarmHandler->handleDriveWasMissingMidlets(aDriveInfo.iId); |
|
997 |
|
998 //Launching all push MIDlets in the push mode which has been installed to a new drive. |
|
999 startOrKillMidlet(aDriveInfo.iId,false); |
|
1000 } |
|
1001 |
|
1002 /** |
|
1003 * |
|
1004 */ |
|
1005 void PushRegistryHandler::manageDriveRemoval(const driveInfo& aDriveInfo) |
|
1006 { |
|
1007 JELOG2(EJavaPush); |
|
1008 |
|
1009 //First is removed drive from the mDriveInfo container. |
|
1010 removeDriveFromContainer(aDriveInfo); |
|
1011 |
|
1012 //Killing all push MIDlets which are installed to the removed drive. |
|
1013 startOrKillMidlet(aDriveInfo.iId,true); |
|
1014 } |
|
1015 |
|
1016 /** |
|
1017 * |
|
1018 */ |
|
1019 void PushRegistryHandler::startOrKillMidlet(const unsigned int aMediaId, |
|
1020 bool aTerminateMidlet) |
|
1021 { |
|
1022 JELOG2(EJavaPush); |
|
1023 |
|
1024 //Retrieving uids of MIDlets installed to the added drive. |
|
1025 list<Uid> uidList; |
|
1026 mPushDataContainer->getMidletUidsByMediaId(aMediaId,uidList); |
|
1027 |
|
1028 //Start push MIDlets in push listening mode. |
|
1029 RtcInterface* rtc = mCore->getRtc(); |
|
1030 for (list<Uid>::const_iterator iter = uidList.begin(); iter != uidList.end(); ++iter) |
|
1031 { |
|
1032 if (false == aTerminateMidlet) |
|
1033 { |
|
1034 if (true == mPushDataContainer->isPushConnections((*iter))) |
|
1035 { |
|
1036 //MIDlet is removed from "do not launch" list also when |
|
1037 //mmc(wherein MIDlet has been installed) is inserted to the device. |
|
1038 mPushDataContainer->removeMidletFromDoNotLaunchList((*iter)); |
|
1039 LOG1WSTR(EJavaPush,EInfo,"startOrKillMidlet() launch Uid: %s",iter->toString()); |
|
1040 rtc->launch(rtcLaunchInfo((*iter),java::captain::RTC_LAUNCH_TYPE_PUSH_C)); |
|
1041 } |
|
1042 } |
|
1043 else |
|
1044 { |
|
1045 mPushDataContainer->clearPendingStatusesOfMidlet((*iter)); |
|
1046 LOG1WSTR(EJavaPush,EInfo,"startOrKillMidlet() terminate Uid: %s",iter->toString()); |
|
1047 rtc->terminate((*iter)); |
|
1048 } |
|
1049 } |
|
1050 uidList.clear(); |
|
1051 } |
|
1052 |
|
1053 /** |
|
1054 * |
|
1055 */ |
|
1056 void PushRegistryHandler::removeDriveFromContainer(const driveInfo& aDriveInfo) |
|
1057 { |
|
1058 for (driveInfos::iterator iter = mDriveInfo.begin(); iter != mDriveInfo.end();) |
|
1059 { |
|
1060 //Root path is unique for every drive and it is always available |
|
1061 //in the driveInfo so it is safe to compare equality of two driveInfo objects |
|
1062 //with this value. |
|
1063 //On the safe side, a whole list is looped through. |
|
1064 if (aDriveInfo.iRootPath == iter->iRootPath) |
|
1065 { |
|
1066 mDriveInfo.erase(iter); |
|
1067 continue; |
|
1068 } |
|
1069 else |
|
1070 ++iter; |
|
1071 }//end for |
|
1072 } |
|
1073 |
|
1074 /** |
|
1075 * |
|
1076 */ |
|
1077 bool PushRegistryHandler::isDriveAvailable(int aMediaId) |
|
1078 { |
|
1079 JELOG2(EJavaPush); |
|
1080 |
|
1081 driveInfos::iterator iter = mDriveInfo.begin(); |
|
1082 for (; iter != mDriveInfo.end(); ++iter) |
|
1083 { |
|
1084 if (aMediaId == iter->iId) |
|
1085 { |
|
1086 //iIsPresent should never be false when it is added to the mDriveInfo |
|
1087 //container. |
|
1088 if (true == iter->iIsPresent) |
|
1089 return true; |
|
1090 } |
|
1091 }//end for |
|
1092 return false; |
|
1093 } |
|
1094 |
|
1095 /** |
|
1096 * |
|
1097 */ |
|
1098 bool PushRegistryHandler::launchMidlet(const Uid& aMidletUid, |
|
1099 const int& aLaunchType) |
|
1100 { |
|
1101 JELOG2(EJavaPush); |
|
1102 |
|
1103 int mediaId = mPushDataContainer->getMediaIdByMidletUid(aMidletUid); |
|
1104 |
|
1105 bool isDriveAvailableFlag = false; |
|
1106 //Media id 0 is reserved for non-removable drives (e.g. c:\ drive) so |
|
1107 //we does not have to check drive's availability in that case. |
|
1108 if (0 == mediaId) |
|
1109 isDriveAvailableFlag = true; |
|
1110 else |
|
1111 { |
|
1112 if (UNDEFINED_MEDIA_ID != mediaId) |
|
1113 isDriveAvailableFlag = isDriveAvailable(mediaId); |
|
1114 } |
|
1115 |
|
1116 if ((MEDIA_ID_IN_LINUX == mediaId) || (true == isDriveAvailableFlag)) |
|
1117 { |
|
1118 LOG2(EJavaPush,EInfo,"MIDlet launched UID: %S, launch type: %d", |
|
1119 aMidletUid.toString().c_str(),aLaunchType); |
|
1120 RtcInterface* rtc = mCore->getRtc(); |
|
1121 rtc->launch(rtcLaunchInfo(aMidletUid,aLaunchType)); |
|
1122 return true; |
|
1123 } |
|
1124 return false; |
|
1125 } |
|
1126 |
|
1127 /** |
|
1128 * |
|
1129 */ |
|
1130 int PushRegistryHandler::getMediaIdByMidletUid(const Uid& aMidletUid) |
|
1131 { |
|
1132 JELOG2(EJavaPush); |
|
1133 |
|
1134 return mPushDataContainer->getMediaIdByMidletUid(aMidletUid); |
|
1135 } |
|
1136 |
|
1137 /** |
|
1138 * |
|
1139 */ |
|
1140 void PushRegistryHandler::readUidArg(CommsMessage& aMsg,const std::string& aMsgName,Uid& aUid) |
|
1141 { |
|
1142 if (!(aMsg >> aUid)) |
|
1143 { |
|
1144 std::string errTxt("Cannot read UID from "); |
|
1145 errTxt.append(aMsgName); |
|
1146 errTxt.append(" msg"); |
|
1147 ELOG1(EJavaPush,"ERROR!!! %s",errTxt.c_str()); |
|
1148 throw PushException(INCORRECT_COMMS_MSG,errTxt,__FILE__,__FUNCTION__,__LINE__); |
|
1149 } |
|
1150 } |
|
1151 |
|
1152 /** |
|
1153 * |
|
1154 */ |
|
1155 void PushRegistryHandler::readWStrArg(CommsMessage& aMsg,const std::string& aMsgName,std::wstring& aStr) |
|
1156 { |
|
1157 if (!(aMsg >> aStr)) |
|
1158 { |
|
1159 std::string errTxt("Cannot read wstring from "); |
|
1160 errTxt.append(aMsgName); |
|
1161 errTxt.append(" msg"); |
|
1162 ELOG1(EJavaPush,"ERROR!!! %s",errTxt.c_str()); |
|
1163 throw PushException(INCORRECT_COMMS_MSG,errTxt,__FILE__,__FUNCTION__,__LINE__); |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 /** |
|
1168 * |
|
1169 */ |
|
1170 int PushRegistryHandler::readIntAsBooleanArg(CommsMessage& aMsg,const std::string& aMsgName) |
|
1171 { |
|
1172 int retValue = readIntArg(aMsg,aMsgName); |
|
1173 |
|
1174 if ((0 != retValue) && (1 != retValue)) |
|
1175 { |
|
1176 std::string errTxt("Incorrect integer value in the "); |
|
1177 errTxt.append(aMsgName); |
|
1178 errTxt.append(" msg"); |
|
1179 ELOG1(EJavaPush,"ERROR!!! %s",errTxt.c_str()); |
|
1180 throw PushException(INCORRECT_COMMS_MSG,errTxt,__FILE__,__FUNCTION__,__LINE__); |
|
1181 } |
|
1182 return retValue; |
|
1183 } |
|
1184 |
|
1185 /** |
|
1186 * |
|
1187 */ |
|
1188 int PushRegistryHandler::readIntArg(CommsMessage& aMsg,const std::string& aMsgName) |
|
1189 { |
|
1190 int retValue = -1; |
|
1191 if (!(aMsg >> retValue)) |
|
1192 { |
|
1193 std::string errTxt("Cannot read int from "); |
|
1194 errTxt.append(aMsgName); |
|
1195 errTxt.append(" msg"); |
|
1196 ELOG1(EJavaPush,"ERROR!!! %s",errTxt.c_str()); |
|
1197 throw PushException(INCORRECT_COMMS_MSG,errTxt,__FILE__,__FUNCTION__,__LINE__); |
|
1198 } |
|
1199 return retValue; |
|
1200 } |
|
1201 |
|
1202 /** |
|
1203 * |
|
1204 */ |
|
1205 long long PushRegistryHandler::readLongLongArg(CommsMessage& aMsg,const std::string& aMsgName) |
|
1206 { |
|
1207 long long retValue = -1; |
|
1208 if (!(aMsg >> retValue)) |
|
1209 { |
|
1210 std::string errTxt("Cannot read long long value from "); |
|
1211 errTxt.append(aMsgName); |
|
1212 errTxt.append(" msg"); |
|
1213 ELOG1(EJavaPush,"ERROR!!! %s",errTxt.c_str()); |
|
1214 throw PushException(INCORRECT_COMMS_MSG,errTxt,__FILE__,__FUNCTION__,__LINE__); |
|
1215 } |
|
1216 return retValue; |
|
1217 } |
|
1218 |
|
1219 |