Fri, 15 Jun 2012 00:59:46 -0400
From now on, prpls must specify images using SRC instead of ID.
This only fixes libpurple, the UI side doesn't follow this change
just yet.
--- a/libpurple/ft.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/ft.c Fri Jun 15 00:59:46 2012 -0400 @@ -306,7 +306,8 @@ int id = purple_imgstore_add_with_id(data, size, NULL); message_with_img = - g_strdup_printf("<img id='%d'> %s", id, escaped); + g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'> %s", + id, escaped); purple_conversation_write(conv, NULL, message_with_img, flags, time(NULL)); purple_imgstore_unref_by_id(id);
--- a/libpurple/imgstore.h Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/imgstore.h Fri Jun 15 00:59:46 2012 -0400 @@ -29,6 +29,8 @@ #include <glib.h> +#define PURPLE_STORED_IMAGE_PROTOCOL "purple-image:" + /** A reference-counted immutable wrapper around an image's data and its * filename. */
--- a/libpurple/protocols/jabber/buddy.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/jabber/buddy.c Fri Jun 15 00:59:46 2012 -0400 @@ -1204,7 +1204,8 @@ char *hash; jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png"))); - img_text = g_strdup_printf("<img id='%d'>", GPOINTER_TO_INT(jbi->vcard_imgids->data)); + img_text = g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'>", + GPOINTER_TO_INT(jbi->vcard_imgids->data)); purple_notify_user_info_add_pair_html(user_info, (photo ? _("Photo") : _("Logo")), img_text);
--- a/libpurple/protocols/msn/switchboard.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/msn/switchboard.c Fri Jun 15 00:59:46 2012 -0400 @@ -828,7 +828,8 @@ } imgid = purple_imgstore_add_with_id(image_data, image_len, NULL); - image_msg = g_strdup_printf("<IMG ID='%d'>", imgid); + image_msg = g_strdup_printf("<IMG SRC='" PURPLE_STORED_IMAGE_PROTOCOL "%d'>", + imgid); if (swboard->current_users > 1 || ((swboard->conv != NULL) &&
--- a/libpurple/protocols/mxit/formcmds.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/mxit/formcmds.c Fri Jun 15 00:59:46 2012 -0400 @@ -327,7 +327,6 @@ const char* img; const char* reply; guchar* rawimg; - char link[256]; gsize rawimglen; int imgid; @@ -336,8 +335,9 @@ rawimg = purple_base64_decode(img, &rawimglen); //purple_util_write_data_to_file_absolute("/tmp/mxitinline.png", (char*) rawimg, rawimglen); imgid = purple_imgstore_add_with_id(rawimg, rawimglen, NULL); - g_snprintf(link, sizeof(link), "<img id=\"%i\">", imgid); - g_string_append_printf(msg, "%s", link); + g_string_append_printf(msg, + "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\">", + imgid); mx->flags |= PURPLE_MESSAGE_IMAGES; } else {
--- a/libpurple/protocols/mxit/markup.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/mxit/markup.c Fri Jun 15 00:59:46 2012 -0400 @@ -403,7 +403,9 @@ } else { /* insert img tag */ - g_snprintf( tag, sizeof( tag ), "<img id=\"%i\">", *img_id ); + g_snprintf( tag, sizeof( tag ), + "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\">", + *img_id ); g_string_insert( mx->msg, start, tag ); } } @@ -1066,7 +1068,7 @@ * Font colour: <font color=#">...</font> * Links: <a href="">...</a> * Newline: <br> - * Inline image: <IMG ID=""> + * Inline image: <IMG SRC=""> * The following characters are also encoded: * & " < > */ @@ -1133,11 +1135,11 @@ g_free( tag ); } } - else if ( purple_str_has_prefix( &message[i], "<IMG ID=" ) ) { + else if ( purple_str_has_prefix( &message[i], "<IMG SRC=" PURPLE_STORED_IMAGE_PROTOCOL) ) { /* inline image */ int imgid; - if ( sscanf( &message[i+9], "%i", &imgid ) ) { + if ( sscanf( &message[i+sizeof("<IMG SRC=" PURPLE_STORED_IMAGE_PROTOCOL)-1], "%i", &imgid ) ) { inline_image_add( mx, imgid ); *msgtype = CP_MSGTYPE_COMMAND; /* inline image must be sent as a MXit command */ }
--- a/libpurple/protocols/mxit/profile.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/mxit/profile.c Fri Jun 15 00:59:46 2012 -0400 @@ -233,7 +233,8 @@ if ( contact->imgid ) { /* this invite has a avatar */ char* img_text; - img_text = g_strdup_printf( "<img id='%d'>", contact->imgid ); + img_text = g_strdup_printf( "<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'>", + contact->imgid ); purple_notify_user_info_add_pair_html( info, _( "Photo" ), img_text ); g_free(img_text); }
--- a/libpurple/protocols/mxit/splashscreen.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/mxit/splashscreen.c Fri Jun 15 00:59:46 2012 -0400 @@ -187,7 +187,8 @@ imgid = purple_imgstore_add_with_id(g_memdup(imgdata, imglen), imglen, NULL); /* Generate and display message */ - g_snprintf(buf, sizeof(buf), "<img id=\"%d\">", imgid); + g_snprintf(buf, sizeof(buf), + "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", imgid); /* Open a request-type popup to display the image */ {
--- a/libpurple/protocols/oscar/odc.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/oscar/odc.c Fri Jun 15 00:59:46 2012 -0400 @@ -376,7 +376,9 @@ if (imgid != 0) { /* Write the new image tag */ - g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); + g_string_append_printf(newmsg, + "<IMG SRC=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", + imgid); } /* Continue from the end of the tag */
--- a/libpurple/protocols/oscar/oscar.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/oscar/oscar.c Fri Jun 15 00:59:46 2012 -0400 @@ -3186,10 +3186,12 @@ g_string_append_len(msg, last, start - last); } - id = g_datalist_get_data(&attribs, "id"); + id = g_datalist_get_data(&attribs, "src"); /* ... if it refers to a valid purple image ... */ - if (id && (image = purple_imgstore_find_by_id(atoi(id)))) { + if (id + && strlen(id) > (sizeof(PURPLE_STORED_IMAGE_PROTOCOL) - 1) + && (image = purple_imgstore_find_by_id(atoi(id + sizeof(PURPLE_STORED_IMAGE_PROTOCOL) - 1)))) { /* ... append the message from start to the tag ... */ unsigned long size = purple_imgstore_get_size(image); const char *filename = purple_imgstore_get_filename(image);
--- a/libpurple/protocols/sametime/sametime.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/sametime/sametime.c Fri Jun 15 00:59:46 2012 -0400 @@ -2833,7 +2833,7 @@ if(align) g_string_append_printf(atstr, " align=\"%s\"", align); if(border) g_string_append_printf(atstr, " border=\"%s\"", border); - mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); + mov = g_snprintf(start, len, "<img%s src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\"", atstr->str, img); while(mov < len) start[mov++] = ' '; g_string_free(atstr, TRUE);
--- a/libpurple/protocols/silc/ops.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/silc/ops.c Fri Jun 15 00:59:46 2012 -0400 @@ -210,7 +210,9 @@ imgid = purple_imgstore_add_with_id(g_memdup(data, data_len), data_len, ""); if (imgid) { cflags |= PURPLE_MESSAGE_IMAGES | PURPLE_MESSAGE_RECV; - g_snprintf(tmp, sizeof(tmp), "<IMG ID=\"%d\">", imgid); + g_snprintf(tmp, sizeof(tmp), + "<IMG SRC=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", + imgid); if (channel) serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)),
--- a/libpurple/protocols/yahoo/yahoo_profile.c Fri Jun 15 00:23:44 2012 -0400 +++ b/libpurple/protocols/yahoo/yahoo_profile.c Fri Jun 15 00:59:46 2012 -0400 @@ -1047,7 +1047,8 @@ " bytes\n", photo_url_text, len); id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL); - tmp = g_strdup_printf("<img id=\"%d\"><br>", id); + tmp = g_strdup_printf("<img id=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\"><br>", + id); purple_notify_user_info_add_pair_html(user_info, NULL, tmp); g_free(tmp); }