changeset 31534:3e11fa72c5d8

merge of '8a2ad25fe0712bc0d47a1229671868560599a2cd' and '9da15614ca2aaddf25bfffea7e99eca752dd86b3'
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 03 May 2011 12:49:56 +0000
parents 5e574e30256b (diff) 1b7c8904c066 (current diff)
children 2f8448c4f43d 6ec53e134447 2ef7fb1f1154
files ChangeLog libpurple/proxy.c libpurple/proxy.h
diffstat 15 files changed, 53 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Tue May 03 05:08:02 2011 +0000
+++ b/COPYRIGHT	Tue May 03 12:49:56 2011 +0000
@@ -48,6 +48,7 @@
 Stefan Becker
 Carlos Bederian
 Dave Bell
+Matthew W.S. Bell
 Igor Belyi
 David Benjamin
 Brian Bernas
--- a/ChangeLog	Tue May 03 05:08:02 2011 +0000
+++ b/ChangeLog	Tue May 03 12:49:56 2011 +0000
@@ -89,6 +89,8 @@
 	XMPP:
 	* Remember the previously entered user directory when searching.
 	  (Keith Moyer) (#12451)
+	* Correctly handle a buddy's unsetting his/her vCard-based avatar.
+	  (Matthew W.S. Bell) (#13370)
 
 	Plugins:
 	* The Voice/Video Settings plugin now includes the ability to test
--- a/finch/gntnotify.c	Tue May 03 05:08:02 2011 +0000
+++ b/finch/gntnotify.c	Tue May 03 12:49:56 2011 +0000
@@ -84,6 +84,10 @@
 
 	if (secondary) {
 		GntWidget *msg;
+		/* XXX: This is broken.  type is PurpleNotifyMsgType, not
+		 * PurpleNotifyType.  Also, the if() followed by the
+		 * inner switch doesn't make much sense.
+		 */
 		if (type == PURPLE_NOTIFY_FORMATTED) {
 			int width = -1, height = -1;
 			char *plain = (char*)secondary;
--- a/libpurple/dnsquery.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/dnsquery.c	Tue May 03 12:49:56 2011 +0000
@@ -24,6 +24,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  *
  */
+#define _PURPLE_DNSQUERY_C_
 
 #include "internal.h"
 #include "debug.h"
--- a/libpurple/dnsquery.h	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/dnsquery.h	Tue May 03 12:49:56 2011 +0000
@@ -102,7 +102,7 @@
  */
 PurpleDnsQueryData *purple_dnsquery_a_account(PurpleAccount *account, const char *hostname, int port, PurpleDnsQueryConnectFunction callback, gpointer data);
 
-#ifndef PURPLE_DISABLE_DEPRECATED
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSQUERY_C_)
 /**
  * Perform an asynchronous DNS query.
  *
--- a/libpurple/dnssrv.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/dnssrv.c	Tue May 03 12:49:56 2011 +0000
@@ -20,6 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
+#define _PURPLE_DNSSRV_C_
 
 #include "internal.h"
 #include "util.h"
--- a/libpurple/dnssrv.h	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/dnssrv.h	Tue May 03 12:49:56 2011 +0000
@@ -114,7 +114,7 @@
  */
 PurpleSrvTxtQueryData *purple_srv_resolve_account(PurpleAccount *account, const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata);
 
-#ifndef PURPLE_DISABLE_DEPRECATED
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSSRV_C_)
 /**
  * Queries an SRV record.
  *
@@ -149,7 +149,7 @@
  */
 PurpleSrvTxtQueryData *purple_txt_resolve_account(PurpleAccount *account, const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata);
 
-#ifndef PURPLE_DISABLE_DEPRECATED
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSSRV_C_)
 /**
  * Queries an TXT record.
  *
--- a/libpurple/protocols/gg/gg.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/gg/gg.c	Tue May 03 12:49:56 2011 +0000
@@ -818,7 +818,6 @@
 
 static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields)
 {
-	GGPInfo *info;
 	PurpleConnection *conn;
 	PurpleRequestField *field;
 	GList *sel;
@@ -827,8 +826,6 @@
 
 	g_return_if_fail(conn != NULL);
 
-	info = conn->proto_data;
-
 	field = purple_request_fields_get_field(fields, "name");
 	sel = purple_request_field_list_get_selected(field);
 
@@ -2595,9 +2592,6 @@
 static void ggp_register_user(PurpleAccount *account)
 {
 	PurpleConnection *gc = purple_account_get_connection(account);
-	GGPInfo *info;
-
-	info = gc->proto_data = g_new0(GGPInfo, 1);
 
 	ggp_token_request(gc, ggp_register_user_dialog);
 }
--- a/libpurple/protocols/jabber/presence.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/jabber/presence.c	Tue May 03 12:49:56 2011 +0000
@@ -450,21 +450,23 @@
 			g_free(nickname);
 		}
 
-		if ((photo = xmlnode_get_child(vcard, "PHOTO")) &&
-				(binval = xmlnode_get_child(photo, "BINVAL")) &&
-				(text = xmlnode_get_data(binval))) {
-			guchar *data;
-			gsize size;
+		if ((photo = xmlnode_get_child(vcard, "PHOTO"))) {
+			guchar *data = NULL;
+			gchar *hash = NULL;
+			gsize size = 0;
 
-			data = purple_base64_decode(text, &size);
-			if (data) {
-				gchar *hash = jabber_calculate_data_hash(data, size, "sha1");
-				purple_buddy_icons_set_for_user(js->gc->account, from, data,
-				                                size, hash);
-				g_free(hash);
+			if ((binval = xmlnode_get_child(photo, "BINVAL")) &&
+					(text = xmlnode_get_data(binval))) {
+				data = purple_base64_decode(text, &size);
+				g_free(text);
+
+				if (data)
+					hash = jabber_calculate_data_hash(data, size, "sha1");
 			}
 
-			g_free(text);
+			purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash);
+
+			g_free(hash);
 		}
 	}
 }
@@ -840,20 +842,22 @@
 		}
 	}
 
-	if(b && presence->vcard_avatar_hash) {
-		const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b);
-		if(!avatar_hash2 || strcmp(presence->vcard_avatar_hash, avatar_hash2)) {
-			JabberIq *iq;
-			xmlnode *vcard;
-
+	if (b && presence->vcard_avatar_hash) {
+		const char *ah = presence->vcard_avatar_hash[0] != '\0' ?
+				presence->vcard_avatar_hash : NULL;
+		const char *ah2 = purple_buddy_icons_get_checksum_for_user(b);
+		if (!purple_strequal(ah, ah2)) {
 			/* XXX this is a crappy way of trying to prevent
 			 * someone from spamming us with presence packets
 			 * and causing us to DoS ourselves...what we really
 			 * need is a queue system that can throttle itself,
 			 * but i'm too tired to write that right now */
 			if(!g_slist_find(js->pending_avatar_requests, presence->jb)) {
+				JabberIq *iq;
+				xmlnode *vcard;
 
-				js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, presence->jb);
+				js->pending_avatar_requests =
+					g_slist_prepend(js->pending_avatar_requests, presence->jb);
 
 				iq = jabber_iq_new(js, JABBER_IQ_GET);
 				xmlnode_set_attrib(iq->node, "to", buddy_name);
@@ -1206,9 +1210,13 @@
 parse_vcard_avatar(JabberStream *js, JabberPresence *presence, xmlnode *x)
 {
 	xmlnode *photo = xmlnode_get_child(x, "photo");
+
 	if (photo) {
+		char *hash_tmp = xmlnode_get_data(photo);
+		hash_tmp = xmlnode_get_data(photo);
 		g_free(presence->vcard_avatar_hash);
-		presence->vcard_avatar_hash = xmlnode_get_data(photo);
+		presence->vcard_avatar_hash =
+			hash_tmp ? hash_tmp : g_strdup("");
 	}
 }
 
--- a/libpurple/protocols/jabber/si.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/jabber/si.c	Tue May 03 12:49:56 2011 +0000
@@ -1691,7 +1691,10 @@
 {
 	JabberSIXfer *jsx;
 	PurpleXfer *xfer;
-	xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail;
+	xmlnode *file, *feature, *x, *field, *option, *value;
+#if ENABLE_FT_THUMBNAILS
+	xmlnode *thumbnail;
+#endif
 	const char *stream_id, *filename, *filesize_c, *profile;
 	guint64 filesize_64 = 0;
 	size_t filesize = 0;
@@ -1795,16 +1798,12 @@
 		if (cid) {
 			jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer),
 			    NULL, TRUE, jabber_si_thumbnail_cb, xfer);
-		} else {
-			purple_xfer_request(xfer);
+			return;
 		}
