2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.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.
21 #include "MsgUtilFile.h"
22 #include "MsgMmsTypes.h"
23 #include "MsgSoundPlayer.h"
24 #include "MsgStorageHandler.h"
25 #include "MmsPluginTransport.h"
26 #include "MmsPluginEventHandler.h"
27 #include "MmsPluginCodec.h"
28 #include "MmsPluginInternal.h"
29 #include "MmsPluginSmil.h"
30 #include "MsgMmsMessage.h"
33 /*==================================================================================================
34 IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
35 ==================================================================================================*/
36 MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL;
39 MmsPluginEventHandler::MmsPluginEventHandler()
41 memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
45 MmsPluginEventHandler::~MmsPluginEventHandler()
51 MmsPluginEventHandler *MmsPluginEventHandler::instance()
54 pInstance = new MmsPluginEventHandler();
60 void MmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
62 listener = *pListener;
66 void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath)
68 MSG_MESSAGE_INFO_S msgInfo = {0,};
70 switch (pRequest->eMmsPduType) {
71 // received data is send-conf
73 MmsPluginInternal::instance()->processSendConf(&msgInfo, pRequest);
76 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
78 //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
79 if (remove(pRetrievedFilePath) != 0)
80 MSG_DEBUG("remove fail");
83 // received data is retrieve-conf
84 case eMMS_RETRIEVE_AUTO_CONF:
85 case eMMS_RETRIEVE_MANUAL_CONF:
86 MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
89 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
92 case eMMS_FORWARD_CONF:
93 MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest);
96 case eMMS_READREPORT_CONF:
97 if (remove(pRetrievedFilePath) != 0)
98 MSG_DEBUG("remove fail");
106 void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
110 msg_error_t err = MSG_SUCCESS;
112 MSG_MESSAGE_INFO_S msgInfo = {};
114 MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId);
116 switch (pRequest->eMmsPduType) {
119 msgInfo.msgId = pRequest->msgId;
120 //Set only changed members
121 msgInfo.msgType.mainType = MSG_MMS_TYPE;
123 if (pRequest->eMmsPduType == eMMS_SEND_REQ)
124 msgInfo.msgType.subType = MSG_SENDREQ_MMS;
126 msgInfo.msgType.subType = MSG_SENDCONF_MMS;
128 msgInfo.networkStatus = MSG_NETWORK_SEND_FAIL;
130 msgInfo.folderId = MSG_OUTBOX_ID;
132 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
135 case eMMS_RETRIEVE_AUTO:
136 case eMMS_RETRIEVE_AUTO_CONF:
137 msgInfo.msgId = pRequest->msgId;
138 //Set only changed members
139 msgInfo.msgType.mainType = MSG_MMS_TYPE;
140 msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
142 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
143 msgInfo.folderId = MSG_INBOX_ID;
145 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
149 case eMMS_RETRIEVE_MANUAL:
150 case eMMS_RETRIEVE_MANUAL_CONF:
151 msgInfo.msgId = pRequest->msgId;
152 //Set only changed members
153 msgInfo.msgType.mainType = MSG_MMS_TYPE;
154 msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
156 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
157 msgInfo.folderId = MSG_INBOX_ID;
159 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);