RemminaStringArray*
remmina_string_array_new_from_string(const gchar *strs)
{
	RemminaStringArray *array;
	gchar *buf, *ptr1, *ptr2;

	array = remmina_string_array_new();
	if (!strs || strs[0] == '\0')
		return array;

	buf = g_strdup(strs);
	ptr1 = buf;
	while (ptr1)
	{
		ptr2 = strchr(ptr1, ',');
		if (ptr2)
			*ptr2++ = '\0';
		remmina_string_array_add(array, ptr1);
		ptr1 = ptr2;
	}

	g_free(buf);

	return array;
}
Exemple #2
0
static void remmina_main_save_expanded_group(RemminaMain *remminamain)
{
	if (GTK_IS_TREE_STORE(remminamain->priv->file_model))
	{
		if (remminamain->priv->expanded_group)
		{
			remmina_string_array_free(remminamain->priv->expanded_group);
		}
		remminamain->priv->expanded_group = remmina_string_array_new();
		gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(remminamain->priv->file_list),
				(GtkTreeViewMappingFunc) remmina_main_save_expanded_group_func, remminamain);
	}
}
gchar* remmina_file_manager_get_groups(void)
{
	gchar dirname[MAX_PATH_LEN];
	gchar filename[MAX_PATH_LEN];
	GDir* dir;
	const gchar* name;
	RemminaFile* remminafile;
	RemminaStringArray* array;
	const gchar* group;
	gchar* groups;

	array = remmina_string_array_new();

	g_snprintf(dirname, MAX_PATH_LEN, "%s/.remmina", g_get_home_dir());
	dir = g_dir_open(dirname, 0, NULL);
	if (dir == NULL)
		return 0;
	while ((name = g_dir_read_name(dir)) != NULL)
	{
		if (!g_str_has_suffix(name, ".remmina"))
			continue;
		g_snprintf(filename, MAX_PATH_LEN, "%s/%s", dirname, name);
		remminafile = remmina_file_load(filename);
		group = remmina_file_get_string(remminafile, "group");
		if (group && remmina_string_array_find(array, group) < 0)
		{
			remmina_string_array_add(array, group);
		}
		remmina_file_free(remminafile);
	}
	g_dir_close(dir);
	remmina_string_array_sort(array);
	groups = remmina_string_array_to_string(array);
	remmina_string_array_free(array);
	return groups;
}