/pidgin/main: a5b71a95a42a: imgstore: remove references from lib...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Thu Apr 10 17:20:55 EDT 2014
Changeset: a5b71a95a42a0880ac3b5934ed980138d98e68f2
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-10 23:20 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/a5b71a95a42a
Description:
imgstore: remove references from libpurple (not prpls yet)
diffstat:
libpurple/log.c | 14 ++++++++------
libpurple/protocols/null/nullprpl.c | 10 +++++-----
libpurple/xfer.c | 17 ++++++++++-------
3 files changed, 23 insertions(+), 18 deletions(-)
diffs (117 lines):
diff --git a/libpurple/log.c b/libpurple/log.c
--- a/libpurple/log.c
+++ b/libpurple/log.c
@@ -24,11 +24,11 @@
#include "dbus-maybe.h"
#include "debug.h"
#include "glibcompat.h"
+#include "image-store.h"
#include "log.h"
#include "prefs.h"
#include "util.h"
#include "stringref.h"
-#include "imgstore.h"
#include "time.h"
static GSList *loggers = NULL;
@@ -798,7 +798,9 @@ static char *log_get_timestamp(PurpleLog
}
/* NOTE: This can return msg (which you may or may not want to g_free())
- * NOTE: or a newly allocated string which you MUST g_free(). */
+ * NOTE: or a newly allocated string which you MUST g_free().
+ * TODO: XXX: does it really works?
+ */
static char *
convert_image_tags(const PurpleLog *log, const char *msg)
{
@@ -828,13 +830,13 @@ convert_image_tags(const PurpleLog *log,
{
FILE *image_file;
char *dir;
- PurpleStoredImage *image;
+ PurpleImage *image;
gconstpointer image_data;
char *new_filename = NULL;
char *path = NULL;
size_t image_byte_count;
- image = purple_imgstore_find_by_id(imgid);
+ image = purple_image_store_get(imgid);
if (image == NULL)
{
/* This should never happen. */
@@ -843,8 +845,8 @@ convert_image_tags(const PurpleLog *log,
g_return_val_if_reached((char *)msg);
}
- image_data = purple_imgstore_get_data(image);
- image_byte_count = purple_imgstore_get_size(image);
+ image_data = purple_image_get_data(image);
+ image_byte_count = purple_image_get_size(image);
dir = purple_log_get_log_dir(log->type, log->name, log->account);
new_filename = purple_util_get_image_filename(image_data, image_byte_count);
diff --git a/libpurple/protocols/null/nullprpl.c b/libpurple/protocols/null/nullprpl.c
--- a/libpurple/protocols/null/nullprpl.c
+++ b/libpurple/protocols/null/nullprpl.c
@@ -924,11 +924,11 @@ static const char *nullprpl_normalize(co
return NULL;
}
-static void nullprpl_set_buddy_icon(PurpleConnection *gc,
- PurpleStoredImage *img) {
- purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n",
- purple_account_get_username(purple_connection_get_account(gc)),
- img ? purple_imgstore_get_filename(img) : "(null)");
+static void
+nullprpl_set_buddy_icon(PurpleConnection *gc, PurpleImage *img) {
+ purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n",
+ purple_account_get_username(purple_connection_get_account(gc)),
+ img ? purple_image_get_path(img) : "(null)");
}
static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) {
diff --git a/libpurple/xfer.c b/libpurple/xfer.c
--- a/libpurple/xfer.c
+++ b/libpurple/xfer.c
@@ -24,6 +24,7 @@
#include "dbus-maybe.h"
#include "enums.h"
+#include "image-store.h"
#include "xfer.h"
#include "network.h"
#include "notify.h"
@@ -32,7 +33,6 @@
#include "request.h"
#include "util.h"
#include "debug.h"
-#include "imgstore.h" /* TODO: temp */
#define FT_INITIAL_BUFFER_SIZE 4096
#define FT_MAX_BUFFER_SIZE 65535
@@ -259,14 +259,17 @@ purple_xfer_conversation_write_internal(
if (print_thumbnail && thumbnail_data) {
gchar *message_with_img;
gpointer data = g_memdup(thumbnail_data, size);
- int id = purple_imgstore_new_with_id(data, size, NULL);
-
- message_with_img =
- g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'> %s",
- id, escaped);
+ PurpleImage *img;
+ guint id;
+
+ img = purple_image_new_from_data(data, size);
+ id = purple_image_store_add(img);
+ g_object_unref(img);
+
+ message_with_img = g_strdup_printf("<img src=\""
+ PURPLE_IMAGE_STORE_PROTOCOL "%u\"> %s", id, escaped);
purple_conversation_write(PURPLE_CONVERSATION(im), NULL,
message_with_img, flags, time(NULL));
- purple_imgstore_unref_by_id(id);
g_free(message_with_img);
} else {
purple_conversation_write(PURPLE_CONVERSATION(im), NULL, escaped, flags,
More information about the Commits
mailing list