changeset 30801:3ada0cc7d2c5

"Invisibility mode" improvements. 1. Removed the code for setting the status message to the status name (like "Available" or "Invisible") when no message is set by user. This should fix #10633, since now no one will see our status change to "Invisible" if we go invisible with no message set. 2. Got rid of sending superfluous packets on server. * There's no need to call oscar_set_extended_status() from oscar_set_status_icq(), because in all cases it has already been called before that. The only thing oscar_set_status_icq() does except setting the extended status is setting the permit/deny setting, so I renamed it accordingly. * No need to call oscar_set_icq_permdeny() in purple_ssi_parseerr() (it will be called in purple_ssi_parselist() anyway). * Combined setting the extended status and the status message (as per TODO). This should fix the problem when client like QIP see us as Invisible for some (quite long) time before we appear as Offline. Also, I removed the code for setting the "itmsurl" status attribute, as there was no way to set this iTunes Store URL from the UI.
author ivan.komarov@soc.pidgin.im
date Wed, 23 Jun 2010 22:22:52 +0000
parents 05c634403678
children 47392e1f491d
files libpurple/protocols/oscar/family_oservice.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h
diffstat 3 files changed, 26 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_oservice.c	Fri Jun 18 13:55:54 2010 +0000
+++ b/libpurple/protocols/oscar/family_oservice.c	Wed Jun 23 22:22:52 2010 +0000
@@ -883,7 +883,7 @@
 int
 aim_srv_setextrainfo(OscarData *od,
 		gboolean seticqstatus, guint32 icqstatus,
-		gboolean setstatusmsg, const char *statusmsg, const char *itmsurl)
+		gboolean setstatusmsg, const char *statusmsg)
 {
 	FlapConnection *conn;
 	ByteStream bs;
@@ -911,18 +911,15 @@
 
 	if (setstatusmsg)
 	{
-		size_t statusmsglen, itmsurllen;
+		size_t statusmsglen;
 		ByteStream tmpbs;
 
 		statusmsglen = (statusmsg != NULL) ? strlen(statusmsg) : 0;
-		itmsurllen = (itmsurl != NULL) ? strlen(itmsurl) : 0;
 
-		byte_stream_new(&tmpbs, statusmsglen + 8 + itmsurllen + 8);
+		byte_stream_new(&tmpbs, statusmsglen + 8);
 		byte_stream_put_bart_asset_str(&tmpbs, 0x0002, statusmsg);
-		byte_stream_put_bart_asset_str(&tmpbs, 0x0009, itmsurl);
 
-		aim_tlvlist_add_raw(&tlvlist, 0x001d,
-				byte_stream_curpos(&tmpbs), tmpbs.data);
+		aim_tlvlist_add_raw(&tlvlist, 0x001d, byte_stream_curpos(&tmpbs), tmpbs.data);
 		byte_stream_destroy(&tmpbs);
 	}
 
--- a/libpurple/protocols/oscar/oscar.c	Fri Jun 18 13:55:54 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Wed Jun 23 22:22:52 2010 +0000
@@ -133,7 +133,7 @@
 
 void oscar_set_info(PurpleConnection *gc, const char *info);
 static void oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, PurpleStatus *status);
-static void oscar_set_extendedstatus(PurpleConnection *gc);
+static void oscar_set_extended_status(PurpleConnection *gc);
 static gboolean purple_ssi_rerequestdata(gpointer data);
 
 void oscar_free_name_data(struct name_data *data) {
@@ -3238,7 +3238,7 @@
 	PurpleStatus *status;
 	gboolean is_available;
 	PurplePresence *presence;
-	const char *username, *message, *itmsurl;
+	const char *username, *message;
 	char *tmp;
 	va_list ap;
 	guint16 maxpermits, maxdenies;
@@ -3279,15 +3279,14 @@
 	else
 		message = NULL;
 	tmp = purple_markup_strip_html(message);
-	itmsurl = purple_status_get_attr_string(status, "itmsurl");
-	aim_srv_setextrainfo(od, FALSE, 0, is_available, tmp, itmsurl);
+	aim_srv_setextrainfo(od, FALSE, 0, is_available, tmp);
 	g_free(tmp);
 
 	presence = purple_status_get_presence(status);
 	aim_srv_setidle(od, !purple_presence_is_idle(presence) ? 0 : time(NULL) - purple_presence_get_idle_time(presence));
 
 	if (od->icq) {
-		oscar_set_extendedstatus(gc);
+		oscar_set_extended_status(gc);
 		aim_icq_setsecurity(od,
 			purple_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION),
 			purple_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE));
@@ -3854,8 +3853,8 @@
 	oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status);
 }
 
-static void
-oscar_set_extendedstatus(PurpleConnection *gc)
+static guint32
+oscar_get_extended_status(PurpleConnection *gc)
 {
 	OscarData *od;
 	PurpleAccount *account;
@@ -3899,7 +3898,13 @@
 	else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM))
 		data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY;
 
