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.
18 #include "MsgUtilFile.h"
19 #include "MmsPluginDebug.h"
20 #include "MmsPluginTypes.h"
21 #include "MmsPluginTransport.h"
22 #include "MmsPluginUserAgent.h"
23 #include "MsgGconfWrapper.h"
25 /*==================================================================================================
26 IMPLEMENTATION OF MmsPluginTransport - Member Functions
27 ==================================================================================================*/
28 MmsPluginTransport *MmsPluginTransport::pInstance = NULL;
31 MmsPluginTransport::MmsPluginTransport()
37 MmsPluginTransport::~MmsPluginTransport()
43 MmsPluginTransport *MmsPluginTransport::instance()
46 pInstance = new MmsPluginTransport();
52 void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
54 mmsTranQEntity reqItem = {0};
56 reqItem.isCompleted = false;
57 reqItem.reqID = pReqInfo->reqId;
60 msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
62 MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
64 switch (pReqInfo->msgInfo.msgType.subType) {
66 case MSG_SENDREQ_JAVA_MMS:
67 MSG_DEBUG("######### SEND REQUEST : POST TRANSACTION");
68 reqItem.msgId = pReqInfo->msgInfo.msgId;
69 reqItem.eMmsPduType = eMMS_SEND_REQ;
70 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
71 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
72 MSG_MMS_VLD_INFO("%d, MMS Send Start %s->%s, Success", pReqInfo->msgInfo.msgId, (msisdn == NULL)?"ME":msisdn, pReqInfo->msgInfo.addressList[0].addressVal);
76 MSG_DEBUG("######### AUTO RETRIEVE : GET TRANSACTION");
77 reqItem.msgId = pReqInfo->msgInfo.msgId;
78 reqItem.eMmsPduType = eMMS_RETRIEVE_AUTO;
79 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
80 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
81 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
82 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
83 MSG_MMS_VLD_INFO("%d, MMS Receive Auto Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn);
86 case MSG_NOTIFYRESPIND_MMS: //reject
88 MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
89 reqItem.msgId = pReqInfo->msgInfo.msgId;
90 reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
91 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
92 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
93 int ret = remove(pReqInfo->msgInfo.msgData);
95 MSG_DEBUG("remove fail\n");
99 case MSG_RETRIEVE_MMS:
100 MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
101 reqItem.msgId = pReqInfo->msgInfo.msgId;
102 reqItem.eMmsPduType = eMMS_RETRIEVE_MANUAL;
103 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
104 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
105 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
106 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
107 MSG_MMS_VLD_INFO("%d, MMS Receive Manual Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn);
110 case MSG_READREPLY_MMS:
112 MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
113 reqItem.msgId = pReqInfo->msgInfo.msgId;
114 reqItem.eMmsPduType = eMMS_READREPORT_REQ;
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 int ret = remove(pReqInfo->msgInfo.msgData);
120 MSG_DEBUG("remove fail\n");
124 case MSG_READRECIND_MMS:
126 MSG_DEBUG("######### SEND READREC IND : POST TRANSACTION");
127 reqItem.msgId = pReqInfo->msgInfo.msgId;
128 reqItem.eMmsPduType = eMMS_READREC_IND;
129 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
130 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
131 // remove x-Read-Rec.ind file
132 int ret = remove(pReqInfo->msgInfo.msgData);
134 MSG_DEBUG("remove fail\n");
138 case MSG_FORWARD_MMS:
139 MSG_DEBUG("######### SEND FORWARD MSG : POST TRANSACTION");
140 reqItem.msgId = pReqInfo->msgInfo.msgId;
141 reqItem.eMmsPduType = eMMS_SEND_REQ;
142 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
143 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
144 MSG_MMS_VLD_INFO("%d, MMS Send Start %s->%s, Success", pReqInfo->msgInfo.msgId, (msisdn == NULL)?"ME":msisdn, pReqInfo->msgInfo.addressList[0].addressVal);
148 MmsPluginUaManager::instance()->addMmsReqEntity(reqItem);
149 MmsPluginUaManager::instance()->start();
152 void MmsPluginTransport::cancelRequest(msg_request_id_t reqId)