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