im.pidgin.pidgin: a66a55b8836e3241bcc5772e499aa7c85d7bef88

kstange at pidgin.im kstange at pidgin.im
Sat Dec 1 03:55:42 EST 2007


-----------------------------------------------------------------
Revision: a66a55b8836e3241bcc5772e499aa7c85d7bef88
Ancestor: c27700a33779f1f8f380b0ed0a62756be4b6f17c
Author: kstange at pidgin.im
Date: 2007-12-01T08:49:27
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/myspace/myspace.c

ChangeLog: 

This fixes some idle-related behavior with the MySpace prpl, most particularly
the loss of status messages and statuses whenever idle activates and deactivates.  It also ensures that idle trumps other statuses (besides invisible), since
it's an exclusive state on this protocol.

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	7c59b709b52ea365e6a86fb6a645ccf810d3d7b9
+++ libpurple/protocols/myspace/myspace.c	0e43a38fa285a4ff350cdd0df4d7f6cdb5bdd3e2
@@ -1047,15 +1047,18 @@ msim_set_status(PurpleAccount *account, 
 msim_set_status(PurpleAccount *account, PurpleStatus *status)
 {
 	PurpleStatusType *type;
+	PurplePresence *pres;
 	MsimSession *session;
 	guint status_code;
-	gchar *statstring;
+	const gchar *message;
+	gchar *stripped;
 
 	session = (MsimSession *)account->gc->proto_data;
 
 	g_return_if_fail(MSIM_SESSION_VALID(session));
 
 	type = purple_status_get_type(status);
+	pres = purple_status_get_presence(status);
 
 	switch (purple_status_type_get_primitive(type)) {
 		case PURPLE_STATUS_AVAILABLE:
@@ -1083,16 +1086,20 @@ msim_set_status(PurpleAccount *account, 
 			break;
 	}
 
-	statstring = (gchar *)purple_status_get_attr_string(status, "message");
+	message = (gchar *)purple_status_get_attr_string(status, "message");
 
-	if (!statstring) {
-		statstring = "";
-	}
+	/* Status strings are plain text. */
+	if (message != NULL)
+		stripped = purple_markup_strip_html(message);
+	else
+		stripped = g_strdup("");
 
-	/* Status strings are plain text. */
-	statstring = purple_markup_strip_html(statstring);
+	msim_set_status_code(session, status_code, stripped);
 
-	msim_set_status_code(session, status_code, statstring);
+	/* If we should be idle, set that status. Time is irrelevant here. */
+	if (purple_presence_is_idle(pres) && status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN)
+		msim_set_idle(account->gc, 1);
+
 }
 
 /** Go idle. */
@@ -1100,6 +1107,7 @@ msim_set_idle(PurpleConnection *gc, int 
 msim_set_idle(PurpleConnection *gc, int time)
 {
 	MsimSession *session;
+	PurpleStatus *status;
 
 	g_return_if_fail(gc != NULL);
 
@@ -1107,16 +1115,30 @@ msim_set_idle(PurpleConnection *gc, int 
 
 	g_return_if_fail(MSIM_SESSION_VALID(session));
 
+	status = purple_account_get_active_status(session->account);
+
 	if (time == 0) {
 		/* Going back from idle. In msim, idle is mutually exclusive 
 		 * from the other states (you can only be away or idle, but not
-		 * both, for example), so by going non-idle I go online.
+		 * both, for example), so by going non-idle I go back to what
+		 * libpurple says I should be.
 		 */
-		/* TODO: find out how to keep old status string? */
-		msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE, g_strdup(""));
+		msim_set_status(session->account, status);
 	} else {
+		const gchar *message;
+		gchar *stripped;
+
+		/* Set the idle message to the status message from the real
+		 * current status.
+		 */
+		message = purple_status_get_attr_string(status, "message");
+		if (message != NULL)
+			stripped = purple_markup_strip_html(message);
+		else
+			stripped = g_strdup("");
+
 		/* msim doesn't support idle time, so just go idle */
-		msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, g_strdup(""));
+		msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, stripped);
 	}
 }
 
@@ -1894,7 +1916,7 @@ msim_incoming_status(MsimSession *sessio
 		purple_debug_info("msim", "msim_status: found buddy %s\n", username);
 	}
 
-	if (status_headline) {
+	if (status_headline && strcmp(status_headline, "") != 0) {
 		/* The status headline is plaintext, but libpurple treats it as HTML,
 		 * so escape any HTML characters to their entity equivalents. */
 		status_headline_escaped = g_markup_escape_text(status_headline, strlen(status_headline));


More information about the Commits mailing list