Fix issue : fail to make thumbnail
[platform/core/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginHttp.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 #ifndef MMS_PLUGIN_HTTP_H
18 #define MMS_PLUGIN_HTTP_H
19
20 #include <map>
21 #include "MmsPluginTypes.h"
22 #include "MsgMutex.h"
23
24 #define MSG_MMS_HH_CONTENT_TYPE     "application/vnd.wap.mms-message"
25 #define MSG_MMS_HH_ACCEPT           "application/vnd.wap.mms-message, */*"
26 #define MSG_MMS_HH_CHARSET          "utf-8, us-ascii"
27 #define MSG_MMS_HH_LANGUAGE         "zh-cn, en"
28 #define MSG_MMS_HH_ENCODING         "deflate,gzip"
29
30 #define MSG_MMS_HH_USER_AGENT           "Mozilla/5.0 (Linux; Tizen 2.3) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3"
31
32 typedef unsigned int MMS_HTTP_HEADER_FIELD_T;
33
34 typedef enum _MMS_HTTP_HEADER_FIELD_E {
35         MMS_HH_CONTENT_TYPE,
36         MMS_HH_HOST,
37         MMS_HH_ACCEPT,
38         MMS_HH_ACCEPT_CHARSET,
39         MMS_HH_ACCEPT_LANGUAGE,
40         MMS_HH_ACCEPT_ENCODING,
41         MMS_HH_USER_AGENT,
42         MMS_HH_UA_PROFILE,
43 #if defined(FEATURE_SMS_CDMA)
44         MMS_HH_MDN
45 #endif
46 } MMS_HTTP_HEADER_FIELD_E;
47
48 typedef enum _MMS_HTTP_TRANSACTION_TYPE_E {
49         MMS_HTTP_TRANSACTION_TYPE_UNKNOWN = 0,
50         MMS_HTTP_TRANSACTION_TYPE_GET,
51         MMS_HTTP_TRANSACTION_TYPE_POST,
52 } MMS_HTTP_TRANSACTION_TYPE_E;
53
54 typedef enum _MMS_HTTP_ERROR_E {
55         MMS_HTTP_ERROR_NONE = 0,
56         MMS_HTTP_ERROR_ABORT,
57         MMS_HTTP_ERROR_TRANSACTION_TYPE,
58         MMS_HTTP_ERROR_TRANSACTION,
59         MMS_HTTP_ERROR_SESSION,
60 } MMS_HTTP_ERROR_E;
61
62 typedef struct _http_session_info_s {
63         MMS_HTTP_TRANSACTION_TYPE_E transaction_type;
64         const char *url;
65         const char *proxy;
66         const char *dns_list;
67         const char *interface;
68         const char *post_data;
69         unsigned int post_data_len;
70         char *response_data;
71         unsigned int response_data_len;
72 } http_request_info_s;
73
74 class MmsPluginHttpAgent {
75         public:
76                 static MmsPluginHttpAgent *instance();
77
78                 MMS_HTTP_ERROR_E httpRequest(http_request_info_s &request_info);
79
80                 void setAbortFlag(){
81                         MsgMutexLocker locker(mx);
82                         abort = true;
83                 };
84
85                 bool getAbortFlag(){
86                         MsgMutexLocker locker(mx);
87                         return abort;
88                 };
89
90         private:
91                 static MmsPluginHttpAgent *pInstance;
92
93                 MmsPluginHttpAgent();
94                 ~MmsPluginHttpAgent();
95
96                 void initSession();
97                 MMS_HTTP_ERROR_E setSession(http_request_info_s &request_info);
98                 MMS_HTTP_ERROR_E startTransaction();
99                 void clearSession();
100
101                 void initAbortFlag(){
102                         MsgMutexLocker locker(mx);
103                         abort = false;
104                 };
105
106                 MMS_HTTP_TRANSACTION_TYPE_E transaction_type;
107
108                 void *session_header;
109                 void *session_option;
110
111                 FILE *respfile;
112                 bool abort;
113                 MsgMutex mx;
114 };
115
116 #endif /* MMS_PLUGIN_HTTP_H */