# HG changeset patch # User Eric Warmenhoven # Date 977457347 0 # Node ID 04874e92af246f24096990bd4ed173121b465eaa # Parent 6b0a7cea1dd17fd1e1fda4657c4af334df602774 [gaim-migrate @ 1365] better handling of new user for probably use in reg dialog. committer: Tailor Script diff -r 6b0a7cea1dd1 -r 04874e92af24 src/aim.c --- a/src/aim.c Fri Dec 22 03:14:27 2000 +0000 +++ b/src/aim.c Fri Dec 22 03:55:47 2000 +0000 @@ -155,13 +155,8 @@ /* if there is more than one user of the same name, then fuck them, they just have * to use the account editor to sign in the second one */ u = find_user(username, -1); - if (!u) { - u = g_new0(struct aim_user, 1); - g_snprintf(u->username, sizeof(u->username), "%s", username); - u->protocol = PROTO_TOC; - u->options = OPT_USR_REM_PASS; - aim_users = g_list_append(aim_users, u); - } + if (!u) + u = new_user(username, PROTO_TOC, OPT_USR_REM_PASS); g_snprintf(u->password, sizeof u->password, "%s", password); save_prefs(); serv_login(u); diff -r 6b0a7cea1dd1 -r 04874e92af24 src/multi.c --- a/src/multi.c Fri Dec 22 03:14:27 2000 +0000 +++ b/src/multi.c Fri Dec 22 03:55:47 2000 +0000 @@ -227,6 +227,7 @@ { char *txt; int i; + if (u) { u->options = u->tmp_options; u->protocol = u->tmp_protocol; @@ -241,25 +242,16 @@ (u->options & OPT_USR_AUTO) ? "True" : "False"); 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)); - u = g_new0(struct aim_user, 1); - g_snprintf(u->username, sizeof(u->username), "%s", txt); + u = new_user(txt, tmpusr.protocol, tmpusr.options); + txt = gtk_entry_get_text(GTK_ENTRY(tmpusr.pass)); g_snprintf(u->password, sizeof(u->password), "%s", txt); - u->options = tmpusr.options; - u->protocol = tmpusr.protocol; - gtk_widget_destroy(newmod); - titles[0] = u->username; - titles[1] = u->gc ? "Yes" : "No"; - titles[2] = (u->options & OPT_USR_AUTO) ? "True" : "False"; - titles[3] = proto_name(u->protocol); - 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]); + + gtk_widget_destroy(newmod); } save_prefs(); } @@ -841,3 +833,26 @@ gtk_widget_destroy(gc->meter); gc->meter = NULL; } + +struct aim_user *new_user(char *name, int proto, int opts) +{ + char *titles[4]; + int i; + + struct aim_user *u = g_new0(struct aim_user, 1); + g_snprintf(u->username, sizeof(u->username), "%s", name); + u->protocol = proto; + u->options = opts; + aim_users = g_list_append(aim_users, u); + + if (list) { + titles[0] = u->username; + titles[1] = u->gc ? "Yes" : "No"; + titles[2] = (u->options & OPT_USR_AUTO) ? "True" : "False"; + titles[3] = proto_name(u->protocol); + i = gtk_clist_append(GTK_CLIST(list), titles); + gtk_clist_set_row_data(GTK_CLIST(list), i, u); + } + + return u; +} diff -r 6b0a7cea1dd1 -r 04874e92af24 src/multi.h --- a/src/multi.h Fri Dec 22 03:14:27 2000 +0000 +++ b/src/multi.h Fri Dec 22 03:55:47 2000 +0000 @@ -71,6 +71,7 @@ /* now that we have our struct, we're going to need lots of them. Maybe even a list of them. */ extern GSList *connections; +struct aim_user *new_user(char *, int, int); struct gaim_connection *new_gaim_conn(struct aim_user *); void destroy_gaim_conn(struct gaim_connection *); diff -r 6b0a7cea1dd1 -r 04874e92af24 src/prpl.c --- a/src/prpl.c Fri Dec 22 03:14:27 2000 +0000 +++ b/src/prpl.c Fri Dec 22 03:55:47 2000 +0000 @@ -158,11 +158,15 @@ } } -static void reg_prpl(gpointer a, struct prpl *p) +void prepare_regbox_for_next() { while (GTK_BOX(regbox)->children) gtk_container_remove(GTK_CONTAINER(regbox), ((GtkBoxChild *)GTK_BOX(regbox)->children->data)->widget); +} + +static void reg_prpl(gpointer a, struct prpl *p) +{ regprpl = p; (*regprpl->draw_new_user)(regbox); } diff -r 6b0a7cea1dd1 -r 04874e92af24 src/prpl.h --- a/src/prpl.h Fri Dec 22 03:14:27 2000 +0000 +++ b/src/prpl.h Fri Dec 22 03:55:47 2000 +0000 @@ -108,6 +108,7 @@ struct prpl *find_prpl(int); void register_user(gpointer, gpointer); +void prepare_regbox_for_next(); void do_ask_dialog(const char *, void *, void *, void *); #endif