changeset 6106:99f4bbeb27bc

[gaim-migrate @ 6567] Fix Cae non-fatal bug 6: "no notification of incorrect password/name." Also removed some unused code from gtkconn.c and multi.c (which was derelict). Make dialog and request windows show the titles that are passed to them. Fixed a compiler warning coughsean'sawaymessagestuffcough I'm looking forward to writting a NEWS entry for 0.65, I hope it will be soon :-) committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 13 Jul 2003 09:34:48 +0000
parents 786adff640e1
children 38410dac4ac2
files src/connection.c src/gtkconn.c src/gtknotify.c src/main.c src/multi.c src/notify.c src/protocols/gg/gg.c src/protocols/icq/gaim_icq.c src/protocols/jabber/jabber.c
diffstat 9 files changed, 25 insertions(+), 453 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/connection.c	Sun Jul 13 09:34:48 2003 +0000
@@ -30,6 +30,7 @@
 #include "request.h"
 #include "server.h"
 #include "sound.h"
+#include "util.h"
 
 static GList *connections = NULL;
 static GList *connections_connecting = NULL;
@@ -364,10 +365,19 @@
 gaim_connection_error(GaimConnection *gc, const char *text)
 {
 	GaimConnectionUiOps *ops;
+	gchar *primary, *secondary;
 
 	g_return_if_fail(gc   != NULL);
 	g_return_if_fail(text != NULL);
 
+	primary = g_strdup_printf(_("%s has been disconnected"),
+				gaim_account_get_username(gaim_connection_get_account(gc)));
+	secondary = g_strdup_printf("%s\n%s", full_date(),
+								text ? text : _("Reason Unknown."));
+	gaim_notify_error(NULL, _("Connection Error"), primary, secondary);
+	g_free(primary);
+	g_free(secondary);
+
 	ops = gaim_get_connection_ui_ops();
 
 	if (ops != NULL && ops->disconnected != NULL)
--- a/src/gtkconn.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/gtkconn.c	Sun Jul 13 09:34:48 2003 +0000
@@ -22,7 +22,6 @@
 
 #include "account.h"
 #include "debug.h"
-#include "notify.h"
 #include "util.h"
 
 #include "gtkblist.h"
@@ -334,96 +333,3 @@
 	}
 	return;
 }
-
-#if 0
-struct kick_dlg {
-	GaimAccount *account;
-	GtkWidget *dlg;
-};
-static GSList *kicks = NULL;
-
-static struct kick_dlg *find_kick_dlg(GaimAccount *account)
-{
-	GSList *k = kicks;
-	while (k) {
-		struct kick_dlg *d = k->data;
-		if (d->account == account)
-			return d;
-		k = k->next;
-	}
-	return NULL;
-}
-
-static void set_kick_null(struct kick_dlg *k)
-{
-	kicks = g_slist_remove(kicks, k);
-	g_free(k);
-}
-
-/*
- * Common code for hide_login_progress(), and hide_login_progress_info()
- */
-static void hide_login_progress_common(GaimConnection *gc,
-				       char *details,
-				       char *title,
-				       char *prologue)
-{
-	gchar *buf;
-	struct kick_dlg *k = find_kick_dlg(gc->account);
-	struct signon_meter *meter = find_signon_meter(gc);
-	buf = g_strdup_printf(_("%s\n%s: %s"), full_date(), prologue, details);
-	if (k)
-		gtk_widget_destroy(k->dlg);
-	k = g_new0(struct kick_dlg, 1);
-	k->account = gc->account;
-	k->dlg = gaim_notify_message(NULL, GAIM_NOTIFY_MSG_ERROR, NULL,
-								 title, buf, G_CALLBACK(set_kick_null), k);
-	kicks = g_slist_append(kicks, k);
-	if (meter) {
-		kill_meter(meter, _("Done."));
-		meter_win->meters = g_slist_remove(meter_win->meters, meter);
-		g_free(meter);
-	}
-	g_free(buf);
-}
-
-static void hide_login_progress(GaimConnection *gc, char *why)
-{
-	GaimAccount *account = gaim_connection_get_account(gc);
-	gchar *buf;
-
-	gaim_event_broadcast(event_error, gc, why);
-	buf = g_strdup_printf(_("%s was unable to sign on"),
-						  gaim_account_get_username(account));
-	hide_login_progress_common(gc, why, _("Signon Error"), buf);
-	g_free(buf);
-}
-
-/*
- * Like hide_login_progress(), but for informational, not error/warning,
- * messages.
- *
- */
-static void hide_login_progress_notice(GaimConnection *gc, char *why)
-{
-	GaimAccount *account = gaim_connection_get_account(gc);
-
-	hide_login_progress_common(gc, why, _("Notice"),
-							   (char *)gaim_account_get_username(account));
-}
-
-/*
- * Like hide_login_progress(), but for non-signon error messages.
- *
- */
-static void hide_login_progress_error(GaimConnection *gc, char *why)
-{
-	char buf[2048];
-	GaimAccount *account = gaim_connection_get_account(gc);
-
-	gaim_event_broadcast(event_error, gc, why);
-	g_snprintf(buf, sizeof(buf), _("%s has been signed off"),
-			   gaim_account_get_username(account));
-	hide_login_progress_common(gc, why, _("Connection Error"), buf);
-}
-#endif
--- a/src/gtknotify.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/gtknotify.c	Sun Jul 13 09:34:48 2003 +0000
@@ -95,7 +95,7 @@
 		gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 	}
 
