comparison src/server.c @ 964:2cd7b73e2c9a

[gaim-migrate @ 974] damn i'm smooth. chat is working now. :) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 10 Oct 2000 10:04:59 +0000
parents e006338ce34e
children 9eb07b383df4
comparison
equal deleted inserted replaced
963:c1fb7afe4fd7 964:2cd7b73e2c9a
32 #include <gtk/gtk.h> 32 #include <gtk/gtk.h>
33 #include <aim.h> 33 #include <aim.h>
34 extern int gaim_caps; 34 extern int gaim_caps;
35 #include "multi.h" 35 #include "multi.h"
36 #include "gaim.h" 36 #include "gaim.h"
37
38 #include "pixmaps/ok.xpm"
39 #include "pixmaps/cancel.xpm"
37 40
38 int correction_time = 0; 41 int correction_time = 0;
39 42
40 struct gaim_connection *serv_login(char *username, char *password) 43 struct gaim_connection *serv_login(char *username, char *password)
41 { 44 {
509 g_free(buf); 512 g_free(buf);
510 } 513 }
511 } 514 }
512 515
513 516
514 void serv_accept_chat(int i) 517 void serv_accept_chat(struct gaim_connection *g, int i)
515 { 518 {
516 /* FIXME */
517 struct gaim_connection *g = connections->data;
518 if (g->protocol == PROTO_TOC) { 519 if (g->protocol == PROTO_TOC) {
519 char *buf = g_malloc(256); 520 char *buf = g_malloc(256);
520 g_snprintf(buf, 255, "toc_chat_accept %d", i); 521 g_snprintf(buf, 255, "toc_chat_accept %d", i);
521 sflap_send(g, buf, -1, TYPE_DATA); 522 sflap_send(g, buf, -1, TYPE_DATA);
522 g_free(buf); 523 g_free(buf);
523 } else if (g->protocol == PROTO_OSCAR) { 524 } else if (g->protocol == PROTO_OSCAR) {
524 /* this should never get called because libfaim doesn't use the id 525 /* this should never get called because libfaim doesn't use the id
525 * (i'm not even sure Oscar does). go through serv_join_chat instead */ 526 * (i'm not even sure Oscar does). go through serv_join_chat instead */
526 } 527 }
527 } 528 }
528 529
529 void serv_join_chat(int exchange, char *name) 530 void serv_join_chat(struct gaim_connection *g, int exchange, char *name)
530 { 531 {
531 /* FIXME */
532 struct gaim_connection *g = connections->data;
533 if (g->protocol == PROTO_TOC) { 532 if (g->protocol == PROTO_TOC) {
534 char buf[BUF_LONG]; 533 char buf[BUF_LONG];
535 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); 534 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name);
536 sflap_send(g, buf, -1, TYPE_DATA); 535 sflap_send(g, buf, -1, TYPE_DATA);
537 } else if (g->protocol == PROTO_OSCAR) { 536 } else if (g->protocol == PROTO_OSCAR) {
549 aim_bos_reqservice(g->oscar_sess, g->oscar_conn, AIM_CONN_TYPE_CHATNAV); 548 aim_bos_reqservice(g->oscar_sess, g->oscar_conn, AIM_CONN_TYPE_CHATNAV);
550 } 549 }
551 } 550 }
552 } 551 }
553 552
554 void serv_chat_invite(int id, char *message, char *name) 553 void serv_chat_invite(struct gaim_connection *g, int id, char *message, char *name)
555 { 554 {
556 /* FIXME */
557 struct gaim_connection *g = connections->data;
558 if (g->protocol == PROTO_TOC) { 555 if (g->protocol == PROTO_TOC) {
559 char buf[BUF_LONG]; 556 char buf[BUF_LONG];
560 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); 557 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name));
561 sflap_send(g, buf, -1, TYPE_DATA); 558 sflap_send(g, buf, -1, TYPE_DATA);
562 } else if (g->protocol == PROTO_OSCAR) { 559 } else if (g->protocol == PROTO_OSCAR) {
563 GList *bcs = buddy_chats; 560 GSList *bcs = g->buddy_chats;
564 struct conversation *b = NULL; 561 struct conversation *b = NULL;
565 562
566 while (bcs) { 563 while (bcs) {
567 b = (struct conversation *)bcs->data; 564 b = (struct conversation *)bcs->data;
568 if (id == b->id) 565 if (id == b->id)
576 573
577 aim_chat_invite(g->oscar_sess, g->oscar_conn, name, message, 0x4, b->name, 0x1); 574 aim_chat_invite(g->oscar_sess, g->oscar_conn, name, message, 0x4, b->name, 0x1);
578 } 575 }
579 } 576 }
580 577
581 void serv_chat_leave(int id) 578 void serv_chat_leave(struct gaim_connection *g, int id)
582 { 579 {
583 /* FIXME */
584 struct gaim_connection *g = connections->data;
585 if (g->protocol == PROTO_TOC) { 580 if (g->protocol == PROTO_TOC) {
586 char *buf = g_malloc(256); 581 char *buf = g_malloc(256);
587 g_snprintf(buf, 255, "toc_chat_leave %d", id); 582 g_snprintf(buf, 255, "toc_chat_leave %d", id);
588 sflap_send(g, buf, -1, TYPE_DATA); 583 sflap_send(g, buf, -1, TYPE_DATA);
589 g_free(buf); 584 g_free(buf);
590 } else if (g->protocol == PROTO_OSCAR) { 585 } else if (g->protocol == PROTO_OSCAR) {
591 GList *bcs = buddy_chats; 586 GSList *bcs = g->buddy_chats;
592 struct conversation *b = NULL; 587 struct conversation *b = NULL;
593 struct chat_connection *c = NULL; 588 struct chat_connection *c = NULL;
594 int count = 0; 589 int count = 0;
595 590
596 while (bcs) { 591 while (bcs) {
617 aim_conn_kill(g->oscar_sess, &c->conn); 612 aim_conn_kill(g->oscar_sess, &c->conn);
618 g_free(c->name); 613 g_free(c->name);
619 g_free(c); 614 g_free(c);
620 } 615 }
621 /* we do this because with Oscar it doesn't tell us we left */ 616 /* we do this because with Oscar it doesn't tell us we left */
622 serv_got_chat_left(b->id); 617 serv_got_chat_left(g, b->id);
623 } 618 }
624 } 619 }
625 620
626 void serv_chat_whisper(int id, char *who, char *message) 621 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message)
627 { 622 {
628 /* FIXME */
629 struct gaim_connection *g = connections->data;
630 if (g->protocol == PROTO_TOC) { 623 if (g->protocol == PROTO_TOC) {
631 char buf2[MSG_LEN]; 624 char buf2[MSG_LEN];
632 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); 625 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message);
633 sflap_send(g, buf2, -1, TYPE_DATA); 626 sflap_send(g, buf2, -1, TYPE_DATA);
634 } else if (g->protocol == PROTO_OSCAR) { 627 } else if (g->protocol == PROTO_OSCAR) {
635 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)", 628 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)",
636 "Gaim - Chat"); 629 "Gaim - Chat");
637 } 630 }
638 } 631 }
639 632
640 void serv_chat_send(int id, char *message) 633 void serv_chat_send(struct gaim_connection *g, int id, char *message)
641 { 634 {
642 /* FIXME */
643 struct gaim_connection *g = connections->data;
644 if (g->protocol == PROTO_TOC) { 635 if (g->protocol == PROTO_TOC) {
645 char buf[MSG_LEN]; 636 char buf[MSG_LEN];
646 escape_text(message); 637 escape_text(message);
647 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); 638 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message);
648 sflap_send(g, buf, -1, TYPE_DATA); 639 sflap_send(g, buf, -1, TYPE_DATA);
649 } else if (g->protocol == PROTO_OSCAR) { 640 } else if (g->protocol == PROTO_OSCAR) {
650 struct aim_conn_t *cn; 641 struct aim_conn_t *cn;
651 GList *bcs = buddy_chats; 642 GSList *bcs = g->buddy_chats;
652 struct conversation *b = NULL; 643 struct conversation *b = NULL;
653 644
654 while (bcs) { 645 while (bcs) {
655 b = (struct conversation *)bcs->data; 646 b = (struct conversation *)bcs->data;
656 if (id == b->id) 647 if (id == b->id)
899 gtk_widget_destroy(w2); 890 gtk_widget_destroy(w2);
900 } 891 }
901 892
902 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) 893 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2)
903 { 894 {
904 /* FIXME */ 895 struct gaim_connection *g = (struct gaim_connection *)
905 struct gaim_connection *g = connections->data; 896 gtk_object_get_user_data(GTK_OBJECT(GTK_DIALOG(w2)->vbox));
906 if (g->protocol == PROTO_TOC) { 897 if (g->protocol == PROTO_TOC) {
907 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); 898 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2));
908 serv_accept_chat(i); 899 serv_accept_chat(g, i);
909 gtk_widget_destroy(w2); 900 gtk_widget_destroy(w2);
910 } else if (g->protocol == PROTO_OSCAR) { 901 } else if (g->protocol == PROTO_OSCAR) {
911 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); 902 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2));
912 int id = (int)gtk_object_get_user_data(GTK_OBJECT(w)); 903 int id = (int)gtk_object_get_user_data(GTK_OBJECT(w));
913 serv_join_chat(id, i); 904 serv_join_chat(g, id, i);
914 g_free(i); 905 g_free(i);
915 gtk_widget_destroy(w2); 906 gtk_widget_destroy(w2);
916 } 907 }
917 } 908 }
918 909
919 910
920 911
921 void serv_got_chat_invite(char *name, int id, char *who, char *message) 912 void serv_got_chat_invite(struct gaim_connection *g, char *name, int id, char *who, char *message)
922 { 913 {
923 GtkWidget *d; 914 GtkWidget *d;
924 GtkWidget *label; 915 GtkWidget *label;
925 GtkWidget *yesbtn; 916 GtkWidget *yesbtn;
926 GtkWidget *nobtn; 917 GtkWidget *nobtn;
927 918
928 char buf2[BUF_LONG]; 919 char buf2[BUF_LONG];
929 /* FIXME */
930 struct gaim_connection *g = connections->data;
931 920
932 921
933 plugin_event(event_chat_invited, who, name, message); 922 plugin_event(event_chat_invited, who, name, message);
934 923
935 if (message) 924 if (message)
936 g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n%s", who, name, message); 925 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n%s", who, g->username, name, message);
937 else 926 else
938 g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n", who, name); 927 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n", who, g->username, name);
939 928
940 d = gtk_dialog_new(); 929 d = gtk_dialog_new();
941 gtk_widget_realize(d); 930 gtk_widget_realize(d);
942 aol_icon(d->window); 931 aol_icon(d->window);
943 932
944 933
945 label = gtk_label_new(buf2); 934 label = gtk_label_new(buf2);
946 gtk_widget_show(label); 935 gtk_widget_show(label);
947 yesbtn = gtk_button_new_with_label("Yes"); 936 yesbtn = picture_button(d, _("Yes"), ok_xpm);
948 gtk_widget_show(yesbtn); 937 nobtn = picture_button(d, _("No"), cancel_xpm);
949 nobtn = gtk_button_new_with_label("No");
950 gtk_widget_show(nobtn); 938 gtk_widget_show(nobtn);
951 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), 939 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox),
952 label, FALSE, FALSE, 5); 940 label, FALSE, FALSE, 5);
953 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), 941 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area),
954 yesbtn, FALSE, FALSE, 5); 942 yesbtn, FALSE, FALSE, 5);
955 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), 943 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area),
956 nobtn, FALSE, FALSE, 5); 944 nobtn, FALSE, FALSE, 5);
957 945
958 if (display_options & OPT_DISP_COOL_LOOK) 946 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g);
959 gtk_button_set_relief(GTK_BUTTON(yesbtn), GTK_RELIEF_NONE); 947 if (g->protocol == PROTO_TOC) {
960 if (display_options & OPT_DISP_COOL_LOOK)
961 gtk_button_set_relief(GTK_BUTTON(nobtn), GTK_RELIEF_NONE);
962
963 /* gtk_widget_set_usize(d, 200, 110); */
964
965 if (g->protocol == PROTO_TOC)
966 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); 948 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id);
967 else if (g->protocol == PROTO_OSCAR) { 949 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g);
950 } else if (g->protocol == PROTO_OSCAR) {
968 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); 951 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name));
969 gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id); 952 gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id);
970 } else { 953 } else {
971 /* PRPL */ 954 /* PRPL */
972 } 955 }
978 961
979 962
980 gtk_widget_show(d); 963 gtk_widget_show(d);
981 } 964 }
982 965
983 void serv_got_joined_chat(int id, char *name) 966 void serv_got_joined_chat(struct gaim_connection *gc, int id, char *name)
984 { 967 {
985 struct conversation *b; 968 struct conversation *b;
986 969
987 plugin_event(event_chat_join, name, 0, 0); 970 plugin_event(event_chat_join, name, 0, 0);
988 971
989 b = (struct conversation *)g_new0(struct conversation, 1); 972 b = (struct conversation *)g_new0(struct conversation, 1);
990 buddy_chats = g_list_append(buddy_chats, b); 973 gc->buddy_chats = g_slist_append(gc->buddy_chats, b);
991 974
992 b->is_chat = TRUE; 975 b->is_chat = TRUE;
993 b->ignored = NULL; 976 b->ignored = NULL;
994 b->in_room = NULL; 977 b->in_room = NULL;
995 b->id = id; 978 b->id = id;
979 b->gc = gc;
996 g_snprintf(b->name, 80, "%s", name); 980 g_snprintf(b->name, 80, "%s", name);
997 981
998 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) { 982 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) {
999 FILE *fd; 983 FILE *fd;
1000 char *filename; 984 char *filename;
1013 } 997 }
1014 998
1015 show_new_buddy_chat(b); 999 show_new_buddy_chat(b);
1016 } 1000 }
1017 1001
1018 void serv_got_chat_left(int id) 1002 void serv_got_chat_left(struct gaim_connection *g, int id)
1019 { 1003 {
1020 GList *bcs = buddy_chats; 1004 GSList *bcs = g->buddy_chats;
1021 struct conversation *b = NULL; 1005 struct conversation *b = NULL;
1022 1006
1023 1007
1024 while(bcs) { 1008 while(bcs) {
1025 b = (struct conversation *)bcs->data; 1009 b = (struct conversation *)bcs->data;
1036 plugin_event(event_chat_leave, b->name, 0, 0); 1020 plugin_event(event_chat_leave, b->name, 0, 0);
1037 1021
1038 sprintf(debug_buff, "Leaving room %s.\n", b->name); 1022 sprintf(debug_buff, "Leaving room %s.\n", b->name);
1039 debug_print(debug_buff); 1023 debug_print(debug_buff);
1040 1024
1041 buddy_chats = g_list_remove(buddy_chats, b); 1025 g->buddy_chats = g_slist_remove(g->buddy_chats, b);
1042 1026
1043 g_free(b); 1027 g_free(b);
1044 } 1028 }
1045 1029
1046 void serv_got_chat_in(int id, char *who, int whisper, char *message) 1030 void serv_got_chat_in(struct gaim_connection *g, int id, char *who, int whisper, char *message)
1047 { 1031 {
1048 int w; 1032 int w;
1049 GList *bcs = buddy_chats; 1033 GSList *bcs = g->buddy_chats;
1050 struct conversation *b = NULL; 1034 struct conversation *b = NULL;
1051 1035
1052 while(bcs) { 1036 while(bcs) {
1053 b = (struct conversation *)bcs->data; 1037 b = (struct conversation *)bcs->data;
1054 if (id == b->id) 1038 if (id == b->id)