diff src/aim.c @ 960:fa681641643d

[gaim-migrate @ 970] *** MULTIPLE-CONNECTIONS *** committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 10 Oct 2000 00:02:02 +0000
parents 0c3bdd59f983
children 2cd7b73e2c9a
line wrap: on
line diff
--- a/src/aim.c	Mon Oct 09 23:56:33 2000 +0000
+++ b/src/aim.c	Tue Oct 10 00:02:02 2000 +0000
@@ -55,13 +55,6 @@
 #include "locale.h"
 #include "gtkticker.h"
 
-static GtkWidget *name;
-static GtkWidget *pass;
-static GtkWidget *signon;
-static GtkWidget *cancel;
-static GtkWidget *progress;
-static GtkWidget *notice;
-
 GList *permit = NULL;
 GList *deny = NULL;
 GList *log_conversations = NULL;
@@ -73,22 +66,16 @@
 GList *chat_rooms = NULL;
 
 GtkWidget *mainwindow = NULL;
-GtkWidget *remember = NULL;
 
 void BuddyTickerCreateWindow( void );
 
 char toc_addy[16];
 char *quad_addr = NULL;
 
-gboolean running = FALSE; /* whether or not we're currently trying to sign on */
-
 void cancel_logon(void)
 {
 #ifdef USE_APPLET
 	applet_buddy_show = FALSE;
-	if (running)
-		serv_close();
-	running = FALSE;
 	if (mainwindow)
 		gtk_widget_hide(mainwindow);
 #else
@@ -126,6 +113,7 @@
 
 void set_login_progress(int howfar, char *whattosay)
 {
+	/* FIXME: we should do this on a per-connection basis
 	gtk_progress_bar_update(GTK_PROGRESS_BAR(progress),
 				((float)howfar / (float)LOGIN_STEPS));
 	gtk_statusbar_pop(GTK_STATUSBAR(notice), 1);
@@ -133,10 +121,12 @@
 
         while (gtk_events_pending())
                gtk_main_iteration();
+	*/
 }
 
 void hide_login_progress(char *why)
 {
+	/* FIXME: we should do this on a per-connection basis
 	gtk_progress_bar_update(GTK_PROGRESS_BAR(progress),
 				0);
 	gtk_statusbar_pop(GTK_STATUSBAR(notice), 1);
@@ -144,6 +134,7 @@
 
         while (gtk_events_pending())
                gtk_main_iteration();
+	*/
 }
 
 static int snd_tmout;
@@ -153,60 +144,10 @@
 	gtk_timeout_remove(snd_tmout);
 }
 
-char g_screenname[ 64 ];	/* gotta be enough */
-
-void dologin(GtkWidget *widget, GtkWidget *w)
-{
-	char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry));
-        char *password = gtk_entry_get_text(GTK_ENTRY(pass));
-	int i;
-
-        if (query_state() != STATE_OFFLINE)
-                return;
-        
-	if (!strlen(username)) {
-		hide_login_progress(_("Please enter your logon"));
-		return;
-	}
-	if (!strlen(password)) {
-		hide_login_progress(_("You must give your password"));
-		return;
-	}
-
-	/* save screenname away for cache file use */
-
-	strcpy( g_screenname, username );
-
-	/* fold cache screen name file to upper case to avoid problems
-	   finding file later if user uses different case at login time */
-
-	for ( i = 0; i < strlen( g_screenname ); i++ )
-		g_screenname[i] = toupper( g_screenname[i] );
-
-#ifdef USE_APPLET
-	set_user_state(signing_on);
-#endif /* USE_APPLET */
-
-	if (running) return;
-	running = TRUE;
-
-        if (serv_login(username, password) < 0) {
-		running = FALSE;
-                return;
-	}
-
-	if (!USE_OSCAR) /* serv_login will set up USE_OSCAR */
-		gaim_setup();
-}
-
-void auth_failed() {
-	running = FALSE;
-}
-
 /* we need to do this for Oscar because serv_login only starts the login
  * process, it doesn't end there. gaim_setup will be called later from
  * oscar.c, after the buddy list is made and serv_finish_login is called */
