Sync with tizen 2.4
[platform/core/messaging/msg-service.git] / framework / transaction-manager / MsgCmdHandlerTransport.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15 */
16
17 #include <time.h>
18
19 #include "MsgDebug.h"
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"
33 #include "MsgAlarm.h"
34 #include "MsgCmdHandler.h"
35 #include "MsgDevicedWrapper.h"
36
37
38 /*==================================================================================================
39                                      FUNCTION IMPLEMENTATION
40 ==================================================================================================*/
41 int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
42 {
43         msg_error_t err = MSG_SUCCESS;
44         bool bNewMsg = true;
45
46         int eventSize = 0;
47
48         MSG_REQUEST_INFO_S reqInfo = {0,};
49         MSG_PROXY_INFO_S proxyInfo = {0,};
50
51         reqInfo.msgInfo.addressList = NULL;
52         AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList);
53
54         // Get Message Request
55         memcpy(&reqInfo.reqId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t));
56
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));
59
60         MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo);
61
62         if (reqInfo.msgInfo.msgId > 0)
63                 bNewMsg = false;
64
65         // Submit Request
66         err = MsgSubmitReq(&reqInfo, false);
67
68         if (err == MSG_SUCCESS){
69                 MSG_DEBUG("Command Handle Success : MsgSubmitReq()");
70         } else {
71                 MSG_DEBUG("Command Handle Fail : MsgSubmitReq()");
72         }
73
74         int reqId = reqInfo.reqId;
75         proxyInfo.sentMsgId = reqInfo.msgInfo.msgId;
76
77         MSG_DEBUG("REQID: %d, MSGID: %d", reqId, proxyInfo.sentMsgId);
78
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);
87         }
88
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);
94
95                 char* pFileName;
96                 pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_");
97                 strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE);
98
99                 MSG_SEC_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData);
100
101                 MsgTransactionManager* tm = MsgTransactionManager::instance();
102                 tm->setJavaMMSList(&trId);
103         }
104
105         // Make Event Data
106         eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
107
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);
112
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));
117
118         msgIdList.nCount = 1;
119         msgIds[0] = reqInfo.msgInfo.msgId;
120         msgIdList.msgIdList = msgIds;
121
122         if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && reqInfo.msgInfo.msgPort.valid == false) {
123                 if (bNewMsg) {
124                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
125                 } else {
126                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
127                 }
128         } else {
129                 MSG_DEBUG("No need to broadcast storage change CB");
130         }
131
132         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
133
134         MsgStoAutoDeleteConversation(reqInfo.msgInfo.threadId, &msgIdList);
135         if (msgIdList.msgIdList)
136         {
137                 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
138                 delete [] (char*)msgIdList.msgIdList;
139         }
140
141         return eventSize;
142 }
143
144
145 int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
146 {
147         msg_error_t err = MSG_SUCCESS;
148
149         int eventSize = 0;
150
151         // Get Request ID
152         msg_request_id_t* reqId = (msg_request_id_t*)pCmd->cmdData;
153
154         // Cancel Request
155         err = MsgCancelReq(*reqId);
156
157         if (err == MSG_SUCCESS)
158         {
159                 MSG_DEBUG("Command Handle Success : MsgSubCancelReq()");
160         }
161         else
162         {
163                 MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()");
164         }
165
166         // Make Event Data
167         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent);
168
169         return eventSize;
170 }
171
172
173 int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
174 {
175         // input check
176         if (!pCmd || !ppEvent)
177                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
178
179         // Get Message Request
180         int listenerFd = *((int*) pCmd->cmdData);
181         MSG_DEBUG("Registering sent status CB for %d", listenerFd);
182
183         // storing dst fd in list
184         MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
185
186         // Make Event Data
187         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
188
189         return eventSize;
190 }
191
192
193 int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
194 {
195         // input check
196         if (!pCmd || !ppEvent)
197                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
198
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);
202
203         // storing dst fd in list
204         MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
205
206         // Make Event Data
207         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
208
209         return eventSize;
210 }
211
212
213 int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
214 {
215         // input check
216         if (!pCmd || !ppEvent)
217                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
218
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);
222
223         // storing dst fd in list
224         MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
225
226         // Make Event Data
227         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
228
229         return eventSize;
230 }
231
232 int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
233 {
234         // input check
235         if (!pCmd || !ppEvent)
236                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
237
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);
241
242         // storing dst fd in list
243         MsgTransactionManager::instance()->setPushMsgCB(pCmdData);
244         //MsgTransactionManager::instance()->sendPendigPushMsg(pCmdData);
245
246
247         // Make Event Data
248         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
249
250         return eventSize;
251 }
252
253
254
255 int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
256 {
257         // input check
258         if (!pCmd || !ppEvent)
259                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
260
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);
264
265         // storing dst fd in list
266         MsgTransactionManager::instance()->setCBMsgCB(pCmdData);
267
268         // Make Event Data
269         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
270
271         return eventSize;
272 }
273
274
275 int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
276 {
277         // input check
278         if (!pCmd || !ppEvent)
279                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
280
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);
284
285         // storing dst fd in list
286         MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
287
288         // Make Event Data
289         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
290
291         return eventSize;
292 }
293
294
295 int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
296 {
297         // input check
298         if (!pCmd || !ppEvent)
299                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
300
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);
304
305         // storing dst fd in list
306         MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
307
308         // Make Event Data
309         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
310
311         return eventSize;
312 }
313
314
315 int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
316 {
317         // input check
318         if (!pCmd || !ppEvent)
319                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
320
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);
324
325         // storing dst fd in list
326         MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
327
328         // Make Event Data
329         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
330
331         return eventSize;
332 }
333
334
335 int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
336 {
337         // input check
338         if (!pCmd || !ppEvent)
339                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
340
341         // Get Message Request
342         int listenerFd = *((int*) pCmd->cmdData);
343         MSG_DEBUG("Registering storage change CB for %d", listenerFd);
344
345         // storing dst fd in list
346         MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
347
348         // Make Event Data
349         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
350
351         return eventSize;
352 }
353
354
355 int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
356 {
357         // input check
358         if (!pCmd || !ppEvent)
359                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
360
361         // Get Message Request
362         int listenerFd = *((int*) pCmd->cmdData);
363         MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd);
364
365         // storing dst fd in list
366         MsgTransactionManager::instance()->setReportMsgCB(listenerFd);
367
368         // Make Event Data
369         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, MsgException::SUCCESS, (void**)ppEvent);
370
371         return eventSize;
372 }
373
374
375 int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
376 {
377         // input check
378         if (!pCmd || !ppEvent)
379                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
380
381         // Get Message Request
382         MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
383
384         MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
385
386         // storing dst fd in list
387         MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
388
389         // when no sent status cb is found
390         if (!prxInfo) {
391                 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
392         }
393
394         MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
395
396         // if APP send and quit(not exist at this time), don't send the data up.
397         if (prxInfo->handleAddr == 0)
398         {
399                 // just making data which will be passed to plugin. it indicates "handling evt success"
400                 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
401
402                 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
403         }
404
405         unsigned int ret[3] = {0}; //3// reqid, status, object
406
407         ret[0] = pStatus->reqId;
408         ret[1] = pStatus->status;
409         ret[2] = prxInfo->handleAddr;
410
411         // Make Event Data for APP
412         int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
413
414         // Send to listener thread, here
415         MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
416
417         MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
418
419         return eventSize;
420 }
421
422
423 int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
424 {
425         MSG_BEGIN();
426
427         msg_error_t err = MSG_SUCCESS;
428         int eventSize = 0;
429         bool sendNoti = true;
430         bool isClass2msg = false;
431
432         // input check
433         if (!pCmd || !ppEvent)
434                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
435
436         // Get Incoming Message
437         MSG_MESSAGE_INFO_S msgInfo;
438         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
439
440         msgInfo.addressList = NULL;
441         AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
442
443         MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo);
444
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));
450
451 #ifdef MSG_NOTI_INTEGRATION
452         if (msgInfo.msgType.classType == MSG_CLASS_2) {
453                 class2msgId = msgInfo.msgId;
454                 isClass2msg = true;
455         }
456 #endif
457
458         // normal process
459         err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
460
461         if (isClass2msg == true) {
462                 msgIdList.nCount = 2;
463                 msgIds[0] = class2msgId;
464                 msgIds[1] = msgInfo.msgId;
465                 msgIdList.msgIdList = msgIds;
466                 isClass2msg = false;
467         } else {
468                 msgIdList.nCount = 1;
469                 msgIds[0] = msgInfo.msgId;
470                 msgIdList.msgIdList = msgIds;
471         }
472
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);
477                 } else {
478                         MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
479                 }
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);
488         }
489
490         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
491         MsgStoAutoDeleteConversation(msgInfo.threadId, &msgIdList);
492         if (msgIdList.msgIdList)
493         {
494                 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
495                 delete [] (char*)msgIdList.msgIdList;
496         }
497
498 #ifdef FEATURE_SMS_CDMA
499         eventSize = MsgMakeEvent(&msgInfo.msgId, sizeof(msg_message_id_t), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
500 #else
501         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
502 #endif
503
504         if (msgInfo.bTextSms == false) {
505                 MsgDeleteFile(msgInfo.msgData); //ipc
506                 memset(msgInfo.msgData, 0x00, sizeof(msgInfo.msgData));
507         }
508
509         MSG_END();
510
511         return eventSize;
512 }
513
514 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
515 {
516         MSG_BEGIN();
517         msg_error_t err = MSG_SUCCESS;
518         int eventsize = 0;
519
520         MSG_MESSAGE_INFO_S msgInfo;
521         msg_request_id_t reqID;
522
523         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
524
525         msgInfo.addressList = NULL;
526         AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
527
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);
530
531         MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
532         MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
533
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));
538
539         msgIdList.nCount = 1;
540         msgIds[0] = msgInfo.msgId;
541         msgIdList.msgIdList = msgIds;
542
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));
545
546         err = MsgStoGetAddrInfo(msgInfo.msgId, tmpAddr);
547         if (err == MSG_SUCCESS) {
548                 MSG_DEBUG("MmsStoGetAddrInfo() success.");
549                 msgInfo.nAddressCnt = 1;
550         } else {
551                 msgInfo.nAddressCnt = 0;
552                 MSG_DEBUG("MmsStoGetAddrInfo() fail.");
553         }
554
555         if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
556
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);
563                 }
564
565                 if (msgInfo.addressList) {
566                         delete[] msgInfo.addressList;
567                         msgInfo.addressList = NULL;
568                 }
569
570                 msgInfo.addressList = tmpAddr;
571
572                 MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; // Check retrieve mode to determine broadcast type
573
574                 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
575
576                 if (err != MSG_SUCCESS) {
577                         MSG_DEBUG("MsgHandleMmsConfIncomingMsg failed.");
578                         return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
579                 }
580
581                 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
582
583                 if (pMmsRecvData->msgAppId.valid == true) {
584                         MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
585                 } else {
586                         msgInfo.bTextSms = true;
587                         msgInfo.dataSize = 0 ;
588                         memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
589                 }
590
591                 // broadcast to listener threads, here
592                 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
593
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);
597                 else
598                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
599
600                 // make return event
601                 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent);
602
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;
607                 }
608
609                 msgInfo.addressList = tmpAddr;
610
611                 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
612
613                 // when no sent status cb is found
614                 if (prxInfo) {
615                         // No need to update javaMMS sent messages
616                         javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
617                         javamms_list::iterator it = listenerList.begin();
618
619                         MSG_DEBUG("listenerList size:%d ",listenerList.size());
620
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;
628                                         }
629                                 }
630                         } else {
631                                 //msgData has MMS_RECV_DATA_S
632                                 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
633
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;
640                                         }
641                                 }
642                         }
643                 } else {
644                         MSG_DEBUG("prxInfo is NULL");
645                 }
646
647                 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
648
649                 if (err != MSG_SUCCESS) {
650                         return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
651                 }
652
653 __BYPASS_UPDATE:
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);
658                 } else {
659                         MSG_DEBUG("message-dialog: send success");
660
661                         bool bTTS = false;
662
663                         if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
664                                 MSG_DEBUG("MsgSettingGetBool is failed.");
665                         }
666
667                         if (bTTS) {
668                                 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT, false, 0);
669                         }
670
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
675                 }
676
677                 if (prxInfo) {
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);
681                         } else {
682
683                                 unsigned int ret[3] = {0}; //3// reqid, status, object
684
685                                 ret[0] = reqID;
686                                 ret[1] = msgInfo.networkStatus;
687                                 ret[2] = prxInfo->handleAddr;
688
689                                 // Make Event Data for APP
690                                 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
691
692                                 // Send to listener thread, here
693                                 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
694
695                                 MsgTransactionManager::instance()->delProxyInfo(reqID);
696                         }
697                 }
698
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);
701         } else {
702                 //To avoid prevent memory leak.. this case will not occur. eventsize will be return as 0.
703                 if (tmpAddr) {
704                         delete[] tmpAddr;
705                         tmpAddr = NULL;
706                 }
707         }
708
709         MSG_END();
710         return eventsize;
711 }
712
713 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
714 {
715         MSG_BEGIN();
716
717         int eventSize = 0;
718
719         // input check
720         if (!pCmd || !ppEvent)
721                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
722
723         MSG_PUSH_MESSAGE_DATA_S pushData;
724         memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
725
726         // Get Incoming Message
727         memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
728
729
730
731         // broadcast to listener threads, here
732         MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
733
734         // Make Event Data
735         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
736
737         MSG_END();
738         return eventSize;
739 }
740
741 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
742 {
743         MSG_BEGIN();
744
745         msg_error_t err = MSG_SUCCESS;
746         int eventSize = 0;
747
748         // input check
749         if (!pCmd || !ppEvent)
750                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
751
752         // Get Incoming Message
753         MSG_CB_MSG_S cbMsg;
754         memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
755
756         memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
757
758         MSG_MESSAGE_INFO_S msgInfo;
759         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
760
761         msgInfo.addressList = NULL;
762         AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList);
763
764         MsgDecodeMsgInfo((char *)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_CB_MSG_S), &msgInfo);
765
766         MSG_DEBUG("CB MSG ADDRESS COUNT=%d", msgInfo.nAddressCnt);
767
768         if (MsgStoAddCBMsg(&msgInfo) != MSG_SUCCESS) {
769                 MSG_DEBUG("MsgStoAddCBMsg is fail");
770         }
771
772         MsgInsertNotification(&msgInfo);
773         MsgChangePmState();
774
775         msg_id_list_s msgIdList;
776         msg_message_id_t msgIds[1];
777         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
778
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);
784
785         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
786
787         MSG_END();
788
789         return eventSize;
790 }
791
792 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
793 {
794         // input check
795         if (!pCmd || !ppEvent)
796                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
797
798         MSG_SYNCML_MESSAGE_DATA_S syncMLData;
799         memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
800
801         // Get Incoming Message
802         memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
803
804         int eventSize = 0;
805
806         // broadcast to listener threads, here
807         MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
808
809         // Make Event Data
810         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
811
812         return eventSize;
813 }
814
815
816 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
817 {
818         int eventSize = 0;
819
820         // input check
821         if (!pCmd || !ppEvent)
822                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
823
824         MSG_LBS_MESSAGE_DATA_S lbsData;
825         memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
826
827         // Get Incoming Message
828         memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
829
830         // broadcast to listener threads, here
831         MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
832
833         // Make Event Data
834         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
835
836         return eventSize;
837 }
838
839
840 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
841 {
842         msg_error_t err = MSG_SUCCESS;
843
844         char* encodedData = NULL;
845         AutoPtr<char> buf(&encodedData);
846
847         int eventSize = 0;
848
849         msg_message_id_t msgId = 0;
850         int extId = 0;
851
852         // input check
853         if (!pCmd || !ppEvent)
854                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
855
856         // Get Data
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));
859
860         err = MsgStoGetSyncMLExtId(msgId, &extId);
861
862         if (err == MSG_SUCCESS)
863         {
864                 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
865
866                 // broadcast to listener threads, here
867                 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
868         }
869         else
870         {
871                 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
872         }
873
874         // Make Event Data to Client
875         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
876
877         return eventSize;
878 }
879
880
881 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
882 {
883         // input check
884         if (!pCmd || !ppEvent)
885                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
886
887         msg_storage_change_type_t storageChangeType;
888
889         MSG_MESSAGE_INFO_S msgInfo;
890         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
891
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));
894
895         char* encodedData = NULL;
896         AutoPtr<char> buf(&encodedData);
897
898         int eventSize = 0;
899
900         MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
901
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);
907         }
908
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));
913
914         msgIdList.nCount = 1;
915         msgIds[0] = msgInfo.msgId;
916         msgIdList.msgIdList = msgIds;
917
918         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
919
920         // Make Event Data to Client
921         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);
922
923         return eventSize;
924 }
925
926 int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
927 {
928         msg_error_t err = MSG_SUCCESS;
929         int eventSize = 0;
930
931
932         // Get the msgIdList of sending failed message.
933         int *failed_msg_list = NULL;
934         int count = 0;
935         AutoPtr<int> failed_list(&failed_msg_list);
936
937
938         err = MsgStoGetFailedMessage(&failed_msg_list, &count);
939         if (err != MSG_SUCCESS) {
940                 MSG_DEBUG("MsgStoGetFailedMessage() Error!! [%d]", err);
941         }
942
943         for(int i=0; i < count ; ++i)
944         {
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));
950
951                 if (err != MSG_SUCCESS) {
952                         MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err);
953                 }
954
955                 reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING;
956
957                 msg_id_list_s msgIdList;
958                 msg_message_id_t msgIds[1];
959                 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
960
961                 msgIdList.nCount = 1;
962                 msgIds[0] = reqInfo.msgInfo.msgId;
963                 msgIdList.msgIdList = msgIds;
964
965                 err = MsgSubmitReq(&reqInfo, false);
966
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");
971                         else
972                                 MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
973                 } else {
974                         MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
975                 }
976         }
977
978         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_RESEND_MESSAGE, err, (void**)ppEvent);
979
980         MSG_END();
981         return eventSize;
982 }
983
984 #ifdef MSG_PENDING_PUSH_MESSAGE
985 int MsgSendPendingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
986 {
987         MSG_BEGIN();
988
989         int eventSize = 0;
990
991         // input check
992         if (!pCmd || !ppEvent)
993                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
994
995         MsgTransactionManager::instance()->sendPendingPushMsg();
996
997         // Make Event Data
998         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SEND_PENDING_PUSH_MESSAGE, MSG_SUCCESS, (void**)ppEvent);
999
1000         MSG_END();
1001         return eventSize;
1002 }
1003 #endif
1004
1005 #ifdef FEATURE_SMS_CDMA
1006 int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1007 {
1008         MSG_BEGIN();
1009
1010         msg_error_t err = MSG_SUCCESS;
1011         int eventSize = 0;
1012
1013         // input check
1014         if (!pCmd || !ppEvent)
1015                 THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
1016
1017         // Get Incoming Message
1018         bool bInsert;
1019         memcpy(&bInsert, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(bool));
1020
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));
1023
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));
1026
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);
1030
1031         err = MsgCheckUniqueness(bInsert, msgId, &p_msg);
1032
1033         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_CHECK_UNIQUENESS, err, (void**)ppEvent);
1034
1035         MSG_END();
1036
1037         return eventSize;
1038 }
1039 #endif