コード例 #1
0
BMAGConfConnection *
bma_gconf_settings_add_connection (BMAGConfSettings *self, BMConnection *connection)
{
	BMAGConfSettingsPrivate *priv;
	BMAGConfConnection *exported;
	guint32 i = 0;
	char *path = NULL;

	g_return_val_if_fail (BMA_IS_GCONF_SETTINGS (self), NULL);
	g_return_val_if_fail (BM_IS_CONNECTION (connection), NULL);

	priv = BMA_GCONF_SETTINGS_GET_PRIVATE (self);

	/* Find free GConf directory */
	while (i++ < G_MAXUINT32) {
		char buf[255];

		snprintf (&buf[0], 255, GCONF_PATH_CONNECTIONS"/%d", i);
		if (!gconf_client_dir_exists (priv->client, buf, NULL)) {
			path = g_strdup (buf);
			break;
		}
	}

	if (path == NULL) {
		bm_warning ("Couldn't find free GConf directory for new connection.");
		return NULL;
	}

	exported = bma_gconf_connection_new_from_connection (priv->client, path, connection);
	g_free (path);
	if (exported) {
		internal_add_connection (self, exported);

		/* Must save connection to GConf _after_ adding it to the connections
		 * list to avoid races with GConf notifications.
		 */
		bm_settings_connection_interface_update (BM_SETTINGS_CONNECTION_INTERFACE (exported), update_cb, NULL);
	}

	return exported;
}
コード例 #2
0
ファイル: gconf-defaults.c プロジェクト: BARGAN/gconf
static void
unset_in_db (GConfDefaults   *mechanism,
	     const gchar     *address,
             const gchar    **includes,
             const gchar    **excludes,
	     GError         **error)
{
	GConfEngine *engine;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	int i;

	engine = gconf_engine_get_local (address, error);
	if (*error)
		goto out;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

 	/* recursively copy each include, leaving out the excludes */
	for (i = 0; includes[i]; i++) {
		if (gconf_client_dir_exists (dest, includes[i], NULL))
			unset_tree (dest, includes[i], changes, excludes);
		else
			unset_entry (dest, includes[i], changes, excludes);
	}

	gconf_client_commit_change_set (dest, changes, TRUE, error);
	gconf_client_suggest_sync (dest, NULL);

out:
	if (dest)
		g_object_unref (dest);
	if (changes)
		gconf_change_set_unref (changes);
}
コード例 #3
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_dir_exists
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;
  GError *err = NULL;
  jboolean value = JNI_FALSE;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    return value;

  /* on error return false */
  gdk_threads_enter ();
  value = gconf_client_dir_exists (client, dir, &err);
  gdk_threads_leave ();
  if (err != NULL)
    value = JNI_FALSE;

  JCL_free_cstring (env, node, dir);

  return value;
}
コード例 #4
0
ファイル: gam-toggle.c プロジェクト: GNOME/gnome-alsamixer
gboolean
gam_toggle_get_visible (GamToggle *gam_toggle)
{
    GamTogglePrivate *priv;
    gchar *key;
    gboolean visible = TRUE;

    g_return_val_if_fail (GAM_IS_TOGGLE (gam_toggle), TRUE);

    priv = GAM_TOGGLE_GET_PRIVATE (gam_toggle);

    key = g_strdup_printf ("/apps/gnome-alsamixer/display_toggles/%s-%s",
                           gam_mixer_get_config_name (GAM_MIXER (priv->mixer)),
                           gam_toggle_get_config_name (gam_toggle));

    if (gconf_client_dir_exists (gam_app_get_gconf_client (GAM_APP (priv->app)), key, NULL))
        visible = gconf_client_get_bool (gam_app_get_gconf_client (GAM_APP (priv->app)),
                                         key,
                                         NULL);

    g_free (key);

    return visible;
}
コード例 #5
0
ファイル: gconf-defaults.c プロジェクト: BARGAN/gconf
static void
do_copy_authorized (GConfDefaults          *mechanism,
                    DBusGMethodInvocation  *context,
		    gpointer                user_data)
{
        CopyData    *data = user_data;
	GConfClient *source = NULL;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	GConfEngine *engine;
        char *address = NULL;
        gint i;
	GError *error;

	error = NULL;
	engine = gconf_engine_get_local (data->dest_address, &error);
	if (error)
		goto cleanup;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	/* find the address to from the caller id */
        address = gconf_address_for_caller (data->mechanism, data->context, &error);
	if (error)
		goto cleanup;

	engine = gconf_engine_get_local (address, &error);
	if (error)
		goto cleanup;

	source = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

	if (data->value) {
		g_assert (data->includes[1] == NULL);
                g_assert (data->excludes == NULL);

		gconf_change_set_set (changes, data->includes[0], data->value);
	}
	else {
	 	/* recursively copy each include, leaving out the excludes */
		for (i = 0; data->includes[i]; i++) {
			if (gconf_client_dir_exists (source, data->includes[i], NULL))
				copy_tree (source, data->includes[i], changes, (const char **)data->excludes);
			else
				copy_entry (source, data->includes[i], changes, (const char **)data->excludes);
		}
	}

	gconf_client_commit_change_set (dest, changes, FALSE, &error);
	gconf_client_suggest_sync (dest, NULL);

	if (data->changeset_callback) {
		data->changeset_callback (data->mechanism, changes, data->user_data);
	}

cleanup:
	g_free (address);
	if (changes)
		gconf_change_set_unref (changes);
	if (dest)
		g_object_unref (dest);
	if (source)
		g_object_unref (source);

	if (error) {
		throw_error (data->context,
			     GCONF_DEFAULTS_ERROR_GENERAL,
			     "%s", error->message);
		g_error_free (error);
	}
	else
        	dbus_g_method_return (data->context);
}
コード例 #6
0
ファイル: gconf-defaults.c プロジェクト: DOICHE/gconf
static void
do_copy (GConfDefaults          *mechanism,
	 gboolean                mandatory,
	 const char            **includes,
	 const char            **excludes,
	 DBusGMethodInvocation  *context,
	 GConfChangeSet        **changeset_out)
{
        char *address = NULL;
	GConfClient *source = NULL;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	GConfEngine *engine;
	GError *error;
	GError *error2;
	const char *action;
	const char *annotation_key;
	const char *default_action;
	const char *dest_address;
	int i;

	if (changeset_out)
		*changeset_out = NULL;

        stop_killtimer ();

	/* check privileges for each include */
	if (mandatory) {
		annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix"; 
		default_action = "org.gnome.gconf.defaults.set-mandatory";
		dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.mandatory";
	}
	else {
		annotation_key = "org.gnome.gconf.defaults.set-system.prefix";
		default_action = "org.gnome.gconf.defaults.set-system";
		dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.system";
	}

	for (i = 0; includes[i]; i++) {
		action = polkit_action_for_gconf_path (mechanism, annotation_key, includes[i]);
		if (action == NULL)
			action = default_action;

		if (!check_polkit_for_action (mechanism, context, action))
			goto out;
	}

	error = NULL;
	engine = gconf_engine_get_local (dest_address, &error);
	if (error)
		goto cleanup;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	/* find the address to from the caller id */
	address = gconf_address_for_caller (mechanism, context, &error);
	if (error)
		goto cleanup;

	engine = gconf_engine_get_local (address, &error);
	if (error)
		goto cleanup;

	source = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

 	/* recursively copy each include, leaving out the excludes */
	for (i = 0; includes[i]; i++) {
		if (gconf_client_dir_exists (source, includes[i], NULL))
			copy_tree (source, includes[i], changes, excludes);
		else
			copy_entry (source, includes[i], changes, excludes);
	}

	gconf_client_commit_change_set (dest, changes, FALSE, &error);
	gconf_client_suggest_sync (dest, NULL);

	if (changeset_out) {
		*changeset_out = changes;
		changes = NULL;
	}

cleanup:
	g_free (address);
	if (changes)
		gconf_change_set_unref (changes);
	if (dest)
		g_object_unref (dest);
	if (source)
		g_object_unref (source);

	if (error) {
		g_print ("failed to set GConf values:  %s\n", error->message);
		error2 = g_error_new_literal (GCONF_DEFAULTS_ERROR,
					      GCONF_DEFAULTS_ERROR_GENERAL,
					      error->message);
		g_error_free (error);

		dbus_g_method_return_error (context, error2);
		g_error_free (error2);
	}
	else
		dbus_g_method_return (context);

out:
	start_killtimer ();
}