2 * Copyright 2012-2013 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://floralicense.org
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.msgPort.valid)
418 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
420 else if (msgInfo.folderId == MSG_SPAMBOX_ID) {
421 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
424 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
431 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
434 msg_error_t err = MSG_SUCCESS;
437 MSG_MESSAGE_INFO_S msgInfo = {0};
438 msg_request_id_t reqID;
440 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
441 memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_request_id_t));
443 MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
444 MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
446 // For Storage change callback
447 msg_id_list_s msgIdList;
448 msg_message_id_t msgIds[1];
449 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
451 msgIdList.nCount = 1;
452 msgIds[0] = msgInfo.msgId;
453 msgIdList.msgIdList = msgIds;
455 err = MsgStoGetAddrInfo(msgInfo.msgId, &(msgInfo.addressList[0]));
457 if (err == MSG_SUCCESS) {
458 MSG_DEBUG("MmsStoGetAddrInfo() success.");
459 msgInfo.nAddressCnt = 1;
461 MSG_DEBUG("MmsStoGetAddrInfo() fail.");
464 if(msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
466 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
468 if(err != MSG_SUCCESS)
471 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
473 if (pMmsRecvData->msgAppId.valid == true) {
474 MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
476 msgInfo.bTextSms = true;
477 msgInfo.dataSize = 0 ;
478 memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
481 eventsize = MsgMakeEvent(&msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, msgInfo.networkStatus, (void**)ppEvent);
483 // broadcast to listener threads, here
484 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
485 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
486 } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
487 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
489 // when no sent status cb is found (in case of mobile tracker)
491 MSG_DEBUG("prxInfo is NULL");
492 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
494 // No need to update javaMMS sent messages
495 javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
496 javamms_list::iterator it = listenerList.begin();
498 MSG_DEBUG("listenerList size:%d ",listenerList.size());
500 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
501 for ( ; it != listenerList.end() ; it++) {
502 if (strstr(it->pduFileName, "JAVA")) {
503 MSG_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
504 MsgDeleteFile(it->pduFileName); // ipc
505 listenerList.erase(it);
506 goto __BYPASS_UPDATE;
510 //msgData has MMS_RECV_DATA_S
511 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
513 for ( ; it != listenerList.end() ; it++) {
514 if(!strcmp(it->id, pMmsRecvData->szTrID)) {
515 MSG_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
516 MsgDeleteFile(it->pduFileName); // ipc
517 listenerList.erase(it);
518 goto __BYPASS_UPDATE;
524 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
526 if(err != MSG_SUCCESS)
530 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
531 MSG_DEBUG("message-dialog: send fail");
532 MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED);
534 MSG_DEBUG("message-dialog: send success");
535 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT);
537 MSG_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
538 MsgAddPhoneLog(&msgInfo);
542 if (prxInfo->handleAddr == 0) {
543 // just making data which will be passed to plugin. it indicates "handling evt success"
544 MsgTransactionManager::instance()->delProxyInfo(reqID);
546 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
549 unsigned int ret[3] = {0}; //3// reqid, status, object
552 ret[1] = msgInfo.networkStatus;
553 ret[2] = prxInfo->handleAddr;
555 // Make Event Data for APP
556 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
558 // Send to listener thread, here
559 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
561 MsgTransactionManager::instance()->delProxyInfo(reqID);
564 msgInfo.bTextSms = true;
565 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
572 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
579 if (!pCmd || !ppEvent)
580 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
582 MSG_PUSH_MESSAGE_DATA_S pushData;
583 memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
585 // Get Incoming Message
586 memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
590 // broadcast to listener threads, here
591 MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
594 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
600 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
604 msg_error_t err = MSG_SUCCESS;
608 if (!pCmd || !ppEvent)
609 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
611 // Get Incoming Message
613 memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
615 memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
617 msg_id_list_s msgIdList;
618 msg_message_id_t msgIds[1];
619 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
621 MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg);
624 MsgSettingGetBool(CB_SAVE, &bSave);
626 if(bSave && cbMsg.type!= MSG_ETWS_SMS) {
627 msgIdList.nCount = 1;
628 msgIds[0] = (msg_message_id_t)cbMsg.messageId;
629 msgIdList.msgIdList = msgIds;
630 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
632 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
639 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
642 if (!pCmd || !ppEvent)
643 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
645 MSG_SYNCML_MESSAGE_DATA_S syncMLData;
646 memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
648 // Get Incoming Message
649 memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
653 // broadcast to listener threads, here
654 MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
657 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
663 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
668 if (!pCmd || !ppEvent)
669 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
671 MSG_LBS_MESSAGE_DATA_S lbsData;
672 memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
674 // Get Incoming Message
675 memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
677 // broadcast to listener threads, here
678 MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
681 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
687 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
689 msg_error_t err = MSG_SUCCESS;
691 char* encodedData = NULL;
692 AutoPtr<char> buf(&encodedData);
696 msg_message_id_t msgId = 0;
700 if (!pCmd || !ppEvent)
701 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
704 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
705 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(int));
707 err = MsgStoGetSyncMLExtId(msgId, &extId);
709 if (err == MSG_SUCCESS)
711 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
713 // broadcast to listener threads, here
714 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
718 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
721 // Make Event Data to Client
722 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
728 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
731 if (!pCmd || !ppEvent)
732 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
734 msg_storage_change_type_t storageChangeType;
736 MSG_MESSAGE_INFO_S msgInfo;
737 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
739 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
740 memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t));
742 char* encodedData = NULL;
743 AutoPtr<char> buf(&encodedData);
747 MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
749 // broadcast to listener threads, here
750 msg_id_list_s msgIdList;
751 msg_message_id_t msgIds[1];
752 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
754 msgIdList.nCount = 1;
755 msgIds[0] = msgInfo.msgId;
756 msgIdList.msgIdList = msgIds;
758 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
760 // Make Event Data to Client
761 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);