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.
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 "MsgUtilStorage.h"
34 #include "MsgCmdHandler.h"
35 #include "MsgDevicedWrapper.h"
38 /*==================================================================================================
39 FUNCTION IMPLEMENTATION
40 ==================================================================================================*/
41 int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
43 msg_error_t err = MSG_SUCCESS;
48 MSG_REQUEST_INFO_S reqInfo = {0,};
49 MSG_PROXY_INFO_S proxyInfo = {0,};
51 reqInfo.msgInfo.addressList = NULL;
52 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList);
54 // Get Message Request
55 memcpy(&reqInfo.reqId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t));
57 // Storing Request ID, Proxy Info for Sent Status CNF
58 memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)), sizeof(MSG_PROXY_INFO_S));
60 MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo);
62 if (reqInfo.msgInfo.msgId > 0)
66 err = MsgSubmitReq(&reqInfo, false);
68 if (err == MSG_SUCCESS){
69 MSG_DEBUG("Command Handle Success : MsgSubmitReq()");
71 MSG_DEBUG("Command Handle Fail : MsgSubmitReq()");
74 int reqId = reqInfo.reqId;
75 proxyInfo.sentMsgId = reqInfo.msgInfo.msgId;
77 MSG_DEBUG("REQID: %d, MSGID: %d", reqId, proxyInfo.sentMsgId);
79 if (reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE) {
80 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
81 } else if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE) {
82 // Retrieve MMS shall not be kept in sentMsg
83 if ((reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) ||
84 (reqInfo.msgInfo.msgType.subType == MSG_FORWARD_MMS) ||
85 (reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS))
86 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
89 // keep transaction Id list for distinguish java MMS sent msg when sendconf received
90 if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE &&
91 reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS) {
92 MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S trId={0};
93 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);
96 pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_");
97 strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE);
99 MSG_SEC_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData);
101 MsgTransactionManager* tm = MsgTransactionManager::instance();
102 tm->setJavaMMSList(&trId);
106 eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
108 /* reject_msg_support */
109 if (((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) &&
110 (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE)))
111 err = MsgStoDeleteMessage(reqInfo.msgInfo.msgId, true);
113 /** send storage CB */
114 msg_id_list_s msgIdList;
115 msg_message_id_t msgIds[1];
116 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
118 msgIdList.nCount = 1;
119 msgIds[0] = reqInfo.msgInfo.msgId;
120 msgIdList.msgIdList = msgIds;
122 if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && reqInfo.msgInfo.msgPort.valid == false) {
124 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
126 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
129 MSG_DEBUG("No need to broadcast storage change CB");
132 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
134 MsgStoAutoDeleteConversation(reqInfo.msgInfo.threadId, &msgIdList);
135 if (msgIdList.msgIdList)
137 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
138 delete [] (char*)msgIdList.msgIdList;
145 int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
147 msg_error_t err = MSG_SUCCESS;
152 msg_request_id_t* reqId = (msg_request_id_t*)pCmd->cmdData;
155 err = MsgCancelReq(*reqId);
157 if (err == MSG_SUCCESS)
159 MSG_DEBUG("Command Handle Success : MsgSubCancelReq()");
163 MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()");
167 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent);
173 int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
176 if (!pCmd || !ppEvent)
177 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
179 // Get Message Request
180 int listenerFd = *((int*) pCmd->cmdData);
181 MSG_DEBUG("Registering sent status CB for %d", listenerFd);
183 // storing dst fd in list
184 MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
187 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
193 int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
196 if (!pCmd || !ppEvent)
197 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
199 // Get Message Request
200 MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData;
201 MSG_DEBUG("Registering incoming SMS CB for fd %d mType %d port %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->port);
203 // storing dst fd in list
204 MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
207 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
213 int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
216 if (!pCmd || !ppEvent)
217 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
219 // Get Message Request
220 MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData;
221 MSG_DEBUG("Registering incoming MMS Conf CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
223 // storing dst fd in list
224 MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
227 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
232 int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
235 if (!pCmd || !ppEvent)
236 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
238 // Get Message Request
239 MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData;
240 MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
242 // storing dst fd in list
243 MsgTransactionManager::instance()->setPushMsgCB(pCmdData);
244 //MsgTransactionManager::instance()->sendPendigPushMsg(pCmdData);
248 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
255 int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
258 if (!pCmd || !ppEvent)
259 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
261 // Get Message Request
262 MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData;
263 MSG_DEBUG("Registering incoming CB Msg CB for fd:%d mType:%d: bSave: %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->bsave);
265 // storing dst fd in list
266 MsgTransactionManager::instance()->setCBMsgCB(pCmdData);
269 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
275 int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
278 if (!pCmd || !ppEvent)
279 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
281 // Get Message Request
282 MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData;
283 MSG_DEBUG("Registering incoming Sync ML Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
285 // storing dst fd in list
286 MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
289 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
295 int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
298 if (!pCmd || !ppEvent)
299 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
301 // Get Message Request
302 MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData;
303 MSG_DEBUG("Registering incoming LBS Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
305 // storing dst fd in list
306 MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
309 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
315 int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
318 if (!pCmd || !ppEvent)
319 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
321 // Get Message Request
322 MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData;
323 MSG_DEBUG("Registering SyncML Msg ooperation CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
325 // storing dst fd in list
326 MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
329 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
335 int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
338 if (!pCmd || !ppEvent)
339 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
341 // Get Message Request
342 int listenerFd = *((int*) pCmd->cmdData);
343 MSG_DEBUG("Registering storage change CB for %d", listenerFd);
345 // storing dst fd in list
346 MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
349 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
355 int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
358 if (!pCmd || !ppEvent)
359 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
361 // Get Message Request
362 int listenerFd = *((int*) pCmd->cmdData);
363 MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd);
365 // storing dst fd in list
366 MsgTransactionManager::instance()->setReportMsgCB(listenerFd);
369 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, MsgException::SUCCESS, (void**)ppEvent);
375 int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
378 if (!pCmd || !ppEvent)
379 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
381 // Get Message Request
382 MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
384 MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
386 // storing dst fd in list
387 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
389 // when no sent status cb is found
391 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
394 MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
396 // if APP send and quit(not exist at this time), don't send the data up.
397 if (prxInfo->handleAddr == 0)
399 // just making data which will be passed to plugin. it indicates "handling evt success"
400 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
402 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
405 unsigned int ret[3] = {0}; //3// reqid, status, object
407 ret[0] = pStatus->reqId;
408 ret[1] = pStatus->status;
409 ret[2] = prxInfo->handleAddr;
411 // Make Event Data for APP
412 int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
414 // Send to listener thread, here
415 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
417 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
423 int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
427 msg_error_t err = MSG_SUCCESS;
429 bool sendNoti = true;
430 bool isClass2msg = false;
433 if (!pCmd || !ppEvent)
434 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
436 // Get Incoming Message
437 MSG_MESSAGE_INFO_S msgInfo;
438 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
440 msgInfo.addressList = NULL;
441 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
443 MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo);
445 // broadcast to listener threads, here
446 msg_id_list_s msgIdList;
447 msg_message_id_t msgIds[2];
448 msg_message_id_t class2msgId = 0;
449 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
451 #ifdef MSG_NOTI_INTEGRATION
452 if (msgInfo.msgType.classType == MSG_CLASS_2) {
453 class2msgId = msgInfo.msgId;
459 err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
461 if (isClass2msg == true) {
462 msgIdList.nCount = 2;
463 msgIds[0] = class2msgId;
464 msgIds[1] = msgInfo.msgId;
465 msgIdList.msgIdList = msgIds;
468 msgIdList.nCount = 1;
469 msgIds[0] = msgInfo.msgId;
470 msgIdList.msgIdList = msgIds;
473 if (sendNoti == true) {
474 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
475 if (msgInfo.msgType.subType > MSG_TYPE0_SMS && msgInfo.msgType.subType < MSG_WAP_SI_SMS) { // if it is replacement message.
476 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
478 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
480 } else if (msgInfo.msgPort.valid || (msgInfo.msgType.subType >= MSG_MWI_VOICE_SMS && msgInfo.msgType.subType <= MSG_MWI_OTHER_SMS)) {
481 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
482 } else if (msgInfo.folderId == MSG_SPAMBOX_ID) {
483 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
484 } else if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS || msgInfo.msgType.subType == MSG_DELIVERYIND_MMS) {
485 MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_DELIVERY, &msgInfo);
486 } else if (msgInfo.msgType.subType == MSG_READORGIND_MMS) {
487 MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_READ, &msgInfo);
490 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
491 MsgStoAutoDeleteConversation(msgInfo.threadId, &msgIdList);
492 if (msgIdList.msgIdList)
494 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
495 delete [] (char*)msgIdList.msgIdList;
498 #ifdef FEATURE_SMS_CDMA
499 eventSize = MsgMakeEvent(&msgInfo.msgId, sizeof(msg_message_id_t), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
501 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
504 if (msgInfo.bTextSms == false) {
505 MsgDeleteFile(msgInfo.msgData); //ipc
506 memset(msgInfo.msgData, 0x00, sizeof(msgInfo.msgData));
514 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
517 msg_error_t err = MSG_SUCCESS;
520 MSG_MESSAGE_INFO_S msgInfo;
521 msg_request_id_t reqID;
523 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
525 msgInfo.addressList = NULL;
526 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
528 memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t));
529 MsgDecodeMsgInfo((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t), &msgInfo);
531 MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
532 MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
534 // For Storage change callback
535 msg_id_list_s msgIdList;
536 msg_message_id_t msgIds[1];
537 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
539 msgIdList.nCount = 1;
540 msgIds[0] = msgInfo.msgId;
541 msgIdList.msgIdList = msgIds;
543 MSG_ADDRESS_INFO_S *tmpAddr = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
544 memset(tmpAddr, 0x00, sizeof(MSG_ADDRESS_INFO_S));
546 err = MsgStoGetAddrInfo(msgInfo.msgId, tmpAddr);
547 if (err == MSG_SUCCESS) {
548 MSG_DEBUG("MmsStoGetAddrInfo() success.");
549 msgInfo.nAddressCnt = 1;
551 msgInfo.nAddressCnt = 0;
552 MSG_DEBUG("MmsStoGetAddrInfo() fail.");
555 if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
557 /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct.
558 So adding code for comparing exist address and new address and replace with new address(MMSconf) address */
559 if (msgInfo.nAddressCnt == 1 && msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && (g_strcmp0(tmpAddr->addressVal, msgInfo.addressList[0].addressVal) != 0)) {
560 MSG_WARN("Address of NotiInd and MMSConf are different!!, Replace [NotiInd : %s] from [MMSConf : %s]", tmpAddr->addressVal, msgInfo.addressList[0].addressVal);
561 memset(tmpAddr->addressVal, 0x00, MAX_ADDRESS_VAL_LEN);
562 strncpy(tmpAddr->addressVal, msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN);
565 if (msgInfo.addressList) {
566 delete[] msgInfo.addressList;
567 msgInfo.addressList = NULL;
570 msgInfo.addressList = tmpAddr;
572 MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; // Check retrieve mode to determine broadcast type
574 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
576 if (err != MSG_SUCCESS) {
577 MSG_DEBUG("MsgHandleMmsConfIncomingMsg failed.");
578 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
581 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
583 if (pMmsRecvData->msgAppId.valid == true) {
584 MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
586 msgInfo.bTextSms = true;
587 msgInfo.dataSize = 0 ;
588 memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
591 // broadcast to listener threads, here
592 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
594 // determine broadcast type with retrieve mode
595 if (recv_sub_type == MSG_RETRIEVE_AUTOCONF_MMS)
596 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
598 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
601 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent);
603 } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
604 if (msgInfo.addressList) {
605 delete[] msgInfo.addressList;
606 msgInfo.addressList = NULL;
609 msgInfo.addressList = tmpAddr;
611 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
613 // when no sent status cb is found
615 // No need to update javaMMS sent messages
616 javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
617 javamms_list::iterator it = listenerList.begin();
619 MSG_DEBUG("listenerList size:%d ",listenerList.size());
621 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
622 for ( ; it != listenerList.end() ; it++) {
623 if (strstr(it->pduFileName, "JAVA")) {
624 MSG_SEC_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
625 MsgDeleteFile(it->pduFileName); // ipc
626 listenerList.erase(it);
627 goto __BYPASS_UPDATE;
631 //msgData has MMS_RECV_DATA_S
632 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
634 for ( ; it != listenerList.end() ; it++) {
635 if (!strcmp(it->id, pMmsRecvData->szTrID)) {
636 MSG_SEC_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
637 MsgDeleteFile(it->pduFileName); // ipc
638 listenerList.erase(it);
639 goto __BYPASS_UPDATE;
644 MSG_DEBUG("prxInfo is NULL");
647 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
649 if (err != MSG_SUCCESS) {
650 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
654 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
655 MSG_DEBUG("message-dialog: send fail");
656 MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED, true, msgInfo.msgId);
657 // MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_NORMAL_SOUND_PLAY);
659 MSG_DEBUG("message-dialog: send success");
663 if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
664 MSG_DEBUG("MsgSettingGetBool is failed.");
668 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT, false, 0);
671 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
672 MSG_SEC_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
673 MsgAddPhoneLog(&msgInfo);
674 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
678 if (prxInfo->handleAddr == 0) {
679 // just making data which will be passed to plugin. it indicates "handling evt success"
680 MsgTransactionManager::instance()->delProxyInfo(reqID);
683 unsigned int ret[3] = {0}; //3// reqid, status, object
686 ret[1] = msgInfo.networkStatus;
687 ret[2] = prxInfo->handleAddr;
689 // Make Event Data for APP
690 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
692 // Send to listener thread, here
693 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
695 MsgTransactionManager::instance()->delProxyInfo(reqID);
699 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent);
700 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
702 //To avoid prevent memory leak.. this case will not occur. eventsize will be return as 0.
713 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
720 if (!pCmd || !ppEvent)
721 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
723 MSG_PUSH_MESSAGE_DATA_S pushData;
724 memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
726 // Get Incoming Message
727 memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
731 // broadcast to listener threads, here
732 MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
735 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
741 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
745 msg_error_t err = MSG_SUCCESS;
749 if (!pCmd || !ppEvent)
750 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
752 // Get Incoming Message
754 memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
756 memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
758 MSG_MESSAGE_INFO_S msgInfo;
759 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
761 msgInfo.addressList = NULL;
762 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
764 MsgDecodeMsgInfo((char *)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_CB_MSG_S), &msgInfo);
766 MSG_DEBUG("CB MSG ADDRESS COUNT=%d", msgInfo.nAddressCnt);
768 if (MsgStoAddCBMsg(&msgInfo) != MSG_SUCCESS) {
769 MSG_DEBUG("MsgStoAddCBMsg is fail");
772 MsgInsertNotification(&msgInfo);
775 msg_id_list_s msgIdList;
776 msg_message_id_t msgIds[1];
777 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
779 msgIdList.nCount = 1;
780 msgIds[0] = (msg_message_id_t)msgInfo.msgId;
781 msgIdList.msgIdList = msgIds;
782 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
783 MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg);
785 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
792 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
795 if (!pCmd || !ppEvent)
796 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
798 MSG_SYNCML_MESSAGE_DATA_S syncMLData;
799 memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
801 // Get Incoming Message
802 memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
806 // broadcast to listener threads, here
807 MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
810 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
816 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
821 if (!pCmd || !ppEvent)
822 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
824 MSG_LBS_MESSAGE_DATA_S lbsData;
825 memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
827 // Get Incoming Message
828 memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
830 // broadcast to listener threads, here
831 MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
834 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
840 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
842 msg_error_t err = MSG_SUCCESS;
844 char* encodedData = NULL;
845 AutoPtr<char> buf(&encodedData);
849 msg_message_id_t msgId = 0;
853 if (!pCmd || !ppEvent)
854 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
857 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
858 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(int));
860 err = MsgStoGetSyncMLExtId(msgId, &extId);
862 if (err == MSG_SUCCESS)
864 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
866 // broadcast to listener threads, here
867 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
871 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
874 // Make Event Data to Client
875 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
881 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
884 if (!pCmd || !ppEvent)
885 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
887 msg_storage_change_type_t storageChangeType;
889 MSG_MESSAGE_INFO_S msgInfo;
890 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
892 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
893 memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t));
895 char* encodedData = NULL;
896 AutoPtr<char> buf(&encodedData);
900 MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
902 if (msgInfo.msgType.mainType == MSG_TYPE_SMS) {
903 if (storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
904 MsgStoUpdateMessage(&msgInfo, NULL);
905 else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE)
906 MsgStoDeleteMessage(msgInfo.msgId, true);
909 // broadcast to listener threads, here
910 msg_id_list_s msgIdList;
911 msg_message_id_t msgIds[1];
912 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
914 msgIdList.nCount = 1;
915 msgIds[0] = msgInfo.msgId;
916 msgIdList.msgIdList = msgIds;
918 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
920 // Make Event Data to Client
921 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);
926 int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
928 msg_error_t err = MSG_SUCCESS;
932 // Get the msgIdList of sending failed message.
933 int *failed_msg_list = NULL;
935 AutoPtr<int> failed_list(&failed_msg_list);
938 err = MsgStoGetFailedMessage(&failed_msg_list, &count);
939 if (err != MSG_SUCCESS) {
940 MSG_DEBUG("MsgStoGetFailedMessage() Error!! [%d]", err);
943 for(int i=0; i < count ; ++i)
945 MSG_REQUEST_INFO_S reqInfo = {0};
946 reqInfo.msgInfo.addressList = NULL;
947 AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList);
948 reqInfo.msgInfo.msgId = failed_msg_list[i];
949 err = MsgStoGetMessage(reqInfo.msgInfo.msgId, &(reqInfo.msgInfo), &(reqInfo.sendOptInfo));
951 if (err != MSG_SUCCESS) {
952 MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err);
955 reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING;
957 msg_id_list_s msgIdList;
958 msg_message_id_t msgIds[1];
959 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
961 msgIdList.nCount = 1;
962 msgIds[0] = reqInfo.msgInfo.msgId;
963 msgIdList.msgIdList = msgIds;
965 err = MsgSubmitReq(&reqInfo, false);
967 if (err == MSG_SUCCESS) {
968 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
969 if (err == MSG_SUCCESS)
970 MSG_DEBUG("MsgSubmitReq() Success");
972 MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
974 MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
978 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_RESEND_MESSAGE, err, (void**)ppEvent);
984 #ifdef MSG_PENDING_PUSH_MESSAGE
985 int MsgSendPendingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
992 if (!pCmd || !ppEvent)
993 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
995 MsgTransactionManager::instance()->sendPendingPushMsg();
998 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SEND_PENDING_PUSH_MESSAGE, MSG_SUCCESS, (void**)ppEvent);
1005 #ifdef FEATURE_SMS_CDMA
1006 int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1010 msg_error_t err = MSG_SUCCESS;
1014 if (!pCmd || !ppEvent)
1015 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
1017 // Get Incoming Message
1019 memcpy(&bInsert, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(bool));
1021 msg_message_id_t msgId;
1022 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(bool)), sizeof(msg_message_id_t));
1024 MSG_UNIQUE_INDEX_S p_msg;
1025 memcpy(&p_msg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(bool)+sizeof(msg_message_id_t)), sizeof(MSG_UNIQUE_INDEX_S));
1027 MSG_DEBUG("Decoded Teleservice Msg Id = [%d]", p_msg.tele_msgId);
1028 MSG_DEBUG("Decoded Address = [%s]", p_msg.address);
1029 MSG_DEBUG("Decoded Sub Address = [%s]", p_msg.sub_address);
1031 err = MsgCheckUniqueness(bInsert, msgId, &p_msg);
1033 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_CHECK_UNIQUENESS, err, (void**)ppEvent);