예제 #1
0
static void
unset_tree (GConfClient     *dest,
            const char      *path,
	    GConfChangeSet  *changes,
            const char     **excludes)
{
	GSList *list, *l;
	GConfEntry *entry;

	if (path_is_excluded (path, excludes))
		return;

	list = gconf_client_all_entries (dest, path, NULL);
	for (l = list; l; l = l->next) {
		entry = l->data;
		if (!path_is_excluded (entry->key, excludes))
			gconf_change_set_unset (changes, entry->key);
	}
	g_slist_foreach (list, (GFunc)gconf_entry_free, NULL);
	g_slist_free (list);

	list = gconf_client_all_dirs (dest, path, NULL);
	for (l = list; l; l = l->next)
		unset_tree (dest, (const char *)l->data, changes, excludes);
	g_slist_foreach (list, (GFunc)g_free, NULL);
	g_slist_free (list);
}
예제 #2
0
void
gnc_gconf_unset_dir (const gchar *section,
                     GError **caller_error)
{
    GError *error = NULL;
    GSList *entries, *tmp;
    const gchar *key;
    gchar *dir_key;

    if (our_client == NULL)
        our_client = gconf_client_get_default();

    dir_key = gnc_gconf_make_key(section, NULL);
    entries = gconf_client_all_entries(our_client, dir_key, &error);
    g_free(dir_key);
    if (error)
    {
        if (caller_error)
        {
            g_propagate_error(caller_error, error);
        }
        else
        {
            printf("Failed to get directory entries for key %s: %s",
                   dir_key, error->message);
            g_error_free(error);
        }
        return;
    }

    for (tmp = entries; tmp; tmp = g_slist_next(tmp))
    {
        key = gconf_entry_get_key(tmp->data);
        if (!gconf_client_unset(our_client, key, &error))
        {
            if (caller_error)
            {
                g_propagate_error(caller_error, error);
            }
            else
            {
                printf("Failed to unset key %s: %s", key, error->message);
                g_error_free(error);
            }
            break;
        }
    }

    g_slist_foreach(entries, (GFunc)gconf_entry_free, NULL);
    g_slist_free(entries);
}
예제 #3
0
static GHashTable *
load_options (void)
{
        GHashTable *ht = NULL;
        GConfClient *client = gconf_client_get_default ();
        GSList *entries, *e;
        GError *error = NULL;

        gconf_client_add_dir (client, GEOCLUE_GCONF_TOP,
        		      GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);

        entries = gconf_client_all_entries (client, GEOCLUE_GCONF_TOP, &error);
        if (error != NULL) {
                g_warning ("Error loading master options: %s", error->message);
                g_error_free (error);
                return NULL;
        }

        /* Setup keys monitoring */
	gconf_client_notify_add (client, GEOCLUE_GCONF_TOP,
				 (GConfClientNotifyFunc) gconf_key_changed,
				 NULL, NULL, NULL);

        ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
        g_print ("Master options:\n");
        for (e = entries; e; e = e->next) {
                GConfEntry *entry = e->data;
                const char *key, *value;
                GConfValue *v;

                key = gconf_entry_get_key (entry);
                v = gconf_entry_get_value (entry);
                if (v->type != GCONF_VALUE_STRING)
                	continue;
                value = gconf_value_get_string (v);

                if (value != NULL && value[0] == '\0')
                	value = NULL;

                g_print ("  %s = %s\n", key, value);
                g_hash_table_insert (ht, g_path_get_basename (key),
                                     g_strdup (value));
                 gconf_entry_free (entry);
         }
         g_slist_free (entries);

         return ht;
 }
