2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "MmsPluginTypes.h"
21 #include "MmsPluginDebug.h"
22 #include "MmsPluginEventHandler.h"
23 #include "MmsPluginInternal.h"
25 /*==================================================================================================
26 IMPLEMENTATION OF MmsPluginEventHandler - Member Functions
27 ==================================================================================================*/
28 MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL;
31 MmsPluginEventHandler::MmsPluginEventHandler()
33 memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
37 MmsPluginEventHandler::~MmsPluginEventHandler()
43 MmsPluginEventHandler *MmsPluginEventHandler::instance()
46 pInstance = new MmsPluginEventHandler();
52 void MmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
54 listener = *pListener;
58 void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath)
60 MSG_MESSAGE_INFO_S msgInfo = {0,};
62 switch (pRequest->eMmsPduType) {
63 // received data is send-conf
65 MmsPluginInternal::instance()->processSendConf(&msgInfo, pRequest);
68 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
70 //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
71 if (remove(pRetrievedFilePath) != 0)
72 MSG_DEBUG("remove fail");
75 // received data is retrieve-conf
76 case eMMS_RETRIEVE_AUTO_CONF:
77 case eMMS_RETRIEVE_MANUAL_CONF:
78 MSG_ADDRESS_INFO_S addrInfo;
79 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
80 msgInfo.addressList = &addrInfo;
82 MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
85 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
88 case eMMS_FORWARD_CONF:
89 MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest);
92 case eMMS_READREPORT_CONF:
93 if (remove(pRetrievedFilePath) != 0)
94 MSG_DEBUG("remove fail");
102 void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
106 msg_error_t err = MSG_SUCCESS;
108 MSG_MESSAGE_INFO_S msgInfo;
109 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
111 MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId);
114 curTime = time(NULL);
116 msgInfo.displayTime = curTime;
118 switch (pRequest->eMmsPduType) {
121 msgInfo.msgId = pRequest->msgId;
122 //Set only changed members
123 msgInfo.msgType.mainType = MSG_MMS_TYPE;
125 if (pRequest->eMmsPduType == eMMS_SEND_REQ)
126 msgInfo.msgType.subType = MSG_SENDREQ_MMS;
128 msgInfo.msgType.subType = MSG_SENDCONF_MMS;
130 msgInfo.networkStatus = MSG_NETWORK_SEND_FAIL;
132 msgInfo.folderId = MSG_OUTBOX_ID;
134 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
137 case eMMS_RETRIEVE_AUTO:
138 case eMMS_RETRIEVE_AUTO_CONF:
139 msgInfo.msgId = pRequest->msgId;
140 //Set only changed members
141 msgInfo.msgType.mainType = MSG_MMS_TYPE;
142 msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
144 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
145 msgInfo.folderId = MSG_INBOX_ID;
147 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
151 case eMMS_RETRIEVE_MANUAL:
152 case eMMS_RETRIEVE_MANUAL_CONF:
153 msgInfo.msgId = pRequest->msgId;
154 //Set only changed members
155 msgInfo.msgType.mainType = MSG_MMS_TYPE;
156 msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
158 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
159 msgInfo.folderId = MSG_INBOX_ID;
161 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
169 MSG_DEBUG("Error value of MsgMmsConfIncomingListner [%d]", err);