comparison src/server.c @ 3517:6b0cb60162f4

[gaim-migrate @ 3590] Rob McQueen added a mute feature to his nice little docklet. I added a queuing feature. Configure the docklet in the plugins dialog to queue unread messages, and when you receive a message the docklet will eat it up and show a little message pending icon. Click on it, and read your message. ICQ people will like it. I also made plugin_event use a va_list. I bet this breaks perl. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 16 Sep 2002 08:35:24 +0000
parents e23909729192
children f3981f94494a
comparison
equal deleted inserted replaced
3516:db00eb77997d 3517:6b0cb60162f4
53 return; 53 return;
54 } 54 }
55 55
56 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", user->username, p->name()); 56 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", user->username, p->name());
57 user->connecting = TRUE; 57 user->connecting = TRUE;
58 plugin_event(event_connecting, user, 0, 0, 0); 58 connecting_count++;
59 plugin_event(event_connecting, user);
59 p->login(user); 60 p->login(user);
60 } 61 }
61 } 62 }
62 63
63 static gboolean send_keepalive(gpointer d) 64 static gboolean send_keepalive(gpointer d)
205 strncpy_nohtml(buf, message, strlen(message) + 1); 206 strncpy_nohtml(buf, message, strlen(message) + 1);
206 } 207 }
207 208
208 gc->prpl->set_away(gc, state, buf); 209 gc->prpl->set_away(gc, state, buf);
209 210
210 plugin_event(event_away, gc, state, buf, 0); 211 plugin_event(event_away, gc, state, buf);
211 212
212 if (buf) 213 if (buf)
213 g_free(buf); 214 g_free(buf);
214 } 215 }
215 216
229 } 230 }
230 231
231 void serv_set_info(struct gaim_connection *g, char *info) 232 void serv_set_info(struct gaim_connection *g, char *info)
232 { 233 {
233 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_info) { 234 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_info) {
234 if (plugin_event(event_set_info, g, info, 0, 0)) 235 if (plugin_event(event_set_info, g, info))
235 return; 236 return;
236 g->prpl->set_info(g, info); 237 g->prpl->set_info(g, info);
237 } 238 }
238 } 239 }
239 240
521 * bitch all you want; i really don't want you to be dealing with it. */ 522 * bitch all you want; i really don't want you to be dealing with it. */
522 if (len < 0) { 523 if (len < 0) {
523 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); 524 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG));
524 strcpy(buffy, message); 525 strcpy(buffy, message);
525 angel = g_strdup(name); 526 angel = g_strdup(name);
526 plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, (void *)&flags); 527 plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, &flags);
527 528
528 if (!buffy || !angel || plugin_return) { 529 if (!buffy || !angel || plugin_return) {
529 if (buffy) 530 if (buffy)
530 g_free(buffy); 531 g_free(buffy);
531 if (angel) 532 if (angel)
685 g_free(tmpmsg); 686 g_free(tmpmsg);
686 } else { 687 } else {
687 /* we're not away. this is easy. if the convo window doesn't exist, create and update 688 /* we're not away. this is easy. if the convo window doesn't exist, create and update
688 * it (if it does exist it was updated earlier), then play a sound indicating we've 689 * it (if it does exist it was updated earlier), then play a sound indicating we've
689 * received it and then display it. easy. */ 690 * received it and then display it. easy. */
690 if (cnv == NULL) { 691 if (away_options & OPT_AWAY_QUEUE_UNREAD && !find_conversation(name)) {
691 cnv = new_conversation(name); 692 /* We're gonna queue it up and wait for the user to ask for it... probably
692 set_convo_gc(cnv, gc); 693 * by clicking the docklet or windows tray icon. */
693 } 694 struct queued_message *qm;
694 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) 695 qm = g_new0(struct queued_message, 1);
695 play_sound(SND_FIRST_RECEIVE); 696 g_snprintf(qm->name, sizeof(qm->name), "%s", name);
696 else if (cnv->makesound) 697 qm->message = g_strdup(message);
697 play_sound(SND_RECEIVE); 698 qm->gc = gc;
698 699 qm->tm = mtime;
699 set_convo_name(cnv, name); 700 qm->flags = away | WFLAG_RECV;
700 701 qm->len = len;
701 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len); 702 unread_message_queue = g_slist_append(unread_message_queue, qm);
702 } 703 } else {
703 704 if (cnv == NULL) {
704 plugin_event(event_im_displayed_rcvd, gc, name, message, (void *)flags); 705 cnv = new_conversation(name);
706 set_convo_gc(cnv, gc);
707 }
708 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV))
709 play_sound(SND_FIRST_RECEIVE);
710 else if (cnv->makesound)
711 play_sound(SND_RECEIVE);
712
713 set_convo_name(cnv, name);
714
715 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len);
716 }
717 }
718 plugin_event(event_im_displayed_rcvd, gc, name, message, flags, mtime);
705 g_free(name); 719 g_free(name);
706 g_free(message); 720 g_free(message);
707 } 721 }
708 722
709 723
737 handle_buddy_rename(b, who); 751 handle_buddy_rename(b, who);
738 g_free(who); 752 g_free(who);
739 } 753 }
740 754
741 if (!b->idle && idle) { 755 if (!b->idle && idle) {
742 plugin_event(event_buddy_idle, gc, b->name, 0, 0); 756 plugin_event(event_buddy_idle, gc, b->name);
743 system_log(log_idle, gc, b, OPT_LOG_BUDDY_IDLE); 757 system_log(log_idle, gc, b, OPT_LOG_BUDDY_IDLE);
744 } 758 }
745 if (b->idle && !idle) { 759 if (b->idle && !idle) {
746 do_pounce(gc, b->name, OPT_POUNCE_UNIDLE); 760 do_pounce(gc, b->name, OPT_POUNCE_UNIDLE);
747 plugin_event(event_buddy_unidle, gc, b->name, 0, 0); 761 plugin_event(event_buddy_unidle, gc, b->name);
748 system_log(log_unidle, gc, b, OPT_LOG_BUDDY_IDLE); 762 system_log(log_unidle, gc, b, OPT_LOG_BUDDY_IDLE);
749 } 763 }
750 764
751 b->idle = idle; 765 b->idle = idle;
752 b->evil = evil; 766 b->evil = evil;
753 767
754 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { 768 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) {
755 do_pounce(gc, b->name, OPT_POUNCE_UNAWAY); 769 do_pounce(gc, b->name, OPT_POUNCE_UNAWAY);
756 plugin_event(event_buddy_back, gc, b->name, 0, 0); 770 plugin_event(event_buddy_back, gc, b->name);
757 system_log(log_back, gc, b, OPT_LOG_BUDDY_AWAY); 771 system_log(log_back, gc, b, OPT_LOG_BUDDY_AWAY);
758 } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) { 772 } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) {
759 plugin_event(event_buddy_away, gc, b->name, 0, 0); 773 plugin_event(event_buddy_away, gc, b->name);
760 system_log(log_away, gc, b, OPT_LOG_BUDDY_AWAY); 774 system_log(log_away, gc, b, OPT_LOG_BUDDY_AWAY);
761 } 775 }
762 776
763 b->uc = type; 777 b->uc = type;
764 if (caps) 778 if (caps)
768 782
769 if (loggedin) { 783 if (loggedin) {
770 if (!b->present) { 784 if (!b->present) {
771 b->present = 1; 785 b->present = 1;
772 do_pounce(gc, b->name, OPT_POUNCE_SIGNON); 786 do_pounce(gc, b->name, OPT_POUNCE_SIGNON);
773 plugin_event(event_buddy_signon, gc, b->name, 0, 0); 787 plugin_event(event_buddy_signon, gc, b->name);
774 system_log(log_signon, gc, b, OPT_LOG_BUDDY_SIGNON); 788 system_log(log_signon, gc, b, OPT_LOG_BUDDY_SIGNON);
775 } 789 }
776 } else { 790 } else {
777 if (b->present) { 791 if (b->present) {
778 plugin_event(event_buddy_signoff, gc, b->name, 0, 0); 792 plugin_event(event_buddy_signoff, gc, b->name);
779 system_log(log_signoff, gc, b, OPT_LOG_BUDDY_SIGNON); 793 system_log(log_signoff, gc, b, OPT_LOG_BUDDY_SIGNON);
780 } 794 }
781 b->present = 0; 795 b->present = 0;
782 } 796 }
783 797
787 801
788 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) 802 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev)
789 { 803 {
790 char buf2[1024]; 804 char buf2[1024];
791 805
792 plugin_event(event_warned, gc, name, (void *)lev, 0); 806 plugin_event(event_warned, gc, name, lev);
793 807
794 if (gc->evil >= lev) { 808 if (gc->evil >= lev) {
795 gc->evil = lev; 809 gc->evil = lev;
796 return; 810 return;
797 } 811 }
808 struct conversation *cnv = find_conversation(name); 822 struct conversation *cnv = find_conversation(name);
809 if (cnv) { 823 if (cnv) {
810 set_convo_gc(cnv, gc); 824 set_convo_gc(cnv, gc);
811 show_typing(cnv); 825 show_typing(cnv);
812 } else return; 826 } else return;
813 plugin_event(event_got_typing, gc, name, 0, 0); 827 plugin_event(event_got_typing, gc, name);
814 do_pounce(gc, name, OPT_POUNCE_TYPING); 828 do_pounce(gc, name, OPT_POUNCE_TYPING);
815 if (timeout > 0) { 829 if (timeout > 0) {
816 if (cnv->typing_timeout) 830 if (cnv->typing_timeout)
817 gtk_timeout_remove (cnv->typing_timeout); 831 gtk_timeout_remove (cnv->typing_timeout);
818 cnv->typing_timeout = gtk_timeout_add(timeout * 1000,(GtkFunction)reset_typing, 832 cnv->typing_timeout = gtk_timeout_add(timeout * 1000,(GtkFunction)reset_typing,
914 928
915 struct conversation *serv_got_joined_chat(struct gaim_connection *gc, int id, char *name) 929 struct conversation *serv_got_joined_chat(struct gaim_connection *gc, int id, char *name)
916 { 930 {
917 struct conversation *b; 931 struct conversation *b;
918 932
919 plugin_event(event_chat_join, gc, (void *)id, name, 0); 933 plugin_event(event_chat_join, gc, id, name);
920 934
921 b = (struct conversation *)g_new0(struct conversation, 1); 935 b = (struct conversation *)g_new0(struct conversation, 1);
922 gc->buddy_chats = g_slist_append(gc->buddy_chats, b); 936 gc->buddy_chats = g_slist_append(gc->buddy_chats, b);
923 chats = g_list_append(chats, b); 937 chats = g_list_append(chats, b);
924 938
973 } 987 }
974 988
975 if (!b) 989 if (!b)
976 return; 990 return;
977 991
978 plugin_event(event_chat_leave, g, (void *)b->id, 0, 0); 992 plugin_event(event_chat_leave, g, b->id);
979 993
980 debug_printf("Leaving room %s.\n", b->name); 994 debug_printf("Leaving room %s.\n", b->name);
981 995
982 g->buddy_chats = g_slist_remove(g->buddy_chats, b); 996 g->buddy_chats = g_slist_remove(g->buddy_chats, b);
983 997
1012 * bitch all you want; i really don't want you to be dealing with it. */ 1026 * bitch all you want; i really don't want you to be dealing with it. */
1013 1027
1014 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); 1028 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG));
1015 strcpy(buffy, message); 1029 strcpy(buffy, message);
1016 angel = g_strdup(who); 1030 angel = g_strdup(who);
1017 plugin_return = plugin_event(event_chat_recv, g, (void *)b->id, &angel, &buffy); 1031 plugin_return = plugin_event(event_chat_recv, g, b->id, &angel, &buffy);
1018 1032
1019 if (!buffy || !angel || plugin_return) { 1033 if (!buffy || !angel || plugin_return) {
1020 if (buffy) 1034 if (buffy)
1021 g_free(buffy); 1035 g_free(buffy);
1022 if (angel) 1036 if (angel)