-	aim_srv_setextrainfo(od, TRUE, data, FALSE, NULL, NULL);
+	return data;
+}
+
+static void
+oscar_set_extended_status(PurpleConnection *gc)
+{
+	aim_srv_setextrainfo(purple_connection_get_protocol_data(gc), TRUE, oscar_get_extended_status(gc), FALSE, NULL);
 }
 
 static void
@@ -3920,7 +3925,6 @@
 	gsize awaylen = 0;
 
 	char *status_text = NULL;
-	const char *itmsurl = NULL;
 
 	status_type = purple_status_get_type(status);
 	primitive = purple_status_type_get_primitive(status_type);
@@ -4002,8 +4006,6 @@
 		const char *status_html;
 
 		status_html = purple_status_get_attr_string(status, "message");
-		if (od->icq && (status_html == NULL || status_html[0] == '\0'))
-			status_html = purple_status_type_get_name(status_type);
 		if (status_html != NULL)
 		{
 			status_text = purple_markup_strip_html(status_html);
@@ -4015,17 +4017,13 @@
 			}
 		}
 
-		itmsurl = purple_status_get_attr_string(status, "itmsurl");
-
-		/* TODO: Combine these two calls! */
-		aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, itmsurl);
-		oscar_set_extendedstatus(gc);
+		aim_srv_setextrainfo(od, TRUE, oscar_get_extended_status(gc), TRUE, status_text);
 		g_free(status_text);
 	}
 }
 
 static void
-oscar_set_status_icq(PurpleAccount *account)
+oscar_set_icq_permdeny(PurpleAccount *account)
 {
 	PurpleConnection *gc = purple_account_get_connection(account);
 	OscarData *od = purple_connection_get_protocol_data(gc);
@@ -4036,16 +4034,9 @@
 	 * online. Mimicking the official client's behavior, we use PURPLE_PRIVACY_ALLOW_USERS
 	 * when our status is "invisible" and PURPLE_PRIVACY_DENY_USERS otherwise.
 	 * In the former case, we are visible only to buddies on our "permanently visible" list.
-	 * In the latter, we are invisible only to buddies on our "permanentnly invisible" list.
+	 * In the latter, we are invisible only to buddies on our "permanently invisible" list.
 	 */
 	aim_ssi_setpermdeny(od, invisible ? PURPLE_PRIVACY_ALLOW_USERS : PURPLE_PRIVACY_DENY_USERS);
-
-	/*
-	 * TODO: I guess we should probably wait and do this after we get
-	 * confirmation from the above SSI call?  Right now other people
-	 * see our status blip to "invisible" before we appear offline.
-	 */
-	oscar_set_extendedstatus(gc);
 }
 
 void
@@ -4071,12 +4062,11 @@
 		return;
 	}
 
+	if (od->icq)
+		oscar_set_icq_permdeny(account);
+
 	/* Set the AIM-style away message for both AIM and ICQ accounts */
 	oscar_set_info_and_status(account, FALSE, NULL, TRUE, status);
-
-	/* Set the ICQ status for ICQ accounts only */
-	if (od->icq)
-		oscar_set_status_icq(account);
 }
 
 #ifdef CRAZY_WARN
@@ -4244,8 +4234,6 @@
 		return 1;
 	}
 
-	oscar_set_status_icq(purple_connection_get_account(gc));
-
 	return 1;
 }
 
@@ -4546,7 +4534,7 @@
 		} /* End of switch on curitem->type */
 	} /* End of for loop */
 
-	oscar_set_status_icq(account);
+	oscar_set_icq_permdeny(account);
 
 	/* Activate SSI */
 	/* Sending the enable causes other people to be able to see you, and you to see them */
@@ -5671,7 +5659,7 @@
 	purple_account_set_bool(account, "authorization", auth);
 	purple_account_set_bool(account, "web_aware", web_aware);
 
-	oscar_set_extendedstatus(gc);
+	oscar_set_extended_status(gc);
 	aim_icq_setsecurity(od, auth, web_aware);
 }
 
--- a/libpurple/protocols/oscar/oscar.h	Fri Jun 18 13:55:54 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Wed Jun 23 22:22:52 2010 +0000
@@ -723,7 +723,7 @@
 /* 0x0014 */ void aim_srv_setprivacyflags(OscarData *od, FlapConnection *conn, guint32);
 /* 0x0016 */ void aim_srv_nop(OscarData *od, FlapConnection *conn);
 /* 0x0017 */ void aim_srv_setversions(OscarData *od, FlapConnection *conn);
-/* 0x001e */ int aim_srv_setextrainfo(OscarData *od, gboolean seticqstatus, guint32 icqstatus, gboolean setstatusmsg, const char *statusmsg, const char *itmsurl);
+/* 0x001e */ int aim_srv_setextrainfo(OscarData *od, gboolean seticqstatus, guint32 icqstatus, gboolean setstatusmsg, const char *statusmsg);
 
 
 void aim_bos_reqrights(OscarData *od, FlapConnection *conn);