update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginSmil.h
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 <string.h>
33 #include <sys/stat.h>
34 #include <libxml/parser.h>
35 #include <libxml/tree.h>
36 #include "MsgTypes.h"
37 #include "MsgMmsTypes.h"
38 #include "MmsPluginCodec.h"
39
40 #ifndef MMS_PLUGIN_SMIL_H
41 #define MMS_PLUGIN_SMIL_H
42
43 typedef enum _SMIL_ELEMENT_T {
44         ELEMENT_SMIL,
45         ELEMENT_HEAD,
46         ELEMENT_LAYOUT,
47         ELEMENT_ROOTLAYOUT,
48         ELEMENT_REGION,
49         ELEMENT_TRANSITION,
50         ELEMENT_META,
51         ELEMENT_BODY,
52         ELEMENT_PAR,
53         ELEMENT_PARAM,
54         ELEMENT_TEXT,
55         ELEMENT_IMG,
56         ELEMENT_AUDIO,
57         ELEMENT_VIDEO,
58         ELEMENT_REF,
59         ELEMENT_ANIMATE,
60         ELEMENT_MAX,
61 } SMIL_ELEMENT_T;
62
63 typedef int     HMmsSmil;                       // SmilDoc Handle
64
65 #define MMS_SMIL_MAX_DOC        1
66 #define MMS_SMIL_COLOR_SIZE     10
67 #define INVALID_HOBJ    -1
68 #define SP_NO_COLOR_SET -1
69 #define SP_BLACK        0
70
71 /* Structures */
72 /**
73  *      @brief  Represents Smil Doc Information. \n
74  */
75 typedef struct _MmsSmilDoc {
76         xmlDocPtr pSmilDoc;
77         xmlNodePtr pstRootNode;
78 } MmsSmilDoc;
79
80 typedef enum _SMIL_ATTRIBUTE_T {
81         ATTRIBUTE_UNKNOWN = -1,
82         ATTRIBUTE_ID,
83         ATTRIBUTE_TOP,
84         ATTRIBUTE_LEFT,
85         ATTRIBUTE_WIDTH,
86         ATTRIBUTE_HEIGHT,
87         ATTRIBUTE_FIT,
88         ATTRIBUTE_BGCOLOR,
89         ATTRIBUTE_DUR,
90         ATTRIBUTE_SRC,
91         ATTRIBUTE_COLOR,
92         ATTRIBUTE_BOLD,
93         ATTRIBUTE_UNDERLINE,
94         ATTRIBUTE_ITALIC,
95         ATTRIBUTE_REVERSE,
96         ATTRIBUTE_DIRECTION,
97         ATTRIBUTE_SIZE,
98         ATTRIBUTE_FONT,
99         ATTRIBUTE_REGION,
100         ATTRIBUTE_NAME,
101         ATTRIBUTE_VALUE,
102         ATTRIBUTE_ALT,
103         ATTRIBUTE_TYPE,
104         ATTRIBUTE_SUBTYPE,
105         ATTRIBUTE_CONTENT,
106         ATTRIBUTE_FGCOLOR,
107         ATTRIBUTE_TEXTFORMAT,
108         ATTRIBUTE_TRANSIN,
109         ATTRIBUTE_TRANSOUT,
110         ATTRIBUTE_BEGIN,
111         ATTRIBUTE_END,
112         ATTRIBUTE_REPEAT_COUNT,
113 #ifdef MMS_SMIL_ANIMATE
114         ATTRIBUTE_ATTRIBUTE_NAME,
115         ATTRIBUTE_ATTRIBUTE_TYPE,
116         ATTRIBUTE_TARGET_ELEMENT,
117         ATTRIBUTE_FROM,
118         ATTRIBUTE_TO,
119         ATTRIBUTE_BY,
120         ATTRIBUTE_VALUES,
121         ATTRIBUTE_CALCMODE,
122 #endif
123 } SMIL_ATTRIBUTE_T;
124
125 char *MmsSmilGetPresentationData(MSG_MESSAGE_ID_T msgId);
126 bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc);
127 void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node);
128 int MmsSmilGetColorValue(xmlChar *content);
129 int MmsSmilGetTime(char *pValue);
130 int MmsSmilAtoIHexa(char *pInput);
131 #ifndef __SUPPORT_DRM__
132 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart);
133 #else
134 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia);
135 #endif
136 int MmsSmilGetElementID(char *pString);
137 int MmsSmilGetAttrID(char *pString);
138 bool MmsSmilGetFontAttrib(char *pString);
139 MmsTextDirection MmsSmilGetFontDirection(char *pString);
140 int MmsSmilGetFontSizeValue(char *pString);
141 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString);
142 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID);
143 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID);
144 /**     @fn             bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
145  *      @brief  Forms Smil Buffer using pstMsgBody. \n
146  *      @param[in/out]  pstMsgBody is Message handle. \n
147  *      @retval TRUE                            In case of Success. \n
148  *      @retval FALSE                           In case of failure. \n
149  */
150 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody);
151
152 /**     @fn             HMmsSmil MmsSmilCreateEmptySmilDoc(void)
153  *      @brief  Creates default Smil Doc based on input gszEmptyRawDoc. \n
154  *      @retval Returns Smil Document number. \n
155  */
156 HMmsSmil MmsSmilCreateEmptySmilDoc(void);
157
158  /**    @fn                     HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
159  *      @brief          Creates Smil Doc based on input pszRawData. \n
160  *      @param[in]      pszRawData is smil buffer. \n
161  *      @retval         Returns Smil Document number. \n
162  */
163 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData);
164
165  /**    @fn                     BOOL MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
166  *      @brief          Destroys Smil Doc. \n
167  *      @param[in]      hSmilDoc is smil doc number. \n
168  *      @retval TRUE                            In case of Success. \n
169  *      @retval FALSE                           In case of failure. \n
170  */
171 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc);
172
173 /**     @fn                     static bool IsValidSmilDocNo(int nSmilDocNo)
174  *      @brief          Form Smil Doc. \n
175  *      @param[in]      hSmilDoc is smil doc number. \n
176  *      @retval         Returns Smil Buffer     In case of success. \n
177  *      @retval         Returns NULL                    In case of failure. \n
178  */
179 bool IsValidSmilDocNo(int nSmilDocNo);
180
181 /**     @fn                     static char * MmsSmilGetRawData( HMmsSmil hSmilDoc )
182  *      @brief          Form Smil Doc. \n
183  *      @param[in]      hSmilDoc is smil doc number. \n
184  *      @retval         Returns Smil Buffer             In case of success. \n
185  *      @retval         Returns NULL                    In case of failure. \n
186  */
187 char *MmsSmilGetRawData(HMmsSmil hSmilDoc);
188
189 /**     @fn                     static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
190  *      @brief          Add Page to Smil Doc. \n
191  *      @param[in]      hSmilDoc is smil doc number. \n
192  *      @param[in]      pstSmilPage specifies page information. \n
193  *      @retval         TRUE                            In case of Success. \n
194  *      @retval         FALSE                           In case of failure. \n
195  */
196 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage);
197
198 /**     @fn                     static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
199  *      @brief          Add Rootlayout to Smil Doc. \n
200  *      @param[in]      hSmilDoc is smil doc number. \n
201  *      @param[in]      pstSmilRootLayout specifies RootLayout information. \n
202  *      @retval         TRUE                            In case of Success. \n
203  *      @retval         FALSE                           In case of failure. \n
204  */
205 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout);
206
207 /**     @fn                     static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
208  *      @brief          Add Region to Smil Doc. \n
209  *      @param[in]      hSmilDoc is smil doc number. \n
210  *      @param[in]      pstSmilRegion specifies Region information. \n
211  *      @retval         TRUE                            In case of Success. \n
212  *      @retval         FALSE                           In case of failure. \n
213  */
214 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion);
215
216 /**     @fn                     static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
217  *      @brief          Add Media to Smil Doc. \n
218  *      @param[in]      hSmilDoc is smil doc number. \n
219  *      @param[in]      nPageNo specifies page number to which media belongs. \n
220  *      @param[in]      nMediaIdx specifies medi ID. \n
221  *      @param[in]      pstSmilMedia specifies Media information. \n
222  *      @param[in]      pszContentID specifies Content ID of media. \n
223  *      @retval         TRUE                            In case of Success. \n
224  *      @retval         FALSE                           In case of failure. \n
225  */
226 bool MmsSmilAddMedia(HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
227
228 /**     @fn                     static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
229  *      @brief          Create Text Element. \n
230  *      @param[in]      pstSmilMedia specifies Media information. \n
231  *      @param[in]      pszContentID specifies Content ID of media. \n
232  *      @retval         Text Element node               In case of Success. \n
233  *      @retval         NULL                            In case of failure. \n
234  */
235 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
236
237 /**     @fn                     static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
238  *      @brief          Create Image/Audio/Video Element. \n
239  *      @param[in]      pstSmilMedia specifies Media information. \n
240  *      @param[in]      pszContentID specifies Content ID of media. \n
241  *      @retval         Image/Audio/Video Element node  In case of Success. \n
242  *      @retval         NULL                                                    In case of failure. \n
243  */
244 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
245
246 /**     @fn                     static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pNode)
247  *      @brief          Inserts first child to parent node. \n
248  *      @param[in]      pstParent specifies Parent node. \n
249  *      @param[in]      pNode specifies Child node. \n
250  *      @retval         TRUE                            In case of Success. \n
251  *      @retval         FALSE                           In case of failure. \n
252  */
253 bool __MmsInsertFirstChild(xmlNode *pParent, xmlNode *pNode);
254
255 /**     @fn                     static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pNode)
256  *      @brief          Inserts node. \n
257  *      @param[in]      pstParent specifies Parent node. \n
258  *      @param[in]      pstLeftSibling specifies Left Sibling node. \n
259  *      @param[in]      pNode specifies Child node. \n
260  *      @retval         TRUE                            In case of Success. \n
261  *      @retval         FALSE                           In case of failure. \n
262  */
263 bool __MmsSmilInsertNode(xmlNode *pParent, xmlNode *pLeftSibling, xmlNode *pNode);
264
265 /**     @fn                     static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
266  *      @brief          Sets Attribute. \n
267  *      @param[in]      pNode specifies node. \n
268  *      @param[in]      szField specifies attribute field. \n
269  *      @param[in]      szValue specifies value of field \n
270  */
271 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue);
272
273 /**     @fn                     static char *__MmsSmilFindColorValue(int nValue)
274  *      @brief          Converts color to RGB. \n
275  *      @param[in]      nValue specifies color value. \n
276  *      @retval         RGB value. \n
277  */
278 char *__MmsSmilFindColorValue(int nValue);
279
280 /**     @fn                     static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
281  *      @brief          Get node based on pszValue. \n
282  *      @param[in]      pNode specifies node. \n
283  *      @param[in]      pszName specifies name field. \n
284  *      @retval         RGB value. \n
285  */
286 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName);
287
288 #endif//MMS_PLUGIN_SMIL_H
289
290