changeset 1355:04874e92af24

[gaim-migrate @ 1365] better handling of new user for probably use in reg dialog. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 22 Dec 2000 03:55:47 +0000
parents 6b0a7cea1dd1
children c22d04db51be
files src/aim.c src/multi.c src/multi.h src/prpl.c src/prpl.h
diffstat 5 files changed, 38 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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;
+}
--- 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 *);
 
--- 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);
 }
--- 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