propagate from branch 'im.pidgin.pidgin' (head c429e21a08b9c1e309a58544f8cf96637f58f0eb) mxit

Tue, 27 Jul 2010 05:49:56 +0000

author
Andrew Victor <andrew.victor@mxit.com>
date
Tue, 27 Jul 2010 05:49:56 +0000
branch
mxit
changeset 30568
4d09ad59b4d1
parent 30554
c429e21a08b9 (current diff)
parent 30524
bbabed2b8de9 (diff)
child 30569
1a384006a38e

propagate from branch 'im.pidgin.pidgin' (head c429e21a08b9c1e309a58544f8cf96637f58f0eb)
to branch 'im.pidgin.pidgin.mxit' (head bbabed2b8de98ba1ddf9436b0ff881108f5c70fb)

--- a/libpurple/protocols/mxit/markup.c	Mon Jul 26 04:21:47 2010 +0000
+++ b/libpurple/protocols/mxit/markup.c	Tue Jul 27 05:49:56 2010 +0000
@@ -662,7 +662,7 @@
  *  @param message			The message text
  *  @return					The length of the message to skip
  */
-static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len )
+static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len, int msgflags )
 {
 	int		i;
 
@@ -673,7 +673,6 @@
 		 * Search for it....
 		 */
 		gboolean	found	= FALSE;
-		gchar*		nickname;
 
 		for ( i = 1; i < len; i++ ) {
 			if ( ( message[i] == '\n' ) && ( message[i-1] == '>' ) ) {
@@ -685,12 +684,30 @@
 		}
 
 		if ( found ) {
+			gchar*		nickname;
+
 			/*
 			 * The message definitely had an embedded nickname - generate a marked-up
 			 * message to be displayed.
 			 */
 			nickname = g_markup_escape_text( &message[1], -1 );
 
+			/* Remove any MXit escaping from nickname ("\X" --> "X") */
+			if ( msgflags & CP_MSG_MARKUP ) {
+				int	nicklen = strlen( nickname );
+				int	j, k;
+
+				for ( j = 0, k = 0; j < nicklen; j++ ) {
+					if ( nickname[j] == '\\' )
+						j++;
+
+					nickname[k] = nickname[j];
+					k++;
+				}
+
+				nickname[k] = '\0';		/* terminate string */
+			}
+
 			/* add nickname within some BOLD markup to the new converted message */
 			g_string_append_printf( mx->msg, "<b>%s:</b> ", nickname );
 
@@ -747,7 +764,7 @@
 	if ( is_mxit_chatroom_contact( mx->session, mx->from ) ) {
 		/* chatroom message, so we need to extract and skip the sender's nickname
 		 * which is embedded inside the message */
-		i = mxit_extract_chatroom_nick( mx, message, len );
+		i = mxit_extract_chatroom_nick( mx, message, len, msgflags );
 	}
 
 	/* run through the message and check for custom emoticons and markup */

mercurial