| 122 |
122 |
| 123 /*------------------------------------------------------------------------ |
123 /*------------------------------------------------------------------------ |
| 124 * Adds a link to a message |
124 * Adds a link to a message |
| 125 * |
125 * |
| 126 * @param mx The Markup message object |
126 * @param mx The Markup message object |
| 127 * @param linkname This is the what will be returned when the link gets clicked |
127 * @param replydata This is the what will be returned when the link gets clicked |
| 128 * @param displayname This is the name for the link which will be displayed in the UI |
128 * @param isStructured Indicates that the reply is a structured reply |
| 129 */ |
129 * @param displaytext This is the text for the link which will be displayed in the UI |
| 130 void mxit_add_html_link( struct RXMsgData* mx, const char* linkname, const char* displayname ) |
130 */ |
| |
131 void mxit_add_html_link( struct RXMsgData* mx, const char* replydata, gboolean isStructured, const char* displaytext ) |
| 131 { |
132 { |
| 132 #ifdef MXIT_LINK_CLICK |
133 #ifdef MXIT_LINK_CLICK |
| 133 char retstr[256]; |
134 char retstr[256]; |
| 134 gchar* retstr64; |
135 gchar* retstr64; |
| 135 char link[256]; |
136 char link[256]; |
| 136 int len; |
137 int len; |
| 137 |
138 |
| 138 len = g_snprintf( retstr, sizeof( retstr ), "%s|%s|%s|%s|%s", MXIT_LINK_KEY, purple_account_get_username( mx->session->acc ), |
139 /* |
| 139 purple_account_get_protocol_id( mx->session->acc ), mx->from, linkname ); |
140 * The link content is encoded as follows: |
| |
141 * MXIT_LINK_KEY | ACCOUNT_USER | ACCOUNT_PROTO | REPLY_TO | REPLY_FORMAT | REPLY_DATA |
| |
142 */ |
| |
143 len = g_snprintf( retstr, sizeof( retstr ), "%s|%s|%s|%s|%i|%s", |
| |
144 MXIT_LINK_KEY, |
| |
145 purple_account_get_username( mx->session->acc ), |
| |
146 purple_account_get_protocol_id( mx->session->acc ), |
| |
147 mx->from, |
| |
148 isStructured ? 1 : 0, |
| |
149 replydata ); |
| 140 retstr64 = purple_base64_encode( (const unsigned char*) retstr, len ); |
150 retstr64 = purple_base64_encode( (const unsigned char*) retstr, len ); |
| 141 g_snprintf( link, sizeof( link ), "%s%s", MXIT_LINK_PREFIX, retstr64 ); |
151 g_snprintf( link, sizeof( link ), "%s%s", MXIT_LINK_PREFIX, retstr64 ); |
| 142 g_free( retstr64 ); |
152 g_free( retstr64 ); |
| 143 |
153 |
| 144 g_string_append_printf( mx->msg, "<a href=\"%s\">%s</a>", link, displayname ); |
154 g_string_append_printf( mx->msg, "<a href=\"%s\">%s</a>", link, displaytext ); |
| 145 #else |
155 #else |
| 146 g_string_append_printf( mx->msg, "<b>%s</b>", linkname ); |
156 g_string_append_printf( mx->msg, "<b>%s</b>", replydata ); |
| 147 #endif |
157 #endif |
| 148 } |
158 } |
| 149 |
159 |
| 150 |
160 |
| 151 /*------------------------------------------------------------------------ |
161 /*------------------------------------------------------------------------ |
| 822 /* find the end tag */ |
832 /* find the end tag */ |
| 823 ch = strstr( &message[i + 1], "$" ); |
833 ch = strstr( &message[i + 1], "$" ); |
| 824 if ( ch ) { |
834 if ( ch ) { |
| 825 /* end found */ |
835 /* end found */ |
| 826 *ch = '\0'; |
836 *ch = '\0'; |
| 827 mxit_add_html_link( mx, &message[i + 1], &message[i + 1] ); |
837 mxit_add_html_link( mx, &message[i + 1], FALSE, &message[i + 1] ); |
| 828 *ch = '$'; |
838 *ch = '$'; |
| 829 i += ( ch - &message[i + 1] ) + 1; |
839 i += ( ch - &message[i + 1] ) + 1; |
| 830 } |
840 } |
| 831 else { |
841 else { |
| 832 g_string_append_c( mx->msg, message[i] ); |
842 g_string_append_c( mx->msg, message[i] ); |