EFL 1.7 svn doobies
[profile/ivi/efreet.git] / src / lib / efreet_private.h
1 #ifndef EFREET_PRIVATE_H
2 #define EFREET_PRIVATE_H
3
4 #ifdef ENABLE_NLS
5 # include <libintl.h>
6 # define _(str) dgettext(PACKAGE, str)
7 #else
8 # define _(str) (str)
9 #endif
10
11 /**
12  * @file efreet_private.h
13  * @brief Contains methods and defines that are private to the Efreet
14  * implementaion
15  * @addtogroup Efreet_Private Efreet_Private: Private methods and defines
16  *
17  * @{
18  */
19
20 /**
21  * @def NEW(x, c)
22  * Allocate and zero out c structures of type x
23  */
24 #define NEW(x, c) calloc(c, sizeof(x))
25
26 /**
27  * @def FREE(x)
28  * Free x and set to NULL
29  */
30 #define FREE(x) do { free(x); x = NULL; } while (0)
31
32 /**
33  * @def IF_FREE(x)
34  * If x is set, free x and set to NULL
35  */
36 #define IF_FREE(x) do { if (x) FREE(x); } while (0)
37
38 /**
39  * @def IF_RELEASE(x)
40  * If x is set, eina_stringshare_del x and set to NULL
41  */
42 #define IF_RELEASE(x) do { \
43     if (x) { \
44         const char *__tmp; __tmp = (x); (x) = NULL; eina_stringshare_del(__tmp); \
45     } \
46     (x) = NULL; \
47 } while (0)
48
49 /**
50  * @def IF_FREE_LIST(x)
51  * If x is a valid pointer destroy x and set to NULL
52  */
53 #define IF_FREE_LIST(list, free_cb) do { \
54     void *_data; \
55     EINA_LIST_FREE(list, _data) \
56     free_cb(_data); \
57     list = NULL; \
58 } while (0)
59
60 /**
61  * @def IF_FREE_HASH(x)
62  * If x is a valid pointer destroy x and set to NULL
63  */
64 #define IF_FREE_HASH(x) do { \
65     if (x) { \
66         Eina_Hash *__tmp; __tmp = (x); (x) = NULL; eina_hash_free(__tmp); \
67     } \
68     (x) = NULL; \
69 } while (0)
70
71 /**
72  * @def IF_FREE_HASH_CB(x, cb)
73  * If x is a valid pointer destroy x with cb and set to NULL
74  */
75 #define IF_FREE_HASH_CB(x, cb) do { \
76     if (x) { \
77         Eina_Hash *__tmp; __tmp = (x); (x) = NULL; efreet_hash_free(__tmp, cb); \
78     } \
79     (x) = NULL; \
80 } while (0)
81
82 #ifdef EFREET_DEFAULT_LOG_COLOR
83 #undef EFREET_DEFAULT_LOG_COLOR
84 #endif
85 #define EFREET_DEFAULT_LOG_COLOR "\033[36m"
86
87 #ifndef EFREET_MODULE_LOG_DOM
88 #error "Need to define a log domain"
89 #endif
90
91 /**
92  * macros that are used all around the code for message processing
93  * four macros are defined ERR, WRN, DGB, INF. 
94  * EFREET_MODULE_LOG_DOM should be defined individually for each module
95  */
96 #ifdef ERR
97 #undef ERR
98 #endif
99 #define ERR(...) EINA_LOG_DOM_ERR(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
100 #ifdef DBG
101 #undef DBG
102 #endif
103 #define DBG(...) EINA_LOG_DOM_DBG(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
104 #ifdef INF
105 #undef INF
106 #endif
107 #define INF(...) EINA_LOG_DOM_INFO(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
108 #ifdef WRN
109 #undef WRN
110 #endif
111 #define WRN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
112
113 typedef struct _Efreet_Cache_Icon Efreet_Cache_Icon;
114 typedef struct _Efreet_Cache_Icon_Element Efreet_Cache_Icon_Element;
115 typedef struct _Efreet_Cache_Fallback_Icon Efreet_Cache_Fallback_Icon;
116
117 struct _Efreet_Cache_Icon
118 {
119     const char *theme;
120
121     Efreet_Cache_Icon_Element **icons;
122     unsigned int icons_count;
123 };
124
125 struct _Efreet_Cache_Icon_Element
126 {
127     const char **paths;          /* possible paths for icon */
128     unsigned int paths_count;
129
130     unsigned short type;         /* size type of icon */
131
132     unsigned short normal;       /* The size for this icon */
133     unsigned short min;          /* The minimum size for this icon */
134     unsigned short max;          /* The maximum size for this icon */
135 };
136
137 struct _Efreet_Cache_Fallback_Icon
138 {
139     const char *theme;
140     const char **icons;
141     unsigned int icons_count;
142 };
143
144 typedef struct _Efreet_Cache_Version Efreet_Cache_Version;
145 struct _Efreet_Cache_Version
146 {
147     unsigned char major;
148     unsigned char minor;
149 };
150
151 typedef struct _Efreet_Cache_Hash Efreet_Cache_Hash;
152 struct _Efreet_Cache_Hash
153 {
154     Eina_Hash *hash;
155 };
156
157 typedef struct _Efreet_Cache_Array_String Efreet_Cache_Array_String;
158 struct _Efreet_Cache_Array_String
159 {
160     const char **array;
161     unsigned int array_count;
162 };
163
164 int efreet_base_init(void);
165 void efreet_base_shutdown(void);
166
167 int efreet_cache_init(void);
168 void efreet_cache_shutdown(void);
169
170 int efreet_icon_init(void);
171 void efreet_icon_shutdown(void);
172
173 int efreet_menu_init(void);
174 void efreet_menu_shutdown(void);
175 EAPI Eina_List *efreet_default_dirs_get(const char *user_dir,
176                                         Eina_List *system_dirs,
177                                         const char *suffix);
178
179 int efreet_ini_init(void);
180 void efreet_ini_shutdown(void);
181
182 int efreet_desktop_init(void);
183 void efreet_desktop_shutdown(void);
184
185 int efreet_util_init(void);
186 int efreet_util_shutdown(void);
187
188 const char *efreet_home_dir_get(void);
189 void        efreet_dirs_reset(void);
190
191 const char *efreet_lang_get(void);
192 const char *efreet_lang_country_get(void);
193 const char *efreet_lang_modifier_get(void);
194
195 size_t efreet_array_cat(char *buffer, size_t size, const char *strs[]);
196
197 void efreet_cache_desktop_update(void);
198 void efreet_cache_desktop_close(void);
199 void efreet_cache_icon_update(void);
200
201 Efreet_Desktop *efreet_cache_desktop_find(const char *file);
202 void efreet_cache_desktop_free(Efreet_Desktop *desktop);
203 void efreet_cache_desktop_add(Efreet_Desktop *desktop);
204 Efreet_Cache_Array_String *efreet_cache_desktop_dirs(void);
205
206 Efreet_Cache_Icon *efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon);
207 Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
208 Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
209 Eina_List *efreet_cache_icon_theme_list(void);
210
211 Efreet_Cache_Hash *efreet_cache_util_hash_string(const char *key);
212 Efreet_Cache_Hash *efreet_cache_util_hash_array_string(const char *key);
213 Efreet_Cache_Array_String *efreet_cache_util_names(const char *key);
214
215 EAPI void efreet_cache_array_string_free(Efreet_Cache_Array_String *array);
216
217 EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);
218 EAPI void efreet_setowner(const char *path);
219 EAPI void efreet_fsetowner(int fd);
220
221 EAPI extern int efreet_cache_update;
222
223 /**
224  * @}
225  */
226
227 #endif