1 /* GConf 2 * Copyright (C) 1999, 2000 Red Hat Inc. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef GCONF_GCONF_INTERNALS_H 21 #define GCONF_GCONF_INTERNALS_H 22 23 #ifndef GCONF_ENABLE_INTERNALS 24 #error "you are trying to use GConf internal functions outside of GConf. This is a Bad Idea, the ABI for these internals is not fixed" 25 #endif 26 27 #ifdef GCONF_ENABLE_INTERNALS 28 29 #include <config.h> 30 #include <libintl.h> 31 32 #include <glib.h> 33 #include <glib/gstdio.h> 34 #include <glib/gi18n-lib.h> 35 #include "gconf-error.h" 36 #include "gconf-value.h" 37 #include "gconf-engine.h" 38 #include "gconf-sources.h" 39 40 #ifdef HAVE_CORBA 41 #include "GConfX.h" 42 #endif 43 44 #ifdef G_OS_WIN32 45 46 #define DEV_NULL "NUL:" 47 48 #include <sys/stat.h> 49 50 #ifndef S_IRWXU 51 #define S_IRWXU (_S_IREAD|_S_IWRITE|_S_IEXEC) 52 #endif 53 #ifndef S_IRWXG 54 #define S_IRWXG (S_IRWXU >> 3) 55 #endif 56 #ifndef S_IRWXO 57 #define S_IRWXO (S_IRWXU >> 6) 58 #endif 59 60 #undef GCONF_LOCALE_DIR 61 const char *_gconf_win32_get_locale_dir (void) G_GNUC_CONST; 62 #define GCONF_LOCALE_DIR _gconf_win32_get_locale_dir () 63 64 #undef GCONF_CONFDIR 65 const char *_gconf_win32_get_confdir (void) G_GNUC_CONST; 66 #define GCONF_CONFDIR _gconf_win32_get_confdir () 67 68 #undef GCONF_ETCDIR 69 const char *_gconf_win32_get_etcdir (void) G_GNUC_CONST; 70 #define GCONF_ETCDIR _gconf_win32_get_etcdir () 71 72 #undef GCONF_SERVERDIR 73 const char *_gconf_win32_get_serverdir (void) G_GNUC_CONST; 74 #define GCONF_SERVERDIR _gconf_win32_get_serverdir () 75 76 #undef GCONF_BACKEND_DIR 77 const char *_gconf_win32_get_backend_dir (void) G_GNUC_CONST; 78 #define GCONF_BACKEND_DIR _gconf_win32_get_backend_dir () 79 80 char *_gconf_win32_replace_prefix (const char *configure_time_path); 81 const char *_gconf_win32_get_home_dir (void); 82 83 #else 84 85 #define DEV_NULL "/dev/null" 86 87 #endif 88 89 #define GCONF_DATABASE_LIST_DELIM ';' 90 91 gchar* gconf_key_directory (const gchar* key); 92 const gchar* gconf_key_key (const gchar* key); 93 94 #ifdef HAVE_CORBA 95 GConfValue* gconf_value_from_corba_value (const ConfigValue *value); 96 ConfigValue* gconf_corba_value_from_gconf_value (const GConfValue *value); 97 void gconf_fill_corba_value_from_gconf_value (const GConfValue *value, 98 ConfigValue *dest); 99 ConfigValue* gconf_invalid_corba_value (void); 100 101 void gconf_fill_corba_schema_from_gconf_schema (const GConfSchema *sc, 102 ConfigSchema *dest); 103 ConfigSchema* gconf_corba_schema_from_gconf_schema (const GConfSchema *sc); 104 GConfSchema* gconf_schema_from_corba_schema (const ConfigSchema *cs); 105 106 gchar* gconf_object_to_string (CORBA_Object obj, 107 GError **err); 108 #endif 109 110 char *gconf_address_list_get_persistent_name (GSList *addresses); 111 GSList *gconf_persistent_name_get_address_list (const char *persistent_name); 112 void gconf_address_list_free (GSList *addresses); 113 114 const gchar* gconf_value_type_to_string (GConfValueType type); 115 GConfValueType gconf_value_type_from_string (const gchar *str); 116 117 118 GSList* gconf_load_source_path (const gchar* filename, GError** err); 119 120 /* shouldn't be used in applications (although implemented in gconf.c) */ 121 122 void gconf_shutdown_daemon (GError **err); 123 gboolean gconf_ping_daemon (void); 124 gboolean gconf_spawn_daemon (GError **err); 125 #ifdef HAVE_CORBA 126 int gconf_orb_release (void); 127 #endif 128 129 /* Returns 0 on failure (or if the string is "0" of course) */ 130 gulong gconf_string_to_gulong (const gchar *str); 131 gboolean gconf_string_to_double (const gchar *str, 132 gdouble *val); 133 gchar* gconf_double_to_string (gdouble val); 134 const gchar* gconf_current_locale (void); 135 136 137 /* Log wrapper; we might want to not use syslog someday */ 138 typedef enum { 139 GCL_EMERG, 140 GCL_ALERT, 141 GCL_CRIT, 142 GCL_ERR, 143 GCL_WARNING, 144 GCL_NOTICE, 145 GCL_INFO, 146 GCL_DEBUG 147 } GConfLogPriority; 148 149 void gconf_log (GConfLogPriority pri, const gchar* format, ...) G_GNUC_PRINTF (2, 3); 150 151 extern gboolean gconf_log_debug_messages; 152 153 /* return FALSE and set error if the key is bad */ 154 gboolean gconf_key_check(const gchar* key, GError** err); 155 156 /* 157 * If these were public they'd be in gconf-value.h 158 */ 159 160 /* for the complicated types */ 161 GConfValue* gconf_value_new_list_from_string (GConfValueType list_type, 162 const gchar* str, 163 GError** err); 164 GConfValue* gconf_value_new_pair_from_string (GConfValueType car_type, 165 GConfValueType cdr_type, 166 const gchar* str, 167 GError** err); 168 169 GSList* gconf_value_steal_list (GConfValue *value); 170 GConfSchema* gconf_value_steal_schema (GConfValue *value); 171 char* gconf_value_steal_string (GConfValue *value); 172 173 /* These are a hack to encode values into strings and ship them over CORBA, 174 * necessary for obscure reasons (ORBit doesn't like recursive datatypes yet) 175 */ 176 177 /* string quoting is only public for the benefit of the test suite */ 178 179 gchar* gconf_quote_string (const gchar *str); 180 gchar* gconf_unquote_string (const gchar *str, 181 const gchar **end, 182 GError **err); 183 void gconf_unquote_string_inplace (gchar *str, 184 gchar **end, 185 GError **err); 186 187 /* 188 * List/pair conversion stuff 189 */ 190 191 GConfValue* gconf_value_list_from_primitive_list (GConfValueType list_type, 192 GSList *list, 193 GError **err); 194 GConfValue* gconf_value_pair_from_primitive_pair (GConfValueType car_type, 195 GConfValueType cdr_type, 196 gconstpointer address_of_car, 197 gconstpointer address_of_cdr, 198 GError **err); 199 200 GSList* gconf_value_list_to_primitive_list_destructive (GConfValue *val, 201 GConfValueType list_type, 202 GError **err); 203 gboolean gconf_value_pair_to_primitive_pair_destructive (GConfValue *val, 204 GConfValueType car_type, 205 GConfValueType cdr_type, 206 gpointer car_retloc, 207 gpointer cdr_retloc, 208 GError **err); 209 210 211 void gconf_set_daemon_mode (gboolean setting); 212 gboolean gconf_in_daemon_mode (void); 213 void gconf_set_daemon_ior (const gchar *ior); 214 const gchar* gconf_get_daemon_ior (void); 215 216 /* Returns TRUE if there was an error, frees exception, sets err */ 217 #ifdef HAVE_CORBA 218 gboolean gconf_handle_oaf_exception (CORBA_Environment* ev, GError** err); 219 #endif 220 221 void gconf_nanosleep (gulong useconds); 222 223 typedef struct _GConfLock GConfLock; 224 225 GError* gconf_error_new (GConfError en, 226 const gchar* format, ...) G_GNUC_PRINTF (2, 3); 227 228 void gconf_set_error (GError** err, 229 GConfError en, 230 const gchar* format, ...) G_GNUC_PRINTF (3, 4); 231 232 /* merge two errors into a single message */ 233 GError* gconf_compose_errors (GError* err1, GError* err2); 234 235 #ifdef HAVE_CORBA 236 CORBA_ORB gconf_orb_get (void); 237 238 ConfigServer gconf_activate_server (gboolean start_if_not_found, 239 GError **error); 240 241 char* gconf_get_daemon_dir (void); 242 243 GConfLock* gconf_get_lock (const gchar *lock_directory, 244 GError **err); 245 gboolean gconf_release_lock (GConfLock *lock, 246 GError **err); 247 #endif 248 249 gboolean gconf_schema_validate (const GConfSchema *sc, 250 GError **err); 251 gboolean gconf_value_validate (const GConfValue *value, 252 GError **err); 253 254 255 void gconf_engine_set_owner (GConfEngine *engine, 256 gpointer client); 257 void gconf_engine_push_owner_usage (GConfEngine *engine, 258 gpointer client); 259 void gconf_engine_pop_owner_usage (GConfEngine *engine, 260 gpointer client); 261 262 gboolean gconf_engine_recursive_unset (GConfEngine *engine, 263 const char *key, 264 GConfUnsetFlags flags, 265 GError **err); 266 267 #ifdef HAVE_CORBA 268 gboolean gconf_CORBA_Object_equal (gconstpointer a, 269 gconstpointer b); 270 guint gconf_CORBA_Object_hash (gconstpointer key); 271 #endif 272 273 GConfValue* gconf_schema_steal_default_value (GConfSchema *schema); 274 275 void gconf_value_set_string_nocopy (GConfValue *value, 276 char *str); 277 278 void _gconf_init_i18n (void); 279 280 gboolean gconf_use_local_locks (void); 281 282 #endif /* GCONF_ENABLE_INTERNALS */ 283 284 #endif /* GCONF_GCONF_INTERNALS_H */ 285