2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
20 #include "MsgUtilFile.h"
21 #include "MsgException.h"
22 #include "MsgCppTypes.h"
23 //#include "MsgSoundPlayer.h"
24 #include "MsgUtilFunction.h"
25 #include "MsgStorageHandler.h"
26 #include "MsgPluginManager.h"
27 #include "MsgTransManager.h"
28 #include "MsgCmdHandler.h"
29 #include "MsgNotificationWrapper.h"
33 /*==================================================================================================
34 FUNCTION IMPLEMENTATION
35 ==================================================================================================*/
40 static gboolean __refresh_noti(void *data)
47 MSG_DEBUG("## Refresh notification ##");
48 if (MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, false) != MSG_SUCCESS) {
49 MSG_DEBUG("MsgRefreshNoti is failed");
60 int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
62 msg_error_t err = MSG_SUCCESS;
64 char* encodedData = NULL;
65 AutoPtr<char> buf(&encodedData);
67 int dataSize = 0, eventSize = 0;
69 MSG_MESSAGE_INFO_S msgInfo;
70 MSG_SENDINGOPT_INFO_S sendOptInfo;
71 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
72 memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
74 msgInfo.addressList = NULL;
75 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
77 MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo);
79 if(msgInfo.threadId) // threadId is not 0 : message restore from S-Cloud
81 err = MsgStoRestoreMessage(&msgInfo, &sendOptInfo);
83 if (err == MSG_SUCCESS) {
84 MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()");
86 // Encoding Message ID
87 dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData);
89 MSG_DEBUG("Command Handle Fail : MsgStoRestoreMessage()");
96 err = MsgStoAddMessage(&msgInfo, &sendOptInfo);
98 if (err == MSG_SUCCESS) {
99 MSG_DEBUG("Command Handle Success : MsgStoAddMessage()");
100 // Encoding Message ID
101 dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData);
103 MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()");
108 msg_id_list_s msgIdList;
109 msg_message_id_t msgIds[1];
110 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
112 msgIdList.nCount = 1;
113 msgIds[0] = msgInfo.msgId;
114 msgIdList.msgIdList = msgIds;
116 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
118 // Update unread message status
119 if (msgInfo.folderId == MSG_INBOX_ID && msgInfo.bRead == false) {
122 g_timeout_add(300, __refresh_noti, NULL);
126 // Delete Temp File for Message Data
127 if (msgInfo.bTextSms == false)
128 MsgDeleteFile(msgInfo.msgData); //ipc
131 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_MSG, err, (void**)ppEvent);
137 int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
139 msg_error_t err = MSG_SUCCESS;
141 char* encodedData = NULL;
142 AutoPtr<char> buf(&encodedData);
144 int dataSize = 0, eventSize = 0;
146 int extId = 0, pinCode = 0;
148 MSG_MESSAGE_INFO_S msgInfo;
149 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
151 msgInfo.addressList = NULL;
152 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
154 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
155 memcpy(&pinCode, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(int));
157 MsgDecodeMsgInfo((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int), &msgInfo);
161 err = MsgStoAddSyncMLMessage(&msgInfo, extId, pinCode);
163 if (err == MSG_SUCCESS)
165 MSG_DEBUG("Command Handle Success : MsgStoAddSyncMLMessage()");
167 // Encoding Message ID
168 dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData);
170 // broadcast to listener threads, here
171 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
173 msg_id_list_s msgIdList;
174 msg_message_id_t msgIds[1];
175 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
177 msgIdList.nCount = 1;
178 msgIds[0] = msgInfo.msgId;
179 msgIdList.msgIdList = msgIds;
181 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
185 MSG_DEBUG("Command Handle Fail : MsgStoAddSyncMLMessage()");
189 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent);
195 int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
197 msg_error_t err = MSG_SUCCESS;
201 MSG_MESSAGE_INFO_S msgInfo;
202 MSG_SENDINGOPT_INFO_S sendOptInfo;
203 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
204 memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
206 msgInfo.addressList = NULL;
207 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
209 MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo);
212 err = MsgStoUpdateMessage(&msgInfo, &sendOptInfo);
214 if (err == MSG_SUCCESS)
215 MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()");
217 MSG_DEBUG("Command Handle Fail : MsgStoUpdateMessage()");
219 // Delete Temp File for Message Data
220 if (msgInfo.bTextSms == false)
221 MsgDeleteFile(msgInfo.msgData); //ipc
224 msg_id_list_s msgIdList;
225 msg_message_id_t msgIds[1];
226 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
228 msgIdList.nCount = 1;
229 msgIds[0] = msgInfo.msgId;
230 msgIdList.msgIdList = msgIds;
232 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
235 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_MSG, err, (void**)ppEvent);
241 int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
243 msg_error_t err = MSG_SUCCESS;
247 msg_message_id_t msgId;
250 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
251 memcpy(&readStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(bool));
253 // Update Read Status
254 err = MsgStoUpdateReadStatus(msgId, readStatus);
256 MSG_DEBUG("message id = [%d], readStatus = [%d]", msgId, readStatus);
258 if (err == MSG_SUCCESS)
260 MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()");
264 MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()");
268 msg_id_list_s msgIdList;
269 msg_message_id_t msgIds[1];
270 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
272 msgIdList.nCount = 1;
274 msgIdList.msgIdList = msgIds;
276 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
279 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_READ, err, (void**)ppEvent);
285 int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
287 msg_error_t err = MSG_SUCCESS;
291 msg_thread_id_t threadId;
294 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t));
296 MsgStoGetThreadUnreadCnt(threadId, &unReadCnt);
298 MSG_DEBUG("unReadCnt [%d]", unReadCnt);
302 msg_id_list_s msgIdList;
303 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
305 err = MsgStoUpdateThreadReadStatus(threadId, &msgIdList);
307 if (err == MSG_SUCCESS) {
308 MSG_DEBUG("Command Handle Success : MsgStoUpdateThreadReadStatus()");
309 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
311 MSG_DEBUG("Command Handle Fail : MsgStoUpdateThreadReadStatus()");
314 if(msgIdList.msgIdList != NULL)
315 delete [] (char*)msgIdList.msgIdList;
318 // delete report notification
319 if (err == MSG_SUCCESS) {
320 MsgDbHandler *dbHandle = getDbHandle();
321 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
322 char sqlQuery[MAX_QUERY_LEN+1];
324 memset(tempAddr, 0x00, sizeof(tempAddr));
325 memset(sqlQuery, 0x00, sizeof(sqlQuery));
326 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_VAL FROM %s A, %s B WHERE A.CONV_ID = B.CONV_ID AND A.CONV_ID = %d;"
327 , MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, threadId);
329 err = dbHandle->prepareQuery(sqlQuery);
331 if (err == MSG_SUCCESS) {
332 err = dbHandle->stepQuery();
334 if (err == MSG_ERR_DB_ROW) {
335 snprintf(tempAddr, sizeof(tempAddr), "%s", dbHandle->columnText(0));
336 MSG_SEC_DEBUG("Updated address = %s", tempAddr);
337 MsgDeleteReportNotification(tempAddr);
342 dbHandle->finalizeQuery();
346 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_THREAD_READ, err, (void**)ppEvent);
353 int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
355 msg_error_t err = MSG_SUCCESS;
359 msg_message_id_t msgId;
360 bool protectedStatus;
362 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
363 memcpy(&protectedStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(bool));
365 // Update Protected Status
366 err = MsgStoUpdateProtectedStatus(msgId, protectedStatus);
368 if (err == MSG_SUCCESS)
370 MSG_DEBUG("Command Handle Success : MsgStoUpdateProtectedStatus()");
374 MSG_DEBUG("Command Handle Fail : MsgStoUpdateProtectedStatus()");
378 msg_id_list_s msgIdList;
379 msg_message_id_t msgIds[1];
380 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
382 msgIdList.nCount = 1;
384 msgIdList.msgIdList = msgIds;
386 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
389 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PROTECTED, err, (void**)ppEvent);
395 int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
397 msg_error_t err = MSG_SUCCESS;
403 msg_message_id_t* msgId = (msg_message_id_t*)pCmd->cmdData;
405 MsgStoGetSyncMLExtId(*msgId, &extId);
408 err = MsgStoDeleteMessage(*msgId, true);
410 if (err == MSG_SUCCESS) {
411 MSG_DEBUG("Command Handle Success : MsgStoDeleteMessage()");
414 // broadcast to listener threads, here
415 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, extId);
418 msg_id_list_s msgIdList;
419 msg_message_id_t msgIds[1];
420 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
422 msgIdList.nCount = 1;
424 msgIdList.msgIdList = msgIds;
426 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
428 MSG_DEBUG("Command Handle Fail : MsgStoDeleteMessage()");
432 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_MSG, err, (void**)ppEvent);
438 int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
440 msg_error_t err = MSG_SUCCESS;
444 msg_folder_id_t* folderId = (msg_folder_id_t*)pCmd->cmdData;
447 memcpy(&bOnlyDB, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_folder_id_t)), sizeof(bool));
450 msg_id_list_s msgIdList;
451 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
454 err = MsgStoDeleteAllMessageInFolder(*folderId, bOnlyDB, &msgIdList);
456 if (err == MSG_SUCCESS) {
457 MSG_DEBUG("Command Handle Success : MsgStoDeleteAllMessageInFolder()");
458 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
459 if(msgIdList.msgIdList != NULL)
460 delete [] (char*)msgIdList.msgIdList;
462 MSG_DEBUG("Command Handle Fail : MsgStoDeleteAllMessageInFolder()");
466 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELALL_MSGINFOLDER, err, (void**)ppEvent);
473 int MsgDeleteMessageByListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
475 msg_error_t err = MSG_SUCCESS;
479 msg_id_list_s msgIdList;
480 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
482 msgIdList.nCount = *((int *)pCmd->cmdData);
484 MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount);
486 msg_message_id_t msgIds[msgIdList.nCount];
487 memset(msgIds, 0x00, sizeof(msgIds));
489 msgIdList.msgIdList = msgIds;
491 for (int i=0; i<msgIdList.nCount; i++) {
492 msgIds[i] = *(msg_message_id_t *)(((char*)pCmd->cmdData) + (sizeof(int)*(i+1)));
496 err = MsgStoDeleteMessageByList(&msgIdList);
498 if (err == MSG_SUCCESS) {
499 MSG_DEBUG("Command Handle Success : MsgStoDeleteMessageByList()");
500 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
502 MSG_DEBUG("Command Handle Fail : MsgStoDeleteMessageByList()");
506 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_MESSAGE_BY_LIST, err, (void**)ppEvent);
512 int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
514 msg_error_t err = MSG_SUCCESS;
518 msg_message_id_t msgId;
519 msg_folder_id_t folderId;
521 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
522 memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(msg_folder_id_t));
525 err = MsgStoMoveMessageToFolder(msgId, folderId);
527 if (err == MSG_SUCCESS) {
528 MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToFolder()");
530 msg_id_list_s msgIdList;
531 msg_message_id_t msgIds[1];
532 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
534 msgIdList.nCount = 1;
536 msgIdList.msgIdList = msgIds;
538 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
540 MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToFolder()");
544 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOFOLDER, err, (void**)ppEvent);
550 int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
552 msg_error_t err = MSG_SUCCESS;
556 msg_message_id_t msgId;
557 msg_storage_id_t storageId;
559 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
560 memcpy(&storageId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(msg_storage_id_t));
563 err = MsgStoMoveMessageToStorage(msgId, storageId);
565 if (err == MSG_SUCCESS)
567 MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToStorage()");
571 MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToStorage()");
575 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOSTORAGE, err, (void**)ppEvent);
581 int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
583 msg_error_t err = MSG_SUCCESS;
585 char* encodedData = NULL;
586 AutoPtr<char> buf(&encodedData);
588 int dataSize = 0, eventSize = 0;
591 msg_folder_id_t* folderId = (msg_folder_id_t*)pCmd->cmdData;
594 MSG_COUNT_INFO_S countInfo;
596 err = MsgStoCountMessage(*folderId, &countInfo);
598 if (err == MSG_SUCCESS)
600 MSG_DEBUG("Command Handle Success : MsgStoCountMessage()");
602 // Encoding Messaging Count Data
603 dataSize = MsgEncodeCountInfo(&countInfo, &encodedData);
607 MSG_DEBUG("Command Handle Fail : MsgStoCountMessage()");
611 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_MSG, err, (void**)ppEvent);
617 int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
619 msg_error_t err = MSG_SUCCESS;
621 char* encodedData = NULL;
622 AutoPtr<char> buf(&encodedData);
624 int dataSize = 0, eventSize = 0;
627 MSG_MESSAGE_TYPE_S* pMsgType = (MSG_MESSAGE_TYPE_S*)pCmd->cmdData;
632 err = MsgStoCountMsgByType(pMsgType, &nMsgCnt);
634 if (err == MSG_SUCCESS)
636 MSG_DEBUG("Command Handle Success : MsgStoCountMsgByType()");
638 // Encoding Messaging Count Data
639 dataSize = MsgEncodeCountByMsgType(nMsgCnt, &encodedData);
643 MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByType()");
647 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_BY_MSGTYPE, err, (void**)ppEvent);
653 int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
655 msg_error_t err = MSG_SUCCESS;
658 msg_message_id_t* msgId = (msg_message_id_t*)pCmd->cmdData;
660 char* encodedData = NULL;
661 AutoPtr<char> buf(&encodedData);
663 int dataSize = 0, eventSize = 0;
666 MSG_MESSAGE_INFO_S msgInfo;
667 MSG_SENDINGOPT_INFO_S sendOptInfo;
669 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
670 memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
672 msgInfo.addressList = NULL;
673 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
675 err = MsgStoGetMessage(*msgId, &msgInfo, &sendOptInfo);
677 if (err == MSG_SUCCESS)
679 MSG_DEBUG("Command Handle Success : MsgStoGetMessage()");
681 // Encoding Message Info Data
682 dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData);
686 MSG_DEBUG("Command Handle Fail : MsgStoGetMessage()");
689 // MsgSoundPlayStop();
692 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG, err, (void**)ppEvent);
698 int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
701 msg_folder_id_t folderId;
702 MSG_SORT_RULE_S sortRule;
704 memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_folder_id_t));
705 memcpy(&sortRule, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_folder_id_t)), sizeof(MSG_SORT_RULE_S));
707 char* encodedData = NULL;
708 AutoPtr<char> buf(&encodedData);
710 int dataSize = 0, eventSize = 0;
713 // Get Message Common Info
714 msg_struct_list_s folderViewList;
716 // err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList);
718 if (err == MSG_SUCCESS)
720 MSG_DEBUG("Command Handle Success : MsgStoGetFolderViewList()");
722 // Encoding Folder View List Data
723 // dataSize = MsgEncodeFolderViewList(&folderViewList, &encodedData);
725 MSG_DEBUG("dataSize [%d]", dataSize);
727 if (folderViewList.msg_struct_info) {
728 msg_struct_s *msg_struct;
729 for (int i = 0; i < folderViewList.nCount; i++) {
730 msg_struct = (msg_struct_s *)folderViewList.msg_struct_info[i];
731 delete (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
734 g_free(folderViewList.msg_struct_info);
739 MSG_DEBUG("Command Handle Fail : MsgStoGetFolderViewList()");
744 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERVIEWLIST, MSG_SUCCESS, (void**)ppEvent);
750 int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
752 msg_error_t err = MSG_SUCCESS;
757 MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
760 err = MsgStoAddFolder(pFolderInfo);
762 if (err == MSG_SUCCESS)
764 MSG_DEBUG("Command Handle Success : MsgStoAddFolder()");
768 MSG_DEBUG("Command Handle Fail : MsgStoAddFolder()");
772 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_FOLDER, err, (void**)ppEvent);
778 int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
780 msg_error_t err = MSG_SUCCESS;
785 MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
788 err = MsgStoUpdateFolder(pFolderInfo);
790 if (err == MSG_SUCCESS)
792 MSG_DEBUG("Command Handle Success : MsgStoUpdateFolder()");
796 MSG_DEBUG("Command Handle Fail : MsgStoUpdateFolder()");
800 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_FOLDER, err, (void**)ppEvent);
806 int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
808 msg_error_t err = MSG_SUCCESS;
813 msg_folder_id_t* pFolderInfo = (msg_folder_id_t*)pCmd->cmdData;
816 err = MsgStoDeleteFolder(*pFolderInfo);
818 if (err == MSG_SUCCESS)
820 MSG_DEBUG("Command Handle Success : MsgStoDeleteFolder()");
824 MSG_DEBUG("Command Handle Fail : MsgStoDeleteFolder()");
828 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_FOLDER, err, (void**)ppEvent);
834 int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
836 msg_error_t err = MSG_SUCCESS;
838 char* encodedData = NULL;
839 AutoPtr<char> buf(&encodedData);
841 int dataSize = 0, eventSize = 0;
844 msg_struct_list_s folderList;
846 err = MsgStoGetFolderList(&folderList);
848 if (err == MSG_SUCCESS)
850 MSG_DEBUG("Command Handle Success : MsgStoGetFolderList()");
852 // Encoding Folder List Data
853 dataSize = MsgEncodeFolderList(&folderList, &encodedData);
855 if (folderList.msg_struct_info) {
856 msg_struct_s *msg_struct;
857 for (int i = 0; i < folderList.nCount; i++) {
858 msg_struct = (msg_struct_s *)folderList.msg_struct_info[i];
859 delete (MSG_FOLDER_INFO_S *)msg_struct->data;
862 g_free(folderList.msg_struct_info);
867 MSG_DEBUG("Command Handle Fail : MsgStoGetFolderList()");
871 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERLIST, err, (void**)ppEvent);
877 int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent)
879 msg_error_t err = MSG_SUCCESS;
887 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INIT_SIM_BY_SAT, err, (void**)ppEvent);
893 int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
895 msg_error_t err = MSG_SUCCESS;
897 char* encodedData = NULL;
898 AutoPtr<char> buf(&encodedData);
901 int dataSize = 0, eventSize = 0;
904 msg_message_id_t msgId;
906 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
909 MSG_MESSAGE_TYPE_S msgType;
911 err = MsgStoGetMsgType(msgId, &msgType);
913 if (err == MSG_SUCCESS)
915 MSG_DEBUG("Command Handle Success : MsgStoGetMsgType()");
917 // Encoding Storage List Data
918 dataSize = MsgEncodeMsgType(&msgType, &encodedData);
923 MSG_DEBUG("Command Handle Fail : MsgStoGetMsgType()");
927 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG_TYPE, err, (void**)ppEvent);
933 int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
936 msg_error_t err = MSG_SUCCESS;
938 MSG_SORT_RULE_S sortRule = {0};
940 memcpy(&sortRule, pCmd->cmdData, sizeof(MSG_SORT_RULE_S));
942 char* encodedData = NULL;
943 AutoPtr<char> buf(&encodedData);
945 int dataSize = 0, eventSize = 0;
947 // Get Thread View List
948 msg_struct_list_s msgThreadViewList;
950 //err = MsgStoGetThreadViewList(&sortRule, &msgThreadViewList);
952 if (err == MSG_SUCCESS)
954 MSG_DEBUG("Command Handle Success : MsgStoGetThreadViewList()");
956 // Encoding Folder View List Data
957 dataSize = MsgEncodeThreadViewList(&msgThreadViewList, &encodedData);
959 MSG_DEBUG("dataSize [%d]", dataSize);
961 if (msgThreadViewList.msg_struct_info) {
962 msg_struct_s *msg_struct;
963 for (int i = 0; i < folderList.nCount; i++) {
964 msg_struct = (msg_struct_s *)msgThreadViewList.msg_struct_info[i];
965 delete (MSG_THREAD_VIEW_S *)msg_struct->data;
968 g_free(msgThreadViewList.msg_struct_info);
973 MSG_DEBUG("Command Handle Fail : MsgStoGetThreadViewList()");
978 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREADVIEWLIST, err, (void**)ppEvent);
984 int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
986 msg_error_t err = MSG_SUCCESS;
988 msg_thread_id_t threadId;
990 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t));
992 char* encodedData = NULL;
993 AutoPtr<char> buf(&encodedData);
995 int dataSize = 0, eventSize = 0;
997 msg_struct_list_s convViewList;
999 //err = MsgStoGetConversationViewList(threadId, &convViewList);
1001 if (err == MSG_SUCCESS)
1003 MSG_DEBUG("Command Handle Success : MsgStoGetConversationViewList()");
1005 // Encoding Folder View List Data
1006 dataSize = MsgEncodeConversationViewList(&convViewList, &encodedData);
1008 MSG_DEBUG("dataSize [%d]", dataSize);
1010 if (convViewList.msg_struct_info) {
1011 msg_struct_s *msg_struct;
1012 for (int i = 0; i < convViewList.nCount; i++) {
1013 msg_struct = (msg_struct_s *)convViewList.msg_struct_info[i];
1014 delete (MSG_CONVERSATION_VIEW_S *)msg_struct->data;
1017 g_free(convViewList.msg_struct_info);
1022 MSG_DEBUG("Command Handle Fail : MsgStoGetConversationViewList()");
1026 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONVERSATIONVIEWLIST, err, (void**)ppEvent);
1032 int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1034 msg_error_t err = MSG_SUCCESS;
1036 msg_thread_id_t threadId;
1037 bool bIncludeProtect = false;
1038 bool isSyncMLMsg = false;
1040 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t));
1041 memcpy(&bIncludeProtect, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_thread_id_t)), sizeof(bool));
1045 isSyncMLMsg = MsgStoCheckSyncMLMsgInThread(threadId);
1047 msg_id_list_s msgIdList;
1048 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
1050 err = MsgStoDeleteThreadMessageList(threadId, bIncludeProtect, &msgIdList);
1052 if (err == MSG_SUCCESS) {
1053 MSG_DEBUG("Command Handle Success : MsgStoDeleteThreadMessageList()");
1055 if(isSyncMLMsg == true) {
1056 // broadcast to listener threads, here
1057 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, -1);
1060 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
1061 if(msgIdList.msgIdList != NULL)
1062 delete [] (char*)msgIdList.msgIdList;
1066 MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()");
1067 if(msgIdList.msgIdList != NULL)
1068 delete [] (char*)msgIdList.msgIdList;
1072 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_THREADMESSAGELIST, err, (void**)ppEvent);
1078 int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1080 msg_error_t err = MSG_SUCCESS;
1083 MSG_THREAD_LIST_INDEX_S addrInfo;
1085 memcpy(&addrInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_LIST_INDEX_S));
1087 char* encodedData = NULL;
1088 AutoPtr<char> buf(&encodedData);
1090 int dataSize = 0, eventSize = 0;
1092 // Get Message Common Info
1093 MSG_THREAD_COUNT_INFO_S threadCountInfo = {0};
1095 err = MsgStoCountMsgByContact(&addrInfo, &threadCountInfo);
1097 if (err == MSG_SUCCESS)
1099 MSG_DEBUG("Command Handle Success : MsgStoCountMsgByContact()");
1101 // Encoding Folder View List Data
1102 dataSize = MsgEncodeMsgGetContactCount(&threadCountInfo, &encodedData);
1104 MSG_DEBUG("dataSize [%d]", dataSize);
1108 MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByContact()");
1112 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONTACT_COUNT, err, (void**)ppEvent);
1118 int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1120 msg_error_t err = MSG_SUCCESS;
1123 msg_quickpanel_type_t* type = (msg_quickpanel_type_t*)pCmd->cmdData;
1125 char* encodedData = NULL;
1126 AutoPtr<char> buf(&encodedData);
1128 int dataSize = 0, eventSize = 0;
1131 MSG_MESSAGE_INFO_S msgInfo;
1132 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
1134 msgInfo.addressList = NULL;
1135 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
1137 err = MsgStoGetQuickPanelData(*type, &msgInfo);
1139 if (err == MSG_SUCCESS)
1141 MSG_DEBUG("Command Handle Success : MsgStoGetQuickPanelData()");
1143 // Encoding Message Info Data
1144 dataSize = MsgEncodeMsgInfo(&msgInfo, &encodedData);
1148 MSG_DEBUG("Command Handle Fail : MsgStoGetQuickPanelData()");
1152 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_QUICKPANEL_DATA, err, (void**)ppEvent);
1158 int MsgResetDatabaseHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1160 msg_error_t err = MSG_SUCCESS;
1165 err = MsgStoResetDatabase();
1167 if (err == MSG_SUCCESS)
1168 MSG_DEBUG("Command Handle Success : MsgStoResetDatabase()");
1170 MSG_DEBUG("Command Handle Fail : MsgStoResetDatabase()");
1173 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_RESET_DB, err, (void**)ppEvent);
1179 int MsgGetMemSizeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1181 msg_error_t err = MSG_SUCCESS;
1183 char* encodedData = NULL;
1184 AutoPtr<char> buf(&encodedData);
1186 int dataSize = 0, eventSize = 0;
1189 unsigned int memsize = 0;
1191 memsize = MsgDu(MSG_DATA_ROOT_PATH);
1193 dataSize = MsgEncodeMemSize(&memsize, &encodedData);
1196 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MEMSIZE, err, (void**)ppEvent);
1202 int MsgBackupMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1204 msg_error_t err = MSG_SUCCESS;
1207 char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
1208 msg_message_backup_type_t type;
1210 memcpy(&type, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_backup_type_t));
1211 memcpy(&path, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_backup_type_t)), sizeof(path));
1213 MSG_DEBUG("type = %d, path = %s", type, path);
1215 err = MsgStoBackupMessage(type, path);
1216 if (err == MSG_SUCCESS)
1217 MSG_DEBUG("Command Handle Success : MsgBackupMessageHandler()");
1219 MSG_DEBUG("Command Handle Fail : MsgBackupMessageHandler()");
1222 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_BACKUP_MESSAGE, err, (void**)ppEvent);
1228 int MsgRestoreMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1230 msg_error_t err = MSG_SUCCESS;
1233 msg_id_list_s *msgIdList = NULL;
1234 char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
1235 memcpy(&path, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(path));
1236 MSG_DEBUG("path = %s", path);
1239 err = MsgStoRestoreMessage(path, &msgIdList);
1241 if (err == MSG_SUCCESS) {
1242 MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()");
1245 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, msgIdList);
1247 if (msgIdList->msgIdList)
1248 free(msgIdList->msgIdList);
1253 MSG_DEBUG("Not Exist msg id list to restore");
1257 MSG_DEBUG("Command Handle Fail : MsgStoRestoreMessage()");
1260 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_RESTORE_MESSAGE, err, (void**)ppEvent);
1266 int MsgGetReportStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1268 msg_error_t err = MSG_SUCCESS;
1271 msg_message_id_t* msgId = (msg_message_id_t*)pCmd->cmdData;
1272 MSG_MESSAGE_TYPE_S msgType = {0,};
1274 char* encodedData = NULL;
1275 AutoPtr<char> buf(&encodedData);
1277 int dataSize = 0, eventSize = 0;
1279 MSG_REPORT_STATUS_INFO_S *reportStatus = NULL;
1280 int report_count = 0;
1282 if (MsgStoGetMsgType(*msgId, &msgType) != MSG_SUCCESS)
1283 MSG_DEBUG("MsgStoGetMsgType is failed");
1285 if (msgType.mainType == MSG_SMS_TYPE) {
1286 err = MsgStoGetSmsReportStatus(*msgId, &report_count, &reportStatus);
1287 } else if (msgType.mainType == MSG_MMS_TYPE) {
1288 err = MsgStoGetMmsReportStatus(*msgId, &report_count, &reportStatus);
1290 MSG_DEBUG("Message Type is unknown!");
1291 err = MSG_ERR_INVALID_MSG_TYPE;
1294 if (err == MSG_SUCCESS)
1296 MSG_DEBUG("Command Handle Success : MsgGetReportStatusHandler()");
1298 // Encoding Report Status Data
1299 dataSize = MsgEncodeReportStatus(reportStatus, report_count, &encodedData);
1303 MSG_DEBUG("Command Handle Fail : MsgGetReportStatusHandler()");
1307 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_REPORT_STATUS, err, (void**)ppEvent);
1313 int MsgGetThreadIdByAddressHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1315 msg_error_t err = MSG_SUCCESS;
1317 MSG_MESSAGE_INFO_S msgInfo;
1318 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
1320 msgInfo.addressList = NULL;
1321 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
1323 int *addrCnt = (int *)pCmd->cmdData;
1324 MSG_DEBUG("*addrCnt [%d]", *addrCnt);
1326 msgInfo.nAddressCnt = *addrCnt;
1328 msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * msgInfo.nAddressCnt];
1330 for(int i=0; i<msgInfo.nAddressCnt; i++)
1331 memcpy(&msgInfo.addressList[i], (MSG_ADDRESS_INFO_S *)(pCmd->cmdData+sizeof(int)+(sizeof(MSG_ADDRESS_INFO_S)*i)), sizeof(MSG_ADDRESS_INFO_S));
1333 char* encodedData = NULL;
1334 AutoPtr<char> buf(&encodedData);
1336 int dataSize = 0, eventSize = 0;
1338 msg_thread_id_t threadId;
1340 err = MsgStoGetThreadIdByAddress(&msgInfo, &threadId);
1342 if (err == MSG_SUCCESS)
1344 MSG_DEBUG("threadId [%d]", threadId);
1345 MSG_DEBUG("Command Handle Success : MsgGetThreadIdByAddressHandler()");
1347 // Encoding threadId Data
1348 dataSize = MsgEncodeThreadId(&threadId, &encodedData);
1352 MSG_DEBUG("Command Handle Fail : MsgGetThreadIdByAddressHandler()");
1356 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREAD_ID_BY_ADDRESS, err, (void**)ppEvent);
1362 int MsgGetThreadInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1364 msg_error_t err = MSG_SUCCESS;
1366 char* encodedData = NULL;
1367 AutoPtr<char> buf(&encodedData);
1372 msg_thread_id_t threadId;
1374 memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t));
1376 MSG_THREAD_VIEW_S threadInfo;
1377 memset(&threadInfo, 0x00, sizeof(threadInfo));
1379 err = MsgStoGetThreadInfo(threadId, &threadInfo);
1381 if (err == MSG_SUCCESS) {
1382 MSG_DEBUG("Command Handle Success : MsgStoGetThreadInfo()");
1384 // Encoding thread Info Data
1385 dataSize = MsgEncodeThreadInfo(&threadInfo, &encodedData);
1387 MSG_DEBUG("Command Handle Fail : MsgStoGetThreadInfo()");
1391 eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREAD_INFO, err, (void**)ppEvent);
1397 #ifdef MMS_REPORT_OPERATIONS
1398 int MsgCheckReadReportRequestedHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1401 msg_error_t err = MSG_SUCCESS;
1403 char* encodedData = NULL;
1404 AutoPtr<char> buf(&encodedData);
1406 int dataSize = 0, eventSize = 0;
1409 msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
1411 // Check ReadReport Is Requested
1412 bool bReadReportRequested;
1414 bReadReportRequested = MsgStoCheckReadReportRequested(*MsgId);
1415 if (err == MSG_SUCCESS)
1417 MSG_DEBUG("Command Handle Success : MsgStoCheckSendReadReport()");
1419 // Encoding ReadReportIsSent Data
1420 dataSize = MsgEncodeReadReportRequested(bReadReportRequested, &encodedData);
1424 MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
1428 eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_CHECK_READ_REPORT_REQUESTED, err, (void**)ppEvent);
1434 int MsgCheckReadReportIsSentHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1437 msg_error_t err = MSG_SUCCESS;
1439 char* encodedData = NULL;
1440 AutoPtr<char> buf(&encodedData);
1442 int dataSize = 0, eventSize = 0;
1445 msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
1447 // Check ReadReport Is Sent
1448 bool bReadReportIsSent;
1450 MSG_DEBUG("#### MSGID = %d ####", *MsgId);
1452 bReadReportIsSent = MsgStoCheckReadReportIsSent(*MsgId);
1453 MSG_DEBUG("######## 1. bReadStatusIsSent = %d #######", bReadReportIsSent);
1454 if (err == MSG_SUCCESS)
1456 MSG_DEBUG("Command Handle Success : MsgStoCheckReadReportIsSent()");
1458 // Encoding ReadReportIsSent Data
1459 dataSize = MsgEncodeReadReportIsSent(bReadReportIsSent, &encodedData);
1463 MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
1467 eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_CHECK_READ_REPORT_IS_SENT, err, (void**)ppEvent);
1473 int MsgSetReadReportSendStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1476 msg_error_t err = MSG_SUCCESS;
1478 char* encodedData = NULL;
1479 AutoPtr<char> buf(&encodedData);
1481 int dataSize = 0, eventSize = 0;
1484 msg_message_id_t msgId;
1485 int readReportSendStatus;
1487 memcpy(&msgId, (char*)pCmd + sizeof(MSG_CMD_TYPE_T), sizeof(msg_message_id_t));
1488 memcpy(&readReportSendStatus, (char*)pCmd + sizeof(MSG_CMD_TYPE_T) + sizeof(msg_message_id_t), sizeof(int));
1490 // Set Read Report Send Status
1491 err = MsgStoSetReadReportSendStatus(msgId, readReportSendStatus);
1493 if (err == MSG_SUCCESS)
1495 MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()");
1499 MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()");
1503 eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_SET_READ_REPORT_SEND_STATUS, err, (void**)ppEvent);
1509 int MsgGetMmsVersionHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1512 msg_error_t err = MSG_SUCCESS;
1514 char* encodedData = NULL;
1515 AutoPtr<char> buf(&encodedData);
1517 int dataSize = 0, eventSize = 0;
1520 msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
1522 // Check ReadReport Is Sent
1525 MSG_DEBUG("#### MSGID = %d ####", *MsgId);
1527 version = MsgStoGetMmsVersion(*MsgId);
1528 MSG_DEBUG("######## 1. version = %x #######", version);
1529 if (err == MSG_SUCCESS)
1531 MSG_DEBUG("Command Handle Success : MsgStoCheckReadReportIsSent()");
1533 // Encoding ReadReportIsSent Data
1534 dataSize = MsgEncodeMmsVersion(version, &encodedData);
1538 MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
1542 eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_GET_MMS_VERSION, err, (void**)ppEvent);
1548 int MsgGetMmsStatusInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1551 msg_error_t err = MSG_SUCCESS;
1553 char* encodedData = NULL;
1554 AutoPtr<char> buf(&encodedData);
1556 int dataSize = 0, eventSize = 0;
1559 msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
1561 MMS_STATUS_INFO_S mmsStatusInfo;
1563 MSG_DEBUG("#### MSGID = %d ####", *MsgId);
1565 err = MsgStoGetMmsStatusInfo(*MsgId,&mmsStatusInfo);
1566 if (err == MSG_SUCCESS)
1568 MSG_DEBUG("Command Handle Success : MsgGetMmsStatusInfoHandler()");
1570 // Encoding ReadReportIsSent Data
1571 dataSize = MsgEncodeMmsStatusInfo(&mmsStatusInfo, &encodedData);
1575 MSG_DEBUG("Command Handle Fail : MsgGetMmsStatusInfoHandler()");
1579 eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_GET_MMS_STATUS_INFO, err, (void**)ppEvent);
1586 int MsgAddPushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1588 msg_error_t err = MSG_SUCCESS;
1593 MSG_PUSH_EVENT_INFO_S* pPushEvent = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData;
1596 err = MsgStoAddPushEvent(pPushEvent);
1598 if (err == MSG_SUCCESS) {
1599 MSG_DEBUG("Command Handle Success : MsgStoAddPushEvent()");
1601 MSG_DEBUG("Command Handle Fail : MsgStoAddPushEvent()");
1605 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_PUSH_EVENT, err, (void**)ppEvent);
1610 int MsgDeletePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1612 msg_error_t err = MSG_SUCCESS;
1617 MSG_PUSH_EVENT_INFO_S* pPushEvent = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData;
1620 err = MsgStoDeletePushEvent(pPushEvent);
1622 if (err == MSG_SUCCESS) {
1623 MSG_DEBUG("Command Handle Success : MsgStoDeletePushEvent()");
1625 MSG_DEBUG("Command Handle Fail : MsgStoDeletePushEvent()");
1629 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_PUSH_EVENT, err, (void**)ppEvent);
1634 int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1636 msg_error_t err = MSG_SUCCESS;
1642 MSG_PUSH_EVENT_INFO_S* pSrc = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData;
1643 MSG_PUSH_EVENT_INFO_S* pDst = (MSG_PUSH_EVENT_INFO_S*)(pCmd->cmdData + sizeof(MSG_PUSH_EVENT_INFO_S));
1646 err = MsgStoUpdatePushEvent(pSrc, pDst);
1648 if (err == MSG_SUCCESS) {
1649 MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()");
1651 MSG_DEBUG("Command Handle Fail : MsgStoUpdatePushEvent()");
1655 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PUSH_EVENT, err, (void**)ppEvent);
1660 int MsgAddSimMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1662 msg_error_t err = MSG_SUCCESS;
1666 MSG_MESSAGE_INFO_S msgInfo;
1667 MSG_SENDINGOPT_INFO_S sendOptInfo;
1668 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
1669 memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
1671 msgInfo.addressList = NULL;
1672 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
1674 MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo);
1676 int *simIdList = NULL;
1678 char *offset = NULL;
1679 offset = ((char *)pCmd->cmdData) + sizeof(MSG_MESSAGE_INFO_S) + (sizeof(MSG_ADDRESS_INFO_S) * msgInfo.nAddressCnt);
1681 listSize = *(int*)offset;
1682 offset += sizeof(int);
1683 MSG_DEBUG("listSize [%d]", listSize);
1685 simIdList = (int *)offset;
1687 MSG_DEBUG("simIdList[0] [%d]", simIdList[0]);
1690 #if 0 // Not to broadcast callback here.
1691 bool isReplaceMsg = false;
1693 if (msgInfo.msgId <= 0)
1696 isReplaceMsg = true;
1698 if (msgInfo.msgId <= 0)
1702 msg_message_id_t msg_id = MsgStoAddSimMessage(&msgInfo, simIdList, listSize);
1705 MSG_DEBUG("Command Handle Success : MsgStoAddSimMessage()");
1707 #if 0 // Not to broadcast callback here.
1709 msg_id_list_s msgIdList;
1710 msg_message_id_t msgIds[1];
1711 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
1713 msgIdList.nCount = 1;
1714 msgIds[0] = msgInfo.msgId;
1715 msgIdList.msgIdList = msgIds;
1718 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
1720 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
1723 MSG_DEBUG("Command Handle Fail : MsgStoAddSimMessage()");
1724 err = MSG_ERR_INVALID_MESSAGE;
1727 // Delete Temp File for Message Data
1728 if (msgInfo.bTextSms == false)
1729 MsgDeleteFile(msgInfo.msgData); //ipc
1732 eventSize = MsgMakeEvent((const void *)&msg_id, sizeof(msg_message_id_t), MSG_EVENT_ADD_SIM_MSG, err, (void**)ppEvent);
1738 int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1740 msg_error_t err = MSG_SUCCESS;
1746 memcpy(&sim_idx, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
1749 err = MsgStoUpdateIMSI(sim_idx);
1751 if (err == MSG_SUCCESS) {
1752 MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()");
1754 MSG_DEBUG("Command Handle Fail : MsgStoUpdatePushEvent()");
1758 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_IMSI, err, (void**)ppEvent);