-	dialog = gtk_dialog_new_with_buttons("", NULL, 0,
+	dialog = gtk_dialog_new_with_buttons(title, NULL, 0,
 										 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
 										 NULL);
 	g_signal_connect(G_OBJECT(dialog), "response",
--- a/src/main.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/main.c	Sun Jul 13 09:34:48 2003 +0000
@@ -31,6 +31,7 @@
 #include "prpl.h"
 #include "pounce.h"
 #include "sound.h"
+#include "status.h"
 #include "util.h"
 
 //#include "gaim.h"
--- a/src/multi.c	Sun Jul 13 08:20:42 2003 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
- * gaim
- *
- * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <gtk/gtk.h>
-#include "prpl.h"
-#include "multi.h"
-#include "gaim.h"
-#include "conversation.h"
-#include "notify.h"
-#include "gtkblist.h"
-#include "gaim-disclosure.h"
-
-#ifdef _WIN32
-#include "win32dep.h"
-#endif
-
-#define LOGIN_STEPS 5
-
-enum
-{
-	COLUMN_SCREENNAME,
-	COLUMN_ONLINE,
-	COLUMN_AUTOLOGIN,
-	COLUMN_PROTOCOL,
-	COLUMN_DATA,
-	NUM_COLUMNS
-};
-
-struct meter_window {
-		GtkWidget *window;
-		GtkTable *table;
-		gint rows;
-		gint active_count;
-	} *meter_win = NULL;
-
-struct signon_meter {
-	GaimConnection *gc;
-	GtkWidget *button;
-	GtkWidget *progress;
-	GtkWidget *status;
-};
-static GSList *meters = NULL;
-
-GtkWidget* create_meter_pixmap (GaimConnection *gc)
-{
-	GdkPixbuf *pb = create_prpl_icon(gc->account);
-	GdkPixbuf *scale = gdk_pixbuf_scale_simple(pb, 30,30,GDK_INTERP_BILINEAR);
-	GtkWidget *image =
-		gtk_image_new_from_pixbuf(scale);
-	g_object_unref(G_OBJECT(pb));
-	g_object_unref(G_OBJECT(scale));
-	return image;
-}
-
-static struct signon_meter *find_signon_meter(GaimConnection *gc)
-{
-	GSList *m = meters;
-	while (m) {
-		if (((struct signon_meter *)m->data)->gc == gc)
-			return m->data;
-		m = m->next;
-	}
-	return NULL;
-}
-
-void kill_meter(struct signon_meter *meter) {
-	gtk_widget_set_sensitive (meter->button, FALSE);
-	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), 1);
-	gtk_statusbar_pop(GTK_STATUSBAR(meter->status), 1);
-	gtk_statusbar_push(GTK_STATUSBAR(meter->status), 1, _("Done."));
-	meter_win->active_count--;
-	if (meter_win->active_count == 0) {
-		gtk_widget_destroy(meter_win->window);
-		g_free (meter_win);
-		meter_win = NULL;
-	}
-}
-
-void away_on_login(char *mesg)
-{
-	GSList *awy = away_messages;
-	struct away_message *a, *message = NULL;
-	struct gaim_gtk_buddy_list *gtkblist;
-
-	gtkblist = GAIM_GTK_BLIST(gaim_get_blist());
-
-	if (!gtkblist->window) {
-		return;
-	}
-
-	if (mesg == NULL) {
-		/* Use default message */
-		do_away_message(NULL, default_away);
-	} else {
-		/* Use argument */
-		while (awy) {
-			a = (struct away_message *)awy->data;
-			if (strcmp(a->name, mesg) == 0) {
-				message = a;
-				break;
-			}
-			awy = awy->next;
-		}
-		if (message == NULL)
-			message = default_away;
-		do_away_message(NULL, message);
-	}
-	return;
-}
-
-static void cancel_signon(GtkWidget *button, struct signon_meter *meter)
-{
-	meter->gc->wants_to_die = TRUE;
-	gaim_connection_destroy(meter->gc);
-}
-
-static gint meter_destroy(GtkWidget *window, GdkEvent *evt, struct signon_meter *meter)
-{
-	return TRUE;
-}
-
-static struct signon_meter *
-register_meter(GaimConnection *gc, GtkWidget *widget,
-			   GtkTable *table, gint *rows)
-{
-	GaimAccount *account;
-	GtkWidget *graphic;
-	GtkWidget *label;
-	GtkWidget *nest_vbox;
-	GString *name_to_print;
-	struct signon_meter *meter;
-
-	account = gaim_connection_get_account(gc);
-
-	name_to_print = g_string_new(gaim_account_get_username(account));
-
-	meter = g_new0(struct signon_meter, 1);
-
-	(*rows)++;
-	gtk_table_resize (table, *rows, 4);
-
-	graphic = create_meter_pixmap(gc);
-
-	nest_vbox = gtk_vbox_new (FALSE, 0);
-
-	g_string_prepend(name_to_print, _("Signon: "));
-	label = gtk_label_new (name_to_print->str);
-	g_string_free(name_to_print, TRUE);
-	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
-	meter->status = gtk_statusbar_new();
-	gtk_widget_set_size_request(meter->status, 250, -1);
-
-	meter->progress = gtk_progress_bar_new ();
-
-	meter->button = gaim_pixbuf_button_from_stock (_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL);
-	g_signal_connect(G_OBJECT (meter->button), "clicked",
-					 G_CALLBACK (cancel_signon), meter);
-
-	gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
-	gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
-		gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0);
-		gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0);
-	gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
-	gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
-
-	gtk_widget_show_all (GTK_WIDGET (meter_win->window));
-
-	meter_win->active_count++;
-
-	return meter;
-}
-
-static void loop_cancel () {
-	GSList *m = meters;
-	struct signon_meter *meter = NULL;
-	
-	while (m) {
-		meter = (struct signon_meter *) (m->data);
-		meter->gc->wants_to_die = TRUE;
-		gaim_connection_destroy((GaimConnection *) meter->gc);
-		m = meters;
-		}
-	}
-
-void set_login_progress(GaimConnection *gc, float howfar, char *message)
-{
-	struct signon_meter *meter = find_signon_meter(gc);
-
-	if (mainwindow)
-		gtk_widget_hide(mainwindow);
-
-	if (!meter_win) {
-		GtkWidget *cancel_button;
-		GtkWidget *vbox;
-
-		meter_win = g_new0(struct meter_window, 1);
-		meter_win->rows=0;
-
-		meter_win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-		gtk_window_set_resizable(GTK_WINDOW(meter_win->window), FALSE);
-		gtk_window_set_role(GTK_WINDOW(meter_win->window), "signon");
-		gtk_container_set_border_width(GTK_CONTAINER(meter_win->window), 5);
-		gtk_window_set_title (GTK_WINDOW (meter_win->window), _("Signon"));
-		gtk_widget_realize(meter_win->window);
-
-		vbox = gtk_vbox_new (FALSE, 0);
-		gtk_container_add (GTK_CONTAINER (meter_win->window), GTK_WIDGET (vbox));
-
-		meter_win->table = (GtkTable *) gtk_table_new (1 , 4, FALSE);
-		gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (meter_win->table), FALSE, FALSE, 0);
-		gtk_container_set_border_width (GTK_CONTAINER (meter_win->table), 5);
-		gtk_table_set_row_spacings (GTK_TABLE (meter_win->table), 5);
-		gtk_table_set_col_spacings (GTK_TABLE (meter_win->table), 10);
-	
-		cancel_button = gaim_pixbuf_button_from_stock (_("Cancel All"), GTK_STOCK_QUIT, GAIM_BUTTON_HORIZONTAL);
-		g_signal_connect_swapped(G_OBJECT(cancel_button), "clicked",
-								 G_CALLBACK (loop_cancel), NULL);
-		gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(cancel_button), FALSE, FALSE, 0);
-	
-		g_signal_connect(G_OBJECT(meter_win->window), "delete_event",
-						 G_CALLBACK(meter_destroy), NULL);
-	}
-	
-	if (!meter) {
-		meter = register_meter(gc, GTK_WIDGET (meter_win->window), GTK_TABLE (meter_win->table), (gint *)  &meter_win->rows);
-		meter->gc = gc;
-		meters = g_slist_append(meters, meter);
-	}
-
-	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), howfar / LOGIN_STEPS);
-	gtk_statusbar_pop(GTK_STATUSBAR(meter->status), 1);
-	gtk_statusbar_push(GTK_STATUSBAR(meter->status), 1, message);
-}
-
-struct kick_dlg {
-	GaimAccount *account;
-	GtkWidget *dlg;
-};
-static GSList *kicks = NULL;
-
-static struct kick_dlg *find_kick_dlg(GaimAccount *account)
-{
-	GSList *k = kicks;
-	while (k) {
-		struct kick_dlg *d = k->data;
-		if (d->account == account)
-			return d;
-		k = k->next;
-	}
-	return NULL;
-}
-
-static void set_kick_null(struct kick_dlg *k)
-{
-	kicks = g_slist_remove(kicks, k);
-	g_free(k);
-}
-
-/*
- * Common code for hide_login_progress(), and hide_login_progress_info()
- */
-static void hide_login_progress_common(GaimConnection *gc,
-				       char *details,
-				       char *title,
-				       char *prologue)
-{
-	gchar *buf;
-	struct kick_dlg *k = find_kick_dlg(gc->account);
-	struct signon_meter *meter = find_signon_meter(gc);
-	buf = g_strdup_printf(_("%s\n%s: %s"), full_date(), prologue, details);
-	if (k)
-		gtk_widget_destroy(k->dlg);
-	k = g_new0(struct kick_dlg, 1);
-	k->account = gc->account;
-	k->dlg = gaim_notify_message(NULL, GAIM_NOTIFY_MSG_ERROR, NULL,
-								 title, buf, G_CALLBACK(set_kick_null), k);
-	kicks = g_slist_append(kicks, k);
-	if (meter) {
-		kill_meter(meter);
-		meters = g_slist_remove(meters, meter);
-		g_free(meter);
-	}
-	g_free(buf);
-}
-
-void hide_login_progress(GaimConnection *gc, char *why)
-{
-	GaimAccount *account = gaim_connection_get_account(gc);
-	gchar *buf;
-
-	gaim_event_broadcast(event_error, gc, why);
-	buf = g_strdup_printf(_("%s was unable to sign on"),
-						  gaim_account_get_username(account));
-	hide_login_progress_common(gc, why, _("Signon Error"), buf);
-	g_free(buf);
-}
-
-/*
- * Like hide_login_progress(), but for informational, not error/warning,
- * messages.
- *
- */
-void hide_login_progress_notice(GaimConnection *gc, char *why)
-{
-	GaimAccount *account = gaim_connection_get_account(gc);
-
-	hide_login_progress_common(gc, why, _("Notice"),
-							   (char *)gaim_account_get_username(account));
-}
-
-/*
- * Like hide_login_progress(), but for non-signon error messages.
- *
- */
-void hide_login_progress_error(GaimConnection *gc, char *why)
-{
-	char buf[2048];
-	GaimAccount *account = gaim_connection_get_account(gc);
-
-	gaim_event_broadcast(event_error, gc, why);
-	g_snprintf(buf, sizeof(buf), _("%s has been signed off"),
-			   gaim_account_get_username(account));
-	hide_login_progress_common(gc, why, _("Connection Error"), buf);
-}
-
--- a/src/notify.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/notify.c	Sun Jul 13 09:34:48 2003 +0000
@@ -188,4 +188,3 @@
 {
 	return notify_ui_ops;
 }
