Mercurial > pidgin
comparison src/oscar.c @ 1064:b0b40b5faede
[gaim-migrate @ 1074]
for some things, the prpl needs to ask the user if they want to do something. i added a way of doing that to prpl.c. i also tweaked oscar.c to get it to use that system, as well as adding the beginnings of getfile support to oscar.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 04 Nov 2000 09:13:29 +0000 |
parents | 2c4f958c596e |
children | 81d19577285a |
comparison
equal
deleted
inserted
replaced
1063:e1408fb04c36 | 1064:b0b40b5faede |
---|---|
48 #include "pixmaps/admin_icon.xpm" | 48 #include "pixmaps/admin_icon.xpm" |
49 #include "pixmaps/aol_icon.xpm" | 49 #include "pixmaps/aol_icon.xpm" |
50 #include "pixmaps/away_icon.xpm" | 50 #include "pixmaps/away_icon.xpm" |
51 #include "pixmaps/dt_icon.xpm" | 51 #include "pixmaps/dt_icon.xpm" |
52 #include "pixmaps/free_icon.xpm" | 52 #include "pixmaps/free_icon.xpm" |
53 #include "pixmaps/ok.xpm" | |
54 #include "pixmaps/cancel.xpm" | |
55 | 53 |
56 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | | 54 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | |
57 AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; | 55 AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; |
58 | 56 |
59 struct oscar_data { | 57 struct oscar_data { |
74 struct gaim_connection *gc; | 72 struct gaim_connection *gc; |
75 char name[80]; | 73 char name[80]; |
76 struct conversation *cnv; | 74 struct conversation *cnv; |
77 int watcher; | 75 int watcher; |
78 struct aim_conn_t *conn; | 76 struct aim_conn_t *conn; |
77 }; | |
78 | |
79 struct ask_direct { | |
80 struct gaim_connection *gc; | |
81 char *sn; | |
82 struct aim_directim_priv *priv; | |
83 }; | |
84 | |
85 struct ask_getfile { | |
86 struct gaim_connection *gc; | |
87 char *sn; | |
88 char *cookie; | |
89 char *ip; | |
79 }; | 90 }; |
80 | 91 |
81 static struct direct_im *find_direct_im(struct oscar_data *od, char *who) { | 92 static struct direct_im *find_direct_im(struct oscar_data *od, char *who) { |
82 GSList *d = od->direct_ims; | 93 GSList *d = od->direct_ims; |
83 char *n = g_strdup(normalize(who)); | 94 char *n = g_strdup(normalize(who)); |
659 serv_got_update(gc, sn, 0, 0, 0, 0, 0, 0); | 670 serv_got_update(gc, sn, 0, 0, 0, 0, 0, 0); |
660 | 671 |
661 return 1; | 672 return 1; |
662 } | 673 } |
663 | 674 |
664 struct ask_direct { | 675 static void cancel_direct_im(gpointer w, struct ask_direct *d) { |
665 GtkWidget *window; | 676 debug_printf("Freeing DirectIM prompts.\n"); |
666 struct gaim_connection *gc; | 677 |
667 char *sn; | |
668 struct aim_directim_priv *priv; | |
669 }; | |
670 | |
671 static void cancel_direct_im(GtkWidget *w, struct ask_direct *d) { | |
672 gtk_widget_destroy(d->window); | |
673 g_free(d->sn); | 678 g_free(d->sn); |
674 g_free(d); | 679 g_free(d); |
675 } | 680 } |
676 | 681 |
677 static void delete_direct_im(GtkWidget *w, struct direct_im *d) { | 682 static void delete_direct_im(gpointer w, struct direct_im *d) { |
678 struct oscar_data *od = (struct oscar_data *)d->gc->proto_data; | 683 struct oscar_data *od = (struct oscar_data *)d->gc->proto_data; |
679 | 684 |
680 od->direct_ims = g_slist_remove(od->direct_ims, d); | 685 od->direct_ims = g_slist_remove(od->direct_ims, d); |
681 gdk_input_remove(d->watcher); | 686 gdk_input_remove(d->watcher); |
682 aim_conn_kill(od->sess, &d->conn); | 687 aim_conn_kill(od->sess, &d->conn); |
683 g_free(d); | 688 g_free(d); |
684 } | 689 } |
685 | 690 |
686 static void accept_direct_im(GtkWidget *w, struct ask_direct *d) { | 691 static int accept_direct_im(gpointer w, struct ask_direct *d) { |
687 struct gaim_connection *gc = d->gc; | 692 struct gaim_connection *gc = d->gc; |
688 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 693 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
689 struct direct_im *dim; | 694 struct direct_im *dim; |
690 | 695 |
696 debug_printf("Accepted DirectIM.\n"); | |
697 | |
691 dim = find_direct_im(od, d->sn); | 698 dim = find_direct_im(od, d->sn); |
692 if (dim) { | 699 if (dim) { |
693 gtk_widget_show(dim->cnv->window); | |
694 cancel_direct_im(w, d); /* 40 */ | 700 cancel_direct_im(w, d); /* 40 */ |
695 return; | 701 return; |
696 } | 702 } |
697 dim = g_new0(struct direct_im, 1); | 703 dim = g_new0(struct direct_im, 1); |
698 dim->gc = d->gc; | 704 dim->gc = d->gc; |
717 gaim_directim_disconnect, 0); | 723 gaim_directim_disconnect, 0); |
718 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | 724 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
719 gaim_directim_typing, 0); | 725 gaim_directim_typing, 0); |
720 | 726 |
721 cancel_direct_im(w, d); | 727 cancel_direct_im(w, d); |
722 } | 728 |
723 | 729 return TRUE; |
724 static void ask_direct_im(struct gaim_connection *gc, struct aim_userinfo_s *info, | 730 } |
725 struct aim_directim_priv *priv) { | 731 |
726 struct ask_direct *d = g_new0(struct ask_direct, 1); | 732 static void cancel_getfile(gpointer w, struct ask_getfile *g) { |
727 GtkWidget *window; | 733 g_free(g->ip); |
728 GtkWidget *box; | 734 g_free(g->cookie); |
729 GtkWidget *label; | 735 g_free(g->sn); |
730 GtkWidget *hbox; | 736 g_free(g); |
731 GtkWidget *button; | 737 } |
732 char buf[256]; | 738 |
733 | 739 static int accept_getfile(gpointer w, struct ask_getfile *g) { |
734 d->gc = gc; | 740 struct gaim_connection *gc = g->gc; |
735 d->sn = g_strdup(info->sn); | 741 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
736 d->priv = priv; | 742 struct aim_conn_t *newconn; |
737 | 743 |
738 window = gtk_window_new(GTK_WINDOW_DIALOG); | 744 /* |
739 gtk_window_set_wmclass(GTK_WINDOW(window), "directim", "Gaim"); | 745 if ((newconn = aim_accepttransfer(od->sess, od->conn, g->sn, g->cookie, g->ip, od->sess->oft.listing, AIM_CAPS_GETFILE)) == NULL) { |
740 gtk_window_set_policy(GTK_WINDOW(window), 0, 0, 1); | 746 cancel_getfile(w, g); |
741 gtk_window_set_title(GTK_WINDOW(window), _("Accept Direct IM?")); | 747 return; |
742 gtk_widget_realize(window); | 748 } |
743 aol_icon(window->window); | 749 */ |
744 d->window = window; | 750 |
745 | 751 do_error_dialog("getfile FIXME", "ha"); |
746 box = gtk_vbox_new(FALSE, 0); | 752 |
747 gtk_container_add(GTK_CONTAINER(window), box); | 753 cancel_getfile(w, g); |
748 gtk_widget_show(box); | 754 |
749 | 755 return TRUE; |
750 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", info->sn, gc->username); | |
751 label = gtk_label_new(buf); | |
752 gtk_box_pack_start(GTK_BOX(box), label, 0, 0, 5); | |
753 gtk_widget_show(label); | |
754 | |
755 hbox = gtk_hbox_new(FALSE, 0); | |
756 gtk_box_pack_start(GTK_BOX(box), hbox, 0, 0, 1); | |
757 gtk_widget_show(hbox); | |
758 | |
759 button = picture_button(window, _("Accept"), ok_xpm); | |
760 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
761 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(accept_direct_im), d); | |
762 | |
763 button = picture_button(window, _("Cancel"), cancel_xpm); | |
764 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
765 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_direct_im), d); | |
766 | |
767 gtk_widget_show(window); | |
768 } | 756 } |
769 | 757 |
770 int gaim_parse_incoming_im(struct aim_session_t *sess, | 758 int gaim_parse_incoming_im(struct aim_session_t *sess, |
771 struct command_rx_struct *command, ...) { | 759 struct command_rx_struct *command, ...) { |
772 int channel; | 760 int channel; |
813 roominfo->exchange, | 801 roominfo->exchange, |
814 userinfo->sn, | 802 userinfo->sn, |
815 msg); | 803 msg); |
816 } else if (rendtype & AIM_CAPS_SENDFILE) { | 804 } else if (rendtype & AIM_CAPS_SENDFILE) { |
817 } else if (rendtype & AIM_CAPS_GETFILE) { | 805 } else if (rendtype & AIM_CAPS_GETFILE) { |
806 char *ip, *cookie; | |
807 struct aim_conn_t *newconn; | |
808 struct ask_getfile *g = g_new0(struct ask_getfile, 1); | |
809 char buf[256]; | |
810 | |
811 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
812 ip = va_arg(ap, char *); | |
813 cookie = va_arg(ap, char *); | |
814 va_end(ap); | |
815 | |
816 debug_printf("%s received getfile request from %s (%s)\n", | |
817 gc->username, userinfo->sn, ip); | |
818 | |
819 g->gc = gc; | |
820 g->sn = g_strdup(userinfo->sn); | |
821 g->cookie = g_strdup(cookie); | |
822 g->ip = g_strdup(ip); | |
823 g_snprintf(buf, sizeof buf, "%s has just asked to get a file from %s.", | |
824 userinfo->sn, gc->username); | |
825 do_ask_dialog(buf, g, accept_getfile, cancel_getfile); | |
818 } else if (rendtype & AIM_CAPS_VOICE) { | 826 } else if (rendtype & AIM_CAPS_VOICE) { |
819 } else if (rendtype & AIM_CAPS_BUDDYICON) { | 827 } else if (rendtype & AIM_CAPS_BUDDYICON) { |
820 } else if (rendtype & AIM_CAPS_IMIMAGE) { | 828 } else if (rendtype & AIM_CAPS_IMIMAGE) { |
821 struct aim_directim_priv *priv; | 829 struct aim_directim_priv *priv; |
830 struct ask_direct *d = g_new0(struct ask_direct, 1); | |
831 char buf[256]; | |
822 | 832 |
823 userinfo = va_arg(ap, struct aim_userinfo_s *); | 833 userinfo = va_arg(ap, struct aim_userinfo_s *); |
824 priv = va_arg(ap, struct aim_directim_priv *); | 834 priv = va_arg(ap, struct aim_directim_priv *); |
825 va_end(ap); | 835 va_end(ap); |
826 | 836 |
827 debug_printf("%s received direct im request from %s (%s)\n", | 837 debug_printf("%s received direct im request from %s (%s)\n", |
828 gc->username, userinfo->sn, priv->ip); | 838 gc->username, userinfo->sn, priv->ip); |
829 | 839 |
830 ask_direct_im(gc, userinfo, priv); | 840 d->gc = gc; |
841 d->sn = g_strdup(userinfo->sn); | |
842 d->priv = priv; | |
843 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", | |
844 userinfo->sn, gc->username); | |
845 do_ask_dialog(buf, d, accept_direct_im, cancel_direct_im); | |
831 } else { | 846 } else { |
832 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); | 847 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); |
833 debug_print(debug_buff); | 848 debug_print(debug_buff); |
834 } | 849 } |
835 } | 850 } |
1606 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 1621 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
1607 struct direct_im *dim; | 1622 struct direct_im *dim; |
1608 | 1623 |
1609 dim = find_direct_im(od, who); | 1624 dim = find_direct_im(od, who); |
1610 if (dim) { | 1625 if (dim) { |
1611 gtk_widget_show(dim->cnv->window); | 1626 do_error_dialog("Direct IM request already pending.", "Unable"); |
1612 return; | 1627 return; |
1613 } | 1628 } |
1614 dim = g_new0(struct direct_im, 1); | 1629 dim = g_new0(struct direct_im, 1); |
1615 dim->gc = gc; | 1630 dim->gc = gc; |
1616 g_snprintf(dim->name, sizeof dim->name, "%s", who); | 1631 g_snprintf(dim->name, sizeof dim->name, "%s", who); |