comparison plugins/irc.c @ 1075:2fe18b2d6105

[gaim-migrate @ 1085] rock on committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 07 Nov 2000 12:13:02 +0000
parents bde34730789c
children f0f5c10cce63
comparison
equal deleted inserted replaced
1074:2cff18c2f9c6 1075:2fe18b2d6105
41 #include "gnome_applet_mgr.h" 41 #include "gnome_applet_mgr.h"
42 42
43 #include "pixmaps/cancel.xpm" 43 #include "pixmaps/cancel.xpm"
44 #include "pixmaps/ok.xpm" 44 #include "pixmaps/ok.xpm"
45 45
46 /* FIXME: We shouldn't have hard coded servers and ports :-) */
47 #define IRC_SERVER "irc.mozilla.org"
48 #define IRC_PORT 6667
49
50 #define IRC_BUF_LEN 4096 46 #define IRC_BUF_LEN 4096
51 47
52 48
53 static int chat_id = 0; 49 static int chat_id = 0;
54 50
833 set_login_progress(gc, 1, buf); 829 set_login_progress(gc, 1, buf);
834 830
835 while (gtk_events_pending()) 831 while (gtk_events_pending())
836 gtk_main_iteration(); 832 gtk_main_iteration();
837 833
838 host = gethostbyname(IRC_SERVER); 834 host = gethostbyname(user->proto_opt[0]);
839 if (!host) { 835 if (!host) {
840 hide_login_progress(gc, "Unable to resolve hostname"); 836 hide_login_progress(gc, "Unable to resolve hostname");
841 destroy_gaim_conn(gc); 837 destroy_gaim_conn(gc);
842 return; 838 return;
843 } 839 }
844 840
845 site.sin_family = AF_INET; 841 site.sin_family = AF_INET;
846 site.sin_addr.s_addr = *(long *)(host->h_addr); 842 site.sin_addr.s_addr = *(long *)(host->h_addr);
847 site.sin_port = htons(IRC_PORT); 843 site.sin_port = htons(atoi(user->proto_opt[1]));
848 844
849 fd = socket(AF_INET, SOCK_STREAM, 0); 845 fd = socket(AF_INET, SOCK_STREAM, 0);
850 if (fd < 0) { 846 if (fd < 0) {
851 hide_login_progress(gc, "Unable to create socket"); 847 hide_login_progress(gc, "Unable to create socket");
852 destroy_gaim_conn(gc); 848 destroy_gaim_conn(gc);
887 883
888 /* But first, let's go ahead and check our list */ 884 /* But first, let's go ahead and check our list */
889 irc_request_buddy_update(gc); 885 irc_request_buddy_update(gc);
890 } 886 }
891 887
888 static void irc_print_option(GtkEntry *entry, struct aim_user *user) {
889 if (gtk_object_get_user_data(GTK_OBJECT(entry))) {
890 g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s",
891 gtk_entry_get_text(entry));
892 } else {
893 g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s",
894 gtk_entry_get_text(entry));
895 }
896 }
897
898 static void irc_user_opts(GtkWidget *book, struct aim_user *user) {
899 /* so here, we create the new notebook page */
900 GtkWidget *vbox;
901 GtkWidget *hbox;
902 GtkWidget *label;
903 GtkWidget *entry;
904
905 vbox = gtk_vbox_new(FALSE, 0);
906 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox,
907 gtk_label_new("IRC Options"));
908 gtk_widget_show(vbox);
909
910 hbox = gtk_hbox_new(FALSE, 0);
911 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
912 gtk_widget_show(hbox);
913
914 label = gtk_label_new("Server:");
915 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
916 gtk_widget_show(label);
917
918 entry = gtk_entry_new();
919 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
920 gtk_signal_connect(GTK_OBJECT(entry), "changed",
921 GTK_SIGNAL_FUNC(irc_print_option), user);
922 if (user->proto_opt[0][0]) {
923 debug_printf("setting text %s\n", user->proto_opt[0]);
924 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]);
925 }
926 gtk_widget_show(entry);
927
928 hbox = gtk_hbox_new(FALSE, 0);
929 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
930 gtk_widget_show(hbox);
931
932 label = gtk_label_new("Port:");
933 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
934 gtk_widget_show(label);
935
936 entry = gtk_entry_new();
937 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
938 if (user->proto_opt[1][0]) {
939 debug_printf("setting text %s\n", user->proto_opt[1]);
940 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]);
941 }
942 gtk_object_set_user_data(GTK_OBJECT(entry), user);
943 gtk_signal_connect(GTK_OBJECT(entry), "changed",
944 GTK_SIGNAL_FUNC(irc_print_option), user);
945 gtk_widget_show(entry);
946 }
947
892 static struct prpl *my_protocol = NULL; 948 static struct prpl *my_protocol = NULL;
893 949
894 void irc_init(struct prpl *ret) { 950 void irc_init(struct prpl *ret) {
895 ret->protocol = PROTO_IRC; 951 ret->protocol = PROTO_IRC;
896 ret->name = irc_name; 952 ret->name = irc_name;
953 ret->user_opts = irc_user_opts;
897 ret->login = irc_login; 954 ret->login = irc_login;
898 ret->close = irc_close; 955 ret->close = irc_close;
899 ret->send_im = irc_send_im; 956 ret->send_im = irc_send_im;
900 ret->set_info = NULL; 957 ret->set_info = NULL;
901 ret->get_info = NULL; 958 ret->get_info = NULL;