-
--- a/src/protocols/gg/gg.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/protocols/gg/gg.c	Sun Jul 13 09:34:48 2003 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 6509 2003-07-08 03:36:41Z thekingant $
+ * $Id: gg.c 6567 2003-07-13 09:34:48Z thekingant $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  * 
@@ -529,7 +529,7 @@
 	/*
 	   if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) {
 	   gaim_debug(GAIM_DEBUG_MISC, "gg", "uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); 
-	   hide_login_progress(gc, "Unable to connect.");
+	   gaim_connection_error(gc, "Unable to connect.");
 	   signoff(gc);
 	   return;
 	   }
--- a/src/protocols/icq/gaim_icq.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/protocols/icq/gaim_icq.c	Sun Jul 13 09:34:48 2003 +0000
@@ -84,13 +84,13 @@
 	struct icq_data *id = (struct icq_data *)gc->proto_data;
 
 	if (!id->connected) {
-		hide_login_progress(gc, "Unable to connect");
+		gaim_connection_error(gc, "Unable to connect");
 		signoff(gc);
 		return;
 	}
 
 	if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) {
-		hide_login_progress(gc, "Unable to connect");
+		gaim_connection_error(gc, "Unable to connect");
 		signoff(gc);
 		return;
 	}
@@ -166,13 +166,13 @@
 
 static void icq_wrong_passwd(icq_Link *link) {
 	struct gaim_connection *gc = link->icq_UserData;
-	hide_login_progress(gc, "Invalid password.");
+	gaim_connection_error(gc, "Invalid password.");
 	signoff(gc);
 }
 
 static void icq_invalid_uin(icq_Link *link) {
 	struct gaim_connection *gc = link->icq_UserData;
-	hide_login_progress(gc, "Invalid UIN.");
+	gaim_connection_error(gc, "Invalid UIN.");
 	signoff(gc);
 }
 
@@ -341,7 +341,7 @@
 	icq_ContactClear(id->link);
 
 	if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) {
-		hide_login_progress(gc, _("Unable to connect"));
+		gaim_connection_error(gc, _("Unable to connect"));
 		signoff(gc);
 		return;
 	}
@@ -349,7 +349,7 @@
 	id->cur_status = STATUS_ONLINE;
 	icq_Login(link, STATUS_ONLINE);
 
-	set_login_progress(gc, 0, _("Connecting..."));
+	gaim_connection_update_progress(gc, _("Connecting..."), 0, 2);
 }
 
 static void icq_close(struct gaim_connection *gc) {
--- a/src/protocols/jabber/jabber.c	Sun Jul 13 08:20:42 2003 +0000
+++ b/src/protocols/jabber/jabber.c	Sun Jul 13 09:34:48 2003 +0000
@@ -4241,13 +4241,16 @@
 		gjc->was_connected = 1;
 		/*
 		 * TBD?
-		set_login_progress(GJ_GC(gjc), 2, _("Connected"));
+		gaim_connection_update_progress(GJ_GC(gjc), _("Connected"), 
+				2, JABBER_CONNECT_STEPS);
 		 */
 		break;
 	case JCONN_STATE_ON:
 		/*
 		 * TBD?
-		set_login_progress(GJ_GC(gjc), 3, _("Requesting Authentication Method"));
+		gaim_connection_update_progress(GJ_GC(gjc), _("Authenticating"),
+				_("Requesting Authentication Method"), 3, 
+				JABBER_CONNECT_STEPS);
 		 */
 		gjab_reqreg(gjc);
 		/*