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_id_list_s msgIdList;
44 memset(&msgIdList, 0x00, sizeof(msg_id_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_ADD_FILTER] = &MsgAddFilterHandler;
91 handlerMap[MSG_CMD_UPDATE_FILTER] = &MsgUpdateFilterHandler;
92 handlerMap[MSG_CMD_DELETE_FILTER] = &MsgDeleteFilterHandler;
93 handlerMap[MSG_CMD_GET_FILTERLIST] = &MsgGetFilterListHandler;
94 handlerMap[MSG_CMD_SET_FILTER_OPERATION] = &MsgSetFilterOperationHandler;
95 handlerMap[MSG_CMD_GET_FILTER_OPERATION] = &MsgGetFilterOperationHandler;
97 handlerMap[MSG_CMD_GET_MSG_TYPE] = &MsgGetMsgTypeHandler;
99 handlerMap[MSG_CMD_SUBMIT_REQ] = &MsgSubmitReqHandler;
100 handlerMap[MSG_CMD_CANCEL_REQ] = &MsgCancelReqHandler;
102 handlerMap[MSG_CMD_REG_SENT_STATUS_CB] = &MsgRegSentStatusCallbackHandler;
103 handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler;
104 handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler;
105 handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB] = &MsgRegIncomingMMSConfMsgCallbackHandler;
106 handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB] = &MsgRegIncomingSyncMLMsgCallbackHandler;
107 handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB] = &MsgRegIncomingLBSMsgCallbackHandler;
108 handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler;
110 handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
111 handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
112 handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
113 handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
115 handlerMap[MSG_CMD_PLG_INCOMING_SYNCML_IND] = &MsgIncomingSyncMLMsgHandler;
116 handlerMap[MSG_CMD_PLG_INCOMING_LBS_IND] = &MsgIncomingLBSMsgHandler;
117 handlerMap[MSG_CMD_PLG_INIT_SIM_BY_SAT] = &MsgInitSimBySatHandler;
119 handlerMap[MSG_CMD_GET_THREADVIEWLIST] = &MsgGetThreadViewListHandler;
120 handlerMap[MSG_CMD_GET_CONVERSATIONVIEWLIST] = &MsgGetConversationViewListHandler;
121 handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST] = &MsgDeleteThreadMessageListHandler;
123 handlerMap[MSG_CMD_GET_CONTACT_COUNT] = &MsgCountMsgByContactHandler;
124 handlerMap[MSG_CMD_GET_QUICKPANEL_DATA] = &MsgGetQuickPanelDataHandler;
125 handlerMap[MSG_CMD_COUNT_BY_MSGTYPE] = &MsgCountMsgByTypeHandler;
126 handlerMap[MSG_CMD_RESET_DB] = &MsgResetDatabaseHandler;
127 handlerMap[MSG_CMD_GET_MEMSIZE] = &MsgGetMemSizeHandler;
129 handlerMap[MSG_CMD_BACKUP_MESSAGE] = &MsgBackupMessageHandler;
130 handlerMap[MSG_CMD_RESTORE_MESSAGE] = &MsgRestoreMessageHandler;
132 handlerMap[MSG_CMD_UPDATE_THREAD_READ] = &MsgUpdateThreadReadStatusHandler;
134 handlerMap[MSG_CMD_SYNCML_OPERATION] = &MsgSyncMLMsgOperationHandler;
135 handlerMap[MSG_CMD_GET_REPORT_STATUS] = &MsgGetReportStatusHandler;
137 handlerMap[MSG_CMD_GET_THREAD_ID_BY_ADDRESS] = &MsgGetThreadIdByAddressHandler;
138 handlerMap[MSG_CMD_GET_THREAD_INFO] = &MsgGetThreadInfoHandler;
140 handlerMap[MSG_CMD_GET_SMSC_OPT] = &MsgGetConfigHandler;
141 handlerMap[MSG_CMD_GET_CB_OPT] = &MsgGetConfigHandler;
142 handlerMap[MSG_CMD_GET_SMS_SEND_OPT] = &MsgGetConfigHandler;
143 handlerMap[MSG_CMD_GET_MMS_SEND_OPT] = &MsgGetConfigHandler;
144 handlerMap[MSG_CMD_GET_MMS_RECV_OPT] = &MsgGetConfigHandler;
145 handlerMap[MSG_CMD_GET_PUSH_MSG_OPT] = &MsgGetConfigHandler;
146 handlerMap[MSG_CMD_GET_VOICE_MSG_OPT] = &MsgGetConfigHandler;
147 handlerMap[MSG_CMD_GET_GENERAL_MSG_OPT] = &MsgGetConfigHandler;
148 handlerMap[MSG_CMD_GET_MSG_SIZE_OPT] = &MsgGetConfigHandler;
150 handlerMap[MSG_CMD_SET_SMSC_OPT] = &MsgSetConfigHandler;
151 handlerMap[MSG_CMD_SET_CB_OPT] = &MsgSetConfigHandler;
152 handlerMap[MSG_CMD_SET_SMS_SEND_OPT] = &MsgSetConfigHandler;
153 handlerMap[MSG_CMD_SET_MMS_SEND_OPT] = &MsgSetConfigHandler;
154 handlerMap[MSG_CMD_SET_MMS_RECV_OPT] = &MsgSetConfigHandler;
155 handlerMap[MSG_CMD_SET_PUSH_MSG_OPT] = &MsgSetConfigHandler;
156 handlerMap[MSG_CMD_SET_VOICE_MSG_OPT] = &MsgSetConfigHandler;
157 handlerMap[MSG_CMD_SET_GENERAL_MSG_OPT] = &MsgSetConfigHandler;
158 handlerMap[MSG_CMD_SET_MSG_SIZE_OPT] = &MsgSetConfigHandler;
162 MsgTransactionManager::~MsgTransactionManager()
164 // pthread_cond_init(&retCV, NULL); // = PTHREAD_COND_INITIALIZER;
169 MsgTransactionManager* MsgTransactionManager::instance()
172 pInstance = new MsgTransactionManager();
178 void MsgTransactionManager::run()
180 servSock.open(MSG_SOCKET_PATH);
182 fd_set readfds = servSock.fdSet();
185 MSG_DEBUG("Start Transaction Manager");
189 readfds = servSock.fdSet();
190 nfds = servSock.maxFd();
192 MSG_DEBUG("Wait For Select() : nfds %d", nfds);
197 if( select(nfds, &readfds, NULL, NULL, NULL) == -1)
199 THROW(MsgException::SELECT_ERROR, strerror(errno));
204 for (int i=0 ; i < nfds; i++)
206 if (FD_ISSET(i, &readfds))
208 if (i == servSock.fd()) // if it is socket connection request
215 catch (MsgException& e)
217 MSG_FATAL("%s", e.what());
221 MSG_FATAL("%s", e.what());
230 void MsgTransactionManager::write(int fd, const char* buf, int len)
232 servSock.write(fd, buf, len);
236 void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
238 if (pPrxInfo == NULL)
239 THROW(MsgException::SENT_STATUS_ERROR, "Input Parameter is NULL");
241 MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
243 fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
245 if (it == statusCBFdMap.end()) { // if the status CB is not registered
246 MSG_DEBUG("No sent_status registered for fd %d", pPrxInfo->listenerFd);
248 sentMsgMap.insert(make_pair(reqId, *pPrxInfo));
253 MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
255 sentmsg_map::iterator it = sentMsgMap.find(reqId);
257 if (it == sentMsgMap.end())
259 //THROW(MsgException::SENT_STATUS_ERROR, "No submit request for %d", reqId);
260 MSG_DEBUG("No sent status cb found (exception: mobile tracker)");
264 return &(it->second);
268 void MsgTransactionManager::delProxyInfo(int reqId)
270 sentmsg_map::iterator it = sentMsgMap.find(reqId);
272 if (it == sentMsgMap.end())
274 THROW(MsgException::SENT_STATUS_ERROR, "channel info does not exist");
277 sentMsgMap.erase(it);
281 void MsgTransactionManager::handleRequest(int fd)
285 MSG_DEBUG("Event from fd %d", fd);
288 AutoPtr<char> wrap(&buf);
290 int ret = servSock.read(fd, &buf, &len);
292 if( ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0)
294 MSG_DEBUG("Read value [%d]", ret);
300 THROW(MsgException::INVALID_RESULT, "read buffer size = 0");
302 char* pEventData = NULL;
303 AutoPtr<char> eventBuf(&pEventData);
307 // decoding cmd from APP
308 MSG_CMD_S* pCmd = (MSG_CMD_S*) buf;
309 MSG_DEBUG("Command Type [%d : %s]", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType));
311 if (pCmd->cmdType > MSG_CMD_NUM)
312 THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined");
314 if (pCmd->cmdType < MSG_CMD_GET_REPORT_STATUS)
317 if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false)
319 #ifdef MSG_CHECK_PRIVILEGE
320 eventSize = sizeof(MSG_EVENT_S);
322 pEventData = new char[eventSize];
324 MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData;
326 pMsgEvent->eventType = pCmd->cmdType;
327 pMsgEvent->result = MSG_ERR_SECURITY_ERROR;
329 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
330 servSock.write(fd, pEventData, eventSize);
337 // determine the handler based on pCmd->cmdType
338 int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
340 pfHandler = handlerMap[pCmd->cmdType];
343 THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType);
345 // run handler function
346 eventSize = pfHandler(pCmd, &pEventData);
348 if (eventSize == 0 || pEventData == NULL)
349 THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL");
351 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
353 servSock.write(fd, pEventData, eventSize);
359 // terminating the socket connection between ipc server and ipc client
360 void MsgTransactionManager::cleanup(int fd)
366 MSG_DEBUG("fd %d disonnected", fd);
368 // remove sent msg info for fd
369 sentmsg_map::iterator sentmsg_it = sentMsgMap.begin();
371 for (; sentmsg_it != sentMsgMap.end(); sentmsg_it++)
373 if (sentmsg_it->second.listenerFd == fd)
375 sentmsg_it->second.listenerFd = 0;
376 sentmsg_it->second.handleAddr = 0;
380 // remove sent status callback for fd
381 statusCBFdMap.erase(fd);
383 // remove all newMsgCBs for fd
384 newmsg_list::iterator newmsg_it = newMsgCBList.begin();
386 while (newmsg_it != newMsgCBList.end())
388 if (newmsg_it->listenerFd == fd)
390 newmsg_it = newMsgCBList.erase(newmsg_it);
398 // remove all newMMSConfMsgCBs for fd
399 mmsconf_list::iterator mmsconf_it = newMMSConfMsgCBList.begin();
401 while (mmsconf_it != newMMSConfMsgCBList.end())
403 if (mmsconf_it->listenerFd == fd)
405 mmsconf_it = newMMSConfMsgCBList.erase(mmsconf_it);
413 // remove all newSyncMLMsgCBs for fd
414 syncmlmsg_list::iterator syncmlmsg_it = newSyncMLMsgCBList.begin();
416 while (syncmlmsg_it != newSyncMLMsgCBList.end())
418 if (syncmlmsg_it->listenerFd == fd)
420 syncmlmsg_it = newSyncMLMsgCBList.erase(syncmlmsg_it);
428 // remove all newLBSMsgCBs for fd
429 lbsmsg_list::iterator lbsmsg_it = newLBSMsgCBList.begin();
431 while (lbsmsg_it != newLBSMsgCBList.end())
433 if (lbsmsg_it->listenerFd == fd)
435 lbsmsg_it = newLBSMsgCBList.erase(lbsmsg_it);
443 // remove all operationSyncMLMsgCBs for fd
444 syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin();
446 while (syncmlop_it != operationSyncMLMsgCBList.end())
448 if (syncmlop_it->listenerFd == fd)
450 syncmlop_it = operationSyncMLMsgCBList.erase(syncmlop_it);
458 // remove storage change callback for fd
459 storageChangeFdMap.erase(fd);
465 bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie)
467 if (CmdType >= MSG_CMD_PLG_SENT_STATUS_CNF && CmdType <= MSG_CMD_PLG_INIT_SIM_BY_SAT)
469 MSG_DEBUG("Request from Plug-in");
473 // Get Cookie from APP
476 MSG_DEBUG("Cookie is NULL");
484 cookieSize = security_server_get_cookie_size();
486 MSG_DEBUG("cookie size : [%d]", cookieSize);
488 // char cookie[MAX_COOKIE_LEN];
491 if (CmdType == MSG_CMD_REG_INCOMING_SYNCML_MSG_CB)
493 MSG_DEBUG("get GID for message_sync");
494 gid = security_server_get_gid("message_sync");
496 else if (CmdType == MSG_CMD_REG_INCOMING_LBS_MSG_CB)
498 MSG_DEBUG("get GID for message_lbs");
499 gid = security_server_get_gid("message_lbs");
503 MSG_DEBUG("get GID for message");
504 gid = security_server_get_gid("message");
507 MSG_DEBUG("gid [%d]", gid);
511 retVal = security_server_check_privilege(pCookie, gid);
515 if (retVal == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
517 MSG_DEBUG("access denied !! [%d]", retVal);
521 MSG_DEBUG("fail to check privilege [%d]", retVal);
527 MSG_DEBUG("privilege check success !!");
533 void MsgTransactionManager::setSentStatusCB(int listenerFd)
536 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d",listenerFd);
538 statusCBFdMap[listenerFd] = true;
542 void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo)
546 MSG_FATAL("cbinfo NULL");
550 newmsg_list::iterator it = newMsgCBList.begin();
552 for (; it != newMsgCBList.end(); it++)
554 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (it->port == pCbInfo->port))
556 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d, port %d", it->listenerFd, it->msgType, it->port);
561 newMsgCBList.push_back(*pCbInfo);
565 void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbInfo)
569 MSG_FATAL("cbinfo NULL");
573 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
575 for (; it != newMMSConfMsgCBList.end(); it++)
577 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (!strncmp(it->appId, pCbInfo->appId, MAX_MMS_JAVA_APPID_LEN)))
579 MSG_DEBUG("Duplicated MMSConfMessageCB info fd:%d, mType:%d, appId:%s", it->listenerFd, it->msgType, it->appId);
584 newMMSConfMsgCBList.push_back(*pCbInfo);
588 void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo)
592 MSG_FATAL("cbinfo NULL");
596 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
598 for (; it != newSyncMLMsgCBList.end(); it++)
600 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
602 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
607 newSyncMLMsgCBList.push_back(*pCbInfo);
611 void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbInfo)
615 MSG_FATAL("cbinfo NULL");
619 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
621 for (; it != newLBSMsgCBList.end(); it++)
623 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
625 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
630 newLBSMsgCBList.push_back(*pCbInfo);
634 void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId)
638 MSG_FATAL("trId NULL");
642 javamms_list::iterator it;
644 for (it = javaMMSList.begin(); it != javaMMSList.end(); it++)
646 if (!strcmp(it->id, pTrId->id))
648 MSG_DEBUG("Duplicated javaMMS transaction Id:%s", it->id);
653 javaMMSList.push_back(*pTrId);
657 void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbInfo)
661 MSG_FATAL("cbinfo NULL");
665 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
667 for (; it != operationSyncMLMsgCBList.end(); it++)
669 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
671 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
676 operationSyncMLMsgCBList.push_back(*pCbInfo);
680 void MsgTransactionManager::setStorageChangeCB(int listenerFd)
683 THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
685 storageChangeFdMap[listenerFd] = true;
689 javamms_list& MsgTransactionManager::getJavaMMSList()
695 void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo)
699 char* pEventData = NULL;
700 AutoPtr<char> eventBuf(&pEventData);
702 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData));
704 MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
706 newmsg_list::iterator it = newMsgCBList.begin();
708 for (; it != newMsgCBList.end(); it++)
710 MSG_DEBUG("fd %d dstport %d",it->listenerFd, it->port);
712 if ((msgInfo->msgPort.valid == false) && (it->port == 0))
714 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
715 write(it->listenerFd, pEventData, eventSize);
717 else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort))
719 MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd);
720 write(it->listenerFd, pEventData, eventSize);
728 void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData)
732 char* pEventData = NULL;
733 AutoPtr<char> eventBuf(&pEventData);
735 int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
737 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
739 for (; it != newMMSConfMsgCBList.end(); it++)
741 MSG_DEBUG("fd:%d appId:%s",it->listenerFd, it->appId);
743 if (mmsRecvData->msgAppId.valid == true)
745 if (!strcmp(it->appId, mmsRecvData->msgAppId.appId))
747 MSG_DEBUG("Send incoming java msg to listener %d", it->listenerFd);
748 write(it->listenerFd, pEventData, eventSize);
753 if (strlen(it->appId) <= 0)
755 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
756 write(it->listenerFd, pEventData, eventSize);
766 void MsgTransactionManager::broadcastSyncMLMsgCB(const msg_error_t err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData)
770 char* pEventData = NULL;
771 AutoPtr<char> eventBuf(&pEventData);
773 int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
775 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
777 for (; it != newSyncMLMsgCBList.end(); it++)
779 MSG_DEBUG("Send incoming SyncML information to listener %d", it->listenerFd);
780 write(it->listenerFd, pEventData, eventSize);
787 void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_LBS_MESSAGE_DATA_S *lbsData)
791 char* pEventData = NULL;
792 AutoPtr<char> eventBuf(&pEventData);
794 int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
796 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
798 for (; it != newLBSMsgCBList.end(); it++)
800 MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd);
801 write(it->listenerFd, pEventData, eventSize);
808 void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const msg_error_t err, const int msgId, const int extId)
812 char* pEventData = NULL;
813 AutoPtr<char> eventBuf(&pEventData);
815 char* encodedData = NULL;
816 AutoPtr<char> buf(&encodedData);
818 // Encoding Storage Change Data
819 int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData);
821 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
823 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
825 for( ; it != operationSyncMLMsgCBList.end() ; it++ )
827 MSG_DEBUG("Send SyncML operation to listener %d", it->listenerFd);
828 write(it->listenerFd, pEventData, eventSize);
835 void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList)
839 if(pMsgIdList == NULL) {
840 MSG_DEBUG("pMsgIdList is NULL.");
844 MSG_DEBUG("storageChangeType [%d]", storageChangeType);
848 char* pEventData = NULL;
849 AutoPtr<char> eventBuf(&pEventData);
851 char* encodedData = NULL;
852 AutoPtr<char> buf(&encodedData);
854 // Encoding Storage Change Data
855 dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData);
857 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
859 fd_map::iterator it = storageChangeFdMap.begin();
861 for (; it != storageChangeFdMap.end(); it++)
863 MSG_DEBUG("Send Storage Change Callback to listener %d", it->first);
864 write(it->first, pEventData, eventSize);
871 void MsgTransactionManager::setTMStatus()
881 void MsgTransactionManager::getTMStatus()
888 ret = cv.timedwait(mx.pMutex(), 3);
892 if (ret == ETIMEDOUT)
894 MSG_DEBUG("MsgTransactionManager::getTMStatus TIME-OUT");