コード例 #1
0
ファイル: smiley.c プロジェクト: matyapiro31/instantbird-1.5
static void
sync_smileys(void)
{
	xmlnode *root_node;
	char *data;

	if (!smileys_loaded) {
		purple_debug_error(SMILEYS_LOG_ID, "Attempted to save smileys before it "
						 "was read!\n");
		return;
	}

	root_node = smileys_to_xmlnode();
	data = xmlnode_to_formatted_str(root_node, NULL);
	purple_util_write_data_to_file(XML_FILE_NAME, data, -1);

	g_free(data);
	xmlnode_free(root_node);
}
コード例 #2
0
ファイル: gf_games.c プロジェクト: wosigh/messaging-plugins
static void gfire_game_save_config_xml()
{
	xmlnode *game_config = xmlnode_new("game_config");
	xmlnode_set_attrib(game_config, "version", "2");

	GList *cur = gfire_games_config;
	while(cur)
	{
		xmlnode_insert_child(game_config, gfire_game_configuration_to_xmlnode((gfire_game_configuration*)cur->data));

		cur = g_list_next(cur);
	}

	gchar *xml_str = xmlnode_to_formatted_str(game_config, NULL);

	purple_util_write_data_to_file("gfire_game_config.xml", xml_str, -1);
	g_free(xml_str);

	xmlnode_free(game_config);
}
コード例 #3
0
ファイル: prefs.c プロジェクト: psunkari/spicebird
static void
sync_prefs(void)
{
	xmlnode *node;
	char *data;

	if (!prefs_loaded)
	{
		/*
		 * TODO: Call schedule_prefs_save()?  Ideally we wouldn't need to.
		 * (prefs.xml should be loaded when purple_prefs_init is called)
		 */
		purple_debug_error("prefs", "Attempted to save prefs before "
						 "they were read!\n");
		return;
	}

	node = prefs_to_xmlnode();
	data = xmlnode_to_formatted_str(node, NULL);
	purple_util_write_data_to_file("prefs.xml", data, -1);
	g_free(data);
	xmlnode_free(node);
}
コード例 #4
0
ファイル: yahoo_aliases.c プロジェクト: Mons/libpurple-mini
static void
yahoo_set_userinfo_cb(PurpleConnection *gc, PurpleRequestFields *fields)
{
	xmlnode *node = xmlnode_new("ab");
	xmlnode *ct = xmlnode_new_child(node, "ct");
	YahooData *yd = purple_connection_get_protocol_data(gc);
	PurpleAccount *account;
	PurpleUtilFetchUrlData *url_data;
	char *webaddress, *webpage;
	char *request, *content;
	int len;
	int i;
	char * yfields[] = { "fn", "ln", "nn", "mn", "hp", "wp", "mo", NULL };

	account = purple_connection_get_account(gc);

	xmlnode_set_attrib(node, "k", purple_connection_get_display_name(gc));
	xmlnode_set_attrib(node, "cc", "1");		/* XXX: ? */

	xmlnode_set_attrib(ct, "e", "1");
	xmlnode_set_attrib(ct, "yi", purple_request_fields_get_string(fields, "yname"));
	xmlnode_set_attrib(ct, "id", purple_request_fields_get_string(fields, "yid"));
	xmlnode_set_attrib(ct, "pr", "0");

	for (i = 0; yfields[i]; i++) {
		const char *v = purple_request_fields_get_string(fields, yfields[i]);
		xmlnode_set_attrib(ct, yfields[i], v ? v : "");
	}

	content = xmlnode_to_formatted_str(node, &len);
	xmlnode_free(node);
	purple_url_parse(yd->jp ? YAHOOJP_USERINFO_URL : YAHOO_USERINFO_URL, &webaddress, NULL, &webpage, NULL, NULL);

	request = g_strdup_printf("POST %s HTTP/1.1\r\n"
				  "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
				  "Cookie: T=%s; path=/; domain=.yahoo.com; Y=%s;\r\n"
				  "Host: %s\r\n"
				  "Content-Length: %d\r\n"
				  "Cache-Control: no-cache\r\n\r\n"
				  "%s\r\n\r\n",
				  webpage,
				  yd->cookie_t, yd->cookie_y,
				  webaddress,
				  len + 4,
				  content);

#if 0
	{
		/* This is if we wanted to send our contact details to everyone
		 * in the buddylist. But this cannot be done now, because in the
		 * official messenger, doing this pops a conversation window at
		 * the receiver's end, which is stupid, and thus not really
		 * surprising. */
		struct yahoo_userinfo *ui = g_new(struct yahoo_userinfo, 1);
		node = xmlnode_new("contact");

		for (i = 0; yfields[i]; i++) {
			const char *v = purple_request_fields_get_string(fields, yfields[i]);
			if (v) {
				xmlnode *nd = xmlnode_new_child(node, yfields[i]);
				xmlnode_insert_data(nd, v, -1);
			}
		}

		ui->yd = yd;
		ui->xml = xmlnode_to_str(node, NULL);
		xmlnode_free(node);
	}
#endif

	url_data = purple_util_fetch_url_request_len_with_account(account, webaddress, FALSE,
			YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
			yahoo_fetch_aliases_cb, gc);
	if (url_data != NULL)
		yd->url_datas = g_slist_prepend(yd->url_datas, url_data);

	g_free(webaddress);
	g_free(webpage);
	g_free(content);
	g_free(request);
}