changeset 29781:232fcf1755d6

The default state on the MXit server when connecting is Available (with no status message), but Pidgin might be configured to remember the last presence state. So after login, if the presence is not Available or if a Status message has been set then we need to send a Status update packet to the MXit servers. Pidgin also use a HTML-style encoding for the status message. In the situation above they also need to be de-HTML'ified first.
author andrew.victor@mxit.com
date Tue, 26 Jan 2010 14:16:18 +0000
parents 72b059116c82
children 81ea740f92a4
files libpurple/protocols/mxit/protocol.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/protocol.c	Mon Jan 18 20:41:11 2010 +0000
+++ b/libpurple/protocols/mxit/protocol.c	Tue Jan 26 14:16:18 2010 +0000
@@ -1254,6 +1254,7 @@
 {
 	PurpleStatus*	status;
 	int				presence;
+	const char*		statusmsg;
 	const char*		profilelist[] = { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_HIDENUMBER, CP_PROFILE_FULLNAME,
 									CP_PROFILE_TITLE, CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_EMAIL,
 									CP_PROFILE_MOBILENR };
@@ -1272,13 +1273,21 @@
 	/* update presence status */
 	status = purple_account_get_active_status( session->acc );
 	presence = mxit_convert_presence( purple_status_get_id( status ) );
-	if ( presence != MXIT_PRESENCE_ONLINE ) {
+	statusmsg = purple_status_get_attr_string( status, "message" );
+
+	if ( ( presence != MXIT_PRESENCE_ONLINE ) || ( statusmsg ) ) {
 		/* when logging into MXit, your default presence is online. but with the UI, one can change
 		 * the presence to whatever. in the case where its changed to a different presence setting
 		 * we need to send an update to the server, otherwise the user's presence will be out of
 		 * sync between the UI and MXit.
 		 */
-		mxit_send_presence( session, presence, purple_status_get_attr_string( status, "message" ) );
+		char* statusmsg1 = purple_markup_strip_html( statusmsg );
+		char* statusmsg2 = g_strndup( statusmsg1, CP_MAX_STATUS_MSG );
+
+		mxit_send_presence( session, presence, statusmsg2 );
+
+		g_free( statusmsg1 );
+		g_free( statusmsg2 );
 	}
 
 	/* save extra info if this is a HTTP connection */