-	} else {
-		purple_xfer_request(xfer);
 	}
-#else
-	thumbnail = NULL; /* Silence warning */
+#endif
+
 	purple_xfer_request(xfer);
-#endif
 }
 
 void
--- a/libpurple/protocols/msn/switchboard.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Tue May 03 12:49:56 2011 +0000
@@ -643,10 +643,8 @@
 static void
 iro_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
-	PurpleAccount *account;
 	MsnSwitchBoard *swboard;
 
-	account = cmdproc->session->account;
 	swboard = cmdproc->data;
 
 	swboard->total_users = atoi(cmd->params[2]);
@@ -658,14 +656,12 @@
 joi_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
 	MsnSession *session;
-	PurpleAccount *account;
 	MsnSwitchBoard *swboard;
 	const char *passport;
 
 	passport = cmd->params[0];
 
 	session = cmdproc->session;
-	account = session->account;
 	swboard = cmdproc->data;
 
 	msn_switchboard_add_user(swboard, passport);
--- a/libpurple/protocols/myspace/myspace.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue May 03 12:49:56 2011 +0000
@@ -377,19 +377,13 @@
 static char *
 msim_status_text(PurpleBuddy *buddy)
 {
-	MsimSession *session;
 	MsimUser *user;
-	const gchar *display_name, *headline;
+	const gchar *display_name = NULL, *headline = NULL;
 	PurpleAccount *account;
-	PurpleConnection *gc;
 
 	g_return_val_if_fail(buddy != NULL, NULL);
 
 	account = purple_buddy_get_account(buddy);
-	gc = purple_account_get_connection(account);
-	session = (MsimSession *)gc->proto_data;
-
-	display_name = headline = NULL;
 
 	user = msim_get_user_from_buddy(buddy, FALSE);
 	if (user != NULL) {
@@ -859,7 +853,6 @@
 msim_check_inbox_cb(MsimSession *session, const MsimMessage *reply, gpointer data)
 {
 	MsimMessage *body;
-	guint old_inbox_status;
 	guint i, n;
 	/* Information for each new inbox message type. */
 	static struct
@@ -896,8 +889,6 @@
 	if (body == NULL)
 		return;
 
-	old_inbox_status = session->inbox_status;
-
 	n = 0;
 
 	for (i = 0; i < G_N_ELEMENTS(message_types); ++i) {
@@ -1357,7 +1348,6 @@
 static gboolean
 msim_incoming_status(MsimSession *session, MsimMessage *msg)
 {
-	PurpleBuddyList *blist;
 	MsimUser *user;
 	GList *list;
 	gchar *status_headline, *status_headline_escaped;
@@ -1391,8 +1381,6 @@
 	purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code);
 	status_headline = msim_msg_get_string_from_element(g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE));
 
-	blist = purple_get_blist();
-
 	/* Add buddy if not found.
 	 * TODO: Could this be responsible for #3444? */
 	user = msim_find_user(session, username);
@@ -2026,7 +2014,6 @@
 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond)
 {
 	PurpleConnection *gc;
-	PurpleAccount *account;
 	MsimSession *session;
 	gchar *end;
 	int n;
@@ -2035,7 +2022,6 @@
 	g_return_if_fail(source >= 0);  /* Note: 0 is a valid fd */
 
 	gc = (PurpleConnection *)(gc_uncasted);
-	account = purple_connection_get_account(gc);
 	session = gc->proto_data;
 
 	/* libpurple/eventloop.h only defines these two */
@@ -3187,14 +3173,11 @@
  * Actions menu for account.
  */
 static GList *
-msim_actions(PurplePlugin *plugin, gpointer context)
+msim_actions(PurplePlugin *plugin, gpointer context /* PurpleConnection* */)
 {
-	PurpleConnection *gc;
 	GList *menu;
 	PurplePluginAction *act;
 
-	gc = (PurpleConnection *)context;
-
 	menu = NULL;
 
 #if 0
--- a/libpurple/protocols/myspace/user.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/protocols/myspace/user.c	Tue May 03 12:49:56 2011 +0000
@@ -565,7 +565,7 @@
 {
 	MsimMessage *body;
 	gchar *field_name;
-	guint rid, cmd, dsn, lid;
+	guint rid, dsn, lid;
 
 	g_return_if_fail(user != NULL);
 	/* Callback can be null to not call anything, just lookup & store information. */
@@ -579,8 +579,6 @@
 
 	/* Send request */
 
-	cmd = MSIM_CMD_GET;
-
 	if (msim_is_userid(user)) {
 		field_name = "UserID";
 		dsn = MG_MYSPACE_INFO_BY_ID_DSN;
@@ -602,7 +600,7 @@
 	g_return_if_fail(msim_send(session,
 			"persist", MSIM_TYPE_INTEGER, 1,
 			"sesskey", MSIM_TYPE_INTEGER, session->sesskey,
-			"cmd", MSIM_TYPE_INTEGER, 1,
+			"cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET,
 			"dsn", MSIM_TYPE_INTEGER, dsn,
 			"uid", MSIM_TYPE_INTEGER, session->userid,
 			"lid", MSIM_TYPE_INTEGER, lid,
--- a/libpurple/proxy.c	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/proxy.c	Tue May 03 12:49:56 2011 +0000
@@ -29,6 +29,7 @@
 /* it is intended to : 1st handle http proxy, using the CONNECT command
  , 2nd provide an easy way to add socks support
  , 3rd draw women to it like flies to honey */
+#define _PURPLE_PROXY_C_
 
 #include "internal.h"
 #include "cipher.h"
--- a/libpurple/proxy.h	Tue May 03 05:08:02 2011 +0000
+++ b/libpurple/proxy.h	Tue May 03 12:49:56 2011 +0000
@@ -316,7 +316,7 @@
 			const char *host, int port,
 			PurpleProxyConnectFunction connect_cb, gpointer data);
 
-#ifndef PURPLE_DISABLE_DEPRECATED
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_PROXY_C_)
 /**
  * Makes a connection through a SOCKS5 proxy.
  *