# HG changeset patch # User Mark Doliner # Date 1102280752 0 # Node ID 61852117568f36ceb22b1f93c77059aaee903c92 # Parent 32e7baa81e03a3476f242a67a35ff0b817f851f8 [gaim-migrate @ 11527] A little code cleanup here and there. And I removed gaim_setup() from gtkmain.c and put it in gtksound.c committer: Tailor Script diff -r 32e7baa81e03 -r 61852117568f HACKING --- a/HACKING Sun Dec 05 18:57:57 2004 +0000 +++ b/HACKING Sun Dec 05 21:05:52 2004 +0000 @@ -204,12 +204,9 @@ reporting idle time (imagine that). It's a pretty straight-forward file. This also takes care of the auto-away stuff. -main.c: +gtkmain.c: This is where the main() function is. It takes care of a lot of the - initialization stuff, and showing the login window. It's pretty tiny - and there's not really much to edit in it. This has some of the most - pointless functions, like gaim_setup, which optionally turns off sounds - on signon. A lot of this file should actually be part of other files. + initialization stuff, and showing the buddy list or account editor. md5.c: Oscar, Yahoo, and MSN all require md5 hashing, so better to put it in diff -r 32e7baa81e03 -r 61852117568f plugins/chkmail.c --- a/plugins/chkmail.c Sun Dec 05 18:57:57 2004 +0000 +++ b/plugins/chkmail.c Sun Dec 05 21:05:52 2004 +0000 @@ -18,8 +18,6 @@ #include "internal.h" #include "gtkgaim.h" -#include "gaim.h" - char username[] = ""; char password[] = ""; char mailhost[] = ""; @@ -101,7 +99,6 @@ } } - void setup_mail_list() { GList *list; @@ -131,16 +128,15 @@ gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); gtk_tree_item_expand(GTK_TREE_ITEM(item)); - buf = g_malloc(BUF_LONG); - - g_snprintf(buf, BUF_LONG, _("%s (%d new/%d total)"), mailhost, lastnum - orig, lastnum); + /* XXX - This needs to use ngettext() */ + buf = g_strdup_printf(_("%s (%d new/%d total)"), mailhost, lastnum - orig, lastnum); item = gtk_tree_item_new_with_label(buf); g_free(buf); gtk_tree_append(GTK_TREE(tree), item); gtk_widget_show(item); } - + void gaim_plugin_init(void *h) { handle = h; @@ -149,7 +145,7 @@ gaim_signal_connect(handle, event_blist_update, setup_mail_list, NULL); setup_mail_list(); - + mytimer = g_timeout_add(30000, check_mail, NULL); } @@ -187,7 +183,6 @@ state = 0; } - void gaim_plugin_remove() { g_source_remove(mytimer); while (state == 1) { } diff -r 32e7baa81e03 -r 61852117568f plugins/filectl.c --- a/plugins/filectl.c Sun Dec 05 18:57:57 2004 +0000 +++ b/plugins/filectl.c Sun Dec 05 21:05:52 2004 +0000 @@ -21,7 +21,6 @@ #include "conversation.h" #include "debug.h" #include "eventloop.h" -#include "gaim.h" #include "internal.h" #include "util.h" #include "version.h" diff -r 32e7baa81e03 -r 61852117568f src/gaim.h --- a/src/gaim.h Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gaim.h Sun Dec 05 21:05:52 2004 +0000 @@ -25,8 +25,6 @@ #define XPATCH BAD /* Because Kalla Said So */ -#include "connection.h" - /* Functions in idle.c */ extern gint check_idle(gpointer); diff -r 32e7baa81e03 -r 61852117568f src/gtkblist.c --- a/src/gtkblist.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtkblist.c Sun Dec 05 21:05:52 2004 +0000 @@ -4894,7 +4894,6 @@ } - static void build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, gpointer context) { @@ -5098,4 +5097,3 @@ } } } - diff -r 32e7baa81e03 -r 61852117568f src/gtkconn.c --- a/src/gtkconn.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtkconn.c Sun Dec 05 21:05:52 2004 +0000 @@ -236,8 +236,6 @@ { struct login_meter *meter = find_login_meter(gc); - gaim_setup(gc); - #if 0 /* XXX CORE/UI */ do_away_menu(); #endif diff -r 32e7baa81e03 -r 61852117568f src/gtkconv.c --- a/src/gtkconv.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtkconv.c Sun Dec 05 21:05:52 2004 +0000 @@ -63,9 +63,6 @@ #include "gtkutils.h" #include "gtkstock.h" -/* XXX */ -#include "gaim.h" - #define AUTO_RESPONSE "<AUTO-REPLY> : " #define SEND_COLOR "#16569E" diff -r 32e7baa81e03 -r 61852117568f src/gtkdialogs.h --- a/src/gtkdialogs.h Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtkdialogs.h Sun Dec 05 21:05:52 2004 +0000 @@ -88,9 +88,6 @@ extern struct smiley_theme *current_smiley_theme; extern GSList *smiley_themes; -/* Functions in gtkmain.c */ -extern void gaim_setup(GaimConnection *); - /* Functions in session.c */ extern void session_init(gchar *, gchar *, gchar *); extern void session_end(); diff -r 32e7baa81e03 -r 61852117568f src/gtkmain.c --- a/src/gtkmain.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtkmain.c Sun Dec 05 21:05:52 2004 +0000 @@ -100,27 +100,6 @@ }; #endif -static guint snd_tmout = 0; -static gboolean sound_timeout(gpointer data) -{ - gaim_gtk_sound_set_login_mute(FALSE); - snd_tmout = 0; - return 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(GaimConnection *gc) -{ - if (gaim_prefs_get_bool("/gaim/gtk/sound/enabled/login")) { - if (snd_tmout) - g_source_remove(snd_tmout); - gaim_gtk_sound_set_login_mute(TRUE); - snd_tmout = gaim_timeout_add(10000, sound_timeout, NULL); - } -} - static int dologin_named(char *name) { GaimAccount *account; @@ -335,49 +314,43 @@ } static void -show_usage(int mode, const char *name) +show_usage(const char *name, gboolean terse) { - char *text=NULL; + char *text; + char *text_conv; + GError *error = NULL; - switch (mode) { - case 0: /* full help text */ - text=g_strdup_printf(_("Gaim %s\n" + if (terse) { + text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name); + } else { + text = g_strdup_printf(_("Gaim %s\n" "Usage: %s [OPTION]...\n\n" " -a, --acct display account editor window\n" - " -w, --away[=MESG] make away on signon (optional argument MESG specifies\n" - " name of away message to use)\n" - " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" - " account(s) to use, seperated by commas)\n" - " -n, --loginwin don't automatically login; show login window\n" - " -u, --user=NAME use account NAME\n" " -c, --config=DIR use DIR for config files\n" " -d, --debug print debugging messages to stdout\n" + " -h, --help display this help and exit\n" + " -n, --loginwin don't automatically login; show login window\n" + " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" + " account(s) to use, seperated by commas)\n" + " -u, --user=NAME use account NAME\n" " -v, --version display the current version and exit\n" - " -h, --help display this help and exit\n"), VERSION, name); - break; - case 1: /* short message */ - text=g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name); - break; + " -w, --away[=MESG] make away on signon (optional argument MESG specifies\n" + " name of away message to use)\n"), VERSION, name); } - if(text) { - char *text_conv; - GError *error=NULL; - - /* tries to convert 'text' to users locale */ - text_conv=g_locale_from_utf8(text,-1,NULL,NULL,&error); - if(text_conv) { - puts(text_conv); - g_free(text_conv); - } - /* use 'text' as a fallback */ - else { - g_warning("%s\n", error->message); - g_error_free(error); - puts(text); - } - g_free(text); + /* tries to convert 'text' to users locale */ + text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error); + if (text_conv != NULL) { + puts(text_conv); + g_free(text_conv); } + /* use 'text' as a fallback */ + else { + g_warning("%s\n", error->message); + g_error_free(error); + puts(text); + } + g_free(text); } #ifdef HAVE_STARTUP_NOTIFICATION @@ -630,8 +603,6 @@ } */ - gui_check = gtk_init_check(&argc, &argv); - /* scan command-line options */ opterr = 1; while ((opt = getopt_long(argc, argv, @@ -642,10 +613,6 @@ #endif long_options, NULL)) != -1) { switch (opt) { - case 'u': /* set user */ - opt_user = 1; - opt_user_arg = g_strdup(optarg); - break; case 'a': /* account editor */ opt_acct = 1; break; @@ -656,21 +623,25 @@ set_gaim_user_dir(optarg); opt_config_dir_arg = g_strdup(optarg); break; - case 's': /* use existing session ID */ - opt_session_arg = g_strdup(optarg); - break; - case 'v': /* version */ - opt_version = 1; - break; case 'h': /* help */ opt_help = 1; break; case 'n': /* don't autologin */ opt_nologin = 1; break; + case 's': /* use existing session ID */ + opt_session_arg = g_strdup(optarg); + break; + case 'u': /* set user */ + opt_user = 1; + opt_user_arg = g_strdup(optarg); + break; + case 'v': /* version */ + opt_version = 1; + break; case '?': default: - show_usage(1, argv[0]); + show_usage(argv[0], TRUE); return 0; break; } @@ -678,7 +649,7 @@ /* show help message */ if (opt_help) { - show_usage(0, argv[0]); + show_usage(argv[0], FALSE); return 0; } /* show version message */ @@ -687,6 +658,7 @@ return 0; } + gui_check = gtk_init_check(&argc, &argv); if (!gui_check) { char *display = gdk_get_display(); @@ -758,7 +730,6 @@ g_free(opt_session_arg); opt_session_arg = NULL; } - if (opt_config_dir_arg != NULL) { g_free(opt_config_dir_arg); opt_config_dir_arg = NULL; @@ -787,7 +758,7 @@ gaim_accounts_auto_login(GAIM_GTK_UI); gaim_blist_show(); - + if (opt_acct) { gaim_gtk_accounts_window_show(); } @@ -795,13 +766,14 @@ #ifdef HAVE_STARTUP_NOTIFICATION startup_notification_complete(); #endif + gtk_main(); + gaim_sound_shutdown(); #ifdef _WIN32 wgaim_cleanup(); #endif - return 0; } diff -r 32e7baa81e03 -r 61852117568f src/gtksound.c --- a/src/gtksound.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtksound.c Sun Dec 05 21:05:52 2004 +0000 @@ -58,6 +58,7 @@ #define PLAY_SOUND_TIMEOUT 15000 +static guint mute_login_sounds_timeout = 0; static gboolean mute_login_sounds = FALSE; static gboolean sound_initialized = FALSE; @@ -83,8 +84,36 @@ static void _pref_sound_method_changed(const char *name, GaimPrefType type, gpointer val, gpointer data); +static gboolean +mute_login_sounds_cb(gpointer data) +{ + mute_login_sounds = FALSE; + mute_login_sounds_timeout = 0; + return FALSE; +} + +/* + * We mute sounds for the 10 seconds after you log in so that + * you don't get flooded with sounds when the blist shows all + * your buddies logging in. + */ +static void +account_signon_cb(GaimConnection *gc, gpointer data) +{ + if (mute_login_sounds_timeout != 0) + g_source_remove(mute_login_sounds_timeout); + mute_login_sounds = TRUE; + mute_login_sounds_timeout = gaim_timeout_add(10000, mute_login_sounds_cb, NULL); +} + static void gaim_gtk_sound_init(void) { + void *gtk_sound_handle = gaim_gtk_sound_get_handle(); + + gaim_signal_connect(gaim_connections_get_handle(), "signed-on", + gtk_sound_handle, GAIM_CALLBACK(account_signon_cb), + NULL); + gaim_prefs_add_none("/gaim/gtk/sound"); gaim_prefs_add_none("/gaim/gtk/sound/enabled"); gaim_prefs_add_none("/gaim/gtk/sound/file"); @@ -388,11 +417,6 @@ #endif /* USE_NAS_AUDIO */ -void gaim_gtk_sound_set_login_mute(gboolean mute) -{ - mute_login_sounds = mute; -} - const char *gaim_gtk_sound_get_event_option(GaimSoundEventID event) { if(event >= GAIM_NUM_SOUNDS) diff -r 32e7baa81e03 -r 61852117568f src/gtksound.h --- a/src/gtksound.h Sun Dec 05 18:57:57 2004 +0000 +++ b/src/gtksound.h Sun Dec 05 21:05:52 2004 +0000 @@ -44,13 +44,6 @@ GaimSoundUiOps *gaim_gtk_sound_get_ui_ops(void); /** - * Mutes or un-mutes login sounds. - * - * @param mute The mute state. - */ -void gaim_gtk_sound_set_login_mute(gboolean mute); - -/** * Get the prefs option for an event. * * @param event The event. diff -r 32e7baa81e03 -r 61852117568f src/protocols/rendezvous/rendezvous.c --- a/src/protocols/rendezvous/rendezvous.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/protocols/rendezvous/rendezvous.c Sun Dec 05 21:05:52 2004 +0000 @@ -126,7 +126,7 @@ gaim_prpl_got_user_status(account, b->name, "offline", NULL); gaim_blist_remove_buddy(b); /* XXX - This results in incorrect group counts--needs to be fixed in the core */ - /* XXX - We also need to call remove_idle_buddy() in server.c for idle buddies */ + /* XXX - We also need to call remove_idle_buddy() in server.c for idle buddies */ /* * XXX - Instead of removing immediately, wait 10 seconds and THEN remove diff -r 32e7baa81e03 -r 61852117568f src/proxy.c --- a/src/proxy.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/proxy.c Sun Dec 05 21:05:52 2004 +0000 @@ -36,8 +36,6 @@ #include "proxy.h" #include "util.h" -#include "gaim.h" - static GaimProxyInfo *global_proxy_info = NULL; struct PHB { diff -r 32e7baa81e03 -r 61852117568f src/socket.c --- a/src/socket.c Sun Dec 05 18:57:57 2004 +0000 +++ b/src/socket.c Sun Dec 05 21:05:52 2004 +0000 @@ -22,7 +22,7 @@ */ /* Somewhat inspired by XMMS*/ - + /* This provides code for connecting to a Gaim socket and communicating with * it. It will eventually be made a library once the core and ui are split. */ @@ -30,7 +30,6 @@ #include #include #include -#include "gaim.h" #include "gaim-socket.h" void cui_send_packet (int fd, struct gaim_cui_packet *p) {