src/gtkconv.c

changeset 7564
baab99d239d8
parent 7561
fd6a81f1594e
child 7583
c4db7febf636
equal deleted inserted replaced
7563:b921749e2976 7564:baab99d239d8
2894 2894
2895 g_free(entered); 2895 g_free(entered);
2896 g_free(partial); 2896 g_free(partial);
2897 } 2897 }
2898 2898
2899 static gboolean
2900 meify(char *message, size_t len)
2901 {
2902 /*
2903 * Read /me-ify: If the message (post-HTML) starts with /me,
2904 * remove the "/me " part of it (including that space) and return TRUE.
2905 */
2906 char *c;
2907 gboolean inside_html = 0;
2908
2909 /* Umm.. this would be very bad if this happens. */
2910 g_return_val_if_fail(message != NULL, FALSE);
2911
2912 if (len == -1)
2913 len = strlen(message);
2914
2915 for (c = message; *c != '\0'; c++, len--) {
2916 if (inside_html) {
2917 if (*c == '>')
2918 inside_html = FALSE;
2919 }
2920 else {
2921 if (*c == '<')
2922 inside_html = TRUE;
2923 else
2924 break;
2925 }
2926 }
2927
2928 if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) {
2929 memmove(c, c + 4, len - 3);
2930
2931 return TRUE;
2932 }
2933
2934 return FALSE;
2935 }
2936
2937 static void 2899 static void
2938 save_convo(GtkWidget *save, GaimConversation *c) 2900 save_convo(GtkWidget *save, GaimConversation *c)
2939 { 2901 {
2940 char buf[BUF_LONG]; 2902 char buf[BUF_LONG];
2941 GtkWidget *window; 2903 GtkWidget *window;
4608 4570
4609 if (flags & GAIM_MESSAGE_WHISPER) { 4571 if (flags & GAIM_MESSAGE_WHISPER) {
4610 str = g_malloc(1024); 4572 str = g_malloc(1024);
4611 4573
4612 /* If we're whispering, it's not an autoresponse. */ 4574 /* If we're whispering, it's not an autoresponse. */
4613 if (meify(new_message, length)) { 4575 if (gaim_message_meify(new_message, length)) {
4614 g_snprintf(str, 1024, "***%s", who); 4576 g_snprintf(str, 1024, "***%s", who);
4615 strcpy(color, "#6C2585"); 4577 strcpy(color, "#6C2585");
4616 } 4578 }
4617 else { 4579 else {
4618 g_snprintf(str, 1024, "*%s*:", who); 4580 g_snprintf(str, 1024, "*%s*:", who);
4619 strcpy(color, "#00FF00"); 4581 strcpy(color, "#00FF00");
4620 } 4582 }
4621 } 4583 }
4622 else { 4584 else {
4623 if (meify(new_message, length)) { 4585 if (gaim_message_meify(new_message, length)) {
4624 str = g_malloc(1024); 4586 str = g_malloc(1024);
4625 4587
4626 if (flags & GAIM_MESSAGE_AUTO_RESP) 4588 if (flags & GAIM_MESSAGE_AUTO_RESP)
4627 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who); 4589 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who);
4628 else 4590 else

mercurial