Beispiel #1
0
static void
reset_plugin_window(GntWidget *window, gpointer null)
{
	GList *list = g_object_get_data(G_OBJECT(plugins.tree), "seen-list");
	purple_prefs_set_path_list("/finch/plugins/seen", list);
	g_list_foreach(list, (GFunc)g_free, NULL);
	g_list_free(list);

	plugins.window = NULL;
	plugins.tree = NULL;
	plugins.aboot = NULL;
}
Beispiel #2
0
void
purple_plugins_save_loaded(const char *key)
{
#ifdef PURPLE_PLUGINS
	GList *pl;
	GList *files = NULL;

	for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) {
		PurplePlugin *plugin = pl->data;

		if (plugin->info->type != PURPLE_PLUGIN_PROTOCOL &&
		    plugin->info->type != PURPLE_PLUGIN_LOADER &&
		    !g_list_find(plugins_to_disable, plugin)) {
			files = g_list_append(files, plugin->path);
		}
	}

	purple_prefs_set_path_list(key, files);
	g_list_free(files);
#endif
}
Beispiel #3
0
static void
prefs_start_element_handler (GMarkupParseContext *context,
		const gchar *element_name,
		const gchar **attribute_names,
		const gchar **attribute_values,
		gpointer user_data,
		GError **error)
{
	PurplePrefType pref_type = PURPLE_PREF_NONE;
	int i;
	const char *pref_name = NULL, *pref_value = NULL;
	GString *pref_name_full;
	GList *tmp;

	if(!purple_strequal(element_name, "pref") &&
	   !purple_strequal(element_name, "item"))
		return;

	for(i = 0; attribute_names[i]; i++) {
		if(purple_strequal(attribute_names[i], "name")) {
			pref_name = attribute_values[i];
		} else if(purple_strequal(attribute_names[i], "type")) {
			if(purple_strequal(attribute_values[i], "bool"))
				pref_type = PURPLE_PREF_BOOLEAN;
			else if(purple_strequal(attribute_values[i], "int"))
				pref_type = PURPLE_PREF_INT;
			else if(purple_strequal(attribute_values[i], "string"))
				pref_type = PURPLE_PREF_STRING;
			else if(purple_strequal(attribute_values[i], "stringlist"))
				pref_type = PURPLE_PREF_STRING_LIST;
			else if(purple_strequal(attribute_values[i], "path"))
				pref_type = PURPLE_PREF_PATH;
			else if(purple_strequal(attribute_values[i], "pathlist"))
				pref_type = PURPLE_PREF_PATH_LIST;
			else
				return;
		} else if(purple_strequal(attribute_names[i], "value")) {
			pref_value = attribute_values[i];
		}
	}

	if(purple_strequal(element_name, "item")) {
		struct purple_pref *pref;

		pref_name_full = g_string_new("");

		for(tmp = prefs_stack; tmp; tmp = tmp->next) {
			pref_name_full = g_string_prepend(pref_name_full, tmp->data);
			pref_name_full = g_string_prepend_c(pref_name_full, '/');
		}

		pref = find_pref(pref_name_full->str);

		if(pref) {
			if(pref->type == PURPLE_PREF_STRING_LIST) {
				pref->value.stringlist = g_list_append(pref->value.stringlist,
						g_strdup(pref_value));
			} else if(pref->type == PURPLE_PREF_PATH_LIST) {
				pref->value.stringlist = g_list_append(pref->value.stringlist,
						g_filename_from_utf8(pref_value, -1, NULL, NULL, NULL));
			}
		}
		g_string_free(pref_name_full, TRUE);
	} else {
		char *decoded;

		if(!pref_name || purple_strequal(pref_name, "/"))
			return;

		pref_name_full = g_string_new(pref_name);

		for(tmp = prefs_stack; tmp; tmp = tmp->next) {
			pref_name_full = g_string_prepend_c(pref_name_full, '/');
			pref_name_full = g_string_prepend(pref_name_full, tmp->data);
		}

		pref_name_full = g_string_prepend_c(pref_name_full, '/');

		switch(pref_type) {
			case PURPLE_PREF_NONE:
				purple_prefs_add_none(pref_name_full->str);
				break;
			case PURPLE_PREF_BOOLEAN:
				purple_prefs_set_bool(pref_name_full->str, atoi(pref_value));
				break;
			case PURPLE_PREF_INT:
				purple_prefs_set_int(pref_name_full->str, atoi(pref_value));
				break;
			case PURPLE_PREF_STRING:
				purple_prefs_set_string(pref_name_full->str, pref_value);
				break;
			case PURPLE_PREF_STRING_LIST:
				purple_prefs_set_string_list(pref_name_full->str, NULL);
				break;
			case PURPLE_PREF_PATH:
				if (pref_value) {
					decoded = g_filename_from_utf8(pref_value, -1, NULL, NULL, NULL);
					purple_prefs_set_path(pref_name_full->str, decoded);
					g_free(decoded);
				} else {
					purple_prefs_set_path(pref_name_full->str, NULL);
				}
				break;
			case PURPLE_PREF_PATH_LIST:
				purple_prefs_set_path_list(pref_name_full->str, NULL);
				break;
		}
		prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name));
		g_string_free(pref_name_full, TRUE);
	}
}
Beispiel #4
0
static void
purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpref)
{
	struct purple_pref *child, *next;
	char *oldname, *newname;

	/* if we're a parent, rename the kids first */
	for(child = oldpref->first_child; child != NULL; child = next)
	{
		struct purple_pref *newchild;
		next = child->sibling;
		for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling)
		{
			if(purple_strequal(child->name, newchild->name))
			{
				purple_prefs_rename_node(child, newchild);
				break;
			}
		}
		if(newchild == NULL) {
			/* no rename happened, we weren't able to find the new pref */
			char *tmpname = pref_full_name(child);
			purple_debug_error("prefs", "Unable to find rename pref for %s\n", tmpname);
			g_free(tmpname);
		}
	}

	oldname = pref_full_name(oldpref);
	newname = pref_full_name(newpref);

	if (oldpref->type != newpref->type)
	{
		purple_debug_error("prefs", "Unable to rename %s to %s: differing types\n", oldname, newname);
		g_free(oldname);
		g_free(newname);
		return;
	}

	purple_debug_info("prefs", "Renaming %s to %s\n", oldname, newname);
	g_free(oldname);

	switch(oldpref->type) {
		case PURPLE_PREF_NONE:
			break;
		case PURPLE_PREF_BOOLEAN:
			purple_prefs_set_bool(newname, oldpref->value.boolean);
			break;
		case PURPLE_PREF_INT:
			purple_prefs_set_int(newname, oldpref->value.integer);
			break;
		case PURPLE_PREF_STRING:
			purple_prefs_set_string(newname, oldpref->value.string);
			break;
		case PURPLE_PREF_STRING_LIST:
			purple_prefs_set_string_list(newname, oldpref->value.stringlist);
			break;
		case PURPLE_PREF_PATH:
			purple_prefs_set_path(newname, oldpref->value.string);
			break;
		case PURPLE_PREF_PATH_LIST:
			purple_prefs_set_path_list(newname, oldpref->value.stringlist);
			break;
	}
	g_free(newname);

	remove_pref(oldpref);
}