2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "MmsPluginTypes.h"
21 #include "MmsPluginDebug.h"
22 #include "MmsPluginEventHandler.h"
23 #include "MmsPluginInternal.h"
25 /*==================================================================================================
26 IMPLEMENTATION OF SmsPluginEventHandler - 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 MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
81 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
84 case eMMS_FORWARD_CONF:
85 MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest);
88 case eMMS_READREPORT_CONF:
89 if (remove(pRetrievedFilePath) != 0)
90 MSG_DEBUG("remove fail");
98 void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
102 msg_error_t err = MSG_SUCCESS;
104 MSG_MESSAGE_INFO_S msgInfo;
105 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
107 MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId);
109 switch (pRequest->eMmsPduType) {
112 msgInfo.msgId = pRequest->msgId;
113 //Set only changed members
114 msgInfo.msgType.mainType = MSG_MMS_TYPE;
116 if (pRequest->eMmsPduType == eMMS_SEND_REQ)
117 msgInfo.msgType.subType = MSG_SENDREQ_MMS;
119 msgInfo.msgType.subType = MSG_SENDCONF_MMS;
121 msgInfo.networkStatus = MSG_NETWORK_SEND_FAIL;
123 msgInfo.folderId = MSG_OUTBOX_ID;
125 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
128 case eMMS_RETRIEVE_AUTO:
129 case eMMS_RETRIEVE_AUTO_CONF:
130 msgInfo.msgId = pRequest->msgId;
131 //Set only changed members
132 msgInfo.msgType.mainType = MSG_MMS_TYPE;
133 msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
135 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
136 msgInfo.folderId = MSG_INBOX_ID;
138 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
142 case eMMS_RETRIEVE_MANUAL:
143 case eMMS_RETRIEVE_MANUAL_CONF:
144 msgInfo.msgId = pRequest->msgId;
145 //Set only changed members
146 msgInfo.msgType.mainType = MSG_MMS_TYPE;
147 msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
149 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
150 msgInfo.folderId = MSG_INBOX_ID;
152 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);