Exemplo n.º 1
0
PurpleStoredImage *
purple_buddy_icons_find_account_icon(PurpleAccount *account)
{
	PurpleStoredImage *img;
	const char *account_icon_file;
	const char *dirname;
	char *path;
	guchar *data;
	size_t len;

	g_return_val_if_fail(account != NULL, NULL);

	if ((img = g_hash_table_lookup(pointer_icon_cache, account)))
	{
		return purple_imgstore_ref(img);
	}

	account_icon_file = purple_account_get_string(account, "buddy_icon", NULL);

	if (account_icon_file == NULL)
		return NULL;

	dirname = purple_buddy_icons_get_cache_dir();
	path = g_build_filename(dirname, account_icon_file, NULL);

	if (read_icon_file(path, &data, &len))
	{
		g_free(path);
		img = purple_buddy_icons_set_account_icon(account, data, len);
		return purple_imgstore_ref(img);
	}
	g_free(path);

	return NULL;
}
Exemplo n.º 2
0
PurpleStoredImage *
purple_buddy_icons_node_find_custom_icon(PurpleBlistNode *node)
{
	char *path;
	size_t len;
	guchar *data;
	PurpleStoredImage *img;
	const char *custom_icon_file, *dirname;

	g_return_val_if_fail(node != NULL, NULL);

	if ((img = g_hash_table_lookup(pointer_icon_cache, node)))
	{
		return purple_imgstore_ref(img);
	}

	custom_icon_file = purple_blist_node_get_string(node,
	                                                "custom_buddy_icon");

	if (custom_icon_file == NULL)
		return NULL;

	dirname = purple_buddy_icons_get_cache_dir();
	path = g_build_filename(dirname, custom_icon_file, NULL);

	if (read_icon_file(path, &data, &len))
	{
		g_free(path);
		img = purple_buddy_icons_node_set_custom_icon(node, data, len);
		return purple_imgstore_ref(img);
	}
	g_free(path);

	return NULL;
}
Exemplo n.º 3
0
void purple_imgstore_ref_by_id(int id)
{
	PurpleStoredImage *img = purple_imgstore_find_by_id(id);

	g_return_if_fail(img != NULL);

	purple_imgstore_ref(img);
}
Exemplo n.º 4
0
void
msn_object_set_image(MsnObject *obj, PurpleStoredImage *img)
{
	g_return_if_fail(obj != NULL);
	g_return_if_fail(img != NULL);

	/* obj->local = TRUE; */

	purple_imgstore_unref(obj->img);
	obj->img = purple_imgstore_ref(img);
}
Exemplo n.º 5
0
void
msn_slpmsg_set_image(MsnSlpMessage *slpmsg, PurpleStoredImage *img)
{
	/* We can only have one data source at a time. */
	g_return_if_fail(slpmsg->buffer == NULL);
	g_return_if_fail(slpmsg->img == NULL);
	g_return_if_fail(slpmsg->ft == FALSE);

	slpmsg->img = purple_imgstore_ref(img);
	slpmsg->buffer = (guchar *)purple_imgstore_get_data(img);
	slpmsg->size = purple_imgstore_get_size(img);
}
Exemplo n.º 6
0
ggp_image_prepare_result ggp_image_prepare(PurpleConversation *conv,
	const int stored_id, uint64_t *id)
{
	PurpleConnection *gc = purple_conversation_get_connection(conv);
	ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
	PurpleStoredImage *image = purple_imgstore_find_by_id(stored_id);
	size_t image_size;
	gconstpointer image_data;
	uint32_t image_crc;
	ggp_image_sent *sent_image;

	if (!image) {
		purple_debug_error("gg", "ggp_image_prepare: image %d "
			"not found in image store\n", stored_id);
		return GGP_IMAGE_PREPARE_FAILURE;
	}

	image_size = purple_imgstore_get_size(image);

	if (image_size > GGP_IMAGE_SIZE_MAX) {
		purple_debug_warning("gg", "ggp_image_prepare: image "
			"is too big (max bytes: %d)\n", GGP_IMAGE_SIZE_MAX);
		return GGP_IMAGE_PREPARE_TOO_BIG;
	}

	purple_imgstore_ref(image);
	image_data = purple_imgstore_get_data(image);
	image_crc = gg_crc32(0, image_data, image_size);

	purple_debug_info("gg", "ggp_image_prepare: image prepared "
		"[id=%d, crc=%u, size=%" G_GSIZE_FORMAT "]\n",
		stored_id, image_crc, image_size);

	*id = ggp_image_params_to_id(image_crc, image_size);

	sent_image = g_new(ggp_image_sent, 1);
	sent_image->id = stored_id;
	sent_image->conv_name = g_strdup(purple_conversation_get_name(conv));
	g_hash_table_insert(sdata->sent_images, ggp_uint64dup(*id),
		sent_image);

	return GGP_IMAGE_PREPARE_OK;
}
Exemplo n.º 7
0
static PurpleStoredImage *
purple_buddy_icon_data_new(guchar *icon_data, size_t icon_len, const char *filename)
{
	char *file;
	PurpleStoredImage *img;

	g_return_val_if_fail(icon_data != NULL, NULL);
	g_return_val_if_fail(icon_len  > 0,     NULL);

	if (filename == NULL)
	{
		file = purple_util_get_image_filename(icon_data, icon_len);
		if (file == NULL)
		{
			g_free(icon_data);
			return NULL;
		}
	}
	else
		file = g_strdup(filename);

	if ((img = g_hash_table_lookup(icon_data_cache, file)))
	{
		g_free(file);
		g_free(icon_data);
		return purple_imgstore_ref(img);
	}

	img = purple_imgstore_add(icon_data, icon_len, file);

	/* This will take ownership of file and g_free it either now or later. */
	g_hash_table_insert(icon_data_cache, file, img);

	purple_buddy_icon_data_cache(img);

	return img;
}
Exemplo n.º 8
0
void fetion_set_buddy_icon(PurpleConnection * gc, PurpleStoredImage * img)
{
	size_t size = purple_imgstore_get_size(img);
	PurpleProxyConnectData *conn;
	struct fetion_account_data *sip = gc->proto_data;

	g_return_if_fail(img != NULL);

	if (size > 0x32000)
		return;
	sip->icon = img;

	purple_debug_info("fetion:", "set_buddy_icon:len[%d]\n", size);
	if ((conn =
	     purple_proxy_connect(sip->gc, sip->account, sip->UploadServer, 80,
				  UploadPortrait, sip)) == NULL) {
		purple_connection_error_reason(sip->gc,
					       PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
					       _("Couldn't create socket"));
	}

	purple_imgstore_ref(img);

}
Exemplo n.º 9
0
PurpleStoredImage *
purple_smiley_get_stored_image(const PurpleSmiley *smiley)
{
	return purple_imgstore_ref(smiley->img);
}
Exemplo n.º 10
0
PurpleStoredImage *
purple_smiley_get_stored_image(const PurpleSmiley *smiley)
{
	PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(smiley);
	return purple_imgstore_ref(priv->img);
}