Initialize Tizen 2.3
[framework/uifw/ecore.git] / mobile / src / lib / ecore_config / Ecore_Config.h
1 #ifndef _ECORE_CONFIG_H
2 # define _ECORE_CONFIG_H
3
4 #ifdef EAPI
5 #undef EAPI
6 #endif
7 #ifdef _MSC_VER
8 # ifdef BUILDING_DLL
9 #  define EAPI __declspec(dllexport)
10 # else
11 #  define EAPI __declspec(dllimport)
12 # endif
13 #else
14 # ifdef __GNUC__
15 #  if __GNUC__ >= 4
16 #   define EAPI __attribute__ ((visibility("default")))
17 #  else
18 #   define EAPI
19 #  endif
20 # else
21 #  define EAPI
22 # endif
23 #endif
24
25 /**
26  * @file 
27  * @brief Provides the Enlightened Property Library.
28  *
29  * This file provies all headers and structs for use with Ecore_Config.
30  * Using individual header files should not be necessary.
31  */
32
33 # define DIR_DELIMITER      '/'
34 # define ECORE_CONFIG_FLOAT_PRECISION 1000
35
36 /* FIXME: this should only be included if evas is present */
37 # include <Evas.h>
38
39 # define ECORE_CONFIG_GLOBAL_ID "_system"
40
41 /* structures */
42
43 /**
44  * Valid configuration property types.
45  */
46 typedef enum Ecore_Config_Type
47 {
48    ECORE_CONFIG_NIL = 0,                        /**< Property with no value. */
49    ECORE_CONFIG_INT = 1,                        /**< Integer property type. */
50    ECORE_CONFIG_FLT = 2,                        /**< Float property type. */
51    ECORE_CONFIG_STR = 3,                        /**< String property type. */
52    ECORE_CONFIG_RGB = 4,                        /**< Colour property type. */
53    ECORE_CONFIG_THM = 5,                        /**< Theme property type. */
54    ECORE_CONFIG_BLN = 6,                        /**< Boolean property type. */
55    ECORE_CONFIG_SCT = 7,      /**< Structure property type */
56 } Ecore_Config_Type;
57
58 typedef enum Ecore_Config_Flag
59 {
60    ECORE_CONFIG_FLAG_NONE = 0,
61    ECORE_CONFIG_FLAG_BOUNDS = 1,
62    ECORE_CONFIG_FLAG_MODIFIED = 2,
63    ECORE_CONFIG_FLAG_SYSTEM = 4,
64    ECORE_CONFIG_FLAG_CMDLN = 8
65 } Ecore_Config_Flag;
66
67 /**
68  * Property change callback function prototype.
69  */
70 typedef int         (*Ecore_Config_Listener) (const char *key,
71                                               const Ecore_Config_Type type,
72                                               const int tag, void *data);
73
74 typedef struct Ecore_Config_Listener_List
75 {
76    Ecore_Config_Listener listener;
77    const char         *name;
78    void               *data;
79    int                 tag;
80    struct Ecore_Config_Listener_List *next;
81 } Ecore_Config_Listener_List;
82
83 /**
84  * The actual property for storing a key-value pair.
85  */
86 typedef struct Ecore_Config_Prop
87 {
88    char               *key;     /* Property key. */
89    char               *description;     /* Description set by ecore_config_descibe. */
90    char                short_opt;       /* short identifier on command line (-f) */
91    char               *long_opt;        /* long identifier on command line (--foo) */
92    char               *ptr;     /* Used as the value when the property is a string or theme. */
93    Ecore_Config_Type   type;    /* Property type. */
94    long                val;     /* Used as the value when the property is an integer, float or colour. */
95    long                lo;      /* Lower bound for the value when the property is an integer or float. */
96    long                hi;      /* Higher bound for the value when the property is an integer or float. */
97    long                step;    /* Increment for the value when the property is an integer or float. */
98    Ecore_Config_Flag   flags;   /// < Configuration flags.
99    Ecore_Config_Listener_List *listeners;       /* List of change listeners. */
100    void               *data;    /// < Stores extra data for the property.
101    struct Ecore_Config_Prop *parent; /* if we are in a struct we have a parent to notify of changes etc */
102    struct Ecore_Config_Prop *next;      /* Pointer to the next property in the list. */
103 } Ecore_Config_Prop;
104
105 /*
106  * A container for a list of properties.  Provided so that an
107  * application can use different set of properties at any time. This
108  * is useful for multiple window support.
109  */
110 typedef struct Ecore_Config_Bundle
111 {
112    char               *identifier;      /* Identifier for this set of properties (window ID for example) */
113    char               *owner;   /* This is used to store the application name related to the bundle */
114    long                serial;  /* Unique identifier to identify bundle */
115    Ecore_Config_Prop  *data;    /* Pointer to root of property list */
116    void               *user_data;       /* App specific pointer to "other data" */
117    struct Ecore_Config_Bundle *next;    /* Pointer to next bundle in this application */
118 } Ecore_Config_Bundle;
119
120 typedef struct Ecore_Config_Server
121 {
122    void               *server;
123    char               *name;
124    Ecore_Config_Bundle *bundles;        /* data anchor */
125    struct Ecore_Config_Server *next;
126 } Ecore_Config_Server;
127
128 # ifdef __cplusplus
129 extern              "C"
130 {
131 # endif
132
133 /* global ptrs to save passing them through the API */
134    EAPI extern Ecore_Config_Server *__ecore_config_server_global;
135    EAPI extern Ecore_Config_Server *__ecore_config_server_local;
136    EAPI extern Ecore_Config_Bundle *__ecore_config_bundle_local;
137    EAPI extern char        *__ecore_config_app_name;
138
139    EAPI Ecore_Config_Prop  *ecore_config_get(const char *key);
140    EAPI const char         *ecore_config_type_get(const Ecore_Config_Prop *e);
141    EAPI int                 ecore_config_boolean_get(const char *key);
142    EAPI char               *ecore_config_string_get(const char *key);
143    EAPI long                ecore_config_int_get(const char *key);
144    EAPI int                 ecore_config_argb_get(const char *key, int *a, int *r,
145                                                   int *g, int *b);
146    EAPI long                ecore_config_argbint_get(const char *key);
147    EAPI char               *ecore_config_argbstr_get(const char *key);
148    EAPI float               ecore_config_float_get(const char *key);
149    EAPI char               *ecore_config_theme_get(const char *key);
150    EAPI char               *ecore_config_as_string_get(const char *key);
151    EAPI int                 ecore_config_bound(Ecore_Config_Prop *e);
152    EAPI int                 ecore_config_describe(const char *key, const char *desc);
153    EAPI int                 ecore_config_short_opt_set(const char *key,
154                                                        char short_opt);
155    EAPI int                 ecore_config_long_opt_set(const char *key,
156                                                       const char *long_opt);
157    EAPI int                 ecore_config_set(const char *key, const char *val);
158    EAPI int                 ecore_config_typed_set(const char *key, const void *val,
159                                                    int type);
160    EAPI int                 ecore_config_boolean_set(const char *key, int val);
161    EAPI int                 ecore_config_string_set(const char *key, const char *val);
162    EAPI int                 ecore_config_int_set(const char *key, int val);
163    EAPI int                 ecore_config_argb_set(const char *key, int a, int r, int g, int b);
164    EAPI int                 ecore_config_argbint_set(const char *key, long argb);
165    EAPI int                 ecore_config_argbstr_set(const char *key, const char *val);
166    EAPI int                 ecore_config_float_set(const char *key, float val);
167    EAPI int                 ecore_config_theme_set(const char *key, const char *val);
168    EAPI int                 ecore_config_theme_preview_group_set(const char *key,
169                                                                  const char *group);
170    EAPI int                 ecore_config_as_string_set(const char *key, const char *val);
171
172    EAPI int                 ecore_config_default(const char *key, const char *val,
173                                                  float lo, float hi, float step);
174    EAPI int                 ecore_config_typed_default(const char *key, const void *val,
175                                                        int type);
176    EAPI int                 ecore_config_boolean_default(const char *key, int val);
177    EAPI int                 ecore_config_int_default(const char *key, int val);
178    EAPI int                 ecore_config_int_default_bound(const char *key, int val,
179                                                            int lo, int hi, int step);
180    EAPI int                 ecore_config_string_default(const char *key, const char *val);
181    EAPI int                 ecore_config_float_default(const char *key, float val);
182    EAPI int                 ecore_config_float_default_bound(const char *key,
183                                                              float val, float lo,
184                                                              float hi, float step);
185    EAPI int                 ecore_config_argb_default(const char *key, int a, int r, int g, int b);
186    EAPI int                 ecore_config_argbint_default(const char *key, long argb);
187    EAPI int                 ecore_config_argbstr_default(const char *key, const char *val);
188    EAPI int                 ecore_config_theme_default(const char *key, const char *val);
189    EAPI int                 ecore_config_struct_default(const char *key);
190    EAPI int                 ecore_config_struct_int_add(const char *key, const char *name, int val);
191    EAPI int                 ecore_config_struct_float_add(const char *key, const char *name, float val);
192    EAPI int                 ecore_config_struct_create(const char *key);
193    EAPI int                 ecore_config_struct_string_add(const char *key, const char *name, const char* val);
194    EAPI int                 ecore_config_struct_theme_add(const char *key, const char *name, const char* val);
195    EAPI int                 ecore_config_struct_argb_add(const char *key, const char *name, int a, int r, int g, int b);
196    EAPI int                 ecore_config_struct_boolean_add(const char *key, const char *name, int val);
197    EAPI int                 ecore_config_struct_get(const char *key, void *data);
198
199    EAPI int                 ecore_config_listen(const char *name, const char *key,
200                                                 Ecore_Config_Listener listener,
201                                                 int tag, void *data);
202    EAPI int                 ecore_config_deaf(const char *name, const char *key,
203                                               Ecore_Config_Listener listener);
204    EAPI Ecore_Config_Prop  *ecore_config_dst(Ecore_Config_Prop *e);
205    EAPI int                 ecore_config_type_guess(const char *key, const char *val);
206
207    EAPI Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv,
208                                                      const char *id);
209    EAPI Ecore_Config_Bundle *ecore_config_bundle_1st_get(Ecore_Config_Server *srv);
210    EAPI Ecore_Config_Bundle *ecore_config_bundle_next_get(Ecore_Config_Bundle *ns);
211    EAPI Ecore_Config_Bundle *ecore_config_bundle_by_serial_get(Ecore_Config_Server *srv,
212                                                                long serial);
213    EAPI Ecore_Config_Bundle *ecore_config_bundle_by_label_get(Ecore_Config_Server *srv,
214                                                               const char *label);
215    EAPI long                ecore_config_bundle_serial_get(Ecore_Config_Bundle *ns);
216    EAPI char               *ecore_config_bundle_label_get(Ecore_Config_Bundle *ns);
217
218    EAPI int                 ecore_config_init(const char *name);
219    EAPI int                 ecore_config_shutdown(void);
220
221    EAPI int                 ecore_config_system_init(void);
222    EAPI int                 ecore_config_system_shutdown(void);
223
224    EAPI int                 ecore_config_load(void);
225    EAPI int                 ecore_config_file_load(const char *file);
226    EAPI int                 ecore_config_save(void);
227    EAPI int                 ecore_config_file_save(const char *file);
228
229 /* error codes */
230 # define ECORE_CONFIG_ERR_NOTSUPP     (-16)
231 # define ECORE_CONFIG_ERR_NOFILE      (-15)
232 # define ECORE_CONFIG_ERR_META_DLFAIL (-14)
233 # define ECORE_CONFIG_ERR_META_FILE   (-13)
234 # define ECORE_CONFIG_ERR_META_FORMAT (-12)
235 # define ECORE_CONFIG_ERR_MONMIS      (-11)
236 # define ECORE_CONFIG_ERR_NOEXEC      (-10)
237 # define ECORE_CONFIG_ERR_PARTIAL      (-9)
238 # define ECORE_CONFIG_ERR_PATHEX       (-8)
239 # define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
240 # define ECORE_CONFIG_ERR_MUTEX        (-6)
241 # define ECORE_CONFIG_ERR_NOTFOUND     (-5)     /* Error indicating that the item searched for could not be found. */
242 # define ECORE_CONFIG_ERR_OOM          (-4)     /* Error given when the program runs out of memory. */
243 # define ECORE_CONFIG_ERR_IGNORED      (-3)     /* Error occurred, but was ignored. */
244 # define ECORE_CONFIG_ERR_NODATA       (-2)     /* Error given when necessary data is not provided. */
245 # define ECORE_CONFIG_ERR_FAIL         (-1)     /* Failure result. */
246 # define ECORE_CONFIG_ERR_SUCC          (0)     /* Success result. */
247
248 # define ECORE_CONFIG_PARSE_HELP       (-2)     /* Help was displayed */
249 # define ECORE_CONFIG_PARSE_EXIT       (-1)     /* An error occurred */
250 # define ECORE_CONFIG_PARSE_CONTINUE    (0)     /* Arguments parsed successfully */
251
252 /* convenience mathods in convenience.c */
253    /* FIXME: this should only be included if evas is present */
254    EAPI int                 ecore_config_evas_font_path_apply(Evas *evas);
255    EAPI char               *ecore_config_theme_search_path_get(void);
256    EAPI int                 ecore_config_theme_search_path_append(const char *append);
257      
258    EAPI char               *ecore_config_theme_default_path_get(void);
259    EAPI char               *ecore_config_theme_with_path_from_name_get(char *name);
260    EAPI char               *ecore_config_theme_with_path_get(const char *key);
261    EAPI void                ecore_config_args_display(void);
262    EAPI int                 ecore_config_args_parse(void);
263    EAPI void                ecore_config_args_callback_str_add(char short_opt,
264                                                                char *long_opt, char *desc,
265                                                                void (*func)(char *val, void *data),
266                                                                void *data);
267    EAPI void                ecore_config_args_callback_noarg_add(char short_opt,
268                                                                  char *long_opt, char *desc,
269                                                                  void (*func)(char *val, void *data),
270                                                                  void *data);
271    EAPI void                ecore_config_app_describe(char *description);
272
273    EAPI int                 ecore_config_create(const char *key, void *val,
274                                                 char short_opt, char *long_opt,
275                                                 char *desc);
276    EAPI int                 ecore_config_typed_create(const char *key, void *val,
277                                                       int type, char short_opt,
278                                                       char *long_opt, char *desc);
279    EAPI int                 ecore_config_boolean_create(const char *key, int val,
280                                                         char short_opt, char *long_opt,
281                                                         char *desc);
282    EAPI int                 ecore_config_int_create(const char *key, int val,
283                                                     char short_opt, char *long_opt,
284                                                     char *desc);
285    EAPI int                 ecore_config_int_create_bound(const char *key, int val,
286                                                           int low, int high,
287                                                           int step, char short_opt,
288                                                           char *long_opt,
289                                                           char *desc);
290    EAPI int                 ecore_config_string_create(const char *key, char *val,
291                                                        char short_opt,
292                                                        char *long_opt, char *desc);
293    EAPI int                 ecore_config_float_create(const char *key, float val,
294                                                       char short_opt, char *long_opt,
295                                                       char *desc);
296    EAPI int                 ecore_config_float_create_bound(const char *key,
297                                                             float val, float low,
298                                                             float high, float step,
299                                                             char short_opt,
300                                                             char *long_opt,
301                                                             char *desc);
302    EAPI int                 ecore_config_argb_create(const char *key, char *val,
303                                                      char short_opt, char *long_opt,
304                                                      char *desc);
305    EAPI int                 ecore_config_theme_create(const char *key, char *val,
306                                                       char short_opt, char *long_opt,
307                                                       char *desc);
308
309 # ifdef __cplusplus
310 }
311 # endif
312 #endif