8bcdde9c85a9d5e9e2567969420aafd02fdfb594
[framework/uifw/efreet.git] / src / lib / efreet_private.h
1 /* vim: set sw=4 ts=4 sts=4 et: */
2 #ifndef EFREET_PRIVATE_H
3 #define EFREET_PRIVATE_H
4
5 /**
6  * @file efreet_private.h
7  * @brief Contains methods and defines that are private to the Efreet
8  * implementaion
9  * @addtogroup Efreet_Private Efreet_Private: Private methods and defines
10  *
11  * @{
12  */
13
14 #include "config.h"
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <string.h>
18 #include <unistd.h>
19 #include <ctype.h>
20 #include <fcntl.h>
21 #include <sys/mman.h>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <dirent.h>
25 #include <fnmatch.h>
26 #include <limits.h>
27
28 #ifdef HAVE_ALLOCA_H
29 #include <alloca.h>
30 #endif
31
32 #include <Eina.h>
33 #include <Ecore.h>
34 #include <Ecore_File.h>
35 #include <Ecore_Str.h>
36
37 #include "efreet_xml.h"
38 #include "efreet_ini.h"
39
40 /**
41  * @def NEW(x, c)
42  * Allocate and zero out c structures of type x
43  */
44 #define NEW(x, c) calloc(c, sizeof(x))
45
46 /**
47  * @def FREE(x)
48  * Free x and set to NULL
49  */
50 #define FREE(x) do { free(x); x = NULL; } while (0)
51
52 /**
53  * @def IF_FREE(x)
54  * If x is set, free x and set to NULL
55  */
56 #define IF_FREE(x) do { if (x) FREE(x); } while (0)
57
58 /**
59  * @def IF_RELEASE(x)
60  * If x is set, eina_stringshare_del x and set to NULL
61  */
62 #define IF_RELEASE(x) do { \
63     if (x) { \
64         const char *__tmp; __tmp = (x); (x) = NULL; eina_stringshare_del(__tmp); \
65     } \
66     (x) = NULL; \
67 } while (0)
68
69 /**
70  * @def IF_FREE_LIST(x)
71  * If x is a valid pointer destroy x and set to NULL
72  */
73 #define IF_FREE_LIST(x) do { \
74      x = eina_list_free(x);                     \
75 } while (0)
76
77 /**
78  * @def IF_FREE_DLIST(x)
79  * If x is a valid pointer destroy x and set to NULL
80  */
81 #define IF_FREE_DLIST(x) do { \
82     if (x) { \
83         Ecore_DList *__tmp; __tmp = (x); (x) = NULL; ecore_dlist_destroy(__tmp); \
84     } \
85     (x) = NULL; \
86 } while (0)
87
88 /**
89  * @def IF_FREE_HASH(x)
90  * If x is a valid pointer destroy x and set to NULL
91  */
92 #define IF_FREE_HASH(x) do { \
93     if (x) { \
94         Eina_Hash *__tmp; __tmp = (x); (x) = NULL; eina_hash_free(__tmp); \
95     } \
96     (x) = NULL; \
97 } while (0)
98
99 #ifndef PATH_MAX
100 /**
101  * @def PATH_MAX
102  * Convenience define to set the maximim path length
103  */
104 #define PATH_MAX 4096
105 #endif
106
107 /**
108  * @internal
109  * The different types of commands in an Exec entry
110  */
111 enum Efreet_Desktop_Command_Flag
112 {
113     EFREET_DESKTOP_EXEC_FLAG_FULLPATH = 0x0001,
114     EFREET_DESKTOP_EXEC_FLAG_URI      = 0x0002,
115     EFREET_DESKTOP_EXEC_FLAG_DIR      = 0x0004,
116     EFREET_DESKTOP_EXEC_FLAG_FILE     = 0x0008
117 };
118
119 /**
120  * @internal
121  * Efreet_Desktop_Command_Flag
122  */
123 typedef enum Efreet_Desktop_Command_Flag Efreet_Desktop_Command_Flag;
124
125 /**
126  * @internal
127  * Efreet_Desktop_Command
128  */
129 typedef struct Efreet_Desktop_Command Efreet_Desktop_Command;
130
131 /**
132  * @internal
133  * Holds information on a desktop Exec command entry
134  */
135 struct Efreet_Desktop_Command
136 {
137   Efreet_Desktop *desktop;
138   int num_pending;
139
140   Efreet_Desktop_Command_Flag flags;
141
142   Efreet_Desktop_Command_Cb cb_command;
143   Efreet_Desktop_Progress_Cb cb_progress;
144   void *data;
145
146   Eina_List *files; /**< list of Efreet_Desktop_Command_File */
147 };
148
149 /**
150  * @internal
151  * Efreet_Desktop_Command_File
152  */
153 typedef struct Efreet_Desktop_Command_File Efreet_Desktop_Command_File;
154
155 /**
156  * @internal
157  * Stores information on a file passed to the desktop Exec command
158  */
159 struct Efreet_Desktop_Command_File
160 {
161   Efreet_Desktop_Command *command;
162   char *dir;
163   char *file;
164   char *fullpath;
165   char *uri;
166
167   int pending;
168 };
169
170 int efreet_base_init(void);
171 void efreet_base_shutdown(void);
172
173 int efreet_icon_init(void);
174 void efreet_icon_shutdown(void);
175
176 int efreet_menu_init(void);
177 void efreet_menu_shutdown(void);
178 Eina_List *efreet_default_dirs_get(const char *user_dir,
179                                     Eina_List *system_dirs,
180                                     const char *suffix);
181
182 int efreet_ini_init(void);
183 int efreet_ini_shutdown(void);
184
185 int efreet_desktop_init(void);
186 int efreet_desktop_shutdown(void);
187
188 const char *efreet_home_dir_get(void);
189
190 EAPI const char *efreet_lang_get(void);
191 EAPI const char *efreet_lang_country_get(void);
192 EAPI const char *efreet_lang_modifier_get(void);
193
194 size_t efreet_array_cat(char *buffer, size_t size, const char *strs[]);
195
196 const char *efreet_desktop_environment_get(void);
197
198 #define NON_EXISTING (void *)-1
199
200 void efreet_cache_clear(void);
201 const char *efreet_icon_hash_get(const char *theme_name, const char *icon, int size);
202 void efreet_icon_hash_put(const char *theme_name, const char *icon, int size, const char *file);
203
204 /**
205  * @}
206  */
207
208 #endif