update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / MmsPluginTransport.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 "MmsPluginEventHandler.h"
33 #include "MmsPluginTransport.h"
34 #include "MsgUtilFile.h"
35 #include "MmsPluginCodec.h"
36 #include "MmsPluginMessage.h"
37 #include "MmsPluginUserAgent.h"
38
39
40 /*==================================================================================================
41                                      IMPLEMENTATION OF MmsPluginTransport - Member Functions
42 ==================================================================================================*/
43 MmsPluginTransport *MmsPluginTransport::pInstance = NULL;
44
45
46 MmsPluginTransport::MmsPluginTransport()
47 {
48
49 }
50
51
52 MmsPluginTransport::~MmsPluginTransport()
53 {
54
55 }
56
57
58 MmsPluginTransport *MmsPluginTransport::instance()
59 {
60         if (!pInstance)
61                 pInstance = new MmsPluginTransport();
62
63         return pInstance;
64 }
65
66
67 void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
68 {
69         mmsTranQEntity reqItem = {0};
70
71         reqItem.isCompleted = false;
72         reqItem.reqID = pReqInfo->reqId;
73
74         MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
75
76         switch (pReqInfo->msgInfo.msgType.subType) {
77         case MSG_SENDREQ_MMS:
78         case MSG_SENDREQ_JAVA_MMS:
79                 MSG_DEBUG("######### SEND REQUEST : POST TRANSACTION");
80                 reqItem.msgId = pReqInfo->msgInfo.msgId;
81                 reqItem.eMmsPduType = eMMS_SEND_REQ;
82                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
83                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
84                 break;
85
86         case MSG_GET_MMS:
87                 MSG_DEBUG("######### AUTO RETRIEVE : GET TRANSACTION");
88                 reqItem.msgId = pReqInfo->msgInfo.msgId;
89                 reqItem.eMmsPduType = eMMS_RETRIEVE_AUTO;
90                 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
91                 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
92                 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
93                 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
94                 break;
95
96         case MSG_NOTIFYRESPIND_MMS:
97                 MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
98                 reqItem.msgId = pReqInfo->msgInfo.msgId;
99                 reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
100                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
101                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
102                 remove(pReqInfo->msgInfo.msgData);
103                 break;
104
105         case MSG_RETRIEVE_MMS:
106                 MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
107                 reqItem.msgId = pReqInfo->msgInfo.msgId;
108                 reqItem.eMmsPduType = eMMS_RETRIEVE_MANUAL;
109                 reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
110                 reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
111                 reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
112                 memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
113                 break;
114
115         case MSG_READREPLY_MMS:
116                 MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
117                 reqItem.msgId = pReqInfo->msgInfo.msgId;
118                 reqItem.eMmsPduType = eMMS_READREPORT_REQ;
119                 reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
120                 reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
121                 // remove mms file
122                 remove(pReqInfo->msgInfo.msgData);
123                 break;
124
125         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                 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