5af0dc8e8d951432e580906960bf1854cc342e2e
[platform/core/messaging/msg-service.git] / proxy / MsgHandleStorage.cpp
1  /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *    http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #include "MsgDebug.h"
18 #include "MsgUtilFile.h"
19 #include "MsgCppTypes.h"
20 #include "MsgException.h"
21 #include "MsgUtilFunction.h"
22 #include "MsgProxyListener.h"
23 #include "MsgHandle.h"
24
25 #include "MsgStorageHandler.h"
26
27
28 /*==================================================================================================
29                                      IMPLEMENTATION OF MsgHandle - Storage Member Functions
30 ==================================================================================================*/
31 int MsgHandle::addMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
32 {
33         MSG_MESSAGE_INFO_S msgInfo = {0};
34         MSG_SENDINGOPT_INFO_S sendOptInfo;
35
36         // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
37         convertMsgStruct(pMsg, &msgInfo);
38
39         // Covert MSG_SENDINGOPT_S to MSG_SENDINGOPT_INFO_S
40         convertSendOptStruct(pSendOpt, &sendOptInfo, pMsg->msgType);
41
42         // Allocate Memory to Command Data
43         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
44
45         char cmdBuf[cmdSize];
46         bzero(cmdBuf, cmdSize);
47         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
48
49         // Set Command Parameters
50         pCmd->cmdType = MSG_CMD_ADD_MSG;
51
52         // Copy Cookie
53         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
54
55         // Copy Command Data
56         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
57         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
58
59         // Send Command to Messaging FW
60         char* pEventData = NULL;
61         AutoPtr<char> eventBuf(&pEventData);
62
63         write((char*)pCmd, cmdSize, &pEventData);
64
65         // Get Return Data
66         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
67
68         if (pEvent->eventType != MSG_EVENT_ADD_MSG)
69         {
70                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
71         }
72
73         if (pEvent->result != MSG_SUCCESS) return pEvent->result;
74
75         MSG_MESSAGE_ID_T msgId = 0;
76
77         // Decode Return Data
78         MsgDecodeMsgId(pEvent->data, &msgId);
79
80         return (int)msgId;
81 }
82
83
84 MSG_ERROR_T MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
85 {
86         MSG_MESSAGE_INFO_S msgInfo;
87
88         // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
89         convertMsgStruct((MSG_MESSAGE_S*)pSyncMLMsg->msg, &msgInfo);
90
91         // Allocate Memory to Command Data
92         int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(int) + sizeof(MSG_MESSAGE_INFO_S);
93
94         char cmdBuf[cmdSize];
95         bzero(cmdBuf, cmdSize);
96         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
97
98         // Set Command Parameters
99         pCmd->cmdType = MSG_CMD_ADD_SYNCML_MSG;
100
101         // Copy Cookie
102         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
103
104         // Copy Command Data
105         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pSyncMLMsg->extId, sizeof(int));
106         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), &pSyncMLMsg->pinCode, sizeof(int));
107         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
108
109         // Send Command to Messaging FW
110         char* pEventData = NULL;
111         AutoPtr<char> eventBuf(&pEventData);
112
113
114         write((char*)pCmd, cmdSize, &pEventData);
115
116         // Get Return Data
117         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
118
119         if (pEvent->eventType != MSG_EVENT_ADD_SYNCML_MSG)
120         {
121                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
122         }
123
124         return pEvent->result;
125 }
126
127
128 MSG_ERROR_T MsgHandle::updateMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
129 {
130         MSG_MESSAGE_INFO_S msgInfo;
131         MSG_SENDINGOPT_INFO_S sendOptInfo;
132
133         // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
134         convertMsgStruct(pMsg, &msgInfo);
135
136         if(pSendOpt != NULL)
137                 convertSendOptStruct(pSendOpt, &sendOptInfo, pMsg->msgType);
138
139         // Allocate Memory to Command Data
140         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
141
142         char cmdBuf[cmdSize];
143         bzero(cmdBuf, cmdSize);
144         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
145
146         // Set Command Parameters
147         pCmd->cmdType = MSG_CMD_UPDATE_MSG;
148
149         // Copy Cookie
150         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
151
152         // Copy Command Data
153         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
154         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
155
156         // Send Command to Messaging FW
157         char* pEventData = NULL;
158         AutoPtr<char> eventBuf(&pEventData);
159
160
161         write((char*)pCmd, cmdSize, &pEventData);
162
163         // Get Return Data
164         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
165
166         if (pEvent->eventType != MSG_EVENT_UPDATE_MSG)
167         {
168                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
169         }
170
171         return pEvent->result;
172 }
173
174
175 MSG_ERROR_T MsgHandle::updateReadStatus(MSG_MESSAGE_ID_T MsgId, bool bRead)
176 {
177         // Allocate Memory to Command Data
178         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(bool);
179
180         char cmdBuf[cmdSize];
181         bzero(cmdBuf, cmdSize);
182         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
183
184         // Set Command Parameters
185         pCmd->cmdType = MSG_CMD_UPDATE_READ;
186
187         // Copy Cookie
188         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
189
190         // Copy Command Data
191         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
192         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &bRead, sizeof(bool));
193
194         // Send Command to Messaging FW
195         char* pEventData = NULL;
196         AutoPtr<char> eventBuf(&pEventData);
197
198
199         write((char*)pCmd, cmdSize, &pEventData);
200
201         // Get Return Data
202         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
203
204         if (pEvent->eventType != MSG_EVENT_UPDATE_READ)
205         {
206                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
207         }
208
209         return pEvent->result;
210 }
211
212
213 MSG_ERROR_T MsgHandle::updateProtectedStatus(MSG_MESSAGE_ID_T MsgId, bool bProtected)
214 {
215         // Allocate Memory to Command Data
216         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(bool);
217
218         char cmdBuf[cmdSize];
219         bzero(cmdBuf, cmdSize);
220         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
221
222         // Set Command Parameters
223         pCmd->cmdType = MSG_CMD_UPDATE_PROTECTED;
224
225         // Copy Cookie
226         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
227
228         // Copy Command Data
229         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
230         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &bProtected, sizeof(bool));
231
232         // Send Command to Messaging FW
233         char* pEventData = NULL;
234         AutoPtr<char> eventBuf(&pEventData);
235
236
237         write((char*)pCmd, cmdSize, &pEventData);
238
239         // Get Return Data
240         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
241
242         if (pEvent->eventType != MSG_EVENT_UPDATE_PROTECTED)
243         {
244                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
245         }
246
247         return pEvent->result;
248 }
249
250
251 MSG_ERROR_T MsgHandle::deleteMessage(MSG_MESSAGE_ID_T MsgId)
252 {
253         // Allocate Memory to Command Data
254         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
255
256         char cmdBuf[cmdSize];
257         bzero(cmdBuf, cmdSize);
258         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
259
260         // Set Command Parameters
261         pCmd->cmdType = MSG_CMD_DELETE_MSG;
262
263         // Copy Cookie
264         memcpy((void*)pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
265
266         // Copy Command Data
267         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
268
269         // Send Command to Messaging FW
270         char* pEventData = NULL;
271         AutoPtr<char> eventBuf(&pEventData);
272
273
274         write((char*)pCmd, cmdSize, &pEventData);
275
276         // Get Return Data
277         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
278
279         if (pEvent->eventType != MSG_EVENT_DELETE_MSG)
280         {
281                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
282         }
283
284         return pEvent->result;
285 }
286
287
288 MSG_ERROR_T MsgHandle::deleteAllMessagesInFolder(MSG_FOLDER_ID_T FolderId, bool bOnlyDB)
289 {
290         // Allocate Memory to Command Data
291         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
292
293         char cmdBuf[cmdSize];
294         bzero(cmdBuf, cmdSize);
295         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
296
297         // Set Command Parameters
298         pCmd->cmdType = MSG_CMD_DELALL_MSGINFOLDER;
299
300         // Copy Cookie
301         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
302
303         // Copy Command Data
304         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
305         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), &bOnlyDB, sizeof(bool));
306
307         // Send Command to Messaging FW
308         char* pEventData = NULL;
309         AutoPtr<char> eventBuf(&pEventData);
310
311
312         write((char*)pCmd, cmdSize, &pEventData);
313
314         // Get Return Data
315         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
316
317         if (pEvent->eventType != MSG_EVENT_DELALL_MSGINFOLDER)
318         {
319                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
320         }
321
322         return pEvent->result;
323 }
324
325
326 MSG_ERROR_T MsgHandle::moveMessageToFolder(MSG_MESSAGE_ID_T MsgId, MSG_FOLDER_ID_T DestFolderId)
327 {
328         // Allocate Memory to Command Data
329         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(MSG_FOLDER_ID_T);
330
331         char cmdBuf[cmdSize];
332         bzero(cmdBuf, cmdSize);
333         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
334
335         // Set Command Parameters
336         pCmd->cmdType = MSG_CMD_MOVE_MSGTOFOLDER;
337
338         // Copy Cookie
339         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
340
341         // Copy Command Data
342         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
343         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(MSG_MESSAGE_ID_T)+MAX_COOKIE_LEN), &DestFolderId, sizeof(MSG_FOLDER_ID_T));
344
345         // Send Command to Messaging FW
346         char* pEventData = NULL;
347         AutoPtr<char> eventBuf(&pEventData);
348
349
350         write((char*)pCmd, cmdSize, &pEventData);
351
352         // Get Return Data
353         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
354
355         if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER)
356         {
357                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
358         }
359
360         return pEvent->result;
361 }
362
363
364 MSG_ERROR_T MsgHandle::moveMessageToStorage(MSG_MESSAGE_ID_T MsgId, MSG_STORAGE_ID_T DestStorageId)
365 {
366         // Allocate Memory to Command Data
367         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(MSG_STORAGE_ID_T);
368
369         char cmdBuf[cmdSize];
370         bzero(cmdBuf, cmdSize);
371         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
372
373         // Set Command Parameters
374         pCmd->cmdType = MSG_CMD_MOVE_MSGTOSTORAGE;
375
376         // Copy Cookie
377         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
378
379         // Copy Command Data
380         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
381         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &DestStorageId, sizeof(MSG_STORAGE_ID_T));
382
383         // Send Command to Messaging FW
384         char* pEventData = NULL;
385         AutoPtr<char> eventBuf(&pEventData);
386
387
388         write((char*)pCmd, cmdSize, &pEventData);
389
390         // Get Return Data
391         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
392
393         if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE)
394         {
395                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
396         }
397
398         return pEvent->result;
399 }
400
401
402 MSG_ERROR_T MsgHandle::countMessage(MSG_FOLDER_ID_T FolderId, MSG_COUNT_INFO_S *pCountInfo)
403 {
404         // Allocate Memory to Command Data
405         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
406
407         char cmdBuf[cmdSize];
408         bzero(cmdBuf, cmdSize);
409         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
410
411         // Set Command Parameters
412         pCmd->cmdType = MSG_CMD_COUNT_MSG;
413
414         // Copy Cookie
415         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
416
417         // Copy Command Data
418         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
419
420         // Send Command to Messaging FW
421         char* pEventData = NULL;
422         AutoPtr<char> eventBuf(&pEventData);
423
424
425         write((char*)pCmd, cmdSize, &pEventData);
426
427         // Get Return Data
428         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
429
430         if (pEvent->eventType != MSG_EVENT_COUNT_MSG)
431         {
432                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
433         }
434
435         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
436
437         // Decode Return Data
438         MsgDecodeCountInfo(pEvent->data, pCountInfo);
439
440         return MSG_SUCCESS;
441 }
442
443
444 MSG_ERROR_T MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
445 {
446         // Allocate Memory to Command Data
447         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_TYPE_S);
448
449         char cmdBuf[cmdSize];
450         bzero(cmdBuf, cmdSize);
451         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
452
453         // Set Command Parameters
454         pCmd->cmdType = MSG_CMD_COUNT_BY_MSGTYPE;
455
456         // Copy Cookie
457         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
458
459         // Copy Command Data
460         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgType, sizeof(MSG_MESSAGE_TYPE_S));
461
462         // Send Command to Messaging FW
463         char* pEventData = NULL;
464         AutoPtr<char> eventBuf(&pEventData);
465
466         write((char*)pCmd, cmdSize, &pEventData);
467
468         // Get Return Data
469         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
470
471         if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE)
472         {
473                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
474         }
475
476         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
477
478         // Decode Return Data
479         memcpy(pMsgCount, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(int));
480
481         return MSG_SUCCESS;
482 }
483
484
485 MSG_ERROR_T MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
486 {
487         // Allocate Memory to Command Data
488         int cmdSize = sizeof(MSG_CMD_S) +  sizeof(MSG_THREAD_LIST_INDEX_S);
489
490         char cmdBuf[cmdSize];
491         bzero(cmdBuf, cmdSize);
492         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
493
494         // Set Command Parameters
495         pCmd->cmdType = MSG_CMD_GET_CONTACT_COUNT;
496
497         // Copy Cookie
498         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
499
500         // Copy Command Data
501         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pAddrInfo, sizeof(MSG_THREAD_LIST_INDEX_S));
502
503         // Send Command to Messaging FW
504         char* pEventData = NULL;
505         AutoPtr<char> eventBuf(&pEventData);
506
507         write((char*)pCmd, cmdSize, &pEventData);
508
509         // Get Return Data
510         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
511
512         if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT)
513         {
514                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
515         }
516
517         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
518
519         // Decode Return Data
520         MsgDecodeContactCount(pEvent->data, pMsgThreadCountList);
521
522         return MSG_SUCCESS;
523 }
524
525
526 MSG_ERROR_T MsgHandle::getMessage(MSG_MESSAGE_ID_T MsgId, MSG_MESSAGE_S *pMsg, MSG_SENDINGOPT_S *pSendOpt)
527 {
528         // Allocate Memory to Command Data
529         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
530
531         char cmdBuf[cmdSize];
532         bzero(cmdBuf, cmdSize);
533         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
534
535         // Set Command Parameters
536         pCmd->cmdType = MSG_CMD_GET_MSG;
537
538         // Copy Cookie
539         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
540
541         // Copy Command Data
542         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
543
544         // Send Command to Messaging FW
545         char* pEventData = NULL;
546         AutoPtr<char> eventBuf(&pEventData);
547
548
549         write((char*)pCmd, cmdSize, &pEventData);
550
551         // Get Return Data
552         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
553
554         if (pEvent->eventType != MSG_EVENT_GET_MSG)
555         {
556                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
557         }
558
559         if(pEvent->result != MSG_SUCCESS)
560                 return pEvent->result;
561
562         // Decode Return Data
563         MSG_MESSAGE_INFO_S msgInfo;
564         MSG_SENDINGOPT_INFO_S sendOptInfo;
565         MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
566
567         // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
568         convertMsgStruct(&msgInfo, pMsg);
569
570         if(pSendOpt != NULL)
571                 convertSendOptStruct(&sendOptInfo, pSendOpt, pMsg->msgType);
572
573         // Delete Temp File
574         if (msgInfo.bTextSms == false)
575         {
576                 // Delete Temp File
577                 MsgDeleteFile(msgInfo.msgData); //ipc
578         }
579
580         return MSG_SUCCESS;
581 }
582
583
584 MSG_ERROR_T MsgHandle::getFolderViewList(MSG_FOLDER_ID_T FolderId, const MSG_SORT_RULE_S *pSortRule, MSG_LIST_S *pMsgFolderViewList)
585 {
586         MSG_ERROR_T err = MSG_SUCCESS;
587
588         err = MsgStoConnectDB();
589
590         if (err != MSG_SUCCESS)
591         {
592                 MSG_DEBUG("MsgStoConnectDB() Error!!");
593                 return err;
594         }
595
596         err = MsgStoGetFolderViewList(FolderId, (MSG_SORT_RULE_S *)pSortRule, pMsgFolderViewList);
597
598         if (err != MSG_SUCCESS)
599         {
600                 MSG_DEBUG("MsgStoGetFolderViewList() Error!!");
601                 return err;
602         }
603
604         MsgStoDisconnectDB();
605
606         return err;
607 }
608
609
610 MSG_ERROR_T MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
611 {
612         // Allocate Memory to Command Data
613         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
614
615         char cmdBuf[cmdSize];
616         bzero(cmdBuf, cmdSize);
617         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
618
619         // Set Command Parameters
620         pCmd->cmdType = MSG_CMD_ADD_FOLDER;
621
622         // Copy Cookie
623         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
624
625         // Copy Command Data
626         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
627
628         // Send Command to Messaging FW
629         char* pEventData = NULL;
630         AutoPtr<char> eventBuf(&pEventData);
631
632
633         write((char*)pCmd, cmdSize, &pEventData);
634
635         // Get Return Data
636         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
637
638         if (pEvent->eventType != MSG_EVENT_ADD_FOLDER)
639         {
640                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
641         }
642
643         return pEvent->result;
644 }
645
646
647 MSG_ERROR_T MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
648 {
649         // Allocate Memory to Command Data
650         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
651
652         char cmdBuf[cmdSize];
653         bzero(cmdBuf, cmdSize);
654         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
655
656         // Set Command Parameters
657         pCmd->cmdType = MSG_CMD_UPDATE_FOLDER;
658
659         // Copy Cookie
660         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
661
662         // Copy Command Data
663         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
664
665         // Send Command to Messaging FW
666         char* pEventData = NULL;
667         AutoPtr<char> eventBuf(&pEventData);
668
669
670         write((char*)pCmd, cmdSize, &pEventData);
671
672         // Get Return Data
673         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
674
675         if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER)
676         {
677                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
678         }
679
680         return pEvent->result;;
681 }
682
683
684 MSG_ERROR_T MsgHandle::deleteFolder(MSG_FOLDER_ID_T FolderId)
685 {
686         // Allocate Memory to Command Data
687         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
688
689         char cmdBuf[cmdSize];
690         bzero(cmdBuf, cmdSize);
691         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
692
693         // Set Command Parameters
694         pCmd->cmdType = MSG_CMD_DELETE_FOLDER;
695
696         // Copy Cookie
697         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
698
699         // Copy Command Data
700         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
701
702         // Send Command to Messaging FW
703         char* pEventData = NULL;
704         AutoPtr<char> eventBuf(&pEventData);
705
706
707         write((char*)pCmd, cmdSize, &pEventData);
708
709         // Get Return Data
710         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
711
712         if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER)
713         {
714                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
715         }
716
717         return pEvent->result;
718 }
719
720
721 MSG_ERROR_T MsgHandle::getFolderList(MSG_FOLDER_LIST_S *pFolderList)
722 {
723         // Allocate Memory to Command Data
724         int cmdSize = sizeof(MSG_CMD_S);
725
726         char cmdBuf[cmdSize];
727         bzero(cmdBuf, cmdSize);
728         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
729
730         // Set Command Parameters
731         pCmd->cmdType = MSG_CMD_GET_FOLDERLIST;
732
733         // Copy Cookie
734         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
735
736         // Send Command to Messaging FW
737         char* pEventData = NULL;
738         AutoPtr<char> eventBuf(&pEventData);
739
740         write((char*)pCmd, cmdSize, &pEventData);
741
742         // Get Return Data
743         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
744
745         if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST)
746         {
747                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
748         }
749
750         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
751
752         // Decode Return Data
753         MsgDecodeFolderList(pEvent->data, pFolderList);
754
755         return MSG_SUCCESS;
756 }
757
758
759 MSG_ERROR_T MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
760 {
761         MSG_ERROR_T err =  MSG_SUCCESS;
762
763         err = MsgStoConnectDB();
764
765         if (err != MSG_SUCCESS)
766         {
767                 MSG_DEBUG("MsgStoConnectDB() Error!!");
768                 return err;
769         }
770
771         err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
772
773         if (err != MSG_SUCCESS)
774         {
775                 MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
776                 return err;
777         }
778
779         MsgStoDisconnectDB();
780
781         return err;
782 }
783
784
785 MSG_ERROR_T MsgHandle::getConversationViewList(MSG_THREAD_ID_T ThreadId, MSG_LIST_S *pConvViewList)
786 {
787         MSG_BEGIN();
788
789         MSG_ERROR_T err =  MSG_SUCCESS;
790
791         MsgStoConnectDB();
792         err = MsgStoGetConversationViewList(ThreadId, pConvViewList);
793         MsgStoDisconnectDB();
794
795         if(err != MSG_SUCCESS)
796                 return err;
797
798
799 // Update Read Status for the Thead ID
800         // Allocate Memory to Command Data
801         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_ID_T);
802
803         char cmdBuf[cmdSize];
804         bzero(cmdBuf, cmdSize);
805         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
806
807         // Set Command Parameters
808         pCmd->cmdType = MSG_CMD_UPDATE_THREAD_READ;
809
810         // Copy Cookie
811         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
812
813         // Copy Command Data
814         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(MSG_THREAD_ID_T));
815
816         // Send Command to Messaging FW
817         char* pEventData = NULL;
818         AutoPtr<char> eventBuf(&pEventData);
819
820         write((char*)pCmd, cmdSize, &pEventData);
821
822         // Get Return Data
823         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
824
825         if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ)
826         {
827                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
828         }
829
830         MSG_END();
831
832         return err;
833 }
834
835
836 MSG_ERROR_T MsgHandle::deleteThreadMessageList(MSG_THREAD_ID_T ThreadId)
837 {
838         // Allocate Memory to Command Data
839         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_LIST_INDEX_S);
840
841         char cmdBuf[cmdSize];
842         bzero(cmdBuf, cmdSize);
843         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
844
845         // Set Command Parameters
846         pCmd->cmdType = MSG_CMD_DELETE_THREADMESSAGELIST;
847
848         // Copy Cookie
849         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
850
851         // Copy Command Data
852         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(MSG_THREAD_ID_T));
853
854         // Send Command to Messaging FW
855         char* pEventData = NULL;
856         AutoPtr<char> eventBuf(&pEventData);
857
858
859         write((char*)pCmd, cmdSize, &pEventData);
860
861         // Get Return Data
862         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
863
864         if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST)
865         {
866                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
867         }
868
869         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
870
871         return MSG_SUCCESS;
872 }
873
874
875 MSG_ERROR_T MsgHandle::getQuickPanelData(MSG_QUICKPANEL_TYPE_T Type, MSG_MESSAGE_S *pMsg)
876 {
877         // Allocate Memory to Command Data
878         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_QUICKPANEL_TYPE_T);
879
880         char cmdBuf[cmdSize];
881         bzero(cmdBuf, cmdSize);
882         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
883
884         // Set Command Parameters
885         pCmd->cmdType = MSG_CMD_GET_QUICKPANEL_DATA;
886
887         // Copy Cookie
888         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
889
890         // Copy Command Data
891         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &Type, sizeof(MSG_QUICKPANEL_TYPE_T));
892
893         // Send Command to Messaging FW
894         char* pEventData = NULL;
895         AutoPtr<char> eventBuf(&pEventData);
896
897         write((char*)pCmd, cmdSize, &pEventData);
898
899         // Get Return Data
900         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
901
902         if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA)
903         {
904                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
905         }
906
907         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
908
909         // Decode Return Data
910         MSG_MESSAGE_INFO_S msgInfo;
911
912         memcpy(&msgInfo, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(MSG_MESSAGE_INFO_S));
913
914         // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
915         convertMsgStruct(&msgInfo, pMsg);
916
917         // Delete Temp File
918         if (msgInfo.bTextSms == false)
919         {
920                 // Delete Temp File
921                 MsgDeleteFile(msgInfo.msgData); //ipc
922         }
923
924         return MSG_SUCCESS;
925 }
926
927
928 MSG_ERROR_T MsgHandle::resetDatabase()
929 {
930         // Allocate Memory to Command Data
931         int cmdSize = sizeof(MSG_CMD_S);
932
933         char cmdBuf[cmdSize];
934         bzero(cmdBuf, cmdSize);
935         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
936
937         // Set Command Parameters
938         pCmd->cmdType = MSG_CMD_RESET_DB;
939
940         // Copy Cookie
941         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
942
943         // Send Command to Messaging FW
944         char* pEventData = NULL;
945         AutoPtr<char> eventBuf(&pEventData);
946
947         write((char*)pCmd, cmdSize, &pEventData);
948
949         // Get Return Data
950         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
951
952         if (pEvent->eventType != MSG_EVENT_RESET_DB)
953         {
954                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
955         }
956
957         return pEvent->result;
958 }
959
960
961 MSG_ERROR_T MsgHandle::getMemSize(unsigned int* memsize)
962 {
963         // Allocate Memory to Command Data
964         int cmdSize = sizeof(MSG_CMD_S);
965
966         char cmdBuf[cmdSize];
967         bzero(cmdBuf, cmdSize);
968         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
969
970         // Set Command Parameters
971         pCmd->cmdType = MSG_CMD_GET_MEMSIZE;
972
973         // Copy Cookie
974         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
975
976         // Send Command to Messaging FW
977         char* pEventData = NULL;
978         AutoPtr<char> eventBuf(&pEventData);
979
980
981         write((char*)pCmd, cmdSize, &pEventData);
982
983         // Get Return Data
984         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
985
986         if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE)
987         {
988                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
989         }
990
991         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
992
993         // Decode Return Data
994         MsgDecodeMemSize(pEvent->data, memsize);
995
996         return MSG_SUCCESS;
997 }
998
999
1000 MSG_ERROR_T MsgHandle::searchMessage(const char *pSearchString, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
1001 {
1002         MSG_ERROR_T err =  MSG_SUCCESS;
1003
1004         err = MsgStoConnectDB();
1005
1006         if (err != MSG_SUCCESS)
1007         {
1008                 MSG_DEBUG("MsgStoConnectDB() Error!!");
1009                 return err;
1010         }
1011
1012         err = MsgStoSearchMessage(pSearchString, pThreadViewList);
1013
1014         if (err != MSG_SUCCESS)
1015         {
1016                 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1017                 return err;
1018         }
1019
1020         MsgStoDisconnectDB();
1021
1022         return err;
1023 }
1024
1025
1026 MSG_ERROR_T MsgHandle::searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, MSG_LIST_S *pMsgList)
1027 {
1028         MSG_ERROR_T err =  MSG_SUCCESS;
1029
1030         err = MsgStoConnectDB();
1031
1032         if (err != MSG_SUCCESS) {
1033                 MSG_DEBUG("MsgStoConnectDB() Error!!");
1034                 return err;
1035         }
1036
1037         err = MsgStoSearchMessage(pSearchCon, offset, limit, pMsgList);
1038
1039         if (err != MSG_SUCCESS) {
1040                 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1041                 return err;
1042         }
1043
1044         MsgStoDisconnectDB();
1045
1046         return err;
1047 }
1048
1049
1050
1051 MSG_ERROR_T MsgHandle::getMsgIdList(MSG_REFERENCE_ID_T RefId, MSG_MSGID_LIST_S *pMsgIdList)
1052 {
1053         MSG_ERROR_T err =  MSG_SUCCESS;
1054
1055         err = MsgStoConnectDB();
1056
1057         if (err != MSG_SUCCESS)
1058         {
1059                 MSG_DEBUG("MsgStoConnectDB() Error!!");
1060                 return err;
1061         }
1062
1063         err = MsgStoGetMsgIdList(RefId, pMsgIdList);
1064
1065         if (err != MSG_SUCCESS)
1066         {
1067                 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1068                 return err;
1069         }
1070
1071         MsgStoDisconnectDB();
1072
1073         return err;
1074 }
1075
1076
1077 MSG_ERROR_T MsgHandle::getRejectMsgList(const char *pNumber, MSG_REJECT_MSG_LIST_S *pRejectMsgList)
1078 {
1079         MSG_ERROR_T err =  MSG_SUCCESS;
1080
1081         err = MsgStoConnectDB();
1082
1083         if (err != MSG_SUCCESS)
1084         {
1085                 MSG_DEBUG("MsgStoConnectDB() Error!!");
1086                 return err;
1087         }
1088
1089         err = MsgStoGetRejectMsgList(pNumber, pRejectMsgList);
1090
1091         if (err != MSG_SUCCESS)
1092         {
1093                 MSG_DEBUG("MsgStoGetRejectMsgList() Error!!");
1094                 return err;
1095         }
1096
1097         MsgStoDisconnectDB();
1098
1099         return err;
1100 }
1101
1102
1103 MSG_ERROR_T MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam)
1104 {
1105         if (!onStorageChange)
1106                 THROW(MsgException::INVALID_PARAM, "onStorageChange is null");
1107
1108         MsgProxyListener* eventListener = MsgProxyListener::instance();
1109
1110         eventListener->start();
1111
1112         if (eventListener->regStorageChangeEventCB(this, onStorageChange, pUserParam) == false) // callback was already registered, just return SUCCESS
1113                 return MSG_SUCCESS;
1114
1115         // Allocate Memory to Command Data
1116         int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
1117         char cmdBuf[cmdSize];
1118         bzero(cmdBuf, cmdSize);
1119         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
1120
1121         // Set Command Parameters
1122         pCmd->cmdType = MSG_CMD_REG_STORAGE_CHANGE_CB;
1123
1124         // Copy Cookie
1125         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1126
1127         int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
1128
1129         MSG_DEBUG("remote fd %d", listenerFd);
1130
1131         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
1132
1133         MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
1134
1135         // Send Command to Messaging FW
1136         char* pEventData = NULL;
1137         AutoPtr<char> eventBuf(&pEventData);
1138
1139         write((char*)pCmd, cmdSize, &pEventData);
1140
1141         // Get Return Data
1142         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1143
1144         if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB)
1145         {
1146                 THROW(MsgException::INVALID_PARAM, "Event Data Error");
1147         }
1148
1149         return pEvent->result;
1150 }
1151
1152
1153 MSG_ERROR_T MsgHandle::getReportStatus(MSG_MESSAGE_ID_T msg_id, MSG_REPORT_STATUS_INFO_S *pReport_status)
1154 {
1155         // Allocate Memory to Command Data
1156         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
1157
1158         char cmdBuf[cmdSize];
1159         bzero(cmdBuf, cmdSize);
1160         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1161
1162         // Set Command Parameters
1163         pCmd->cmdType = MSG_CMD_GET_REPORT_STATUS;
1164
1165         // Copy Cookie
1166         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1167
1168         // Copy Command Data
1169         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msg_id, sizeof(MSG_MESSAGE_ID_T));
1170
1171         // Send Command to Messaging FW
1172         char* pEventData = NULL;
1173         AutoPtr<char> eventBuf(&pEventData);
1174
1175
1176         write((char*)pCmd, cmdSize, &pEventData);
1177
1178         // Get Return Data
1179         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1180
1181         if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS)
1182         {
1183                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1184         }
1185
1186         if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1187
1188         // Decode Return Data
1189         MsgDecodeReportStatus(pEvent->data, pReport_status);
1190
1191         return MSG_SUCCESS;
1192 }