update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / MmsPluginEventHandler.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include<stdio.h>
32 #include<stdlib.h>
33
34 #include "MsgDebug.h"
35 #include "MsgUtilFile.h"
36 #include "MsgMmsTypes.h"
37 #include "MsgSoundPlayer.h"
38 #include "MsgStorageHandler.h"
39 #include "MmsPluginTransport.h"
40 #include "MmsPluginEventHandler.h"
41 #include "MmsPluginCodec.h"
42 #include "MmsPluginInternal.h"
43 #include "MmsPluginSmil.h"
44 #include "MsgMmsMessage.h"
45
46
47 /*==================================================================================================
48                                      IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
49 ==================================================================================================*/
50 MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL;
51
52
53 MmsPluginEventHandler::MmsPluginEventHandler()
54 {
55         memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
56 }
57
58
59 MmsPluginEventHandler::~MmsPluginEventHandler()
60 {
61
62 }
63
64
65 MmsPluginEventHandler *MmsPluginEventHandler::instance()
66 {
67         if (!pInstance)
68                 pInstance = new MmsPluginEventHandler();
69
70         return pInstance;
71 }
72
73
74 void MmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
75 {
76         listener = *pListener;
77 }
78
79
80 void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath)
81 {
82         MSG_MESSAGE_INFO_S msgInfo = {0,};
83
84         switch (pRequest->eMmsPduType) {
85         // received data is send-conf
86         case eMMS_SEND_CONF:
87                 MmsPluginInternal::instance()->processSendConf(&msgInfo, pRequest);
88
89                 // callback to MSG FW
90                 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
91
92                 //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
93                 remove(pRetrievedFilePath); // not ipc
94                 break;
95
96         // received data is retrieve-conf
97         case eMMS_RETRIEVE_AUTO_CONF:
98         case eMMS_RETRIEVE_MANUAL_CONF:
99                 MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
100
101                 // callback to MSG FW
102                 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
103                 break;
104
105         case eMMS_FORWARD_CONF:
106                 MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest);
107                 break;
108
109         default:
110                 break;
111         }
112 }
113
114
115 void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
116 {
117         MSG_BEGIN();
118
119         MSG_ERROR_T err = MSG_SUCCESS;
120
121         MSG_MESSAGE_INFO_S msgInfo = {};
122         MMS_RECV_DATA_S recvData = {{0}, };
123
124         MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId);
125
126         switch (pRequest->eMmsPduType) {
127         case eMMS_SEND_REQ:
128         case eMMS_SEND_CONF:
129                 msgInfo.msgId = pRequest->msgId;
130                 //Set only changed members
131                 msgInfo.msgType.mainType = MSG_MMS_TYPE;
132
133                 if (pRequest->eMmsPduType == eMMS_SEND_REQ)
134                         msgInfo.msgType.subType = MSG_SENDREQ_MMS;
135                 else
136                         msgInfo.msgType.subType = MSG_SENDCONF_MMS;
137
138                 msgInfo.networkStatus = MSG_NETWORK_SEND_FAIL;
139
140                 msgInfo.folderId = MSG_OUTBOX_ID;
141
142                 listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
143                 break;
144
145         case eMMS_RETRIEVE_AUTO:
146         case eMMS_RETRIEVE_AUTO_CONF:
147                 msgInfo.msgId = pRequest->msgId;
148                 //Set only changed members
149                 msgInfo.msgType.mainType = MSG_MMS_TYPE;
150                 msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
151
152                 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
153                 msgInfo.folderId = MSG_INBOX_ID;
154
155                 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
156
157                 break;
158
159         case eMMS_RETRIEVE_MANUAL:
160         case eMMS_RETRIEVE_MANUAL_CONF:
161                 msgInfo.msgId = pRequest->msgId;
162                 //Set only changed members
163                 msgInfo.msgType.mainType = MSG_MMS_TYPE;
164                 msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
165
166                 msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
167                 msgInfo.folderId = MSG_INBOX_ID;
168
169                 err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
170
171                 break;
172
173         default:
174                 break;
175         }
176
177         MSG_END();
178 }
179