|
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 "logger.h" |
|
20 #include "pushdbhandler.h" |
|
21 #include "javacommonutils.h" |
|
22 #include "pusherrorcodes.h" |
|
23 #include "pushexception.h" |
|
24 #include "javastorageexception.h" |
|
25 #include "javastoragenames.h" |
|
26 |
|
27 using namespace java::push; |
|
28 using namespace java::storage; |
|
29 using namespace java::util; |
|
30 |
|
31 /** |
|
32 * |
|
33 */ |
|
34 PushDBHandler::PushDBHandler() |
|
35 : mDbStorage(NULL) |
|
36 { |
|
37 JELOG2(EJavaPush); |
|
38 } |
|
39 |
|
40 /** |
|
41 * |
|
42 */ |
|
43 PushDBHandler::~PushDBHandler() |
|
44 { |
|
45 JELOG2(EJavaPush); |
|
46 } |
|
47 |
|
48 /** |
|
49 * |
|
50 */ |
|
51 void PushDBHandler::storeDynamicPushRegistration(const java::util::Uid& aUid, |
|
52 const std::wstring& aUri, |
|
53 const std::wstring& aMidletName, |
|
54 const std::wstring& aFilter) |
|
55 { |
|
56 JELOG2(EJavaPush); |
|
57 try |
|
58 { |
|
59 JavaStorageApplicationEntry_t entries; |
|
60 JavaStorageEntry entry; |
|
61 entry.setEntry(URL,aUri,JavaStorageEntry::STRING); |
|
62 entries.insert(entry); |
|
63 entry.setEntry(NAME,aMidletName,JavaStorageEntry::STRING); |
|
64 entries.insert(entry); |
|
65 entry.setEntry(FILTER,aFilter,JavaStorageEntry::STRING); |
|
66 entries.insert(entry); |
|
67 entry.setEntry(REGISTRATION_TYPE,L"0",JavaStorageEntry::INT); |
|
68 entries.insert(entry); |
|
69 |
|
70 entry.setEntry(ID, aUid.toString()); |
|
71 entries.insert(entry); |
|
72 |
|
73 //ScopedLock lockObj(mMutex); |
|
74 openDbStorage(); |
|
75 mDbStorage->startTransaction(); |
|
76 mDbStorage->write(PUSH_REGISTRATIONS_TABLE,entries); |
|
77 mDbStorage->commitTransaction(); |
|
78 mDbStorage->close(); |
|
79 } |
|
80 catch (JavaStorageException& ex) |
|
81 { |
|
82 if (0 != mDbStorage.get()) |
|
83 { |
|
84 mDbStorage->rollbackTransaction(); |
|
85 mDbStorage->close(); |
|
86 } |
|
87 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
88 } |
|
89 catch (...) |
|
90 { |
|
91 WLOG(EJavaPush,"ERROR!!! Unexpected error in storeDynamicPushRegistration() operation"); |
|
92 if (0 != mDbStorage.get()) |
|
93 { |
|
94 mDbStorage->rollbackTransaction(); |
|
95 mDbStorage->close(); |
|
96 } |
|
97 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
98 } |
|
99 } |
|
100 |
|
101 /** |
|
102 * |
|
103 */ |
|
104 void PushDBHandler::unregisterDynamicPushRegistration(const java::util::Uid& aUid, |
|
105 const std::wstring& aUri) |
|
106 { |
|
107 JELOG2(EJavaPush); |
|
108 try |
|
109 { |
|
110 JavaStorageApplicationEntry_t entries; |
|
111 JavaStorageEntry entry; |
|
112 entry.setEntry(ID,aUid.toString(),JavaStorageEntry::STRING); |
|
113 entries.insert(entry); |
|
114 entry.setEntry(URL,aUri,JavaStorageEntry::STRING); |
|
115 entries.insert(entry); |
|
116 entry.setEntry(REGISTRATION_TYPE,L"0",JavaStorageEntry::INT); |
|
117 entries.insert(entry); |
|
118 |
|
119 //ScopedLock lockObj(mMutex); |
|
120 openDbStorage(); |
|
121 |
|
122 mDbStorage->startTransaction(); |
|
123 mDbStorage->remove(PUSH_REGISTRATIONS_TABLE,entries); |
|
124 mDbStorage->commitTransaction(); |
|
125 mDbStorage->close(); |
|
126 } |
|
127 catch (PushException& ex) |
|
128 { |
|
129 if (0 != mDbStorage.get()) |
|
130 { |
|
131 mDbStorage->close(); |
|
132 } |
|
133 throw; |
|
134 } |
|
135 catch (JavaStorageException& ex) |
|
136 { |
|
137 if (0 != mDbStorage.get()) |
|
138 { |
|
139 mDbStorage->rollbackTransaction(); |
|
140 mDbStorage->close(); |
|
141 } |
|
142 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
143 } |
|
144 catch (...) |
|
145 { |
|
146 WLOG(EJavaPush,"ERROR!!! Unexpected error in unregisterDynamicPushRegistration() operation"); |
|
147 if (0 != mDbStorage.get()) |
|
148 { |
|
149 mDbStorage->rollbackTransaction(); |
|
150 mDbStorage->close(); |
|
151 } |
|
152 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
153 } |
|
154 } |
|
155 |
|
156 /** |
|
157 * |
|
158 */ |
|
159 void PushDBHandler::storeAlarm(const Uid& aUid,const long long& aAlarmInMilliSecs) |
|
160 { |
|
161 JELOG2(EJavaPush); |
|
162 try |
|
163 { |
|
164 JavaStorageApplicationEntry_t entries; |
|
165 JavaStorageEntry entry; |
|
166 |
|
167 std::wstring timeStr = JavaCommonUtils::longLongToWstring(aAlarmInMilliSecs); |
|
168 entry.setEntry(ALARM_TIME,timeStr,JavaStorageEntry::STRING); |
|
169 entries.insert(entry); |
|
170 entry.setEntry(ID, aUid.toString()); |
|
171 entries.insert(entry); |
|
172 |
|
173 //ScopedLock lockObj(mMutex); |
|
174 openDbStorage(); |
|
175 mDbStorage->startTransaction(); |
|
176 mDbStorage->write(ALARM_REGISTRATIONS_TABLE,entries); |
|
177 mDbStorage->commitTransaction(); |
|
178 mDbStorage->close(); |
|
179 } |
|
180 catch (JavaStorageException& ex) |
|
181 { |
|
182 if (0 !=mDbStorage.get()) |
|
183 { |
|
184 mDbStorage->rollbackTransaction(); |
|
185 mDbStorage->close(); |
|
186 } |
|
187 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
188 } |
|
189 catch (...) |
|
190 { |
|
191 WLOG(EJavaPush,"ERROR!!! Unexpected error in storeAlarm() operation"); |
|
192 if (0 != mDbStorage.get()) |
|
193 { |
|
194 mDbStorage->rollbackTransaction(); |
|
195 mDbStorage->close(); |
|
196 } |
|
197 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
198 } |
|
199 } |
|
200 |
|
201 /** |
|
202 * |
|
203 */ |
|
204 void PushDBHandler::deleteAlarm(const Uid& aUid) |
|
205 { |
|
206 JELOG2(EJavaPush); |
|
207 try |
|
208 { |
|
209 JavaStorageApplicationEntry_t entries; |
|
210 JavaStorageEntry entry; |
|
211 entry.setEntry(ID, aUid.toString()); |
|
212 entries.insert(entry); |
|
213 |
|
214 //ScopedLock lockObj(mMutex); |
|
215 openDbStorage(); |
|
216 mDbStorage->startTransaction(); |
|
217 mDbStorage->remove(ALARM_REGISTRATIONS_TABLE,entries); |
|
218 mDbStorage->commitTransaction(); |
|
219 mDbStorage->close(); |
|
220 } |
|
221 catch (JavaStorageException& ex) |
|
222 { |
|
223 if (0 !=mDbStorage.get()) |
|
224 { |
|
225 mDbStorage->rollbackTransaction(); |
|
226 mDbStorage->close(); |
|
227 } |
|
228 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
229 } |
|
230 catch (...) |
|
231 { |
|
232 WLOG(EJavaPush,"ERROR!!! Unexpected error in deleteAlarm() operation"); |
|
233 if (0 != mDbStorage.get()) |
|
234 { |
|
235 mDbStorage->rollbackTransaction(); |
|
236 mDbStorage->close(); |
|
237 } |
|
238 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
239 } |
|
240 } |
|
241 |
|
242 /** |
|
243 * |
|
244 */ |
|
245 void PushDBHandler::getPushRegs(const java::util::Uid& aUid, |
|
246 java::storage::JavaStorageApplicationList_t& aPushRegs) |
|
247 { |
|
248 JELOG2(EJavaPush); |
|
249 try |
|
250 { |
|
251 JavaStorageApplicationEntry_t findPatterns; |
|
252 JavaStorageEntry findPattern; |
|
253 if (!aUid.isEmpty()) |
|
254 { |
|
255 findPattern.setEntry(ID,aUid.toString(),JavaStorageEntry::STRING); |
|
256 findPatterns.insert(findPattern); |
|
257 } |
|
258 |
|
259 //ScopedLock lockObj(mMutex); |
|
260 openDbStorage(); |
|
261 mDbStorage->search(PUSH_REGISTRATIONS_TABLE,findPatterns,aPushRegs); |
|
262 mDbStorage->close(); |
|
263 } |
|
264 catch (JavaStorageException& ex) |
|
265 { |
|
266 if (0 !=mDbStorage.get()) |
|
267 { |
|
268 mDbStorage->close(); |
|
269 } |
|
270 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
271 } |
|
272 catch (...) |
|
273 { |
|
274 WLOG(EJavaPush,"ERROR!!! Unexpected error in getPushRegs() operation"); |
|
275 if (0 != mDbStorage.get()) |
|
276 { |
|
277 mDbStorage->close(); |
|
278 } |
|
279 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
280 } |
|
281 } |
|
282 |
|
283 /** |
|
284 * |
|
285 */ |
|
286 void PushDBHandler::getAlarms(const java::util::Uid& aUid, |
|
287 std::list<DbAlarmData>& aAlarmList) |
|
288 { |
|
289 JELOG2(EJavaPush); |
|
290 try |
|
291 { |
|
292 JavaStorageEntry findPattern; |
|
293 JavaStorageApplicationEntry_t findPatterns; |
|
294 JavaStorageApplicationList_t foundEntries; |
|
295 if (!aUid.isEmpty()) |
|
296 { |
|
297 findPattern.setEntry(ID,aUid.toString(),JavaStorageEntry::STRING); |
|
298 findPatterns.insert(findPattern); |
|
299 } |
|
300 |
|
301 //ScopedLock lockObj(mMutex); |
|
302 openDbStorage(); |
|
303 mDbStorage->search(ALARM_REGISTRATIONS_TABLE,findPatterns,foundEntries); |
|
304 fillAlarmData(aAlarmList,foundEntries); |
|
305 mDbStorage->close(); |
|
306 } |
|
307 catch (JavaStorageException& ex) |
|
308 { |
|
309 if (0 !=mDbStorage.get()) |
|
310 { |
|
311 mDbStorage->close(); |
|
312 } |
|
313 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
314 } |
|
315 catch (...) |
|
316 { |
|
317 WLOG(EJavaPush,"ERROR!!! Unexpected error in getAlarms() operation"); |
|
318 if (0 != mDbStorage.get()) |
|
319 { |
|
320 mDbStorage->close(); |
|
321 } |
|
322 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
323 } |
|
324 } |
|
325 |
|
326 /** |
|
327 * |
|
328 */ |
|
329 void PushDBHandler::getMidletSuiteInfo(const java::util::Uid& aSuiteUid, |
|
330 std::multimap<Uid, |
|
331 MidletSuiteData>& aMidletSuiteInfo) |
|
332 { |
|
333 JELOG2(EJavaPush); |
|
334 |
|
335 getMidletSuiteInfo(aSuiteUid,PACKAGE_ID,aMidletSuiteInfo); |
|
336 } |
|
337 |
|
338 /** |
|
339 * |
|
340 */ |
|
341 void PushDBHandler::getMidletSuiteInfoByMidletUid |
|
342 (const Uid& aMidletUid,std::multimap<Uid,MidletSuiteData>& aMidletSuiteInfo) |
|
343 { |
|
344 JELOG2(EJavaPush); |
|
345 |
|
346 getMidletSuiteInfo(aMidletUid,ID,aMidletSuiteInfo); |
|
347 } |
|
348 |
|
349 /** |
|
350 * |
|
351 */ |
|
352 void PushDBHandler::getMidletSuiteInfo(const java::util::Uid& aUid, |
|
353 const std::wstring& aSearchColumn, |
|
354 std::multimap<Uid,MidletSuiteData>& aMidletSuiteInfo) |
|
355 { |
|
356 JELOG2(EJavaPush); |
|
357 |
|
358 try |
|
359 { |
|
360 JavaStorageEntry findPattern; |
|
361 JavaStorageApplicationEntry_t findPatterns; |
|
362 JavaStorageApplicationList_t foundEntries; |
|
363 if (!aUid.isEmpty()) |
|
364 { |
|
365 //Search condition can be PACKAGE_ID or ID. |
|
366 findPattern.setEntry(aSearchColumn,aUid.toString(),JavaStorageEntry::STRING); |
|
367 findPatterns.insert(findPattern); |
|
368 } |
|
369 |
|
370 findPattern.setEntry(PACKAGE_ID,L""); |
|
371 findPatterns.insert(findPattern); |
|
372 findPattern.setEntry(ID,L""); |
|
373 findPatterns.insert(findPattern); |
|
374 findPattern.setEntry(MAIN_CLASS,L""); |
|
375 findPatterns.insert(findPattern); |
|
376 |
|
377 //ScopedLock lockObj(mMutex); |
|
378 openDbStorage(); |
|
379 mDbStorage->search(APPLICATION_TABLE,findPatterns,foundEntries); |
|
380 fillMidletSuiteInfo(aMidletSuiteInfo,foundEntries); |
|
381 addMediaId(*mDbStorage.get(),aMidletSuiteInfo); |
|
382 mDbStorage->close(); |
|
383 } |
|
384 catch (ExceptionBase& ex) |
|
385 { |
|
386 if (0 !=mDbStorage.get()) |
|
387 { |
|
388 mDbStorage->close(); |
|
389 } |
|
390 throw PushException(DB_ERROR,ex.toString(),__FILE__,__FUNCTION__,__LINE__); |
|
391 } |
|
392 catch (...) |
|
393 { |
|
394 WLOG(EJavaPush,"ERROR!!! Unexpected error in getAlarms() operation"); |
|
395 if (0 != mDbStorage.get()) |
|
396 { |
|
397 mDbStorage->close(); |
|
398 } |
|
399 throw PushException(DB_ERROR,"Unexpected exception occurred",__FILE__,__FUNCTION__,__LINE__); |
|
400 } |
|
401 } |
|
402 |
|
403 /** |
|
404 * |
|
405 */ |
|
406 void PushDBHandler::addMediaId(JavaStorage& aStorageObj, |
|
407 std::multimap<Uid,MidletSuiteData>& aMidletSuiteInfo) |
|
408 { |
|
409 JELOG2(EJavaPush); |
|
410 |
|
411 std::map<Uid,int> mediaIdContainer; |
|
412 std::map<Uid,int>::iterator mediaIdContainerIter; |
|
413 |
|
414 std::multimap<Uid,MidletSuiteData>::iterator iter; |
|
415 for (iter = aMidletSuiteInfo.begin(); iter != aMidletSuiteInfo.end(); ++iter) |
|
416 { |
|
417 if (UNDEFINED_MEDIA_ID == iter->second.mMediaId) |
|
418 { |
|
419 mediaIdContainerIter = mediaIdContainer.find(iter->first); |
|
420 if (mediaIdContainer.end() == mediaIdContainerIter) |
|
421 { |
|
422 getMediaId(aStorageObj,iter->first,mediaIdContainer); |
|
423 mediaIdContainerIter = mediaIdContainer.find(iter->first); |
|
424 if (mediaIdContainer.end() == mediaIdContainerIter) |
|
425 { |
|
426 throw PushException(DB_ERROR,"media id by suite uid is not found", |
|
427 __FILE__,__FUNCTION__,__LINE__); |
|
428 } |
|
429 } |
|
430 iter->second.mMediaId = mediaIdContainerIter->second; |
|
431 }//end if(-1 == iter->second.mMediaId) |
|
432 }//end for |
|
433 |
|
434 mediaIdContainer.clear(); |
|
435 } |
|
436 |
|
437 /** |
|
438 * |
|
439 */ |
|
440 void PushDBHandler::getMediaId(JavaStorage& aStorageObj,const Uid& aSuiteUid, |
|
441 std::map<Uid,int>& aMediaIdContainer) |
|
442 { |
|
443 JavaStorageEntry findPattern; |
|
444 JavaStorageApplicationEntry_t findPatterns; |
|
445 JavaStorageApplicationList_t foundEntries; |
|
446 |
|
447 findPattern.setEntry(ID,aSuiteUid.toString(),JavaStorageEntry::STRING); |
|
448 findPatterns.insert(findPattern); |
|
449 findPattern.setEntry(MEDIA_ID,L""); |
|
450 findPatterns.insert(findPattern); |
|
451 |
|
452 aStorageObj.search(APPLICATION_PACKAGE_TABLE,findPatterns,foundEntries); |
|
453 fillMidletId(aSuiteUid,aMediaIdContainer,foundEntries); |
|
454 } |
|
455 |
|
456 /** |
|
457 * |
|
458 */ |
|
459 void PushDBHandler::fillMidletId(const Uid& aSuiteUid, |
|
460 std::map<Uid,int>& aMediaIdContainer, |
|
461 JavaStorageApplicationList_t& aFoundEntries) |
|
462 { |
|
463 JavaStorageEntry findPatternForMediaId; |
|
464 std::wstring empty = L""; |
|
465 findPatternForMediaId.setEntry(MEDIA_ID,empty); |
|
466 |
|
467 JavaStorageApplicationList_t::iterator iter; |
|
468 for (iter = aFoundEntries.begin(); iter != aFoundEntries.end(); ++iter) |
|
469 { |
|
470 int mediaId = 0; |
|
471 if ((true == getDbValueAsInt(iter,findPatternForMediaId,mediaId))) |
|
472 aMediaIdContainer.insert(std::pair<Uid,int>(aSuiteUid,mediaId)); |
|
473 }//end for |
|
474 } |
|
475 |
|
476 /** |
|
477 * |
|
478 */ |
|
479 void PushDBHandler::fillAlarmData(std::list<DbAlarmData>& aAlarmList, |
|
480 JavaStorageApplicationList_t& aFoundEntries) |
|
481 { |
|
482 JELOG2(EJavaPush); |
|
483 |
|
484 JavaStorageEntry findPatternForUid; |
|
485 std::wstring empty = L""; |
|
486 findPatternForUid.setEntry(ID,empty); |
|
487 |
|
488 JavaStorageEntry findPatternForTime; |
|
489 findPatternForTime.setEntry(ALARM_TIME,empty); |
|
490 |
|
491 JavaStorageApplicationList_t::iterator iter; |
|
492 for (iter = aFoundEntries.begin(); iter != aFoundEntries.end(); ++iter) |
|
493 { |
|
494 // Get application ID. |
|
495 Uid tmpUid; |
|
496 long long tmpTime = 0LL; |
|
497 if ((true == getDbValueAsUid(iter,findPatternForUid,tmpUid)) |
|
498 && (true == getDbValueAsLongLong(iter,findPatternForTime,tmpTime))) |
|
499 { |
|
500 DbAlarmData alarmData(tmpUid,tmpTime,true); |
|
501 aAlarmList.push_back(alarmData); |
|
502 } |
|
503 }//end for |
|
504 } |
|
505 |
|
506 /** |
|
507 * |
|
508 */ |
|
509 void PushDBHandler::fillMidletSuiteInfo(std::multimap<Uid,MidletSuiteData>& aMidletSuiteInfo, |
|
510 JavaStorageApplicationList_t& aFoundEntries) |
|
511 { |
|
512 JELOG2(EJavaPush); |
|
513 |
|
514 JavaStorageEntry findPatternForSuiteUid; |
|
515 std::wstring empty = L""; |
|
516 findPatternForSuiteUid.setEntry(PACKAGE_ID,empty); |
|
517 |
|
518 JavaStorageEntry findPatternForMidletUid; |
|
519 findPatternForMidletUid.setEntry(ID,empty); |
|
520 |
|
521 JavaStorageEntry findPatternForMainClass; |
|
522 findPatternForMainClass.setEntry(MAIN_CLASS,empty); |
|
523 |
|
524 JavaStorageApplicationList_t::iterator iter; |
|
525 for (iter = aFoundEntries.begin(); iter != aFoundEntries.end(); ++iter) |
|
526 { |
|
527 Uid tmpSuiteUid; |
|
528 Uid tmpMidletUid; |
|
529 std::wstring className; |
|
530 if ((true == getDbValueAsUid(iter,findPatternForSuiteUid,tmpSuiteUid)) |
|
531 && (true == getDbValueAsUid(iter,findPatternForMidletUid,tmpMidletUid)) |
|
532 && (true == getDbValueAsWStr(iter,findPatternForMainClass,className))) |
|
533 { |
|
534 MidletSuiteData dataObj(tmpMidletUid,className); |
|
535 aMidletSuiteInfo.insert(std::pair<Uid,MidletSuiteData>(tmpSuiteUid,dataObj)); |
|
536 } |
|
537 }//end for |
|
538 } |
|
539 |
|
540 /** |
|
541 * |
|
542 */ |
|
543 bool PushDBHandler::getDbValueAsUid(JavaStorageApplicationList_t::iterator& aIter, |
|
544 JavaStorageEntry& aFindPattern,Uid& aOutput) |
|
545 { |
|
546 JavaStorageApplicationEntry_t::iterator tmpIter = aIter->find(aFindPattern); |
|
547 if (tmpIter != aIter->end()) |
|
548 { |
|
549 std::wstring uidAsStr = tmpIter->entryValue(); |
|
550 if (0 != uidAsStr.compare(L"")) |
|
551 { |
|
552 Uid tmpUid(uidAsStr); |
|
553 aOutput = uidAsStr; |
|
554 return true; |
|
555 } |
|
556 }//end if(tmpIter != aIter->end()) |
|
557 return false; |
|
558 } |
|
559 |
|
560 /** |
|
561 * |
|
562 */ |
|
563 bool PushDBHandler::getDbValueAsLongLong(JavaStorageApplicationList_t::iterator& aIter, |
|
564 JavaStorageEntry& aFindPattern,long long& aOutput) |
|
565 { |
|
566 JavaStorageApplicationEntry_t::iterator tmpIter = aIter->find(aFindPattern); |
|
567 if (tmpIter != aIter->end()) |
|
568 { |
|
569 std::wstring longLongAsStr = tmpIter->entryValue(); |
|
570 if (0 != longLongAsStr.compare(L"")) |
|
571 { |
|
572 aOutput = JavaCommonUtils::wstringToLongLong(longLongAsStr); |
|
573 return true; |
|
574 } |
|
575 }//end if(tmpIter != aIter->end()) |
|
576 return false; |
|
577 } |
|
578 |
|
579 /** |
|
580 * |
|
581 */ |
|
582 bool PushDBHandler::getDbValueAsInt(JavaStorageApplicationList_t::iterator& aIter, |
|
583 JavaStorageEntry& aFindPattern,int& aOutput) |
|
584 { |
|
585 JavaStorageApplicationEntry_t::iterator tmpIter = aIter->find(aFindPattern); |
|
586 if (tmpIter != aIter->end()) |
|
587 { |
|
588 std::wstring intAsStr = tmpIter->entryValue(); |
|
589 if (0 != intAsStr.compare(L"")) |
|
590 { |
|
591 aOutput = JavaCommonUtils::wstringToInt(intAsStr); |
|
592 return true; |
|
593 } |
|
594 }//end if(tmpIter != aIter->end()) |
|
595 return false; |
|
596 } |
|
597 |
|
598 /** |
|
599 * |
|
600 */ |
|
601 bool PushDBHandler::getDbValueAsWStr(JavaStorageApplicationList_t::iterator& aIter, |
|
602 JavaStorageEntry& aFindPattern,std::wstring& aOutput) |
|
603 { |
|
604 JavaStorageApplicationEntry_t::iterator tmpIter = aIter->find(aFindPattern); |
|
605 if (tmpIter != aIter->end()) |
|
606 { |
|
607 aOutput = tmpIter->entryValue(); |
|
608 if (0 != aOutput.compare(L"")) |
|
609 { |
|
610 return true; |
|
611 } |
|
612 }//end if(tmpIter != aIter->end()) |
|
613 return false; |
|
614 } |
|
615 |
|
616 /** |
|
617 * |
|
618 */ |
|
619 void PushDBHandler::openDbStorage() |
|
620 { |
|
621 JELOG2(EJavaPush); |
|
622 |
|
623 if (0 == mDbStorage.get()) |
|
624 mDbStorage.reset(JavaStorage::createInstance()); |
|
625 |
|
626 mDbStorage->open("JavaStorage"); |
|
627 } |
|
628 |
|
629 /** |
|
630 * IMPLEMENTATION OF DbAlarmData CLASS. |
|
631 */ |
|
632 DbAlarmData::DbAlarmData(const Uid& aUid,const long long& aTimeInMilliSecs,bool aValidateTime) |
|
633 : mUid(aUid),mTimeInMilliSecs(aTimeInMilliSecs),mValidateTime(aValidateTime) |
|
634 { |
|
635 } |
|
636 |
|
637 DbAlarmData::~DbAlarmData() |
|
638 { |
|
639 } |
|
640 |
|
641 DbAlarmData::DbAlarmData(const DbAlarmData& x) |
|
642 { |
|
643 *this = x; |
|
644 } |
|
645 |
|
646 const Uid& DbAlarmData::getUid() const |
|
647 { |
|
648 return mUid; |
|
649 } |
|
650 |
|
651 long long DbAlarmData::getTime() const |
|
652 { |
|
653 return mTimeInMilliSecs; |
|
654 } |
|
655 |
|
656 bool DbAlarmData::validateAlarmTime() const |
|
657 { |
|
658 return mValidateTime; |
|
659 } |
|
660 |
|
661 DbAlarmData& DbAlarmData::operator=(const DbAlarmData& x) |
|
662 { |
|
663 mUid = x.mUid; |
|
664 mTimeInMilliSecs = x.mTimeInMilliSecs; |
|
665 mValidateTime = x.mValidateTime; |
|
666 return *this; |
|
667 } |
|
668 |
|
669 |
|
670 |