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.
18 #include "MmsPluginEventHandler.h"
19 #include "MmsPluginTransport.h"
20 #include "MsgUtilFile.h"
21 #include "MmsPluginCodec.h"
22 #include "MmsPluginMessage.h"
23 #include "MmsPluginUserAgent.h"
26 /*==================================================================================================
27 IMPLEMENTATION OF MmsPluginTransport - Member Functions
28 ==================================================================================================*/
29 MmsPluginTransport *MmsPluginTransport::pInstance = NULL;
32 MmsPluginTransport::MmsPluginTransport()
38 MmsPluginTransport::~MmsPluginTransport()
44 MmsPluginTransport *MmsPluginTransport::instance()
47 pInstance = new MmsPluginTransport();
53 void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
55 mmsTranQEntity reqItem = {0};
57 reqItem.isCompleted = false;
58 reqItem.reqID = pReqInfo->reqId;
60 MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
62 switch (pReqInfo->msgInfo.msgType.subType) {
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);
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);
82 case MSG_NOTIFYRESPIND_MMS:
83 MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
84 reqItem.msgId = pReqInfo->msgInfo.msgId;
85 reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
86 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
87 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
88 remove(pReqInfo->msgInfo.msgData);
91 case MSG_RETRIEVE_MMS:
92 MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
93 reqItem.msgId = pReqInfo->msgInfo.msgId;
94 reqItem.eMmsPduType = eMMS_RETRIEVE_MANUAL;
95 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
96 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
97 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
98 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
101 case MSG_READREPLY_MMS:
102 MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
103 reqItem.msgId = pReqInfo->msgInfo.msgId;
104 reqItem.eMmsPduType = eMMS_READREPORT_REQ;
105 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
106 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
107 // remove x-Read-Rec.ind file
108 remove(pReqInfo->msgInfo.msgData);
111 case MSG_READRECIND_MMS:
112 MSG_DEBUG("######### SEND READREC IND : POST TRANSACTION");
113 reqItem.msgId = pReqInfo->msgInfo.msgId;
114 reqItem.eMmsPduType = eMMS_READREC_IND;
115 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
116 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
117 // remove x-Read-Rec.ind file
118 remove(pReqInfo->msgInfo.msgData);
121 case MSG_FORWARD_MMS:
122 MSG_DEBUG("######### SEND FORWARD MSG : POST TRANSACTION");
123 reqItem.msgId = pReqInfo->msgInfo.msgId;
124 reqItem.eMmsPduType = eMMS_SEND_REQ;
125 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
126 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
130 MmsPluginUaManager::instance()->addMmsReqEntity(reqItem);
131 MmsPluginUaManager::instance()->start();
135 void MmsPluginTransport::cancelRequest(msg_request_id_t reqId)