Sync with tizen 2.4
[platform/core/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginCodecCommon.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_CODEC_COMMON_H
18 #define MMS_PLUGIN_CODEC_COMMON_H
19
20 #include "MmsPluginCodecTypes.h"
21
22 #define         MSG_CH_CR                                               '\r'
23 #define         MSG_CH_LF                                               '\n'
24 #define         MSG_CH_SP                                               ' '
25 #define         MSG_CH_TAB                                              '\t'
26 #define         MSG_CH_NULL                                             '\0'
27 #define         MSG_CH_COLON                                    ':'
28 #define         MSG_CH_SEMICOLON                                ';'
29 #define         MSG_CH_UNDERLINE                                '_'
30 #define         MSG_CH_COMMA                                    ','
31 #define         MSG_CH_BASE64_LOWER                             'b'
32 #define         MSG_CH_BASE64_UPPER                             'B'
33 #define         MSG_CH_QPRINT_LOWER                             'Q'
34 #define         MSG_CH_QPRINT_UPPER                             'q'
35
36 #define         MSG_CH_QUESTION                                 '?'
37 #define         MSG_CH_QUOT                                             '"'
38 #define         MSG_CH_EQUAL                                    '='
39 #define         MSG_CH_BRACKET_S                                '<'
40 #define         MSG_CH_BRACKET_E                                '>'
41
42 #define         MSG_STR_DEC_START                       "=?"
43 #define         MSG_STR_DEC_END                         "?="
44 #define         MSG_STR_CRLF                            "\r\n"
45 #define         MSG_END_OF_HEADER                       "\r\n\r\n"
46 #define         MSG_STR_DOUBLE_HYPEN            "--"
47 #define         MSG_STR_BOUNDARY_DEL            "\r\n--"
48
49 #define         MSG_MMS_CH_EMAIL_AT                     '@'
50
51 /* character-set parameter value of content-type header field */
52 enum {
53         MSG_CHARSET_US_ASCII,
54         MSG_CHARSET_UTF16,
55         MSG_CHARSET_USC2,
56         MSG_CHARSET_UTF8,
57         MSG_CHARSET_ISO_2022_KR,
58         MSG_CHARSET_KS_C_5601_1987,
59         MSG_CHARSET_EUC_KR,
60         MSG_CHARSET_ISO_2022_JP,
61         MSG_CHARSET_ISO_2022_JP_2,
62         MSG_CHARSET_ISO_8859_1,
63         MSG_CHARSET_ISO_8859_2,
64         MSG_CHARSET_ISO_8859_3,
65         MSG_CHARSET_ISO_8859_4,
66         MSG_CHARSET_ISO_8859_5,
67         MSG_CHARSET_ISO_8859_6,
68         MSG_CHARSET_ISO_8859_7,
69         MSG_CHARSET_ISO_8859_8,
70         MSG_CHARSET_ISO_8859_9,
71         MSG_CHARSET_ISO_8859_10,
72         MSG_CHARSET_ISO_8859_15,
73         MSG_CHARSET_Shift_JIS,
74         MSG_CHARSET_EUC_JP,
75         MSG_CHARSET_GB2312,
76         MSG_CHARSET_BIG5,
77         MSG_CHARSET_WIN1251,
78         MSG_CHARSET_KOI8_R,
79         MSG_CHARSET_KOI8_U,
80
81         MSG_CHARSET_NUM,
82         MSG_CHARSET_UNKNOWN
83 };
84
85 /* Content-Transfer-Encoding header field value */
86 enum {
87         MSG_ENCODING_7BIT,
88         MSG_ENCODING_8BIT,
89         MSG_ENCODING_BINARY,
90         MSG_ENCODING_BASE64,
91         MSG_ENCODING_QUOTE_PRINTABLE,
92         MSG_ENCODING_NUM,
93         MSG_ENCODING_OTHER,
94 };
95
96
97 /* Content-Disposition header field value */
98 enum {
99         MSG_DISPOSITION_FORMDATA,
100         MSG_DISPOSITION_ATTACHMENT,
101         MSG_DISPOSITION_INLINE,
102         MSG_DISPOSITION_NUM
103 };
104
105 /* MIME header field */
106 enum {
107         MSG_FIELD_RETURN_PATH,
108         MSG_FIELD_MESSAGE_ID,
109         MSG_FIELD_FROM,
110         MSG_FIELD_TO,
111         MSG_FIELD_CC,
112         MSG_FIELD_SUBJECT,
113         MSG_FIELD_DATE,
114         MSG_FIELD_MIME_VERSION,
115         MSG_FIELD_CONTENT_TYPE,
116         MSG_FIELD_CONTENT_TRANSFER_ENCODING,
117         MSG_FIELD_CONTENT_DISPOSITION, //If start param is given in multipart/related, this field will be ignored
118         MSG_FIELD_CONTENT_ID,
119         MSG_FIELD_CONTENT_LOCATION,
120         MSG_FIELD_CONTENT_NAME,
121         MSG_FIELD_CONTENT_DESCRIPTION,
122         MSG_FIELD_CONTENT_VENDOR,
123         MSG_FIELD_RIGHT_ISSUER,
124
125         MSG_FIELD_RETURN_RECEIPT_TO,                    /* for Delivery confirm */
126         MSG_FIELD_DISPOSITION_NOTIFICATION_TO,  /* for Read confirm */
127
128         MSG_FILED_CONTENT_REPLACE_POS,
129         MSG_FILED_CONTENT_REPLACE_SIZE,
130         MSG_FILED_CONTENT_REPLACE_INDEX,
131
132         MSG_FIELD_DRM_CONVERTED,
133
134         MSG_FIELD_NUM,
135         MSG_FIELD_UNKNOWN,
136 };
137
138 /* MIME header field parameter */
139 enum {
140         MSG_PARAM_CHARSET,
141         MSG_PARAM_NAME,
142         MSG_PARAM_FILENAME,
143         MSG_PARAM_TYPE,                 // only used as parameter of Content-Type: multipart/related
144         MSG_PARAM_START,                // Only if content-type is multipart/related
145         MSG_PARAM_START_INFO,   // Only if content-type is multipart/related
146         MSG_PARAM_BOUNDARY,
147         MSG_PARAM_REPORT_TYPE,  // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
148 #ifdef FEATURE_JAVA_MMS
149         MSG_PARAM_APPLICATION_ID,
150         MSG_PARAM_REPLY_TO_APPLICATION_ID,
151 #endif
152         MSG_PARAM_NUM,
153         MSG_PARAM_UNKNOWN,
154 };
155
156 const char *MmsGetTextByCode(MmsCode i, UINT16 code);
157 const char *MmsGetTextValue(MmsCode i, int j);
158 const char *MmsGetTextValuebyField(int field, int value);
159 int MmsGetBinaryType(MmsCode i, UINT16 value);
160 int MmsGetTextType(MmsCode i, char *pValue);
161 UINT16 MmsGetBinaryValue(MmsCode i, int j);
162
163 void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
164 bool MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
165 unsigned char *MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
166
167 char *MsgDecodeText(const char *pOri);
168
169 const char *MmsDebugGetMimeType(MimeType mimeType);
170 const char *MmsDebugGetMmsReport(MmsReport report);
171 const char *MmsDebugGetMmsReportAllowed(MmsReportAllowed reportAllowed);
172 const char *MmsDebugGetMmsReadStatus(msg_read_report_status_t readStatus);
173 const char *MmsDebugGetMsgType(MmsMsgType msgType);
174 const char *MmsDebugGetResponseStatus(MmsResponseStatus responseStatus);
175 const char *MmsDebugGetRetrieveStatus(MmsRetrieveStatus retrieveStatus);
176 const char *MmsDebugGetMsgStatus(msg_delivery_report_status_t msgStatus);
177 const char *MmsDebugGetMsgClass(MmsMsgClass msgClass);
178 const char *MmsDebugGetDataType(MmsDataType dataType);
179
180 bool MmsInitMsgType(MsgType *pMsgType);
181 bool MmsInitMsgBody(MsgBody *pMsgBody);
182 bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam);
183 bool MmsInitMsgAttrib(MmsAttrib *pAttrib);
184 bool MmsInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo);
185
186 bool MmsReleaseMsgBody(MsgBody *pBody, int type);
187 bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib);
188 void MmsReleaseMsgDRMInfo(MsgDRMInfo *pDrmInfo);
189 void MmsReleaseMmsMsg(MmsMsg *pMmsMsg);
190
191 bool MmsIsTextType(int type);
192 bool MmsIsMultipart(int type);
193 bool MmsIsVitemContent(int type, char *pszName);
194
195 MsgMultipart *MmsAllocMultipart(void);
196 bool MmsPrintMulitpart(MsgMultipart *pMultipart, int index);
197 #endif //MMS_PLUGIN_CODEC_COMMON_H