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.
20 #include "MsgException.h"
21 #include "MsgUtilFile.h"
22 #include "MsgContact.h"
23 #include "MsgSoundPlayer.h"
24 #include "MsgGconfWrapper.h"
25 #include "MsgNotificationWrapper.h"
26 #include "MsgUtilFunction.h"
27 #include "MsgSubmitHandler.h"
28 #include "MsgDeliverHandler.h"
29 #include "MsgStorageHandler.h"
30 #include "MsgTransManager.h"
31 #include "MsgPluginManager.h"
32 #include "MsgCmdHandler.h"
33 #include "MsgUtilStorage.h"
37 /*==================================================================================================
38 FUNCTION IMPLEMENTATION
39 ==================================================================================================*/
40 int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
42 msg_error_t err = MSG_SUCCESS;
47 MSG_REQUEST_INFO_S reqInfo = {0,};
48 MSG_PROXY_INFO_S proxyInfo = {0,};
50 // Get Message Request
51 memcpy(&reqInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_REQUEST_INFO_S));
53 // Storing Request ID, Proxy Info for Sent Status CNF
54 memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)), sizeof(MSG_PROXY_INFO_S));
56 if (reqInfo.msgInfo.msgId > 0)
60 err = MsgSubmitReq(&reqInfo, false);
62 if (err == MSG_SUCCESS){
63 MSG_DEBUG("Command Handle Success : MsgSubmitReq()");
65 MSG_DEBUG("Command Handle Fail : MsgSubmitReq()");
68 int reqId = reqInfo.reqId;
69 proxyInfo.sentMsgId = reqInfo.msgInfo.msgId;
71 MSG_DEBUG("REQID: %d, MSGID: %d", reqId, proxyInfo.sentMsgId);
73 if (reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE) {
74 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
75 } else if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE) {
76 // Retrieve MMS shall not be kept in sentMsg
77 if ((reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) ||
78 (reqInfo.msgInfo.msgType.subType == MSG_FORWARD_MMS) ||
79 (reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS))
80 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
83 // keep transaction Id list for distinguish java MMS sent msg when sendconf received
84 if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE &&
85 reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS) {
86 MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S trId={0};
87 memcpy(&trId.id, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)+sizeof(MSG_PROXY_INFO_S)), MMS_TR_ID_LEN);
90 pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_");
91 strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE);
93 MSG_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData);
95 MsgTransactionManager* tm = MsgTransactionManager::instance();
96 tm->setJavaMMSList(&trId);
100 eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
102 /* reject_msg_support */
103 if(((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) &&
104 (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE)))
105 err = MsgStoDeleteMessage(reqInfo.msgInfo.msgId, true);
107 /** send storage CB */
108 msg_id_list_s msgIdList;
109 msg_message_id_t msgIds[1];
110 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
112 msgIdList.nCount = 1;
113 msgIds[0] = reqInfo.msgInfo.msgId;
114 msgIdList.msgIdList = msgIds;
116 if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && bNewMsg && reqInfo.msgInfo.msgPort.valid == false) {
117 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
118 } else if (err == MSG_ERR_SECURITY_ERROR) { // Case of MDM enabled, it returns MSG_ERR_SECURITY_ERROR.
119 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
121 MSG_DEBUG("No need to broadcast storage change CB");
128 int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
130 msg_error_t err = MSG_SUCCESS;
135 msg_request_id_t* reqId = (msg_request_id_t*)pCmd->cmdData;
138 err = MsgCancelReq(*reqId);
140 if (err == MSG_SUCCESS)
142 MSG_DEBUG("Command Handle Success : MsgSubCancelReq()");
146 MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()");
150 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent);
156 int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
159 if( !pCmd || !ppEvent)
160 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
162 // Get Message Request
163 int listenerFd = *((int*) pCmd->cmdData);
164 MSG_DEBUG("Registering sent status CB for %d", listenerFd);
166 // storing dst fd in list
167 MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
170 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
176 int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
179 if( !pCmd || !ppEvent)
180 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
182 // Get Message Request
183 MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData;
184 MSG_DEBUG("Registering incoming SMS CB for fd %d mType %d port %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->port);
186 // storing dst fd in list
187 MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
190 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
196 int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
199 if( !pCmd || !ppEvent)
200 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
202 // Get Message Request
203 MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData;
204 MSG_DEBUG("Registering incoming MMS Conf CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
206 // storing dst fd in list
207 MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
210 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
215 int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
218 if( !pCmd || !ppEvent)
219 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
221 // Get Message Request
222 MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData;
223 MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
225 // storing dst fd in list
226 MsgTransactionManager::instance()->setPushMsgCB(pCmdData);
229 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
234 int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
237 if( !pCmd || !ppEvent)
238 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
240 // Get Message Request
241 MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData;
242 MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d", pCmdData->listenerFd, pCmdData->msgType);
244 // storing dst fd in list
245 MsgTransactionManager::instance()->setCBMsgCB(pCmdData);
248 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
254 int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
257 if( !pCmd || !ppEvent)
258 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
260 // Get Message Request
261 MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData;
262 MSG_DEBUG("Registering incoming Sync ML Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
264 // storing dst fd in list
265 MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
268 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
274 int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
277 if( !pCmd || !ppEvent)
278 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
280 // Get Message Request
281 MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData;
282 MSG_DEBUG("Registering incoming LBS Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
284 // storing dst fd in list
285 MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
288 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
294 int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
297 if( !pCmd || !ppEvent)
298 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
300 // Get Message Request
301 MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData;
302 MSG_DEBUG("Registering SyncML Msg ooperation CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
304 // storing dst fd in list
305 MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
308 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
314 int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
317 if( !pCmd || !ppEvent)
318 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
320 // Get Message Request
321 int listenerFd = *((int*) pCmd->cmdData);
322 MSG_DEBUG("Registering storage change CB for %d", listenerFd);
324 // storing dst fd in list
325 MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
328 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
334 int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
337 if (!pCmd || !ppEvent)
338 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
340 // Get Message Request
341 MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
343 MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
345 // storing dst fd in list
346 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
348 // when no sent status cb is found (in case of mobile tracker)
351 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
354 MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
356 // if APP send and quit(not exist at this time), don't send the data up.
357 if (prxInfo->handleAddr == 0)
359 // just making data which will be passed to plugin. it indicates "handling evt success"
360 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
362 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
365 unsigned int ret[3] = {0}; //3// reqid, status, object
367 ret[0] = pStatus->reqId;
368 ret[1] = pStatus->status;
369 ret[2] = prxInfo->handleAddr;
371 // Make Event Data for APP
372 int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
374 // Send to listener thread, here
375 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
377 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
383 int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
387 msg_error_t err = MSG_SUCCESS;
389 bool sendNoti = true;
392 if (!pCmd || !ppEvent)
393 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
395 // Get Incoming Message
396 MSG_MESSAGE_INFO_S msgInfo;
397 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
399 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
402 err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
404 // broadcast to listener threads, here
405 msg_id_list_s msgIdList;
406 msg_message_id_t msgIds[1];
407 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
409 msgIdList.nCount = 1;
410 msgIds[0] = msgInfo.msgId;
411 msgIdList.msgIdList = msgIds;
413 if (sendNoti == true) {
414 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
415 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
416 } else if (msgInfo.folderId == MSG_SPAMBOX_ID) {
417 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
420 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
427 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
430 msg_error_t err = MSG_SUCCESS;
433 MSG_MESSAGE_INFO_S msgInfo = {0};
434 msg_request_id_t reqID;
436 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
437 memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_request_id_t));
439 MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
440 MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
442 // For Storage change callback
443 msg_id_list_s msgIdList;
444 msg_message_id_t msgIds[1];
445 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
447 msgIdList.nCount = 1;
448 msgIds[0] = msgInfo.msgId;
449 msgIdList.msgIdList = msgIds;
451 err = MsgStoGetAddrInfo(msgInfo.msgId, &(msgInfo.addressList[0]));
453 if (err == MSG_SUCCESS) {
454 MSG_DEBUG("MmsStoGetAddrInfo() success.");
455 msgInfo.nAddressCnt = 1;
457 MSG_DEBUG("MmsStoGetAddrInfo() fail.");
460 if(msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
462 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
464 if(err != MSG_SUCCESS)
467 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
469 if (pMmsRecvData->msgAppId.valid == true) {
470 MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
472 msgInfo.bTextSms = true;
473 msgInfo.dataSize = 0 ;
474 memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
477 eventsize = MsgMakeEvent(&msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, msgInfo.networkStatus, (void**)ppEvent);
479 // broadcast to listener threads, here
480 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
481 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
482 } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
483 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
485 // when no sent status cb is found (in case of mobile tracker)
487 MSG_DEBUG("prxInfo is NULL");
488 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
490 // No need to update javaMMS sent messages
491 javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
492 javamms_list::iterator it = listenerList.begin();
494 MSG_DEBUG("listenerList size:%d ",listenerList.size());
496 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
497 for ( ; it != listenerList.end() ; it++) {
498 if (strstr(it->pduFileName, "JAVA")) {
499 MSG_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
500 MsgDeleteFile(it->pduFileName); // ipc
501 listenerList.erase(it);
502 goto __BYPASS_UPDATE;
506 //msgData has MMS_RECV_DATA_S
507 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
509 for ( ; it != listenerList.end() ; it++) {
510 if(!strcmp(it->id, pMmsRecvData->szTrID)) {
511 MSG_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
512 MsgDeleteFile(it->pduFileName); // ipc
513 listenerList.erase(it);
514 goto __BYPASS_UPDATE;
520 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
522 if(err != MSG_SUCCESS)
526 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
527 MSG_DEBUG("message-dialog: send fail");
528 MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED);
530 MSG_DEBUG("message-dialog: send success");
531 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT);
533 MSG_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
534 MsgAddPhoneLog(&msgInfo);
538 if (prxInfo->handleAddr == 0) {
539 // just making data which will be passed to plugin. it indicates "handling evt success"
540 MsgTransactionManager::instance()->delProxyInfo(reqID);
542 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
545 unsigned int ret[3] = {0}; //3// reqid, status, object
548 ret[1] = msgInfo.networkStatus;
549 ret[2] = prxInfo->handleAddr;
551 // Make Event Data for APP
552 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
554 // Send to listener thread, here
555 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
557 MsgTransactionManager::instance()->delProxyInfo(reqID);
560 msgInfo.bTextSms = true;
561 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
568 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
572 if (!pCmd || !ppEvent)
573 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
575 MSG_PUSH_MESSAGE_DATA_S pushData;
576 memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
578 // Get Incoming Message
579 memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
583 // broadcast to listener threads, here
584 MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
587 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
593 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
597 msg_error_t err = MSG_SUCCESS;
601 if (!pCmd || !ppEvent)
602 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
604 // Get Incoming Message
606 memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
608 memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
610 msg_id_list_s msgIdList;
611 msg_message_id_t msgIds[1];
612 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
614 MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg);
617 MsgSettingGetBool(CB_SAVE, &bSave);
619 if(bSave && cbMsg.type!= MSG_ETWS_SMS) {
620 msgIdList.nCount = 1;
621 msgIds[0] = (msg_message_id_t)cbMsg.messageId;
622 msgIdList.msgIdList = msgIds;
623 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
625 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
632 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
635 if (!pCmd || !ppEvent)
636 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
638 MSG_SYNCML_MESSAGE_DATA_S syncMLData;
639 memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
641 // Get Incoming Message
642 memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
646 // broadcast to listener threads, here
647 MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
650 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
656 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
661 if (!pCmd || !ppEvent)
662 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
664 MSG_LBS_MESSAGE_DATA_S lbsData;
665 memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
667 // Get Incoming Message
668 memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
670 // broadcast to listener threads, here
671 MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
674 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
680 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
682 msg_error_t err = MSG_SUCCESS;
684 char* encodedData = NULL;
685 AutoPtr<char> buf(&encodedData);
689 msg_message_id_t msgId = 0;
693 if (!pCmd || !ppEvent)
694 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
697 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
698 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(int));
700 err = MsgStoGetSyncMLExtId(msgId, &extId);
702 if (err == MSG_SUCCESS)
704 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
706 // broadcast to listener threads, here
707 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
711 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
714 // Make Event Data to Client
715 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
721 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
724 if (!pCmd || !ppEvent)
725 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
727 msg_storage_change_type_t storageChangeType;
729 MSG_MESSAGE_INFO_S msgInfo;
730 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
732 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
733 memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t));
735 char* encodedData = NULL;
736 AutoPtr<char> buf(&encodedData);
740 MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
742 // broadcast to listener threads, here
743 msg_id_list_s msgIdList;
744 msg_message_id_t msgIds[1];
745 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
747 msgIdList.nCount = 1;
748 msgIds[0] = msgInfo.msgId;
749 msgIdList.msgIdList = msgIds;
751 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
753 // Make Event Data to Client
754 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);