| 36 |
36 |
| 37 #ifdef _WIN32 |
37 #ifdef _WIN32 |
| 38 #include "win32dep.h" |
38 #include "win32dep.h" |
| 39 #endif |
39 #endif |
| 40 |
40 |
| 41 struct ConvPlacementData |
41 typedef struct |
| 42 { |
42 { |
| 43 char *name; |
43 char *name; |
| 44 gaim_conv_placement_fnc fnc; |
44 GaimConvPlacementFunc fnc; |
| 45 }; |
45 |
| |
46 } ConvPlacementData; |
| 46 |
47 |
| 47 #define SEND_TYPED_TIMEOUT 5000 |
48 #define SEND_TYPED_TIMEOUT 5000 |
| 48 |
49 |
| 49 static struct gaim_window_ui_ops *win_ui_ops = NULL; |
50 static GaimWindowUiOps *win_ui_ops = NULL; |
| 50 |
51 |
| 51 static GList *conversations = NULL; |
52 static GList *conversations = NULL; |
| 52 static GList *ims = NULL; |
53 static GList *ims = NULL; |
| 53 static GList *chats = NULL; |
54 static GList *chats = NULL; |
| 54 static GList *windows = NULL; |
55 static GList *windows = NULL; |
| 55 static GList *conv_placement_fncs = NULL; |
56 static GList *conv_placement_fncs = NULL; |
| 56 static gaim_conv_placement_fnc place_conv = NULL; |
57 static GaimConvPlacementFunc place_conv = NULL; |
| 57 static int place_conv_index = -1; |
58 static int place_conv_index = -1; |
| 58 |
59 |
| 59 static gint |
60 static gint |
| 60 insertname_compare(gconstpointer one, gconstpointer two) |
61 insertname_compare(gconstpointer one, gconstpointer two) |
| 61 { |
62 { |
| 249 |
250 |
| 250 strncpy(buf, buffy, limit); |
251 strncpy(buf, buffy, limit); |
| 251 g_free(buffy); |
252 g_free(buffy); |
| 252 |
253 |
| 253 if (type == GAIM_CONV_IM) { |
254 if (type == GAIM_CONV_IM) { |
| 254 struct gaim_im *im = GAIM_IM(conv); |
255 GaimIm *im = GAIM_IM(conv); |
| 255 |
256 |
| 256 buffy = g_strdup(buf); |
257 buffy = g_strdup(buf); |
| 257 gaim_event_broadcast(event_im_displayed_sent, gc, |
258 gaim_event_broadcast(event_im_displayed_sent, gc, |
| 258 gaim_conversation_get_name(conv), &buffy); |
259 gaim_conversation_get_name(conv), &buffy); |
| 259 |
260 |
| 427 } |
428 } |
| 428 |
429 |
| 429 } |
430 } |
| 430 |
431 |
| 431 static void |
432 static void |
| 432 update_conv_indexes(struct gaim_window *win) |
433 update_conv_indexes(GaimWindow *win) |
| 433 { |
434 { |
| 434 GList *l; |
435 GList *l; |
| 435 int i; |
436 int i; |
| 436 |
437 |
| 437 for (l = gaim_window_get_conversations(win), i = 0; |
438 for (l = gaim_window_get_conversations(win), i = 0; |
| 438 l != NULL; |
439 l != NULL; |
| 439 l = l->next, i++) { |
440 l = l->next, i++) { |
| 440 |
441 |
| 441 struct gaim_conversation *conv = (struct gaim_conversation *)l->data; |
442 GaimConversation *conv = (GaimConversation *)l->data; |
| 442 |
443 |
| 443 conv->conversation_pos = i; |
444 conv->conversation_pos = i; |
| 444 } |
445 } |
| 445 } |
446 } |
| 446 |
447 |
| 447 struct gaim_window * |
448 GaimWindow * |
| 448 gaim_window_new(void) |
449 gaim_window_new(void) |
| 449 { |
450 { |
| 450 struct gaim_window *win; |
451 GaimWindow *win; |
| 451 |
452 |
| 452 win = g_malloc0(sizeof(struct gaim_window)); |
453 win = g_malloc0(sizeof(GaimWindow)); |
| 453 |
454 |
| 454 win->ui_ops = gaim_get_win_ui_ops(); |
455 win->ui_ops = gaim_get_win_ui_ops(); |
| 455 |
456 |
| 456 if (win->ui_ops != NULL && win->ui_ops->new_window != NULL) |
457 if (win->ui_ops != NULL && win->ui_ops->new_window != NULL) |
| 457 win->ui_ops->new_window(win); |
458 win->ui_ops->new_window(win); |
| 593 |
594 |
| 594 for (l = gaim_window_get_conversations(win); |
595 for (l = gaim_window_get_conversations(win); |
| 595 l != NULL; |
596 l != NULL; |
| 596 l = l->next) { |
597 l = l->next) { |
| 597 |
598 |
| 598 struct gaim_conversation *conv = (struct gaim_conversation *)l; |
599 GaimConversation *conv = (GaimConversation *)l; |
| 599 |
600 |
| 600 gaim_conversation_set_ui_ops(conv, conv_ops); |
601 gaim_conversation_set_ui_ops(conv, conv_ops); |
| 601 |
602 |
| 602 if (win->ui_ops != NULL && win->ui_ops->add_conversation != NULL) |
603 if (win->ui_ops != NULL && win->ui_ops->add_conversation != NULL) |
| 603 win->ui_ops->add_conversation(win, conv); |
604 win->ui_ops->add_conversation(win, conv); |
| 604 } |
605 } |
| 605 } |
606 } |
| 606 |
607 |
| 607 struct gaim_window_ui_ops * |
608 GaimWindowUiOps * |
| 608 gaim_window_get_ui_ops(const struct gaim_window *win) |
609 gaim_window_get_ui_ops(const GaimWindow *win) |
| 609 { |
610 { |
| 610 if (win == NULL) |
611 if (win == NULL) |
| 611 return NULL; |
612 return NULL; |
| 612 |
613 |
| 613 return win->ui_ops; |
614 return win->ui_ops; |
| 614 } |
615 } |
| 615 |
616 |
| 616 int |
617 int |
| 617 gaim_window_add_conversation(struct gaim_window *win, |
618 gaim_window_add_conversation(GaimWindow *win, GaimConversation *conv) |
| 618 struct gaim_conversation *conv) |
619 { |
| 619 { |
620 GaimWindowUiOps *ops; |
| 620 struct gaim_window_ui_ops *ops; |
|
| 621 |
621 |
| 622 if (win == NULL || conv == NULL) |
622 if (win == NULL || conv == NULL) |
| 623 return -1; |
623 return -1; |
| 624 |
624 |
| 625 if (gaim_conversation_get_window(conv) != NULL) { |
625 if (gaim_conversation_get_window(conv) != NULL) { |
| 646 } |
646 } |
| 647 |
647 |
| 648 return win->conversation_count - 1; |
648 return win->conversation_count - 1; |
| 649 } |
649 } |
| 650 |
650 |
| 651 struct gaim_conversation * |
651 GaimConversation * |
| 652 gaim_window_remove_conversation(struct gaim_window *win, unsigned int index) |
652 gaim_window_remove_conversation(GaimWindow *win, unsigned int index) |
| 653 { |
653 { |
| 654 struct gaim_window_ui_ops *ops; |
654 GaimWindowUiOps *ops; |
| 655 struct gaim_conversation *conv; |
655 GaimConversation *conv; |
| 656 GList *node; |
656 GList *node; |
| 657 |
657 |
| 658 if (win == NULL || index >= gaim_window_get_conversation_count(win)) |
658 if (win == NULL || index >= gaim_window_get_conversation_count(win)) |
| 659 return NULL; |
659 return NULL; |
| 660 |
660 |
| 661 ops = gaim_window_get_ui_ops(win); |
661 ops = gaim_window_get_ui_ops(win); |
| 662 |
662 |
| 663 node = g_list_nth(gaim_window_get_conversations(win), index); |
663 node = g_list_nth(gaim_window_get_conversations(win), index); |
| 664 conv = (struct gaim_conversation *)node->data; |
664 conv = (GaimConversation *)node->data; |
| 665 |
665 |
| 666 if (ops != NULL && ops->remove_conversation != NULL) |
666 if (ops != NULL && ops->remove_conversation != NULL) |
| 667 ops->remove_conversation(win, conv); |
667 ops->remove_conversation(win, conv); |
| 668 |
668 |
| 669 win->conversations = g_list_remove_link(win->conversations, node); |
669 win->conversations = g_list_remove_link(win->conversations, node); |
| 729 win->conversations = g_list_insert(win->conversations, conv, new_index); |
729 win->conversations = g_list_insert(win->conversations, conv, new_index); |
| 730 |
730 |
| 731 update_conv_indexes(win); |
731 update_conv_indexes(win); |
| 732 } |
732 } |
| 733 |
733 |
| 734 struct gaim_conversation * |
734 GaimConversation * |
| 735 gaim_window_get_conversation_at(const struct gaim_window *win, |
735 gaim_window_get_conversation_at(const GaimWindow *win, unsigned int index) |
| 736 unsigned int index) |
|
| 737 { |
736 { |
| 738 if (win == NULL || index >= gaim_window_get_conversation_count(win)) |
737 if (win == NULL || index >= gaim_window_get_conversation_count(win)) |
| 739 return NULL; |
738 return NULL; |
| 740 |
739 |
| 741 return (struct gaim_conversation *)g_list_nth_data( |
740 return (GaimConversation *)g_list_nth_data( |
| 742 gaim_window_get_conversations(win), index); |
741 gaim_window_get_conversations(win), index); |
| 743 } |
742 } |
| 744 |
743 |
| 745 size_t |
744 size_t |
| 746 gaim_window_get_conversation_count(const struct gaim_window *win) |
745 gaim_window_get_conversation_count(const GaimWindow *win) |
| 747 { |
746 { |
| 748 if (win == NULL) |
747 if (win == NULL) |
| 749 return 0; |
748 return 0; |
| 750 |
749 |
| 751 return win->conversation_count; |
750 return win->conversation_count; |
| 752 } |
751 } |
| 753 |
752 |
| 754 void |
753 void |
| 755 gaim_window_switch_conversation(struct gaim_window *win, unsigned int index) |
754 gaim_window_switch_conversation(GaimWindow *win, unsigned int index) |
| 756 { |
755 { |
| 757 struct gaim_window_ui_ops *ops; |
756 GaimWindowUiOps *ops; |
| 758 |
757 |
| 759 if (win == NULL || index < 0 || |
758 if (win == NULL || index < 0 || |
| 760 index >= gaim_window_get_conversation_count(win)) |
759 index >= gaim_window_get_conversation_count(win)) |
| 761 return; |
760 return; |
| 762 |
761 |
| 798 gaim_get_windows(void) |
797 gaim_get_windows(void) |
| 799 { |
798 { |
| 800 return windows; |
799 return windows; |
| 801 } |
800 } |
| 802 |
801 |
| 803 struct gaim_window * |
802 GaimWindow * |
| 804 gaim_get_first_window_with_type(GaimConversationType type) |
803 gaim_get_first_window_with_type(GaimConversationType type) |
| 805 { |
804 { |
| 806 GList *wins, *convs; |
805 GList *wins, *convs; |
| 807 struct gaim_window *win; |
806 GaimWindow *win; |
| 808 struct gaim_conversation *conv; |
807 GaimConversation *conv; |
| 809 |
808 |
| 810 if (type == GAIM_CONV_UNKNOWN) |
809 if (type == GAIM_CONV_UNKNOWN) |
| 811 return NULL; |
810 return NULL; |
| 812 |
811 |
| 813 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
812 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
| 814 win = (struct gaim_window *)wins->data; |
813 win = (GaimWindow *)wins->data; |
| 815 |
814 |
| 816 for (convs = gaim_window_get_conversations(win); |
815 for (convs = gaim_window_get_conversations(win); |
| 817 convs != NULL; |
816 convs != NULL; |
| 818 convs = convs->next) { |
817 convs = convs->next) { |
| 819 |
818 |
| 820 conv = (struct gaim_conversation *)convs->data; |
819 conv = (GaimConversation *)convs->data; |
| 821 |
820 |
| 822 if (gaim_conversation_get_type(conv) == type) |
821 if (gaim_conversation_get_type(conv) == type) |
| 823 return win; |
822 return win; |
| 824 } |
823 } |
| 825 } |
824 } |
| 826 |
825 |
| 827 return NULL; |
826 return NULL; |
| 828 } |
827 } |
| 829 |
828 |
| 830 struct gaim_window * |
829 GaimWindow * |
| 831 gaim_get_last_window_with_type(GaimConversationType type) |
830 gaim_get_last_window_with_type(GaimConversationType type) |
| 832 { |
831 { |
| 833 GList *wins, *convs; |
832 GList *wins, *convs; |
| 834 struct gaim_window *win; |
833 GaimWindow *win; |
| 835 struct gaim_conversation *conv; |
834 GaimConversation *conv; |
| 836 |
835 |
| 837 if (type == GAIM_CONV_UNKNOWN) |
836 if (type == GAIM_CONV_UNKNOWN) |
| 838 return NULL; |
837 return NULL; |
| 839 |
838 |
| 840 for (wins = g_list_last(gaim_get_windows()); |
839 for (wins = g_list_last(gaim_get_windows()); |
| 841 wins != NULL; |
840 wins != NULL; |
| 842 wins = wins->prev) { |
841 wins = wins->prev) { |
| 843 |
842 |
| 844 win = (struct gaim_window *)wins->data; |
843 win = (GaimWindow *)wins->data; |
| 845 |
844 |
| 846 for (convs = gaim_window_get_conversations(win); |
845 for (convs = gaim_window_get_conversations(win); |
| 847 convs != NULL; |
846 convs != NULL; |
| 848 convs = convs->next) { |
847 convs = convs->next) { |
| 849 |
848 |
| 850 conv = (struct gaim_conversation *)convs->data; |
849 conv = (GaimConversation *)convs->data; |
| 851 |
850 |
| 852 if (gaim_conversation_get_type(conv) == type) |
851 if (gaim_conversation_get_type(conv) == type) |
| 853 return win; |
852 return win; |
| 854 } |
853 } |
| 855 } |
854 } |
| 858 } |
857 } |
| 859 |
858 |
| 860 /************************************************************************** |
859 /************************************************************************** |
| 861 * Conversation API |
860 * Conversation API |
| 862 **************************************************************************/ |
861 **************************************************************************/ |
| 863 struct gaim_conversation * |
862 GaimConversation * |
| 864 gaim_conversation_new(GaimConversationType type, GaimAccount *account, |
863 gaim_conversation_new(GaimConversationType type, GaimAccount *account, |
| 865 const char *name) |
864 const char *name) |
| 866 { |
865 { |
| 867 struct gaim_conversation *conv; |
866 GaimConversation *conv; |
| 868 |
867 |
| 869 if (type == GAIM_CONV_UNKNOWN) |
868 if (type == GAIM_CONV_UNKNOWN) |
| 870 return NULL; |
869 return NULL; |
| 871 |
870 |
| 872 /* Check if this conversation already exists. */ |
871 /* Check if this conversation already exists. */ |
| 873 if ((conv = gaim_find_conversation_with_account(name, account)) != NULL) |
872 if ((conv = gaim_find_conversation_with_account(name, account)) != NULL) |
| 874 return conv; |
873 return conv; |
| 875 |
874 |
| 876 conv = g_malloc0(sizeof(struct gaim_conversation)); |
875 conv = g_malloc0(sizeof(GaimConversation)); |
| 877 |
876 |
| 878 conv->type = type; |
877 conv->type = type; |
| 879 conv->account = account; |
878 conv->account = account; |
| 880 conv->name = g_strdup(name); |
879 conv->name = g_strdup(name); |
| 881 conv->title = g_strdup(name); |
880 conv->title = g_strdup(name); |
| 884 conv->data = g_hash_table_new_full(g_str_hash, g_str_equal, |
883 conv->data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 885 g_free, NULL); |
884 g_free, NULL); |
| 886 |
885 |
| 887 if (type == GAIM_CONV_IM) |
886 if (type == GAIM_CONV_IM) |
| 888 { |
887 { |
| 889 conv->u.im = g_malloc0(sizeof(struct gaim_im)); |
888 conv->u.im = g_malloc0(sizeof(GaimIm)); |
| 890 conv->u.im->conv = conv; |
889 conv->u.im->conv = conv; |
| 891 |
890 |
| 892 ims = g_list_append(ims, conv); |
891 ims = g_list_append(ims, conv); |
| 893 |
892 |
| 894 gaim_conversation_set_logging(conv, |
893 gaim_conversation_set_logging(conv, |
| 895 gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
894 gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
| 896 } |
895 } |
| 897 else if (type == GAIM_CONV_CHAT) |
896 else if (type == GAIM_CONV_CHAT) |
| 898 { |
897 { |
| 899 conv->u.chat = g_malloc0(sizeof(struct gaim_chat)); |
898 conv->u.chat = g_malloc0(sizeof(GaimChat)); |
| 900 conv->u.chat->conv = conv; |
899 conv->u.chat->conv = conv; |
| 901 |
900 |
| 902 chats = g_list_append(chats, conv); |
901 chats = g_list_append(chats, conv); |
| 903 |
902 |
| 904 gaim_conversation_set_logging(conv, |
903 gaim_conversation_set_logging(conv, |
| 1067 |
1066 |
| 1068 g_free(conv); |
1067 g_free(conv); |
| 1069 } |
1068 } |
| 1070 |
1069 |
| 1071 GaimConversationType |
1070 GaimConversationType |
| 1072 gaim_conversation_get_type(const struct gaim_conversation *conv) |
1071 gaim_conversation_get_type(const GaimConversation *conv) |
| 1073 { |
1072 { |
| 1074 if (conv == NULL) |
1073 if (conv == NULL) |
| 1075 return GAIM_CONV_UNKNOWN; |
1074 return GAIM_CONV_UNKNOWN; |
| 1076 |
1075 |
| 1077 return conv->type; |
1076 return conv->type; |
| 1078 } |
1077 } |
| 1079 |
1078 |
| 1080 void |
1079 void |
| 1081 gaim_conversation_set_ui_ops(struct gaim_conversation *conv, |
1080 gaim_conversation_set_ui_ops(GaimConversation *conv, |
| 1082 struct gaim_conversation_ui_ops *ops) |
1081 GaimConversationUiOps *ops) |
| 1083 { |
1082 { |
| 1084 if (conv == NULL || conv->ui_ops == ops) |
1083 if (conv == NULL || conv->ui_ops == ops) |
| 1085 return; |
1084 return; |
| 1086 |
1085 |
| 1087 if (conv->ui_ops != NULL && conv->ui_ops->destroy_conversation != NULL) |
1086 if (conv->ui_ops != NULL && conv->ui_ops->destroy_conversation != NULL) |
| 1090 conv->ui_data = NULL; |
1089 conv->ui_data = NULL; |
| 1091 |
1090 |
| 1092 conv->ui_ops = ops; |
1091 conv->ui_ops = ops; |
| 1093 } |
1092 } |
| 1094 |
1093 |
| 1095 struct gaim_conversation_ui_ops * |
1094 GaimConversationUiOps * |
| 1096 gaim_conversation_get_ui_ops(struct gaim_conversation *conv) |
1095 gaim_conversation_get_ui_ops(const GaimConversation *conv) |
| 1097 { |
1096 { |
| 1098 if (conv == NULL) |
1097 if (conv == NULL) |
| 1099 return NULL; |
1098 return NULL; |
| 1100 |
1099 |
| 1101 return conv->ui_ops; |
1100 return conv->ui_ops; |
| 1102 } |
1101 } |
| 1103 |
1102 |
| 1104 void |
1103 void |
| 1105 gaim_conversation_set_account(struct gaim_conversation *conv, |
1104 gaim_conversation_set_account(GaimConversation *conv, GaimAccount *account) |
| 1106 GaimAccount *account) |
|
| 1107 { |
1105 { |
| 1108 if (conv == NULL || account == gaim_conversation_get_account(conv)) |
1106 if (conv == NULL || account == gaim_conversation_get_account(conv)) |
| 1109 return; |
1107 return; |
| 1110 |
1108 |
| 1111 conv->account = account; |
1109 conv->account = account; |
| 1112 |
1110 |
| 1113 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
1111 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
| 1114 } |
1112 } |
| 1115 |
1113 |
| 1116 GaimAccount * |
1114 GaimAccount * |
| 1117 gaim_conversation_get_account(const struct gaim_conversation *conv) |
1115 gaim_conversation_get_account(const GaimConversation *conv) |
| 1118 { |
1116 { |
| 1119 if (conv == NULL) |
1117 if (conv == NULL) |
| 1120 return NULL; |
1118 return NULL; |
| 1121 |
1119 |
| 1122 return conv->account; |
1120 return conv->account; |
| 1123 } |
1121 } |
| 1124 |
1122 |
| 1125 GaimConnection * |
1123 GaimConnection * |
| 1126 gaim_conversation_get_gc(const struct gaim_conversation *conv) |
1124 gaim_conversation_get_gc(const GaimConversation *conv) |
| 1127 { |
1125 { |
| 1128 GaimAccount *account; |
1126 GaimAccount *account; |
| 1129 |
1127 |
| 1130 if (conv == NULL) |
1128 if (conv == NULL) |
| 1131 return NULL; |
1129 return NULL; |
| 1156 if (ops != NULL && ops->set_title != NULL) |
1154 if (ops != NULL && ops->set_title != NULL) |
| 1157 ops->set_title(conv, conv->title); |
1155 ops->set_title(conv, conv->title); |
| 1158 } |
1156 } |
| 1159 |
1157 |
| 1160 const char * |
1158 const char * |
| 1161 gaim_conversation_get_title(const struct gaim_conversation *conv) |
1159 gaim_conversation_get_title(const GaimConversation *conv) |
| 1162 { |
1160 { |
| 1163 if (conv == NULL) |
1161 if (conv == NULL) |
| 1164 return NULL; |
1162 return NULL; |
| 1165 |
1163 |
| 1166 return conv->title; |
1164 return conv->title; |
| 1167 } |
1165 } |
| 1168 |
1166 |
| 1169 void |
1167 void |
| 1170 gaim_conversation_autoset_title(struct gaim_conversation *conv) |
1168 gaim_conversation_autoset_title(GaimConversation *conv) |
| 1171 { |
1169 { |
| 1172 GaimAccount *account; |
1170 GaimAccount *account; |
| 1173 struct buddy *b; |
1171 struct buddy *b; |
| 1174 const char *text, *name; |
1172 const char *text, *name; |
| 1175 |
1173 |
| 1189 |
1187 |
| 1190 gaim_conversation_set_title(conv, text); |
1188 gaim_conversation_set_title(conv, text); |
| 1191 } |
1189 } |
| 1192 |
1190 |
| 1193 int |
1191 int |
| 1194 gaim_conversation_get_index(const struct gaim_conversation *conv) |
1192 gaim_conversation_get_index(const GaimConversation *conv) |
| 1195 { |
1193 { |
| 1196 if (conv == NULL) |
1194 if (conv == NULL) |
| 1197 return 0; |
1195 return 0; |
| 1198 |
1196 |
| 1199 return conv->conversation_pos; |
1197 return conv->conversation_pos; |
| 1200 } |
1198 } |
| 1201 |
1199 |
| 1202 void |
1200 void |
| 1203 gaim_conversation_set_unseen(struct gaim_conversation *conv, |
1201 gaim_conversation_set_unseen(GaimConversation *conv, GaimUnseenState state) |
| 1204 GaimUnseenState state) |
|
| 1205 { |
1202 { |
| 1206 if (conv == NULL) |
1203 if (conv == NULL) |
| 1207 return; |
1204 return; |
| 1208 |
1205 |
| 1209 conv->unseen = state; |
1206 conv->unseen = state; |
| 1210 |
1207 |
| 1211 gaim_conversation_update(conv, GAIM_CONV_UPDATE_UNSEEN); |
1208 gaim_conversation_update(conv, GAIM_CONV_UPDATE_UNSEEN); |
| 1212 } |
1209 } |
| 1213 |
1210 |
| 1214 void |
1211 void |
| 1215 gaim_conversation_foreach(void (*func)(struct gaim_conversation *conv)) |
1212 gaim_conversation_foreach(void (*func)(GaimConversation *conv)) |
| 1216 { |
1213 { |
| 1217 struct gaim_conversation *conv; |
1214 GaimConversation *conv; |
| 1218 GList *l; |
1215 GList *l; |
| 1219 |
1216 |
| 1220 if (func == NULL) |
1217 if (func == NULL) |
| 1221 return; |
1218 return; |
| 1222 |
1219 |
| 1223 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
1220 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
| 1224 conv = (struct gaim_conversation *)l->data; |
1221 conv = (GaimConversation *)l->data; |
| 1225 |
1222 |
| 1226 func(conv); |
1223 func(conv); |
| 1227 } |
1224 } |
| 1228 } |
1225 } |
| 1229 |
1226 |
| 1230 GaimUnseenState |
1227 GaimUnseenState |
| 1231 gaim_conversation_get_unseen(const struct gaim_conversation *conv) |
1228 gaim_conversation_get_unseen(const GaimConversation *conv) |
| 1232 { |
1229 { |
| 1233 if (conv == NULL) |
1230 if (conv == NULL) |
| 1234 return 0; |
1231 return 0; |
| 1235 |
1232 |
| 1236 return conv->unseen; |
1233 return conv->unseen; |
| 1237 } |
1234 } |
| 1238 |
1235 |
| 1239 const char * |
1236 const char * |
| 1240 gaim_conversation_get_name(const struct gaim_conversation *conv) |
1237 gaim_conversation_get_name(const GaimConversation *conv) |
| 1241 { |
1238 { |
| 1242 if (conv == NULL) |
1239 if (conv == NULL) |
| 1243 return NULL; |
1240 return NULL; |
| 1244 |
1241 |
| 1245 return conv->name; |
1242 return conv->name; |
| 1246 } |
1243 } |
| 1247 |
1244 |
| 1248 void |
1245 void |
| 1249 gaim_conversation_set_logging(struct gaim_conversation *conv, gboolean log) |
1246 gaim_conversation_set_logging(GaimConversation *conv, gboolean log) |
| 1250 { |
1247 { |
| 1251 if (conv == NULL) |
1248 if (conv == NULL) |
| 1252 return; |
1249 return; |
| 1253 |
1250 |
| 1254 conv->logging = log; |
1251 conv->logging = log; |
| 1255 |
1252 |
| 1256 gaim_conversation_update(conv, GAIM_CONV_UPDATE_LOGGING); |
1253 gaim_conversation_update(conv, GAIM_CONV_UPDATE_LOGGING); |
| 1257 } |
1254 } |
| 1258 |
1255 |
| 1259 gboolean |
1256 gboolean |
| 1260 gaim_conversation_is_logging(const struct gaim_conversation *conv) |
1257 gaim_conversation_is_logging(const GaimConversation *conv) |
| 1261 { |
1258 { |
| 1262 if (conv == NULL) |
1259 if (conv == NULL) |
| 1263 return FALSE; |
1260 return FALSE; |
| 1264 |
1261 |
| 1265 return conv->logging; |
1262 return conv->logging; |
| 1266 } |
1263 } |
| 1267 |
1264 |
| 1268 GList * |
1265 GList * |
| 1269 gaim_conversation_get_send_history(const struct gaim_conversation *conv) |
1266 gaim_conversation_get_send_history(const GaimConversation *conv) |
| 1270 { |
1267 { |
| 1271 if (conv == NULL) |
1268 if (conv == NULL) |
| 1272 return NULL; |
1269 return NULL; |
| 1273 |
1270 |
| 1274 return conv->send_history; |
1271 return conv->send_history; |
| 1275 } |
1272 } |
| 1276 |
1273 |
| 1277 void |
1274 void |
| 1278 gaim_conversation_set_history(struct gaim_conversation *conv, |
1275 gaim_conversation_set_history(GaimConversation *conv, GString *history) |
| 1279 GString *history) |
|
| 1280 { |
1276 { |
| 1281 if (conv == NULL) |
1277 if (conv == NULL) |
| 1282 return; |
1278 return; |
| 1283 |
1279 |
| 1284 conv->history = history; |
1280 conv->history = history; |
| 1285 } |
1281 } |
| 1286 |
1282 |
| 1287 GString * |
1283 GString * |
| 1288 gaim_conversation_get_history(const struct gaim_conversation *conv) |
1284 gaim_conversation_get_history(const GaimConversation *conv) |
| 1289 { |
1285 { |
| 1290 if (conv == NULL) |
1286 if (conv == NULL) |
| 1291 return NULL; |
1287 return NULL; |
| 1292 |
1288 |
| 1293 return conv->history; |
1289 return conv->history; |
| 1294 } |
1290 } |
| 1295 |
1291 |
| 1296 struct gaim_window * |
1292 GaimWindow * |
| 1297 gaim_conversation_get_window(const struct gaim_conversation *conv) |
1293 gaim_conversation_get_window(const GaimConversation *conv) |
| 1298 { |
1294 { |
| 1299 if (conv == NULL) |
1295 if (conv == NULL) |
| 1300 return NULL; |
1296 return NULL; |
| 1301 |
1297 |
| 1302 return conv->window; |
1298 return conv->window; |
| 1303 } |
1299 } |
| 1304 |
1300 |
| 1305 struct gaim_im * |
1301 GaimIm * |
| 1306 gaim_conversation_get_im_data(const struct gaim_conversation *conv) |
1302 gaim_conversation_get_im_data(const GaimConversation *conv) |
| 1307 { |
1303 { |
| 1308 if (conv == NULL) |
1304 if (conv == NULL) |
| 1309 return NULL; |
1305 return NULL; |
| 1310 |
1306 |
| 1311 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
1307 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
| 1312 return NULL; |
1308 return NULL; |
| 1313 |
1309 |
| 1314 return conv->u.im; |
1310 return conv->u.im; |
| 1315 } |
1311 } |
| 1316 |
1312 |
| 1317 struct gaim_chat * |
1313 GaimChat * |
| 1318 gaim_conversation_get_chat_data(const struct gaim_conversation *conv) |
1314 gaim_conversation_get_chat_data(const GaimConversation *conv) |
| 1319 { |
1315 { |
| 1320 if (conv == NULL) |
1316 if (conv == NULL) |
| 1321 return NULL; |
1317 return NULL; |
| 1322 |
1318 |
| 1323 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) |
1319 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) |
| 1325 |
1321 |
| 1326 return conv->u.chat; |
1322 return conv->u.chat; |
| 1327 } |
1323 } |
| 1328 |
1324 |
| 1329 void |
1325 void |
| 1330 gaim_conversation_set_data(struct gaim_conversation *conv, const char *key, |
1326 gaim_conversation_set_data(GaimConversation *conv, const char *key, |
| 1331 gpointer data) |
1327 gpointer data) |
| 1332 { |
1328 { |
| 1333 if (conv == NULL || key == NULL) |
1329 if (conv == NULL || key == NULL) |
| 1334 return; |
1330 return; |
| 1335 |
1331 |
| 1336 g_hash_table_replace(conv->data, g_strdup(key), data); |
1332 g_hash_table_replace(conv->data, g_strdup(key), data); |
| 1337 } |
1333 } |
| 1338 |
1334 |
| 1339 gpointer |
1335 gpointer |
| 1340 gaim_conversation_get_data(struct gaim_conversation *conv, const char *key) |
1336 gaim_conversation_get_data(GaimConversation *conv, const char *key) |
| 1341 { |
1337 { |
| 1342 if (conv == NULL || key == NULL) |
1338 if (conv == NULL || key == NULL) |
| 1343 return NULL; |
1339 return NULL; |
| 1344 |
1340 |
| 1345 return g_hash_table_lookup(conv->data, key); |
1341 return g_hash_table_lookup(conv->data, key); |
| 1361 gaim_get_chats(void) |
1357 gaim_get_chats(void) |
| 1362 { |
1358 { |
| 1363 return chats; |
1359 return chats; |
| 1364 } |
1360 } |
| 1365 |
1361 |
| 1366 struct gaim_conversation * |
1362 GaimConversation * |
| 1367 gaim_find_conversation(const char *name) |
1363 gaim_find_conversation(const char *name) |
| 1368 { |
1364 { |
| 1369 struct gaim_conversation *c = NULL; |
1365 GaimConversation *c = NULL; |
| 1370 char *cuser; |
1366 char *cuser; |
| 1371 GList *cnv; |
1367 GList *cnv; |
| 1372 |
1368 |
| 1373 if (name == NULL) |
1369 if (name == NULL) |
| 1374 return NULL; |
1370 return NULL; |
| 1375 |
1371 |
| 1376 cuser = g_strdup(normalize(name)); |
1372 cuser = g_strdup(normalize(name)); |
| 1377 |
1373 |
| 1378 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
1374 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
| 1379 c = (struct gaim_conversation *)cnv->data; |
1375 c = (GaimConversation *)cnv->data; |
| 1380 |
1376 |
| 1381 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c)))) |
1377 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c)))) |
| 1382 break; |
1378 break; |
| 1383 |
1379 |
| 1384 c = NULL; |
1380 c = NULL; |
| 1387 g_free(cuser); |
1383 g_free(cuser); |
| 1388 |
1384 |
| 1389 return c; |
1385 return c; |
| 1390 } |
1386 } |
| 1391 |
1387 |
| 1392 struct gaim_conversation * |
1388 GaimConversation * |
| 1393 gaim_find_conversation_with_account(const char *name, const GaimAccount *account) |
1389 gaim_find_conversation_with_account(const char *name, |
| 1394 { |
1390 const GaimAccount *account) |
| 1395 struct gaim_conversation *c = NULL; |
1391 { |
| |
1392 GaimConversation *c = NULL; |
| 1396 char *cuser; |
1393 char *cuser; |
| 1397 GList *cnv; |
1394 GList *cnv; |
| 1398 |
1395 |
| 1399 if (name == NULL) |
1396 if (name == NULL) |
| 1400 return NULL; |
1397 return NULL; |
| 1401 |
1398 |
| 1402 cuser = g_strdup(normalize(name)); |
1399 cuser = g_strdup(normalize(name)); |
| 1403 |
1400 |
| 1404 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
1401 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
| 1405 c = (struct gaim_conversation *)cnv->data; |
1402 c = (GaimConversation *)cnv->data; |
| 1406 |
1403 |
| 1407 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) && |
1404 if (!gaim_utf8_strcasecmp(cuser, |
| |
1405 normalize(gaim_conversation_get_name(c))) && |
| 1408 account == gaim_conversation_get_account(c)) { |
1406 account == gaim_conversation_get_account(c)) { |
| 1409 |
1407 |
| 1410 break; |
1408 break; |
| 1411 } |
1409 } |
| 1412 |
1410 |
| 1417 |
1415 |
| 1418 return c; |
1416 return c; |
| 1419 } |
1417 } |
| 1420 |
1418 |
| 1421 void |
1419 void |
| 1422 gaim_conversation_write(struct gaim_conversation *conv, const char *who, |
1420 gaim_conversation_write(GaimConversation *conv, const char *who, |
| 1423 const char *message, size_t length, int flags, |
1421 const char *message, size_t length, int flags, |
| 1424 time_t mtime) |
1422 time_t mtime) |
| 1425 { |
1423 { |
| 1426 GaimPluginProtocolInfo *prpl_info = NULL; |
1424 GaimPluginProtocolInfo *prpl_info = NULL; |
| 1427 GaimConnection *gc; |
1425 GaimConnection *gc; |
| 1428 GaimAccount *account; |
1426 GaimAccount *account; |
| 1429 struct gaim_conversation_ui_ops *ops; |
1427 GaimConversationUiOps *ops; |
| 1430 struct gaim_window *win; |
1428 GaimWindow *win; |
| 1431 struct buddy *b; |
1429 struct buddy *b; |
| 1432 GaimUnseenState unseen; |
1430 GaimUnseenState unseen; |
| 1433 /* int logging_font_options = 0; */ |
1431 /* int logging_font_options = 0; */ |
| 1434 |
1432 |
| 1435 if (conv == NULL || message == NULL) |
1433 if (conv == NULL || message == NULL) |
| 1554 } |
1550 } |
| 1555 |
1551 |
| 1556 /************************************************************************** |
1552 /************************************************************************** |
| 1557 * IM Conversation API |
1553 * IM Conversation API |
| 1558 **************************************************************************/ |
1554 **************************************************************************/ |
| 1559 struct gaim_conversation * |
1555 GaimConversation * |
| 1560 gaim_im_get_conversation(struct gaim_im *im) |
1556 gaim_im_get_conversation(const GaimIm *im) |
| 1561 { |
1557 { |
| 1562 if (im == NULL) |
1558 if (im == NULL) |
| 1563 return NULL; |
1559 return NULL; |
| 1564 |
1560 |
| 1565 return im->conv; |
1561 return im->conv; |
| 1566 } |
1562 } |
| 1567 |
1563 |
| 1568 void |
1564 void |
| 1569 gaim_im_set_typing_state(struct gaim_im *im, int state) |
1565 gaim_im_set_typing_state(GaimIm *im, int state) |
| 1570 { |
1566 { |
| 1571 if (im == NULL) |
1567 if (im == NULL) |
| 1572 return; |
1568 return; |
| 1573 |
1569 |
| 1574 im->typing_state = state; |
1570 im->typing_state = state; |
| 1575 } |
1571 } |
| 1576 |
1572 |
| 1577 int |
1573 int |
| 1578 gaim_im_get_typing_state(const struct gaim_im *im) |
1574 gaim_im_get_typing_state(const GaimIm *im) |
| 1579 { |
1575 { |
| 1580 if (im == NULL) |
1576 if (im == NULL) |
| 1581 return 0; |
1577 return 0; |
| 1582 |
1578 |
| 1583 return im->typing_state; |
1579 return im->typing_state; |
| 1584 } |
1580 } |
| 1585 |
1581 |
| 1586 void |
1582 void |
| 1587 gaim_im_start_typing_timeout(struct gaim_im *im, int timeout) |
1583 gaim_im_start_typing_timeout(GaimIm *im, int timeout) |
| 1588 { |
1584 { |
| 1589 struct gaim_conversation *conv; |
1585 GaimConversation *conv; |
| 1590 const char *name; |
1586 const char *name; |
| 1591 |
1587 |
| 1592 if (im == NULL) |
1588 if (im == NULL) |
| 1593 return; |
1589 return; |
| 1594 |
1590 |
| 1614 g_source_remove(im->typing_timeout); |
1610 g_source_remove(im->typing_timeout); |
| 1615 im->typing_timeout = 0; |
1611 im->typing_timeout = 0; |
| 1616 } |
1612 } |
| 1617 |
1613 |
| 1618 guint |
1614 guint |
| 1619 gaim_im_get_typing_timeout(const struct gaim_im *im) |
1615 gaim_im_get_typing_timeout(const GaimIm *im) |
| 1620 { |
1616 { |
| 1621 if (im == NULL) |
1617 if (im == NULL) |
| 1622 return 0; |
1618 return 0; |
| 1623 |
1619 |
| 1624 return im->typing_timeout; |
1620 return im->typing_timeout; |
| 1625 } |
1621 } |
| 1626 |
1622 |
| 1627 void |
1623 void |
| 1628 gaim_im_set_type_again(struct gaim_im *im, time_t val) |
1624 gaim_im_set_type_again(GaimIm *im, time_t val) |
| 1629 { |
1625 { |
| 1630 if (im == NULL) |
1626 if (im == NULL) |
| 1631 return; |
1627 return; |
| 1632 |
1628 |
| 1633 im->type_again = val; |
1629 im->type_again = val; |
| 1634 } |
1630 } |
| 1635 |
1631 |
| 1636 time_t |
1632 time_t |
| 1637 gaim_im_get_type_again(const struct gaim_im *im) |
1633 gaim_im_get_type_again(const GaimIm *im) |
| 1638 { |
1634 { |
| 1639 if (im == NULL) |
1635 if (im == NULL) |
| 1640 return 0; |
1636 return 0; |
| 1641 |
1637 |
| 1642 return im->type_again; |
1638 return im->type_again; |
| 1643 } |
1639 } |
| 1644 |
1640 |
| 1645 void |
1641 void |
| 1646 gaim_im_start_type_again_timeout(struct gaim_im *im) |
1642 gaim_im_start_type_again_timeout(GaimIm *im) |
| 1647 { |
1643 { |
| 1648 if (im == NULL) |
1644 if (im == NULL) |
| 1649 return; |
1645 return; |
| 1650 |
1646 |
| 1651 im->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed, |
1647 im->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed, |
| 1652 gaim_im_get_conversation(im)); |
1648 gaim_im_get_conversation(im)); |
| 1653 } |
1649 } |
| 1654 |
1650 |
| 1655 void |
1651 void |
| 1656 gaim_im_stop_type_again_timeout(struct gaim_im *im) |
1652 gaim_im_stop_type_again_timeout(GaimIm *im) |
| 1657 { |
1653 { |
| 1658 if (im == NULL) |
1654 if (im == NULL) |
| 1659 return; |
1655 return; |
| 1660 |
1656 |
| 1661 if (im->type_again_timeout == 0) |
1657 if (im->type_again_timeout == 0) |
| 1664 g_source_remove(im->type_again_timeout); |
1660 g_source_remove(im->type_again_timeout); |
| 1665 im->type_again_timeout = 0; |
1661 im->type_again_timeout = 0; |
| 1666 } |
1662 } |
| 1667 |
1663 |
| 1668 guint |
1664 guint |
| 1669 gaim_im_get_type_again_timeout(const struct gaim_im *im) |
1665 gaim_im_get_type_again_timeout(const GaimIm *im) |
| 1670 { |
1666 { |
| 1671 if (im == NULL) |
1667 if (im == NULL) |
| 1672 return 0; |
1668 return 0; |
| 1673 |
1669 |
| 1674 return im->type_again_timeout; |
1670 return im->type_again_timeout; |
| 1675 } |
1671 } |
| 1676 |
1672 |
| 1677 void |
1673 void |
| 1678 gaim_im_update_typing(struct gaim_im *im) |
1674 gaim_im_update_typing(GaimIm *im) |
| 1679 { |
1675 { |
| 1680 if (im == NULL) |
1676 if (im == NULL) |
| 1681 return; |
1677 return; |
| 1682 |
1678 |
| 1683 gaim_conversation_update(gaim_im_get_conversation(im), |
1679 gaim_conversation_update(gaim_im_get_conversation(im), |
| 1684 GAIM_CONV_UPDATE_TYPING); |
1680 GAIM_CONV_UPDATE_TYPING); |
| 1685 } |
1681 } |
| 1686 |
1682 |
| 1687 void |
1683 void |
| 1688 gaim_im_write(struct gaim_im *im, const char *who, const char *message, |
1684 gaim_im_write(GaimIm *im, const char *who, const char *message, |
| 1689 size_t len, int flags, time_t mtime) |
1685 size_t len, int flags, time_t mtime) |
| 1690 { |
1686 { |
| 1691 struct gaim_conversation *c; |
1687 GaimConversation *c; |
| 1692 |
1688 |
| 1693 if (im == NULL || message == NULL) |
1689 if (im == NULL || message == NULL) |
| 1694 return; |
1690 return; |
| 1695 |
1691 |
| 1696 c = gaim_im_get_conversation(im); |
1692 c = gaim_im_get_conversation(im); |
| 1701 else |
1697 else |
| 1702 gaim_conversation_write(c, who, message, -1, flags, mtime); |
1698 gaim_conversation_write(c, who, message, -1, flags, mtime); |
| 1703 } |
1699 } |
| 1704 |
1700 |
| 1705 void |
1701 void |
| 1706 gaim_im_send(struct gaim_im *im, const char *message) |
1702 gaim_im_send(GaimIm *im, const char *message) |
| 1707 { |
1703 { |
| 1708 if (im == NULL || message == NULL) |
1704 if (im == NULL || message == NULL) |
| 1709 return; |
1705 return; |
| 1710 |
1706 |
| 1711 common_send(gaim_im_get_conversation(im), message); |
1707 common_send(gaim_im_get_conversation(im), message); |
| 1713 |
1709 |
| 1714 /************************************************************************** |
1710 /************************************************************************** |
| 1715 * Chat Conversation API |
1711 * Chat Conversation API |
| 1716 **************************************************************************/ |
1712 **************************************************************************/ |
| 1717 |
1713 |
| 1718 struct gaim_conversation * |
1714 GaimConversation * |
| 1719 gaim_chat_get_conversation(struct gaim_chat *chat) |
1715 gaim_chat_get_conversation(const GaimChat *chat) |
| 1720 { |
1716 { |
| 1721 if (chat == NULL) |
1717 if (chat == NULL) |
| 1722 return NULL; |
1718 return NULL; |
| 1723 |
1719 |
| 1724 return chat->conv; |
1720 return chat->conv; |
| 1725 } |
1721 } |
| 1726 |
1722 |
| 1727 GList * |
1723 GList * |
| 1728 gaim_chat_set_users(struct gaim_chat *chat, GList *users) |
1724 gaim_chat_set_users(GaimChat *chat, GList *users) |
| 1729 { |
1725 { |
| 1730 if (chat == NULL) |
1726 if (chat == NULL) |
| 1731 return NULL; |
1727 return NULL; |
| 1732 |
1728 |
| 1733 chat->in_room = users; |
1729 chat->in_room = users; |
| 1734 |
1730 |
| 1735 return users; |
1731 return users; |
| 1736 } |
1732 } |
| 1737 |
1733 |
| 1738 GList * |
1734 GList * |
| 1739 gaim_chat_get_users(const struct gaim_chat *chat) |
1735 gaim_chat_get_users(const GaimChat *chat) |
| 1740 { |
1736 { |
| 1741 if (chat == NULL) |
1737 if (chat == NULL) |
| 1742 return NULL; |
1738 return NULL; |
| 1743 |
1739 |
| 1744 return chat->in_room; |
1740 return chat->in_room; |
| 1745 } |
1741 } |
| 1746 |
1742 |
| 1747 void |
1743 void |
| 1748 gaim_chat_ignore(struct gaim_chat *chat, const char *name) |
1744 gaim_chat_ignore(GaimChat *chat, const char *name) |
| 1749 { |
1745 { |
| 1750 if (chat == NULL || name == NULL) |
1746 if (chat == NULL || name == NULL) |
| 1751 return; |
1747 return; |
| 1752 |
1748 |
| 1753 /* Make sure the user isn't already ignored. */ |
1749 /* Make sure the user isn't already ignored. */ |
| 1779 g_free(item->data); |
1775 g_free(item->data); |
| 1780 g_list_free_1(item); |
1776 g_list_free_1(item); |
| 1781 } |
1777 } |
| 1782 |
1778 |
| 1783 GList * |
1779 GList * |
| 1784 gaim_chat_set_ignored(struct gaim_chat *chat, GList *ignored) |
1780 gaim_chat_set_ignored(GaimChat *chat, GList *ignored) |
| 1785 { |
1781 { |
| 1786 if (chat == NULL) |
1782 if (chat == NULL) |
| 1787 return NULL; |
1783 return NULL; |
| 1788 |
1784 |
| 1789 chat->ignored = ignored; |
1785 chat->ignored = ignored; |
| 1790 |
1786 |
| 1791 return ignored; |
1787 return ignored; |
| 1792 } |
1788 } |
| 1793 |
1789 |
| 1794 GList * |
1790 GList * |
| 1795 gaim_chat_get_ignored(const struct gaim_chat *chat) |
1791 gaim_chat_get_ignored(const GaimChat *chat) |
| 1796 { |
1792 { |
| 1797 if (chat == NULL) |
1793 if (chat == NULL) |
| 1798 return NULL; |
1794 return NULL; |
| 1799 |
1795 |
| 1800 return chat->ignored; |
1796 return chat->ignored; |
| 1801 } |
1797 } |
| 1802 |
1798 |
| 1803 const char * |
1799 const char * |
| 1804 gaim_chat_get_ignored_user(const struct gaim_chat *chat, const char *user) |
1800 gaim_chat_get_ignored_user(const GaimChat *chat, const char *user) |
| 1805 { |
1801 { |
| 1806 GList *ignored; |
1802 GList *ignored; |
| 1807 |
1803 |
| 1808 if (chat == NULL || user == NULL) |
1804 if (chat == NULL || user == NULL) |
| 1809 return NULL; |
1805 return NULL; |
| 1829 |
1825 |
| 1830 return NULL; |
1826 return NULL; |
| 1831 } |
1827 } |
| 1832 |
1828 |
| 1833 gboolean |
1829 gboolean |
| 1834 gaim_chat_is_user_ignored(const struct gaim_chat *chat, const char *user) |
1830 gaim_chat_is_user_ignored(const GaimChat *chat, const char *user) |
| 1835 { |
1831 { |
| 1836 if (chat == NULL || user == NULL) |
1832 if (chat == NULL || user == NULL) |
| 1837 return FALSE; |
1833 return FALSE; |
| 1838 |
1834 |
| 1839 return (gaim_chat_get_ignored_user(chat, user) != NULL); |
1835 return (gaim_chat_get_ignored_user(chat, user) != NULL); |
| 1840 } |
1836 } |
| 1841 |
1837 |
| 1842 void |
1838 void |
| 1843 gaim_chat_set_topic(struct gaim_chat *chat, const char *who, const char *topic) |
1839 gaim_chat_set_topic(GaimChat *chat, const char *who, const char *topic) |
| 1844 { |
1840 { |
| 1845 if (chat == NULL) |
1841 if (chat == NULL) |
| 1846 return; |
1842 return; |
| 1847 |
1843 |
| 1848 if (chat->who != NULL) free(chat->who); |
1844 if (chat->who != NULL) free(chat->who); |
| 1854 gaim_conversation_update(gaim_chat_get_conversation(chat), |
1850 gaim_conversation_update(gaim_chat_get_conversation(chat), |
| 1855 GAIM_CONV_UPDATE_TOPIC); |
1851 GAIM_CONV_UPDATE_TOPIC); |
| 1856 } |
1852 } |
| 1857 |
1853 |
| 1858 const char * |
1854 const char * |
| 1859 gaim_chat_get_topic(const struct gaim_chat *chat) |
1855 gaim_chat_get_topic(const GaimChat *chat) |
| 1860 { |
1856 { |
| 1861 if (chat == NULL) |
1857 if (chat == NULL) |
| 1862 return NULL; |
1858 return NULL; |
| 1863 |
1859 |
| 1864 return chat->topic; |
1860 return chat->topic; |
| 1865 } |
1861 } |
| 1866 |
1862 |
| 1867 void |
1863 void |
| 1868 gaim_chat_set_id(struct gaim_chat *chat, int id) |
1864 gaim_chat_set_id(GaimChat *chat, int id) |
| 1869 { |
1865 { |
| 1870 if (chat == NULL) |
1866 if (chat == NULL) |
| 1871 return; |
1867 return; |
| 1872 |
1868 |
| 1873 chat->id = id; |
1869 chat->id = id; |
| 1874 } |
1870 } |
| 1875 |
1871 |
| 1876 int |
1872 int |
| 1877 gaim_chat_get_id(const struct gaim_chat *chat) |
1873 gaim_chat_get_id(const GaimChat *chat) |
| 1878 { |
1874 { |
| 1879 if (chat == NULL) |
1875 if (chat == NULL) |
| 1880 return -1; |
1876 return -1; |
| 1881 |
1877 |
| 1882 return chat->id; |
1878 return chat->id; |
| 1883 } |
1879 } |
| 1884 |
1880 |
| 1885 void |
1881 void |
| 1886 gaim_chat_write(struct gaim_chat *chat, const char *who, |
1882 gaim_chat_write(GaimChat *chat, const char *who, const char *message, |
| 1887 const char *message, int flags, time_t mtime) |
1883 int flags, time_t mtime) |
| 1888 { |
1884 { |
| 1889 GaimAccount *account; |
1885 GaimAccount *account; |
| 1890 struct gaim_conversation *conv; |
1886 GaimConversation *conv; |
| 1891 GaimConnection *gc; |
1887 GaimConnection *gc; |
| 1892 |
1888 |
| 1893 if (chat == NULL || who == NULL || message == NULL) |
1889 if (chat == NULL || who == NULL || message == NULL) |
| 1894 return; |
1890 return; |
| 1895 |
1891 |
| 1927 else |
1923 else |
| 1928 gaim_conversation_write(conv, who, message, -1, flags, mtime); |
1924 gaim_conversation_write(conv, who, message, -1, flags, mtime); |
| 1929 } |
1925 } |
| 1930 |
1926 |
| 1931 void |
1927 void |
| 1932 gaim_chat_send(struct gaim_chat *chat, const char *message) |
1928 gaim_chat_send(GaimChat *chat, const char *message) |
| 1933 { |
1929 { |
| 1934 if (chat == NULL || message == NULL) |
1930 if (chat == NULL || message == NULL) |
| 1935 return; |
1931 return; |
| 1936 |
1932 |
| 1937 common_send(gaim_chat_get_conversation(chat), message); |
1933 common_send(gaim_chat_get_conversation(chat), message); |
| 1938 } |
1934 } |
| 1939 |
1935 |
| 1940 void |
1936 void |
| 1941 gaim_chat_add_user(struct gaim_chat *chat, const char *user, |
1937 gaim_chat_add_user(GaimChat *chat, const char *user, const char *extra_msg) |
| 1942 const char *extra_msg) |
1938 { |
| 1943 { |
1939 GaimConversation *conv; |
| 1944 struct gaim_conversation *conv; |
1940 GaimConversationUiOps *ops; |
| 1945 struct gaim_conversation_ui_ops *ops; |
|
| 1946 char tmp[BUF_LONG]; |
1941 char tmp[BUF_LONG]; |
| 1947 |
1942 |
| 1948 if (chat == NULL || user == NULL) |
1943 if (chat == NULL || user == NULL) |
| 1949 return; |
1944 return; |
| 1950 |
1945 |
| 1973 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
1968 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
| 1974 } |
1969 } |
| 1975 } |
1970 } |
| 1976 |
1971 |
| 1977 void |
1972 void |
| 1978 gaim_chat_rename_user(struct gaim_chat *chat, const char *old_user, |
1973 gaim_chat_rename_user(GaimChat *chat, const char *old_user, |
| 1979 const char *new_user) |
1974 const char *new_user) |
| 1980 { |
1975 { |
| 1981 struct gaim_conversation *conv; |
1976 GaimConversation *conv; |
| 1982 struct gaim_conversation_ui_ops *ops; |
1977 GaimConversationUiOps *ops; |
| 1983 char tmp[BUF_LONG]; |
1978 char tmp[BUF_LONG]; |
| 1984 GList *names; |
1979 GList *names; |
| 1985 |
1980 |
| 1986 if (chat == NULL || old_user == NULL || new_user == NULL) |
1981 if (chat == NULL || old_user == NULL || new_user == NULL) |
| 1987 return; |
1982 return; |
| 2021 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
2016 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
| 2022 } |
2017 } |
| 2023 } |
2018 } |
| 2024 |
2019 |
| 2025 void |
2020 void |
| 2026 gaim_chat_remove_user(struct gaim_chat *chat, const char *user, |
2021 gaim_chat_remove_user(GaimChat *chat, const char *user, const char *reason) |
| 2027 const char *reason) |
2022 { |
| 2028 { |
2023 GaimConversation *conv; |
| 2029 struct gaim_conversation *conv; |
2024 GaimConversationUiOps *ops; |
| 2030 struct gaim_conversation_ui_ops *ops; |
|
| 2031 char tmp[BUF_LONG]; |
2025 char tmp[BUF_LONG]; |
| 2032 GList *names; |
2026 GList *names; |
| 2033 |
2027 |
| 2034 if (chat == NULL || user == NULL) |
2028 if (chat == NULL || user == NULL) |
| 2035 return; |
2029 return; |
| 2065 |
2059 |
| 2066 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
2060 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
| 2067 } |
2061 } |
| 2068 } |
2062 } |
| 2069 |
2063 |
| 2070 struct gaim_conversation * |
2064 GaimConversation * |
| 2071 gaim_find_chat(GaimConnection *gc, int id) |
2065 gaim_find_chat(const GaimConnection *gc, int id) |
| 2072 { |
2066 { |
| 2073 GList *l; |
2067 GList *l; |
| 2074 struct gaim_conversation *conv; |
2068 GaimConversation *conv; |
| 2075 |
2069 |
| 2076 for (l = gaim_get_chats(); l != NULL; l = l->next) { |
2070 for (l = gaim_get_chats(); l != NULL; l = l->next) { |
| 2077 conv = (struct gaim_conversation *)l->data; |
2071 conv = (GaimConversation *)l->data; |
| 2078 |
2072 |
| 2079 if (gaim_chat_get_id(GAIM_CHAT(conv)) == id && |
2073 if (gaim_chat_get_id(GAIM_CHAT(conv)) == id && |
| 2080 gaim_conversation_get_gc(conv) == gc) |
2074 gaim_conversation_get_gc(conv) == gc) |
| 2081 return conv; |
2075 return conv; |
| 2082 } |
2076 } |
| 2087 /************************************************************************** |
2081 /************************************************************************** |
| 2088 * Conversation placement functions |
2082 * Conversation placement functions |
| 2089 **************************************************************************/ |
2083 **************************************************************************/ |
| 2090 /* This one places conversations in the last made window. */ |
2084 /* This one places conversations in the last made window. */ |
| 2091 static void |
2085 static void |
| 2092 conv_placement_last_created_win(struct gaim_conversation *conv) |
2086 conv_placement_last_created_win(GaimConversation *conv) |
| 2093 { |
2087 { |
| 2094 struct gaim_window *win; |
2088 GaimWindow *win; |
| 2095 |
2089 |
| 2096 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im")) |
2090 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im")) |
| 2097 win = g_list_last(gaim_get_windows())->data; |
2091 win = g_list_last(gaim_get_windows())->data; |
| 2098 else |
2092 else |
| 2099 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); |
2093 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); |
| 2125 * This groups things by, well, group. Buddies from groups will always be |
2119 * This groups things by, well, group. Buddies from groups will always be |
| 2126 * grouped together, and a buddy from a group not belonging to any currently |
2120 * grouped together, and a buddy from a group not belonging to any currently |
| 2127 * open windows will get a new window. |
2121 * open windows will get a new window. |
| 2128 */ |
2122 */ |
| 2129 static void |
2123 static void |
| 2130 conv_placement_by_group(struct gaim_conversation *conv) |
2124 conv_placement_by_group(GaimConversation *conv) |
| 2131 { |
2125 { |
| 2132 struct gaim_window *win; |
2126 GaimWindow *win; |
| 2133 GaimConversationType type; |
2127 GaimConversationType type; |
| 2134 |
2128 |
| 2135 type = gaim_conversation_get_type(conv); |
2129 type = gaim_conversation_get_type(conv); |
| 2136 |
2130 |
| 2137 if (type != GAIM_CONV_IM) { |
2131 if (type != GAIM_CONV_IM) { |
| 2153 if (b != NULL) |
2147 if (b != NULL) |
| 2154 grp = gaim_find_buddys_group(b); |
2148 grp = gaim_find_buddys_group(b); |
| 2155 |
2149 |
| 2156 /* Go through the list of IMs and find one with this group. */ |
2150 /* Go through the list of IMs and find one with this group. */ |
| 2157 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
2151 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
| 2158 struct gaim_window *win2; |
2152 GaimWindow *win2; |
| 2159 struct gaim_conversation *conv2; |
2153 GaimConversation *conv2; |
| 2160 struct buddy *b2; |
2154 struct buddy *b2; |
| 2161 struct group *g2 = NULL; |
2155 struct group *g2 = NULL; |
| 2162 |
2156 |
| 2163 win2 = (struct gaim_window *)wins->data; |
2157 win2 = (GaimWindow *)wins->data; |
| 2164 |
2158 |
| 2165 for (convs = gaim_window_get_conversations(win2); |
2159 for (convs = gaim_window_get_conversations(win2); |
| 2166 convs != NULL; |
2160 convs != NULL; |
| 2167 convs = convs->next) { |
2161 convs = convs->next) { |
| 2168 |
2162 |
| 2169 conv2 = (struct gaim_conversation *)convs->data; |
2163 conv2 = (GaimConversation *)convs->data; |
| 2170 |
2164 |
| 2171 b2 = gaim_find_buddy(gaim_conversation_get_account(conv2), |
2165 b2 = gaim_find_buddy(gaim_conversation_get_account(conv2), |
| 2172 gaim_conversation_get_name(conv2)); |
2166 gaim_conversation_get_name(conv2)); |
| 2173 |
2167 |
| 2174 if (b2 != NULL) |
2168 if (b2 != NULL) |
| 2200 type = gaim_conversation_get_type(conv); |
2194 type = gaim_conversation_get_type(conv); |
| 2201 |
2195 |
| 2202 |
2196 |
| 2203 /* Go through the list of IMs and find one with this group. */ |
2197 /* Go through the list of IMs and find one with this group. */ |
| 2204 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
2198 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
| 2205 struct gaim_window *win2; |
2199 GaimWindow *win2; |
| 2206 struct gaim_conversation *conv2; |
2200 GaimConversation *conv2; |
| 2207 |
2201 |
| 2208 win2 = (struct gaim_window *)wins->data; |
2202 win2 = (GaimWindow *)wins->data; |
| 2209 |
2203 |
| 2210 for (convs = gaim_window_get_conversations(win2); |
2204 for (convs = gaim_window_get_conversations(win2); |
| 2211 convs != NULL; |
2205 convs != NULL; |
| 2212 convs = convs->next) { |
2206 convs = convs->next) { |
| 2213 |
2207 |
| 2214 conv2 = (struct gaim_conversation *)convs->data; |
2208 conv2 = (GaimConversation *)convs->data; |
| 2215 |
2209 |
| 2216 if ((gaim_prefs_get_bool("/core/conversations/combine_chat_im") || |
2210 if ((gaim_prefs_get_bool("/core/conversations/combine_chat_im") || |
| 2217 type == gaim_conversation_get_type(conv2)) && |
2211 type == gaim_conversation_get_type(conv2)) && |
| 2218 account == gaim_conversation_get_account(conv2)) { |
2212 account == gaim_conversation_get_account(conv2)) { |
| 2219 |
2213 |
| 2227 /* Make a new window. */ |
2221 /* Make a new window. */ |
| 2228 conv_placement_new_window(conv); |
2222 conv_placement_new_window(conv); |
| 2229 } |
2223 } |
| 2230 |
2224 |
| 2231 static int |
2225 static int |
| 2232 add_conv_placement_fnc(const char *name, gaim_conv_placement_fnc fnc) |
2226 add_conv_placement_fnc(const char *name, GaimConvPlacementFunc fnc) |
| 2233 { |
2227 { |
| 2234 struct ConvPlacementData *data; |
2228 ConvPlacementData *data; |
| 2235 |
2229 |
| 2236 data = g_malloc0(sizeof(struct ConvPlacementData)); |
2230 data = g_malloc0(sizeof(ConvPlacementData)); |
| 2237 |
2231 |
| 2238 data->name = g_strdup(name); |
2232 data->name = g_strdup(name); |
| 2239 data->fnc = fnc; |
2233 data->fnc = fnc; |
| 2240 |
2234 |
| 2241 conv_placement_fncs = g_list_append(conv_placement_fncs, data); |
2235 conv_placement_fncs = g_list_append(conv_placement_fncs, data); |
| 2271 } |
2265 } |
| 2272 |
2266 |
| 2273 void |
2267 void |
| 2274 gaim_conv_placement_remove_fnc(int index) |
2268 gaim_conv_placement_remove_fnc(int index) |
| 2275 { |
2269 { |
| 2276 struct ConvPlacementData *data; |
2270 ConvPlacementData *data; |
| 2277 GList *node; |
2271 GList *node; |
| 2278 |
2272 |
| 2279 if (index < 0 || index > g_list_length(conv_placement_fncs)) |
2273 if (index < 0 || index > g_list_length(conv_placement_fncs)) |
| 2280 return; |
2274 return; |
| 2281 |
2275 |
| 2282 node = g_list_nth(conv_placement_fncs, index); |
2276 node = g_list_nth(conv_placement_fncs, index); |
| 2283 data = (struct ConvPlacementData *)node->data; |
2277 data = (ConvPlacementData *)node->data; |
| 2284 |
2278 |
| 2285 g_free(data->name); |
2279 g_free(data->name); |
| 2286 g_free(data); |
2280 g_free(data); |
| 2287 |
2281 |
| 2288 conv_placement_fncs = g_list_remove_link(conv_placement_fncs, node); |
2282 conv_placement_fncs = g_list_remove_link(conv_placement_fncs, node); |
| 2332 |
2326 |
| 2333 return data->fnc; |
2327 return data->fnc; |
| 2334 } |
2328 } |
| 2335 |
2329 |
| 2336 int |
2330 int |
| 2337 gaim_conv_placement_get_fnc_index(gaim_conv_placement_fnc fnc) |
2331 gaim_conv_placement_get_fnc_index(GaimConvPlacementFunc fnc) |
| 2338 { |
2332 { |
| 2339 struct ConvPlacementData *data; |
2333 ConvPlacementData *data; |
| 2340 GList *node; |
2334 GList *node; |
| 2341 int i; |
2335 int i; |
| 2342 |
2336 |
| 2343 ensure_default_funcs(); |
2337 ensure_default_funcs(); |
| 2344 |
2338 |
| 2345 for (node = conv_placement_fncs, i = 0; |
2339 for (node = conv_placement_fncs, i = 0; |
| 2346 node != NULL; |
2340 node != NULL; |
| 2347 node = node->next, i++) { |
2341 node = node->next, i++) { |
| 2348 |
2342 |
| 2349 data = (struct ConvPlacementData *)node->data; |
2343 data = (ConvPlacementData *)node->data; |
| 2350 |
2344 |
| 2351 if (data->fnc == fnc) |
2345 if (data->fnc == fnc) |
| 2352 return i; |
2346 return i; |
| 2353 } |
2347 } |
| 2354 |
2348 |