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.
19 #include <sys/socket.h>
22 #include <security-server.h>
25 #include "MsgMemory.h"
26 #include "MsgException.h"
27 #include "MsgCppTypes.h"
28 #include "MsgContact.h"
29 #include "MsgIpcSocket.h"
30 #include "MsgGconfWrapper.h"
31 #include "MsgUtilFunction.h"
32 #include "MsgCmdHandler.h"
33 #include "MsgSettingHandler.h"
34 #include "MsgStorageHandler.h"
35 #include "MsgPluginManager.h"
36 #include "MsgTransManager.h"
38 /*==================================================================================================
39 FUNCTION IMPLEMENTATION
40 ==================================================================================================*/
41 void MsgContactChangedCallback()
43 MSG_MSGID_LIST_S msgIdList;
44 memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
46 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_CONTACT, &msgIdList);
49 /*==================================================================================================
50 IMPLEMENTATION OF MsgTransactionManager - Member Functions
51 ==================================================================================================*/
52 MsgTransactionManager* MsgTransactionManager::pInstance = NULL;
53 MsgIpcServerSocket MsgTransactionManager::servSock;
56 MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv()
60 statusCBFdMap.clear();
62 newMMSConfMsgCBList.clear();
63 newSyncMLMsgCBList.clear();
64 newLBSMsgCBList.clear();
66 operationSyncMLMsgCBList.clear();
67 storageChangeFdMap.clear();
71 // Fill in mMsgHandlers, as given in the below.
72 handlerMap[MSG_CMD_ADD_MSG] = &MsgAddMessageHandler;
73 handlerMap[MSG_CMD_ADD_SYNCML_MSG] = &MsgAddSyncMLMessageHandler;
74 handlerMap[MSG_CMD_UPDATE_MSG] = &MsgUpdateMessageHandler;
75 handlerMap[MSG_CMD_UPDATE_READ] = &MsgUpdateReadStatusHandler;
76 handlerMap[MSG_CMD_UPDATE_PROTECTED] = &MsgUpdateProtectedStatusHandler;
77 handlerMap[MSG_CMD_DELETE_MSG] = &MsgDeleteMessageHandler;
78 handlerMap[MSG_CMD_DELALL_MSGINFOLDER] = &MsgDeleteAllMessageInFolderHandler;
79 handlerMap[MSG_CMD_MOVE_MSGTOFOLDER] = &MsgMoveMessageToFolderHandler;
80 handlerMap[MSG_CMD_MOVE_MSGTOSTORAGE] = &MsgMoveMessageToStorageHandler;
81 handlerMap[MSG_CMD_COUNT_MSG] = &MsgCountMessageHandler;
82 handlerMap[MSG_CMD_GET_MSG] = &MsgGetMessageHandler;
83 handlerMap[MSG_CMD_GET_FOLDERVIEWLIST] = &MsgGetFolderViewListHandler;
85 handlerMap[MSG_CMD_ADD_FOLDER] = &MsgAddFolderHandler;
86 handlerMap[MSG_CMD_UPDATE_FOLDER] = &MsgUpdateFolderHandler;
87 handlerMap[MSG_CMD_DELETE_FOLDER] = &MsgDeleteFolderHandler;
88 handlerMap[MSG_CMD_GET_FOLDERLIST] = &MsgGetFolderListHandler;
90 handlerMap[MSG_CMD_SET_CONFIG] = &MsgSetConfigHandler;
91 handlerMap[MSG_CMD_GET_CONFIG] = &MsgGetConfigHandler;
92 handlerMap[MSG_CMD_GET_MSG_TYPE] = &MsgGetMsgTypeHandler;
94 handlerMap[MSG_CMD_SUBMIT_REQ] = &MsgSubmitReqHandler;
95 handlerMap[MSG_CMD_CANCEL_REQ] = &MsgCancelReqHandler;
97 handlerMap[MSG_CMD_REG_SENT_STATUS_CB] = &MsgRegSentStatusCallbackHandler;
98 handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler;
99 handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler;
100 handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB] = &MsgRegIncomingMMSConfMsgCallbackHandler;
101 handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB] = &MsgRegIncomingSyncMLMsgCallbackHandler;
102 handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB] = &MsgRegIncomingLBSMsgCallbackHandler;
103 handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler;
105 handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
106 handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
107 handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
108 handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
110 handlerMap[MSG_CMD_PLG_INCOMING_SYNCML_IND] = &MsgIncomingSyncMLMsgHandler;
111 handlerMap[MSG_CMD_PLG_INCOMING_LBS_IND] = &MsgIncomingLBSMsgHandler;
112 handlerMap[MSG_CMD_PLG_INIT_SIM_BY_SAT] = &MsgInitSimBySatHandler;
114 handlerMap[MSG_CMD_GET_THREADVIEWLIST] = &MsgGetThreadViewListHandler;
115 handlerMap[MSG_CMD_GET_CONVERSATIONVIEWLIST] = &MsgGetConversationViewListHandler;
116 handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST] = &MsgDeleteThreadMessageListHandler;
118 handlerMap[MSG_CMD_GET_CONTACT_COUNT] = &MsgCountMsgByContactHandler;
119 handlerMap[MSG_CMD_GET_QUICKPANEL_DATA] = &MsgGetQuickPanelDataHandler;
120 handlerMap[MSG_CMD_COUNT_BY_MSGTYPE] = &MsgCountMsgByTypeHandler;
121 handlerMap[MSG_CMD_RESET_DB] = &MsgResetDatabaseHandler;
122 handlerMap[MSG_CMD_GET_MEMSIZE] = &MsgGetMemSizeHandler;
124 handlerMap[MSG_CMD_UPDATE_THREAD_READ] = &MsgUpdateThreadReadStatusHandler;
126 handlerMap[MSG_CMD_SYNCML_OPERATION] = &MsgSyncMLMsgOperationHandler;
127 handlerMap[MSG_CMD_GET_REPORT_STATUS] = &MsgGetReportStatusHandler;
131 MsgTransactionManager::~MsgTransactionManager()
137 MsgTransactionManager* MsgTransactionManager::instance()
140 pInstance = new MsgTransactionManager();
146 void MsgTransactionManager::run()
148 servSock.open(MSG_SOCKET_PATH);
150 fd_set readfds = servSock.fdSet();
153 MSG_DEBUG("Start Transaction Manager");
157 readfds = servSock.fdSet();
158 nfds = servSock.maxFd();
160 MSG_DEBUG("Wait For Select() : nfds %d", nfds);
165 if( select(nfds, &readfds, NULL, NULL, NULL) == -1)
167 THROW(MsgException::SELECT_ERROR, strerror(errno));
172 for (int i=0 ; i < nfds; i++)
174 if (FD_ISSET(i, &readfds))
176 if (i == servSock.fd()) // if it is socket connection request
183 catch (MsgException& e)
185 MSG_FATAL("%s", e.what());
189 MSG_FATAL("%s", e.what());
198 void MsgTransactionManager::write(int fd, const char* buf, int len)
200 servSock.write(fd, buf, len);
204 void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
206 if (pPrxInfo == NULL)
207 THROW(MsgException::SENT_STATUS_ERROR, "Input Parameter is NULL");
209 MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
211 fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
213 if (it == statusCBFdMap.end()) { // if the status CB is not registered
214 MSG_DEBUG("No sent_status registered for fd %d", pPrxInfo->listenerFd);
216 sentMsgMap.insert(make_pair(reqId, *pPrxInfo));
221 MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
223 sentmsg_map::iterator it = sentMsgMap.find(reqId);
225 if (it == sentMsgMap.end())
227 MSG_DEBUG("No sent status cb found (exception: mobile tracker)");
231 return &(it->second);
235 void MsgTransactionManager::delProxyInfo(int reqId)
237 sentmsg_map::iterator it = sentMsgMap.find(reqId);
239 if (it == sentMsgMap.end())
241 THROW(MsgException::SENT_STATUS_ERROR, "channel info does not exist");
244 sentMsgMap.erase(it);
248 void MsgTransactionManager::handleRequest(int fd)
252 MSG_DEBUG("Event from fd %d", fd);
255 AutoPtr<char> wrap(&buf);
257 int ret = servSock.read(fd, &buf, &len);
259 if( ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0)
261 MSG_DEBUG("Read value [%d]", ret);
267 THROW(MsgException::INVALID_RESULT, "read buffer size = 0");
269 char* pEventData = NULL;
270 AutoPtr<char> eventBuf(&pEventData);
274 // decoding cmd from APP
275 MSG_CMD_S* pCmd = (MSG_CMD_S*) buf;
276 MSG_DEBUG("Command Type [%d : %s]", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType));
278 if (pCmd->cmdType > MSG_CMD_NUM)
279 THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined");
281 if (pCmd->cmdType < MSG_CMD_GET_REPORT_STATUS)
284 if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false)
286 #ifdef MSG_CHECK_PRIVILEGE
287 eventSize = sizeof(MSG_EVENT_S);
289 pEventData = new char[eventSize];
291 MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData;
293 pMsgEvent->eventType = pCmd->cmdType;
294 pMsgEvent->result = MSG_ERR_SECURITY_ERROR;
296 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
297 servSock.write(fd, pEventData, eventSize);
304 // determine the handler based on pCmd->cmdType
305 int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
307 pfHandler = handlerMap[pCmd->cmdType];
310 THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType);
312 // run handler function
313 eventSize = pfHandler(pCmd, &pEventData);
315 if (eventSize == 0 || pEventData == NULL)
316 THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL");
318 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
320 servSock.write(fd, pEventData, eventSize);
326 // terminating the socket connection between ipc server and ipc client
327 void MsgTransactionManager::cleanup(int fd)
333 MSG_DEBUG("fd %d disonnected", fd);
335 // remove sent msg info for fd
336 sentmsg_map::iterator sentmsg_it = sentMsgMap.begin();
338 for (; sentmsg_it != sentMsgMap.end(); sentmsg_it++)
340 if (sentmsg_it->second.listenerFd == fd)
342 sentmsg_it->second.listenerFd = 0;
343 sentmsg_it->second.handleAddr = 0;
347 // remove sent status callback for fd
348 statusCBFdMap.erase(fd);
350 // remove all newMsgCBs for fd
351 newmsg_list::iterator newmsg_it = newMsgCBList.begin();
353 while (newmsg_it != newMsgCBList.end())
355 if (newmsg_it->listenerFd == fd)
357 newmsg_it = newMsgCBList.erase(newmsg_it);
365 // remove all newMMSConfMsgCBs for fd
366 mmsconf_list::iterator mmsconf_it = newMMSConfMsgCBList.begin();
368 while (mmsconf_it != newMMSConfMsgCBList.end())
370 if (mmsconf_it->listenerFd == fd)
372 mmsconf_it = newMMSConfMsgCBList.erase(mmsconf_it);
380 // remove all newSyncMLMsgCBs for fd
381 syncmlmsg_list::iterator syncmlmsg_it = newSyncMLMsgCBList.begin();
383 while (syncmlmsg_it != newSyncMLMsgCBList.end())
385 if (syncmlmsg_it->listenerFd == fd)
387 syncmlmsg_it = newSyncMLMsgCBList.erase(syncmlmsg_it);
395 // remove all newLBSMsgCBs for fd
396 lbsmsg_list::iterator lbsmsg_it = newLBSMsgCBList.begin();
398 while (lbsmsg_it != newLBSMsgCBList.end())
400 if (lbsmsg_it->listenerFd == fd)
402 lbsmsg_it = newLBSMsgCBList.erase(lbsmsg_it);
410 // remove all operationSyncMLMsgCBs for fd
411 syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin();
413 while (syncmlop_it != operationSyncMLMsgCBList.end())
415 if (syncmlop_it->listenerFd == fd)
417 syncmlop_it = operationSyncMLMsgCBList.erase(syncmlop_it);
425 // remove storage change callback for fd
426 storageChangeFdMap.erase(fd);
432 bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie)
434 if (CmdType >= MSG_CMD_PLG_SENT_STATUS_CNF && CmdType <= MSG_CMD_PLG_INIT_SIM_BY_SAT)
436 MSG_DEBUG("Request from Plug-in");
440 // Get Cookie from APP
443 MSG_DEBUG("Cookie is NULL");
451 cookieSize = security_server_get_cookie_size();
453 MSG_DEBUG("cookie size : [%d]", cookieSize);
456 if (CmdType == MSG_CMD_REG_INCOMING_SYNCML_MSG_CB)
458 MSG_DEBUG("get GID for message_sync");
459 gid = security_server_get_gid("message_sync");
461 else if (CmdType == MSG_CMD_REG_INCOMING_LBS_MSG_CB)
463 MSG_DEBUG("get GID for message_lbs");
464 gid = security_server_get_gid("message_lbs");
468 MSG_DEBUG("get GID for message");
469 gid = security_server_get_gid("message");
472 MSG_DEBUG("gid [%d]", gid);
476 retVal = security_server_check_privilege(pCookie, gid);
480 if (retVal == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
482 MSG_DEBUG("access denied !! [%d]", retVal);
486 MSG_DEBUG("fail to check privilege [%d]", retVal);
492 MSG_DEBUG("privilege check success !!");
498 void MsgTransactionManager::setSentStatusCB(int listenerFd)
501 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d",listenerFd);
503 statusCBFdMap[listenerFd] = true;
507 void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo)
511 MSG_FATAL("cbinfo NULL");
515 newmsg_list::iterator it = newMsgCBList.begin();
517 for (; it != newMsgCBList.end(); it++)
519 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (it->port == pCbInfo->port))
521 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d, port %d", it->listenerFd, it->msgType, it->port);
526 newMsgCBList.push_back(*pCbInfo);
530 void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbInfo)
534 MSG_FATAL("cbinfo NULL");
538 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
540 for (; it != newMMSConfMsgCBList.end(); it++)
542 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (!strncmp(it->appId, pCbInfo->appId, MAX_MMS_JAVA_APPID_LEN)))
544 MSG_DEBUG("Duplicated MMSConfMessageCB info fd:%d, mType:%d, appId:%s", it->listenerFd, it->msgType, it->appId);
549 newMMSConfMsgCBList.push_back(*pCbInfo);
553 void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo)
557 MSG_FATAL("cbinfo NULL");
561 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
563 for (; it != newSyncMLMsgCBList.end(); it++)
565 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
567 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
572 newSyncMLMsgCBList.push_back(*pCbInfo);
576 void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbInfo)
580 MSG_FATAL("cbinfo NULL");
584 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
586 for (; it != newLBSMsgCBList.end(); it++)
588 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
590 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
595 newLBSMsgCBList.push_back(*pCbInfo);
599 void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId)
603 MSG_FATAL("trId NULL");
607 javamms_list::iterator it;
609 for (it = javaMMSList.begin(); it != javaMMSList.end(); it++)
611 if (!strcmp(it->id, pTrId->id))
613 MSG_DEBUG("Duplicated javaMMS transaction Id:%s", it->id);
618 javaMMSList.push_back(*pTrId);
622 void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbInfo)
626 MSG_FATAL("cbinfo NULL");
630 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
632 for (; it != operationSyncMLMsgCBList.end(); it++)
634 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
636 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
641 operationSyncMLMsgCBList.push_back(*pCbInfo);
645 void MsgTransactionManager::setStorageChangeCB(int listenerFd)
648 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
650 storageChangeFdMap[listenerFd] = true;
654 javamms_list& MsgTransactionManager::getJavaMMSList()
660 void MsgTransactionManager::broadcastIncomingMsgCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo)
664 char* pEventData = NULL;
665 AutoPtr<char> eventBuf(&pEventData);
667 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData));
669 MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
671 newmsg_list::iterator it = newMsgCBList.begin();
673 for (; it != newMsgCBList.end(); it++)
675 MSG_DEBUG("fd %d dstport %d",it->listenerFd, it->port);
677 if ((msgInfo->msgPort.valid == false) && (it->port == 0))
679 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
680 write(it->listenerFd, pEventData, eventSize);
682 else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort))
684 MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd);
685 write(it->listenerFd, pEventData, eventSize);
693 void MsgTransactionManager::broadcastMMSConfCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData)
697 char* pEventData = NULL;
698 AutoPtr<char> eventBuf(&pEventData);
700 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
702 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
704 for (; it != newMMSConfMsgCBList.end(); it++)
706 MSG_DEBUG("fd:%d appId:%s",it->listenerFd, it->appId);
708 if (mmsRecvData->msgAppId.valid == true)
710 if (!strcmp(it->appId, mmsRecvData->msgAppId.appId))
712 MSG_DEBUG("Send incoming java msg to listener %d", it->listenerFd);
713 write(it->listenerFd, pEventData, eventSize);
718 if (strlen(it->appId) <= 0)
720 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
721 write(it->listenerFd, pEventData, eventSize);
731 void MsgTransactionManager::broadcastSyncMLMsgCB(const MSG_ERROR_T err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData)
735 char* pEventData = NULL;
736 AutoPtr<char> eventBuf(&pEventData);
738 int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
740 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
742 for (; it != newSyncMLMsgCBList.end(); it++)
744 MSG_DEBUG("Send incoming SyncML information to listener %d", it->listenerFd);
745 write(it->listenerFd, pEventData, eventSize);
752 void MsgTransactionManager::broadcastLBSMsgCB(const MSG_ERROR_T err, const MSG_LBS_MESSAGE_DATA_S *lbsData)
756 char* pEventData = NULL;
757 AutoPtr<char> eventBuf(&pEventData);
759 int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
761 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
763 for (; it != newLBSMsgCBList.end(); it++)
765 MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd);
766 write(it->listenerFd, pEventData, eventSize);
773 void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const MSG_ERROR_T err, const int msgId, const int extId)
777 char* pEventData = NULL;
778 AutoPtr<char> eventBuf(&pEventData);
780 char* encodedData = NULL;
781 AutoPtr<char> buf(&encodedData);
783 // Encoding Storage Change Data
784 int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData);
786 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
788 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
790 for( ; it != operationSyncMLMsgCBList.end() ; it++ )
792 MSG_DEBUG("Send SyncML operation to listener %d", it->listenerFd);
793 write(it->listenerFd, pEventData, eventSize);
800 void MsgTransactionManager::broadcastStorageChangeCB(const MSG_ERROR_T err, const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList)
804 if(pMsgIdList == NULL) {
805 MSG_DEBUG("pMsgIdList is NULL.");
809 MSG_DEBUG("storageChangeType [%d]", storageChangeType);
813 char* pEventData = NULL;
814 AutoPtr<char> eventBuf(&pEventData);
816 char* encodedData = NULL;
817 AutoPtr<char> buf(&encodedData);
819 // Encoding Storage Change Data
820 dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData);
822 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
824 fd_map::iterator it = storageChangeFdMap.begin();
826 for (; it != storageChangeFdMap.end(); it++)
828 MSG_DEBUG("Send Storage Change Callback to listener %d", it->first);
829 write(it->first, pEventData, eventSize);
836 void MsgTransactionManager::setTMStatus()
846 void MsgTransactionManager::getTMStatus()
853 ret = cv.timedwait(mx.pMutex(), 3);
857 if (ret == ETIMEDOUT)
859 MSG_DEBUG("MsgTransactionManager::getTMStatus TIME-OUT");