diff src/aim.c @ 3726:d85208a99af2

[gaim-migrate @ 3862] (12:18:46) Robot101: it switches the .desktop file to the new KDE/GNOME common vfolder format (12:18:48) Robot101: and location (12:19:01) Robot101: and it moves a function from util.c to aim.c and makes it static (12:19:08) Robot101: because it's only used by the main window and removes a function herman #ifdef 0'ed, and fixes a segfault in the docklet. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 17 Oct 2002 16:25:54 +0000
parents d7e83b4db191
children 9bcb42faccc0
line wrap: on
line diff
--- a/src/aim.c	Thu Oct 17 05:06:15 2002 +0000
+++ b/src/aim.c	Thu Oct 17 16:25:54 2002 +0000
@@ -165,20 +165,44 @@
 	save_prefs();
 	serv_login(u);
 }
-#if 0
-static void dologin_all(GtkWidget *widget, GtkWidget *w)
+
+/* <name> is a comma-separated list of names, or NULL
+   if NULL and there is at least one user defined in .gaimrc, try to login.
+   if not NULL, parse <name> into separate strings, look up each one in 
+   .gaimrc and, if it's there, try to login.
+   returns:  0 if successful
+            -1 if no user was found that had a saved password
+*/
+static int dologin_named(char *name)
 {
 	struct aim_user *u;
-	GSList *users = aim_users;
+	char **names, **n;
+	int retval = -1;
 
-	while (users) {
-		u = users->data;
-		if (u->options & OPT_USR_AUTO)
+	if (name !=NULL) {	/* list of names given */
+		names = g_strsplit(name, ",", 32);
+		for (n = names; *n != NULL; n++) {
+			u = find_user(*n, -1);
+			if (u) {	/* found a user */
+				if (u->options & OPT_USR_REM_PASS) {
+					retval = 0;
+					serv_login(u);
+				}
+			}
+		}
+		g_strfreev(names);
+	} else {		/* no name given, use default */
+		u = (struct aim_user *)aim_users->data;
+		if (u->options & OPT_USR_REM_PASS) {
+			retval = 0;
 			serv_login(u);
-		users = users->next;
+		}
 	}
+
+	return retval;
 }
-#endif
+
+
 static void doenter(GtkWidget *widget, GtkWidget *w)
 {
 	if (widget == name) {
@@ -516,7 +540,7 @@
 int main(int argc, char *argv[])
 #endif
 {
-	int opt_acct = 0, opt_help = 0, opt_version = 0, opt_login = 0, opt_nologin = 0, do_login_ret = -1;
+	int opt_acct = 0, opt_help = 0, opt_version = 0, opt_login = 0, opt_nologin = 0, dologin_ret = -1;
 	char *opt_user_arg = NULL, *opt_login_arg = NULL;
 #if HAVE_SIGNAL_H
 	int sig_indx;	/* for setting up signal catching */
@@ -794,7 +818,7 @@
 
 	/* deal with --login */
 	if (opt_login) {
-		do_login_ret = do_auto_login(opt_login_arg);
+		dologin_ret = dologin_named(opt_login_arg);
 		if (opt_login_arg != NULL) {
 			g_free(opt_login_arg);
 			opt_login_arg = NULL;
@@ -806,7 +830,7 @@
 
 	if (opt_acct) {
 		account_editor(NULL, NULL);
-	} else if ((do_login_ret == -1) && !connections)
+	} else if ((dologin_ret == -1) && !connections)
 		show_login();
 #ifdef _WIN32
 	/* Various win32 initializations */