2 * Copyright 2012 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://www.tizenopensource.org/license
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"
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;
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;
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;
138 MSG_SENDINGOPT_INFO_S sendOptInfo;
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::moveMessageToFolder(msg_message_id_t MsgId, msg_folder_id_t DestFolderId)
342 // Allocate Memory to Command Data
343 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_folder_id_t);
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_MOVE_MSGTOFOLDER;
353 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
356 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
357 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(msg_message_id_t)+MAX_COOKIE_LEN), &DestFolderId, sizeof(msg_folder_id_t));
359 // Send Command to Messaging FW
360 char* pEventData = NULL;
361 AutoPtr<char> eventBuf(&pEventData);
364 write((char*)pCmd, cmdSize, &pEventData);
367 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
369 if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER)
371 THROW(MsgException::INVALID_RESULT, "Event Data Error");
374 return pEvent->result;
378 msg_error_t MsgHandle::moveMessageToStorage(msg_message_id_t MsgId, msg_storage_id_t DestStorageId)
380 // Allocate Memory to Command Data
381 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_storage_id_t);
383 char cmdBuf[cmdSize];
384 bzero(cmdBuf, cmdSize);
385 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
387 // Set Command Parameters
388 pCmd->cmdType = MSG_CMD_MOVE_MSGTOSTORAGE;
391 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
394 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
395 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &DestStorageId, sizeof(msg_storage_id_t));
397 // Send Command to Messaging FW
398 char* pEventData = NULL;
399 AutoPtr<char> eventBuf(&pEventData);
402 write((char*)pCmd, cmdSize, &pEventData);
405 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
407 if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE)
409 THROW(MsgException::INVALID_RESULT, "Event Data Error");
412 return pEvent->result;
416 msg_error_t MsgHandle::countMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S *pCountInfo)
418 // Allocate Memory to Command Data
419 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
421 char cmdBuf[cmdSize];
422 bzero(cmdBuf, cmdSize);
423 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
425 // Set Command Parameters
426 pCmd->cmdType = MSG_CMD_COUNT_MSG;
429 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
432 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
434 // Send Command to Messaging FW
435 char* pEventData = NULL;
436 AutoPtr<char> eventBuf(&pEventData);
439 write((char*)pCmd, cmdSize, &pEventData);
442 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
444 if (pEvent->eventType != MSG_EVENT_COUNT_MSG)
446 THROW(MsgException::INVALID_RESULT, "Event Data Error");
449 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
451 // Decode Return Data
452 MsgDecodeCountInfo(pEvent->data, pCountInfo);
458 msg_error_t MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
460 // Allocate Memory to Command Data
461 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_TYPE_S);
463 char cmdBuf[cmdSize];
464 bzero(cmdBuf, cmdSize);
465 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
467 // Set Command Parameters
468 pCmd->cmdType = MSG_CMD_COUNT_BY_MSGTYPE;
471 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
474 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgType, sizeof(MSG_MESSAGE_TYPE_S));
476 // Send Command to Messaging FW
477 char* pEventData = NULL;
478 AutoPtr<char> eventBuf(&pEventData);
480 write((char*)pCmd, cmdSize, &pEventData);
483 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
485 if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE)
487 THROW(MsgException::INVALID_RESULT, "Event Data Error");
490 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
492 // Decode Return Data
493 memcpy(pMsgCount, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
499 msg_error_t MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
501 // Allocate Memory to Command Data
502 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_LIST_INDEX_S);
504 char cmdBuf[cmdSize];
505 bzero(cmdBuf, cmdSize);
506 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
508 // Set Command Parameters
509 pCmd->cmdType = MSG_CMD_GET_CONTACT_COUNT;
512 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
515 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pAddrInfo, sizeof(msg_contact_id_t));
516 msg_struct_s *pAddr = (msg_struct_s *)pAddrInfo->msgAddrInfo;
518 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN + sizeof(msg_contact_id_t)), pAddr->data, sizeof(MSG_ADDRESS_INFO_S));
519 // Send Command to Messaging FW
520 char* pEventData = NULL;
521 AutoPtr<char> eventBuf(&pEventData);
523 write((char*)pCmd, cmdSize, &pEventData);
526 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
528 if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT)
530 THROW(MsgException::INVALID_RESULT, "Event Data Error");
533 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
535 // Decode Return Data
536 MsgDecodeContactCount(pEvent->data, pMsgThreadCountList);
542 msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *pMsg, MSG_SENDINGOPT_S *pSendOpt)
544 // Allocate Memory to Command Data
545 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
547 char cmdBuf[cmdSize];
548 bzero(cmdBuf, cmdSize);
549 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
551 // Set Command Parameters
552 pCmd->cmdType = MSG_CMD_GET_MSG;
555 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
558 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
560 // Send Command to Messaging FW
561 char* pEventData = NULL;
562 AutoPtr<char> eventBuf(&pEventData);
565 write((char*)pCmd, cmdSize, &pEventData);
568 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
570 if (pEvent->eventType != MSG_EVENT_GET_MSG)
572 THROW(MsgException::INVALID_RESULT, "Event Data Error");
575 if(pEvent->result != MSG_SUCCESS)
576 return pEvent->result;
578 // Decode Return Data
579 MSG_MESSAGE_INFO_S msgInfo;
580 MSG_SENDINGOPT_INFO_S sendOptInfo;
581 MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
583 // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_HIDDEN_S
584 convertMsgStruct(&msgInfo, pMsg);
586 if(pSendOpt != NULL) {
587 MSG_MESSAGE_TYPE_S msgType = {0,};
589 msgType.mainType = pMsg->mainType;
590 msgType.subType = pMsg->subType;
591 msgType.classType = pMsg->classType;
593 convertSendOptStruct(&sendOptInfo, pSendOpt, msgType);
597 if (msgInfo.bTextSms == false)
600 MsgDeleteFile(msgInfo.msgData); //ipc
607 msg_error_t MsgHandle::getFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList)
609 msg_error_t err = MSG_SUCCESS;
611 err = MsgStoConnectDB();
613 if (err != MSG_SUCCESS)
615 MSG_DEBUG("MsgStoConnectDB() Error!!");
619 err = MsgStoGetFolderViewList(FolderId, (MSG_SORT_RULE_S *)pSortRule, pMsgFolderViewList);
621 if (err != MSG_SUCCESS)
623 MSG_DEBUG("MsgStoGetFolderViewList() Error!!");
627 MsgStoDisconnectDB();
633 msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
635 // Allocate Memory to Command Data
636 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
638 char cmdBuf[cmdSize];
639 bzero(cmdBuf, cmdSize);
640 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
642 // Set Command Parameters
643 pCmd->cmdType = MSG_CMD_ADD_FOLDER;
646 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
649 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
651 // Send Command to Messaging FW
652 char* pEventData = NULL;
653 AutoPtr<char> eventBuf(&pEventData);
656 write((char*)pCmd, cmdSize, &pEventData);
659 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
661 if (pEvent->eventType != MSG_EVENT_ADD_FOLDER)
663 THROW(MsgException::INVALID_RESULT, "Event Data Error");
666 return pEvent->result;
670 msg_error_t MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
672 // Allocate Memory to Command Data
673 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
675 char cmdBuf[cmdSize];
676 bzero(cmdBuf, cmdSize);
677 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
679 // Set Command Parameters
680 pCmd->cmdType = MSG_CMD_UPDATE_FOLDER;
683 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
686 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
688 // Send Command to Messaging FW
689 char* pEventData = NULL;
690 AutoPtr<char> eventBuf(&pEventData);
693 write((char*)pCmd, cmdSize, &pEventData);
696 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
698 if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER)
700 THROW(MsgException::INVALID_RESULT, "Event Data Error");
703 return pEvent->result;;
707 msg_error_t MsgHandle::deleteFolder(msg_folder_id_t FolderId)
709 // Allocate Memory to Command Data
710 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
712 char cmdBuf[cmdSize];
713 bzero(cmdBuf, cmdSize);
714 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
716 // Set Command Parameters
717 pCmd->cmdType = MSG_CMD_DELETE_FOLDER;
720 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
723 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
725 // Send Command to Messaging FW
726 char* pEventData = NULL;
727 AutoPtr<char> eventBuf(&pEventData);
730 write((char*)pCmd, cmdSize, &pEventData);
733 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
735 if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER)
737 THROW(MsgException::INVALID_RESULT, "Event Data Error");
740 return pEvent->result;
744 msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList)
746 // Allocate Memory to Command Data
747 int cmdSize = sizeof(MSG_CMD_S);
749 char cmdBuf[cmdSize];
750 bzero(cmdBuf, cmdSize);
751 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
753 // Set Command Parameters
754 pCmd->cmdType = MSG_CMD_GET_FOLDERLIST;
757 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
759 // Send Command to Messaging FW
760 char* pEventData = NULL;
761 AutoPtr<char> eventBuf(&pEventData);
763 write((char*)pCmd, cmdSize, &pEventData);
766 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
768 if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST)
770 THROW(MsgException::INVALID_RESULT, "Event Data Error");
773 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
775 // Decode Return Data
776 MsgDecodeFolderList(pEvent->data, pFolderList);
782 msg_error_t MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
784 msg_error_t err = MSG_SUCCESS;
786 err = MsgStoConnectDB();
788 if (err != MSG_SUCCESS)
790 MSG_DEBUG("MsgStoConnectDB() Error!!");
794 err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
796 if (err != MSG_SUCCESS)
798 MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
802 MsgStoDisconnectDB();
808 msg_error_t MsgHandle::getConversationViewList(msg_thread_id_t ThreadId, msg_struct_list_s *pConvViewList)
812 msg_error_t err = MSG_SUCCESS;
815 err = MsgStoGetConversationViewList(ThreadId, pConvViewList);
816 MsgStoDisconnectDB();
818 if(err != MSG_SUCCESS)
822 // Update Read Status for the Thead ID
824 // Allocate Memory to Command Data
825 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
827 char cmdBuf[cmdSize];
828 bzero(cmdBuf, cmdSize);
829 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
831 // Set Command Parameters
832 pCmd->cmdType = MSG_CMD_UPDATE_THREAD_READ;
835 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
838 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
840 // Send Command to Messaging FW
841 char* pEventData = NULL;
842 AutoPtr<char> eventBuf(&pEventData);
844 write((char*)pCmd, cmdSize, &pEventData);
847 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
849 if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ)
851 THROW(MsgException::INVALID_RESULT, "Event Data Error");
861 msg_error_t MsgHandle::deleteThreadMessageList(msg_thread_id_t ThreadId)
863 // Allocate Memory to Command Data
864 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_LIST_INDEX_S);
866 char cmdBuf[cmdSize];
867 bzero(cmdBuf, cmdSize);
868 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
870 // Set Command Parameters
871 pCmd->cmdType = MSG_CMD_DELETE_THREADMESSAGELIST;
874 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
877 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
879 // Send Command to Messaging FW
880 char* pEventData = NULL;
881 AutoPtr<char> eventBuf(&pEventData);
884 write((char*)pCmd, cmdSize, &pEventData);
887 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
889 if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST)
891 THROW(MsgException::INVALID_RESULT, "Event Data Error");
894 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
900 msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_HIDDEN_S *pMsg)
902 // Allocate Memory to Command Data
903 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_quickpanel_type_t);
905 char cmdBuf[cmdSize];
906 bzero(cmdBuf, cmdSize);
907 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
909 // Set Command Parameters
910 pCmd->cmdType = MSG_CMD_GET_QUICKPANEL_DATA;
913 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
916 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &Type, sizeof(msg_quickpanel_type_t));
918 // Send Command to Messaging FW
919 char* pEventData = NULL;
920 AutoPtr<char> eventBuf(&pEventData);
922 write((char*)pCmd, cmdSize, &pEventData);
925 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
927 if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA)
929 THROW(MsgException::INVALID_RESULT, "Event Data Error");
932 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
934 // Decode Return Data
935 MSG_MESSAGE_INFO_S msgInfo;
937 memcpy(&msgInfo, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(MSG_MESSAGE_INFO_S));
939 // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
940 convertMsgStruct(&msgInfo, pMsg);
943 if (msgInfo.bTextSms == false)
946 MsgDeleteFile(msgInfo.msgData); //ipc
953 msg_error_t MsgHandle::resetDatabase()
955 // Allocate Memory to Command Data
956 int cmdSize = sizeof(MSG_CMD_S);
958 char cmdBuf[cmdSize];
959 bzero(cmdBuf, cmdSize);
960 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
962 // Set Command Parameters
963 pCmd->cmdType = MSG_CMD_RESET_DB;
966 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
968 // Send Command to Messaging FW
969 char* pEventData = NULL;
970 AutoPtr<char> eventBuf(&pEventData);
972 write((char*)pCmd, cmdSize, &pEventData);
975 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
977 if (pEvent->eventType != MSG_EVENT_RESET_DB)
979 THROW(MsgException::INVALID_RESULT, "Event Data Error");
982 return pEvent->result;
986 msg_error_t MsgHandle::getMemSize(unsigned int* memsize)
988 // Allocate Memory to Command Data
989 int cmdSize = sizeof(MSG_CMD_S);
991 char cmdBuf[cmdSize];
992 bzero(cmdBuf, cmdSize);
993 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
995 // Set Command Parameters
996 pCmd->cmdType = MSG_CMD_GET_MEMSIZE;
999 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1001 // Send Command to Messaging FW
1002 char* pEventData = NULL;
1003 AutoPtr<char> eventBuf(&pEventData);
1006 write((char*)pCmd, cmdSize, &pEventData);
1009 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1011 if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE)
1013 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1016 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1018 // Decode Return Data
1019 MsgDecodeMemSize(pEvent->data, memsize);
1025 msg_error_t MsgHandle::backupMessage()
1027 // Allocate Memory to Command Data
1028 int cmdSize = sizeof(MSG_CMD_S);
1030 char cmdBuf[cmdSize];
1031 bzero(cmdBuf, cmdSize);
1032 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1034 // Set Command Parameters
1035 pCmd->cmdType = MSG_CMD_BACKUP_MESSAGE;
1038 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1040 // Send Command to Messaging FW
1041 char* pEventData = NULL;
1042 AutoPtr<char> eventBuf(&pEventData);
1045 write((char*)pCmd, cmdSize, &pEventData);
1048 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1050 if (pEvent->eventType != MSG_EVENT_BACKUP_MESSAGE)
1052 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1055 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1061 msg_error_t MsgHandle::restoreMessage()
1063 // Allocate Memory to Command Data
1064 int cmdSize = sizeof(MSG_CMD_S);
1066 char cmdBuf[cmdSize];
1067 bzero(cmdBuf, cmdSize);
1068 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1070 // Set Command Parameters
1071 pCmd->cmdType = MSG_CMD_RESTORE_MESSAGE;
1074 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1076 // Send Command to Messaging FW
1077 char* pEventData = NULL;
1078 AutoPtr<char> eventBuf(&pEventData);
1081 write((char*)pCmd, cmdSize, &pEventData);
1084 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1086 if (pEvent->eventType != MSG_EVENT_RESTORE_MESSAGE)
1088 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1091 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1097 msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList)
1099 msg_error_t err = MSG_SUCCESS;
1101 err = MsgStoConnectDB();
1103 if (err != MSG_SUCCESS)
1105 MSG_DEBUG("MsgStoConnectDB() Error!!");
1109 err = MsgStoSearchMessage(pSearchString, pThreadViewList);
1111 if (err != MSG_SUCCESS)
1113 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1117 MsgStoDisconnectDB();
1123 msg_error_t MsgHandle::searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList)
1125 msg_error_t err = MSG_SUCCESS;
1127 err = MsgStoConnectDB();
1129 if (err != MSG_SUCCESS) {
1130 MSG_DEBUG("MsgStoConnectDB() Error!!");
1134 err = MsgStoSearchMessage(pSearchCon, offset, limit, pMsgList);
1136 if (err != MSG_SUCCESS) {
1137 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1141 MsgStoDisconnectDB();
1147 msg_error_t MsgHandle::getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList)
1149 msg_error_t err = MSG_SUCCESS;
1151 err = MsgStoConnectDB();
1153 if (err != MSG_SUCCESS)
1155 MSG_DEBUG("MsgStoConnectDB() Error!!");
1159 err = MsgStoGetRejectMsgList(pNumber, pRejectMsgList);
1161 if (err != MSG_SUCCESS)
1163 MSG_DEBUG("MsgStoGetRejectMsgList() Error!!");
1167 MsgStoDisconnectDB();
1173 msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam)
1175 if (!onStorageChange)
1176 THROW(MsgException::INVALID_PARAM, "onStorageChange is null");
1178 MsgProxyListener* eventListener = MsgProxyListener::instance();
1180 eventListener->start();
1182 if (eventListener->regStorageChangeEventCB(this, onStorageChange, pUserParam) == false) // callback was already registered, just return SUCCESS
1185 // Allocate Memory to Command Data
1186 int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
1187 char cmdBuf[cmdSize];
1188 bzero(cmdBuf, cmdSize);
1189 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
1191 // Set Command Parameters
1192 pCmd->cmdType = MSG_CMD_REG_STORAGE_CHANGE_CB;
1195 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1197 int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
1199 MSG_DEBUG("remote fd %d", listenerFd);
1201 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
1203 MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
1205 // Send Command to Messaging FW
1206 char* pEventData = NULL;
1207 AutoPtr<char> eventBuf(&pEventData);
1209 write((char*)pCmd, cmdSize, &pEventData);
1212 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1214 if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB)
1216 THROW(MsgException::INVALID_PARAM, "Event Data Error");
1219 return pEvent->result;
1223 msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, MSG_REPORT_STATUS_INFO_S *pReport_status)
1225 // Allocate Memory to Command Data
1226 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
1228 char cmdBuf[cmdSize];
1229 bzero(cmdBuf, cmdSize);
1230 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1232 // Set Command Parameters
1233 pCmd->cmdType = MSG_CMD_GET_REPORT_STATUS;
1236 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1238 // Copy Command Data
1239 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msg_id, sizeof(msg_message_id_t));
1241 // Send Command to Messaging FW
1242 char* pEventData = NULL;
1243 AutoPtr<char> eventBuf(&pEventData);
1246 write((char*)pCmd, cmdSize, &pEventData);
1249 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1251 if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS)
1253 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1256 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1258 // Decode Return Data
1259 MsgDecodeReportStatus(pEvent->data, pReport_status);
1265 msg_error_t MsgHandle::getAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList)
1267 msg_error_t err = MSG_SUCCESS;
1269 err = MsgStoConnectDB();
1271 if (err != MSG_SUCCESS)
1273 MSG_DEBUG("MsgStoConnectDB() Error!!");
1277 err = MsgStoGetAddressList(threadId, (msg_struct_list_s *)pAddrList);
1279 if (err != MSG_SUCCESS)
1281 MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
1285 MsgStoDisconnectDB();
1291 msg_error_t MsgHandle::getThreadIdByAddress(msg_struct_list_s *pAddrList, msg_thread_id_t *pThreadId)
1293 // Allocate Memory to Command Data
1294 int cmdSize = sizeof(MSG_CMD_S) + sizeof(pAddrList->nCount) + (sizeof(MSG_ADDRESS_INFO_S)*pAddrList->nCount);
1296 char cmdBuf[cmdSize];
1297 bzero(cmdBuf, cmdSize);
1298 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1300 // Set Command Parameters
1301 pCmd->cmdType = MSG_CMD_GET_THREAD_ID_BY_ADDRESS;
1304 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1306 // Copy Command Data
1307 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pAddrList->nCount, sizeof(pAddrList->nCount));
1308 int addSize = sizeof(MSG_ADDRESS_INFO_S);
1309 for(int i=0; i<pAddrList->nCount; i++) {
1310 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));
1313 // Send Command to Messaging FW
1314 char* pEventData = NULL;
1315 AutoPtr<char> eventBuf(&pEventData);
1318 write((char*)pCmd, cmdSize, &pEventData);
1321 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1323 if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS)
1325 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1328 if(pEvent->result != MSG_SUCCESS) return pEvent->result;
1330 // Decode Return Data
1331 MsgDecodeThreadId(pEvent->data, pThreadId);
1337 msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pThreadInfo)
1339 // Allocate Memory to Command Data
1340 int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
1342 char cmdBuf[cmdSize];
1343 bzero(cmdBuf, cmdSize);
1344 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1346 // Set Command Parameters
1347 pCmd->cmdType = MSG_CMD_GET_THREAD_INFO;
1350 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1352 // Copy Command Data
1353 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &threadId, sizeof(msg_thread_id_t));
1355 // Send Command to Messaging FW
1356 char* pEventData = NULL;
1357 AutoPtr<char> eventBuf(&pEventData);
1359 write((char*)pCmd, cmdSize, &pEventData);
1362 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1364 if (pEvent->eventType != MSG_EVENT_GET_THREAD_INFO)
1366 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1369 // Decode Return Data
1370 MsgDecodeThreadInfo(pEvent->data, pThreadInfo);
1376 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)
1378 msg_error_t err = MSG_SUCCESS;
1380 err = MsgStoConnectDB();
1382 if (err != MSG_SUCCESS) {
1383 MSG_DEBUG("MsgStoConnectDB() Error!!");
1387 err = MsgStoGetMessageList(folderId, threadId, msgType, storageId, pMsgList);
1389 if (err != MSG_SUCCESS) {
1390 MSG_DEBUG("MsgStoSearchMessage() Error!!");
1394 MsgStoDisconnectDB();
1400 int MsgHandle::addPushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
1402 // Allocate Memory to Command Data
1403 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
1405 char cmdBuf[cmdSize];
1406 bzero(cmdBuf, cmdSize);
1407 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1409 // Set Command Parameters
1410 pCmd->cmdType = MSG_CMD_ADD_PUSH_EVENT;
1413 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1415 // Copy Command Data
1416 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
1418 // Send Command to Messaging FW
1419 char* pEventData = NULL;
1420 AutoPtr<char> eventBuf(&pEventData);
1422 write((char*)pCmd, cmdSize, &pEventData);
1425 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1427 if (pEvent->eventType != MSG_EVENT_ADD_PUSH_EVENT)
1429 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1432 return pEvent->result;
1436 int MsgHandle::deletePushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
1438 // Allocate Memory to Command Data
1439 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
1441 char cmdBuf[cmdSize];
1442 bzero(cmdBuf, cmdSize);
1443 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1445 // Set Command Parameters
1446 pCmd->cmdType = MSG_CMD_DELETE_PUSH_EVENT;
1449 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1451 // Copy Command Data
1452 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
1454 // Send Command to Messaging FW
1455 char* pEventData = NULL;
1456 AutoPtr<char> eventBuf(&pEventData);
1458 write((char*)pCmd, cmdSize, &pEventData);
1461 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1463 if (pEvent->eventType != MSG_EVENT_DELETE_PUSH_EVENT)
1465 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1468 return pEvent->result;
1471 int MsgHandle::updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_S *pDst)
1473 // Allocate Memory to Command Data
1474 int cmdSize = sizeof(MSG_CMD_S) + 2 * sizeof(MSG_PUSH_EVENT_INFO_S);
1476 char cmdBuf[cmdSize];
1477 bzero(cmdBuf, cmdSize);
1478 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
1480 // Set Command Parameters
1481 pCmd->cmdType = MSG_CMD_UPDATE_PUSH_EVENT;
1484 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
1486 // Copy Command Data
1487 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSrc, sizeof(MSG_PUSH_EVENT_INFO_S));
1488 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));
1490 // Send Command to Messaging FW
1491 char* pEventData = NULL;
1492 AutoPtr<char> eventBuf(&pEventData);
1494 write((char*)pCmd, cmdSize, &pEventData);
1497 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
1499 if (pEvent->eventType != MSG_EVENT_UPDATE_PUSH_EVENT)
1501 THROW(MsgException::INVALID_RESULT, "Event Data Error");
1504 return pEvent->result;