2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
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
8 * http://floralicense.org
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.
18 #include "MsgUtilFile.h"
19 #include "MsgCppTypes.h"
20 #include "MsgException.h"
21 #include "MsgUtilFunction.h"
22 #include "MsgProxyListener.h"
23 #include "MsgHandle.h"
25 #include "MsgStorageHandler.h"
27 #include "MsgVMessage.h"
28 /*==================================================================================================
29 IMPLEMENTATION OF MsgHandle - Storage Member Functions
30 ==================================================================================================*/
31 int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
33 MSG_MESSAGE_INFO_S msgInfo = {0,};
34 MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
36 // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
37 convertMsgStruct(pMsg, &msgInfo);
39 // Covert MSG_SENDINGOPT_S to MSG_SENDINGOPT_INFO_S
40 MSG_MESSAGE_TYPE_S msgType = {0,};
42 msgType.mainType = pMsg->mainType;
43 msgType.subType = pMsg->subType;
44 msgType.classType = pMsg->classType;
46 convertSendOptStruct(pSendOpt, &sendOptInfo, msgType);
48 // Allocate Memory to Command Data
49 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
52 bzero(cmdBuf, cmdSize);
53 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
55 // Set Command Parameters
56 pCmd->cmdType = MSG_CMD_ADD_MSG;
59 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
62 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
63 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
65 // Send Command to Messaging FW
66 char* pEventData = NULL;
67 AutoPtr<char> eventBuf(&pEventData);
69 write((char*)pCmd, cmdSize, &pEventData);
72 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
74 if (pEvent->eventType != MSG_EVENT_ADD_MSG)
76 THROW(MsgException::INVALID_RESULT, "Event Data Error");
79 if (pEvent->result != MSG_SUCCESS) return pEvent->result;
81 msg_message_id_t msgId = 0;
84 MsgDecodeMsgId(pEvent->data, &msgId);
90 msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
92 MSG_MESSAGE_INFO_S msgInfo = {0, };
94 // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
95 msg_struct_s *msg = (msg_struct_s *)pSyncMLMsg->msg;
96 convertMsgStruct((MSG_MESSAGE_HIDDEN_S *)msg->data, &msgInfo);
98 // Allocate Memory to Command Data
99 int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(int) + sizeof(MSG_MESSAGE_INFO_S);
101 char cmdBuf[cmdSize];
102 bzero(cmdBuf, cmdSize);
103 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
105 // Set Command Parameters
106 pCmd->cmdType = MSG_CMD_ADD_SYNCML_MSG;
109 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
112 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pSyncMLMsg->extId, sizeof(int));
113 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), &pSyncMLMsg->pinCode, sizeof(int));
114 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
116 // Send Command to Messaging FW
117 char* pEventData = NULL;
118 AutoPtr<char> eventBuf(&pEventData);
121 write((char*)pCmd, cmdSize, &pEventData);
124 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
126 if (pEvent->eventType != MSG_EVENT_ADD_SYNCML_MSG)
128 THROW(MsgException::INVALID_RESULT, "Event Data Error");
131 return pEvent->result;
135 msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
137 MSG_MESSAGE_INFO_S msgInfo = {0, };
138 MSG_SENDINGOPT_INFO_S sendOptInfo = {0, };
140 // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
141 convertMsgStruct(pMsg, &msgInfo);
143 if(pSendOpt != NULL) {
144 MSG_MESSAGE_TYPE_S msgType = {0,};
146 msgType.mainType = pMsg->mainType;
147 msgType.subType = pMsg->subType;
148 msgType.classType = pMsg->classType;
150 convertSendOptStruct(pSendOpt, &sendOptInfo, msgType);
153 // Allocate Memory to Command Data
154 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
156 char cmdBuf[cmdSize];
157 bzero(cmdBuf, cmdSize);
158 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
160 // Set Command Parameters
161 pCmd->cmdType = MSG_CMD_UPDATE_MSG;
164 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
167 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
168 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
170 // Send Command to Messaging FW
171 char* pEventData = NULL;
172 AutoPtr<char> eventBuf(&pEventData);
175 write((char*)pCmd, cmdSize, &pEventData);
178 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
180 if (pEvent->eventType != MSG_EVENT_UPDATE_MSG)
182 THROW(MsgException::INVALID_RESULT, "Event Data Error");
185 return pEvent->result;
189 msg_error_t MsgHandle::updateReadStatus(msg_message_id_t MsgId, bool bRead)
191 // Allocate Memory to Command Data
192 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(bool);
194 char cmdBuf[cmdSize];
195 bzero(cmdBuf, cmdSize);
196 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
198 // Set Command Parameters
199 pCmd->cmdType = MSG_CMD_UPDATE_READ;
202 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
205 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
206 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &bRead, sizeof(bool));
208 // Send Command to Messaging FW
209 char* pEventData = NULL;
210 AutoPtr<char> eventBuf(&pEventData);
213 write((char*)pCmd, cmdSize, &pEventData);
216 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
218 if (pEvent->eventType != MSG_EVENT_UPDATE_READ)
220 THROW(MsgException::INVALID_RESULT, "Event Data Error");
223 return pEvent->result;
227 msg_error_t MsgHandle::updateProtectedStatus(msg_message_id_t MsgId, bool bProtected)
229 // Allocate Memory to Command Data
230 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(bool);
232 char cmdBuf[cmdSize];
233 bzero(cmdBuf, cmdSize);
234 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
236 // Set Command Parameters
237 pCmd->cmdType = MSG_CMD_UPDATE_PROTECTED;
240 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
243 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
244 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &bProtected, sizeof(bool));
246 // Send Command to Messaging FW
247 char* pEventData = NULL;
248 AutoPtr<char> eventBuf(&pEventData);
251 write((char*)pCmd, cmdSize, &pEventData);
254 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
256 if (pEvent->eventType != MSG_EVENT_UPDATE_PROTECTED)
258 THROW(MsgException::INVALID_RESULT, "Event Data Error");
261 return pEvent->result;
265 msg_error_t MsgHandle::deleteMessage(msg_message_id_t MsgId)
267 // Allocate Memory to Command Data
268 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
270 char cmdBuf[cmdSize];
271 bzero(cmdBuf, cmdSize);
272 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
274 // Set Command Parameters
275 pCmd->cmdType = MSG_CMD_DELETE_MSG;
278 memcpy((void*)pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
281 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
283 // Send Command to Messaging FW
284 char* pEventData = NULL;
285 AutoPtr<char> eventBuf(&pEventData);
288 write((char*)pCmd, cmdSize, &pEventData);
291 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
293 if (pEvent->eventType != MSG_EVENT_DELETE_MSG)
295 THROW(MsgException::INVALID_RESULT, "Event Data Error");
298 return pEvent->result;
302 msg_error_t MsgHandle::deleteAllMessagesInFolder(msg_folder_id_t FolderId, bool bOnlyDB)
304 // Allocate Memory to Command Data
305 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
307 char cmdBuf[cmdSize];
308 bzero(cmdBuf, cmdSize);
309 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
311 // Set Command Parameters
312 pCmd->cmdType = MSG_CMD_DELALL_MSGINFOLDER;
315 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
318 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
319 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_folder_id_t)), &bOnlyDB, sizeof(bool));
321 // Send Command to Messaging FW
322 char* pEventData = NULL;
323 AutoPtr<char> eventBuf(&pEventData);
326 write((char*)pCmd, cmdSize, &pEventData);
329 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
331 if (pEvent->eventType != MSG_EVENT_DELALL_MSGINFOLDER)
333 THROW(MsgException::INVALID_RESULT, "Event Data Error");
336 return pEvent->result;
340 msg_error_t MsgHandle::deleteMessagesByList(msg_id_list_s *pMsgIdList)
342 // Allocate Memory to Command Data
343 int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + (sizeof(int)*pMsgIdList->nCount);
345 char cmdBuf[cmdSize];
346 bzero(cmdBuf, cmdSize);
347 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
349 // Set Command Parameters
350 pCmd->cmdType = MSG_CMD_DELETE_MESSAGE_BY_LIST;
353 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
356 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &(pMsgIdList->nCount), sizeof(int));
357 for (int i=0; i<pMsgIdList->nCount; i++) {
358 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+(sizeof(int)*i)), &(pMsgIdList->msgIdList[i]), sizeof(int));
361 // Send Command to Messaging FW
362 char* pEventData = NULL;
363 AutoPtr<char> eventBuf(&pEventData);
366 write((char*)pCmd, cmdSize, &pEventData);
369 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
371 if (pEvent->eventType != MSG_EVENT_DELETE_MESSAGE_BY_LIST) {
372 THROW(MsgException::INVALID_RESULT, "Event Data Error");
375 return pEvent->result;
379 msg_error_t MsgHandle::moveMessageToFolder(msg_message_id_t MsgId, msg_folder_id_t DestFolderId)
381 // Allocate Memory to Command Data
382 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_folder_id_t);
384 char cmdBuf[cmdSize];
385 bzero(cmdBuf, cmdSize);
386 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
388 // Set Command Parameters
389 pCmd->cmdType = MSG_CMD_MOVE_MSGTOFOLDER;
392 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
395 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
396 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(msg_message_id_t)+MAX_COOKIE_LEN), &DestFolderId, sizeof(msg_folder_id_t));
398 // Send Command to Messaging FW
399 char* pEventData = NULL;
400 AutoPtr<char> eventBuf(&pEventData);
403 write((char*)pCmd, cmdSize, &pEventData);
406 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
408 if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER)
410 THROW(MsgException::INVALID_RESULT, "Event Data Error");
413 return pEvent->result;
417 msg_error_t MsgHandle::moveMessageToStorage(msg_message_id_t MsgId, msg_storage_id_t DestStorageId)
419 // Allocate Memory to Command Data
420 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_storage_id_t);
422 char cmdBuf[cmdSize];
423 bzero(cmdBuf, cmdSize);
424 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
426 // Set Command Parameters
427 pCmd->cmdType = MSG_CMD_MOVE_MSGTOSTORAGE;
430 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
433 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
434 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &DestStorageId, sizeof(msg_storage_id_t));
436 // Send Command to Messaging FW
437 char* pEventData = NULL;
438 AutoPtr<char> eventBuf(&pEventData);
441 write((char*)pCmd, cmdSize, &pEventData);
444 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
446 if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE)
448 THROW(MsgException::INVALID_RESULT, "Event Data Error");
451 return pEvent->result;
455 msg_error_t MsgHandle::countMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S *pCountInfo)
457 // Allocate Memory to Command Data
458 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
460 char cmdBuf[cmdSize];
461 bzero(cmdBuf, cmdSize);
462 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
464 // Set Command Parameters
465 pCmd->cmdType = MSG_CMD_COUNT_MSG;
468 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
471 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
473 // Send Command to Messaging FW
474 char* pEventData = NULL;
475 AutoPtr<char> eventBuf(&pEventData);
478 write((char*)pCmd, cmdSize, &pEventData);
481 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
483 if (pEvent->eventType != MSG_EVENT_COUNT_MSG)
485 THROW(MsgException::INVALID_RESULT, "Event Data Error");
488 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
490 // Decode Return Data
491 MsgDecodeCountInfo(pEvent->data, pCountInfo);
497 msg_error_t MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
499 // Allocate Memory to Command Data
500 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_TYPE_S);
502 char cmdBuf[cmdSize];
503 bzero(cmdBuf, cmdSize);
504 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
506 // Set Command Parameters
507 pCmd->cmdType = MSG_CMD_COUNT_BY_MSGTYPE;
510 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
513 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgType, sizeof(MSG_MESSAGE_TYPE_S));
515 // Send Command to Messaging FW
516 char* pEventData = NULL;
517 AutoPtr<char> eventBuf(&pEventData);
519 write((char*)pCmd, cmdSize, &pEventData);
522 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
524 if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE)
526 THROW(MsgException::INVALID_RESULT, "Event Data Error");
529 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
531 // Decode Return Data
532 memcpy(pMsgCount, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
538 msg_error_t MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
540 // Allocate Memory to Command Data
541 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_LIST_INDEX_S);
543 char cmdBuf[cmdSize];
544 bzero(cmdBuf, cmdSize);
545 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
547 // Set Command Parameters
548 pCmd->cmdType = MSG_CMD_GET_CONTACT_COUNT;
551 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
554 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pAddrInfo, sizeof(msg_contact_id_t));
555 msg_struct_s *pAddr = (msg_struct_s *)pAddrInfo->msgAddrInfo;
557 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN + sizeof(msg_contact_id_t)), pAddr->data, sizeof(MSG_ADDRESS_INFO_S));
558 // Send Command to Messaging FW
559 char* pEventData = NULL;
560 AutoPtr<char> eventBuf(&pEventData);
562 write((char*)pCmd, cmdSize, &pEventData);
565 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
567 if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT)
569 THROW(MsgException::INVALID_RESULT, "Event Data Error");
572 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
574 // Decode Return Data
575 MsgDecodeContactCount(pEvent->data, pMsgThreadCountList);
581 msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *pMsg, MSG_SENDINGOPT_S *pSendOpt)
583 // Allocate Memory to Command Data
584 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
586 char cmdBuf[cmdSize];
587 bzero(cmdBuf, cmdSize);
588 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
590 // Set Command Parameters
591 pCmd->cmdType = MSG_CMD_GET_MSG;
594 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
597 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
599 // Send Command to Messaging FW
600 char* pEventData = NULL;
601 AutoPtr<char> eventBuf(&pEventData);
604 write((char*)pCmd, cmdSize, &pEventData);
607 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
609 if (pEvent->eventType != MSG_EVENT_GET_MSG)
611 THROW(MsgException::INVALID_RESULT, "Event Data Error");
614 if(pEvent->result != MSG_SUCCESS)
615 return pEvent->result;
617 // Decode Return Data
618 MSG_MESSAGE_INFO_S msgInfo;
619 MSG_SENDINGOPT_INFO_S sendOptInfo;
620 MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
622 // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_HIDDEN_S
623 convertMsgStruct(&msgInfo, pMsg);
625 if(pSendOpt != NULL) {
626 MSG_MESSAGE_TYPE_S msgType = {0,};
628 msgType.mainType = pMsg->mainType;
629 msgType.subType = pMsg->subType;
630 msgType.classType = pMsg->classType;
632 convertSendOptStruct(&sendOptInfo, pSendOpt, msgType);
636 if (msgInfo.bTextSms == false)
639 MsgDeleteFile(msgInfo.msgData); //ipc
646 msg_error_t MsgHandle::getFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList)
648 msg_error_t err = MSG_SUCCESS;
650 err = MsgStoConnectDB();
652 if (err != MSG_SUCCESS)
654 MSG_DEBUG("MsgStoConnectDB() Error!!");
658 err = MsgStoGetFolderViewList(FolderId, (MSG_SORT_RULE_S *)pSortRule, pMsgFolderViewList);
660 if (err != MSG_SUCCESS)
662 MSG_DEBUG("MsgStoGetFolderViewList() Error!!");
666 MsgStoDisconnectDB();
672 msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
674 // Allocate Memory to Command Data
675 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
677 char cmdBuf[cmdSize];
678 bzero(cmdBuf, cmdSize);
679 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
681 // Set Command Parameters
682 pCmd->cmdType = MSG_CMD_ADD_FOLDER;
685 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
688 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
690 // Send Command to Messaging FW
691 char* pEventData = NULL;
692 AutoPtr<char> eventBuf(&pEventData);
695 write((char*)pCmd, cmdSize, &pEventData);
698 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
700 if (pEvent->eventType != MSG_EVENT_ADD_FOLDER)
702 THROW(MsgException::INVALID_RESULT, "Event Data Error");
705 return pEvent->result;
709 msg_error_t MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
711 // Allocate Memory to Command Data
712 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
714 char cmdBuf[cmdSize];
715 bzero(cmdBuf, cmdSize);
716 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
718 // Set Command Parameters
719 pCmd->cmdType = MSG_CMD_UPDATE_FOLDER;
722 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
725 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
727 // Send Command to Messaging FW
728 char* pEventData = NULL;
729 AutoPtr<char> eventBuf(&pEventData);
732 write((char*)pCmd, cmdSize, &pEventData);
735 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
737 if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER)
739 THROW(MsgException::INVALID_RESULT, "Event Data Error");
742 return pEvent->result;;
746 msg_error_t MsgHandle::deleteFolder(msg_folder_id_t FolderId)
748 // Allocate Memory to Command Data
749 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
751 char cmdBuf[cmdSize];
752 bzero(cmdBuf, cmdSize);
753 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
755 // Set Command Parameters
756 pCmd->cmdType = MSG_CMD_DELETE_FOLDER;
759 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
762 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
764 // Send Command to Messaging FW
765 char* pEventData = NULL;
766 AutoPtr<char> eventBuf(&pEventData);
769 write((char*)pCmd, cmdSize, &pEventData);
772 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
774 if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER)
776 THROW(MsgException::INVALID_RESULT, "Event Data Error");
779 return pEvent->result;
783 msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList)
785 // Allocate Memory to Command Data
786 int cmdSize = sizeof(MSG_CMD_S);
788 char cmdBuf[cmdSize];
789 bzero(cmdBuf, cmdSize);
790 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
792 // Set Command Parameters
793 pCmd->cmdType = MSG_CMD_GET_FOLDERLIST;
796 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
798 // Send Command to Messaging FW
799 char* pEventData = NULL;
800 AutoPtr<char> eventBuf(&pEventData);
802 write((char*)pCmd, cmdSize, &pEventData);
805 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
807 if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST)
809 THROW(MsgException::INVALID_RESULT, "Event Data Error");
812 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
814 // Decode Return Data
815 MsgDecodeFolderList(pEvent->data, pFolderList);
821 msg_error_t MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
823 msg_error_t err = MSG_SUCCESS;
825 err = MsgStoConnectDB();
827 if (err != MSG_SUCCESS)
829 MSG_DEBUG("MsgStoConnectDB() Error!!");
833 err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
835 if (err != MSG_SUCCESS)
837 MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
841 MsgStoDisconnectDB();
846 msg_error_t MsgHandle::getConversationViewItem(msg_message_id_t MsgId, MSG_CONVERSATION_VIEW_S *pConv)
850 msg_error_t err = MSG_SUCCESS;
853 err = MsgStoGetConversationViewItem(MsgId, pConv);
854 MsgStoDisconnectDB();
859 msg_error_t MsgHandle::getConversationViewList(msg_thread_id_t ThreadId, msg_struct_list_s *pConvViewList)
863 msg_error_t err = MSG_SUCCESS;
866 err = MsgStoGetConversationViewList(ThreadId, pConvViewList);
867 MsgStoDisconnectDB();
869 if(err != MSG_SUCCESS)
873 // Update Read Status for the Thead ID
875 // Allocate Memory to Command Data
876 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
878 char cmdBuf[cmdSize];
879 bzero(cmdBuf, cmdSize);
880 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
882 // Set Command Parameters
883 pCmd->cmdType = MSG_CMD_UPDATE_THREAD_READ;
886 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
889 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
891 // Send Command to Messaging FW
892 char* pEventData = NULL;
893 AutoPtr<char> eventBuf(&pEventData);
895 write((char*)pCmd, cmdSize, &pEventData);
898 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
900 if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ)
902 THROW(MsgException::INVALID_RESULT, "Event Data Error");
912 msg_error_t MsgHandle::deleteThreadMessageList(msg_thread_id_t ThreadId, bool include_protected_msg)
914 // Allocate Memory to Command Data
915 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t) + sizeof(bool);
917 char cmdBuf[cmdSize];
918 bzero(cmdBuf, cmdSize);
919 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
921 // Set Command Parameters
922 pCmd->cmdType = MSG_CMD_DELETE_THREADMESSAGELIST;
925 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
928 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
929 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_thread_id_t)), &include_protected_msg, sizeof(bool));
931 // Send Command to Messaging FW
932 char* pEventData = NULL;
933 AutoPtr<char> eventBuf(&pEventData);
936 write((char*)pCmd, cmdSize, &pEventData);
939 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
941 if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST)
943 THROW(MsgException::INVALID_RESULT, "Event Data Error");
946 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
952 msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_HIDDEN_S *pMsg)
954 // Allocate Memory to Command Data
955 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_quickpanel_type_t);
957 char cmdBuf[cmdSize];
958 bzero(cmdBuf, cmdSize);
959 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
961 // Set Command Parameters
962 pCmd->cmdType = MSG_CMD_GET_QUICKPANEL_DATA;
965 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
968 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &Type, sizeof(msg_quickpanel_type_t));
970 // Send Command to Messaging FW
971 char* pEventData = NULL;
972 AutoPtr<char> eventBuf(&pEventData);
974 write((char*)pCmd, cmdSize, &pEventData);
977 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
979 if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA)
981 THROW(MsgException::INVALID_RESULT, "Event Data Error");
984 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
986 // Decode Return Data
987 MSG_MESSAGE_INFO_S msgInfo;
989 memcpy(&msgInfo, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(MSG_MESSAGE_INFO_S));
991 // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
992 convertMsgStruct(&msgInfo, pMsg);
995 if (msgInfo.bTextSms == false)
998 MsgDeleteFile(msgInfo.msgData); //ipc
1005 msg_error_t MsgHandle::resetDatabase()
1007 // Allocate Memory to Command Data
1008 int cmdSize = sizeof(MSG_CMD_S);
1010 char cmdBuf[cmdSize];
1011 bzero(cmdBuf, cmdSize);
1012 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1014 // Set Command Parameters
1015 pCmd->cmdType = MSG_CMD_RESET_DB;
1018 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1020 // Send Command to Messaging FW
1021 char* pEventData = NULL;
1022 AutoPtr<char> eventBuf(&pEventData);
1024 write((char*)pCmd, cmdSize, &pEventData);
1027 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1029 if (pEvent->eventType != MSG_EVENT_RESET_DB)
1031 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1034 return pEvent->result;
1038 msg_error_t MsgHandle::getMemSize(unsigned int* memsize)
1040 // Allocate Memory to Command Data
1041 int cmdSize = sizeof(MSG_CMD_S);
1043 char cmdBuf[cmdSize];
1044 bzero(cmdBuf, cmdSize);
1045 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1047 // Set Command Parameters
1048 pCmd->cmdType = MSG_CMD_GET_MEMSIZE;
1051 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1053 // Send Command to Messaging FW
1054 char* pEventData = NULL;
1055 AutoPtr<char> eventBuf(&pEventData);
1058 write((char*)pCmd, cmdSize, &pEventData);
1061 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1063 if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE)
1065 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1068 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1070 // Decode Return Data
1071 MsgDecodeMemSize(pEvent->data, memsize);
1076 msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char *backup_filepath)
1078 if (backup_filepath == NULL)
1079 return MSG_ERR_NULL_POINTER;
1081 //Create an empty file for writing.
1082 //If a file with the same name already exists its content is erased
1083 //and the file is treated as a new empty file.
1084 FILE *pFile = MsgOpenFile(backup_filepath, "w");
1085 if (pFile == NULL) {
1086 MSG_DEBUG("File Open error");
1087 return MSG_ERR_STORAGE_ERROR;
1089 MsgCloseFile(pFile);
1091 char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
1092 strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
1094 // Allocate Memory to Command Data
1095 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_backup_type_t) + sizeof(path);
1097 char cmdBuf[cmdSize];
1098 bzero(cmdBuf, cmdSize);
1099 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1101 // Set Command Parameters
1102 pCmd->cmdType = MSG_CMD_BACKUP_MESSAGE;
1105 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1106 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &type, sizeof(msg_message_backup_type_t));
1107 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_backup_type_t)), (char *)path, sizeof(path));
1109 // Send Command to Messaging FW
1110 char* pEventData = NULL;
1111 AutoPtr<char> eventBuf(&pEventData);
1113 write((char*)pCmd, cmdSize, &pEventData);
1116 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1118 if (pEvent->eventType != MSG_EVENT_BACKUP_MESSAGE)
1120 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1123 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1128 msg_error_t MsgHandle::restoreMessage(const char *backup_filepath)
1130 if (backup_filepath == NULL)
1131 return MSG_ERR_NULL_POINTER;
1133 if (MsgAccessFile(backup_filepath, R_OK) == false) {
1134 MSG_DEBUG("File access error");
1135 return MSG_ERR_UNKNOWN;
1138 char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
1139 strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
1141 // Allocate Memory to Command Data
1142 int cmdSize = sizeof(MSG_CMD_S) + sizeof(path);
1144 char cmdBuf[cmdSize];
1145 bzero(cmdBuf, cmdSize);
1146 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1148 // Set Command Parameters
1149 pCmd->cmdType = MSG_CMD_RESTORE_MESSAGE;
1152 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1153 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), (char *)path, sizeof(path));
1155 // Send Command to Messaging FW
1156 char* pEventData = NULL;
1157 AutoPtr<char> eventBuf(&pEventData);
1160 write((char*)pCmd, cmdSize, &pEventData);
1163 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1165 if (pEvent->eventType != MSG_EVENT_RESTORE_MESSAGE)
1167 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1170 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1176 msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList)
1178 msg_error_t err = MSG_SUCCESS;
1180 err = MsgStoConnectDB();
1182 if (err != MSG_SUCCESS)
1184 MSG_DEBUG("MsgStoConnectDB() Error!!");
1188 err = MsgStoSearchMessage(pSearchString, pThreadViewList);
1190 if (err != MSG_SUCCESS)
1192 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1196 MsgStoDisconnectDB();
1202 msg_error_t MsgHandle::searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList)
1204 msg_error_t err = MSG_SUCCESS;
1206 err = MsgStoConnectDB();
1208 if (err != MSG_SUCCESS) {
1209 MSG_DEBUG("MsgStoConnectDB() Error!!");
1213 err = MsgStoSearchMessage(pSearchCon, offset, limit, pMsgList);
1215 if (err != MSG_SUCCESS) {
1216 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1220 MsgStoDisconnectDB();
1226 msg_error_t MsgHandle::getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList)
1228 msg_error_t err = MSG_SUCCESS;
1230 err = MsgStoConnectDB();
1232 if (err != MSG_SUCCESS)
1234 MSG_DEBUG("MsgStoConnectDB() Error!!");
1238 err = MsgStoGetRejectMsgList(pNumber, pRejectMsgList);
1240 if (err != MSG_SUCCESS)
1242 MSG_DEBUG("MsgStoGetRejectMsgList() Error!!");
1246 MsgStoDisconnectDB();
1252 msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam)
1254 if (!onStorageChange)
1255 THROW(MsgException::INVALID_PARAM, "onStorageChange is null");
1257 MsgProxyListener* eventListener = MsgProxyListener::instance();
1259 eventListener->start();
1261 if (eventListener->regStorageChangeEventCB(this, onStorageChange, pUserParam) == false) // callback was already registered, just return SUCCESS
1264 // Allocate Memory to Command Data
1265 int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
1266 char cmdBuf[cmdSize];
1267 bzero(cmdBuf, cmdSize);
1268 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
1270 // Set Command Parameters
1271 pCmd->cmdType = MSG_CMD_REG_STORAGE_CHANGE_CB;
1274 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1276 int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
1278 MSG_DEBUG("remote fd %d", listenerFd);
1280 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
1282 MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
1284 // Send Command to Messaging FW
1285 char* pEventData = NULL;
1286 AutoPtr<char> eventBuf(&pEventData);
1288 write((char*)pCmd, cmdSize, &pEventData);
1291 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1293 if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB)
1295 THROW(MsgException::INVALID_PARAM, "Event Data Error");
1298 return pEvent->result;
1301 msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_s *report_list)
1303 // Allocate Memory to Command Data
1304 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
1306 char cmdBuf[cmdSize];
1307 bzero(cmdBuf, cmdSize);
1308 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1310 // Set Command Parameters
1311 pCmd->cmdType = MSG_CMD_GET_REPORT_STATUS;
1314 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1316 // Copy Command Data
1317 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msg_id, sizeof(msg_message_id_t));
1319 // Send Command to Messaging FW
1320 char* pEventData = NULL;
1321 AutoPtr<char> eventBuf(&pEventData);
1324 write((char*)pCmd, cmdSize, &pEventData);
1327 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1329 if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS)
1331 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1334 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1336 // Decode Return Data
1337 MsgDecodeReportStatus(pEvent->data, report_list);
1343 msg_error_t MsgHandle::getAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList)
1345 msg_error_t err = MSG_SUCCESS;
1347 err = MsgStoConnectDB();
1349 if (err != MSG_SUCCESS)
1351 MSG_DEBUG("MsgStoConnectDB() Error!!");
1355 err = MsgStoGetAddressList(threadId, (msg_struct_list_s *)pAddrList);
1357 if (err != MSG_SUCCESS)
1359 MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
1363 MsgStoDisconnectDB();
1369 msg_error_t MsgHandle::getThreadIdByAddress(msg_struct_list_s *pAddrList, msg_thread_id_t *pThreadId)
1371 // Allocate Memory to Command Data
1372 int cmdSize = sizeof(MSG_CMD_S) + sizeof(pAddrList->nCount) + (sizeof(MSG_ADDRESS_INFO_S)*pAddrList->nCount);
1374 char cmdBuf[cmdSize];
1375 bzero(cmdBuf, cmdSize);
1376 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1378 // Set Command Parameters
1379 pCmd->cmdType = MSG_CMD_GET_THREAD_ID_BY_ADDRESS;
1382 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1384 // Copy Command Data
1385 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pAddrList->nCount, sizeof(pAddrList->nCount));
1386 int addSize = sizeof(MSG_ADDRESS_INFO_S);
1387 for(int i=0; i<pAddrList->nCount; i++) {
1388 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(pAddrList->nCount)+(addSize*i)+MAX_COOKIE_LEN), ((msg_struct_s *)(pAddrList->msg_struct_info[i]))->data, sizeof(MSG_ADDRESS_INFO_S));
1391 // Send Command to Messaging FW
1392 char* pEventData = NULL;
1393 AutoPtr<char> eventBuf(&pEventData);
1396 write((char*)pCmd, cmdSize, &pEventData);
1399 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1401 if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS)
1403 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1406 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1408 // Decode Return Data
1409 MsgDecodeThreadId(pEvent->data, pThreadId);
1415 msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pThreadInfo)
1417 // Allocate Memory to Command Data
1418 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
1420 char cmdBuf[cmdSize];
1421 bzero(cmdBuf, cmdSize);
1422 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1424 // Set Command Parameters
1425 pCmd->cmdType = MSG_CMD_GET_THREAD_INFO;
1428 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1430 // Copy Command Data
1431 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &threadId, sizeof(msg_thread_id_t));
1433 // Send Command to Messaging FW
1434 char* pEventData = NULL;
1435 AutoPtr<char> eventBuf(&pEventData);
1437 write((char*)pCmd, cmdSize, &pEventData);
1440 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1442 if (pEvent->eventType != MSG_EVENT_GET_THREAD_INFO)
1444 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1447 // Decode Return Data
1448 MsgDecodeThreadInfo(pEvent->data, pThreadInfo);
1454 msg_error_t MsgHandle::getMessageList(msg_folder_id_t folderId, msg_thread_id_t threadId, msg_message_type_t msgType, msg_storage_id_t storageId, msg_struct_list_s *pMsgList)
1456 msg_error_t err = MSG_SUCCESS;
1458 err = MsgStoConnectDB();
1460 if (err != MSG_SUCCESS) {
1461 MSG_DEBUG("MsgStoConnectDB() Error!!");
1465 err = MsgStoGetMessageList(folderId, threadId, msgType, storageId, pMsgList);
1467 if (err != MSG_SUCCESS) {
1468 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1472 MsgStoDisconnectDB();
1478 int MsgHandle::addPushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
1480 // Allocate Memory to Command Data
1481 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
1483 char cmdBuf[cmdSize];
1484 bzero(cmdBuf, cmdSize);
1485 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1487 // Set Command Parameters
1488 pCmd->cmdType = MSG_CMD_ADD_PUSH_EVENT;
1491 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1493 // Copy Command Data
1494 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
1496 // Send Command to Messaging FW
1497 char* pEventData = NULL;
1498 AutoPtr<char> eventBuf(&pEventData);
1500 write((char*)pCmd, cmdSize, &pEventData);
1503 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1505 if (pEvent->eventType != MSG_EVENT_ADD_PUSH_EVENT)
1507 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1510 return pEvent->result;
1514 int MsgHandle::deletePushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
1516 // Allocate Memory to Command Data
1517 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
1519 char cmdBuf[cmdSize];
1520 bzero(cmdBuf, cmdSize);
1521 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1523 // Set Command Parameters
1524 pCmd->cmdType = MSG_CMD_DELETE_PUSH_EVENT;
1527 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1529 // Copy Command Data
1530 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
1532 // Send Command to Messaging FW
1533 char* pEventData = NULL;
1534 AutoPtr<char> eventBuf(&pEventData);
1536 write((char*)pCmd, cmdSize, &pEventData);
1539 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1541 if (pEvent->eventType != MSG_EVENT_DELETE_PUSH_EVENT)
1543 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1546 return pEvent->result;
1549 int MsgHandle::updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_S *pDst)
1551 // Allocate Memory to Command Data
1552 int cmdSize = sizeof(MSG_CMD_S) + 2 * sizeof(MSG_PUSH_EVENT_INFO_S);
1554 char cmdBuf[cmdSize];
1555 bzero(cmdBuf, cmdSize);
1556 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1558 // Set Command Parameters
1559 pCmd->cmdType = MSG_CMD_UPDATE_PUSH_EVENT;
1562 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1564 // Copy Command Data
1565 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSrc, sizeof(MSG_PUSH_EVENT_INFO_S));
1566 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_PUSH_EVENT_INFO_S)), pDst, sizeof(MSG_PUSH_EVENT_INFO_S));
1568 // Send Command to Messaging FW
1569 char* pEventData = NULL;
1570 AutoPtr<char> eventBuf(&pEventData);
1572 write((char*)pCmd, cmdSize, &pEventData);
1575 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1577 if (pEvent->eventType != MSG_EVENT_UPDATE_PUSH_EVENT)
1579 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1582 return pEvent->result;
1585 msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData)
1587 // Allocate Memory to Command Data
1588 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
1589 char *encode_data = NULL;
1590 char cmdBuf[cmdSize];
1591 bzero(cmdBuf, cmdSize);
1592 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1594 // Set Command Parameters
1595 pCmd->cmdType = MSG_CMD_GET_MSG;
1598 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1600 // Copy Command Data
1601 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
1603 // Send Command to Messaging FW
1604 char* pEventData = NULL;
1605 AutoPtr<char> eventBuf(&pEventData);
1608 write((char*)pCmd, cmdSize, &pEventData);
1611 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1613 if (pEvent->eventType != MSG_EVENT_GET_MSG)
1615 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1618 if(pEvent->result != MSG_SUCCESS)
1619 return pEvent->result;
1621 // Decode Return Data
1622 MSG_MESSAGE_INFO_S msgInfo = {0,};
1623 MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
1625 MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
1627 //Convert MSG_MESSAGE_INFO_S to
1628 encode_data = MsgVMessageEncode(&msgInfo);
1630 *encodedData = (void*)encode_data;
1632 MSG_DEBUG("Error Encode data");
1633 *encodedData = NULL;
1637 if (msgInfo.bTextSms == false)
1640 MsgDeleteFile(msgInfo.msgData); //ipc