comparison libpurple/protocols/mxit/markup.c @ 30837:8e9b04071e79

propagate from branch 'im.pidgin.pidgin' (head 9166d0ffe82472b17cee09aabbef61d8ec6e3e44) to branch 'im.pidgin.soc.2010.icq-tlc' (head 4c9bb4231e46e234d01e6dc64bf4be49fb12c27c)
author Mark Doliner <mark@kingant.net>
date Thu, 12 Aug 2010 15:30:11 +0000
parents fe072dddc42c
children a8cc50c2279f
comparison
equal deleted inserted replaced
30836:a4d7d154d00d 30837:8e9b04071e79
255 * is that when you have more than 100 '<' characters in the message passed to 255 * is that when you have more than 100 '<' characters in the message passed to
256 * pidgin, none of the markup (including links) are rendered and thus just dump 256 * pidgin, none of the markup (including links) are rendered and thus just dump
257 * all the text as is to the conversation window. this message dump is very 257 * all the text as is to the conversation window. this message dump is very
258 * confusing and makes it totally unusable. to work around this we will count 258 * confusing and makes it totally unusable. to work around this we will count
259 * the amount of tags and if its more than the pidgin threshold, we will just 259 * the amount of tags and if its more than the pidgin threshold, we will just
260 * break the message up into smaller parts and send them seperately to pidgin. 260 * break the message up into smaller parts and send them separately to pidgin.
261 * to the user it will look like multiple messages, but at least he will be able 261 * to the user it will look like multiple messages, but at least he will be able
262 * to use and understand it. 262 * to use and understand it.
263 */ 263 */
264 264
265 ch = mx->msg->str; 265 ch = mx->msg->str;
660 * 660 *
661 * @param mx The received message data object 661 * @param mx The received message data object
662 * @param message The message text 662 * @param message The message text
663 * @return The length of the message to skip 663 * @return The length of the message to skip
664 */ 664 */
665 static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len ) 665 static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len, int msgflags )
666 { 666 {
667 int i; 667 int i;
668 668
669 if ( message[0] == '<' ) { 669 if ( message[0] == '<' ) {
670 /* 670 /*
671 * The message MIGHT contains an embedded nickname. But we can't 671 * The message MIGHT contains an embedded nickname. But we can't
672 * be sure unless we find the end-of-nickname sequence: (>\n) 672 * be sure unless we find the end-of-nickname sequence: (>\n)
673 * Search for it.... 673 * Search for it....
674 */ 674 */
675 gboolean found = FALSE; 675 gboolean found = FALSE;
676 gchar* nickname;
677 676
678 for ( i = 1; i < len; i++ ) { 677 for ( i = 1; i < len; i++ ) {
679 if ( ( message[i] == '\n' ) && ( message[i-1] == '>' ) ) { 678 if ( ( message[i] == '\n' ) && ( message[i-1] == '>' ) ) {
680 found = TRUE; 679 found = TRUE;
681 message[i-1] = '\0'; /* loose the '>' */ 680 message[i-1] = '\0'; /* loose the '>' */
683 break; 682 break;
684 } 683 }
685 } 684 }
686 685
687 if ( found ) { 686 if ( found ) {
687 gchar* nickname;
688
688 /* 689 /*
689 * The message definitely had an embedded nickname - generate a marked-up 690 * The message definitely had an embedded nickname - generate a marked-up
690 * message to be displayed. 691 * message to be displayed.
691 */ 692 */
692 nickname = g_markup_escape_text( &message[1], -1 ); 693 nickname = g_markup_escape_text( &message[1], -1 );
694
695 /* Remove any MXit escaping from nickname ("\X" --> "X") */
696 if ( msgflags & CP_MSG_MARKUP ) {
697 int nicklen = strlen( nickname );
698 int j, k;
699
700 for ( j = 0, k = 0; j < nicklen; j++ ) {
701 if ( nickname[j] == '\\' )
702 j++;
703
704 nickname[k] = nickname[j];
705 k++;
706 }
707
708 nickname[k] = '\0'; /* terminate string */
709 }
693 710
694 /* add nickname within some BOLD markup to the new converted message */ 711 /* add nickname within some BOLD markup to the new converted message */
695 g_string_append_printf( mx->msg, "<b>%s:</b> ", nickname ); 712 g_string_append_printf( mx->msg, "<b>%s:</b> ", nickname );
696 713
697 /* free up the resources */ 714 /* free up the resources */
745 762
746 763
747 if ( is_mxit_chatroom_contact( mx->session, mx->from ) ) { 764 if ( is_mxit_chatroom_contact( mx->session, mx->from ) ) {
748 /* chatroom message, so we need to extract and skip the sender's nickname 765 /* chatroom message, so we need to extract and skip the sender's nickname
749 * which is embedded inside the message */ 766 * which is embedded inside the message */
750 i = mxit_extract_chatroom_nick( mx, message, len ); 767 i = mxit_extract_chatroom_nick( mx, message, len, msgflags );
751 } 768 }
752 769
753 /* run through the message and check for custom emoticons and markup */ 770 /* run through the message and check for custom emoticons and markup */
754 for ( ; i < len; i++ ) { 771 for ( ; i < len; i++ ) {
755 switch ( message[i] ) { 772 switch ( message[i] ) {