예제 #4
0
GSList *
gnc_gconf_client_all_entries (const gchar *name)
{
    GError *error = NULL;
    GSList *value;
    gchar *section;

    if (our_client == NULL)
        our_client = gconf_client_get_default();

    section = gnc_gconf_section_name(name);
    value = gconf_client_all_entries(our_client, section, &error);
    g_free(section);
    if (error != NULL)
    {
        printf("Failed to get list of all gconf keys: %s", error->message);
        g_error_free(error);
    }

    return value;
}
예제 #5
0
파일: options.c 프로젝트: AKMergl/gRDesktop
gint loadOptions() {
	GSList *values;
	gint i;
	gint count;

	values = gconf_client_all_entries(gcfg, GCONF_BASE, NULL);
	count = g_slist_length(values);
	for(i=0; i<count; i++) {
		GConfEntry *item;
		GConfValue *typ;
		gchar *value;
		gchar **path = NULL;
		gint y = 0;

		item = g_slist_nth_data(values, i);
		typ = gconf_entry_get_value(item);
		if(typ == NULL) {
#ifdef _DEBUG_
			g_warning("Gconf item \"%s\" is unassigned!",
				gconf_entry_get_key(item));
#endif
			continue;
		}

		path = g_strsplit(gconf_entry_get_key(item), "/", 0);
		while(path[y] != NULL)
			y++;

		if(!g_ascii_strcasecmp(path[y-1], "hostnames")) {
			if(path != NULL)
				g_strfreev(path);
			continue;
		}

		switch(typ->type) {
		case GCONF_VALUE_STRING:
			value = g_strdup_printf("%s",
				gconf_client_get_string(gcfg, 
				gconf_entry_get_key(item), NULL));
			break;
		case GCONF_VALUE_INT:
			value = g_strdup_printf("%d",
				gconf_client_get_int(gcfg, 
				gconf_entry_get_key(item), NULL));
			break;
		case GCONF_VALUE_FLOAT:
			value = g_strdup_printf("%f",
				gconf_client_get_float(gcfg, 
				gconf_entry_get_key(item), NULL));
			break;
		case GCONF_VALUE_BOOL:
			value = g_strdup_printf("%d",
				gconf_client_get_bool(gcfg, 
				gconf_entry_get_key(item), NULL));
			break;
		default:
			g_warning("Unsupported gconf value type (%d)",
				typ->type);
			continue;
		}
		
#ifdef _DEBUG_
		g_warning("Option: %s->%s", path[y-1], value);
#endif

		g_hash_table_insert(config, g_strdup(path[y-1]),
			g_strdup(value));

		if(path != NULL)
			g_strfreev(path);
	}

	/* get the current username */
	if(SHASH("username") == NULL) {
		g_hash_table_insert(config, "username",
			g_utf8_strup((gchar*)g_get_user_name(), -1));
	}

	return(0);
}
예제 #6
0
/* Not used for now as there is no API to remove completely gconf keys.
 * So we reuse existing accounts instead of creating new ones */
void
destroy_test_account (EmpathyAccount *account)
{
  GConfClient *client;
  gchar *path;
  GError *error = NULL;
  GSList *entries = NULL, *l;
  EmpathyAccountManager *manager;

  client = gconf_client_get_default ();
  path = g_strdup_printf ("/apps/telepathy/mc/accounts/%s",
      empathy_account_get_unique_name (account));

  entries = gconf_client_all_entries (client, path, &error);
  if (error != NULL)
    {
      g_print ("failed to list entries in %s: %s\n", path, error->message);
      g_error_free (error);
      error = NULL;
    }

  for (l = entries; l != NULL; l = g_slist_next (l))
    {
      GConfEntry *entry = l->data;

      if (g_str_has_suffix (entry->key, "data_dir"))
        {
          gchar *dir;

          dir = gconf_client_get_string (client, entry->key, &error);
          if (error != NULL)
            {
              g_print ("get data_dir string failed: %s\n", entry->key);
              g_error_free (error);
              error = NULL;
            }
          else
            {
              if (g_rmdir (dir) != 0)
                g_print ("can't remove %s\n", dir);
            }

          g_free (dir);
        }

      /* FIXME: this doesn't remove the key */
      gconf_client_unset (client, entry->key, &error);
      if (error != NULL)
        {
          g_print ("unset of %s failed: %s\n", path, error->message);
          g_error_free (error);
          error = NULL;
        }

      gconf_entry_unref (entry);
    }

  g_slist_free (entries);

  g_object_unref (client);
  g_free (path);

  manager = empathy_account_manager_dup_singleton ();
  empathy_account_manager_remove (manager, account);
  g_object_unref (account);
  g_object_unref (manager);
}
예제 #7
0
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_gconf_client_all_keys
 * Signature: (Ljava/lang/String;)Ljava/util/List;
 */
JNIEXPORT jobject JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  /* TODO: check all the calls to gdk_threads_enter/leave */
  
  const char *dir = NULL;
  GError *err = NULL;
  GSList *entries = NULL;
  GSList *tmp;

  /* java.util.ArrayList */
  jobject jlist = NULL;

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

  gdk_threads_enter ();
  entries = gconf_client_all_entries (client, dir, &err);
  gdk_threads_leave ();
  if (err != NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
                               err->message);
      g_error_free (err);
      err = NULL;

      JCL_free_cstring (env, node, dir);
      return NULL;
    }

  jlist = get_jlist_reference (env, jlist_class);
  if (jlist == NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
			       "Unable to get java.util.List reference in native code\n");
      JCL_free_cstring (env, node, dir);
      g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
      g_slist_free (entries);
      return NULL;
    }

  tmp = entries;
  while (tmp != NULL)
    {
      const char *_val = gconf_entry_get_key (tmp->data);
      _val = strrchr (_val, '/');
      ++_val;
      (*env)->CallBooleanMethod (env, jlist, jlist_add_id,
				 (*env)->NewStringUTF (env, _val));
      tmp = g_slist_next (tmp);
    }

  /* clean up things */
  JCL_free_cstring (env, node, dir);
  g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
  g_slist_free (entries);
  
  return jlist;
}