예제 #1
0
static PurpleSmiley *
purple_smiley_new_from_stream(const char *shortcut, guchar *smiley_data,
			size_t smiley_data_len)
{
	PurpleSmiley *smiley;

	g_return_val_if_fail(shortcut  != NULL,    NULL);
	g_return_val_if_fail(smiley_data != NULL,  NULL);
	g_return_val_if_fail(smiley_data_len  > 0, NULL);

	smiley = purple_smileys_find_by_shortcut(shortcut);
	if (smiley)
		return smiley;

	/* purple_smiley_create() sets shortcut */
	smiley = purple_smiley_create(shortcut);
	if (!smiley)
		return NULL;

	purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len);

	purple_smiley_data_store(smiley->img);

	return smiley;
}
예제 #2
0
static PurpleSmiley *
purple_smiley_load_file(const char *shortcut, const char *checksum, const char *filename)
{
	PurpleSmiley *smiley = NULL;
	guchar *smiley_data;
	size_t smiley_data_len;
	char *fullpath = NULL;

	g_return_val_if_fail(shortcut  != NULL, NULL);
	g_return_val_if_fail(checksum  != NULL, NULL);
	g_return_val_if_fail(filename != NULL, NULL);

	fullpath = get_file_full_path(filename);
	if (!fullpath)
		return NULL;

	smiley = purple_smiley_create(shortcut);
	if (!smiley) {
		g_free(fullpath);
		return NULL;
	}

	smiley->checksum = g_strdup(checksum);

	if (read_smiley_file(fullpath, &smiley_data, &smiley_data_len))
		purple_smiley_set_data_impl(smiley, smiley_data,
				smiley_data_len);
	else
		purple_smiley_delete(smiley);

	g_free(fullpath);

	return smiley;
}
예제 #3
0
PurpleSmiley *
purple_smiley_new(PurpleStoredImage *img, const char *shortcut)
{
	PurpleSmiley *smiley = NULL;

	g_return_val_if_fail(shortcut  != NULL, NULL);
	g_return_val_if_fail(img       != NULL, NULL);

	smiley = purple_smileys_find_by_shortcut(shortcut);
	if (smiley)
		return smiley;

	smiley = purple_smiley_create(shortcut);
	if (!smiley)
		return NULL;

	g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, img, NULL);

	return smiley;
}
예제 #4
0
파일: smiley.c 프로젝트: Distrotech/pidgin
static void
purple_smiley_load_file(const char *shortcut, const char *checksum, const char *filename)
{
	PurpleSmiley *smiley = NULL;
	PurpleSmileyPrivate *priv = NULL;
	guchar *smiley_data;
	size_t smiley_data_len;
	char *fullpath = NULL;

	g_return_if_fail(shortcut  != NULL);
	g_return_if_fail(checksum  != NULL);
	g_return_if_fail(filename != NULL);

	fullpath = get_file_full_path(filename);
	if (!fullpath) {
		purple_debug_error(SMILEYS_LOG_ID, "Path for filename %s doesn't exist\n", filename);
		return;
	}

	smiley = purple_smiley_create(shortcut);
	if (!smiley) {
		g_free(fullpath);
		return;
	}

	priv = PURPLE_SMILEY_GET_PRIVATE(smiley);

	priv->checksum = g_strdup(checksum);

	if (read_smiley_file(fullpath, &smiley_data, &smiley_data_len))
		purple_smiley_set_data_impl(smiley, smiley_data,
				smiley_data_len);
	else
		purple_smiley_delete(smiley);

	g_free(fullpath);

}