Mercurial > pidgin.yaz
changeset 30250:afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 25 Apr 2010 21:09:34 +0000 |
parents | 905e291986bc |
children | 0bc8e250ae0d |
files | libpurple/ft.c libpurple/ft.h libpurple/protocols/jabber/si.c libpurple/protocols/msn/slplink.c |
diffstat | 4 files changed, 22 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/ft.c Sun Apr 25 20:58:00 2010 +0000 +++ b/libpurple/ft.c Sun Apr 25 21:09:34 2010 +0000 @@ -281,11 +281,14 @@ PurpleConversation *conv = NULL; PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; char *escaped; - gconstpointer thumbnail_data = purple_xfer_get_thumbnail_data(xfer); + gconstpointer thumbnail_data; + gsize size; g_return_if_fail(xfer != NULL); g_return_if_fail(message != NULL); + thumbnail_data = purple_xfer_get_thumbnail(xfer, &size); + conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, purple_xfer_get_account(xfer)); @@ -299,7 +302,6 @@ if (print_thumbnail && thumbnail_data) { gchar *message_with_img; - gsize size = purple_xfer_get_thumbnail_size(xfer); gpointer data = g_memdup(thumbnail_data, size); int id = purple_imgstore_add_with_id(data, size, NULL); @@ -489,6 +491,8 @@ { char *buf, *size_buf; size_t size; + gconstpointer thumb; + gsize thumb_size; /* If we have already accepted the request, ask the destination file name directly */ @@ -514,11 +518,10 @@ serv_got_im(purple_account_get_connection(xfer->account), xfer->who, xfer->message, 0, time(NULL)); - if (purple_xfer_get_thumbnail_data(xfer)) { + if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL, PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, - purple_xfer_get_thumbnail_data(xfer), - purple_xfer_get_thumbnail_size(xfer), xfer, + thumb, thumb_size, xfer, G_CALLBACK(purple_xfer_choose_file), G_CALLBACK(cancel_recv_cb)); } else { @@ -1630,20 +1633,15 @@ ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); } -const void * -purple_xfer_get_thumbnail_data(const PurpleXfer *xfer) +gconstpointer +purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len) { PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); - return priv->thumbnail_data; -} + if (len) + *len = priv->thumbnail_size; -gsize -purple_xfer_get_thumbnail_size(const PurpleXfer *xfer) -{ - PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); - - return priv->thumbnail_size; + return priv->thumbnail_data; } const gchar *
--- a/libpurple/ft.h Sun Apr 25 20:58:00 2010 +0000 +++ b/libpurple/ft.h Sun Apr 25 21:09:34 2010 +0000 @@ -696,17 +696,11 @@ * Gets the thumbnail data for a transfer * * @param xfer The file transfer to get the thumbnail for + * @param len If not @c NULL, the length of the thumbnail data returned + * will be set in the location pointed to by this. * @return The thumbnail data, or NULL if there is no thumbnail */ -const void *purple_xfer_get_thumbnail_data(const PurpleXfer *xfer); - -/** - * Gets the thumbnail size for a transfer - * - * @param xfer The file transfer to get the thumbnail size for - * @return The size, in bytes of the file transfer's thumbnail - */ -gsize purple_xfer_get_thumbnail_size(const PurpleXfer *xfer); +gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len); /** * Gets the mimetype of the thumbnail preview for a transfer
--- a/libpurple/protocols/jabber/si.c Sun Apr 25 20:58:00 2010 +0000 +++ b/libpurple/protocols/jabber/si.c Sun Apr 25 21:09:34 2010 +0000 @@ -1247,6 +1247,8 @@ JabberIq *iq; xmlnode *si, *file, *feature, *x, *field, *option, *value; char buf[32]; + gconstpointer thumb; + gsize thumb_size; xfer->filename = g_path_get_basename(xfer->local_filename); purple_xfer_prepare_thumbnail(xfer, "jpeg,png"); @@ -1269,12 +1271,11 @@ /* maybe later we'll do hash and date attribs */ /* add thumbnail, if appropriate */ - if (purple_xfer_get_thumbnail_data(xfer)) { + if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { const gchar *mimetype = purple_xfer_get_thumbnail_mimetype(xfer); JabberData *thumbnail_data = - jabber_data_create_from_data(purple_xfer_get_thumbnail_data(xfer), - purple_xfer_get_thumbnail_size(xfer), mimetype, TRUE, - jsx->js); + jabber_data_create_from_data(thumb, thumb_size, + mimetype, TRUE, jsx->js); xmlnode *thumbnail = xmlnode_new_child(file, "thumbnail"); xmlnode_set_namespace(thumbnail, NS_THUMBS); xmlnode_set_attrib(thumbnail, "cid",
--- a/libpurple/protocols/msn/slplink.c Sun Apr 25 20:58:00 2010 +0000 +++ b/libpurple/protocols/msn/slplink.c Sun Apr 25 21:09:34 2010 +0000 @@ -720,11 +720,7 @@ u8 = NULL; } - preview = purple_xfer_get_thumbnail_data(xfer); - if (preview) - preview_len = purple_xfer_get_thumbnail_size(xfer); - else - preview_len = 0; + preview = purple_xfer_get_thumbnail(xfer, &preview_len); header = g_malloc(sizeof(MsnFileContext) + preview_len); header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);