add code for to/cc feature
[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 #include "MsgMmsMessage.h"
37
38
39 /*==================================================================================================
40                                      FUNCTION IMPLEMENTATION
41 ==================================================================================================*/
42 int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
43 {
44         msg_error_t err = MSG_SUCCESS;
45         bool bNewMsg = true;
46
47         if (!pCmd || !ppEvent) {
48                 MSG_DEBUG("pCmd or ppEvent is null");
49                 return 0;
50         }
51
52         int ret[3];
53         int eventSize = 0;
54
55         MSG_REQUEST_INFO_S reqInfo = {0,};
56         MSG_PROXY_INFO_S proxyInfo = {0,};
57
58         reqInfo.msgInfo.addressList = NULL;
59         unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter);
60
61         // Get Message Request
62         memcpy(&reqInfo.reqId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t));
63
64         // Storing Request ID, Proxy Info for Sent Status CNF
65         memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)), sizeof(MSG_PROXY_INFO_S));
66
67         MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo);
68
69
70         if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE
71                         && reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
72                 int fd = 0;
73                 memcpy(&fd, pCmd->cmdCookie, sizeof(int));
74                 if (reqInfo.msgInfo.bTextSms == false) {
75                         err = MsgMmsCheckFilepathSmack(fd, reqInfo.msgInfo.msgData);
76                         if (err != MSG_SUCCESS) {
77                                 return MsgMakeEvent(NULL, 0, MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
78                         }
79                 }
80         }
81
82         if (reqInfo.msgInfo.msgId > 0)
83                 bNewMsg = false;
84
85         // Submit Request
86         err = MsgSubmitReq(&reqInfo, false);
87
88         if (err == MSG_SUCCESS){
89                 MSG_DEBUG("Command Handle Success : MsgSubmitReq()");
90         } else {
91                 MSG_DEBUG("Command Handle Fail : MsgSubmitReq()");
92         }
93
94         int reqId = reqInfo.reqId;
95         proxyInfo.sentMsgId = reqInfo.msgInfo.msgId;
96
97         MSG_DEBUG("REQID: %d, MSGID: %d", reqId, proxyInfo.sentMsgId);
98
99         if (reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE) {
100                 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
101         } else if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE) {
102                 // Retrieve MMS shall not be kept in sentMsg
103                 if ((reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) ||
104                         (reqInfo.msgInfo.msgType.subType == MSG_FORWARD_MMS) ||
105                         (reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS))
106                 MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
107         }
108
109         // keep transaction Id list for distinguish java MMS sent msg when sendconf received
110         if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE &&
111                 reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS) {
112                 MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S trId={0};
113                 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);
114
115                 char* pFileName;
116                 pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_");
117                 strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE);
118
119                 MSG_SEC_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData);
120
121                 MsgTransactionManager* tm = MsgTransactionManager::instance();
122                 tm->setJavaMMSList(&trId);
123         }
124
125                 ret[0] = reqId;
126                 ret[1] = reqInfo.msgInfo.msgId;
127                 ret[2] = reqInfo.msgInfo.threadId;
128
129         // Make Event Data
130         eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
131
132         /* reject_msg_support */
133         if (((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) &&
134                  (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE)))
135                 err = MsgStoDeleteMessage(reqInfo.msgInfo.msgId, true);
136
137         /** send storage CB */
138         msg_id_list_s msgIdList;
139         msg_message_id_t msgIds[1];
140         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
141
142         msgIdList.nCount = 1;
143         msgIds[0] = reqInfo.msgInfo.msgId;
144         msgIdList.msgIdList = msgIds;
145
146         if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && reqInfo.msgInfo.msgPort.valid == false) {
147                 if (bNewMsg) {
148                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
149                 } else {
150                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
151                 }
152         } else {
153                 MSG_DEBUG("No need to broadcast storage change CB");
154         }
155
156         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
157
158         MsgStoAutoDeleteConversation(reqInfo.msgInfo.threadId, &msgIdList);
159         if (msgIdList.msgIdList)
160         {
161                 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
162                 delete [] (char*)msgIdList.msgIdList;
163         }
164
165         return eventSize;
166 }
167
168
169 int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
170 {
171         // input check
172         if (!pCmd || !ppEvent) {
173                 MSG_DEBUG("pCmd or ppEvent is null");
174                 return 0;
175         }
176
177         // Get Message Request
178         int listenerFd = 0;
179         memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
180         MSG_DEBUG("Registering sent status CB for %d", listenerFd);
181
182         // storing dst fd in list
183         MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
184
185         // Make Event Data
186         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
187
188         return eventSize;
189 }
190
191
192 int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
193 {
194         // input check
195         if (!pCmd || !ppEvent) {
196                 MSG_DEBUG("pCmd or ppEvent is null");
197                 return 0;
198         }
199
200         // Get Message Request
201         MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData;
202         MSG_DEBUG("Registering incoming SMS CB for fd %d mType %d port %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->port);
203
204         // storing dst fd in list
205         MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
206
207         // Make Event Data
208         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
209
210         return eventSize;
211 }
212
213
214 int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
215 {
216         // input check
217         if (!pCmd || !ppEvent) {
218                 MSG_DEBUG("pCmd or ppEvent is null");
219                 return 0;
220         }
221
222         // Get Message Request
223         MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData;
224         MSG_DEBUG("Registering incoming MMS Conf CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
225
226         // storing dst fd in list
227         MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
228
229         // Make Event Data
230         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
231
232         return eventSize;
233 }
234
235 int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
236 {
237         // input check
238         if (!pCmd || !ppEvent) {
239                 MSG_DEBUG("pCmd or ppEvent is null");
240                 return 0;
241         }
242
243         // Get Message Request
244         MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData;
245         MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
246
247         // storing dst fd in list
248         MsgTransactionManager::instance()->setPushMsgCB(pCmdData);
249         //MsgTransactionManager::instance()->sendPendigPushMsg(pCmdData);
250
251
252         // Make Event Data
253         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
254
255         return eventSize;
256 }
257
258
259
260 int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
261 {
262         // input check
263         if (!pCmd || !ppEvent) {
264                 MSG_DEBUG("pCmd or ppEvent is null");
265                 return 0;
266         }
267
268         // Get Message Request
269         MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData;
270         MSG_DEBUG("Registering incoming CB Msg CB for fd:%d mType:%d: bSave: %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->bsave);
271
272         // storing dst fd in list
273         MsgTransactionManager::instance()->setCBMsgCB(pCmdData);
274
275         // Make Event Data
276         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
277
278         return eventSize;
279 }
280
281
282 int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
283 {
284         // input check
285         if (!pCmd || !ppEvent) {
286                 MSG_DEBUG("pCmd or ppEvent is null");
287                 return 0;
288         }
289
290         // Get Message Request
291         MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData;
292         MSG_DEBUG("Registering incoming Sync ML Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
293
294         // storing dst fd in list
295         MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
296
297         // Make Event Data
298         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
299
300         return eventSize;
301 }
302
303
304 int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
305 {
306         // input check
307         if (!pCmd || !ppEvent) {
308                 MSG_DEBUG("pCmd or ppEvent is null");
309                 return 0;
310         }
311
312         // Get Message Request
313         MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData;
314         MSG_DEBUG("Registering incoming LBS Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
315
316         // storing dst fd in list
317         MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
318
319         // Make Event Data
320         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
321
322         return eventSize;
323 }
324
325
326 int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
327 {
328         // input check
329         if (!pCmd || !ppEvent) {
330                 MSG_DEBUG("pCmd or ppEvent is null");
331                 return 0;
332         }
333
334         // Get Message Request
335         MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData;
336         MSG_DEBUG("Registering SyncML Msg ooperation CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
337
338         // storing dst fd in list
339         MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
340
341         // Make Event Data
342         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
343
344         return eventSize;
345 }
346
347
348 int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
349 {
350         // input check
351         if (!pCmd || !ppEvent) {
352                 MSG_DEBUG("pCmd or ppEvent is null");
353                 return 0;
354         }
355
356         // Get Message Request
357         int listenerFd = 0;
358         memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
359         MSG_DEBUG("Registering storage change CB for %d", listenerFd);
360
361         // storing dst fd in list
362         MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
363
364         // Make Event Data
365         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
366
367         return eventSize;
368 }
369
370
371 int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
372 {
373         // input check
374         if (!pCmd || !ppEvent) {
375                 MSG_DEBUG("pCmd or ppEvent is null");
376                 return 0;
377         }
378
379         // Get Message Request
380         int listenerFd = 0;
381         memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
382         MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd);
383
384         // storing dst fd in list
385         MsgTransactionManager::instance()->setReportMsgCB(listenerFd);
386
387         // Make Event Data
388         int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, MsgException::SUCCESS, (void**)ppEvent);
389
390         return eventSize;
391 }
392
393
394 int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
395 {
396         // input check
397         if (!pCmd || !ppEvent) {
398                 MSG_DEBUG("pCmd or ppEvent is null");
399                 return 0;
400         }
401
402         // Get Message Request
403         MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
404
405         MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
406
407         // storing dst fd in list
408         MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
409
410         // when no sent status cb is found
411         if (!prxInfo) {
412                 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
413         }
414
415         MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
416
417         // if APP send and quit(not exist at this time), don't send the data up.
418         if (prxInfo->handleAddr == 0)
419         {
420                 // just making data which will be passed to plugin. it indicates "handling evt success"
421                 MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
422
423                 return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
424         }
425
426         unsigned long ret[3] = {0}; //3// reqid, status, object
427
428         ret[0] = (unsigned long)pStatus->reqId;
429         ret[1] = (unsigned long)pStatus->status;
430         ret[2] = prxInfo->handleAddr;
431
432         // Make Event Data for APP
433         int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
434
435         // Send to listener thread, here
436         MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
437
438         MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
439
440         return eventSize;
441 }
442
443
444 int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
445 {
446         MSG_BEGIN();
447
448         msg_error_t err = MSG_SUCCESS;
449         int eventSize = 0;
450         bool sendNoti = true;
451         bool isClass2msg = false;
452
453         // input check
454         if (!pCmd || !ppEvent) {
455                 MSG_DEBUG("pCmd or ppEvent is null");
456                 return 0;
457         }
458
459         // Get Incoming Message
460         MSG_MESSAGE_INFO_S msgInfo;
461         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
462
463         msgInfo.addressList = NULL;
464         unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
465
466         MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo);
467
468         // broadcast to listener threads, here
469         msg_id_list_s msgIdList;
470         msg_message_id_t msgIds[2];
471         msg_message_id_t class2msgId = 0;
472         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
473
474 #ifdef MSG_NOTI_INTEGRATION
475         if (msgInfo.msgType.classType == MSG_CLASS_2) {
476                 class2msgId = msgInfo.msgId;
477                 isClass2msg = true;
478         }
479 #endif
480
481         // normal process
482         err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
483
484         if (isClass2msg == true) {
485                 msgIdList.nCount = 2;
486                 msgIds[0] = class2msgId;
487                 msgIds[1] = msgInfo.msgId;
488                 msgIdList.msgIdList = msgIds;
489                 isClass2msg = false;
490         } else {
491                 msgIdList.nCount = 1;
492                 msgIds[0] = msgInfo.msgId;
493                 msgIdList.msgIdList = msgIds;
494         }
495
496         if (sendNoti == true) {
497                 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
498                 if (msgInfo.msgType.subType > MSG_TYPE0_SMS && msgInfo.msgType.subType < MSG_WAP_SI_SMS) { // if it is replacement message.
499                         MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
500                 } else {
501                         MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
502                 }
503         } else if (msgInfo.msgPort.valid || (msgInfo.msgType.subType >= MSG_MWI_VOICE_SMS && msgInfo.msgType.subType <= MSG_MWI_OTHER_SMS)) {
504                 MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
505         } else if (msgInfo.folderId == MSG_SPAMBOX_ID) {
506                 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
507         } else if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS || msgInfo.msgType.subType == MSG_DELIVERYIND_MMS) {
508                 MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_DELIVERY, &msgInfo);
509         } else if (msgInfo.msgType.subType == MSG_READORGIND_MMS) {
510                 MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_READ, &msgInfo);
511         }
512
513         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
514         MsgStoAutoDeleteConversation(msgInfo.threadId, &msgIdList);
515         if (msgIdList.msgIdList)
516         {
517                 MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
518                 delete [] (char*)msgIdList.msgIdList;
519         }
520
521 #ifdef FEATURE_SMS_CDMA
522         eventSize = MsgMakeEvent(&msgInfo.msgId, sizeof(msg_message_id_t), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
523 #else
524         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
525 #endif
526
527         if (msgInfo.bTextSms == false) {
528                 MsgDeleteFile(msgInfo.msgData); //ipc
529                 memset(msgInfo.msgData, 0x00, sizeof(msgInfo.msgData));
530         }
531
532         MSG_END();
533
534         return eventSize;
535 }
536
537 int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
538 {
539         MSG_BEGIN();
540
541         if (!pCmd || !ppEvent) {
542                 MSG_DEBUG("pCmd or ppEvent is null");
543                 return 0;
544         }
545
546         msg_error_t err = MSG_SUCCESS;
547         int eventsize = 0;
548
549         MSG_MESSAGE_INFO_S msgInfo;
550         msg_request_id_t reqID;
551
552         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
553
554         msgInfo.addressList = NULL;
555         unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
556
557         memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t));
558         MsgDecodeMsgInfo((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t), &msgInfo);
559
560         MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
561         MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
562
563         /* For Storage change callback */
564         msg_id_list_s msgIdList;
565         msg_message_id_t msgIds[1];
566         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
567
568         msgIdList.nCount = 1;
569         msgIds[0] = msgInfo.msgId;
570         msgIdList.msgIdList = msgIds;
571
572         MsgDbHandler *dbHandle = getDbHandle();
573         int tmpAddrCnt = 0;
574         MSG_ADDRESS_INFO_S *tmpAddr = NULL;
575         int order = MsgGetContactNameOrder();
576         err = MsgStoGetAddressByMsgId(dbHandle, msgInfo.msgId, order, &tmpAddrCnt, &tmpAddr);
577         if (err != MSG_SUCCESS) {
578                 MSG_DEBUG("MsgStoGetAddressByMsgId() fail.");
579         }
580
581         if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
582                 if (msgInfo.networkStatus != MSG_NETWORK_RETRIEVE_SUCCESS) {
583                         if (msgInfo.addressList) {
584                                 delete[] msgInfo.addressList;
585                                 msgInfo.addressList = NULL;
586                         }
587
588                         msgInfo.addressList = tmpAddr;
589                         msgInfo.nAddressCnt = tmpAddrCnt;
590                 } else {
591                         if (tmpAddr) {
592                                 delete [] tmpAddr;
593                                 tmpAddr = NULL;
594                         }
595                 }
596
597                 msg_thread_id_t prev_conv_id = MsgGetThreadId(dbHandle, msgInfo.msgId);
598                 MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; /* Check retrieve mode to determine broadcast type */
599
600                 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
601
602                 if (err != MSG_SUCCESS) {
603                         MSG_DEBUG("MsgHandleMmsConfIncomingMsg failed.");
604                         return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
605                 }
606
607                 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
608
609                 if (pMmsRecvData->msgAppId.valid == true) {
610                         MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
611                 } else {
612                         msgInfo.bTextSms = true;
613                         msgInfo.dataSize = 0 ;
614                         memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
615                 }
616
617                 /* broadcast to listener threads, here */
618                 MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
619
620                 /* determine broadcast type with retrieve mode */
621                 if (recv_sub_type == MSG_RETRIEVE_AUTOCONF_MMS) {
622                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
623                 } else {
624                         if (prev_conv_id == msgInfo.threadId
625                                 || msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_FAIL || msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_PENDING) {
626                                 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
627                         } else {
628                                 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
629                                 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
630                         }
631                 }
632
633                 // make return event
634                 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent);
635
636         } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
637                 if (msgInfo.addressList) {
638                         delete[] msgInfo.addressList;
639                         msgInfo.addressList = NULL;
640                 }
641
642                 msgInfo.addressList = tmpAddr;
643                 msgInfo.nAddressCnt = tmpAddrCnt;
644
645                 MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
646
647                 // when no sent status cb is found
648                 if (prxInfo) {
649                         // No need to update javaMMS sent messages
650                         javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
651                         javamms_list::iterator it = listenerList.begin();
652
653                         MSG_DEBUG("listenerList size:%d ",listenerList.size());
654
655                         if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
656                                 for ( ; it != listenerList.end() ; it++) {
657                                         if (strstr(it->pduFileName, "JAVA")) {
658                                                 MSG_SEC_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
659                                                 MsgDeleteFile(it->pduFileName);         // ipc
660                                                 listenerList.erase(it);
661                                                 goto __BYPASS_UPDATE;
662                                         }
663                                 }
664                         } else {
665                                 //msgData has MMS_RECV_DATA_S
666                                 MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
667
668                                 for ( ; it != listenerList.end() ; it++) {
669                                         if (!strcmp(it->id, pMmsRecvData->szTrID)) {
670                                                 MSG_SEC_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
671                                                 MsgDeleteFile(it->pduFileName); // ipc
672                                                 listenerList.erase(it);
673                                                 goto __BYPASS_UPDATE;
674                                         }
675                                 }
676                         }
677                 } else {
678                         MSG_DEBUG("prxInfo is NULL");
679                 }
680
681                 err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
682
683                 if (err != MSG_SUCCESS) {
684                         return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent);
685                 }
686
687 __BYPASS_UPDATE:
688                 if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
689                         MSG_DEBUG("message-dialog: send fail");
690                         MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED, true, msgInfo.msgId);
691 //                      MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_NORMAL_SOUND_PLAY);
692                 } else {
693                         MSG_DEBUG("message-dialog: send success");
694
695 #if 0 // disabled as per UX request to not show success notification : 2015. 09. 18
696                         bool bTTS = false;
697
698                         if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
699                                 MSG_DEBUG("MsgSettingGetBool is failed.");
700                         }
701
702                         if (bTTS) {
703                                 MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT, false, 0);
704                         }
705
706 #endif
707 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
708                         MSG_SEC_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
709                         MsgAddPhoneLog(&msgInfo);
710 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
711                 }
712
713                 if (prxInfo) {
714                         if (prxInfo->handleAddr == 0) {
715                                 // just making data which will be passed to plugin. it indicates "handling evt success"
716                                 MsgTransactionManager::instance()->delProxyInfo(reqID);
717                         } else {
718
719                                 unsigned long ret[3] = {0}; //3// reqid, status, object
720
721                                 ret[0] = (unsigned long)reqID;
722                                 ret[1] = (unsigned long)msgInfo.networkStatus;
723                                 ret[2] = prxInfo->handleAddr;
724
725                                 // Make Event Data for APP
726                                 eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
727
728                                 // Send to listener thread, here
729                                 MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
730
731                                 MsgTransactionManager::instance()->delProxyInfo(reqID);
732                         }
733                 }
734
735                 eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent);
736                 MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
737         } else {
738                 //To avoid prevent memory leak.. this case will not occur. eventsize will be return as 0.
739                 if (tmpAddr) {
740                         delete[] tmpAddr;
741                         tmpAddr = NULL;
742                 }
743         }
744
745         MSG_END();
746         return eventsize;
747 }
748
749 int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
750 {
751         MSG_BEGIN();
752
753         int eventSize = 0;
754
755         // input check
756         if (!pCmd || !ppEvent) {
757                 MSG_DEBUG("pCmd or ppEvent is null");
758                 return 0;
759         }
760
761         MSG_PUSH_MESSAGE_DATA_S pushData;
762         memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
763
764         // Get Incoming Message
765         memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S));
766
767
768
769         // broadcast to listener threads, here
770         MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData);
771
772         // Make Event Data
773         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
774
775         MSG_END();
776         return eventSize;
777 }
778
779 int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
780 {
781         MSG_BEGIN();
782
783         msg_error_t err = MSG_SUCCESS;
784         int eventSize = 0;
785
786         // input check
787         if (!pCmd || !ppEvent) {
788                 MSG_DEBUG("pCmd or ppEvent is null");
789                 return 0;
790         }
791
792         // Get Incoming Message
793         MSG_CB_MSG_S cbMsg;
794         memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S));
795
796         memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S));
797
798         MSG_MESSAGE_INFO_S msgInfo;
799         memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
800
801         msgInfo.addressList = NULL;
802         unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
803
804         MsgDecodeMsgInfo((char *)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_CB_MSG_S), &msgInfo);
805
806         MSG_DEBUG("CB MSG ADDRESS COUNT=%d", msgInfo.nAddressCnt);
807
808         if (MsgStoAddCBMsg(&msgInfo) != MSG_SUCCESS) {
809                 MSG_DEBUG("MsgStoAddCBMsg is fail");
810         }
811
812         if (msgInfo.msgType.classType == MSG_CLASS_0) {
813                 MsgLaunchClass0(msgInfo.msgId);
814                 bool isFavorites = false;
815                 if (!checkBlockingMode(msgInfo.addressList[0].addressVal, &isFavorites)) {
816                         MsgPlayTTSMode(msgInfo.msgType.subType, msgInfo.msgId, isFavorites);
817                         MsgSoundPlayer::instance()->MsgSoundPlayStart(&(msgInfo.addressList[0]), MSG_SOUND_PLAY_USER);
818                 }
819         } else {
820                 MsgInsertNotification(&msgInfo);
821         }
822
823         if (MsgCheckNotificationSettingEnable())
824                 MsgChangePmState();
825
826         msg_id_list_s msgIdList;
827         msg_message_id_t msgIds[1];
828         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
829
830         msgIdList.nCount = 1;
831         msgIds[0] = (msg_message_id_t)msgInfo.msgId;
832         msgIdList.msgIdList = msgIds;
833         MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
834         MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg, msgInfo.msgId);
835
836         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent);
837
838         MSG_END();
839
840         return eventSize;
841 }
842
843 int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
844 {
845         // input check
846         if (!pCmd || !ppEvent) {
847                 MSG_DEBUG("pCmd or ppEvent is null");
848                 return 0;
849         }
850
851         MSG_SYNCML_MESSAGE_DATA_S syncMLData;
852         memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
853
854         // Get Incoming Message
855         memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
856
857         int eventSize = 0;
858
859         // broadcast to listener threads, here
860         MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
861
862         // Make Event Data
863         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
864
865         return eventSize;
866 }
867
868
869 int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
870 {
871         int eventSize = 0;
872
873         // input check
874         if (!pCmd || !ppEvent) {
875                 MSG_DEBUG("pCmd or ppEvent is null");
876                 return 0;
877         }
878
879         MSG_LBS_MESSAGE_DATA_S lbsData;
880         memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
881
882         // Get Incoming Message
883         memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
884
885         // broadcast to listener threads, here
886         MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
887
888         // Make Event Data
889         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
890
891         return eventSize;
892 }
893
894
895 int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
896 {
897         msg_error_t err = MSG_SUCCESS;
898
899         char* encodedData = NULL;
900         unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
901
902         int eventSize = 0;
903
904         msg_message_id_t msgId = 0;
905         int extId = 0;
906
907         // input check
908         if (!pCmd || !ppEvent) {
909                 MSG_DEBUG("pCmd or ppEvent is null");
910                 return 0;
911         }
912
913         // Get Data
914         memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
915         memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), sizeof(int));
916
917         err = MsgStoGetSyncMLExtId(msgId, &extId);
918
919         if (err == MSG_SUCCESS)
920         {
921                 MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
922
923                 // broadcast to listener threads, here
924                 MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
925         }
926         else
927         {
928                 MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
929         }
930
931         // Make Event Data to Client
932         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
933
934         return eventSize;
935 }
936
937
938 int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
939 {
940         // input check
941         if (!pCmd || !ppEvent) {
942                 MSG_DEBUG("pCmd or ppEvent is null");
943                 return 0;
944         }
945
946         msg_id_list_s msgIdList;
947         memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
948         msg_storage_change_type_t storageChangeType;
949
950         memcpy(&msgIdList.nCount, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
951
952         msgIdList.msgIdList = new msg_message_id_t[msgIdList.nCount];
953         for (int i = 0; i < msgIdList.nCount; i++) {
954                 memcpy(&msgIdList.msgIdList[i], (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+i*sizeof(msg_message_id_t)), sizeof(msg_message_id_t));
955         }
956
957         memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+(sizeof(msg_message_id_t)*msgIdList.nCount)), sizeof(msg_storage_change_type_t));
958
959         char* encodedData = NULL;
960         unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
961
962         int eventSize = 0;
963
964         MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount);
965         for (int i = 0; i < msgIdList.nCount; i++) {
966                 MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgIdList.msgIdList[i]);
967         }
968
969         // broadcast to listener threads, here
970         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
971
972         if (msgIdList.msgIdList) {
973                 delete [] msgIdList.msgIdList;
974         }
975
976         // Make Event Data to Client
977         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);
978
979         return eventSize;
980 }
981
982 int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
983 {
984         msg_error_t err = MSG_SUCCESS;
985         int eventSize = 0;
986
987         if (!pCmd || !ppEvent) {
988                 MSG_DEBUG("pCmd or ppEvent is null");
989                 return 0;
990         }
991
992         // Get the msgIdList of sending failed message.
993         int *failed_msg_list = NULL;
994         int count = 0;
995         unique_ptr<int*, void(*)(int**)> failed_list(&failed_msg_list, unique_ptr_deleter);
996
997
998         err = MsgStoGetFailedMessage(&failed_msg_list, &count);
999         if (err != MSG_SUCCESS) {
1000                 MSG_DEBUG("MsgStoGetFailedMessage() Error!! [%d]", err);
1001         }
1002
1003         for(int i=0; i < count ; ++i)
1004         {
1005                 MSG_REQUEST_INFO_S reqInfo = {0};
1006                 reqInfo.msgInfo.addressList = NULL;
1007                 unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter);
1008                 reqInfo.msgInfo.msgId = failed_msg_list[i];
1009                 err = MsgStoGetMessage(reqInfo.msgInfo.msgId, &(reqInfo.msgInfo), &(reqInfo.sendOptInfo));
1010
1011                 if (err != MSG_SUCCESS) {
1012                         MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err);
1013                 }
1014
1015                 if (reqInfo.msgInfo.msgType.subType ==  MSG_GET_MMS || \
1016                                 reqInfo.msgInfo.msgType.subType  == MSG_NOTIFICATIONIND_MMS || \
1017                                 reqInfo.msgInfo.msgType.subType  == MSG_RETRIEVE_MMS)
1018                 {
1019                         MSG_WARN("retrieve pending id[%d]", reqInfo.msgInfo.msgId);
1020                         /* For retrieving failed msg (MMS)*/
1021                         reqInfo.msgInfo.msgType.subType = MSG_RETRIEVE_MMS;
1022                         reqInfo.msgInfo.folderId = MSG_OUTBOX_ID; // outbox fixed
1023                         reqInfo.msgInfo.networkStatus = MSG_NETWORK_RETRIEVING;
1024                 } else {
1025                         /* For sending failed msg */
1026                         reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING;
1027                 }
1028
1029                 msg_id_list_s msgIdList;
1030                 msg_message_id_t msgIds[1];
1031                 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
1032
1033                 msgIdList.nCount = 1;
1034                 msgIds[0] = reqInfo.msgInfo.msgId;
1035                 msgIdList.msgIdList = msgIds;
1036
1037                 err = MsgSubmitReq(&reqInfo, false);
1038
1039                 if (err == MSG_SUCCESS) {
1040                         MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
1041                         if (err == MSG_SUCCESS)
1042                                 MSG_DEBUG("MsgSubmitReq() Success");
1043                         else
1044                                 MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
1045                 } else {
1046                         MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
1047                 }
1048         }
1049
1050         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_RESEND_MESSAGE, err, (void**)ppEvent);
1051
1052         MSG_END();
1053         return eventSize;
1054 }
1055
1056 #ifdef FEATURE_SMS_CDMA
1057 int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent)
1058 {
1059         MSG_BEGIN();
1060
1061         msg_error_t err = MSG_SUCCESS;
1062         int eventSize = 0;
1063
1064         // input check
1065         if (!pCmd || !ppEvent) {
1066                 MSG_DEBUG("pCmd or ppEvent is null");
1067                 return 0;
1068         }
1069
1070         // Get Incoming Message
1071         bool bInsert;
1072         memcpy(&bInsert, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(bool));
1073
1074         msg_message_id_t msgId;
1075         memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(bool)), sizeof(msg_message_id_t));
1076
1077         MSG_UNIQUE_INDEX_S p_msg;
1078         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));
1079
1080         MSG_DEBUG("Decoded Teleservice Msg Id = [%d]", p_msg.tele_msgId);
1081         MSG_DEBUG("Decoded Address = [%s]", p_msg.address);
1082         MSG_DEBUG("Decoded Sub Address = [%s]", p_msg.sub_address);
1083
1084         err = MsgCheckUniqueness(bInsert, msgId, &p_msg);
1085
1086         eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_CHECK_UNIQUENESS, err, (void**)ppEvent);
1087
1088         MSG_END();
1089
1090         return eventSize;
1091 }
1092 #endif