comparison src/conversation.c @ 502:4d1e39112cbd

[gaim-migrate @ 512] smile! you've got french's committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 18 Jul 2000 05:23:25 +0000
parents 6e8019420c1e
children 3133ab511d92
comparison
equal deleted inserted replaced
501:f72f5daa7a32 502:4d1e39112cbd
512 512
513 if (!c->is_chat) { 513 if (!c->is_chat) {
514 buf3 = g_strdup(buf); 514 buf3 = g_strdup(buf);
515 write_to_conv(c, buf3, WFLAG_SEND, NULL); 515 write_to_conv(c, buf3, WFLAG_SEND, NULL);
516 g_free(buf3); 516 g_free(buf3);
517 } 517 escape_text(buf);
518 518 if (escape_message(buf) > MSG_LEN - hdrlen)
519 escape_text(buf); 519 do_error_dialog(_("Message too long, some data truncated."), _("Error"));
520 if (escape_message(buf) > MSG_LEN - hdrlen) { 520
521 do_error_dialog(_("Message too long, some data truncated."), _("Error"));
522 }
523
524 if (c->is_chat) {
525 serv_chat_send(c->id, buf);
526
527 /* no sound because we do that when we receive our message */
528 } else {
529 serv_send_im(c->name, buf, 0); 521 serv_send_im(c->name, buf, 0);
530 522
531 if (c->makesound && (sound_options & OPT_SOUND_SEND)) 523 if (c->makesound && (sound_options & OPT_SOUND_SEND))
532 play_sound(SEND); 524 play_sound(SEND);
525 } else {
526 serv_chat_send(c->id, buf); /* this does escape_text for us */
527
528 /* no sound because we do that when we receive our message */
533 } 529 }
534 530
535 quiet_set(c->bold, FALSE); 531 quiet_set(c->bold, FALSE);
536 quiet_set(c->strike, FALSE); 532 quiet_set(c->strike, FALSE);
537 quiet_set(c->italic, FALSE); 533 quiet_set(c->italic, FALSE);
864 /*------------------------------------------------------------------------*/ 860 /*------------------------------------------------------------------------*/
865 /* Takin care of the window.. */ 861 /* Takin care of the window.. */
866 /*------------------------------------------------------------------------*/ 862 /*------------------------------------------------------------------------*/
867 863
868 864
865 GdkPixmap *is_smiley(struct conversation *c, char *m, int *len) {
866 GdkBitmap *mask;
867 GdkPixmap *face = NULL;
868
869 if (strlen(m) < 2) return face;
870 *len = 2;
871 if ( !strncmp(m, ":)", 2) ||
872 !strncmp(m, "=)", 2)) {
873 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_xpm);
874 } else if (!strncmp(m, ":(", 2) ||
875 !strncmp(m, "=(", 2)) {
876 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, sad_xpm);
877 } else if (!strncmp(m, ";)", 2)) {
878 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, wink_xpm);
879 }
880
881 if (face || strlen(m) < 3) return face;
882 *len = 3;
883 if ( !strncmp(m, ":-)", 3)) {
884 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_xpm);
885 } else if (!strncmp(m, ":-(", 3)) {
886 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, sad_xpm);
887 } else if (!strncmp(m, ";-)", 3)) {
888 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, wink_xpm);
889 } else if (!strncmp(m, ":-p", 3) ||
890 !strncmp(m, ":-P", 3)) {
891 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, tongue_xpm);
892 } else if (!strncmp(m, "=-O", 3)) {
893 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, scream_xpm);
894 } else if (!strncmp(m, ":-*", 3)) {
895 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, kiss_xpm);
896 } else if (!strncmp(m, ">:o", 3)) {
897 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, yell_xpm);
898 } else if (!strncmp(m, "8-)", 3)) {
899 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile8_xpm);
900 } else if (!strncmp(m, ":-$", 3)) {
901 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, moneymouth_xpm);
902 } else if (!strncmp(m, ":-!", 3)) {
903 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, burp_xpm);
904 } else if (!strncmp(m, ":-[", 3)) {
905 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, embarrassed_xpm);
906 } else if (!strncmp(m, ":'(", 3)) {
907 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, cry_xpm);
908 } else if (!strncmp(m, ":-\\", 3) ||
909 !strncmp(m, ":-/", 3)) {
910 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, think_xpm);
911 } else if (!strncmp(m, ":-X", 3)) {
912 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, crossedlips_xpm);
913 } else if (!strncmp(m, ":-D", 3)) {
914 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, bigsmile_xpm);
915 }
916
917 if (face || strlen(m) < 4) return face;
918 *len = 4;
919 if ( !strncmp(m, "O:-)", 4)) {
920 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, angel_xpm);
921 }
922
923 if (face || strlen(m) < 6) return face;
924 *len = 6;
925 if ( !strncmp(m, "&gt;:o", 6)) {
926 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, yell_xpm);
927 }
928
929 return face;
930 }
931
869 /* this is going to be interesting since the conversation could either be a 932 /* this is going to be interesting since the conversation could either be a
870 * normal IM conversation or a chat window. but hopefully it won't matter */ 933 * normal IM conversation or a chat window. but hopefully it won't matter */
871 void write_to_conv(struct conversation *c, char *what, int flags, char *who) 934 void write_to_conv(struct conversation *c, char *what, int flags, char *who)
872 { 935 {
873 char *buf = g_malloc(BUF_LONG); 936 char *buf = g_malloc(BUF_LONG);
874 char *buf2 = g_malloc(BUF_LONG); 937 char *buf2 = g_malloc(BUF_LONG);
875 char *str; 938 char *str;
876 FILE *fd; 939 FILE *fd;
877 char colour[10]; 940 char colour[10];
878 GdkBitmap *mask;
879 GdkPixmap *face; 941 GdkPixmap *face;
880 int state; 942 int state;
881 int y; 943 int y;
882 int i; 944 int i;
883 char *smiley = g_malloc(7); 945 char *smiley = g_malloc(7);
965 1027
966 if (display_options & OPT_DISP_SHOW_SMILEY) 1028 if (display_options & OPT_DISP_SHOW_SMILEY)
967 { 1029 {
968 for (i = 0; i < strlen(what); i++) 1030 for (i = 0; i < strlen(what); i++)
969 { 1031 {
970 buf2[y] = what[i]; 1032 int len;
971 y++; 1033 if ((face = is_smiley(c, &what[i], &len)) != NULL) {
972 1034 buf2[y] = 0;
973 if ( (what[i] == ':') || (what[i] == ';') || (what[i] == '8') ) 1035 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
974 { 1036 gtk_html_add_pixmap(GTK_HTML(c->text), face, 0);
975 if (state < 2) 1037 y = 0;
976 { 1038 i += len - 1;
977 smiley[state] = what[i]; 1039 } else {
978 state++; 1040 buf2[y] = what[i];
979 } 1041 y++;
980 else 1042
981 { 1043 }
982 state = 0;
983 }
984 }
985 else if ( (what[i] == '-') || (what[i] == '^') || (what[i] == 'o') )
986 {
987 if ((state == 1) || (state==2))
988 {
989 smiley[state] = what[i];
990 state++;
991 }
992 else
993 {
994 state = 0;
995 }
996 }
997 else if ((what[i] == ')') || (what[i] == '*') || (what[i] == '(') ||
998 (what[i] == 'p') || (what[i] == 'P') || (what[i] == '$') ||
999 (what[i] == '!') || (what[i] == 'D') || (what[i] == 'X') )
1000 {
1001 if ( (state == 1) && (what[i] == ')') )
1002 {
1003 smiley[state] = what[i];
1004 smiley[state+1] = 0;
1005 buf2[y - state - 1] = 0;
1006 y = 0;
1007 if (!strcasecmp(smiley, ";)"))
1008 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_wink_xpm);
1009 else
1010 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_happy_xpm);
1011 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
1012 gtk_html_add_pixmap(GTK_HTML(c->text), face, 0);
1013 state = 0;
1014 }
1015 else if ( (state == 2) || (state == 3))
1016 {
1017 smiley[state] = what[i];
1018 smiley[state+1] = 0;
1019 buf2[y - state - 1] = 0;
1020 y = 0;
1021
1022 if (!strcasecmp(smiley, ":-("))
1023 {
1024 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_sad_xpm);
1025 }
1026 else if (!strcasecmp(smiley, ";-)"))
1027 {
1028 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_wink_xpm);
1029 }
1030 else
1031 {
1032 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_happy_xpm);
1033 }
1034
1035 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
1036 gtk_html_add_pixmap(GTK_HTML(c->text), face, 0);
1037 state = 0;
1038 }
1039 else
1040 state = 0;
1041 }
1042 else
1043 {
1044 state = 0;
1045 }
1046 } 1044 }
1047 1045
1048 if (buf2) 1046 if (y)
1049 { 1047 {
1050 buf2[y] = 0; 1048 buf2[y] = 0;
1051 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); 1049 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
1052 } 1050 }
1053 } 1051 }