summaryrefslogtreecommitdiff
path: root/viewer/include/msg-ui-viewer-utility.h
blob: 63229ceaee3ff73b0c59d452be60a025a04fc396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __MSG_VIEWER_UTILITY_H__
#define __MSG_VIEWER_UTILITY_H__

/*==================================================================================================
 *									INCLUDE HEADERS
 *==================================================================================================*/
#include "msg-ui-viewer-types.h"
#include <vconf.h>

/*==================================================================================================
 *										DEFINITIONS
 *==================================================================================================*/
#define MSG_VIEWER_COLOR_HEXA_BUFFER_LEN	2
#define MSG_VIEWER_HEXA_SIZE	16
#define MSG_VIEWER_RGB_COLOR_BUF	7
#define MSG_VIEWER_DEFAULT_FILE_NUMBER	1
#define MSG_VIEWER_INVALID_FILE_NUMBER	-1

#define MSG_VIEWER_THEME	EDJDIR"/msg_viewer.edj"
/*==================================================================================================
 *										STRUCTURES
 *==================================================================================================*/
typedef unsigned int MSG_VIEWER_COLORREF;

typedef struct _MSG_VIEWER_RGBQUAD {
	unsigned char    rgbBlue;
	unsigned char    rgbGreen;
	unsigned char    rgbRed;
	unsigned char    rgbReserved;
} MSG_VIEWER_RGBQUAD;

typedef union {
	MSG_VIEWER_RGBQUAD rgbQuad;
	MSG_VIEWER_COLORREF rgbColor;
} MSG_VIEWER_RGB_UNION;

/*==================================================================================================
 *									FUNCTION DECLARATIONS
 *==================================================================================================*/

/*
 *@fn	msg_viewer_util_get_display_name_by_index(int index);
 *@brief	this function is used to get display name from contact index
 *@param[in] index contact_index
 *@return	return display name of contact, Caller must free returned string after using it
 */
char *msg_viewer_util_get_display_name_by_index(int index);

/*
 *@fn	msg_viewer_util_get_file_ext(const char *filepath, char *file_ext, int ext_len);
 *@brief	this function is used to get extension of file
 *@param[in] address string pointer of filepath and file_ext
 *@return	return TRUE on success, else FALSE
 */
MSG_BOOL msg_viewer_util_get_file_ext(const char *filepath, char *file_ext, int ext_len);

/*
 *@fn	msg_viewer_util_get_next_number(char *file_name_without_ext);
 *@brief	this function is used to get the next number to rename the file
 *@param[in] address string pointer of file_name_without_ext
 *@return	return the number(int)
 */
int msg_viewer_util_get_next_number(char *file_name_without_ext);

/*
 *@fn	msg_viewer_util_get_color_as_string(char *szcolor, int szcolor_len, int r, int g, int b);
 *@brief	this function is used to get rgb string from int to string like "ffffff". Buffer(szcolor) length should be longer than 7.
 *@param[in]	r	Red color value
 *@param[in]	g	Green color value
 *@param[in]	b	Blue color value
 *@param[in]	szcolor_len	buffer length of szcolor.
 *@param[out]	szcolor	RGB value will be get as string type.
 */
void msg_viewer_util_get_color_as_string(char *szcolor, int szcolor_len, int r, int g, int b);

/*
 *@fn	msg_viewer_util_get_default_path(char *dir_path, int dir_path_len);
 *@brief	this function is used to get default file path
 *@param[in]	dir_path_len	length of dir_path buffer
 *@param[out]	dir_path	destination file_path of content to be saved
 */
MSG_BOOL msg_viewer_util_get_default_path(char *dir_path, int dir_path_len);

/*
 *@fn		msg_ui_viewer_get_buffer_from_file(const char *filepath, const char *opt, unsigned int *buffer_size)
 *@brief		this function is used to get raw data of filepath
 *@param[in] filepath src file path
 *@param[in] opt open mode
 *@param[out] buffer_size buffer size
  *@return	return allocated raw file data, else NULL
 *@Caution	Caller should free return raw file data after using it.
 */
unsigned char *msg_ui_viewer_get_buffer_from_file(const char *filepath, const char *opt, unsigned int *buffer_size);

/*
 *@fn		msg_ui_viewer_util_copy_file(const char *src_path, char *dst_path)
 *@brief		Copy file from src to dest, if there is file at dest path, then save it with renamed one
 *@param[in] src_path src file path
 *@param[in] dst_path dest file path to be saved
  *@return	return allocated copied file path, else NULL
 *@Caution	Caller should free return copied file path after using data.
 */
char *msg_ui_viewer_util_copy_file(const char *src_path, char *dst_path);

/*
 *@fn		msg_ui_viewer_util_create_working_dir(void)
 *@brief		create temp directroy to save a temp file for viewer
  *@return	return created temp path, else NULL
 *@Caution	Caller should free returned temp path after using it.
 */
char *msg_ui_viewer_util_create_working_dir(void);
#endif