Mercurial > pidgin.yaz
changeset 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 | 2cff18c2f9c6 |
children | 58b98132b4a6 |
files | plugins/irc.c src/buddy.c src/gaim.h src/multi.c src/prpl.h |
diffstat | 5 files changed, 204 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/irc.c Tue Nov 07 09:27:32 2000 +0000 +++ b/plugins/irc.c Tue Nov 07 12:13:02 2000 +0000 @@ -43,10 +43,6 @@ #include "pixmaps/cancel.xpm" #include "pixmaps/ok.xpm" -/* FIXME: We shouldn't have hard coded servers and ports :-) */ -#define IRC_SERVER "irc.mozilla.org" -#define IRC_PORT 6667 - #define IRC_BUF_LEN 4096 @@ -835,7 +831,7 @@ while (gtk_events_pending()) gtk_main_iteration(); - host = gethostbyname(IRC_SERVER); + host = gethostbyname(user->proto_opt[0]); if (!host) { hide_login_progress(gc, "Unable to resolve hostname"); destroy_gaim_conn(gc); @@ -844,7 +840,7 @@ site.sin_family = AF_INET; site.sin_addr.s_addr = *(long *)(host->h_addr); - site.sin_port = htons(IRC_PORT); + site.sin_port = htons(atoi(user->proto_opt[1])); fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { @@ -889,11 +885,72 @@ irc_request_buddy_update(gc); } +static void irc_print_option(GtkEntry *entry, struct aim_user *user) { + if (gtk_object_get_user_data(GTK_OBJECT(entry))) { + g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s", + gtk_entry_get_text(entry)); + } else { + g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s", + gtk_entry_get_text(entry)); + } +} + +static void irc_user_opts(GtkWidget *book, struct aim_user *user) { + /* so here, we create the new notebook page */ + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *entry; + + vbox = gtk_vbox_new(FALSE, 0); + gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, + gtk_label_new("IRC Options")); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + label = gtk_label_new("Server:"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(label); + + entry = gtk_entry_new(); + gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(entry), "changed", + GTK_SIGNAL_FUNC(irc_print_option), user); + if (user->proto_opt[0][0]) { + debug_printf("setting text %s\n", user->proto_opt[0]); + gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]); + } + gtk_widget_show(entry); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + label = gtk_label_new("Port:"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(label); + + entry = gtk_entry_new(); + gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); + if (user->proto_opt[1][0]) { + debug_printf("setting text %s\n", user->proto_opt[1]); + gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]); + } + gtk_object_set_user_data(GTK_OBJECT(entry), user); + gtk_signal_connect(GTK_OBJECT(entry), "changed", + GTK_SIGNAL_FUNC(irc_print_option), user); + gtk_widget_show(entry); +} + static struct prpl *my_protocol = NULL; void irc_init(struct prpl *ret) { ret->protocol = PROTO_IRC; ret->name = irc_name; + ret->user_opts = irc_user_opts; ret->login = irc_login; ret->close = irc_close; ret->send_im = irc_send_im;
--- a/src/buddy.c Tue Nov 07 09:27:32 2000 +0000 +++ b/src/buddy.c Tue Nov 07 12:13:02 2000 +0000 @@ -1601,6 +1601,7 @@ } static void update_idle_time(struct buddy_show *bs) { + /* this also updates the tooltip since that has idle time in it */ char idlet[16]; time_t t; int ihrs, imin;
--- a/src/gaim.h Tue Nov 07 09:27:32 2000 +0000 +++ b/src/gaim.h Tue Nov 07 12:13:02 2000 +0000 @@ -139,6 +139,7 @@ /* stuff for modify window */ GtkWidget *mod; + GtkWidget *main; GtkWidget *name; GtkWidget *pass; int tmp_options;
--- a/src/multi.c Tue Nov 07 09:27:32 2000 +0000 +++ b/src/multi.c Tue Nov 07 12:13:02 2000 +0000 @@ -38,6 +38,7 @@ static GtkWidget *acctedit = NULL; static GtkWidget *list = NULL; /* the clist of names in the accteditor */ static GtkWidget *newmod = NULL; /* the dialog for creating a new account */ +static GtkWidget *newmain = NULL; /* the frame that holds the possible notebook for options */ static struct aim_user tmpusr; struct mod_usr_opt { @@ -227,11 +228,8 @@ gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(u->protocol)); } else { char *titles[4]; + int i; txt = gtk_entry_get_text(GTK_ENTRY(tmpusr.name)); - if (find_user(txt, tmpusr.protocol)) { - gtk_widget_destroy(newmod); - return; - } u = g_new0(struct aim_user, 1); g_snprintf(u->username, sizeof(u->username), "%s", txt); txt = gtk_entry_get_text(GTK_ENTRY(tmpusr.pass)); @@ -246,6 +244,8 @@ i = gtk_clist_append(GTK_CLIST(list), titles); gtk_clist_set_row_data(GTK_CLIST(list), i, u); aim_users = g_list_append(aim_users, u); + for (i = 0; i < 6; i++) + g_snprintf(u->proto_opt[i], sizeof(u->proto_opt[i]), "%s", tmpusr.proto_opt[i]); } save_prefs(); } @@ -259,25 +259,30 @@ } } +static void generate_options(struct aim_user *, GtkWidget *); + static void set_prot(GtkWidget *opt, int proto) { struct aim_user *u = gtk_object_get_user_data(GTK_OBJECT(opt)); if (u) { u->tmp_protocol = proto; + generate_options(u, u->main); } else { - tmpusr.protocol = proto; + tmpusr.tmp_protocol = tmpusr.protocol = proto; + generate_options(NULL, newmain); } } -static GtkWidget *make_protocol_menu(GtkWidget *box, struct aim_user *u) +static GtkWidget *make_protocol_menu(GtkWidget *box, struct aim_user *u, GtkWidget *frame) { GtkWidget *optmenu; GtkWidget *menu; GtkWidget *opt; GSList *p = protocols; struct prpl *e; + int count = 0; + gboolean found = FALSE; - /* PRPL: should we set some way to update these when new protocols get added? */ optmenu = gtk_option_menu_new(); gtk_box_pack_start(GTK_BOX(box), optmenu, FALSE, FALSE, 5); gtk_widget_show(optmenu); @@ -286,6 +291,17 @@ while (p) { e = (struct prpl *)p->data; + if (u) { + if (e->protocol == u->tmp_protocol) + found = TRUE; + if (!found) + count++; + } else { + if (e->protocol == tmpusr.tmp_protocol) + found = TRUE; + if (!found) + count++; + } if (e->name) opt = gtk_menu_item_new_with_label((*e->name)()); else @@ -299,59 +315,71 @@ } gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); - if (u) { - gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), u->protocol); - u->tmp_protocol = u->protocol; - } else { - gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), - ((struct prpl *)protocols->data)->protocol); - } + gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), count); return optmenu; } -static void show_acct_mod(struct aim_user *u) -{ - /* here we can have all the aim_user options, including ones not shown in the main acctedit - * window. this can keep the size of the acctedit window small and readable, and make this - * one the powerful editor. this is where things like name/password are edited, but can - * also have toggles (and even more complex options) like whether to autologin or whether - * to send keepalives or whatever. this would be the perfect place to specify which protocol - * to use. make sure to account for the possibility of protocol plugins. */ - GtkWidget *mod; - GtkWidget *frame; +static void generate_options(struct aim_user *u, GtkWidget *frame) { + GList *tmp; + GtkWidget *book; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *label; GtkWidget *name; GtkWidget *pass; - GtkWidget *button; + struct prpl *p; + + tmp = gtk_container_children(GTK_CONTAINER(frame)); + + if (u) + p = find_prpl(u->tmp_protocol); + else + p = find_prpl(tmpusr.protocol); - if (!u && newmod) { - gtk_widget_show(newmod); - return; - } - if (u && u->mod) { - gtk_widget_show(u->mod); - return; - } + if (p && p->user_opts) { + if (tmp && !GTK_IS_NOTEBOOK(tmp->data)) { + gtk_widget_destroy(tmp->data); + tmp = NULL; + } + + if (!tmp) { + book = gtk_notebook_new(); + gtk_container_add(GTK_CONTAINER(frame), book); + gtk_widget_show(book); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, + gtk_label_new(_("General Options"))); + gtk_widget_show(vbox); - mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_wmclass(GTK_WINDOW(mod), "account", "Gaim"); - gtk_widget_realize(mod); - aol_icon(mod->window); - gtk_container_border_width(GTK_CONTAINER(mod), 10); - gtk_window_set_title(GTK_WINDOW(mod), _("Gaim - Modify Account")); - gtk_signal_connect(GTK_OBJECT(mod), "destroy", - GTK_SIGNAL_FUNC(delmod), u); + if (u) + (*p->user_opts)(book, u); + else + (*p->user_opts)(book, &tmpusr); + } else { + book = (GtkWidget *)tmp->data; + gtk_notebook_remove_page(GTK_NOTEBOOK(book), 1); + if (u) + (*p->user_opts)(book, u); + else + (*p->user_opts)(book, &tmpusr); + return; + } + } else { + if (tmp && GTK_IS_NOTEBOOK(tmp->data)) { + gtk_widget_destroy(tmp->data); + tmp = NULL; + } - frame = gtk_frame_new(_("Modify Account")); - gtk_container_add(GTK_CONTAINER(mod), frame); - gtk_widget_show(frame); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(frame), vbox); - gtk_widget_show(vbox); + if (!tmp) { + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + } else { + return; + } + } hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); @@ -382,14 +410,71 @@ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); gtk_widget_show(hbox); - make_protocol_menu(hbox, u); + make_protocol_menu(hbox, u, frame); acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox); acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox); acct_button(_("Send KeepAlive packet (6 bytes/second)"), u, OPT_USR_KEEPALV, vbox); + if (u) { + u->name = name; + u->pass = pass; + gtk_entry_set_text(GTK_ENTRY(name), u->username); + gtk_entry_set_text(GTK_ENTRY(pass), u->password); + gtk_entry_set_editable(GTK_ENTRY(name), FALSE); + } else { + tmpusr.name = name; + tmpusr.pass = pass; + } +} + +static void show_acct_mod(struct aim_user *u) +{ + /* here we can have all the aim_user options, including ones not shown in the main acctedit + * window. this can keep the size of the acctedit window small and readable, and make this + * one the powerful editor. this is where things like name/password are edited, but can + * also have toggles (and even more complex options) like whether to autologin or whether + * to send keepalives or whatever. this would be the perfect place to specify which protocol + * to use. make sure to account for the possibility of protocol plugins. */ + GtkWidget *mod; + GtkWidget *box; + GtkWidget *frame; + GtkWidget *hbox; + GtkWidget *button; + + if (!u && newmod) { + gtk_widget_show(newmod); + return; + } + if (u && u->mod) { + gtk_widget_show(u->mod); + return; + } + + mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass(GTK_WINDOW(mod), "account", "Gaim"); + gtk_widget_realize(mod); + aol_icon(mod->window); + gtk_container_border_width(GTK_CONTAINER(mod), 10); + gtk_window_set_title(GTK_WINDOW(mod), _("Gaim - Modify Account")); + gtk_window_set_policy(GTK_WINDOW(mod), 0, 1, 1); /* i know, i'm odd */ + gtk_signal_connect(GTK_OBJECT(mod), "destroy", + GTK_SIGNAL_FUNC(delmod), u); + + box = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(mod), box); + gtk_widget_show(box); + + frame = gtk_frame_new(_("Modify Account")); + gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5); + gtk_widget_show(frame); + + if (u) u->tmp_protocol = u->protocol; + else tmpusr.tmp_protocol = tmpusr.protocol; + generate_options(u, frame); + hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); gtk_widget_show(hbox); button = picture_button(mod, _("Cancel"), cancel_xpm); @@ -404,16 +489,11 @@ if (u) { u->mod = mod; - u->name = name; - u->pass = pass; + u->main = frame; /* ha, get it? :) */ u->tmp_options = u->options; - gtk_entry_set_text(GTK_ENTRY(name), u->username); - gtk_entry_set_text(GTK_ENTRY(pass), u->password); - gtk_entry_set_editable(GTK_ENTRY(name), FALSE); } else { newmod = mod; - tmpusr.name = name; - tmpusr.pass = pass; + newmain = frame; } gtk_widget_show(mod);
--- a/src/prpl.h Tue Nov 07 09:27:32 2000 +0000 +++ b/src/prpl.h Tue Nov 07 12:13:02 2000 +0000 @@ -43,6 +43,8 @@ char **(* list_icon)(int); /* returns a GtkMenu * for use in the buddy list */ void (* action_menu)(GtkWidget *, struct gaim_connection *, char *); + /* fuck UI plugins */ + void (* user_opts)(GtkWidget *, struct aim_user *); void (* login) (struct aim_user *); void (* close) (struct gaim_connection *);