RSA sync with private
[platform/core/messaging/msg-service.git] / plugin / mms_plugin / MmsPluginTransport.cpp
1 /*
2 * Copyright 2012  Samsung Electronics Co., Ltd
3 *
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
7 *
8 *    http://www.tizenopensource.org/license
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 <stdio.h>
18 #include "MmsPluginEventHandler.h"
19 #include "MmsPluginTransport.h"
20 #include "MsgUtilFile.h"
21 #include "MmsPluginCodec.h"
22 #include "MmsPluginMessage.h"
23 #include "MmsPluginUserAgent.h"
24
25
26 /*==================================================================================================
27                                      IMPLEMENTATION OF MmsPluginTransport - Member Functions
28 ==================================================================================================*/
29 MmsPluginTransport *MmsPluginTransport::pInstance = NULL;
30
31
32 MmsPluginTransport::MmsPluginTransport()
33 {
34
35 }
36
37
38 MmsPluginTransport::~MmsPluginTransport()
39 {
40
41 }
42
43
44 MmsPluginTransport *MmsPluginTransport::instance()
45 {
46         if (!pInstance)
47                 pInstance = new MmsPluginTransport();
48
49         return pInstance;
50 }
51
52
53 void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
54 {
55         mmsTranQEntity reqItem = {0};
56
57         reqItem.isCompleted = false;
58         reqItem.reqID = pReqInfo->reqId;
59
60         MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
61
62         switch (pReqInfo->msgInfo.msgType.subType) {
63         case MSG_SENDREQ_MMS:
64         case MSG_SENDREQ_JAVA_MMS:
65                 MSG_DEBUG("######### SEND REQUEST : POST TRANSACTION");
66                 reqItem.msgId = pReqInfo->msgInfo.msgId;
67                 reqItem.eMmsPduType = eMMS_SEND_REQ;
68                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
69                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
70                 break;
71
72         case MSG_GET_MMS:
73                 MSG_DEBUG("######### AUTO RETRIEVE : GET TRANSACTION");
74                 reqItem.msgId = pReqInfo->msgInfo.msgId;
75                 reqItem.eMmsPduType = eMMS_RETRIEVE_AUTO;
76                 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
77                 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
78                 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
79                 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
80                 break;
81
82         case MSG_NOTIFYRESPIND_MMS:
83         {
84                 MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
85                 reqItem.msgId = pReqInfo->msgInfo.msgId;
86                 reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
87                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
88                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
89                 int ret = remove(pReqInfo->msgInfo.msgData);
90                 if (ret != 0) {
91                         MSG_DEBUG("remove fail\n");
92                 }
93                 break;
94         }
95         case MSG_RETRIEVE_MMS:
96                 MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
97                 reqItem.msgId = pReqInfo->msgInfo.msgId;
98                 reqItem.eMmsPduType = eMMS_RETRIEVE_MANUAL;
99                 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
100                 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
101                 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
102                 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
103                 break;
104
105         case MSG_READREPLY_MMS:
106         {
107                 MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
108                 reqItem.msgId = pReqInfo->msgInfo.msgId;
109                 reqItem.eMmsPduType = eMMS_READREPORT_REQ;
110                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
111                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
112                 // remove x-Read-Rec.ind file
113                 int ret = remove(pReqInfo->msgInfo.msgData);
114                 if (ret != 0) {
115                         MSG_DEBUG("remove fail\n");
116                 }
117                 break;
118         }
119         case MSG_READRECIND_MMS:
120         {
121                 MSG_DEBUG("######### SEND READREC IND : POST TRANSACTION");
122                 reqItem.msgId = pReqInfo->msgInfo.msgId;
123                 reqItem.eMmsPduType = eMMS_READREC_IND;
124                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
125                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
126                 // remove x-Read-Rec.ind file
127                 int ret = remove(pReqInfo->msgInfo.msgData);
128                 if (ret != 0) {
129                         MSG_DEBUG("remove fail\n");
130                 }
131                 break;
132         }
133         case MSG_FORWARD_MMS:
134                 MSG_DEBUG("######### SEND FORWARD MSG : POST TRANSACTION");
135                 reqItem.msgId = pReqInfo->msgInfo.msgId;
136                 reqItem.eMmsPduType = eMMS_SEND_REQ;
137                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
138                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
139                 break;
140         }
141
142         MmsPluginUaManager::instance()->addMmsReqEntity(reqItem);
143         MmsPluginUaManager::instance()->start();
144 }
145
146
147 void MmsPluginTransport::cancelRequest(msg_request_id_t reqId)
148 {
149
150
151 }
152