static void database_handle_set_schema (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { gchar *key; gchar *schema_key; GError *gerror = NULL; DBusMessage *reply; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &schema_key, DBUS_TYPE_INVALID)) return; /* Empty schema key name means unset. */ if (schema_key[0] == '\0') schema_key = NULL; gconf_database_set_schema (db, key, schema_key, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) return; reply = dbus_message_new_method_return (message); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }
static void database_handle_dir_exists (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { gboolean exists; gchar *dir; GError *gerror = NULL; DBusMessage *reply; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &dir, DBUS_TYPE_INVALID)) return; exists = gconf_database_dir_exists (db, dir, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) return; reply = dbus_message_new_method_return (message); dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &exists, DBUS_TYPE_INVALID); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }
static void database_handle_recursive_unset (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { gchar *key; gchar *locale; GError *gerror = NULL; guint32 unset_flags; DBusMessage *reply; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &locale, DBUS_TYPE_UINT32, &unset_flags, DBUS_TYPE_INVALID)) return; if (locale[0] == '\0') { locale = NULL; } gconf_database_recursive_unset (db, key, locale, unset_flags, &gerror); gconf_database_sync (db, NULL); if (gconfd_dbus_set_exception (conn, message, &gerror)) return; reply = dbus_message_new_method_return (message); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }
static void database_handle_lookup_ext (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { GConfValue *value; gchar *schema_name = NULL; gboolean value_is_default; gboolean value_is_writable; DBusMessage *reply; gchar *key; gchar *locale; GConfLocaleList *locales; gboolean use_schema_default; GError *gerror = NULL; DBusMessageIter iter; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &locale, DBUS_TYPE_BOOLEAN, &use_schema_default, DBUS_TYPE_INVALID)) return; locales = gconfd_locale_cache_lookup (locale); value = gconf_database_query_value (db, key, locales->list, use_schema_default, &schema_name, &value_is_default, &value_is_writable, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) goto fail; reply = dbus_message_new_method_return (message); dbus_message_iter_init_append (reply, &iter); if (value) gconf_dbus_utils_append_entry_values (&iter, key, value, value_is_default, value_is_writable, schema_name); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); fail: g_free (schema_name); if (value) gconf_value_free (value); }
static void database_handle_get_all_dirs (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { GSList *dirs, *l; gchar *dir; GError *gerror = NULL; DBusMessage *reply; DBusMessageIter iter; DBusMessageIter array_iter; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &dir, DBUS_TYPE_INVALID)) return; dirs = gconf_database_all_dirs (db, dir, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) return; reply = dbus_message_new_method_return (message); dbus_message_iter_init_append (reply, &iter); dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array_iter); for (l = dirs; l; l = l->next) { gchar *str = (gchar *) l->data; dbus_message_iter_append_basic (&array_iter, DBUS_TYPE_STRING, &str); g_free (l->data); } dbus_message_iter_close_container (&iter, &array_iter); g_slist_free (dirs); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }
static void database_handle_add_notify (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { gchar *namespace_section; DBusMessage *reply; const char *sender; NotificationData *notification; ListeningClientData *client; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &namespace_section, DBUS_TYPE_INVALID)) return; sender = dbus_message_get_sender (message); client = g_hash_table_lookup (db->listening_clients, sender); if (!client) { client = database_add_listening_client (db, sender); } else { client->nr_of_notifications++; } notification = g_hash_table_lookup (db->notifications, namespace_section); if (notification == NULL) { notification = g_new0 (NotificationData, 1); notification->namespace_section = g_strdup (namespace_section); g_hash_table_insert (db->notifications, notification->namespace_section, notification); } notification->clients = g_list_prepend (notification->clients, g_strdup (sender)); reply = dbus_message_new_method_return (message); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }
static void database_handle_get_all_entries (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { GSList *entries, *l; gchar *dir; gchar *locale; GError *gerror = NULL; GConfLocaleList* locales; DBusMessage *reply; DBusMessageIter iter; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &dir, DBUS_TYPE_STRING, &locale, DBUS_TYPE_INVALID)) return; locales = gconfd_locale_cache_lookup (locale); entries = gconf_database_all_entries (db, dir, locales->list, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) return; reply = dbus_message_new_method_return (message); dbus_message_iter_init_append (reply, &iter); gconf_dbus_utils_append_entries (&iter, entries); for (l = entries; l; l = l->next) { GConfEntry *entry = l->data; gconf_entry_free (entry); } dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); g_slist_free (entries); }
static void server_handle_get_db (DBusConnection *connection, DBusMessage *message) { char *addresses; GSList *list; if (!gconfd_dbus_get_message_args (connection, message, DBUS_TYPE_STRING, &addresses, DBUS_TYPE_INVALID)) return; list = gconf_persistent_name_get_address_list (addresses); server_real_handle_get_db (connection, message, list); g_slist_foreach (list, (GFunc) g_free, NULL); g_slist_free (list); }
static void database_handle_lookup_default (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { GConfValue *value; DBusMessage *reply; gchar *key; gchar *locale; GConfLocaleList *locales; GError *gerror = NULL; DBusMessageIter iter; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &locale, DBUS_TYPE_INVALID)) return; locales = gconfd_locale_cache_lookup (locale); value = gconf_database_query_default_value (db, key, locales->list, NULL, &gerror); if (gconfd_dbus_set_exception (conn, message, &gerror)) goto fail; reply = dbus_message_new_method_return (message); dbus_message_iter_init_append (reply, &iter); if (value) gconf_dbus_utils_append_value (&iter, value); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); fail: if (value) gconf_value_free (value); }
static void database_handle_remove_notify (DBusConnection *conn, DBusMessage *message, GConfDatabase *db) { gchar *namespace_section; DBusMessage *reply; const char *sender; NotificationData *notification; ListeningClientData *client; if (!gconfd_dbus_get_message_args (conn, message, DBUS_TYPE_STRING, &namespace_section, DBUS_TYPE_INVALID)) return; sender = dbus_message_get_sender (message); notification = g_hash_table_lookup (db->notifications, namespace_section); client = g_hash_table_lookup (db->listening_clients, sender); if (client) { client->nr_of_notifications--; if (client->nr_of_notifications == 0) { database_remove_listening_client (db, client); } } /* Notification can be NULL if the client and server get out of sync. */ if (notification == NULL || !database_remove_notification_data (db, notification, sender)) { gconf_log (GCL_DEBUG, _("Notification on %s doesn't exist"), namespace_section); } reply = dbus_message_new_method_return (message); dbus_connection_send (conn, reply, NULL); dbus_message_unref (reply); }