3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
34 #include "MsgUtilFile.h"
35 #include "MsgException.h"
36 #include "MsgCppTypes.h"
37 #include "MsgUtilFunction.h"
38 #include "MsgStorageHandler.h"
39 #include "MsgPluginManager.h"
40 #include "MsgTransManager.h"
41 #include "MsgCmdHandler.h"
44 /*==================================================================================================
45 FUNCTION IMPLEMENTATION
46 ==================================================================================================*/
47 int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
49 MSG_ERROR_T err = MSG_SUCCESS;
51 char* encodedData = NULL;
52 AutoPtr<char> buf(&encodedData);
54 int dataSize = 0, eventSize = 0;
57 MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData;
60 MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S));
62 // Add Message with address
63 for (int i = 0; i < pMsgInfo->nAddressCnt; i++)
65 err = MsgStoAddMessage(pMsgInfo, pSendOptInfo, i);
67 if (err == MSG_SUCCESS)
69 MSG_DEBUG("Command Handle Success : MsgStoAddMessage()");
74 // Encoding Message ID
75 dataSize = MsgEncodeMsgId(&(pMsgInfo->msgId), &encodedData);
80 MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()");
84 // Add Message without address
85 if (pMsgInfo->nAddressCnt == 0)
87 err = MsgStoAddMessage(pMsgInfo, pSendOptInfo);
89 if (err == MSG_SUCCESS)
91 MSG_DEBUG("Command Handle Success : MsgStoAddMessage()");
93 // Encoding Message ID
94 dataSize = MsgEncodeMsgId(&(pMsgInfo->msgId), &encodedData);
98 MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()");
102 // Delete Temp File for Message Data
103 if (pMsgInfo->bTextSms == false)
104 MsgDeleteFile(pMsgInfo->msgData); //ipc
107 MSG_MSGID_LIST_S msgIdList;
108 MSG_MESSAGE_ID_T msgIds[1];
109 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
111 msgIdList.nCount = 1;
112 msgIds[0] = pMsgInfo->msgId;
113 msgIdList.msgIdList = msgIds;
115 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
118 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_MSG, err, (void**)ppEvent);
124 int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
126 MSG_ERROR_T err = MSG_SUCCESS;
130 int extId = 0, pinCode = 0;
132 MSG_MESSAGE_INFO_S msgInfo = {};
134 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
135 memcpy(&pinCode, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(int));
136 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), sizeof(MSG_MESSAGE_INFO_S));
139 err = MsgStoAddSyncMLMessage(&msgInfo, extId, pinCode);
141 if (err == MSG_SUCCESS)
143 MSG_DEBUG("Command Handle Success : MsgStoAddSyncMLMessage()");
145 // broadcast to listener threads, here
146 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
148 MSG_MSGID_LIST_S msgIdList;
149 MSG_MESSAGE_ID_T msgIds[1];
150 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
152 msgIdList.nCount = 1;
153 msgIds[0] = msgInfo.msgId;
154 msgIdList.msgIdList = msgIds;
156 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
160 MSG_DEBUG("Command Handle Fail : MsgStoAddSyncMLMessage()");
164 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent);
170 int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
172 MSG_ERROR_T err = MSG_SUCCESS;
177 MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData;
179 // Get Sending Option
180 MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S));
183 err = MsgStoUpdateMessage(pMsgInfo, pSendOptInfo);
185 if (err == MSG_SUCCESS)
186 MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()");
188 MSG_DEBUG("Command Handle Fail : MsgStoUpdateMessage()");
190 // Delete Temp File for Message Data
191 if (pMsgInfo->bTextSms == false)
192 MsgDeleteFile(pMsgInfo->msgData); //ipc
195 MSG_MSGID_LIST_S msgIdList;
196 MSG_MESSAGE_ID_T msgIds[1];
197 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
199 msgIdList.nCount = 1;
200 msgIds[0] = pMsgInfo->msgId;
201 msgIdList.msgIdList = msgIds;
203 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
206 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_MSG, err, (void**)ppEvent);
212 int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
214 MSG_ERROR_T err = MSG_SUCCESS;
218 MSG_MESSAGE_ID_T msgId;
221 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
222 memcpy(&readStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(bool));
224 // Update Read Status
225 err = MsgStoUpdateReadStatus(msgId, readStatus);
227 if (err == MSG_SUCCESS)
229 MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()");
233 MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()");
237 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_READ, err, (void**)ppEvent);
243 int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
245 MSG_ERROR_T err = MSG_SUCCESS;
249 MSG_THREAD_ID_T threadId;
252 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
254 MsgStoGetThreadUnreadCnt(threadId, &unReadCnt);
256 MSG_DEBUG("unReadCnt [%d]", unReadCnt);
260 err = MsgStoUpdateThreadReadStatus(threadId);
262 if (err == MSG_SUCCESS)
263 MSG_DEBUG("Command Handle Success : MsgStoUpdateThreadReadStatus()");
265 MSG_DEBUG("Command Handle Fail : MsgStoUpdateThreadReadStatus()");
269 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_THREAD_READ, err, (void**)ppEvent);
276 int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
278 MSG_ERROR_T err = MSG_SUCCESS;
282 MSG_MESSAGE_ID_T msgId;
283 bool protectedStatus;
285 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
286 memcpy(&protectedStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(bool));
288 // Update Protected Status
289 err = MsgStoUpdateProtectedStatus(msgId, protectedStatus);
291 if (err == MSG_SUCCESS)
293 MSG_DEBUG("Command Handle Success : MsgStoUpdateProtectedStatus()");
297 MSG_DEBUG("Command Handle Fail : MsgStoUpdateProtectedStatus()");
301 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PROTECTED, err, (void**)ppEvent);
307 int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
309 MSG_ERROR_T err = MSG_SUCCESS;
315 MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
317 MsgStoGetSyncMLExtId(*msgId, &extId);
320 err = MsgStoDeleteMessage(*msgId, true);
322 if (err == MSG_SUCCESS) {
323 MSG_DEBUG("Command Handle Success : MsgStoDeleteMessage()");
326 // broadcast to listener threads, here
327 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, extId);
330 MSG_MSGID_LIST_S msgIdList;
331 MSG_MESSAGE_ID_T msgIds[1];
332 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
334 msgIdList.nCount = 1;
336 msgIdList.msgIdList = msgIds;
338 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
340 MSG_DEBUG("Command Handle Fail : MsgStoDeleteMessage()");
344 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_MSG, err, (void**)ppEvent);
350 int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
352 MSG_ERROR_T err = MSG_SUCCESS;
356 MSG_FOLDER_ID_T* folderId = (MSG_FOLDER_ID_T*)pCmd->cmdData;
359 memcpy(&bOnlyDB, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), sizeof(bool));
362 MSG_MSGID_LIST_S msgIdList;
363 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
366 err = MsgStoDeleteAllMessageInFolder(*folderId, bOnlyDB, &msgIdList);
368 if (err == MSG_SUCCESS) {
369 MSG_DEBUG("Command Handle Success : MsgStoDeleteAllMessageInFolder()");
370 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
371 if(msgIdList.msgIdList != NULL)
372 delete [] (char*)msgIdList.msgIdList;
374 MSG_DEBUG("Command Handle Fail : MsgStoDeleteAllMessageInFolder()");
378 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELALL_MSGINFOLDER, err, (void**)ppEvent);
385 int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
387 MSG_ERROR_T err = MSG_SUCCESS;
391 MSG_MESSAGE_ID_T msgId;
392 MSG_FOLDER_ID_T folderId;
394 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
395 memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(MSG_FOLDER_ID_T));
398 err = MsgStoMoveMessageToFolder(msgId, folderId);
400 if (err == MSG_SUCCESS) {
401 MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToFolder()");
403 MSG_MSGID_LIST_S msgIdList;
404 MSG_MESSAGE_ID_T msgIds[1];
405 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
407 msgIdList.nCount = 1;
409 msgIdList.msgIdList = msgIds;
411 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
413 MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToFolder()");
417 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOFOLDER, err, (void**)ppEvent);
423 int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
425 MSG_ERROR_T err = MSG_SUCCESS;
429 MSG_MESSAGE_ID_T msgId;
430 MSG_STORAGE_ID_T storageId;
432 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
433 memcpy(&storageId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(MSG_STORAGE_ID_T));
436 err = MsgStoMoveMessageToStorage(msgId, storageId);
438 if (err == MSG_SUCCESS)
440 MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToStorage()");
444 MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToStorage()");
448 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOSTORAGE, err, (void**)ppEvent);
454 int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
456 MSG_ERROR_T err = MSG_SUCCESS;
458 char* encodedData = NULL;
459 AutoPtr<char> buf(&encodedData);
461 int dataSize = 0, eventSize = 0;
464 MSG_FOLDER_ID_T* folderId = (MSG_FOLDER_ID_T*)pCmd->cmdData;
467 MSG_COUNT_INFO_S countInfo;
469 err = MsgStoCountMessage(*folderId, &countInfo);
471 if (err == MSG_SUCCESS)
473 MSG_DEBUG("Command Handle Success : MsgStoCountMessage()");
475 // Encoding Messaging Count Data
476 dataSize = MsgEncodeCountInfo(&countInfo, &encodedData);
480 MSG_DEBUG("Command Handle Fail : MsgStoCountMessage()");
484 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_MSG, err, (void**)ppEvent);
490 int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
492 MSG_ERROR_T err = MSG_SUCCESS;
494 char* encodedData = NULL;
495 AutoPtr<char> buf(&encodedData);
497 int dataSize = 0, eventSize = 0;
500 MSG_MESSAGE_TYPE_S* pMsgType = (MSG_MESSAGE_TYPE_S*)pCmd->cmdData;
505 err = MsgStoCountMsgByType(pMsgType, &nMsgCnt);
507 if (err == MSG_SUCCESS)
509 MSG_DEBUG("Command Handle Success : MsgStoCountMsgByType()");
511 // Encoding Messaging Count Data
512 dataSize = MsgEncodeCountByMsgType(nMsgCnt, &encodedData);
516 MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByType()");
520 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_BY_MSGTYPE, err, (void**)ppEvent);
526 int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
528 MSG_ERROR_T err = MSG_SUCCESS;
531 MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
533 char* encodedData = NULL;
534 AutoPtr<char> buf(&encodedData);
536 int dataSize = 0, eventSize = 0;
539 MSG_MESSAGE_INFO_S msgInfo;
540 MSG_SENDINGOPT_INFO_S sendOptInfo;
542 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
543 memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
545 err = MsgStoGetMessage(*msgId, &msgInfo, &sendOptInfo);
547 if (err == MSG_SUCCESS)
549 MSG_DEBUG("Command Handle Success : MsgStoGetMessage()");
551 // Encoding Message Info Data
552 dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData);
556 MSG_DEBUG("Command Handle Fail : MsgStoGetMessage()");
559 // MsgSoundPlayStop();
562 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG, err, (void**)ppEvent);
568 int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
570 MSG_ERROR_T err = MSG_SUCCESS;
573 MSG_FOLDER_ID_T folderId;
574 MSG_SORT_RULE_S sortRule;
576 memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_FOLDER_ID_T));
577 memcpy(&sortRule, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), sizeof(MSG_SORT_RULE_S));
579 char* encodedData = NULL;
580 AutoPtr<char> buf(&encodedData);
582 int dataSize = 0, eventSize = 0;
584 // Get Message Common Info
585 MSG_LIST_S folderViewList;
587 err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList);
589 if (err == MSG_SUCCESS)
591 MSG_DEBUG("Command Handle Success : MsgStoGetFolderViewList()");
593 // Encoding Folder View List Data
594 dataSize = MsgEncodeFolderViewList(&folderViewList, &encodedData);
596 MSG_DEBUG("dataSize [%d]", dataSize);
598 if (folderViewList.msgInfo != NULL)
600 delete [] folderViewList.msgInfo;
601 folderViewList.msgInfo = NULL;
606 MSG_DEBUG("Command Handle Fail : MsgStoGetFolderViewList()");
611 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERVIEWLIST, MSG_SUCCESS, (void**)ppEvent);
617 int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
619 MSG_ERROR_T err = MSG_SUCCESS;
624 MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
627 err = MsgStoAddFolder(pFolderInfo);
629 if (err == MSG_SUCCESS)
631 MSG_DEBUG("Command Handle Success : MsgStoAddFolder()");
635 MSG_DEBUG("Command Handle Fail : MsgStoAddFolder()");
639 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_FOLDER, err, (void**)ppEvent);
645 int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
647 MSG_ERROR_T err = MSG_SUCCESS;
652 MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
655 err = MsgStoUpdateFolder(pFolderInfo);
657 if (err == MSG_SUCCESS)
659 MSG_DEBUG("Command Handle Success : MsgStoUpdateFolder()");
663 MSG_DEBUG("Command Handle Fail : MsgStoUpdateFolder()");
667 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_FOLDER, err, (void**)ppEvent);
673 int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
675 MSG_ERROR_T err = MSG_SUCCESS;
680 MSG_FOLDER_ID_T* pFolderInfo = (MSG_FOLDER_ID_T*)pCmd->cmdData;
683 err = MsgStoDeleteFolder(*pFolderInfo);
685 if (err == MSG_SUCCESS)
687 MSG_DEBUG("Command Handle Success : MsgStoDeleteFolder()");
691 MSG_DEBUG("Command Handle Fail : MsgStoDeleteFolder()");
695 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_FOLDER, err, (void**)ppEvent);
701 int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
703 MSG_ERROR_T err = MSG_SUCCESS;
705 char* encodedData = NULL;
706 AutoPtr<char> buf(&encodedData);
708 int dataSize = 0, eventSize = 0;
711 MSG_FOLDER_LIST_S folderList;
713 err = MsgStoGetFolderList(&folderList);
715 if (err == MSG_SUCCESS)
717 MSG_DEBUG("Command Handle Success : MsgStoGetFolderList()");
719 // Encoding Folder List Data
720 dataSize = MsgEncodeFolderList(&folderList, &encodedData);
722 delete [] folderList.folderInfo;
726 MSG_DEBUG("Command Handle Fail : MsgStoGetFolderList()");
730 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERLIST, err, (void**)ppEvent);
736 int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent)
738 MSG_ERROR_T err = MSG_SUCCESS;
746 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INIT_SIM_BY_SAT, err, (void**)ppEvent);
752 int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
754 MSG_ERROR_T err = MSG_SUCCESS;
756 char* encodedData = NULL;
757 AutoPtr<char> buf(&encodedData);
760 int dataSize = 0, eventSize = 0;
763 MSG_MESSAGE_ID_T msgId;
765 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
768 MSG_MESSAGE_TYPE_S msgType;
770 err = MsgStoGetMsgType(msgId, &msgType);
772 if (err == MSG_SUCCESS)
774 MSG_DEBUG("Command Handle Success : MsgStoGetMsgType()");
776 // Encoding Storage List Data
777 dataSize = MsgEncodeMsgType(&msgType, &encodedData);
782 MSG_DEBUG("Command Handle Fail : MsgStoGetMsgType()");
786 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG_TYPE, err, (void**)ppEvent);
792 int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
794 MSG_ERROR_T err = MSG_SUCCESS;
796 MSG_SORT_RULE_S sortRule = {0};
798 memcpy(&sortRule, pCmd->cmdData, sizeof(MSG_SORT_RULE_S));
800 char* encodedData = NULL;
801 AutoPtr<char> buf(&encodedData);
803 int dataSize = 0, eventSize = 0;
805 // Get Thread View List
806 MSG_THREAD_VIEW_LIST_S msgThreadViewList;
808 err = MsgStoGetThreadViewList(&sortRule, &msgThreadViewList);
810 if (err == MSG_SUCCESS)
812 MSG_DEBUG("Command Handle Success : MsgStoGetThreadViewList()");
814 // Encoding Folder View List Data
815 dataSize = MsgEncodeThreadViewList(&msgThreadViewList, &encodedData);
817 MSG_DEBUG("dataSize [%d]", dataSize);
819 if (msgThreadViewList.msgThreadInfo != NULL)
821 delete [] msgThreadViewList.msgThreadInfo;
822 msgThreadViewList.msgThreadInfo = NULL;
827 MSG_DEBUG("Command Handle Fail : MsgStoGetThreadViewList()");
832 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREADVIEWLIST, err, (void**)ppEvent);
838 int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
840 MSG_ERROR_T err = MSG_SUCCESS;
842 MSG_THREAD_ID_T threadId;
844 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
846 char* encodedData = NULL;
847 AutoPtr<char> buf(&encodedData);
849 int dataSize = 0, eventSize = 0;
851 MSG_LIST_S convViewList;
853 err = MsgStoGetConversationViewList(threadId, &convViewList);
855 if (err == MSG_SUCCESS)
857 MSG_DEBUG("Command Handle Success : MsgStoGetConversationViewList()");
859 // Encoding Folder View List Data
860 dataSize = MsgEncodeConversationViewList(&convViewList, &encodedData);
862 MSG_DEBUG("dataSize [%d]", dataSize);
864 if (convViewList.msgInfo != NULL)
866 delete [] convViewList.msgInfo;
867 convViewList.msgInfo = NULL;
872 MSG_DEBUG("Command Handle Fail : MsgStoGetConversationViewList()");
876 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONVERSATIONVIEWLIST, err, (void**)ppEvent);
882 int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
884 MSG_ERROR_T err = MSG_SUCCESS;
886 MSG_THREAD_ID_T threadId;
887 bool isSyncMLMsg = false;
889 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
893 isSyncMLMsg = MsgStoCheckSyncMLMsgInThread(threadId);
895 MSG_MSGID_LIST_S msgIdList;
896 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
898 err = MsgStoDeleteThreadMessageList(threadId, &msgIdList);
900 if (err == MSG_SUCCESS) {
901 MSG_DEBUG("Command Handle Success : MsgStoDeleteThreadMessageList()");
903 if(isSyncMLMsg == true) {
904 // broadcast to listener threads, here
905 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, -1);
908 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
909 if(msgIdList.msgIdList != NULL)
910 delete [] (char*)msgIdList.msgIdList;
914 MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()");
918 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_THREADMESSAGELIST, err, (void**)ppEvent);
924 int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent)
926 MSG_ERROR_T err = MSG_SUCCESS;
929 MSG_THREAD_LIST_INDEX_S addrInfo;
931 memcpy(&addrInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_LIST_INDEX_S));
933 char* encodedData = NULL;
934 AutoPtr<char> buf(&encodedData);
936 int dataSize = 0, eventSize = 0;
938 // Get Message Common Info
939 MSG_THREAD_COUNT_INFO_S threadCountInfo = {0};
941 err = MsgStoCountMsgByContact(&addrInfo, &threadCountInfo);
943 if (err == MSG_SUCCESS)
945 MSG_DEBUG("Command Handle Success : MsgStoCountMsgByContact()");
947 // Encoding Folder View List Data
948 dataSize = MsgEncodeMsgGetContactCount(&threadCountInfo, &encodedData);
950 MSG_DEBUG("dataSize [%d]", dataSize);
954 MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByContact()");
958 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONTACT_COUNT, err, (void**)ppEvent);
964 int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent)
966 MSG_ERROR_T err = MSG_SUCCESS;
969 MSG_QUICKPANEL_TYPE_T* type = (MSG_QUICKPANEL_TYPE_T*)pCmd->cmdData;
971 char* encodedData = NULL;
972 AutoPtr<char> buf(&encodedData);
974 int dataSize = 0, eventSize = 0;
977 MSG_MESSAGE_INFO_S msgInfo;
979 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
981 err = MsgStoGetQuickPanelData(*type, &msgInfo);
983 if (err == MSG_SUCCESS)
985 MSG_DEBUG("Command Handle Success : MsgStoGetQuickPanelData()");
987 // Encoding Message Info Data
988 dataSize = MsgEncodeMsgInfo(&msgInfo, &encodedData);
992 MSG_DEBUG("Command Handle Fail : MsgStoGetQuickPanelData()");
996 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_QUICKPANEL_DATA, err, (void**)ppEvent);
1002 int MsgResetDatabaseHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1004 MSG_ERROR_T err = MSG_SUCCESS;
1009 err = MsgStoResetDatabase();
1011 if (err == MSG_SUCCESS)
1012 MSG_DEBUG("Command Handle Success : MsgStoResetDatabase()");
1014 MSG_DEBUG("Command Handle Fail : MsgStoResetDatabase()");
1017 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_RESET_DB, err, (void**)ppEvent);
1023 int MsgGetMemSizeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1025 MSG_ERROR_T err = MSG_SUCCESS;
1027 char* encodedData = NULL;
1028 AutoPtr<char> buf(&encodedData);
1030 int dataSize = 0, eventSize = 0;
1033 unsigned int memsize = 0;
1035 memsize = MsgDu(MSG_DATA_ROOT_PATH);
1037 dataSize = MsgEncodeMemSize(&memsize, &encodedData);
1040 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MEMSIZE, err, (void**)ppEvent);
1046 int MsgGetReportStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1048 MSG_ERROR_T err = MSG_SUCCESS;
1051 MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
1053 char* encodedData = NULL;
1054 AutoPtr<char> buf(&encodedData);
1056 int dataSize = 0, eventSize = 0;
1058 MSG_REPORT_STATUS_INFO_S reportStatus;
1060 memset(&reportStatus, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S));
1062 err = MsgStoGetReportStatus(*msgId, &reportStatus);
1064 if (err == MSG_SUCCESS)
1066 MSG_DEBUG("Command Handle Success : MsgGetReportStatusHandler()");
1068 // Encoding Report Status Data
1069 dataSize = MsgEncodeReportStatus(&reportStatus, &encodedData);
1073 MSG_DEBUG("Command Handle Fail : MsgGetReportStatusHandler()");
1077 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_REPORT_STATUS, err, (void**)ppEvent);