-void gaim_setup() {
+void gaim_setup(struct gaim_connection *gc) {
 	if (sound_options & OPT_SOUND_LOGIN &&
 		sound_options & OPT_SOUND_SILENT_SIGNON) {
 		logins_not_muted = 0;
@@ -224,76 +165,24 @@
 			NULL);
 #endif /* USE_APPLET */
 
+	account_online(gc);
+
 	plugin_event(event_signon, 0, 0, 0);
 
-	 running = FALSE;
 	 return;
 }
 
 
 
 
-void doenter(GtkWidget *widget, GtkWidget *w)
-{
-	if (widget == name) {
-		gtk_entry_set_text(GTK_ENTRY(pass),"");
-		gtk_entry_select_region(GTK_ENTRY(GTK_COMBO(name)->entry), 0, 0);
-		gtk_widget_grab_focus(pass);
-	} else if (widget == pass) {
-		dologin(widget, w);
-	}
-
-}
-
-
-static void combo_changed(GtkWidget *w, GtkWidget *combo)
-{
-        char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
-        struct aim_user *u;
-        
-        if (!(general_options & OPT_GEN_REMEMBER_PASS)) {
-                return;
-        }
-
-        u = find_user(txt);
-
-        if (u != NULL) {
-                gtk_entry_set_text(GTK_ENTRY(pass), u->password);
-        } else {
-                gtk_entry_set_text(GTK_ENTRY(pass), "");
-        }
-       
-        return;
-}
-
-static GList *combo_user_names()
-{
-        GList *usr = aim_users;
-        GList *tmp = NULL;
-        struct aim_user *u;
-
-        
-        if (!usr)
-                return g_list_append(NULL, "<unknown>");
-        
-        while(usr) {
-                u = (struct aim_user *)usr->data;
-                tmp = g_list_append(tmp, g_strdup(u->username));
-                usr = usr->next;
-
-        }
-
-        return tmp;
-}
-
-
-
 void show_login()
 {
 	GtkWidget *options;
 #ifdef GAIM_PLUGINS
 	GtkWidget *plugs;
 #endif
+	GtkWidget *accts;
+	GtkWidget *cancel;
 	GtkWidget *reg;
 	GtkWidget *bbox;
 	GtkWidget *hbox;
@@ -310,8 +199,6 @@
 
         if (mainwindow) {
                 gtk_widget_show(mainwindow);
-		if (!(general_options & OPT_GEN_REMEMBER_PASS))
-			gtk_entry_set_text(GTK_ENTRY(pass), "");
                 return;
         }
        
@@ -322,7 +209,7 @@
         /* Disallow resizing */
         gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE);
 	gtk_widget_realize(mainwindow);
-	signon   = gtk_button_new_with_label(_("Signon"));
+	accts    = gtk_button_new_with_label(_("Accounts"));
 	cancel   = gtk_button_new_with_label(_("Cancel"));
 	reg      = gtk_button_new_with_label(_("Register"));
 	options  = gtk_button_new_with_label(_("Options"));
@@ -330,16 +217,10 @@
 	plugs    = gtk_button_new_with_label(_("Plugins")); 
 #endif
 	table    = gtk_table_new(8, 2, FALSE);
-	name     = gtk_combo_new();
-	pass     = gtk_entry_new();
-	notice   = gtk_statusbar_new();
-	progress = gtk_progress_bar_new();
-
-	gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names());
 
 	if (display_options & OPT_DISP_COOL_LOOK)
 	{
-		gtk_button_set_relief(GTK_BUTTON(signon), GTK_RELIEF_NONE);
+		gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE);
 		gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE);
 		gtk_button_set_relief(GTK_BUTTON(reg), GTK_RELIEF_NONE);
 		gtk_button_set_relief(GTK_BUTTON(options), GTK_RELIEF_NONE);
@@ -350,8 +231,8 @@
 
 	/* Make the buttons do stuff */
 	/* Clicking the button initiates a login */
-	gtk_signal_connect(GTK_OBJECT(signon), "clicked",
-			   GTK_SIGNAL_FUNC(dologin), mainwindow);
+	gtk_signal_connect(GTK_OBJECT(accts), "clicked",
+			   GTK_SIGNAL_FUNC(account_editor), mainwindow);
 	gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
 			   GTK_SIGNAL_FUNC(cancel_logon), mainwindow);
 	/* Allow user to change prefs before logging in */
@@ -366,16 +247,6 @@
 	/* Register opens the right URL */
 	gtk_signal_connect(GTK_OBJECT(reg), "clicked",
 			   GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no");
-	/* Enter in the username clears the password and sets
-	   the pointer in the password field */
-	gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate",
-                           GTK_SIGNAL_FUNC(doenter), mainwindow);
-
-        gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed",
-                           GTK_SIGNAL_FUNC(combo_changed), name);
-			   
-	gtk_signal_connect(GTK_OBJECT(pass), "activate",
-			   GTK_SIGNAL_FUNC(doenter), mainwindow);
 	gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event",
 			   GTK_SIGNAL_FUNC(cancel_logon), mainwindow);
 	/* Homogenous spacing, 10 padding */
