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.
19 #include <sys/socket.h>
24 #include <eventsystem.h>
27 #include "MsgMemory.h"
28 #include "MsgException.h"
29 #include "MsgCppTypes.h"
30 #include "MsgContact.h"
31 #include "MsgIpcSocket.h"
32 #include "MsgGconfWrapper.h"
33 #include "MsgUtilFunction.h"
34 #include "MsgUtilFile.h"
36 #include "MsgCmdHandler.h"
37 #include "MsgSettingHandler.h"
38 #include "MsgStorageHandler.h"
39 #include "MsgPluginManager.h"
40 #include "MsgTransManager.h"
42 #define MSG_CHECK_PRIVILEGE
44 void MsgMakeErrorEvent(MSG_CMD_TYPE_T cmdType, msg_error_t errType, int *pEventSize, char **ppEvent)
46 if (*ppEvent) delete [] *ppEvent;
48 *pEventSize = sizeof(MSG_EVENT_S);
49 *ppEvent = new char[sizeof(MSG_EVENT_S)];
51 MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)*ppEvent;
53 pMsgEvent->eventType = cmdType;
54 pMsgEvent->result = errType;
57 /*==================================================================================================
58 IMPLEMENTATION OF MsgTransactionManager - Member Functions
59 ==================================================================================================*/
60 MsgTransactionManager* MsgTransactionManager::pInstance = NULL;
61 MsgIpcServerSocket MsgTransactionManager::servSock;
64 MsgTransactionManager::MsgTransactionManager() : running(false), mx(), mxQ(), cv(), eventQueue()
67 statusCBFdMap.clear();
69 newMMSConfMsgCBList.clear();
70 newSyncMLMsgCBList.clear();
71 newLBSMsgCBList.clear();
73 operationSyncMLMsgCBList.clear();
74 storageChangeFdMap.clear();
78 /* Fill in mMsgHandlers, as given in the below. */
79 handlerMap[MSG_CMD_ADD_MSG] = &MsgAddMessageHandler;
80 handlerMap[MSG_CMD_ADD_SYNCML_MSG] = &MsgAddSyncMLMessageHandler;
81 handlerMap[MSG_CMD_UPDATE_MSG] = &MsgUpdateMessageHandler;
82 handlerMap[MSG_CMD_UPDATE_READ] = &MsgUpdateReadStatusHandler;
83 handlerMap[MSG_CMD_UPDATE_PROTECTED] = &MsgUpdateProtectedStatusHandler;
84 handlerMap[MSG_CMD_DELETE_MSG] = &MsgDeleteMessageHandler;
85 handlerMap[MSG_CMD_DELALL_MSGINFOLDER] = &MsgDeleteAllMessageInFolderHandler;
86 handlerMap[MSG_CMD_MOVE_MSGTOFOLDER] = &MsgMoveMessageToFolderHandler;
87 handlerMap[MSG_CMD_MOVE_MSGTOSTORAGE] = &MsgMoveMessageToStorageHandler;
88 handlerMap[MSG_CMD_COUNT_MSG] = &MsgCountMessageHandler;
89 handlerMap[MSG_CMD_GET_MSG] = &MsgGetMessageHandler;
91 handlerMap[MSG_CMD_ADD_FOLDER] = &MsgAddFolderHandler;
92 handlerMap[MSG_CMD_UPDATE_FOLDER] = &MsgUpdateFolderHandler;
93 handlerMap[MSG_CMD_DELETE_FOLDER] = &MsgDeleteFolderHandler;
94 handlerMap[MSG_CMD_GET_FOLDERLIST] = &MsgGetFolderListHandler;
96 handlerMap[MSG_CMD_ADD_FILTER] = &MsgAddFilterHandler;
97 handlerMap[MSG_CMD_UPDATE_FILTER] = &MsgUpdateFilterHandler;
98 handlerMap[MSG_CMD_DELETE_FILTER] = &MsgDeleteFilterHandler;
99 handlerMap[MSG_CMD_GET_FILTERLIST] = &MsgGetFilterListHandler;
100 handlerMap[MSG_CMD_SET_FILTER_OPERATION] = &MsgSetFilterOperationHandler;
101 handlerMap[MSG_CMD_GET_FILTER_OPERATION] = &MsgGetFilterOperationHandler;
102 handlerMap[MSG_CMD_SET_FILTER_ACTIVATION] = &MsgSetFilterActivationHandler;
104 handlerMap[MSG_CMD_SUBMIT_REQ] = &MsgSubmitReqHandler;
106 handlerMap[MSG_CMD_REG_SENT_STATUS_CB] = &MsgRegSentStatusCallbackHandler;
107 handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler;
108 handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler;
109 handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB] = &MsgRegIncomingMMSConfMsgCallbackHandler;
110 handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB] = &MsgRegIncomingSyncMLMsgCallbackHandler;
111 handlerMap[MSG_CMD_REG_INCOMING_PUSH_MSG_CB] = &MsgRegIncomingPushMsgCallbackHandler;
112 handlerMap[MSG_CMD_REG_INCOMING_CB_MSG_CB] = &MsgRegIncomingCBMsgCallbackHandler;
113 handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB] = &MsgRegIncomingLBSMsgCallbackHandler;
114 handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler;
115 handlerMap[MSG_CMD_REG_REPORT_MSG_INCOMING_CB] = &MsgRegIncomingReportMsgCallbackHandler;
117 handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
118 handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
119 handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
120 handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
121 handlerMap[MSG_CMD_PLG_INCOMING_PUSH_IND] = &MsgIncomingPushMsgHandler;
122 handlerMap[MSG_CMD_PLG_INCOMING_CB_IND] = &MsgIncomingCBMsgHandler;
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_DELETE_THREADMESSAGELIST] = &MsgDeleteThreadMessageListHandler;
130 handlerMap[MSG_CMD_SET_TEMP_ADDRESS_TABLE] = &MsgSetTempAddressTableHandler;
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_BACKUP_MESSAGE] = &MsgBackupMessageHandler;
139 handlerMap[MSG_CMD_RESTORE_MESSAGE] = &MsgRestoreMessageHandler;
141 handlerMap[MSG_CMD_UPDATE_THREAD_READ] = &MsgUpdateThreadReadStatusHandler;
143 handlerMap[MSG_CMD_SYNCML_OPERATION] = &MsgSyncMLMsgOperationHandler;
144 handlerMap[MSG_CMD_GET_REPORT_STATUS] = &MsgGetReportStatusHandler;
146 handlerMap[MSG_CMD_GET_THREAD_ID_BY_ADDRESS] = &MsgGetThreadIdByAddressHandler;
147 handlerMap[MSG_CMD_GET_THREAD_INFO] = &MsgGetThreadInfoHandler;
148 handlerMap[MSG_CMD_GET_SMSC_OPT] = &MsgGetConfigHandler;
149 handlerMap[MSG_CMD_GET_CB_OPT] = &MsgGetConfigHandler;
150 handlerMap[MSG_CMD_GET_SMS_SEND_OPT] = &MsgGetConfigHandler;
151 handlerMap[MSG_CMD_GET_MMS_SEND_OPT] = &MsgGetConfigHandler;
152 handlerMap[MSG_CMD_GET_MMS_RECV_OPT] = &MsgGetConfigHandler;
153 handlerMap[MSG_CMD_GET_PUSH_MSG_OPT] = &MsgGetConfigHandler;
154 handlerMap[MSG_CMD_GET_VOICE_MSG_OPT] = &MsgGetConfigHandler;
155 handlerMap[MSG_CMD_GET_GENERAL_MSG_OPT] = &MsgGetConfigHandler;
156 handlerMap[MSG_CMD_GET_MSG_SIZE_OPT] = &MsgGetConfigHandler;
158 handlerMap[MSG_CMD_SET_SMSC_OPT] = &MsgSetConfigHandler;
159 handlerMap[MSG_CMD_SET_CB_OPT] = &MsgSetConfigHandler;
160 handlerMap[MSG_CMD_SET_SMS_SEND_OPT] = &MsgSetConfigHandler;
161 handlerMap[MSG_CMD_SET_MMS_SEND_OPT] = &MsgSetConfigHandler;
162 handlerMap[MSG_CMD_SET_MMS_RECV_OPT] = &MsgSetConfigHandler;
163 handlerMap[MSG_CMD_SET_PUSH_MSG_OPT] = &MsgSetConfigHandler;
164 handlerMap[MSG_CMD_SET_VOICE_MSG_OPT] = &MsgSetConfigHandler;
165 handlerMap[MSG_CMD_SET_GENERAL_MSG_OPT] = &MsgSetConfigHandler;
166 handlerMap[MSG_CMD_SET_MSG_SIZE_OPT] = &MsgSetConfigHandler;
168 handlerMap[MSG_CMD_ADD_PUSH_EVENT] = &MsgAddPushEventHandler;
169 handlerMap[MSG_CMD_DELETE_PUSH_EVENT] = &MsgDeletePushEventHandler;
170 handlerMap[MSG_CMD_UPDATE_PUSH_EVENT] = &MsgUpdatePushEventHandler;
171 handlerMap[MSG_CMD_DELETE_MESSAGE_BY_LIST] = &MsgDeleteMessageByListHandler;
172 handlerMap[MSG_CMD_ADD_SIM_MSG] = &MsgAddSimMessageHandler;
173 handlerMap[MSG_CMD_PLG_RESEND_MESSAGE] = &MsgResendMessageHandler;
174 #ifdef FEATURE_SMS_CDMA
175 handlerMap[MSG_CMD_PLG_CHECK_UNIQUENESS] = &MsgCheckUniquenessHandler;
177 handlerMap[MSG_CMD_UPDATE_IMSI] = &MsgUpdateIMSIHandler;
181 MsgTransactionManager::~MsgTransactionManager()
183 /* pthread_cond_init(&retCV, NULL); */ /* = PTHREAD_COND_INITIALIZER; */
187 MsgTransactionManager* MsgTransactionManager::instance()
190 pInstance = new MsgTransactionManager();
195 static void* worker_event_queue(void* arg)
197 MsgTransactionManager::instance()->workerEventQueue();
201 void MsgTransactionManager::run()
203 servSock.open(MSG_SOCKET_PATH);
205 fd_set readfds = servSock.fdSet();
208 MSG_DEBUG("Start Transaction Manager");
210 /* Set Msg FW Ready Flag */
211 if(MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true) != MSG_SUCCESS)
212 MSG_DEBUG("MsgSettingSetBool FAIL : VCONFKEY_MSG_SERVER_READY");
213 MSG_INFO("### VCONFKEY_MSG_SERVER_READY ###");
215 /* running worker for plg task */
217 if (pthread_create(&tv, NULL, &worker_event_queue, NULL) != 0) {
218 THROW(MsgException::SERVER_READY_ERROR, "cannot create thread [%d]", errno);
222 readfds = servSock.fdSet();
223 nfds = servSock.maxFd();
225 MSG_DEBUG("Wait For Select() : nfds %d", nfds);
227 if(select(nfds, &readfds, NULL, NULL, NULL) == -1) {
228 THROW(MsgException::SELECT_ERROR, "select error : %s", g_strerror(errno));
232 for (int i=0 ; i < nfds; i++) {
233 if (FD_ISSET(i, &readfds)) {
234 if (i == servSock.fd()) /* if it is socket connection request */
240 } catch (MsgException& e) {
241 MSG_FATAL("%s", e.what());
242 } catch (exception& e) {
243 MSG_FATAL("%s", e.what());
249 void MsgTransactionManager::write(int fd, const char* buf, int len)
251 servSock.write(fd, buf, len);
255 void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
257 if (pPrxInfo == NULL)
258 THROW(MsgException::SENT_STATUS_ERROR, "Input Parameter is NULL");
260 MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
262 MsgMutexLocker lock(mx);
264 fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
266 if (it == statusCBFdMap.end()) { /* if the status CB is not registered */
267 MSG_DEBUG("No sent_status registered for fd %d", pPrxInfo->listenerFd);
269 sentMsgMap.insert(make_pair(reqId, *pPrxInfo));
274 MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
276 sentmsg_map::iterator it = sentMsgMap.find(reqId);
278 if (it == sentMsgMap.end()) {
279 MSG_DEBUG("No sent status cb found");
283 return &(it->second);
287 void MsgTransactionManager::delProxyInfo(int reqId)
289 MsgMutexLocker lock(mx);
291 sentmsg_map::iterator it = sentMsgMap.find(reqId);
293 if (it == sentMsgMap.end()) {
294 THROW(MsgException::SENT_STATUS_ERROR, "channel info does not exist");
297 sentMsgMap.erase(it);
300 void MsgTransactionManager::workerEventQueue()
302 MSG_CMD_S* pCmd = NULL;
303 int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
304 char* pEventData = NULL;
305 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
312 while (!eventQueue.front(&pCmd)) { /* if no item, wait */
313 MSG_DEBUG("waiting for task");
314 cv.wait(mxQ.pMsgMutex());
316 eventQueue.pop_front(); /* pop it from queue*/
320 MSG_FATAL("pCmd NULL");
324 memcpy (&fd, pCmd->cmdCookie, sizeof(int));
326 MSG_FATAL("fd [%d] < 0", fd);
327 g_free(pCmd); pCmd = NULL;
330 pfHandler = handlerMap[pCmd->cmdType];
332 MSG_FATAL("No handler for %d", pCmd->cmdType);
333 MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData);
335 /* run handler function */
336 eventSize = pfHandler(pCmd, &pEventData);
338 if (eventSize == 0 || pEventData == NULL) {
339 MSG_FATAL("event size[%d] = 0 or event data = NULL", eventSize);
340 MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData);
344 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
345 servSock.write(fd, pEventData, eventSize);
346 g_free(pCmd); pCmd = NULL;
350 void MsgTransactionManager::handleRequest(int fd)
354 MSG_DEBUG("Event from fd %d", fd);
357 unique_ptr<char*, void(*)(char**)> wrap(&buf, unique_ptr_deleter);
359 int ret = servSock.read(fd, &buf, &len);
361 if (ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0) {
362 MSG_DEBUG("Read value [%d]", ret);
367 if (len <= 0 && len >= MSG_MAX_IPC_SIZE)
368 THROW(MsgException::INVALID_RESULT, "read buffer size <= 0 or over max ipc size");
370 char* pEventData = NULL;
371 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
375 /* decoding cmd from APP */
376 MSG_CMD_S* pCmd = (MSG_CMD_S*) buf;
377 MSG_DEBUG("Command Type [%d : %s]", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType));
379 if (pCmd->cmdType > MSG_CMD_NUM)
380 THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined");
382 /* check privilege */
383 /* if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false) { */
384 if (checkPrivilege(fd, pCmd->cmdType) == false) {
385 MSG_DEBUG("No Privilege rule. Not allowed.");
386 #ifdef MSG_CHECK_PRIVILEGE
387 MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_PERMISSION_DENIED, &eventSize, &pEventData);
389 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
390 servSock.write(fd, pEventData, eventSize);
396 /* determine the handler based on pCmd->cmdType */
397 int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
399 switch (pCmd->cmdType) {
400 case MSG_CMD_PLG_SENT_STATUS_CNF:
401 case MSG_CMD_PLG_STORAGE_CHANGE_IND:
402 case MSG_CMD_PLG_INCOMING_MSG_IND:
403 case MSG_CMD_PLG_INCOMING_MMS_CONF:
404 case MSG_CMD_PLG_INCOMING_SYNCML_IND:
405 case MSG_CMD_PLG_INCOMING_LBS_IND:
406 case MSG_CMD_PLG_INIT_SIM_BY_SAT:
407 case MSG_CMD_PLG_INCOMING_PUSH_IND:
408 case MSG_CMD_PLG_INCOMING_CB_IND: {
409 MSG_CMD_S* pCmdDup = (MSG_CMD_S*)calloc(1, len); /* pCmdDup should be freed afterward */
410 if (pCmdDup != NULL) {
411 memcpy(pCmdDup, pCmd, len);
412 memcpy(pCmdDup->cmdCookie, &fd, sizeof(int)); /* Now, cmdCookie keeps fd for return */
414 mxQ.lock(); /* aquire lock before adding cmd */
415 eventQueue.push_back(pCmdDup);
416 cv.signal(); /* wake up worker */
422 pfHandler = handlerMap[pCmd->cmdType];
424 MSG_FATAL("No handler for %d", pCmd->cmdType);
425 MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData);
427 /* run handler function */
428 memcpy (pCmd->cmdCookie, &fd, sizeof(int)); /* Now, cmdCookie keeps fd for return */
429 eventSize = pfHandler(pCmd, &pEventData);
431 if (eventSize == 0 || pEventData == NULL) {
432 MSG_FATAL("event size[%d] = 0 or event data = NULL", eventSize);
433 MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData);
437 MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
439 servSock.write(fd, pEventData, eventSize);
446 /* terminating the socket connection between ipc server and ipc client */
447 void MsgTransactionManager::cleanup(int fd)
451 MsgMutexLocker lock(mx);
455 MSG_DEBUG("fd %d disonnected", fd);
457 /* remove sent msg info for fd */
458 sentmsg_map::iterator sentmsg_it = sentMsgMap.begin();
460 for (; sentmsg_it != sentMsgMap.end(); sentmsg_it++) {
461 if (sentmsg_it->second.listenerFd == fd) {
462 sentmsg_it->second.listenerFd = 0;
463 sentmsg_it->second.handleAddr = 0;
467 /* remove sent status callback for fd */
468 statusCBFdMap.erase(fd);
470 MSG_DEBUG("After erase fd [%d], statusCBFdMap has below.", fd);
471 fd_map::iterator it = statusCBFdMap.begin();
472 for (; it != statusCBFdMap.end(); ++it)
473 MSG_DEBUG("[%d]", it->first);
475 /* remove all newMsgCBs for fd */
476 newmsg_list::iterator newmsg_it = newMsgCBList.begin();
478 while (newmsg_it != newMsgCBList.end()) {
479 if (newmsg_it->listenerFd == fd) {
480 newmsg_it = newMsgCBList.erase(newmsg_it);
486 /* remove all newMMSConfMsgCBs for fd */
487 mmsconf_list::iterator mmsconf_it = newMMSConfMsgCBList.begin();
489 while (mmsconf_it != newMMSConfMsgCBList.end()) {
490 if (mmsconf_it->listenerFd == fd) {
491 mmsconf_it = newMMSConfMsgCBList.erase(mmsconf_it);
497 /* remove all newSyncMLMsgCBs for fd */
498 syncmlmsg_list::iterator syncmlmsg_it = newSyncMLMsgCBList.begin();
500 while (syncmlmsg_it != newSyncMLMsgCBList.end()) {
501 if (syncmlmsg_it->listenerFd == fd) {
502 syncmlmsg_it = newSyncMLMsgCBList.erase(syncmlmsg_it);
508 /* remove all newLBSMsgCBs for fd */
509 lbsmsg_list::iterator lbsmsg_it = newLBSMsgCBList.begin();
511 while (lbsmsg_it != newLBSMsgCBList.end()) {
512 if (lbsmsg_it->listenerFd == fd) {
513 lbsmsg_it = newLBSMsgCBList.erase(lbsmsg_it);
519 /* remove all newPushMsgCBs for fd */
520 pushmsg_list::iterator pushmsg_it = newPushMsgCBList.begin();
522 while (pushmsg_it != newPushMsgCBList.end()) {
523 if (pushmsg_it->listenerFd == fd) {
524 pushmsg_it = newPushMsgCBList.erase(pushmsg_it);
530 /* remove all newCBMsgCBs for fd */
531 cbmsg_list::iterator cbmsg_it = newCBMsgCBList.begin();
532 /*bool bSave = false; */
534 while (cbmsg_it != newCBMsgCBList.end()) {
535 if (cbmsg_it->listenerFd == fd) {
536 cbmsg_it = newCBMsgCBList.erase(cbmsg_it);
538 /*if (cbmsg_it->bsave == true) */
544 /* remove all operationSyncMLMsgCBs for fd */
545 syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin();
547 while (syncmlop_it != operationSyncMLMsgCBList.end()) {
548 if (syncmlop_it->listenerFd == fd) {
549 syncmlop_it = operationSyncMLMsgCBList.erase(syncmlop_it);
555 /* remove storage change callback for fd */
556 storageChangeFdMap.erase(fd);
558 MSG_DEBUG("After erase fd [%d], storageChangeFdMap has below.", fd);
559 it = storageChangeFdMap.begin();
560 for (; it != storageChangeFdMap.end(); ++it)
561 MSG_DEBUG("[%d]", it->first);
563 /* remove report msg incoming callback for fd */
564 reportMsgCBFdMap.erase(fd);
566 MSG_DEBUG("After erase fd [%d], reportMsgCBFdMap has below.", fd);
567 it = reportMsgCBFdMap.begin();
568 for (; it != reportMsgCBFdMap.end(); ++it)
569 MSG_DEBUG("[%d]", it->first);
575 bool MsgTransactionManager::checkPrivilege(int fd, MSG_CMD_TYPE_T CmdType)
577 bool bAllowed = true;
580 char *peer_client = NULL;
581 char *peer_user = NULL;
582 char *peer_session = NULL;
585 if (p_cynara == NULL) {
586 if (this->initCynara() == false) {
587 MSG_ERR("Cynara initialize failed. It will try again when API is called.");
593 ret = cynara_creds_socket_get_client(fd, client_method, &peer_client);
594 if (ret != CYNARA_API_SUCCESS) {
595 MSG_ERR("cynara_creds_socket_get_client() is failed [%d]", ret);
600 ret = cynara_creds_socket_get_user(fd, user_method, &peer_user);
601 if (ret != CYNARA_API_SUCCESS) {
602 MSG_ERR("cynara_creds_socket_get_user() is failed [%d]", ret);
607 ret = cynara_creds_socket_get_pid(fd, &peer_pid);
608 if (ret != CYNARA_API_SUCCESS) {
609 MSG_ERR("cynara_creds_socket_get_pid() is failed [%d]", ret);
614 peer_session = cynara_session_from_pid(peer_pid);
615 if (peer_session == NULL) {
616 MSG_ERR("cynara_session_from_pid() is failed");
622 case MSG_CMD_GET_MSG:
623 case MSG_CMD_COUNT_MSG:
624 case MSG_CMD_COUNT_BY_MSGTYPE:
625 case MSG_CMD_REG_INCOMING_MSG_CB:
626 case MSG_CMD_REG_INCOMING_CB_MSG_CB:
627 case MSG_CMD_REG_INCOMING_PUSH_MSG_CB:
628 case MSG_CMD_REG_SENT_STATUS_CB:
629 case MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB:
630 case MSG_CMD_REG_INCOMING_SYNCML_MSG_CB:
631 case MSG_CMD_REG_INCOMING_LBS_MSG_CB:
632 case MSG_CMD_REG_SYNCML_MSG_OPERATION_CB:
633 case MSG_CMD_REG_REPORT_MSG_INCOMING_CB:
634 case MSG_CMD_GET_CONTACT_COUNT:
635 case MSG_CMD_GET_FOLDERLIST:
636 case MSG_CMD_GET_QUICKPANEL_DATA:
637 case MSG_CMD_GET_MEMSIZE:
638 case MSG_CMD_BACKUP_MESSAGE:
639 case MSG_CMD_REG_STORAGE_CHANGE_CB:
640 case MSG_CMD_GET_REPORT_STATUS:
641 case MSG_CMD_GET_THREAD_ID_BY_ADDRESS:
642 case MSG_CMD_GET_THREAD_INFO:
643 case MSG_CMD_SYNCML_OPERATION:
644 case MSG_CMD_GET_FILTERLIST:
645 case MSG_CMD_GET_FILTER_OPERATION:
646 case MSG_CMD_GET_SMSC_OPT:
647 case MSG_CMD_GET_CB_OPT:
648 case MSG_CMD_GET_SMS_SEND_OPT:
649 case MSG_CMD_GET_MMS_SEND_OPT:
650 case MSG_CMD_GET_MMS_RECV_OPT:
651 case MSG_CMD_GET_PUSH_MSG_OPT:
652 case MSG_CMD_GET_VOICE_MSG_OPT:
653 case MSG_CMD_GET_GENERAL_MSG_OPT:
654 case MSG_CMD_GET_MSG_SIZE_OPT: {
655 ret = cynara_check(p_cynara, peer_client, peer_session, peer_user,
656 "http://tizen.org/privilege/message.read");
657 if (ret != CYNARA_API_ACCESS_ALLOWED) {
658 MSG_INFO("privilege [read] not allowd : [%d]", ret);
663 case MSG_CMD_SUBMIT_REQ:
664 case MSG_CMD_SET_CB_OPT:
665 case MSG_CMD_ADD_PUSH_EVENT:
666 case MSG_CMD_DELETE_PUSH_EVENT:
667 case MSG_CMD_UPDATE_PUSH_EVENT:
668 case MSG_CMD_ADD_MSG:
669 case MSG_CMD_ADD_SYNCML_MSG:
670 case MSG_CMD_UPDATE_MSG:
671 case MSG_CMD_UPDATE_READ:
672 case MSG_CMD_UPDATE_PROTECTED:
673 case MSG_CMD_DELETE_MSG:
674 case MSG_CMD_DELALL_MSGINFOLDER:
675 case MSG_CMD_MOVE_MSGTOFOLDER:
676 case MSG_CMD_MOVE_MSGTOSTORAGE:
677 case MSG_CMD_DELETE_THREADMESSAGELIST:
678 case MSG_CMD_ADD_FOLDER:
679 case MSG_CMD_UPDATE_FOLDER:
680 case MSG_CMD_DELETE_FOLDER:
681 case MSG_CMD_RESET_DB:
682 case MSG_CMD_RESTORE_MESSAGE:
683 case MSG_CMD_DELETE_MESSAGE_BY_LIST:
684 case MSG_CMD_UPDATE_THREAD_READ:
685 case MSG_CMD_ADD_FILTER:
686 case MSG_CMD_UPDATE_FILTER:
687 case MSG_CMD_DELETE_FILTER:
688 case MSG_CMD_SET_FILTER_OPERATION:
689 case MSG_CMD_SET_FILTER_ACTIVATION:
690 case MSG_CMD_SET_SMSC_OPT:
691 case MSG_CMD_SET_SMS_SEND_OPT:
692 case MSG_CMD_SET_MMS_SEND_OPT:
693 case MSG_CMD_SET_MMS_RECV_OPT:
694 case MSG_CMD_SET_PUSH_MSG_OPT:
695 case MSG_CMD_SET_VOICE_MSG_OPT:
696 case MSG_CMD_SET_GENERAL_MSG_OPT:
697 case MSG_CMD_SET_MSG_SIZE_OPT: {
698 ret = cynara_check(p_cynara, peer_client, peer_session, peer_user,
699 "http://tizen.org/privilege/message.write");
700 if (ret != CYNARA_API_ACCESS_ALLOWED) {
701 MSG_INFO("privilege [write] not allowd : [%d]", ret);
709 MSG_FREE(peer_client);
711 MSG_FREE(peer_session);
717 void MsgTransactionManager::setSentStatusCB(int listenerFd)
720 THROW(MsgException::INVALID_PARAM, "InParam Error: listenerFd %d", listenerFd);
722 statusCBFdMap[listenerFd] = true;
726 void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo)
729 MSG_FATAL("cbinfo NULL");
733 MsgMutexLocker lock(mx);
735 newmsg_list::iterator it = newMsgCBList.begin();
737 for (; it != newMsgCBList.end(); it++) {
738 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (it->port == pCbInfo->port)) {
739 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d, port %d", it->listenerFd, it->msgType, it->port);
744 newMsgCBList.push_back(*pCbInfo);
748 void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbInfo)
751 MSG_FATAL("cbinfo NULL");
755 MsgMutexLocker lock(mx);
757 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
759 for (; it != newMMSConfMsgCBList.end(); it++) {
760 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (!strncmp(it->appId, pCbInfo->appId, MAX_MMS_JAVA_APPID_LEN))) {
761 MSG_DEBUG("Duplicated MMSConfMessageCB info fd:%d, mType:%d, appId:%s", it->listenerFd, it->msgType, it->appId);
766 newMMSConfMsgCBList.push_back(*pCbInfo);
770 void MsgTransactionManager::setPushMsgCB(MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCbInfo)
773 MSG_FATAL("cbinfo NULL");
777 MsgMutexLocker lock(mx);
779 pushmsg_list::iterator it = newPushMsgCBList.begin();
781 for (; it != newPushMsgCBList.end(); it++) {
782 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && !strncmp(it->appId, pCbInfo->appId, MAX_WAPPUSH_ID_LEN)) {
783 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
788 newPushMsgCBList.push_back(*pCbInfo);
791 void MsgTransactionManager::setCBMsgCB(MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCbInfo)
795 MSG_FATAL("cbinfo NULL");
799 MsgMutexLocker lock(mx);
801 cbmsg_list::iterator it = newCBMsgCBList.begin();
803 for (; it != newCBMsgCBList.end(); it++) {
804 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType)) {
805 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
809 MSG_DEBUG("bSave : [%d]", pCbInfo->bsave);
812 if(MsgSettingSetBool(CB_SAVE, pCbInfo->bsave) != MSG_SUCCESS)
813 MSG_DEBUG("MsgSettingSetBool FAIL: CB_SAVE");
817 newCBMsgCBList.push_back(*pCbInfo);
823 void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo)
826 MSG_FATAL("cbinfo NULL");
830 MsgMutexLocker lock(mx);
832 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
834 for (; it != newSyncMLMsgCBList.end(); it++) {
835 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType)) {
836 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
841 newSyncMLMsgCBList.push_back(*pCbInfo);
845 void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbInfo)
848 MSG_FATAL("cbinfo NULL");
852 MsgMutexLocker lock(mx);
854 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
856 for (; it != newLBSMsgCBList.end(); it++) {
857 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType)) {
858 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
863 newLBSMsgCBList.push_back(*pCbInfo);
867 void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId)
870 MSG_FATAL("trId NULL");
874 javamms_list::iterator it;
876 for (it = javaMMSList.begin(); it != javaMMSList.end(); it++) {
877 if (!strcmp(it->id, pTrId->id)) {
878 MSG_SEC_DEBUG("Duplicated javaMMS transaction Id:%s", it->id);
883 javaMMSList.push_back(*pTrId);
887 void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbInfo)
890 MSG_FATAL("cbinfo NULL");
894 MsgMutexLocker lock(mx);
896 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
898 for (; it != operationSyncMLMsgCBList.end(); it++) {
899 if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType)) {
900 MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
905 operationSyncMLMsgCBList.push_back(*pCbInfo);
909 void MsgTransactionManager::setStorageChangeCB(int listenerFd)
912 THROW(MsgException::INVALID_PARAM, "InParam Error: listenerFd %d", listenerFd);
914 MsgMutexLocker lock(mx);
916 storageChangeFdMap[listenerFd] = true;
920 void MsgTransactionManager::setReportMsgCB(int listenerFd)
923 THROW(MsgException::INVALID_PARAM, "InParam Error: listenerFd %d", listenerFd);
925 MsgMutexLocker lock(mx);
927 reportMsgCBFdMap[listenerFd] = true;
931 javamms_list& MsgTransactionManager::getJavaMMSList()
937 void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo)
941 if ((msgInfo->msgPort.valid == true) && (msgInfo->msgPort.dstPort == MSG_LBS_PORT)) {
942 MSG_DEBUG("Message for LBS.");
944 if (msgInfo->bTextSms == false) {
945 MSG_DEBUG("msgInfo->bTextSms == false");
949 char* pFileData = NULL;
950 unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
952 if (MsgOpenAndReadFile(msgInfo->msgData, &pFileData, &fileSize) == true)
953 MsgLbsSms(pFileData, fileSize);
955 MSG_DEBUG("MsgOpenAndReadFile failed.");
957 MsgLbsSms(msgInfo->msgText, (int)msgInfo->dataSize);
962 char* pEventData = NULL;
963 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
965 char* encodedData = NULL;
966 unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
967 int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData);
969 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData));
971 MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
973 MsgMutexLocker lock(mx);
975 newmsg_list::iterator it = newMsgCBList.begin();
977 for (; it != newMsgCBList.end(); it++) {
978 MSG_DEBUG("fd %d dstport %d", it->listenerFd, it->port);
980 if ((msgInfo->msgPort.valid == false) && (it->port == 0)) {
981 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
982 write(it->listenerFd, pEventData, eventSize);
983 } else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort)) {
984 MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd);
985 write(it->listenerFd, pEventData, eventSize);
993 void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData)
997 char* pEventData = NULL;
998 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1000 char* encodedData = NULL;
1001 unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
1002 int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData);
1004 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
1006 MsgMutexLocker lock(mx);
1008 mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
1010 for (; it != newMMSConfMsgCBList.end(); it++) {
1011 MSG_DEBUG("fd:%d appId:%s", it->listenerFd, it->appId);
1013 if (mmsRecvData->msgAppId.valid == true) {
1014 if (!strcmp(it->appId, mmsRecvData->msgAppId.appId)) {
1015 MSG_DEBUG("Send incoming java msg to listener %d", it->listenerFd);
1016 write(it->listenerFd, pEventData, eventSize);
1019 if (strlen(it->appId) <= 0) {
1020 MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
1021 write(it->listenerFd, pEventData, eventSize);
1030 void MsgTransactionManager::broadcastPushMsgCB(const msg_error_t err, const MSG_PUSH_MESSAGE_DATA_S *pushData)
1034 char* pEventData = NULL;
1035 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1037 int eventSize = MsgMakeEvent(pushData, sizeof(MSG_PUSH_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, err, (void**)(&pEventData));
1039 MsgMutexLocker lock(mx);
1041 pushmsg_list::iterator it = newPushMsgCBList.begin();
1043 for (; it != newPushMsgCBList.end(); it++) {
1044 MSG_DEBUG("registered_appid : %s, incoming_appid: %s", it->appId, pushData->pushAppId);
1045 if (!strcmp(it->appId, pushData->pushAppId)) {
1046 MSG_DEBUG("Send incoming Push information to listener %d", it->listenerFd);
1047 write(it->listenerFd, pEventData, eventSize);
1054 void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg, msg_message_id_t cbMsgId)
1058 char* pEventData = NULL;
1059 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1061 int eventSize = MsgMakeEvent(cbMsg, sizeof(MSG_CB_MSG_S), MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)(&pEventData));
1063 MsgMutexLocker lock(mx);
1065 cbmsg_list::iterator it = newCBMsgCBList.begin();
1067 for (; it != newCBMsgCBList.end(); it++) {
1068 MSG_DEBUG("Send incoming CB information to listener %d", it->listenerFd);
1069 write(it->listenerFd, pEventData, eventSize);
1072 /* Send system event */
1074 b = bundle_create();
1076 bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_CB);
1077 char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
1078 snprintf(msgId, sizeof(msgId), "%u", cbMsgId);
1079 bundle_add_str(b, EVT_KEY_MSG_ID, msgId);
1080 eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
1087 void MsgTransactionManager::broadcastSyncMLMsgCB(const msg_error_t err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData)
1091 char* pEventData = NULL;
1092 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1094 int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
1096 MsgMutexLocker lock(mx);
1098 syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
1100 for (; it != newSyncMLMsgCBList.end(); it++) {
1101 MSG_DEBUG("Send incoming SyncML information to listener %d", it->listenerFd);
1102 write(it->listenerFd, pEventData, eventSize);
1109 void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_LBS_MESSAGE_DATA_S *lbsData)
1114 char* pEventData = NULL;
1115 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1117 int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
1119 MsgMutexLocker lock(mx);
1121 lbsmsg_list::iterator it = newLBSMsgCBList.begin();
1123 for (; it != newLBSMsgCBList.end(); it++) {
1124 MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd);
1125 write(it->listenerFd, pEventData, eventSize);
1128 MsgLbsWapPush(lbsData->pushHeader, lbsData->pushBody, lbsData->pushBodyLen);
1134 void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const msg_error_t err, const int msgId, const int extId)
1138 char* pEventData = NULL;
1139 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1141 char* encodedData = NULL;
1142 unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
1144 /* Encoding Storage Change Data */
1145 int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData);
1147 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
1149 MsgMutexLocker lock(mx);
1151 syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
1153 for( ; it != operationSyncMLMsgCBList.end() ; it++ ) {
1154 MSG_DEBUG("Send SyncML operation to listener %d", it->listenerFd);
1155 write(it->listenerFd, pEventData, eventSize);
1162 void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList)
1166 if(pMsgIdList == NULL) {
1167 MSG_DEBUG("pMsgIdList is NULL.");
1171 MSG_DEBUG("storageChangeType [%d]", storageChangeType);
1175 char* pEventData = NULL;
1176 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1178 char* encodedData = NULL;
1179 unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
1181 /* Encoding Storage Change Data */
1182 dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData);
1184 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
1186 MsgMutexLocker lock(mx);
1188 fd_map::iterator it = storageChangeFdMap.begin();
1190 for (; it != storageChangeFdMap.end(); it++) {
1191 MSG_DEBUG("Send Storage Change Callback to listener %d", it->first);
1192 write(it->first, pEventData, eventSize);
1199 void MsgTransactionManager::broadcastReportMsgCB(const msg_error_t err, const msg_report_type_t reportMsgType, const MSG_MESSAGE_INFO_S *pMsgInfo)
1203 if(pMsgInfo == NULL) {
1204 MSG_DEBUG("pMsgInfo is NULL.");
1208 MSG_DEBUG("reportMsgType [%d]", reportMsgType);
1212 char* pEventData = NULL;
1213 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
1215 char* encodedData = NULL;
1216 unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
1218 /* Encoding Storage Change Data */
1219 dataSize = MsgEncodeReportMsgData(reportMsgType, pMsgInfo, &encodedData);
1221 int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND, err, (void**)(&pEventData));
1223 MsgMutexLocker lock(mx);
1225 fd_map::iterator it = reportMsgCBFdMap.begin();
1227 for (; it != reportMsgCBFdMap.end(); it++) {
1228 MSG_DEBUG("Send Report Message Incoming Callback to listener %d", it->first);
1229 write(it->first, pEventData, eventSize);
1236 bool MsgTransactionManager::initCynara()
1240 ret = cynara_initialize(&p_cynara, NULL);
1242 if (ret == CYNARA_API_SUCCESS) {
1243 MSG_INFO("cynara_initialize() is successful");
1245 MSG_INFO("cynara_initialize() is failed [%d]", ret);
1249 ret = cynara_creds_get_default_client_method(&client_method);
1250 if (ret != CYNARA_API_SUCCESS) {
1251 MSG_ERR("cynara_creds_get_default_client_method() is failed [%d]", ret);
1255 ret = cynara_creds_get_default_user_method(&user_method);
1256 if (ret != CYNARA_API_SUCCESS) {
1257 MSG_ERR("cynara_creds_get_default_user_method() is failed [%d]", ret);
1265 void MsgTransactionManager::finishCynara()
1269 ret = cynara_finish(p_cynara);
1271 if (ret == CYNARA_API_SUCCESS) {
1272 MSG_INFO("cynara_finish() is successful");
1274 MSG_INFO("cynara_finish() is failed [%d]", ret);