Mercurial > pidgin.yaz
changeset 5717:1d140b31d4b3
[gaim-migrate @ 6138]
this almost kinda sorta works. It's the wonderful connecting dialog
that shows you how far along you are in connecting. This also gets rid of
the ever-present signon dialog.
Oh, and I ended up digging through header hell and changing a lot. Hopefully
I didn't break anything too badly.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 03 Jun 2003 19:55:47 +0000 |
parents | 52f301dbfeaa |
children | c19cc2a3d65e |
files | src/Makefile.am src/account.c src/buddy_chat.c src/connection.c src/connection.h src/conversation.c src/conversation.h src/core.h src/dialogs.c src/gtkaccount.c src/gtkconn.c src/gtkconn.h src/gtkconv.c src/gtkutils.c src/main.c src/protocols/msn/msn.c src/protocols/msn/msn.h src/protocols/zephyr/zephyr.c src/proxy.h src/prpl.c src/prpl.h src/ui.h |
diffstat | 22 files changed, 450 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.am Tue Jun 03 17:37:25 2003 +0000 +++ b/src/Makefile.am Tue Jun 03 19:55:47 2003 +0000 @@ -65,6 +65,8 @@ gtkcellrendererprogress.h \ gtkblist.c \ gtkblist.h \ + gtkconn.c \ + gtkconn.h \ gtkconv.c \ gtkconv.h \ gtkdebug.c \ @@ -93,8 +95,6 @@ main.c \ md5.c \ md5.h \ - multi.c \ - multi.h \ privacy.h \ session.c \ socket.c \
--- a/src/account.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/account.c Tue Jun 03 19:55:47 2003 +0000 @@ -32,8 +32,10 @@ #include <glib.h> #include "account.h" +#include "debug.h" #include "prefs.h" #include "prpl.h" +#include "util.h" typedef enum {
--- a/src/buddy_chat.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/buddy_chat.c Tue Jun 03 19:55:47 2003 +0000 @@ -33,6 +33,8 @@ #include "prpl.h" #include "notify.h" +#include "gaim.h" +#include "multi.h" #ifdef _WIN32 #include "wspell.h"
--- a/src/connection.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/connection.c Tue Jun 03 19:55:47 2003 +0000 @@ -20,7 +20,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "connection.h" +#include "debug.h" +#include "gaim.h" static GList *connections = NULL; static GList *connections_connecting = NULL;
--- a/src/connection.h Tue Jun 03 17:37:25 2003 +0000 +++ b/src/connection.h Tue Jun 03 19:55:47 2003 +0000 @@ -29,7 +29,6 @@ #include "account.h" #include "plugin.h" -#include "multi.h" typedef enum {
--- a/src/conversation.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/conversation.c Tue Jun 03 19:55:47 2003 +0000 @@ -30,6 +30,7 @@ #include <ctype.h> #include "conversation.h" #include "gaim.h" +#include "multi.h" #include "prpl.h" #include "notify.h" #include "prefs.h"
--- a/src/conversation.h Tue Jun 03 17:37:25 2003 +0000 +++ b/src/conversation.h Tue Jun 03 19:55:47 2003 +0000 @@ -24,6 +24,8 @@ #ifndef _GAIM_CONVERSATION_H_ #define _GAIM_CONVERSATION_H_ +#include "account.h" + /**************************************************************************/ /** Data Structures */ /**************************************************************************/ @@ -84,9 +86,6 @@ GAIM_CONV_UPDATE_AWAY /**< The other user went away. */ }; -/* Yeah, this has to be included here. Ugh. */ -#include "gaim.h" - /** * Conversation window operations. *
--- a/src/core.h Tue Jun 03 17:37:25 2003 +0000 +++ b/src/core.h Tue Jun 03 19:55:47 2003 +0000 @@ -47,7 +47,6 @@ #include "debug.h" -#include "multi.h" #include "conversation.h" #include "ft.h" #include "privacy.h"
--- a/src/dialogs.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/dialogs.c Tue Jun 03 19:55:47 2003 +0000 @@ -51,6 +51,7 @@ #include "gtkblist.h" #include "notify.h" #include "prefs.h" +#include "multi.h" #ifdef _WIN32 #include "win32dep.h"
--- a/src/gtkaccount.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/gtkaccount.c Tue Jun 03 19:55:47 2003 +0000 @@ -20,6 +20,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <gtk/gtk.h> + #include "gtkaccount.h" #include "account.h" #include "accountopt.h" @@ -28,8 +31,9 @@ #include "stock.h" #include "gtkblist.h" #include "gaim-disclosure.h" +#include "gaim.h" -#ifdef _WIN32 +#ifdef _WIN32 # include <gdk/gdkwin32.h> #else # include <unistd.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gtkconn.c Tue Jun 03 19:55:47 2003 +0000 @@ -0,0 +1,375 @@ +/* + * 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 <string.h> +#include <gtk/gtk.h> + +#include "account.h" +#include "gtkblist.h" +#include "gaim.h" + +#ifdef _WIN32 +#include "win32dep.h" +#endif + +struct signon_meter { + GaimAccount *account; + GtkWidget *button; + GtkWidget *progress; + GtkWidget *status; +}; + +struct meter_window { + GtkWidget *window; + GtkWidget *table; + gint rows; + gint active_count; + GSList *meters; +} *meter_win = NULL; + +static void cancel_signon(GtkWidget *button, struct signon_meter *meter) +{ + meter->account->gc->wants_to_die = TRUE; + gaim_connection_destroy(meter->account->gc); +} + +static void cancel_all () { + GSList *m = meter_win ? meter_win->meters : NULL; + + while (m) { + cancel_signon(NULL, m->data); + m = meter_win ? meter_win->meters : NULL; + } +} + +static gint meter_destroy(GtkWidget *window, GdkEvent *evt, struct signon_meter *meter) +{ + return TRUE; +} + +static struct signon_meter *find_signon_meter(GaimConnection *gc) +{ + GSList *m = meter_win ? meter_win->meters : NULL; + + while (m) { + if (((struct signon_meter *)m->data)->account == gc->account) + return m->data; + m = m->next; + } + + return NULL; +} + +static 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 * +new_meter(GaimConnection *gc, GtkWidget *widget, + GtkWidget *table, gint *rows) +{ + GtkWidget *graphic; + GtkWidget *label; + GtkWidget *nest_vbox; + GString *name_to_print; + struct signon_meter *meter; + + + meter = g_new0(struct signon_meter, 1); + + meter->account = gaim_connection_get_account(gc); + name_to_print = g_string_new(gaim_account_get_username(meter->account)); + + (*rows)++; + gtk_table_resize (GTK_TABLE(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_label_new(""); + gtk_misc_set_alignment(GTK_MISC(meter->status), 0, 0.5); + 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 kill_meter(struct signon_meter *meter, const char *text) { + gtk_widget_set_sensitive (meter->button, FALSE); + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), 1); + gtk_label_set_text(GTK_LABEL(meter->status), text); + meter_win->active_count--; + if (meter_win->active_count == 0) { + gtk_widget_destroy(meter_win->window); + g_free (meter_win); + meter_win = NULL; + } +} + +static void gaim_gtk_connection_connect_progress(GaimConnection *gc, + const char *text, size_t step, size_t step_count) +{ + struct signon_meter *meter; + + if(!meter_win) { + GtkWidget *vbox; + GtkWidget *cancel_button; + + if(mainwindow) + gtk_widget_hide(mainwindow); + + meter_win = g_new0(struct meter_window, 1); + 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), vbox); + + meter_win->table = 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(cancel_all), 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); + } + + meter = find_signon_meter(gc); + if(!meter) { + meter = new_meter(gc, meter_win->window, meter_win->table, + &meter_win->rows); + + meter_win->meters = g_slist_append(meter_win->meters, meter); + } + + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), + (float)step / (float)step_count); + gtk_label_set_text(GTK_LABEL(meter->status), text); +} + +static void gaim_gtk_connection_connected(GaimConnection *gc) +{ + struct signon_meter *meter = find_signon_meter(gc); + + if(meter) + kill_meter(meter, _("Done.")); +} + +static void gaim_gtk_connection_request_pass(GaimConnection *gc) +{ +} + +static void gaim_gtk_connection_disconnected(GaimConnection *gc, + const char *reason) +{ + struct signon_meter *meter = find_signon_meter(gc); + if(meter) + kill_meter(meter, _("Done.")); +} + +static void gaim_gtk_connection_notice(GaimConnection *gc, + const char *text) +{ +} + +static GaimConnectionUiOps conn_ui_ops = +{ + gaim_gtk_connection_connect_progress, + gaim_gtk_connection_connected, + gaim_gtk_connection_request_pass, + gaim_gtk_connection_disconnected, + gaim_gtk_connection_notice +}; + +GaimConnectionUiOps *gaim_get_gtk_connection_ui_ops(void) +{ + return &conn_ui_ops; +} + + +static 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; +} + + +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); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gtkconn.h Tue Jun 03 19:55:47 2003 +0000 @@ -0,0 +1,40 @@ +/** + * @file gtkconn.h GTK+ Connection API + * + * gaim + * + * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> + * + * 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 + */ + +#ifndef _GAIM_GTKCONN_H_ +#define _GAIM_GTKCONN_H_ + +/**************************************************************************/ +/** @name GTK+ Connection API */ +/**************************************************************************/ +/*@{*/ + +/** + * Gets GTK Connection UI ops + * + * @return UI operations struct + */ +GaimConnectionUiOps *gaim_get_gtk_connection_ui_ops(void); + +/*@}*/ + +#endif /* _GAIM_GTKCONN_H_ */
--- a/src/gtkconv.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/gtkconv.c Tue Jun 03 19:55:47 2003 +0000 @@ -46,6 +46,11 @@ #include "gtkblist.h" #include "notify.h" #include "prefs.h" +#include "gtkconv.h" +#include "gaim.h" +#include "ui.h" +#include "debug.h" +#include "multi.h" #ifdef _WIN32 #include "win32dep.h"
--- a/src/gtkutils.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/gtkutils.c Tue Jun 03 19:55:47 2003 +0000 @@ -46,6 +46,7 @@ #include <gdk/gdkkeysyms.h> #include "prefs.h" #include "prpl.h" +#include "gaim.h" #include "ui.h" #include "notify.h"
--- a/src/main.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/main.c Tue Jun 03 19:55:47 2003 +0000 @@ -56,6 +56,7 @@ #include "notify.h" #include "gtkaccount.h" #include "gtkblist.h" +#include "gtkconn.h" #include "gtkdebug.h" #include "gtknotify.h" #include "gtkrequest.h" @@ -892,6 +893,7 @@ gaim_set_notify_ui_ops(gaim_get_gtk_notify_ui_ops()); gaim_set_request_ui_ops(gaim_get_gtk_request_ui_ops()); gaim_set_sound_ui_ops(gaim_get_gtk_sound_ui_ops()); + gaim_set_connection_ui_ops(gaim_get_gtk_connection_ui_ops()); gaim_proxy_init(); gaim_sound_init();
--- a/src/protocols/msn/msn.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/protocols/msn/msn.c Tue Jun 03 19:55:47 2003 +0000 @@ -27,6 +27,7 @@ #include "session.h" #include "state.h" #include "utils.h" +#include "multi.h" #define BUDDY_ALIAS_MAXLEN 388
--- a/src/protocols/msn/msn.h Tue Jun 03 17:37:25 2003 +0000 +++ b/src/protocols/msn/msn.h Tue Jun 03 19:55:47 2003 +0000 @@ -42,7 +42,11 @@ #include <netdb.h> #endif +#include "gaim.h" +#include "account.h" #include "blist.h" +#include "conversation.h" +#include "connection.h" #include "debug.h" #include "md5.h" #include "proxy.h"
--- a/src/protocols/zephyr/zephyr.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/protocols/zephyr/zephyr.c Tue Jun 03 19:55:47 2003 +0000 @@ -32,6 +32,7 @@ #include <errno.h> #include "gaim.h" #include "prpl.h" +#include "multi.h" #include "zephyr/zephyr.h" extern Code_t ZGetLocations(ZLocations_t *, int *);
--- a/src/proxy.h Tue Jun 03 17:37:25 2003 +0000 +++ b/src/proxy.h Tue Jun 03 19:55:47 2003 +0000 @@ -37,7 +37,6 @@ #include <glib.h> -#include "core.h" #include "account.h" /**
--- a/src/prpl.c Tue Jun 03 17:37:25 2003 +0000 +++ b/src/prpl.c Tue Jun 03 19:55:47 2003 +0000 @@ -22,6 +22,7 @@ #include "gaim.h" #include "gtkutils.h" #include "gtkblist.h" +#include "multi.h" #include "prpl.h" #include "notify.h" #include <sys/types.h>