Merge "N_SE-24408 : Fix B/S after resend from MMS viewer" into tizen_2.0
[apps/core/preloaded/message-app.git] / viewer / include / msg-ui-viewer-utility.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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://floralicense.org/license
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 __MSG_VIEWER_UTILITY_H__
18 #define __MSG_VIEWER_UTILITY_H__
19
20 /*==================================================================================================
21  *                                                                      INCLUDE HEADERS
22  *==================================================================================================*/
23 #include "msg-ui-viewer-types.h"
24 #include <vconf.h>
25
26 /*==================================================================================================
27  *                                                                              DEFINITIONS
28  *==================================================================================================*/
29 #define MSG_VIEWER_COLOR_HEXA_BUFFER_LEN        2
30 #define MSG_VIEWER_HEXA_SIZE    16
31 #define MSG_VIEWER_RGB_COLOR_BUF        7
32 #define MSG_VIEWER_DEFAULT_FILE_NUMBER  1
33 #define MSG_VIEWER_INVALID_FILE_NUMBER  -1
34
35 #define MSG_VIEWER_THEME        EDJDIR"/msg_viewer.edj"
36 /*==================================================================================================
37  *                                                                              STRUCTURES
38  *==================================================================================================*/
39 typedef unsigned int MSG_VIEWER_COLORREF;
40
41 typedef struct _MSG_VIEWER_RGBQUAD {
42         unsigned char    rgbBlue;
43         unsigned char    rgbGreen;
44         unsigned char    rgbRed;
45         unsigned char    rgbReserved;
46 } MSG_VIEWER_RGBQUAD;
47
48 typedef union {
49         MSG_VIEWER_RGBQUAD rgbQuad;
50         MSG_VIEWER_COLORREF rgbColor;
51 } MSG_VIEWER_RGB_UNION;
52
53 /*==================================================================================================
54  *                                                                      FUNCTION DECLARATIONS
55  *==================================================================================================*/
56
57 /*
58  *@fn   msg_viewer_util_get_display_name_by_index(int index);
59  *@brief        this function is used to get display name from contact index
60  *@param[in] index contact_index
61  *@return       return display name of contact, Caller must free returned string after using it
62  */
63 char *msg_viewer_util_get_display_name_by_index(int index);
64
65 /*
66  *@fn   msg_viewer_util_get_file_ext(const char *filepath, char *file_ext, int ext_len);
67  *@brief        this function is used to get extension of file
68  *@param[in] address string pointer of filepath and file_ext
69  *@return       return TRUE on success, else FALSE
70  */
71 MSG_BOOL msg_viewer_util_get_file_ext(const char *filepath, char *file_ext, int ext_len);
72
73 /*
74  *@fn   msg_viewer_util_get_next_number(char *file_name_without_ext);
75  *@brief        this function is used to get the next number to rename the file
76  *@param[in] address string pointer of file_name_without_ext
77  *@return       return the number(int)
78  */
79 int msg_viewer_util_get_next_number(char *file_name_without_ext);
80
81 /*
82  *@fn   msg_viewer_util_get_color_as_string(char *szcolor, int szcolor_len, int r, int g, int b);
83  *@brief        this function is used to get rgb string from int to string like "ffffff". Buffer(szcolor) length should be longer than 7.
84  *@param[in]    r       Red color value
85  *@param[in]    g       Green color value
86  *@param[in]    b       Blue color value
87  *@param[in]    szcolor_len     buffer length of szcolor.
88  *@param[out]   szcolor RGB value will be get as string type.
89  */
90 void msg_viewer_util_get_color_as_string(char *szcolor, int szcolor_len, int r, int g, int b);
91
92 /*
93  *@fn   msg_viewer_util_get_default_path(char *dir_path, int dir_path_len);
94  *@brief        this function is used to get default file path
95  *@param[in]    dir_path_len    length of dir_path buffer
96  *@param[out]   dir_path        destination file_path of content to be saved
97  */
98 MSG_BOOL msg_viewer_util_get_default_path(char *dir_path, int dir_path_len);
99
100 /*
101  *@fn           msg_ui_viewer_get_buffer_from_file(const char *filepath, const char *opt, unsigned int *buffer_size)
102  *@brief                this function is used to get raw data of filepath
103  *@param[in] filepath src file path
104  *@param[in] opt open mode
105  *@param[out] buffer_size buffer size
106   *@return      return allocated raw file data, else NULL
107  *@Caution      Caller should free return raw file data after using it.
108  */
109 unsigned char *msg_ui_viewer_get_buffer_from_file(const char *filepath, const char *opt, unsigned int *buffer_size);
110
111 /*
112  *@fn           msg_ui_viewer_util_copy_file(const char *src_path, char *dst_path)
113  *@brief                Copy file from src to dest, if there is file at dest path, then save it with renamed one
114  *@param[in] src_path src file path
115  *@param[in] dst_path dest file path to be saved
116   *@return      return allocated copied file path, else NULL
117  *@Caution      Caller should free return copied file path after using data.
118  */
119 char *msg_ui_viewer_util_copy_file(const char *src_path, char *dst_path);
120
121 /*
122  *@fn           msg_ui_viewer_util_create_working_dir(void)
123  *@brief                create temp directroy to save a temp file for viewer
124   *@return      return created temp path, else NULL
125  *@Caution      Caller should free returned temp path after using it.
126  */
127 char *msg_ui_viewer_util_create_working_dir(void);
128 #endif