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.
33 #include <sys/socket.h>
36 #include <security-server.h>
39 #include "MsgMemory.h"
40 #include "MsgException.h"
41 #include "MsgCppTypes.h"
42 #include "MsgContact.h"
43 #include "MsgIpcSocket.h"
44 #include "MsgGconfWrapper.h"
45 #include "MsgUtilFunction.h"
46 #include "MsgCmdHandler.h"
47 #include "MsgSettingHandler.h"
48 #include "MsgStorageHandler.h"
49 #include "MsgPluginManager.h"
50 #include "MsgTransManager.h"
52 /*==================================================================================================
53 FUNCTION IMPLEMENTATION
54 ==================================================================================================*/
55 void MsgContactChangedCallback()
57 MSG_MSGID_LIST_S msgIdList;
58 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
60 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_CONTACT, &msgIdList);
63 /*==================================================================================================
64 IMPLEMENTATION OF MsgTransactionManager - Member Functions
65 ==================================================================================================*/
66 MsgTransactionManager* MsgTransactionManager::pInstance = NULL;
67 MsgIpcServerSocket MsgTransactionManager::servSock;
70 MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv()
74 statusCBFdMap.clear();
76 newMMSConfMsgCBList.clear();
77 newSyncMLMsgCBList.clear();
78 newLBSMsgCBList.clear();
80 operationSyncMLMsgCBList.clear();
81 storageChangeFdMap.clear();
85 // Fill in mMsgHandlers, as given in the below.
86 handlerMap[MSG_CMD_ADD_MSG] = &MsgAddMessageHandler;
87 handlerMap[MSG_CMD_ADD_SYNCML_MSG] = &MsgAddSyncMLMessageHandler;
88 handlerMap[MSG_CMD_UPDATE_MSG] = &MsgUpdateMessageHandler;
89 handlerMap[MSG_CMD_UPDATE_READ] = &MsgUpdateReadStatusHandler;
90 handlerMap[MSG_CMD_UPDATE_PROTECTED] = &MsgUpdateProtectedStatusHandler;
91 handlerMap[MSG_CMD_DELETE_MSG] = &MsgDeleteMessageHandler;
92 handlerMap[MSG_CMD_DELALL_MSGINFOLDER] = &MsgDeleteAllMessageInFolderHandler;
93 handlerMap[MSG_CMD_MOVE_MSGTOFOLDER] = &MsgMoveMessageToFolderHandler;
94 handlerMap[MSG_CMD_MOVE_MSGTOSTORAGE] = &MsgMoveMessageToStorageHandler;
95 handlerMap[MSG_CMD_COUNT_MSG] = &MsgCountMessageHandler;
96 handlerMap[MSG_CMD_GET_MSG] = &MsgGetMessageHandler;
97 handlerMap[MSG_CMD_GET_FOLDERVIEWLIST] = &MsgGetFolderViewListHandler;
99 handlerMap[MSG_CMD_ADD_FOLDER] = &MsgAddFolderHandler;
100 handlerMap[MSG_CMD_UPDATE_FOLDER] = &MsgUpdateFolderHandler;
101 handlerMap[MSG_CMD_DELETE_FOLDER] = &MsgDeleteFolderHandler;
102 handlerMap[MSG_CMD_GET_FOLDERLIST] = &MsgGetFolderListHandler;
104 handlerMap[MSG_CMD_SET_CONFIG] = &MsgSetConfigHandler;
105 handlerMap[MSG_CMD_GET_CONFIG] = &MsgGetConfigHandler;
106 handlerMap[MSG_CMD_GET_MSG_TYPE] = &MsgGetMsgTypeHandler;
108 handlerMap[MSG_CMD_SUBMIT_REQ] = &MsgSubmitReqHandler;
109 handlerMap[MSG_CMD_CANCEL_REQ] = &MsgCancelReqHandler;
111 handlerMap[MSG_CMD_REG_SENT_STATUS_CB] = &MsgRegSentStatusCallbackHandler;
112 handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler;
113 handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler;
114 handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB] = &MsgRegIncomingMMSConfMsgCallbackHandler;
115 handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB] = &MsgRegIncomingSyncMLMsgCallbackHandler;
116 handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB] = &MsgRegIncomingLBSMsgCallbackHandler;
117 handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler;
119 handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
120 handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
121 handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
122 handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
124 handlerMap[MSG_CMD_PLG_INCOMING_SYNCML_IND] = &MsgIncomingSyncMLMsgHandler;
125 handlerMap[MSG_CMD_PLG_INCOMING_LBS_IND] = &MsgIncomingLBSMsgHandler;
126 handlerMap[MSG_CMD_PLG_INIT_SIM_BY_SAT] = &MsgInitSimBySatHandler;
128 handlerMap[MSG_CMD_GET_THREADVIEWLIST] = &MsgGetThreadViewListHandler;
129 handlerMap[MSG_CMD_GET_CONVERSATIONVIEWLIST] = &MsgGetConversationViewListHandler;
130 handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST] = &MsgDeleteThreadMessageListHandler;
132 handlerMap[MSG_CMD_GET_CONTACT_COUNT] = &MsgCountMsgByContactHandler;
133 handlerMap[MSG_CMD_GET_QUICKPANEL_DATA] = &MsgGetQuickPanelDataHandler;
134 handlerMap[MSG_CMD_COUNT_BY_MSGTYPE] = &MsgCountMsgByTypeHandler;
135 handlerMap[MSG_CMD_RESET_DB] = &MsgResetDatabaseHandler;
136 handlerMap[MSG_CMD_GET_MEMSIZE] = &MsgGetMemSizeHandler;
138 handlerMap[MSG_CMD_UPDATE_THREAD_READ] = &MsgUpdateThreadReadStatusHandler;
140 handlerMap[MSG_CMD_SYNCML_OPERATION] = &MsgSyncMLMsgOperationHandler;
141 handlerMap[MSG_CMD_GET_REPORT_STATUS] = &MsgGetReportStatusHandler;
145 MsgTransactionManager::~MsgTransactionManager()
151 MsgTransactionManager* MsgTransactionManager::instance()
154 pInstance = new MsgTransactionManager();
160 void MsgTransactionManager::run()
162 servSock.open(MSG_SOCKET_PATH);
164 fd_set readfds = servSock.fdSet();
167 MSG_DEBUG("Start Transaction Manager");
171 readfds = servSock.fdSet();
172 nfds = servSock.maxFd();
174 MSG_DEBUG("Wait For Select() : nfds %d", nfds);
179 if( select(nfds, &readfds, NULL, NULL, NULL) == -1)
181 THROW(MsgException::SELECT_ERROR, strerror(errno));
186 for (int i=0 ; i < nfds; i++)
188 if (FD_ISSET(i, &readfds))
190 if (i == servSock.fd()) // if it is socket connection request
197 catch (MsgException& e)
199 MSG_FATAL("%s", e.what());
203 MSG_FATAL("%s", e.what());
212 void MsgTransactionManager::write(int fd, const char* buf, int len)
214 servSock.write(fd, buf, len);
218 void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
220 if (pPrxInfo == NULL)
221 THROW(MsgException::SENT_STATUS_ERROR, "Input Parameter is NULL");
223 MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
225 fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
227 if (it == statusCBFdMap.end()) { // if the status CB is not registered
228 MSG_DEBUG("No sent_status registered for fd %d", pPrxInfo->listenerFd);
230 sentMsgMap.insert(make_pair(reqId, *pPrxInfo));
235 MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
237 sentmsg_map::iterator it = sentMsgMap.find(reqId);
239 if (it == sentMsgMap.end())
241 MSG_DEBUG("No sent status cb found (exception: mobile tracker)");
245 return &(it->second);
249 void MsgTransactionManager::delProxyInfo(int reqId)
251 sentmsg_map::iterator it = sentMsgMap.find(reqId);
253 if (it == sentMsgMap.end())
255 THROW(MsgException::SENT_STATUS_ERROR, "channel info does not exist");
258 sentMsgMap.erase(it);
262 void MsgTransactionManager::handleRequest(int fd)
266 MSG_DEBUG("Event from fd %d", fd);
269 AutoPtr<char> wrap(&buf);
271 int ret = servSock.read(fd, &buf, &len);
273 if( ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0)
275 MSG_DEBUG("Read value [%d]", ret);
281 THROW(MsgException::INVALID_RESULT, "read buffer size = 0");
283 char* pEventData = NULL;
284 AutoPtr<char> eventBuf(&pEventData);
288 // decoding cmd from APP
289 MSG_CMD_S* pCmd = (MSG_CMD_S*) buf;
290 MSG_DEBUG("Command Type [%d : %s]", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType));
292 if (pCmd->cmdType > MSG_CMD_NUM)
293 THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined");
295 if (pCmd->cmdType < MSG_CMD_GET_REPORT_STATUS)
298 if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false)
300 #ifdef MSG_CHECK_PRIVILEGE
301 eventSize = sizeof(MSG_EVENT_S);
303 pEventData = new char[eventSize];
305 MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData;
307 pMsgEvent->eventType = pCmd->cmdType;
308 pMsgEvent->result = MSG_ERR_SECURITY_ERROR;
310 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
311 servSock.write(fd, pEventData, eventSize);
318 // determine the handler based on pCmd->cmdType
319 int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
321 pfHandler = handlerMap[pCmd->cmdType];
324 THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType);
326 // run handler function
327 eventSize = pfHandler(pCmd, &pEventData);
329 if (eventSize == 0 || pEventData == NULL)
330 THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL");
332 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
334 servSock.write(fd, pEventData, eventSize);
340 // terminating the socket connection between ipc server and ipc client
341 void MsgTransactionManager::cleanup(int fd)
347 MSG_DEBUG("fd %d disonnected", fd);
349 // remove sent msg info for fd
350 sentmsg_map::iterator sentmsg_it = sentMsgMap.begin();
352 for (; sentmsg_it != sentMsgMap.end(); sentmsg_it++)
354 if (sentmsg_it->second.listenerFd == fd)
356 sentmsg_it->second.listenerFd = 0;
357 sentmsg_it->second.handleAddr = 0;
361 // remove sent status callback for fd
362 statusCBFdMap.erase(fd);
364 // remove all newMsgCBs for fd
365 newmsg_list::iterator newmsg_it = newMsgCBList.begin();
367 while (newmsg_it != newMsgCBList.end())
369 if (newmsg_it->listenerFd == fd)
371 newmsg_it = newMsgCBList.erase(newmsg_it);
379 // remove all newMMSConfMsgCBs for fd
380 mmsconf_list::iterator mmsconf_it = newMMSConfMsgCBList.begin();
382 while (mmsconf_it != newMMSConfMsgCBList.end())
384 if (mmsconf_it->listenerFd == fd)
386 mmsconf_it = newMMSConfMsgCBList.erase(mmsconf_it);
394 // remove all newSyncMLMsgCBs for fd
395 syncmlmsg_list::iterator syncmlmsg_it = newSyncMLMsgCBList.begin();
397 while (syncmlmsg_it != newSyncMLMsgCBList.end())
399 if (syncmlmsg_it->listenerFd == fd)
401 syncmlmsg_it = newSyncMLMsgCBList.erase(syncmlmsg_it);
409 // remove all newLBSMsgCBs for fd
410 lbsmsg_list::iterator lbsmsg_it = newLBSMsgCBList.begin();
412 while (lbsmsg_it != newLBSMsgCBList.end())
414 if (lbsmsg_it->listenerFd == fd)
416 lbsmsg_it = newLBSMsgCBList.erase(lbsmsg_it);
424 // remove all operationSyncMLMsgCBs for fd
425 syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin();
427 while (syncmlop_it != operationSyncMLMsgCBList.end())
429 if (syncmlop_it->listenerFd == fd)
431 syncmlop_it = operationSyncMLMsgCBList.erase(syncmlop_it);
439 // remove storage change callback for fd
440 storageChangeFdMap.erase(fd);
446 bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie)
448 if (CmdType >= MSG_CMD_PLG_SENT_STATUS_CNF && CmdType <= MSG_CMD_PLG_INIT_SIM_BY_SAT)
450 MSG_DEBUG("Request from Plug-in");
454 // Get Cookie from APP
457 MSG_DEBUG("Cookie is NULL");
465 cookieSize = security_server_get_cookie_size();
467 MSG_DEBUG("cookie size : [%d]", cookieSize);
470 if (CmdType == MSG_CMD_REG_INCOMING_SYNCML_MSG_CB)
472 MSG_DEBUG("get GID for message_sync");
473 gid = security_server_get_gid("message_sync");
475 else if (CmdType == MSG_CMD_REG_INCOMING_LBS_MSG_CB)
477 MSG_DEBUG("get GID for message_lbs");
478 gid = security_server_get_gid("message_lbs");
482 MSG_DEBUG("get GID for message");
483 gid = security_server_get_gid("message");
486 MSG_DEBUG("gid [%d]", gid);
490 retVal = security_server_check_privilege(pCookie, gid);
494 if (retVal == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
496 MSG_DEBUG("access denied !! [%d]", retVal);
500 MSG_DEBUG("fail to check privilege [%d]", retVal);
506 MSG_DEBUG("privilege check success !!");
512 void MsgTransactionManager::setSentStatusCB(int listenerFd)
515 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d",listenerFd);
517 statusCBFdMap[listenerFd] = true;
521 void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo)
525 MSG_FATAL("cbinfo NULL");
529 newmsg_list::iterator it = newMsgCBList.begin();
531 for (; it != newMsgCBList.end(); it++)
533 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (it->port == pCbInfo->port))
535 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d, port %d", it->listenerFd, it->msgType, it->port);
540 newMsgCBList.push_back(*pCbInfo);
544 void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbInfo)
548 MSG_FATAL("cbinfo NULL");
552 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
554 for (; it != newMMSConfMsgCBList.end(); it++)
556 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (!strncmp(it->appId, pCbInfo->appId, MAX_MMS_JAVA_APPID_LEN)))
558 MSG_DEBUG("Duplicated MMSConfMessageCB info fd:%d, mType:%d, appId:%s", it->listenerFd, it->msgType, it->appId);
563 newMMSConfMsgCBList.push_back(*pCbInfo);
567 void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo)
571 MSG_FATAL("cbinfo NULL");
575 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
577 for (; it != newSyncMLMsgCBList.end(); it++)
579 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
581 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
586 newSyncMLMsgCBList.push_back(*pCbInfo);
590 void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbInfo)
594 MSG_FATAL("cbinfo NULL");
598 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
600 for (; it != newLBSMsgCBList.end(); it++)
602 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
604 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
609 newLBSMsgCBList.push_back(*pCbInfo);
613 void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId)
617 MSG_FATAL("trId NULL");
621 javamms_list::iterator it;
623 for (it = javaMMSList.begin(); it != javaMMSList.end(); it++)
625 if (!strcmp(it->id, pTrId->id))
627 MSG_DEBUG("Duplicated javaMMS transaction Id:%s", it->id);
632 javaMMSList.push_back(*pTrId);
636 void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbInfo)
640 MSG_FATAL("cbinfo NULL");
644 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
646 for (; it != operationSyncMLMsgCBList.end(); it++)
648 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
650 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
655 operationSyncMLMsgCBList.push_back(*pCbInfo);
659 void MsgTransactionManager::setStorageChangeCB(int listenerFd)
662 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
664 storageChangeFdMap[listenerFd] = true;
668 javamms_list& MsgTransactionManager::getJavaMMSList()
674 void MsgTransactionManager::broadcastIncomingMsgCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo)
678 char* pEventData = NULL;
679 AutoPtr<char> eventBuf(&pEventData);
681 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData));
683 MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
685 newmsg_list::iterator it = newMsgCBList.begin();
687 for (; it != newMsgCBList.end(); it++)
689 MSG_DEBUG("fd %d dstport %d",it->listenerFd, it->port);
691 if ((msgInfo->msgPort.valid == false) && (it->port == 0))
693 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
694 write(it->listenerFd, pEventData, eventSize);
696 else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort))
698 MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd);
699 write(it->listenerFd, pEventData, eventSize);
707 void MsgTransactionManager::broadcastMMSConfCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData)
711 char* pEventData = NULL;
712 AutoPtr<char> eventBuf(&pEventData);
714 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
716 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
718 for (; it != newMMSConfMsgCBList.end(); it++)
720 MSG_DEBUG("fd:%d appId:%s",it->listenerFd, it->appId);
722 if (mmsRecvData->msgAppId.valid == true)
724 if (!strcmp(it->appId, mmsRecvData->msgAppId.appId))
726 MSG_DEBUG("Send incoming java msg to listener %d", it->listenerFd);
727 write(it->listenerFd, pEventData, eventSize);
732 if (strlen(it->appId) <= 0)
734 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
735 write(it->listenerFd, pEventData, eventSize);
745 void MsgTransactionManager::broadcastSyncMLMsgCB(const MSG_ERROR_T err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData)
749 char* pEventData = NULL;
750 AutoPtr<char> eventBuf(&pEventData);
752 int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
754 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
756 for (; it != newSyncMLMsgCBList.end(); it++)
758 MSG_DEBUG("Send incoming SyncML information to listener %d", it->listenerFd);
759 write(it->listenerFd, pEventData, eventSize);
766 void MsgTransactionManager::broadcastLBSMsgCB(const MSG_ERROR_T err, const MSG_LBS_MESSAGE_DATA_S *lbsData)
770 char* pEventData = NULL;
771 AutoPtr<char> eventBuf(&pEventData);
773 int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
775 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
777 for (; it != newLBSMsgCBList.end(); it++)
779 MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd);
780 write(it->listenerFd, pEventData, eventSize);
787 void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const MSG_ERROR_T err, const int msgId, const int extId)
791 char* pEventData = NULL;
792 AutoPtr<char> eventBuf(&pEventData);
794 char* encodedData = NULL;
795 AutoPtr<char> buf(&encodedData);
797 // Encoding Storage Change Data
798 int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData);
800 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
802 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
804 for( ; it != operationSyncMLMsgCBList.end() ; it++ )
806 MSG_DEBUG("Send SyncML operation to listener %d", it->listenerFd);
807 write(it->listenerFd, pEventData, eventSize);
814 void MsgTransactionManager::broadcastStorageChangeCB(const MSG_ERROR_T err, const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList)
818 if(pMsgIdList == NULL) {
819 MSG_DEBUG("pMsgIdList is NULL.");
823 MSG_DEBUG("storageChangeType [%d]", storageChangeType);
827 char* pEventData = NULL;
828 AutoPtr<char> eventBuf(&pEventData);
830 char* encodedData = NULL;
831 AutoPtr<char> buf(&encodedData);
833 // Encoding Storage Change Data
834 dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData);
836 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
838 fd_map::iterator it = storageChangeFdMap.begin();
840 for (; it != storageChangeFdMap.end(); it++)
842 MSG_DEBUG("Send Storage Change Callback to listener %d", it->first);
843 write(it->first, pEventData, eventSize);
850 void MsgTransactionManager::setTMStatus()
860 void MsgTransactionManager::getTMStatus()
867 ret = cv.timedwait(mx.pMutex(), 3);
871 if (ret == ETIMEDOUT)
873 MSG_DEBUG("MsgTransactionManager::getTMStatus TIME-OUT");