2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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/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) && reqInfo.msgInfo.msgPort.valid == false) {
118 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
120 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
122 } else if (err == MSG_ERR_SECURITY_ERROR) { // Case of MDM enabled, it returns MSG_ERR_SECURITY_ERROR.
123 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
125 MSG_DEBUG("No need to broadcast storage change CB");
132 int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
134 msg_error_t err = MSG_SUCCESS;
139 msg_request_id_t* reqId = (msg_request_id_t*)pCmd->cmdData;
142 err = MsgCancelReq(*reqId);
144 if (err == MSG_SUCCESS)
146 MSG_DEBUG("Command Handle Success : MsgSubCancelReq()");
150 MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()");
154 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent);
160 int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
163 if( !pCmd || !ppEvent)
164 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
166 // Get Message Request
167 int listenerFd = *((int*) pCmd->cmdData);
168 MSG_DEBUG("Registering sent status CB for %d", listenerFd);
170 // storing dst fd in list
171 MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
174 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
180 int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
183 if( !pCmd || !ppEvent)
184 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
186 // Get Message Request
187 MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData;
188 MSG_DEBUG("Registering incoming SMS CB for fd %d mType %d port %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->port);
190 // storing dst fd in list
191 MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
194 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
200 int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
203 if( !pCmd || !ppEvent)
204 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
206 // Get Message Request
207 MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData;
208 MSG_DEBUG("Registering incoming MMS Conf CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
210 // storing dst fd in list
211 MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
214 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
219 int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
222 if( !pCmd || !ppEvent)
223 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
225 // Get Message Request
226 MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData;
227 MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
229 // storing dst fd in list
230 MsgTransactionManager::instance()->setPushMsgCB(pCmdData);
233 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
238 int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
241 if( !pCmd || !ppEvent)
242 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
244 // Get Message Request
245 MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData;
246 MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d", pCmdData->listenerFd, pCmdData->msgType);
248 // storing dst fd in list
249 MsgTransactionManager::instance()->setCBMsgCB(pCmdData);
252 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
258 int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
261 if( !pCmd || !ppEvent)
262 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
264 // Get Message Request
265 MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData;
266 MSG_DEBUG("Registering incoming Sync ML Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
268 // storing dst fd in list
269 MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
272 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
278 int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
281 if( !pCmd || !ppEvent)
282 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
284 // Get Message Request
285 MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData;
286 MSG_DEBUG("Registering incoming LBS Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
288 // storing dst fd in list
289 MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
292 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
298 int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
301 if( !pCmd || !ppEvent)
302 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
304 // Get Message Request
305 MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData;
306 MSG_DEBUG("Registering SyncML Msg ooperation CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
308 // storing dst fd in list
309 MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
312 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
318 int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
321 if( !pCmd || !ppEvent)
322 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
324 // Get Message Request
325 int listenerFd = *((int*) pCmd->cmdData);
326 MSG_DEBUG("Registering storage change CB for %d", listenerFd);
328 // storing dst fd in list
329 MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
332 int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
338 int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
341 if (!pCmd || !ppEvent)
342 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
344 // Get Message Request
345 MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
347 MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
349 // storing dst fd in list
350 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
352 // when no sent status cb is found (in case of mobile tracker)
355 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
358 MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
360 // if APP send and quit(not exist at this time), don't send the data up.
361 if (prxInfo->handleAddr == 0)
363 // just making data which will be passed to plugin. it indicates "handling evt success"
364 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
366 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
370 uint64_t ret[3] = {0}; //3// reqid, status, object
372 unsigned int ret[3] = {0}; //3// reqid, status, object
375 ret[0] = pStatus->reqId;
376 ret[1] = pStatus->status;
377 ret[2] = prxInfo->handleAddr;
379 // Make Event Data for APP
380 int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
382 // Send to listener thread, here
383 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
385 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
391 int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
395 msg_error_t err = MSG_SUCCESS;
397 bool sendNoti = true;
400 if (!pCmd || !ppEvent)
401 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
403 // Get Incoming Message
404 MSG_MESSAGE_INFO_S msgInfo;
405 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
407 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
410 err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
412 // broadcast to listener threads, here
413 msg_id_list_s msgIdList;
414 msg_message_id_t msgIds[1];
415 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
417 msgIdList.nCount = 1;
418 msgIds[0] = msgInfo.msgId;
419 msgIdList.msgIdList = msgIds;
421 if (sendNoti == true) {
422 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
423 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
424 } else if(msgInfo.msgPort.valid)
426 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
428 else if (msgInfo.folderId == MSG_SPAMBOX_ID) {
429 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
432 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
439 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
442 msg_error_t err = MSG_SUCCESS;
445 MSG_MESSAGE_INFO_S msgInfo = {0};
446 msg_request_id_t reqID;
448 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
449 memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_request_id_t));
451 MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
452 MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
454 // For Storage change callback
455 msg_id_list_s msgIdList;
456 msg_message_id_t msgIds[1];
457 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
459 msgIdList.nCount = 1;
460 msgIds[0] = msgInfo.msgId;
461 msgIdList.msgIdList = msgIds;
463 err = MsgStoGetAddrInfo(msgInfo.msgId, &(msgInfo.addressList[0]));
465 if (err == MSG_SUCCESS) {
466 MSG_DEBUG("MmsStoGetAddrInfo() success.");
467 msgInfo.nAddressCnt = 1;
469 MSG_DEBUG("MmsStoGetAddrInfo() fail.");
472 if(msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
474 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
476 if(err != MSG_SUCCESS)
479 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
481 if (pMmsRecvData->msgAppId.valid == true) {
482 MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
484 msgInfo.bTextSms = true;
485 msgInfo.dataSize = 0 ;
486 memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
489 eventsize = MsgMakeEvent(&msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, msgInfo.networkStatus, (void**)ppEvent);
491 // broadcast to listener threads, here
492 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
493 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
494 } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
495 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
497 // when no sent status cb is found (in case of mobile tracker)
499 MSG_DEBUG("prxInfo is NULL");
500 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
502 // No need to update javaMMS sent messages
503 javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
504 javamms_list::iterator it = listenerList.begin();
506 MSG_DEBUG("listenerList size:%d ",listenerList.size());
508 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
509 for ( ; it != listenerList.end() ; it++) {
510 if (strstr(it->pduFileName, "JAVA")) {
511 MSG_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
512 MsgDeleteFile(it->pduFileName); // ipc
513 listenerList.erase(it);
514 goto __BYPASS_UPDATE;
518 //msgData has MMS_RECV_DATA_S
519 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
521 for ( ; it != listenerList.end() ; it++) {
522 if(!strcmp(it->id, pMmsRecvData->szTrID)) {
523 MSG_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
524 MsgDeleteFile(it->pduFileName); // ipc
525 listenerList.erase(it);
526 goto __BYPASS_UPDATE;
532 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
534 if(err != MSG_SUCCESS)
538 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
539 MSG_DEBUG("message-dialog: send fail");
540 MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED);
542 MSG_DEBUG("message-dialog: send success");
543 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT);
545 MSG_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
546 MsgAddPhoneLog(&msgInfo);
550 if (prxInfo->handleAddr == 0) {
551 // just making data which will be passed to plugin. it indicates "handling evt success"
552 MsgTransactionManager::instance()->delProxyInfo(reqID);
554 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
558 uint64_t ret[3] = {0}; //3// reqid, status, object
560 unsigned int ret[3] = {0}; //3// reqid, status, object
564 ret[1] = msgInfo.networkStatus;
565 ret[2] = prxInfo->handleAddr;
567 // Make Event Data for APP
568 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
570 // Send to listener thread, here
571 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
573 MsgTransactionManager::instance()->delProxyInfo(reqID);
576 msgInfo.bTextSms = true;
577 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
584 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
591 if (!pCmd || !ppEvent)
592 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
594 MSG_PUSH_MESSAGE_DATA_S pushData;
595 memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
597 // Get Incoming Message
598 memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
602 // broadcast to listener threads, here
603 MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
606 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
612 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
616 msg_error_t err = MSG_SUCCESS;
620 if (!pCmd || !ppEvent)
621 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
623 // Get Incoming Message
625 memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
627 memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
629 msg_id_list_s msgIdList;
630 msg_message_id_t msgIds[1];
631 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
633 MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg);
636 MsgSettingGetBool(CB_SAVE, &bSave);
638 if(bSave && cbMsg.type!= MSG_ETWS_SMS) {
639 msgIdList.nCount = 1;
640 msgIds[0] = (msg_message_id_t)cbMsg.messageId;
641 msgIdList.msgIdList = msgIds;
642 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
644 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
651 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
654 if (!pCmd || !ppEvent)
655 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
657 MSG_SYNCML_MESSAGE_DATA_S syncMLData;
658 memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
660 // Get Incoming Message
661 memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
665 // broadcast to listener threads, here
666 MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
669 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
675 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
680 if (!pCmd || !ppEvent)
681 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
683 MSG_LBS_MESSAGE_DATA_S lbsData;
684 memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
686 // Get Incoming Message
687 memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
689 // broadcast to listener threads, here
690 MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
693 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
699 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
701 msg_error_t err = MSG_SUCCESS;
703 char* encodedData = NULL;
704 AutoPtr<char> buf(&encodedData);
708 msg_message_id_t msgId = 0;
712 if (!pCmd || !ppEvent)
713 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
716 memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
717 memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(int));
719 err = MsgStoGetSyncMLExtId(msgId, &extId);
721 if (err == MSG_SUCCESS)
723 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
725 // broadcast to listener threads, here
726 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
730 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
733 // Make Event Data to Client
734 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
740 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
743 if (!pCmd || !ppEvent)
744 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
746 msg_storage_change_type_t storageChangeType;
748 MSG_MESSAGE_INFO_S msgInfo;
749 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
751 memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
752 memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t));
754 char* encodedData = NULL;
755 AutoPtr<char> buf(&encodedData);
759 MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
761 // broadcast to listener threads, here
762 msg_id_list_s msgIdList;
763 msg_message_id_t msgIds[1];
764 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
766 msgIdList.nCount = 1;
767 msgIds[0] = msgInfo.msgId;
768 msgIdList.msgIdList = msgIds;
770 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
772 // Make Event Data to Client
773 eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);