changeset 16623:dd6e1dde4cb5

merge of '2d00dcb7fc18b083ac949b5febda711ecfd52cdb' and '672f4498d064f8279f66bb1ca2922dded2435411'
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 29 Apr 2007 01:17:40 +0000
parents bb5c527cf143 (current diff) 8d8168fada21 (diff)
children bb039b61f16e 56cc78d3d04f
files libpurple/buddyicon.c
diffstat 4 files changed, 39 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/buddyicon.c	Sun Apr 29 01:12:58 2007 +0000
+++ b/libpurple/buddyicon.c	Sun Apr 29 01:17:40 2007 +0000
@@ -694,11 +694,13 @@
 	{
 		const char *filename = purple_imgstore_get_filename(img);
 		purple_account_set_string(account, "buddy_icon", filename);
+		purple_account_set_int(account, "buddy_icon_timestamp", time(NULL));
 		ref_filename(filename);
 	}
 	else
 	{
 		purple_account_set_string(account, "buddy_icon", NULL);
+		purple_account_set_int(account, "buddy_icon_timestamp", 0);
 	}
 	unref_filename(old_icon);
 
@@ -733,6 +735,25 @@
 	return img;
 }
 
+time_t
+purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account)
+{
+	time_t ret;
+
+	g_return_val_if_fail(account != NULL, 0);
+
+	ret = purple_account_get_int(account, "buddy_icon_timestamp", 0);
+
+	/* This deals with migration cases. */
+	if (ret == 0 && purple_account_get_string(account, "buddy_icon", NULL) != NULL)
+	{
+		ret = time(NULL);
+		purple_account_set_int(account, "buddy_icon_timestamp", ret);
+	}
+
+	return ret;
+}
+
 PurpleStoredImage *
 purple_buddy_icons_find_custom_icon(PurpleContact *contact)
 {
@@ -888,7 +909,7 @@
 		char *new_filename;
 
 		if (!read_icon_file(path, &icon_data, &icon_len) ||
-		    icon_data == NULL || icon_len > 0)
+		    icon_data == NULL || icon_len <= 0)
 		{
 			delete_buddy_icon_settings(node, setting_name);
 			g_free(path);
--- a/libpurple/buddyicon.h	Sun Apr 29 01:12:58 2007 +0000
+++ b/libpurple/buddyicon.h	Sun Apr 29 01:17:40 2007 +0000
@@ -261,6 +261,19 @@
                                     guchar *icon_data, size_t icon_len);
 
 /**
+ * Returns the timestamp of when the icon was set.
+ *
+ * This is intended for use in protocols that require a timestamp for
+ * buddy icon update reasons.
+ *
+ * @param account The account
+ *
+ * @return The time the icon was set, or 0 if an error occurred.
+ */
+time_t
+purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account);
+
+/**
  * Returns the custom buddy icon image for a contact.
  *
  * The caller owns a reference to the image in the store, and must dereference
--- a/libpurple/protocols/oscar/oscar.c	Sun Apr 29 01:12:58 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Apr 29 01:17:40 2007 +0000
@@ -1941,9 +1941,9 @@
 		purple_debug_info("oscar",
 				   "Sending buddy icon to %s (%d bytes)\n",
 				   userinfo->sn, len);
-		/* TODO: XXX: FIXME: Does this actually need the mtime of the file? */
 		aim_im_sendch2_icon(od, userinfo->sn, data, len,
-			time(NULL), aimutil_iconsum(data, len));
+			purple_buddy_icons_get_account_icon_timestamp(account),
+			aimutil_iconsum(data, len));
 	}
 	purple_imgstore_unref(img);
 
@@ -4232,8 +4232,7 @@
 			gconstpointer data = purple_imgstore_get_data(img);
 			args.iconlen   = purple_imgstore_get_size(img);
 			args.iconsum   = aimutil_iconsum(data, args.iconlen);
-			/* TODO: XXX: FIXME: Deal with the timestamp issue. */
-			args.iconstamp = time(NULL);
+			args.iconstamp = purple_buddy_icons_get_account_icon_timestamp(account);
 
 			if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) {
 				bi->ico_informed = FALSE;
--- a/libpurple/protocols/silc/buddy.c	Sun Apr 29 01:12:58 2007 +0000
+++ b/libpurple/protocols/silc/buddy.c	Sun Apr 29 01:17:40 2007 +0000
@@ -1706,7 +1706,7 @@
 	if (!mime)
 		return;
 
-	t = purple_util_get_image_extension(purple_imgstore_get_data(img), purple_imgstore_get_size(img));
+	t = purple_imgstore_get_extension(img);
 	if (!t || !strcmp(t, "icon")) {
 		silc_mime_free(mime);
 		return;