@@ -385,70 +256,34 @@
 	
 	gtk_box_pack_start(GTK_BOX(bbox), reg, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0);
 
 	gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0);
 #ifdef GAIM_PLUGINS
 	gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0);
 #endif
 
+	gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0);
 
 	/* Labels for selectors and text boxes */
-#if 0	
-	label = gtk_label_new("TOC: ");
-	gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2,0,0, 5, 5);
-	gtk_widget_show(label);
-#endif
-	label = gtk_label_new(_("Screen Name: "));
-	gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3,0,0, 5, 5);
-	gtk_widget_show(label);
-	label = gtk_label_new(_("Password: "));
-	gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4,0,0, 5, 5);
-	gtk_widget_show(label);
-	remember = gtk_check_button_new_with_label(_("Remember Password"));
-	gtk_table_attach(GTK_TABLE(table), remember, 0,2,4,5,0,0, 5, 5);
-	gtk_widget_show(remember);
 
 	gtk_widget_show(options);
 #ifdef GAIM_PLUGINS
 	gtk_widget_show(plugs);
 #endif
 	
-        /* Adjust sizes of inputs */
-	gtk_widget_set_usize(name,100,0);
-	gtk_widget_set_usize(pass,100,0);
-
-
-	/* Status and label */
-	gtk_widget_show(notice);
-
-	gtk_widget_set_usize(progress,150,0);
-
-        gtk_widget_show(progress);
-
-        gtk_table_attach(GTK_TABLE(table), progress, 0, 2, 6, 7, 0, 0, 5, 5);
-	gtk_widget_set_usize(GTK_STATUSBAR(notice)->label, 150, 0);
-	gtk_table_attach(GTK_TABLE(table), notice, 0, 2, 8, 9, 0, 0, 5, 5);
-
 	/* Attach the buttons at the bottom */
-	gtk_widget_show(signon);
 	gtk_widget_show(cancel);
 	gtk_widget_show(reg);
+	gtk_widget_show(accts);
 	gtk_widget_show(bbox);
 	gtk_widget_show(hbox);
 	gtk_widget_show(sbox);
+	gtk_table_attach(GTK_TABLE(table), accts, 0,2,6,7,0,0, 5, 5);
 	gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5);
 	
 	/* Text fields */
 	
-	gtk_table_attach(GTK_TABLE(table),name,1,2,2,3,0,0,5,5);
-	gtk_widget_show(name);
-	gtk_table_attach(GTK_TABLE(table),pass,1,2,3,4,0,0,5,5);
-	gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE);
-	gtk_widget_show(pass);
-	
 	gtk_container_border_width(GTK_CONTAINER(sbox), 10);	 
 	
 	gtk_container_add(GTK_CONTAINER(mainwindow),table );
@@ -456,25 +291,6 @@
 	gtk_widget_show(table);
         gtk_window_set_title(GTK_WINDOW(mainwindow),_("Gaim - Login"));
 
-        gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(remember), (general_options & OPT_GEN_REMEMBER_PASS));
-
-	if (current_user) {
-		sprintf(debug_buff, "Current user is %s\n", current_user->username);
-		debug_print(debug_buff);
-		gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(name)->entry), current_user->username);
-		if ((general_options & OPT_GEN_REMEMBER_PASS)) {
-			combo_changed(NULL, name);
-			gtk_widget_grab_focus(signon);
-		} else {
-			gtk_widget_grab_focus(pass);
-		}
-	} else {
-		gtk_widget_grab_focus(name);
-	}
-
-
-	gtk_signal_connect(GTK_OBJECT(remember), "clicked", GTK_SIGNAL_FUNC(set_general_option), (int *)OPT_GEN_REMEMBER_PASS);
-
 
         gtk_widget_realize(mainwindow);
 
@@ -501,10 +317,12 @@
 
 	SetTickerPrefs();
 	
+	/*
         if((general_options & OPT_GEN_AUTO_LOGIN) &&
            (general_options & OPT_GEN_REMEMBER_PASS)) {
 		dologin(signon, NULL);
 	}
+	*/
 }
 
 extern void show_debug(GtkObject *);
@@ -591,6 +409,7 @@
         
 
         show_login();
+	auto_login();
         gtk_main();
         
 #endif /* USE_APPLET */