summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@src.gnome.org>2003-03-13 19:19:50 +0000
committerAnders Carlsson <andersca@src.gnome.org>2003-03-13 19:19:50 +0000
commit78505627b7ab717da1d49a2d898bf3b4022e7bbb (patch)
tree0b54b6ff74d9a4eef1cfde2fde2b33d23e46a503
parent89adfbc77d3124634a98e9bad5a44d8e6fae2348 (diff)
downloadgconf-78505627b7ab717da1d49a2d898bf3b4022e7bbb.tar.gz
Lots of things
-rw-r--r--gconf/gconf-dbus.c106
-rw-r--r--gconf/gconf-value.c3
-rw-r--r--gconf/gconf.c75
-rw-r--r--gconf/gconfd-dbus.c76
-rw-r--r--gconf/simple-test.c19
-rw-r--r--tests/Makefile.am12
-rw-r--r--tests/dbus-glue.c47
-rw-r--r--tests/dbus-glue.h8
-rw-r--r--tests/testchangeset.c7
-rw-r--r--tests/testdirlist.c7
-rw-r--r--tests/testgconf.c6
-rw-r--r--tests/testpersistence.c8
-rw-r--r--tests/testschemas.c9
13 files changed, 293 insertions, 90 deletions
diff --git a/gconf/gconf-dbus.c b/gconf/gconf-dbus.c
index faa2badf..4ed49dbe 100644
--- a/gconf/gconf-dbus.c
+++ b/gconf/gconf-dbus.c
@@ -92,6 +92,10 @@ gconf_dbus_create_gconf_value_from_dict (DBusDict *dict)
if (*tmp != '\0')
gconf_schema_set_long_desc (schema, tmp);
+ dbus_dict_get_string (dict, "owner", &tmp);
+ if (*tmp != '\0')
+ gconf_schema_set_owner (schema, tmp);
+
dbus_dict_get_string (dict, "default_value", &tmp);
{
GConfValue *val;
@@ -147,6 +151,28 @@ gconf_dbus_fill_message_from_gconf_value (DBusMessage *message,
switch (gconf_value_get_list_type (value))
{
+ case GCONF_VALUE_STRING:
+ {
+ char **str;
+
+ str = g_new (char *, len + 1);
+ str[len] = NULL;
+
+ i = 0;
+ while (list)
+ {
+ GConfValue *value = list->data;
+
+ str[i] = g_strdup (gconf_value_get_string (value));
+
+ list = list->next;
+ ++i;
+ }
+
+ dbus_message_append_string_array (message, (const char **)str, len);
+ g_strfreev (str);
+ break;
+ }
case GCONF_VALUE_INT:
{
int *array;
@@ -168,26 +194,46 @@ gconf_dbus_fill_message_from_gconf_value (DBusMessage *message,
g_free (array);
break;
}
- case GCONF_VALUE_STRING:
+ case GCONF_VALUE_FLOAT:
{
- char **str;
+ double *array;
- str = g_new (char *, len + 1);
- str[len] = NULL;
+ array = g_new (double, len);
i = 0;
while (list)
{
GConfValue *value = list->data;
+
+ array[i] = gconf_value_get_float (value);
+
+ list = list->next;
+ ++i;
+ }
- str[i] = g_strdup (gconf_value_get_string (value));
+ dbus_message_append_double_array (message, array, len);
+ g_free (array);
+ break;
+ }
+ case GCONF_VALUE_BOOL:
+ {
+ unsigned char *array;
+
+ array = g_new (unsigned char, len);
+
+ i = 0;
+ while (list)
+ {
+ GConfValue *value = list->data;
+
+ array[i] = gconf_value_get_bool (value);
list = list->next;
++i;
}
- dbus_message_append_string_array (message, (const char **)str, len);
- g_strfreev (str);
+ dbus_message_append_boolean_array (message, array, len);
+ g_free (array);
break;
}
default:
@@ -230,6 +276,8 @@ gconf_dbus_create_gconf_value_from_message (DBusMessageIter *iter)
break;
case DBUS_TYPE_INT32_ARRAY:
case DBUS_TYPE_STRING_ARRAY:
+ case DBUS_TYPE_DOUBLE_ARRAY:
+ case DBUS_TYPE_BOOLEAN_ARRAY:
type = GCONF_VALUE_LIST;
break;
case DBUS_TYPE_DICT:
@@ -280,6 +328,50 @@ gconf_dbus_create_gconf_value_from_message (DBusMessageIter *iter)
switch (arg_type)
{
+ case DBUS_TYPE_BOOLEAN_ARRAY:
+ {
+ unsigned char *array;
+ int len;
+
+ dbus_message_iter_get_boolean_array (iter, &array, &len);
+
+ for (i = 0; i < len; i++)
+ {
+ GConfValue *value = gconf_value_new (GCONF_VALUE_BOOL);
+
+ gconf_value_set_bool (value, array[i]);
+
+ list = g_slist_prepend (list, value);
+ }
+ list = g_slist_reverse (list);
+ dbus_free (array);
+
+ gconf_value_set_list_type (gval, GCONF_VALUE_BOOL);
+ gconf_value_set_list_nocopy (gval, list);
+ break;
+ }
+ case DBUS_TYPE_DOUBLE_ARRAY:
+ {
+ double *array;
+ int len;
+
+ dbus_message_iter_get_double_array (iter, &array, &len);
+
+ for (i = 0; i < len; i++)
+ {
+ GConfValue *value = gconf_value_new (GCONF_VALUE_FLOAT);
+
+ gconf_value_set_float (value, array[i]);
+
+ list = g_slist_prepend (list, value);
+ }
+ list = g_slist_reverse (list);
+ dbus_free (array);
+
+ gconf_value_set_list_type (gval, GCONF_VALUE_FLOAT);
+ gconf_value_set_list_nocopy (gval, list);
+ break;
+ }
case DBUS_TYPE_INT32_ARRAY:
{
dbus_int32_t *array;
diff --git a/gconf/gconf-value.c b/gconf/gconf-value.c
index 8532e01e..91f339ea 100644
--- a/gconf/gconf-value.c
+++ b/gconf/gconf-value.c
@@ -798,7 +798,8 @@ void
gconf_value_free(GConfValue* value)
{
GConfRealValue *real;
-
+
+ g_assert (value != NULL);
g_return_if_fail(value != NULL);
real = REAL_VALUE (value);
diff --git a/gconf/gconf.c b/gconf/gconf.c
index 0f928638..3a06358b 100644
--- a/gconf/gconf.c
+++ b/gconf/gconf.c
@@ -513,7 +513,7 @@ gconf_engine_unref(GConfEngine* conf)
}
else
{
-#if GCONF_CORBA_BROKEN
+#ifdef GCONF_CORBA_BROKEN
/* Remove all connections associated with this GConf */
GSList* removed;
GSList* tmp;
@@ -638,9 +638,9 @@ gconf_engine_notify_add(GConfEngine* conf,
if (db == -1)
{
- g_return_val_if_fail(err == NULL || *err != NULL, NULL);
+ g_return_val_if_fail(err == NULL || *err != NULL, 0);
- return NULL;
+ return 0;
}
message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_ADD_LISTENER);
@@ -652,7 +652,7 @@ gconf_engine_notify_add(GConfEngine* conf,
0);
dbus_dict_unref (properties);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -671,7 +671,7 @@ gconf_engine_notify_add(GConfEngine* conf,
return 0;
}
- dbus_message_get_args (reply,
+ dbus_message_get_args (reply, NULL,
DBUS_TYPE_UINT32, &id,
0);
@@ -824,7 +824,7 @@ gconf_engine_get_fuller (GConfEngine *conf,
DBUS_TYPE_BOOLEAN, use_schema_default,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1014,7 +1014,7 @@ gconf_engine_get_default_from_schema (GConfEngine* conf,
DBUS_TYPE_STRING, gconf_current_locale(),
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken(reply))
@@ -1113,7 +1113,7 @@ gconf_engine_set (GConfEngine* conf, const gchar* key,
0);
gconf_dbus_fill_message_from_gconf_value (message, value);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1140,7 +1140,6 @@ gconf_engine_unset (GConfEngine* conf, const gchar* key, GError** err)
{
int db;
gint tries = 0;
- guint dbus_flags;
DBusMessage *message, *reply;
g_return_val_if_fail (conf != NULL, FALSE);
@@ -1185,13 +1184,13 @@ gconf_engine_unset (GConfEngine* conf, const gchar* key, GError** err)
return FALSE;
}
- message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_SET);
+ message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_UNSET);
dbus_message_append_args (message,
DBUS_TYPE_UINT32, db,
DBUS_TYPE_STRING, key,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1206,7 +1205,7 @@ gconf_engine_unset (GConfEngine* conf, const gchar* key, GError** err)
if (gconf_handle_dbus_exception(reply, err))
{
dbus_message_unref (reply);
- return NULL;
+ return FALSE;
}
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
@@ -1291,7 +1290,7 @@ gconf_engine_recursive_unset (GConfEngine *conf,
DBUS_TYPE_STRING, key,
DBUS_TYPE_UINT32, dbus_flags,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
@@ -1362,18 +1361,18 @@ gconf_engine_associate_schema (GConfEngine* conf, const gchar* key,
if (db == -1)
{
- g_return_val_if_fail(err == NULL || *err != NULL, NULL);
+ g_return_val_if_fail(err == NULL || *err != NULL, FALSE);
- return NULL;
+ return FALSE;
}
- message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_ALL_ENTRIES);
+ message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_SET_SCHEMA);
dbus_message_append_args (message,
DBUS_TYPE_UINT32, db,
DBUS_TYPE_STRING, key,
DBUS_TYPE_STRING, schema_key,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1494,7 +1493,7 @@ gconf_engine_all_entries(GConfEngine* conf, const gchar* dir, GError** err)
DBUS_TYPE_STRING, gconf_current_locale(),
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1512,7 +1511,7 @@ gconf_engine_all_entries(GConfEngine* conf, const gchar* dir, GError** err)
return NULL;
}
- dbus_message_get_args (reply,
+ dbus_message_get_args (reply, NULL,
DBUS_TYPE_STRING_ARRAY, &keys, &keys_len,
DBUS_TYPE_STRING_ARRAY, &schema_names, &schema_names_len,
DBUS_TYPE_BOOLEAN_ARRAY, &is_defaults, &is_defaults_len,
@@ -1625,7 +1624,7 @@ gconf_engine_all_dirs(GConfEngine* conf, const gchar* dir, GError** err)
DBUS_TYPE_STRING, dir,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1643,7 +1642,7 @@ gconf_engine_all_dirs(GConfEngine* conf, const gchar* dir, GError** err)
return NULL;
}
- dbus_message_get_args (reply,
+ dbus_message_get_args (reply, NULL,
DBUS_TYPE_STRING_ARRAY, &keys, &len,
0);
i = 0;
@@ -1711,8 +1710,11 @@ gconf_engine_suggest_sync(GConfEngine* conf, GError** err)
}
message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_SYNC);
+ dbus_message_append_args (message,
+ DBUS_TYPE_UINT32, db,
+ 0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1725,7 +1727,7 @@ gconf_engine_suggest_sync(GConfEngine* conf, GError** err)
}
if (gconf_handle_dbus_exception(reply, err))
- g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+ g_return_if_fail (err == NULL || *err == NULL);
dbus_message_unref (reply);
}
@@ -1779,8 +1781,11 @@ gconf_clear_cache(GConfEngine* conf, GError** err)
}
message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_CLEAR_CACHE);
+ dbus_message_append_args (message,
+ DBUS_TYPE_UINT32, db,
+ 0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1793,7 +1798,7 @@ gconf_clear_cache(GConfEngine* conf, GError** err)
}
if (gconf_handle_dbus_exception(reply, err))
- g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+ g_return_if_fail (err == NULL || *err == NULL);
dbus_message_unref (reply);
}
@@ -1842,8 +1847,11 @@ gconf_synchronous_sync(GConfEngine* conf, GError** err)
}
message = dbus_message_new (GCONF_DBUS_CONFIG_SERVER, GCONF_DBUS_CONFIG_DATABASE_SYNCHRONOUS_SYNC);
+ dbus_message_append_args (message,
+ DBUS_TYPE_UINT32, db,
+ 0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken (reply))
@@ -1856,7 +1864,7 @@ gconf_synchronous_sync(GConfEngine* conf, GError** err)
}
if (gconf_handle_dbus_exception(reply, err))
- g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+ g_return_if_fail (err == NULL || *err == NULL);
dbus_message_unref (reply);
}
@@ -1904,7 +1912,7 @@ gconf_engine_dir_exists(GConfEngine *conf, const gchar *dir, GError** err)
DBUS_TYPE_STRING, dir,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken(reply))
@@ -1924,7 +1932,7 @@ gconf_engine_dir_exists(GConfEngine *conf, const gchar *dir, GError** err)
return FALSE;
}
- dbus_message_get_args (reply,
+ dbus_message_get_args (reply, NULL,
DBUS_TYPE_BOOLEAN, &exists,
0);
@@ -1973,7 +1981,7 @@ gconf_engine_remove_dir (GConfEngine* conf,
DBUS_TYPE_STRING, dir,
0);
- reply = dbus_connection_send_message_with_reply_and_block (dbus_conn, message, -1, NULL);
+ reply = dbus_connection_send_with_reply_and_block (dbus_conn, message, -1, NULL);
dbus_message_unref (message);
if (gconf_server_broken(reply))
@@ -2081,10 +2089,11 @@ try_to_contact_server (gboolean start_if_not_found,
if (!CORBA_Object_is_nil (server, &ev))
{
+#ifdef GCONF_CORBA_BROKEN
ConfigServer_add_client (server,
gconf_get_config_listener (),
&ev);
-
+#endif
if (ev._major != CORBA_NO_EXCEPTION)
{
g_set_error (err,
@@ -2174,6 +2183,7 @@ gconf_debug_shutdown (void)
return gconf_orb_release ();
}
+#ifdef GCONF_CORBA_BROKEN
static void notify (PortableServer_Servant servant,
ConfigDatabase db,
CORBA_unsigned_long cnxn,
@@ -2387,6 +2397,7 @@ gconf_get_config_listener(void)
return listener;
}
+#endif
static const char *config_listener_messages[] =
{
@@ -2407,7 +2418,7 @@ gconf_config_listener_notify (DBusConnection *connection,
GConfValue *value;
GConfEntry* entry;
- dbus_message_get_args (message,
+ dbus_message_get_args (message, NULL,
DBUS_TYPE_UINT32, &id,
DBUS_TYPE_UINT32, &cnxn_id,
DBUS_TYPE_STRING, &key,
diff --git a/gconf/gconfd-dbus.c b/gconf/gconfd-dbus.c
index 50092662..d889b047 100644
--- a/gconf/gconfd-dbus.c
+++ b/gconf/gconfd-dbus.c
@@ -42,7 +42,7 @@ static const char *config_database_messages[] = {
GCONF_DBUS_CONFIG_DATABASE_UNSET,
GCONF_DBUS_CONFIG_DATABASE_SET_SCHEMA,
GCONF_DBUS_CONFIG_DATABASE_SYNC,
- GCONF_DBUS_CONFIG_DATABASE_SYNCHRONOUS_SYNC
+ GCONF_DBUS_CONFIG_DATABASE_SYNCHRONOUS_SYNC,
GCONF_DBUS_CONFIG_DATABASE_CLEAR_CACHE
};
@@ -55,11 +55,12 @@ typedef struct {
char *who;
} Listener;
-static Listener* listener_new (const char *who,
- const char *name);
-static void listener_destroy (Listener *l);
-static void add_client (DBusConnection *connection,
- const char *name);
+static Listener* listener_new (const char *who,
+ const char *name);
+static void listener_destroy (Listener *l);
+static void add_client (DBusConnection *connection,
+ const char *name);
+
static void
gconfd_shutdown (DBusConnection *connection,
@@ -122,14 +123,14 @@ gconf_dbus_get_message_args (DBusConnection *connection,
int first_arg_type,
...)
{
- DBusResultCode retval;
+ gboolean retval;
va_list var_args;
va_start (var_args, first_arg_type);
- retval = dbus_message_get_args_valist (message, first_arg_type, var_args);
+ retval = dbus_message_get_args_valist (message, NULL, first_arg_type, var_args);
va_end (var_args);
- if (retval != DBUS_RESULT_SUCCESS)
+ if (!retval)
{
g_warning ("malformed message of type %s\n", dbus_message_get_name (message));
@@ -176,7 +177,7 @@ gconfd_config_database_dir_exists (DBusConnection *connection,
reply = dbus_message_new_reply (message);
dbus_message_append_boolean (reply, retval);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -285,7 +286,7 @@ gconfd_config_database_all_entries (DBusConnection *connection,
}
g_slist_free(pairs);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -344,7 +345,7 @@ gconfd_config_database_all_dirs (DBusConnection *connection,
reply = dbus_message_new_reply (message);
dbus_message_append_string_array (reply, (const char **)dirs, len);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
g_strfreev (dirs);
@@ -403,13 +404,14 @@ gconfd_config_database_lookup (DBusConnection *connection,
reply = dbus_message_new_reply (message);
gconf_dbus_fill_message_from_gconf_value (reply, val);
- gconf_value_free (val);
+ if (val)
+ gconf_value_free (val);
dbus_message_append_string (reply, s ? s : "");
dbus_message_append_boolean (reply, is_default);
dbus_message_append_boolean (reply, is_writable);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -457,7 +459,7 @@ gconfd_config_database_lookup_default_value (DBusConnection *connection,
reply = dbus_message_new_reply (message);
gconf_dbus_fill_message_from_gconf_value (reply, val);
gconf_value_free (val);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -494,7 +496,7 @@ gconfd_config_database_remove_dir (DBusConnection *connection,
/* This really sucks, but we need to ack that the removal was successful */
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -558,7 +560,7 @@ gconfd_config_database_add_listener (DBusConnection *connection,
cnxn = gconf_database_dbus_add_listener (db, dbus_message_get_sender (message), name, dir);
reply = dbus_message_new_reply (message);
dbus_message_append_uint32 (reply, cnxn);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
dbus_dict_unref (dict);
}
@@ -605,7 +607,7 @@ gconfd_config_database_set (DBusConnection *connection,
/* This really sucks, but we need to ack that the setting was successful */
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -648,7 +650,7 @@ gconfd_config_database_recursive_unset (DBusConnection *connection,
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -678,12 +680,12 @@ gconfd_config_database_unset (DBusConnection *connection,
}
gconf_database_unset (db, key, NULL, &error);
-
+
if (gconf_dbus_set_exception (connection, message, error))
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -691,7 +693,6 @@ static void
gconfd_config_database_set_schema (DBusConnection *connection,
DBusMessage *message)
{
- guint flags;
int id;
gchar *key, *schema_key;
GConfDatabase *db;
@@ -705,7 +706,6 @@ gconfd_config_database_set_schema (DBusConnection *connection,
DBUS_TYPE_UINT32, &id,
DBUS_TYPE_STRING, &key,
DBUS_TYPE_STRING, &schema_key,
- DBUS_TYPE_UINT32, &flags,
0))
return;
@@ -719,12 +719,12 @@ gconfd_config_database_set_schema (DBusConnection *connection,
*schema_key != '\0' ?
schema_key : NULL,
&error);
-
+
if (gconf_dbus_set_exception (connection, message, error))
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -736,7 +736,7 @@ gconfd_config_database_synchronous_sync (DBusConnection *connection,
GConfDatabase *db;
DBusMessage *reply;
GError *error = NULL;
-
+
if (gconfd_dbus_check_in_shutdown (connection, message))
return;
@@ -756,7 +756,7 @@ gconfd_config_database_synchronous_sync (DBusConnection *connection,
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -788,7 +788,7 @@ gconfd_config_database_sync (DBusConnection *connection,
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -796,7 +796,6 @@ static void
gconfd_config_database_clear_cache (DBusConnection *connection,
DBusMessage *message)
{
- guint flags;
int id;
GConfDatabase *db;
DBusMessage *reply;
@@ -821,7 +820,7 @@ gconfd_config_database_clear_cache (DBusConnection *connection,
return;
reply = dbus_message_new_reply (message);
- dbus_connection_send_message (connection, reply, NULL, NULL);
+ dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
}
@@ -891,8 +890,11 @@ remove_client (DBusConnection *connection,
char *name;
GList *list;
GConfDatabase *db;
+
+ if (!client_hash)
+ return;
- dbus_message_get_args (message,
+ dbus_message_get_args (message, NULL,
DBUS_TYPE_STRING, &name,
0);
@@ -1040,9 +1042,10 @@ gconfd_dbus_init (void)
const char *dbus_address;
DBusResultCode result;
DBusMessageHandler *handler;
-
+ DBusError error;
char *name;
+ dbus_error_init (&error);
dbus_address = get_dbus_address ();
if (!dbus_address)
{
@@ -1059,17 +1062,18 @@ gconfd_dbus_init (void)
return FALSE;
}
- name = dbus_bus_register_client (dbus_conn, &result);
+ name = dbus_bus_register_client (dbus_conn, &error);
if (!name)
{
gconf_log (GCL_ERR, _("Failed to register client with the D-BUS bus daemon: %s"),
- dbus_result_to_string (result));
+ error.message);
+ dbus_error_free (&error);
return FALSE;
}
if (dbus_bus_acquire_service (dbus_conn, "org.freedesktop.Config.Server",
DBUS_SERVICE_FLAG_PROHIBIT_REPLACEMENT,
- &result) != DBUS_SERVICE_REPLY_PRIMARY_OWNER)
+ NULL) != DBUS_SERVICE_REPLY_PRIMARY_OWNER)
{
gconf_log (GCL_ERR, _("Failed to acquire resource"));
return FALSE;
@@ -1141,7 +1145,7 @@ notify_listeners_cb(GConfListeners* listeners,
gconf_dbus_fill_message_from_gconf_value (message, closure->value);
- dbus_connection_send_message (dbus_conn, message, NULL, NULL);
+ dbus_connection_send (dbus_conn, message, NULL);
dbus_message_unref (message);
}
diff --git a/gconf/simple-test.c b/gconf/simple-test.c
index 3a4aa691..031a21b4 100644
--- a/gconf/simple-test.c
+++ b/gconf/simple-test.c
@@ -86,9 +86,13 @@ notify_func (GConfClient* client,
if (gconf_entry_get_value (entry))
s = gconf_value_to_string (gconf_entry_get_value (entry));
-
+ else
+ s = g_strdup ("(nothing)");
+
gconf_client_unset (client, gconf_entry_get_key (entry), NULL);
+
printf ("key changed: %s to %s\n", gconf_entry_get_key (entry), s);
+
g_free (s);
}
@@ -108,7 +112,7 @@ main (int argc, char **argv)
const char *address;
char *name;
GMainLoop *loop;
-
+ DBusError error;
address = g_getenv ("GCONF_DBUS_ADDRESS");
connection = dbus_connection_open (address, &result);
@@ -119,12 +123,13 @@ main (int argc, char **argv)
dbus_result_to_string (result));
return 1;
}
-
- name = dbus_bus_register_client (connection, &result);
+
+ dbus_error_init (&error);
+ name = dbus_bus_register_client (connection, &error);
if (!name)
{
g_printerr ("Failed to register client with the D-BUS bus daemon: %s",
- dbus_result_to_string (result));
+ error.message);
return 1;
}
@@ -146,12 +151,12 @@ main (int argc, char **argv)
g_main_loop_run (loop);
-#if 0
+
g_print ("foo: %s\n", gconf_client_get_string (client, "/desktop/gnome/interface/icon_theme", NULL));
g_print ("foo: %d\n", gconf_client_dir_exists (client, "/desktop/gnome/interface", NULL));
recurse (client, "/", 0);
-#endif
+
return 0;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 65218906..6b290886 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,23 +13,23 @@ testunique_SOURCES=testunique.c
testunique_LDADD = $(TESTLIBS)
-testgconf_SOURCES=testgconf.c
+testgconf_SOURCES=testgconf.c dbus-glue.c
testgconf_LDADD = $(TESTLIBS)
-testpersistence_SOURCES=testpersistence.c
+testpersistence_SOURCES=testpersistence.c dbus-glue.c
testpersistence_LDADD = $(TESTLIBS)
-testlisteners_SOURCES=testlisteners.c
+testlisteners_SOURCES=testlisteners.c
testlisteners_LDADD = $(TESTLIBS)
-testschemas_SOURCES=testschemas.c
+testschemas_SOURCES=testschemas.c dbus-glue.c
testschemas_LDADD = $(TESTLIBS)
-testchangeset_SOURCES=testchangeset.c
+testchangeset_SOURCES=testchangeset.c dbus-glue.c
testchangeset_LDADD = $(TESTLIBS)
@@ -37,7 +37,7 @@ testencode_SOURCES=testencode.c
testencode_LDADD = $(TESTLIBS)
-testdirlist_SOURCES=testdirlist.c
+testdirlist_SOURCES=testdirlist.c dbus-glue.c
testdirlist_LDADD = $(TESTLIBS)
diff --git a/tests/dbus-glue.c b/tests/dbus-glue.c
new file mode 100644
index 00000000..b87b0f64
--- /dev/null
+++ b/tests/dbus-glue.c
@@ -0,0 +1,47 @@
+#include "dbus-glue.h"
+#include <gconf/gconf.h>
+#include <dbus/dbus.h>
+
+static const char *
+get_dbus_address (void)
+{
+ /* FIXME: Change this when we know how to find the message bus. */
+ return g_getenv ("GCONF_DBUS_ADDRESS");
+}
+
+gboolean
+setup_dbus (void)
+{
+ static DBusConnection *dbus_conn = NULL;
+ const char *dbus_address;
+ DBusResultCode result;
+ char *name;
+
+ dbus_address = get_dbus_address ();
+ if (!dbus_address)
+ {
+ g_printerr ("Failed to get the D-BUS bus daemon address");
+ return FALSE;
+ }
+
+ dbus_conn = dbus_connection_open (dbus_address, &result);
+ if (!dbus_conn)
+ {
+ g_printerr ("Failed to connect to the D-BUS bus daemon: %s",
+ dbus_result_to_string (result));
+ return FALSE;
+ }
+
+ name = dbus_bus_register_client (dbus_conn, &result);
+ if (!name)
+ {
+ g_printerr ("Failed to register client with the D-BUS bus daemon: %s",
+ dbus_result_to_string (result));
+ return FALSE;
+ }
+
+ dbus_free (name);
+
+ return gconf_init_dbus (dbus_conn);
+}
+
diff --git a/tests/dbus-glue.h b/tests/dbus-glue.h
new file mode 100644
index 00000000..e2148648
--- /dev/null
+++ b/tests/dbus-glue.h
@@ -0,0 +1,8 @@
+#ifndef DBUS_GLUE_H
+#define DBUS_GLUE_H
+
+#include <glib.h>
+
+gboolean setup_dbus (void);
+
+#endif
diff --git a/tests/testchangeset.c b/tests/testchangeset.c
index faddb6cc..4ace20d0 100644
--- a/tests/testchangeset.c
+++ b/tests/testchangeset.c
@@ -51,6 +51,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include "dbus-glue.h"
static void
check(gboolean condition, const gchar* fmt, ...)
@@ -302,6 +303,12 @@ main (int argc, char** argv)
err = NULL;
return 1;
}
+
+ if (!setup_dbus ())
+ {
+ g_printerr ("could not initialize D-BUS");
+ return 1;
+ }
conf = gconf_engine_get_default();
diff --git a/tests/testdirlist.c b/tests/testdirlist.c
index d16cd6c1..e8818e1f 100644
--- a/tests/testdirlist.c
+++ b/tests/testdirlist.c
@@ -51,6 +51,7 @@
#include <locale.h>
#include <stdlib.h>
#include <string.h>
+#include "dbus-glue.h"
static void
check(gboolean condition, const gchar* fmt, ...)
@@ -241,6 +242,12 @@ main (int argc, char** argv)
err = NULL;
return 1;
}
+
+ if (!setup_dbus ())
+ {
+ g_printerr ("could not initialize D-BUS");
+ return 1;
+ }
conf = gconf_engine_get_default();
diff --git a/tests/testgconf.c b/tests/testgconf.c
index 080e684b..e3e5c355 100644
--- a/tests/testgconf.c
+++ b/tests/testgconf.c
@@ -52,6 +52,7 @@
#include <math.h>
#include <locale.h>
#include <gconf/gconf-internals.h>
+#include "dbus-glue.h"
static void
check(gboolean condition, const gchar* fmt, ...)
@@ -955,6 +956,11 @@ main (int argc, char** argv)
return 1;
}
+ if (!setup_dbus ())
+ {
+ g_printerr ("could not initialize D-BUS");
+ return 1;
+ }
check_utils ();
conf = gconf_engine_get_default();
diff --git a/tests/testpersistence.c b/tests/testpersistence.c
index f2753ab6..065e00a9 100644
--- a/tests/testpersistence.c
+++ b/tests/testpersistence.c
@@ -52,6 +52,7 @@
#include <math.h>
#include <locale.h>
#include <gconf/gconf-internals.h>
+#include "dbus-glue.h"
const char *null_safe(const char *s)
{
@@ -902,6 +903,13 @@ main (int argc, char** argv)
err = NULL;
return 1;
}
+
+
+ if (!setup_dbus ())
+ {
+ g_printerr ("could not initialize D-BUS");
+ return 1;
+ }
conf = gconf_engine_get_default();
diff --git a/tests/testschemas.c b/tests/testschemas.c
index 0b871782..9c251eec 100644
--- a/tests/testschemas.c
+++ b/tests/testschemas.c
@@ -51,6 +51,7 @@
#include <math.h>
#include <locale.h>
#include <gconf/gconf-internals.h>
+#include "dbus-glue.h"
/* glibc printf() functions accept NULL for a %s format, but to be
safe, check for null strings and return a printable value */
@@ -624,7 +625,7 @@ check_schema_use(GConfEngine * conf)
}
else if (strcmp (s, schema_key) != 0)
{
- fprintf (stderr, "ERROR: got wrong schema name '%s'\n", schema_key);
+ fprintf (stderr, "ERROR: got wrong schema name '%s' instead of '%s'\n", schema_key, s);
exit (1);
}
@@ -795,6 +796,12 @@ main (int argc, char** argv)
err = NULL;
return 1;
}
+
+ if (!setup_dbus ())
+ {
+ g_printerr ("could not initialize D-BUS");
+ return 1;
+ }
conf = gconf_engine_get_default();