Mercurial > pidgin.yaz
comparison src/buddy_chat.c @ 2632:11badfae115c
[gaim-migrate @ 2645]
(23:26:04) Linux226: This is all odd to me.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 28 Oct 2001 06:26:34 +0000 |
parents | a2cf3cac7e66 |
children | 7a3f7aebd4e5 |
comparison
equal
deleted
inserted
replaced
2631:a2cf3cac7e66 | 2632:11badfae115c |
---|---|
50 extern int state_lock; | 50 extern int state_lock; |
51 | 51 |
52 GList *chats = NULL; | 52 GList *chats = NULL; |
53 GtkWidget *all_chats = NULL; | 53 GtkWidget *all_chats = NULL; |
54 GtkWidget *chat_notebook = NULL; | 54 GtkWidget *chat_notebook = NULL; |
55 | |
56 static char *ignored(struct conversation *b, char *who) | |
57 { | |
58 GList *ignore = b->ignored; | |
59 while (ignore) { | |
60 char *ign = ignore->data; | |
61 if (!g_strcasecmp(who, ign)) | |
62 return ign; | |
63 if (*ign == '+' && !g_strcasecmp(who, ign + 1)) | |
64 return ign; | |
65 if (*ign == '@') { | |
66 ign++; | |
67 if (*ign == '+' && !g_strcasecmp(who, ign + 1)) | |
68 return ign; | |
69 if (*ign != '+' && !g_strcasecmp(who, ign)) | |
70 return ign; | |
71 } | |
72 ignore = ignore->next; | |
73 } | |
74 return NULL; | |
75 } | |
55 | 76 |
56 | 77 |
57 static void destroy_join_chat() | 78 static void destroy_join_chat() |
58 { | 79 { |
59 if (joinchat) | 80 if (joinchat) |
667 return FALSE; | 688 return FALSE; |
668 } | 689 } |
669 | 690 |
670 void chat_write(struct conversation *b, char *who, int flag, char *message, time_t mtime) | 691 void chat_write(struct conversation *b, char *who, int flag, char *message, time_t mtime) |
671 { | 692 { |
672 GList *ignore = b->ignored; | |
673 char *str; | 693 char *str; |
674 | 694 |
675 if (!b->is_chat) { | 695 if (!b->is_chat) { |
676 debug_printf("chat_write: expecting chat, got IM\n"); | 696 debug_printf("chat_write: expecting chat, got IM\n"); |
677 return; | 697 return; |
678 } | 698 } |
679 | 699 |
680 while (ignore) { | 700 if (ignored(b, who)) |
681 char *ign = ignore->data; | 701 return; |
682 if (!g_strcasecmp(who, ign)) | |
683 return; | |
684 if (*ign == '+' && !g_strcasecmp(who, ign + 1)) | |
685 return; | |
686 if (*ign == '@') { | |
687 ign++; | |
688 if (*ign == '+' && !g_strcasecmp(who, ign + 1)) | |
689 return; | |
690 if (*ign != '+' && !g_strcasecmp(who, ign)) | |
691 return; | |
692 } | |
693 ignore = ignore->next; | |
694 } | |
695 | |
696 | 702 |
697 if (!(flag & WFLAG_WHISPER)) { | 703 if (!(flag & WFLAG_WHISPER)) { |
698 str = g_strdup(normalize (who)); | 704 str = g_strdup(normalize (who)); |
699 if (!g_strcasecmp(str, normalize(b->gc->username))) { | 705 if (!g_strcasecmp(str, normalize(b->gc->username))) { |
700 if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY)) | 706 if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY)) |
815 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_im), b); | 821 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_im), b); |
816 gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(obj)); | 822 gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(obj)); |
817 gtk_menu_append(GTK_MENU(menu), button); | 823 gtk_menu_append(GTK_MENU(menu), button); |
818 gtk_widget_show(button); | 824 gtk_widget_show(button); |
819 | 825 |
820 if (g_list_find_custom(b->ignored, gtk_object_get_user_data(obj), (GCompareFunc)strcmp)) | 826 if (ignored(b, gtk_object_get_user_data(obj))) |
821 button = gtk_menu_item_new_with_label(_("Un-Ignore")); | 827 button = gtk_menu_item_new_with_label(_("Un-Ignore")); |
822 else | 828 else |
823 button = gtk_menu_item_new_with_label(_("Ignore")); | 829 button = gtk_menu_item_new_with_label(_("Ignore")); |
824 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_ign), b); | 830 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_ign), b); |
825 gtk_object_set_user_data(GTK_OBJECT(button), obj); | 831 gtk_object_set_user_data(GTK_OBJECT(button), obj); |
845 { | 851 { |
846 char *name = g_strdup(buddy); | 852 char *name = g_strdup(buddy); |
847 char tmp[BUF_LONG]; | 853 char tmp[BUF_LONG]; |
848 GtkWidget *list_item; | 854 GtkWidget *list_item; |
849 int pos; | 855 int pos; |
850 GList *ignored; | |
851 | 856 |
852 plugin_event(event_chat_buddy_join, b->gc, (void *)b->id, name, 0); | 857 plugin_event(event_chat_buddy_join, b->gc, (void *)b->id, name, 0); |
853 b->in_room = g_list_insert_sorted(b->in_room, name, insertname); | 858 b->in_room = g_list_insert_sorted(b->in_room, name, insertname); |
854 pos = g_list_index(b->in_room, name); | 859 pos = g_list_index(b->in_room, name); |
855 | 860 |
856 ignored = b->ignored; | 861 if (ignored(b, buddy)) { |
857 while (ignored) { | |
858 if (!g_strcasecmp(name, ignored->data)) | |
859 break; | |
860 ignored = ignored->next; | |
861 } | |
862 | |
863 if (ignored) { | |
864 g_snprintf(tmp, sizeof(tmp), "X %s", name); | 862 g_snprintf(tmp, sizeof(tmp), "X %s", name); |
865 list_item = gtk_list_item_new_with_label(tmp); | 863 list_item = gtk_list_item_new_with_label(tmp); |
866 } else | 864 } else |
867 list_item = gtk_list_item_new_with_label(name); | 865 list_item = gtk_list_item_new_with_label(name); |
868 | 866 |
891 GList *names = b->in_room; | 889 GList *names = b->in_room; |
892 GList *items = GTK_LIST(b->list)->children; | 890 GList *items = GTK_LIST(b->list)->children; |
893 | 891 |
894 char *name = g_strdup(new); | 892 char *name = g_strdup(new); |
895 GtkWidget *list_item; | 893 GtkWidget *list_item; |
894 char *ign; | |
896 int pos; | 895 int pos; |
897 GList *ignored = b->ignored; | |
898 | 896 |
899 char tmp[BUF_LONG]; | 897 char tmp[BUF_LONG]; |
900 | 898 |
901 while (names) { | 899 while (names) { |
902 if (!g_strcasecmp((char *)names->data, old)) { | 900 if (!g_strcasecmp((char *)names->data, old)) { |
922 } | 920 } |
923 | 921 |
924 b->in_room = g_list_insert_sorted(b->in_room, name, insertname); | 922 b->in_room = g_list_insert_sorted(b->in_room, name, insertname); |
925 pos = g_list_index(b->in_room, name); | 923 pos = g_list_index(b->in_room, name); |
926 | 924 |
927 while (ignored) { | 925 ign = ignored(b, old); |
928 if (!g_strcasecmp(old, ignored->data)) | 926 |
929 break; | 927 if (ign) { |
930 ignored = ignored->next; | 928 g_free(ign); |
931 } | 929 b->ignored = g_list_remove(b->ignored, ign); |
932 | 930 |
933 if (ignored) { | 931 /* we haven't added them yet. if we find them, don't add them again */ |
934 g_free(ignored->data); | 932 if (!ignored(b, new)) |
935 b->ignored = g_list_remove(b->ignored, ignored->data); | 933 b->ignored = g_list_append(b->ignored, g_strdup(name)); |
936 b->ignored = g_list_append(b->ignored, g_strdup(name)); | 934 |
935 g_snprintf(tmp, sizeof(tmp), "X %s", name); | |
936 list_item = gtk_list_item_new_with_label(tmp); | |
937 } else if (ignored(b, new)) { | |
937 g_snprintf(tmp, sizeof(tmp), "X %s", name); | 938 g_snprintf(tmp, sizeof(tmp), "X %s", name); |
938 list_item = gtk_list_item_new_with_label(tmp); | 939 list_item = gtk_list_item_new_with_label(tmp); |
939 } else | 940 } else |
940 list_item = gtk_list_item_new_with_label(name); | 941 list_item = gtk_list_item_new_with_label(name); |
941 | 942 |
1023 } | 1024 } |
1024 | 1025 |
1025 void ignore_callback(GtkWidget *w, struct conversation *b) | 1026 void ignore_callback(GtkWidget *w, struct conversation *b) |
1026 { | 1027 { |
1027 char *name; | 1028 char *name; |
1028 GList *i, *ignored; | 1029 GList *i; |
1030 char *ign; | |
1029 int pos; | 1031 int pos; |
1030 GtkWidget *list_item; | 1032 GtkWidget *list_item; |
1031 char tmp[80]; | 1033 char tmp[80]; |
1032 | 1034 |
1033 i = GTK_LIST(b->list)->selection; | 1035 i = GTK_LIST(b->list)->selection; |
1037 return; | 1039 return; |
1038 } | 1040 } |
1039 | 1041 |
1040 pos = gtk_list_child_position(GTK_LIST(b->list), i->data); | 1042 pos = gtk_list_child_position(GTK_LIST(b->list), i->data); |
1041 | 1043 |
1042 ignored = b->ignored; | 1044 ign = ignored(b, name); |
1043 while (ignored) { | 1045 |
1044 if (!g_strcasecmp(name, ignored->data)) | 1046 if (ign) { |
1045 break; | 1047 g_free(ign); |
1046 ignored = ignored->next; | 1048 b->ignored = g_list_remove(b->ignored, ign); |
1047 } | |
1048 | |
1049 if (ignored) { | |
1050 g_free(ignored->data); | |
1051 b->ignored = g_list_remove(b->ignored, ignored->data); | |
1052 g_snprintf(tmp, sizeof tmp, "%s", name); | 1049 g_snprintf(tmp, sizeof tmp, "%s", name); |
1053 } else { | 1050 } else { |
1054 b->ignored = g_list_append(b->ignored, g_strdup(name)); | 1051 b->ignored = g_list_append(b->ignored, g_strdup(name)); |
1055 g_snprintf(tmp, sizeof tmp, "X %s", name); | 1052 g_snprintf(tmp, sizeof tmp, "X %s", name); |
1056 } | 1053 } |
1475 gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); | 1472 gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); |
1476 | 1473 |
1477 while (r) { | 1474 while (r) { |
1478 char *name = r->data; | 1475 char *name = r->data; |
1479 GtkWidget *list_item; | 1476 GtkWidget *list_item; |
1480 GList *ignored = c->ignored; | |
1481 char tmp[BUF_LONG]; | 1477 char tmp[BUF_LONG]; |
1482 | 1478 |
1483 while (ignored) { | 1479 if (ignored(c, name)) { |
1484 if (!g_strcasecmp(name, ignored->data)) | |
1485 break; | |
1486 ignored = ignored->next; | |
1487 } | |
1488 | |
1489 if (ignored) { | |
1490 g_snprintf(tmp, sizeof(tmp), "X %s", name); | 1480 g_snprintf(tmp, sizeof(tmp), "X %s", name); |
1491 list_item = gtk_list_item_new_with_label(tmp); | 1481 list_item = gtk_list_item_new_with_label(tmp); |
1492 } else | 1482 } else |
1493 list_item = gtk_list_item_new_with_label(name); | 1483 list_item = gtk_list_item_new_with_label(name); |
1494 | 1484 |
1524 gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); | 1514 gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); |
1525 | 1515 |
1526 while (r) { | 1516 while (r) { |
1527 char *name = r->data; | 1517 char *name = r->data; |
1528 GtkWidget *list_item; | 1518 GtkWidget *list_item; |
1529 GList *ignored = c->ignored; | |
1530 char tmp[BUF_LONG]; | 1519 char tmp[BUF_LONG]; |
1531 | 1520 |
1532 while (ignored) { | 1521 if (ignored(c, name)) { |
1533 if (!g_strcasecmp(name, ignored->data)) | |
1534 break; | |
1535 ignored = ignored->next; | |
1536 } | |
1537 | |
1538 if (ignored) { | |
1539 g_snprintf(tmp, sizeof(tmp), "X %s", name); | 1522 g_snprintf(tmp, sizeof(tmp), "X %s", name); |
1540 list_item = gtk_list_item_new_with_label(tmp); | 1523 list_item = gtk_list_item_new_with_label(tmp); |
1541 } else | 1524 } else |
1542 list_item = gtk_list_item_new_with_label(name); | 1525 list_item = gtk_list_item_new_with_label(name); |
1543 | 1526 |