Mercurial > pidgin
changeset 5211:0241d6b6702d
[gaim-migrate @ 5581]
Wrote a new debugging API, and of course core/ui split it. Debug statements
can now have debug levels and categories, for future filtering of stuff,
and color highlighting. It's nifty, m'kay?
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 26 Apr 2003 06:46:08 +0000 |
parents | 39bb2a35f8d9 |
children | 740303e8425b |
files | ChangeLog src/Makefile.am src/buddy.c src/core.h src/event.c src/gaim.h src/gaimrc.c src/gtkconv.c src/html.c src/idle.c src/list.c src/log.c src/main.c src/multi.c src/plugin.c src/prefs.c src/protocols/irc/irc.c src/protocols/oscar/oscar.c src/proxy.c src/prpl.c src/server.c src/session.c src/sound.c src/ui.h src/util.c |
diffstat | 25 files changed, 508 insertions(+), 331 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Apr 26 05:31:26 2003 +0000 +++ b/ChangeLog Sat Apr 26 06:46:08 2003 +0000 @@ -4,6 +4,8 @@ * A rewrite of the plugin API. Plugin authors will need to change their code based off the changes found in other plugins. * Perl script support is now provided in the perl plugin. + * Debugging is core/ui split, and has a new API with support for + debug levels and categories. version 0.62 (04/23/2003): * Keyboard shortcuts in the buddy list work again (Thanks Joe
--- a/src/Makefile.am Sat Apr 26 05:31:26 2003 +0000 +++ b/src/Makefile.am Sat Apr 26 06:46:08 2003 +0000 @@ -10,6 +10,8 @@ conversation.h \ core.c \ core.h \ + debug.c \ + debug.h \ event.c \ event.h \ ft.c \ @@ -48,6 +50,8 @@ gtkcellrendererprogress.h \ gtkconv.c \ gtkconv.h \ + gtkdebug.c \ + gtkdebug.h \ gtkft.c \ gtkft.h \ gtkimhtml.c \
--- a/src/buddy.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/buddy.c Sat Apr 26 06:46:08 2003 +0000 @@ -635,6 +635,20 @@ } } +static void +toggle_debug(void) +{ + misc_options ^= OPT_MISC_DEBUG; + + if ((misc_options & OPT_MISC_DEBUG)) + gaim_gtk_debug_window_show(); + else + gaim_gtk_debug_window_hide(); + + save_prefs(); +} + + /*************************************************** * Crap * ***************************************************/
--- a/src/core.h Sat Apr 26 05:31:26 2003 +0000 +++ b/src/core.h Sat Apr 26 06:46:08 2003 +0000 @@ -49,6 +49,7 @@ struct buddy; +#include "debug.h" #include "multi.h" #include "conversation.h" #include "ft.h"
--- a/src/event.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/event.c Sat Apr 26 06:46:08 2003 +0000 @@ -21,18 +21,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "event.h" +#include "debug.h" #include <sys/time.h> #include <stdarg.h> #include <stdio.h> #include <string.h> -/* - * XXX - This is for debug_printf! Move out when debug_printf moved to debug.h - * -- ChipX86 - */ -#include "gaim.h" - /** * A signal callback. */ @@ -74,7 +69,8 @@ callbacks = g_list_append(callbacks, call); - debug_printf("Adding callback %d\n", g_list_length(callbacks)); + gaim_debug(GAIM_DEBUG_INFO, "signals", + "Adding callback %d\n", g_list_length(callbacks)); } void @@ -105,7 +101,9 @@ g_return_if_fail(handle != NULL); - debug_printf("%d callbacks to search\n", g_list_length(callbacks)); + gaim_debug(GAIM_DEBUG_INFO, "signals", + "Disconnecting callbacks. %d to search.\n", + g_list_length(callbacks)); for (c = callbacks; c != NULL; c = c_next) { c_next = c->next; @@ -114,8 +112,9 @@ if (g->handle == handle) { callbacks = g_list_remove(callbacks, (gpointer)g); - debug_printf("Removing callback, %d remain\n", - g_list_length(callbacks)); + gaim_debug(GAIM_DEBUG_INFO, "signals", + "Removing callback. %d remain.\n", + g_list_length(callbacks)); } } } @@ -276,7 +275,8 @@ break; default: - debug_printf("unknown event %d\n", event); + gaim_debug(GAIM_DEBUG_WARNING, "events", + "Unknown event %d\n", event); break; }
--- a/src/gaim.h Sat Apr 26 05:31:26 2003 +0000 +++ b/src/gaim.h Sat Apr 26 06:46:08 2003 +0000 @@ -377,9 +377,6 @@ /* Functions in idle.c */ extern gint check_idle(gpointer); -/* Functions in prefs.c */ -extern void debug_printf(char * fmt, ...) G_GNUC_PRINTF(1,2); - /* Functions in server.c */ /* input to serv */ extern void serv_login(struct gaim_account *);
--- a/src/gaimrc.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/gaimrc.c Sat Apr 26 06:46:08 2003 +0000 @@ -471,8 +471,6 @@ struct gaim_pounce *pounce; struct gaim_gtkpounce_data *pounce_data; - debug_printf("*** Writing pounces.\n"); - fprintf(f, "pounce {\n"); for (pnc = gaim_get_pounces(); pnc != NULL; pnc = pnc->next) { @@ -793,7 +791,8 @@ if((account=gaimrc_read_user(f))!=NULL) gaim_accounts = g_slist_append(gaim_accounts, account); else { - debug_printf("Error reading in users from .gaimrc\n"); + gaim_debug(GAIM_DEBUG_ERROR, "gaimrc", + "Error reading in users from .gaimrc\n"); return; } } @@ -1152,11 +1151,13 @@ user[0] = '\0'; pass[0] = '\0'; - debug_printf("gaimrc_parse_proxy_uri(%s)\n", proxy); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", + "gaimrc_parse_proxy_uri(%s)\n", proxy); if ((c = strchr(proxy, ':')) == NULL) { - debug_printf("no uri detected\n"); + gaim_debug(GAIM_DEBUG_ERROR, "gaimrc", + "No URI detected.\n"); /* No URI detected. */ return FALSE; } @@ -1168,11 +1169,11 @@ else return FALSE; - debug_printf("found http proxy\n"); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Found HTTP proxy.\n"); /* Get past "://" */ c += 3; - debug_printf("looking at %s\n", c); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Looking at %s\n", c); for (;;) { @@ -1234,9 +1235,10 @@ global_proxy_info.proxyport = port; - debug_printf("host '%s'\nuser '%s'\npassword '%s'\nport %d\n", - global_proxy_info.proxyhost, global_proxy_info.proxyuser, - global_proxy_info.proxypass, global_proxy_info.proxyport); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", + "Host: '%s', User: '%s', Password: '%s', Port: %d\n", + global_proxy_info.proxyhost, global_proxy_info.proxyuser, + global_proxy_info.proxypass, global_proxy_info.proxyport); return TRUE; } @@ -1249,7 +1251,7 @@ buf[0] = 0; global_proxy_info.proxyhost[0] = 0; - debug_printf("gaimrc_read_proxy\n"); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "gaimrc_read_proxy\n"); while (buf[0] != '}') { if (buf[0] == '#') @@ -1263,7 +1265,8 @@ if (!strcmp(p->option, "host")) { g_snprintf(global_proxy_info.proxyhost, sizeof(global_proxy_info.proxyhost), "%s", p->value[0]); - debug_printf("set proxyhost %s\n", global_proxy_info.proxyhost); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", + "Set proxyhost %s\n", global_proxy_info.proxyhost); } else if (!strcmp(p->option, "port")) { global_proxy_info.proxyport = atoi(p->value[0]); } else if (!strcmp(p->option, "type")) { @@ -1459,11 +1462,13 @@ FILE *f; char buf[1024]; int ver = 0; - debug_printf("load_prefs\n"); + + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Loading preferences.\n"); if (is_saving_prefs) { request_load_prefs = 1; - debug_printf("currently saving, will request load\n"); + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", + "Currently saving. Will request load.\n"); return; } @@ -1478,7 +1483,7 @@ if ((f = fopen(buf, "r"))) { is_loading_prefs = 1; - debug_printf("start load_prefs\n"); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "start load_prefs\n"); fgets(buf, sizeof(buf), f); sscanf(buf, "# .gaimrc v%d", &ver); if ((ver <= 3) || (buf[0] != '#')) @@ -1486,7 +1491,8 @@ while (!feof(f)) { int tag = gaimrc_parse_tag(f); - debug_printf("starting read tag %d\n", tag); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", + "starting read tag %d\n", tag); switch (tag) { case -1: /* Let the loop end, EOF */ @@ -1517,13 +1523,15 @@ /* NOOP */ break; } - debug_printf("ending read tag %d\n", tag); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", + "ending read tag %d\n", tag); } fclose(f); is_loading_prefs = 0; - debug_printf("end load_prefs\n"); + gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "end load_prefs\n"); if (request_save_prefs) { - debug_printf("saving prefs on request\n"); + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", + "Saving preferences on request\n"); save_prefs(); request_save_prefs = 0; } @@ -1545,13 +1553,14 @@ gchar *filename; gchar *filename_temp; - debug_printf("enter save_prefs\n"); + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Entering save_prefs\n"); if (!prefs_initial_load) return; if (is_loading_prefs) { request_save_prefs = 1; - debug_printf("currently loading, will request save\n"); + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", + "Currently loading. Will request save.\n"); return; } @@ -1579,20 +1588,24 @@ gaimrc_write_proxy(f); fclose(f); if (rename(filename_temp, filename) < 0) - debug_printf("error renaming %s to %s\n", filename_temp, filename); + gaim_debug(GAIM_DEBUG_ERROR, "gaimrc", + "Error renaming %s to %s\n", filename_temp, filename); is_saving_prefs = 0; } else - debug_printf("error opening %s\n", filename_temp); + gaim_debug(GAIM_DEBUG_ERROR, "gaimrc", + "Error opening %s\n", filename_temp); if (request_load_prefs) { - debug_printf("loading prefs on request\n"); + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", + "Loading preferences on request.\n"); load_prefs(); request_load_prefs = 0; } g_free(filename); g_free(filename_temp); - debug_printf("exit save_prefs\n"); + + gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Exiting save_prefs\n"); } @@ -1620,8 +1633,6 @@ struct gaim_pounce *pounce; struct gaim_account *account; - debug_printf("*** Loading pounces...\n"); - for (l = buddy_pounces; l != NULL; l = l->next) { GaimPounceEvent events = GAIM_POUNCE_NONE; GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE;
--- a/src/gtkconv.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/gtkconv.c Sat Apr 26 06:46:08 2003 +0000 @@ -156,7 +156,8 @@ return; if (stat(name, &st) != 0) { - debug_printf("Could not stat %s\n", name); + gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", + "Could not stat image %s\n", name); return; } @@ -1521,8 +1522,8 @@ gtkwin = GAIM_GTK_WINDOW(win); if (gtkwin->in_drag) { - debug_printf("Already in the middle of a window " - "drag at tab_press_cb\n"); + gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", + "Already in the middle of a window drag at tab_press_cb\n"); return TRUE; } @@ -4535,7 +4536,6 @@ struct gaim_gtk_conversation *gtkconv; GtkSpell *spell; - debug_printf("gaim_gtkconv_toggle_spellchk\n"); for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { conv = (struct gaim_conversation *)cl->data; @@ -4614,7 +4614,9 @@ gint delay; if (!g_list_find(gaim_get_ims(), conv)) { - debug_printf("I think this is a bug.\n"); + gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", + "Conversation not found in redraw_icon. I think this " + "is a bug.\n"); return FALSE; } @@ -4810,7 +4812,8 @@ } if (err) { - debug_printf("Buddy icon error: %s\n", err->message); + gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", + "Buddy icon error: %s\n", err->message); g_error_free(err); }
--- a/src/html.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/html.c Sat Apr 26 06:46:08 2003 +0000 @@ -216,7 +216,9 @@ g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/", gunk->full ? gunk->url : gunk->website->page); - debug_printf("Request: %s\n", buf); + + gaim_debug(GAIM_DEBUG_MISC, "grab_url_callback", + "Request: %s\n", buf); write(sock, buf, strlen(buf)); fcntl(sock, F_SETFL, O_NONBLOCK); @@ -282,7 +284,8 @@ gunk->webdata = g_realloc(gunk->webdata, gunk->len + 1); gunk->webdata[gunk->len] = 0; - debug_printf(_("Received: '%s'\n"), gunk->webdata); + gaim_debug(GAIM_DEBUG_MISC, "grab_url_callback", + "Received: '%s'\n", gunk->webdata); gaim_input_remove(gunk->inpa); close(sock);
--- a/src/idle.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/idle.c Sat Apr 26 06:46:08 2003 +0000 @@ -80,7 +80,8 @@ if ((away_options & OPT_AWAY_AUTO) && (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) { if (!gc->away) { - debug_printf("making %s away automatically\n", gc->username); + gaim_debug(GAIM_DEBUG_INFO, "idle", + "Making %s away automatically\n", gc->username); if (g_slist_length(connections) == 1) do_away_message(NULL, default_away); else if (default_away) @@ -96,13 +97,16 @@ } gc->is_auto_away = 0; if (awaymessage == NULL) { - debug_printf("removing auto-away message for %s\n", gc->username); + gaim_debug(GAIM_DEBUG_INFO, "idle", + "Removing auto-away message for %s\n", gc->username); serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); } else { if (g_slist_length(connections) == 1) do_im_back(0, 0); else { - debug_printf("replacing auto-away with global for %s\n", gc->username); + gaim_debug(GAIM_DEBUG_INFO, "idle", + "Replacing auto-away with global for %s\n", + gc->username); serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); } } @@ -117,12 +121,14 @@ } if (idle_time >= IDLEMARK && !gc->is_idle) { - debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); + gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s idle %d seconds\n", + gc->username, idle_time); serv_set_idle(gc, idle_time); gc->is_idle = 1; system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); } else if (idle_time < IDLEMARK && gc->is_idle) { - debug_printf("setting %s unidle\n", gc->username); + gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s unidle\n", + gc->username); serv_touch_idle(gc); system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); }
--- a/src/list.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/list.c Sat Apr 26 06:46:08 2003 +0000 @@ -576,7 +576,9 @@ if (a) { utf8 = gaim_try_conv_to_utf8(a); if (utf8 == NULL) { - debug_printf ("Failed to convert alias for '%s' to UTF-8\n", nm); + gaim_debug(GAIM_DEBUG_ERROR, "toc blist", + "Failed to convert alias for " + "'%s' to UTF-8\n", nm); } } if (utf8 == NULL) { @@ -600,12 +602,14 @@ gaim_privacy_deny_add(account, c + 2); } else if (!strncmp("toc", c, 3)) { sscanf(c + strlen(c) - 1, "%d", &account->permdeny); - debug_printf("permdeny: %d\n", account->permdeny); + gaim_debug(GAIM_DEBUG_MISC, "toc blist", + "permdeny: %d\n", account->permdeny); if (account->permdeny == 0) account->permdeny = 1; } else if (*c == 'm') { sscanf(c + 2, "%d", &account->permdeny); - debug_printf("permdeny: %d\n", account->permdeny); + gaim_debug(GAIM_DEBUG_MISC, "toc blist", + "permdeny: %d\n", account->permdeny); if (account->permdeny == 0) account->permdeny = 1; } @@ -691,7 +695,8 @@ char *e; g_strchomp(line); buddy = g_strchug(line); - debug_printf("\nbuddy: \"%s\"\n\n", buddy); + gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", + "buddy: \"%s\"\n", buddy); dest = g_string_append(dest, "b "); if (strchr(buddy, '{') != NULL) { /* buddy pounce, etc */ @@ -828,12 +833,14 @@ } if (stat(path, &st)) { - debug_printf("Unable to stat %s.\n", path); + gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", + path); return; } if (!(f = fopen(path, "r"))) { - debug_printf("Unable to open %s.\n", path); + gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", + path); return; } @@ -851,17 +858,17 @@ } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { /* AIM 4 buddy list */ - debug_printf("aim 4\n"); + gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); rewind(f); buf = translate_blt(f); } else if (strstr(first, "group") != NULL) { /* AIM 3 buddy list */ - debug_printf("aim 3\n"); + gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); rewind(f); buf = translate_lst(f); } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { /* GnomeICU (hopefully) */ - debug_printf("gnomeicu\n"); + gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); rewind(f); buf = translate_gnomeicu(f); @@ -1140,7 +1147,8 @@ static void blist_error_handler(GMarkupParseContext *context, GError *error, gpointer user_data) { blist_parser_error_occurred = TRUE; - debug_printf("error parsing blist.xml: %s\n", error->message); + gaim_debug(GAIM_DEBUG_ERROR, "blist import", + "Error parsing blist.xml: %s\n", error->message); } static GMarkupParser blist_parser = { @@ -1157,9 +1165,11 @@ GMarkupParseContext *context; GError *error = NULL; - debug_printf("gaim_blist_read: reading %s\n", filename); + gaim_debug(GAIM_DEBUG_INFO, "blist import", + "Reading %s\n", filename); if(!g_file_get_contents(filename, &contents, &length, &error)) { - debug_printf("error reading blist: %s\n", error->message); + gaim_debug(GAIM_DEBUG_ERROR, "blist import", + "Error reading blist: %s\n", error->message); g_error_free(error); return FALSE; } @@ -1173,7 +1183,8 @@ } if(!g_markup_parse_context_end_parse(context, NULL)) { - debug_printf("error parsing blist\n"); + gaim_debug(GAIM_DEBUG_ERROR, "blist import", + "Error parsing %s\n", filename); g_markup_parse_context_free(context); g_free(contents); return FALSE; @@ -1185,7 +1196,8 @@ if(blist_parser_error_occurred) return FALSE; - debug_printf("gaim_blist_read: finished reading %s\n", filename); + gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", + filename); return TRUE; } @@ -1357,7 +1369,8 @@ if(!user_dir) return; if(!blist_safe_to_write) { - debug_printf("AHH!! tried to write the blist before we read it!\n"); + gaim_debug(GAIM_DEBUG_WARNING, "blist save", + "AHH!! Tried to write the blist before we read it!\n"); return; } @@ -1374,13 +1387,15 @@ fclose(file); chmod(filename, S_IRUSR | S_IWUSR); } else { - debug_printf("unable to write %s\n", filename); + gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", + filename); } filename_real = g_build_filename(user_dir, "blist.xml", NULL); if(rename(filename, filename_real) < 0) - debug_printf("error renaming %s to %s\n", filename, filename_real); + gaim_debug(GAIM_DEBUG_ERROR, "blist save", + "Error renaming %s to %s\n", filename, filename_real); g_free(filename);
--- a/src/log.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/log.c Sat Apr 26 06:46:08 2003 +0000 @@ -202,7 +202,7 @@ if (stat(log_all_file, &st) < 0) *flag = 1; - debug_printf("Logging to: \"%s\"\n", log_all_file); + gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file); fd = fopen(log_all_file, "a");
--- a/src/main.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/main.c Sat Apr 26 06:46:08 2003 +0000 @@ -51,6 +51,7 @@ #include "gaim.h" #include "gaim-socket.h" #include "gtklist.h" +#include "gtkdebug.h" #if HAVE_SIGNAL_H #include <signal.h> #endif @@ -119,7 +120,7 @@ /* record what we have before we blow it away... */ save_prefs(); - debug_printf("Unloading all plugins\n"); + gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n"); gaim_plugins_unload_all(); /* XXX */ @@ -404,7 +405,8 @@ { switch (sig) { case SIGHUP: - debug_printf("caught signal %d\n", sig); + gaim_debug(GAIM_DEBUG_WARNING, "sighandler", + "Caught signal %d\n", sig); signoff_all(NULL, NULL); break; case SIGSEGV: @@ -440,7 +442,8 @@ #endif break; default: - debug_printf("caught signal %d\n", sig); + gaim_debug(GAIM_DEBUG_WARNING, "sighandler", + "Caught signal %d\n", sig); signoff_all(NULL, NULL); gaim_plugins_unload_all(); @@ -463,47 +466,50 @@ guint32 x; GError *error; - debug_printf("Core says: "); + gaim_debug(GAIM_DEBUG_INFO, "core socket", "Core says: "); g_io_channel_read_chars(source, &type, sizeof(type), &x, &error); if(error) g_error_free(error); if (x == 0) { - debug_printf("CORE IS GONE!\n"); + gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); g_io_channel_shutdown(source, TRUE, &error); if(error) g_free(error); return FALSE; } - debug_printf("%d ", type); + gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", type); g_io_channel_read_chars(source, &subtype, sizeof(subtype), &x, &error); if(error) g_error_free(error); if (x == 0) { - debug_printf("CORE IS GONE!\n"); + gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); g_io_channel_shutdown(source, TRUE, &error); if(error) g_error_free(error); return FALSE; } - debug_printf("%d ", subtype); + + gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", subtype); g_io_channel_read_chars(source, (guchar *)&len, sizeof(len), &x, &error); if(error) g_error_free(error); if (x == 0) { - debug_printf("CORE IS GONE!\n"); + gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); g_io_channel_shutdown(source, TRUE, &error); if(error) g_error_free(error); return FALSE; } - debug_printf("(%d bytes)\n", len); + + gaim_debug(GAIM_DEBUG_INFO, NULL, "(%d bytes)\n", len); data = g_malloc(len); g_io_channel_read_chars(source, data, len, &x, &error); if(error) g_error_free(error); if (x != len) { - debug_printf("CORE IS GONE! (read %d/%d bytes)\n", x, len); + gaim_debug(GAIM_DEBUG_ERROR, "core socket", + "CORE IS GONE! (read %d/%d bytes)\n", x, len); g_free(data); g_io_channel_shutdown(source, TRUE, &error); if(error) @@ -548,7 +554,8 @@ g_object_unref(G_OBJECT(icon)); g_list_free(icons); } else { - debug_printf("Failed to load default window icon!\n"); + gaim_debug(GAIM_DEBUG_ERROR, "ui_main", + "Failed to load the default window icon!\n"); } g_snprintf(name, sizeof(name), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); @@ -585,21 +592,21 @@ /* WIN32 print and log handlers */ static void gaim_dummy_print( const gchar* string ) { - return; + return; } static void gaim_dummy_log_handler (const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer user_data) { - return; + return; } static void gaim_log_handler (const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer user_data) { - debug_printf("%s - %s\n", domain, msg); + gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); g_log_default_handler(domain, flags, msg, user_data); } #endif /* _WIN32 */ @@ -861,6 +868,13 @@ return 0; } + /* Set the UI operation structures. */ + gaim_set_debug_ui_ops(gaim_get_gtk_debug_ui_ops()); + gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); + gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); + gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); + + plugin_search_paths[0] = LIBDIR; plugin_search_paths[1] = gaim_user_dir(); plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); @@ -878,11 +892,6 @@ wgaim_init(); #endif - /* Set the UI operation structures. */ - gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); - gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); - gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); - load_prefs(); core_main(); load_pounces(); @@ -904,7 +913,7 @@ } if (misc_options & OPT_MISC_DEBUG) - show_debug(); + gaim_gtk_debug_window_show(); static_proto_init();
--- a/src/multi.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/multi.c Sat Apr 26 06:46:08 2003 +0000 @@ -946,7 +946,8 @@ gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); g_object_set_data(G_OBJECT(entry), "position", GINT_TO_POINTER(puo->pos)); if (ma->proto_opt[puo->pos][0]) { - debug_printf("setting text %s\n", ma->proto_opt[puo->pos]); + gaim_debug(GAIM_DEBUG_MISC, "protocol options", + "Setting text %s\n", ma->proto_opt[puo->pos]); gtk_entry_set_text(GTK_ENTRY(entry), ma->proto_opt[puo->pos]); } else { gtk_entry_set_text(GTK_ENTRY(entry), puo->def); @@ -1719,7 +1720,8 @@ gc->account->connecting = FALSE; connecting_count--; - debug_printf("connecting_count: %d\n", connecting_count); + gaim_debug(GAIM_DEBUG_MISC, "accounts", + "Connecting count: %d\n", connecting_count); gaim_event_broadcast(event_signon, gc); system_log(log_signon, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); @@ -1790,8 +1792,11 @@ meters = g_slist_remove(meters, meter); g_free(meter); } - debug_printf("Disconnecting. user = %p, gc = %p (%p)\n", - gc->account, gc->account->gc, gc); + + gaim_debug(GAIM_DEBUG_MISC, "accounts", + "Disconnecting. user = %p, gc = %p (%p)\n", + gc->account, gc->account->gc, gc); + gc->account->gc = NULL; /* wasn't that awkward? */ if (!acctedit) @@ -2059,7 +2064,7 @@ /* core stuff */ /* remove this here so plugins get a sensible count of connections */ connections = g_slist_remove(connections, gc); - debug_printf("date: %s\n", full_date()); + gaim_debug(GAIM_DEBUG_MISC, "accounts", "date: %s\n", full_date()); gaim_event_broadcast(event_signoff, gc); system_log(log_signoff, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); /* set this in case the plugin died before really connecting. @@ -2069,7 +2074,8 @@ gc->account->connecting = FALSE; connecting_count--; } - debug_printf("connecting_count: %d\n", connecting_count); + gaim_debug(GAIM_DEBUG_MISC, "accounts", "connecting_count: %d\n", + connecting_count); serv_close(gc); /* more UI stuff */
--- a/src/plugin.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/plugin.c Sat Apr 26 06:46:08 2003 +0000 @@ -195,8 +195,8 @@ g_module_close(plugin->handle); plugin->handle = NULL; - debug_printf("%s is unloadable %s\n", - plugin->path, g_module_error()); + gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", + plugin->path, g_module_error()); gaim_plugin_destroy(plugin); @@ -292,7 +292,8 @@ g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); - debug_printf("Unloading plugin %s\n", plugin->info->name); + gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", + plugin->info->name); /* cancel any pending dialogs the plugin has */ do_ask_cancel_by_handle(plugin);
--- a/src/prefs.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/prefs.c Sat Apr 26 06:46:08 2003 +0000 @@ -72,7 +72,6 @@ static gboolean program_is_valid(const char *); #endif -struct debug_window *dw = NULL; GtkWidget *prefs = NULL; GtkWidget *debugbutton = NULL; static int notebook_page = 0; @@ -345,7 +344,9 @@ /* It looks like we're dealing with a local file. Let's * just untar it in the right place */ if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { - debug_printf("%s\n", converr ? converr->message : "g_filename_from_uri error"); + gaim_debug(GAIM_DEBUG_ERROR, "theme dnd", "%s\n", + (converr ? converr->message : + "g_filename_from_uri error")); return; } theme_install_theme(tmp, NULL); @@ -1938,99 +1939,6 @@ gtk_widget_show(prefs); } -static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy) -{ - if (debugbutton) - gtk_button_clicked(GTK_BUTTON(debugbutton)); - if (misc_options & OPT_MISC_DEBUG) { - misc_options ^= OPT_MISC_DEBUG; - } - g_free(dw); - dw = NULL; - save_prefs(); - return FALSE; -} - -static void build_debug() -{ - GtkWidget *sw; - GtkTextBuffer *buffer; - GtkTextIter end; - - if (!dw) - dw = g_new0(struct debug_window, 1); - - GAIM_DIALOG(dw->window); - gtk_window_set_default_size(GTK_WINDOW(dw->window), 500, 200); - gtk_window_set_role(GTK_WINDOW(dw->window), "debug"); - gtk_window_set_title(GTK_WINDOW(dw->window), _("Debug Window")); - g_signal_connect(G_OBJECT(dw->window), "delete_event", G_CALLBACK(debug_delete), NULL); - - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - - dw->entry = gtk_text_view_new(); - gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dw->entry), FALSE); - gtk_text_view_set_editable(GTK_TEXT_VIEW(dw->entry), FALSE); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dw->entry), GTK_WRAP_WORD_CHAR); - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dw->entry)); - gtk_text_buffer_get_end_iter(buffer, &end); - gtk_text_buffer_create_mark(buffer, "end", &end, FALSE); - - gtk_container_add(GTK_CONTAINER(sw), dw->entry); - gtk_container_add(GTK_CONTAINER(dw->window), sw); - gtk_widget_show_all(dw->window); -} - -void show_debug() -{ - if ((misc_options & OPT_MISC_DEBUG)) { - if (!dw || !dw->window) - build_debug(); - gtk_widget_show(dw->window); - } else { - if (!dw) - return; - gtk_widget_destroy(dw->window); - dw->window = NULL; - } -} - -void toggle_debug() -{ - misc_options ^= OPT_MISC_DEBUG; - show_debug(); - save_prefs(); -} - -void debug_printf(char *fmt, ...) -{ - va_list ap; - gchar *s; - - va_start(ap, fmt); - s = g_strdup_vprintf(fmt, ap); - va_end(ap); - - if (misc_options & OPT_MISC_DEBUG && dw) { - GtkTextBuffer *buffer; - GtkTextMark *endmark; - GtkTextIter end; - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dw->entry)); - endmark = gtk_text_buffer_get_mark(buffer, "end"); - gtk_text_buffer_get_iter_at_mark(buffer, &end, endmark); - gtk_text_buffer_insert(buffer, &end, s, -1); - gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(dw->entry), endmark); - } - if (opt_debug) - g_print("%s", s); - g_free(s); -} - void set_option(GtkWidget *w, int *option) { *option = !(*option); @@ -2040,8 +1948,12 @@ { misc_options ^= option; - if (option == OPT_MISC_DEBUG) - show_debug(); + if (option == OPT_MISC_DEBUG) { + if ((misc_options & OPT_MISC_DEBUG)) + gaim_gtk_debug_window_show(); + else + gaim_gtk_debug_window_hide(); + } else if(option == OPT_MISC_USE_SERVER_ALIAS) { /* XXX blist reset the aliases here */ gaim_conversation_foreach(gaim_conversation_autoset_title); @@ -2179,7 +2091,8 @@ g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(set_away_option), (int *)option); } else { - debug_printf("gaim_button: \"%s\" has no signal handler attached to it!\n", text); + gaim_debug(GAIM_DEBUG_WARNING, "gaim_button", + "\"%s\" has no signal handler attached to it!\n", text); } gtk_widget_show(button); @@ -2304,7 +2217,9 @@ } if (!g_shell_parse_argv(program, NULL, &argv, &error)) { - debug_printf("Could not parse program '%s': ", error->message); + gaim_debug(GAIM_DEBUG_ERROR, "program_is_valid", + "Could not parse program '%s': %s\n", + program, error->message); g_error_free(error); return FALSE; } @@ -2372,7 +2287,7 @@ *option = *option & ~clear; *option = *option | opt; } else { - debug_printf("HELLO %d\n", opt); + gaim_debug(GAIM_DEBUG_MISC, "dropdown_set", "HELLO %d\n", opt); *option = opt; }
--- a/src/protocols/irc/irc.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/protocols/irc/irc.c Sat Apr 26 06:46:08 2003 +0000 @@ -1310,6 +1310,66 @@ write(xfer->fd, (char *)&pos, 4); } +/* NOTE: This was taken from irssi. Thanks irssi! */ + +static gboolean +is_numeric(const char *str, char end_char) +{ + g_return_val_if_fail(str != NULL, FALSE); + + if (*str == '\0' || *str == end_char) + return FALSE; + + while (*str != '\0' && *str != end_char) { + if (*str < '0' || *str > '9') + return FALSE; + + str++; + } + + return TRUE; +} + +#define get_params_match(params, pos) \ + (is_numeric(params[pos], '\0') && \ + is_numeric(params[(pos)+1], '\0') && atol(params[(pos)+1]) < 65536 && \ + is_numeric(params[(pos)+2], '\0')) + +/* Return number of parameters in `params' that belong to file name. + Normally it's paramcount-3, but I don't think anything forbids of + adding some extension where there could be more parameters after + file size. + + MIRC sends filenames with spaces quoted ("file name"), but I'd rather + not trust that entirely either. At least some clients that don't really + understand the problem with spaces in file names sends the file name + without any quotes. */ +static int +get_file_params_count(char **params, int paramcount) +{ + int pos, best; + + if (*params[0] == '"') { + /* quoted file name? */ + for (pos = 0; pos < paramcount - 3; pos++) { + if (params[pos][strlen(params[pos]) - 1] == '"' && + get_params_match(params, pos + 1)) { + + return pos + 1; + } + } + } + + best = paramcount - 3; + + for (pos = paramcount - 3; pos > 0; pos--) { + if (get_params_match(params, pos)) + best = pos; + } + + return best; +} + static void handle_ctcp(struct gaim_connection *gc, char *to, char *nick, char *msg, char *word[], char *word_eol[]) @@ -1325,19 +1385,19 @@ g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick); do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); } - if (!g_ascii_strncasecmp(msg, "CLIENTINFO", 10)) { + else if (!g_ascii_strncasecmp(msg, "CLIENTINFO", 10)) { g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001"); irc_send_notice (gc, nick, buf); g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick); do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); } - if (!g_ascii_strncasecmp(msg, "USERINFO", 8)) { + else if (!g_ascii_strncasecmp(msg, "USERINFO", 8)) { g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias); irc_send_notice (gc, nick, buf); g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick); do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); } - if (!g_ascii_strncasecmp(msg, "ACTION", 6)) { + else if (!g_ascii_strncasecmp(msg, "ACTION", 6)) { char *po = strchr(msg + 6, 1); char *tmp; if (po) *po = 0; @@ -1345,13 +1405,13 @@ handle_privmsg(gc, to, nick, tmp); g_free(tmp); } - if (!g_ascii_strncasecmp(msg, "PING", 4)) { + else if (!g_ascii_strncasecmp(msg, "PING", 4)) { g_snprintf(buf, sizeof(buf), "\001%s\001", msg); irc_send_notice (gc, nick, buf); g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick); do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); } - if (!g_ascii_strncasecmp(msg, "DCC CHAT", 8)) { + else if (!g_ascii_strncasecmp(msg, "DCC CHAT", 8)) { char **chat_args = g_strsplit(msg, " ", 5); char ask[1024]; struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1); @@ -1362,24 +1422,60 @@ g_snprintf(ask, sizeof(ask), _("%s would like to establish a DCC chat"), nick); do_ask_dialog(ask, _("This requires a direct connection to be established between the two computers. Messages sent will not pass through the IRC server"), dccchat, _("Connect"), dcc_chat_init, _("Cancel"), dcc_chat_cancel, my_protocol->handle, FALSE); } - - - if (!g_ascii_strncasecmp(msg, "DCC SEND", 8)) { + else if (!g_ascii_strncasecmp(msg, "DCC SEND", 8)) { struct gaim_xfer *xfer; char **send_args; char *ip, *filename; struct irc_xfer_data *xfer_data; size_t size; + int param_count, file_params, len; int port; - send_args = g_strsplit(msg, " ", 6); - send_args[5][strlen(send_args[5])-1] = 0; + /* Okay, this is ugly, but should get us past "DCC SEND" */ + msg = strstr(msg, "DCC SEND"); + msg = strchr(msg, ' ') + 1; + msg = strchr(msg, ' ') + 1; + + /* SEND <file name> <address> <port> <size> [...] */ + send_args = g_strsplit(msg, " ", -1); + + for (param_count = 0; send_args[param_count] != NULL; param_count++) + ; + + if (param_count < 4) { + char buf[IRC_BUF_LEN]; + + g_snprintf(buf, sizeof(buf), + _("Received an invalid file send request from %s."), + nick); + + do_error_dialog(buf, _("IRC Error"), GAIM_ERROR); + + return; + } + + file_params = get_file_params_count(send_args, param_count); + + /* send_args[paramcount - 1][strlen(send_args[5])-1] = 0; */ /* Give these better names. */ - ip = send_args[3]; - filename = send_args[2]; - size = atoi(send_args[5]); - port = atoi(send_args[4]); + ip = send_args[file_params]; + port = atoi(send_args[file_params + 1]); + size = atoi(send_args[file_params + 2]); + + send_args[file_params] = NULL; + + filename = g_strjoinv(" ", send_args); + + g_strfreev(send_args); + + len = strlen(filename); + + if (len > 1 && *filename == '"' && filename[len - 1] == '"') { + /* "file name" - MIRC sends filenames with spaces like this */ + filename[len - 1] = '\0'; + g_memmove(filename, filename + 1, len); + } /* Setup the IRC-specific transfer data. */ xfer_data = g_malloc0(sizeof(struct irc_xfer_data)); @@ -1410,8 +1506,6 @@ /* Now perform the request! */ gaim_xfer_request(xfer); } - - /*write_to_conv(c, out, WFLAG_SYSTEM, NULL, time(NULL), -1);*/ } static gboolean
--- a/src/protocols/oscar/oscar.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/protocols/oscar/oscar.c Sat Apr 26 06:46:08 2003 +0000 @@ -4549,10 +4549,13 @@ maxitems = va_arg(ap, fu16_t *); va_end(ap); - debug_printf("ssi rights:"); + gaim_debug(GAIM_DEBUG_MISC, "prpl-oscar", "ssi rights:"); + for (i=0; i<numtypes; i++) - debug_printf(" max type 0x%04x=%hd,", i, maxitems[i]); - debug_printf("\n"); + gaim_debug(GAIM_DEBUG_MISC, NULL, " max type 0x%04x=%hd,", + i, maxitems[i]); + + gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); if (numtypes >= 0) od->rights.maxbuddies = maxitems[0];
--- a/src/proxy.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/proxy.c Sat Apr 26 06:46:08 2003 +0000 @@ -89,7 +89,9 @@ gaim_cond |= GAIM_INPUT_WRITE; /* - debug_printf("CLOSURE: callback for %d, fd is %d\n", closure->result, g_io_channel_unix_get_fd(source)); + gaim_debug(GAIM_DEBUG_MISC, "proxy", + "CLOSURE: callback for %d, fd is %d\n", + closure->result, g_io_channel_unix_get_fd(source)); */ closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); @@ -114,7 +116,12 @@ channel = g_io_channel_unix_new(source); closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, gaim_io_invoke, closure, gaim_io_destroy); - /* debug_printf("CLOSURE: adding input watcher %d for fd %d\n", closure->result, source); */ + + /* + gaim_debug(GAIM_DEBUG_MISC, "proxy", + "CLOSURE: adding input watcher %d for fd %d\n", + closure->result, source); + */ g_io_channel_unref(channel); return closure->result; @@ -122,7 +129,8 @@ void gaim_input_remove(gint tag) { - /* debug_printf("CLOSURE: removing input watcher %d\n", tag); */ + /* gaim_debug(GAIM_DEBUG_MISC, "proxy", + "CLOSURE: removing input watcher %d\n", tag); */ if (tag > 0) g_source_remove(tag); } @@ -182,14 +190,17 @@ /* Are you alive? */ if(kill(req->dns_pid, 0) != 0) { - debug_printf("DNS child %d no longer exists\n", req->dns_pid); + gaim_debug(GAIM_DEBUG_WARNING, "dns", + "DNS child %s no longer exists\n", req->dns_pid); return -1; } /* Let's contact this lost child! */ rc = write(req->fd_in, dns_params, sizeof(*dns_params)); if(rc<0) { - debug_printf("Error writing to DNS child %d: %s\n", req->dns_pid, strerror(errno)); + gaim_debug(GAIM_DEBUG_ERROR, "dns", + "Unable to write to DNS child %d: %d\n", + req->dns_pid, strerror(errno)); close(req->fd_in); return -1; } @@ -199,12 +210,15 @@ /* Did you hear me? (This avoids some race conditions) */ rc = read(req->fd_out, &ch, 1); if(rc != 1 || ch!='Y') { - debug_printf("DNS child %d not responding: killing it!\n", req->dns_pid); + gaim_debug(GAIM_DEBUG_WARNING, "dns", + "DNS child %d not responding. Killing it!\n", + req->dns_pid); kill(req->dns_pid, SIGKILL); return -1; } - debug_printf("Successfuly sent DNS request to child %d\n", req->dns_pid); + gaim_debug(GAIM_DEBUG_INFO, "dns", + "Successfully sent DNS request to child %d\n", req->dns_pid); return 0; } @@ -222,13 +236,17 @@ req->callback = r->callback; req->data = r->data; - debug_printf("Processing queued DNS query for '%s' with child %d\n", req->host, req->dns_pid); + gaim_debug(GAIM_DEBUG_INFO, "dns", + "Processing queued DNS query for '%s' with child %d\n", + req->host, req->dns_pid); if(send_dns_request_to_child(req, &(r->params)) != 0) { req_free(req); req = NULL; - debug_printf("Intent of process queued query of '%s' failed, requeing...\n", - r->params.hostname); + + gaim_debug(GAIM_DEBUG_WARNING, "dns", + "Intent of process queued query of '%s' failed, " + "requeueing...\n", r->params.hostname); g_queue_push_head(queued_requests, r); } else { req->inpa = gaim_input_add(req->fd_out, GAIM_INPUT_READ, host_resolved, req); @@ -251,7 +269,7 @@ struct sockaddr *addr = NULL; socklen_t addrlen; - debug_printf("Host '%s' resolved\n", req->host); + gaim_debug(GAIM_DEBUG_INFO, "dns", "Host '%s' resolved\n", req->host); gaim_input_remove(req->inpa); rc=read(req->fd_out, &err, sizeof(err)); @@ -264,7 +282,7 @@ hstrerror(err), #endif req->dns_pid); - debug_printf("%s\n",message); + gaim_debug(GAIM_DEBUG_ERROR, "dns", "%s\n", message); req->callback(NULL, req->data, message); release_dns_child(req); return; @@ -284,7 +302,7 @@ } else if(rc==-1) { char message[1024]; g_snprintf(message, sizeof(message), "Error reading from DNS child: %s",strerror(errno)); - debug_printf("%s\n",message); + gaim_debug(GAIM_DEBUG_ERROR, "dns", "%s\n", message); req->callback(NULL, req->data, message); req_free(req); return; @@ -292,7 +310,7 @@ char message[1024]; g_snprintf(message, sizeof(message), "EOF reading from DNS child"); close(req->fd_out); - debug_printf("%s\n",message); + gaim_debug(GAIM_DEBUG_ERROR, "dns", "%s\n", message); req->callback(NULL, req->data, message); req_free(req); return; @@ -344,7 +362,8 @@ e[MAX(n,sizeof(e)-1)] = '\0'; if(strstr(e,"gdb")) { - debug_printf("Debugger detected, performing useless query...\n"); + gaim_debug(GAIM_DEBUG_INFO, "dns", + "Debugger detected, performing useless query...\n"); gethostbyname("x.x.x.x.x"); } #endif @@ -385,12 +404,16 @@ if(!queued_requests) queued_requests = g_queue_new(); g_queue_push_tail(queued_requests, r); - debug_printf("DNS query for '%s' queued\n", hostname); + + gaim_debug(GAIM_DEBUG_INFO, "dns", + "DNS query for '%s' queued\n", hostname); + return 0; } if(pipe(child_out) || pipe(child_in)) { - debug_printf("Could not create pipes: %s",strerror(errno)); + gaim_debug(GAIM_DEBUG_ERROR, "dns", + "Could not create pipes: %s\n", strerror(errno)); return -1; } @@ -514,15 +537,18 @@ close(child_out[1]); close(child_in[0]); if(req->dns_pid==-1) { - debug_printf("Could not create child process for DNS: %s\n",strerror(errno)); + gaim_debug(GAIM_DEBUG_ERROR, "dns", + "Could not create child process for DNS: %s\n", + strerror(errno)); g_free(req); return -1; } req->fd_in = child_in[1]; req->fd_out = child_out[0]; number_of_dns_children++; - debug_printf("Created new DNS child %d, there are now %d children.\n", - req->dns_pid, number_of_dns_children); + gaim_debug(GAIM_DEBUG_INFO, "dns", + "Created new DNS child %d, there are now %d children.\n", + req->dns_pid, number_of_dns_children); } req->host=g_strdup(hostname); req->port=port; @@ -561,8 +587,9 @@ if (!inet_aton(hostname, &sin.sin_addr)) { struct hostent *hp; if(!(hp = gethostbyname(hostname))) { - debug_printf("gaim_gethostbyname(\"%s\", %d) failed: %s", - hostname, port, hstrerror(h_errno)); + gaim_debug(GAIM_DEBUG_ERROR, "dns", + "gaim_gethostbyname(\"%s\", %d) failed: %s\n", + hostname, port, hstrerror(h_errno)); return -1; } memset(&sin, 0, sizeof(struct sockaddr_in)); @@ -590,7 +617,7 @@ int error=0; int ret=0; - debug_printf("Connected\n"); + gaim_debug(GAIM_DEBUG_INFO, "proxy", "Connected.\n"); len = sizeof(error); @@ -602,8 +629,10 @@ phb->func(phb->data, -1, GAIM_INPUT_READ); g_free(phb->host); g_free(phb); - debug_printf("getsockopt SO_ERROR check: %s\n", - strerror(((ret<0) ? errno : error))); + + gaim_debug(GAIM_DEBUG_ERROR, "proxy", + "getsockopt SO_ERROR check: %s\n", + strerror((ret < 0) ? errno : error)); return; } fcntl(source, F_SETFL, 0); @@ -631,30 +660,34 @@ { int fd = -1; - debug_printf("connecting to %s:%d with no proxy\n", phb->host, phb->port); + gaim_debug(GAIM_DEBUG_INFO, "proxy", + "Connecting to %s:%d with no proxy\n", phb->host, phb->port); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { - debug_printf("unable to create socket: %s\n", strerror(errno)); + gaim_debug(GAIM_DEBUG_ERROR, "proxy", + "Unable to create socket: %s\n", strerror(errno)); return -1; } fcntl(fd, F_SETFL, O_NONBLOCK); if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - debug_printf("Connect would have blocked\n"); + gaim_debug(GAIM_DEBUG_WARNING, "proxy", + "Connect would have blocked.\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); } else { - debug_printf("connect failed (errno %d)\n", errno); + gaim_debug(GAIM_DEBUG_ERROR, "proxy", + "Connect failed (errno %d)\n", errno); close(fd); return -1; } } else { unsigned int len; int error = ETIMEDOUT; - debug_printf("Connect didn't block\n"); + gaim_debug(GAIM_DEBUG_MISC, "proxy", "Connect didn't block.\n"); len = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - debug_printf("getsockopt failed\n"); + gaim_debug(GAIM_DEBUG_ERROR, "proxy", "getsockopt failed.\n"); close(fd); return -1; } @@ -707,11 +740,13 @@ } if(error) { - debug_printf("Unable to parse proxy's response: %s\n", inputline); + gaim_debug(GAIM_DEBUG_ERROR, "proxy", + "Unable to parse proxy's response: %s\n", inputline); close(source); source=-1; } else if(status!=200) { - debug_printf("Proxy reserver replied: (%s)\n", p); + gaim_debug(GAIM_DEBUG_ERROR, "proxy", + "Proxy server replied: (%s)\n", p); close(source); source=-1; } @@ -731,7 +766,8 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connected\n"); + gaim_debug(GAIM_DEBUG_INFO, "http proxy", "Connected.\n"); + if (phb->inpa > 0) gaim_input_remove(phb->inpa); len = sizeof(error); @@ -776,7 +812,10 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using HTTP\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); + gaim_debug(GAIM_DEBUG_INFO, "http proxy", + "Connecting to %s:%d via %s:%d using HTTP\n", + phb->host, phb->port, phb->gpi->proxyhost, + phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { return -1; @@ -786,7 +825,8 @@ if (connect(fd, addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - debug_printf("Connect would have blocked\n"); + gaim_debug(GAIM_DEBUG_WARNING, "http proxy", + "Connect would have blocked.\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, http_canwrite, phb); } else { close(fd); @@ -796,7 +836,9 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connect didn't block\n"); + gaim_debug(GAIM_DEBUG_MISC, "http proxy", + "Connect didn't block.\n"); + len = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(fd); @@ -841,7 +883,8 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connected\n"); + gaim_debug(GAIM_DEBUG_INFO, "s4 proxy", "Connected.\n"); + if (phb->inpa > 0) gaim_input_remove(phb->inpa); len = sizeof(error); @@ -891,7 +934,10 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using SOCKS4\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); + gaim_debug(GAIM_DEBUG_INFO, "socks4 proxy", + "Connecting to %s:%d via %s:%d using SOCKS4\n", + phb->host, phb->port, phb->gpi->proxyhost, + phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { return -1; @@ -900,7 +946,8 @@ fcntl(fd, F_SETFL, O_NONBLOCK); if (connect(fd, addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - debug_printf("Connect would have blocked\n"); + gaim_debug(GAIM_DEBUG_WARNING, "socks4 proxy", + "Connect would have blocked.\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, phb); } else { close(fd); @@ -910,7 +957,9 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connect didn't block\n"); + gaim_debug(GAIM_DEBUG_MISC, "socks4 proxy", + "Connect didn't block.\n"); + len = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(fd); @@ -929,10 +978,10 @@ struct PHB *phb = data; gaim_input_remove(phb->inpa); - debug_printf("able to read again\n"); + gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read again.\n"); if (read(source, buf, 10) < 10) { - debug_printf("or not...\n"); + gaim_debug(GAIM_DEBUG_WARNING, "socks5 proxy", "or not...\n"); close(source); if(!phb->account || phb->account->gc) phb->func(phb->data, -1, GAIM_INPUT_READ); @@ -941,7 +990,7 @@ return; } if ((buf[0] != 0x05) || (buf[1] != 0x00)) { - debug_printf("bad data\n"); + gaim_debug(GAIM_DEBUG_ERROR, "socks5 proxy", "Bad data.\n"); close(source); if(!phb->account || phb->account->gc) phb->func(phb->data, -1, GAIM_INPUT_READ); @@ -990,7 +1039,7 @@ struct PHB *phb = data; gaim_input_remove(phb->inpa); - debug_printf("got auth response\n"); + gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got auth response.\n"); if (read(source, buf, 2) < 2) { close(source); @@ -1019,7 +1068,7 @@ struct PHB *phb = data; gaim_input_remove(phb->inpa); - debug_printf("able to read\n"); + gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read.\n"); if (read(source, buf, 2) < 2) { close(source); @@ -1070,7 +1119,8 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connected\n"); + gaim_debug(GAIM_INFO, "socks5 proxy", "Connected.\n"); + if (phb->inpa > 0) gaim_input_remove(phb->inpa); len = sizeof(error); @@ -1098,7 +1148,7 @@ } if (write(source, buf, i) < i) { - debug_printf("unable to write\n"); + gaim_debug(GAIM_DEBUG_ERROR, "socks5 proxy", "Unable to write\n"); close(source); if(!phb->account || phb->account->gc) phb->func(phb->data, -1, GAIM_INPUT_READ); @@ -1114,7 +1164,10 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); + gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", + "Connecting to %s:%d via %s:%d using SOCKS5\n", + phb->host, phb->port, phb->gpi->proxyhost, + phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { return -1; @@ -1123,7 +1176,8 @@ fcntl(fd, F_SETFL, O_NONBLOCK); if (connect(fd, addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - debug_printf("Connect would have blocked\n"); + gaim_debug(GAIM_DEBUG_WARNING, "socks5 proxy", + "Connect would have blocked.\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, phb); } else { close(fd); @@ -1133,7 +1187,8 @@ unsigned int len; int error = ETIMEDOUT; - debug_printf("Connect didn't block\n"); + gaim_debug(GAIM_DEBUG_MISC, "socks5 proxy", + "Connect didn't block.\n"); len = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(fd);
--- a/src/prpl.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/prpl.c Sat Apr 26 06:46:08 2003 +0000 @@ -84,7 +84,8 @@ { GSList *d = do_ask_dialogs; - debug_printf("%d dialogs to search\n", g_slist_length(d)); + gaim_debug(GAIM_DEBUG_MISC, "prpl", + "%d dialogs to search", g_slist_length(d)); while (d) { struct doaskstruct *doask = d->data; @@ -92,7 +93,8 @@ d = d->next; if (doask->handle == handle) { - debug_printf("removing dialog, %d remain\n", g_slist_length(d)); + gaim_debug(GAIM_DEBUG_MISC, "prpl", + "Removing dialog, %d remain\n", g_slist_length(d)); gtk_dialog_response(GTK_DIALOG(doask->dialog), GTK_RESPONSE_NONE); } } @@ -413,7 +415,9 @@ gtk_widget_destroy(mn->email_win); return; } - debug_printf("removing mail notification\n"); + + gaim_debug(GAIM_DEBUG_INFO, "prpl", "Removing mail notification.\n"); + mailnots = g_slist_remove(mailnots, mn); if (mn->url) g_free(mn->url); @@ -555,7 +559,8 @@ return; } - debug_printf("Got icon for %s (length %d)\n", realwho, len); + gaim_debug(GAIM_DEBUG_MISC, "prpl", "Got icon for %s (length %d)\n", + realwho, len); id->data = g_memdup(data, len); id->len = len; @@ -577,10 +582,13 @@ g_free(random); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { - debug_printf("creating icon cache directory\n"); + gaim_debug(GAIM_DEBUG_INFO, "buddy icons", + "Creating icon cache directory.\n"); + if(mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) - debug_printf("error creating directory %s: %s\n", - dirname, strerror(errno)); + gaim_debug(GAIM_DEBUG_ERROR, "buddy icons", + "Unable to create directory %s: %s\n", + dirname, strerror(errno)); } g_free(dirname);
--- a/src/server.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/server.c Sat Apr 26 06:46:08 2003 +0000 @@ -55,11 +55,13 @@ return; } - debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", - account->username, p->info->name); + gaim_debug(GAIM_DEBUG_INFO, "server", + PACKAGE " " VERSION " logging in %s using %s\n", + account->username, p->info->name); account->connecting = TRUE; connecting_count++; - debug_printf("connecting_count: %d\n", connecting_count); + gaim_debug(GAIM_DEBUG_MISC, "server", + "connection count: %d\n", connecting_count); gaim_event_broadcast(event_connecting, account); prpl_info->login(account); } @@ -82,10 +84,10 @@ static void update_keepalive(struct gaim_connection *gc, gboolean on) { if (on && !gc->keepalive) { - debug_printf("allowing NOP\n"); + gaim_debug(GAIM_DEBUG_INFO, "server", "allowing NOP\n"); gc->keepalive = g_timeout_add(60000, send_keepalive, gc); } else if (!on && gc->keepalive > 0) { - debug_printf("removing NOP\n"); + gaim_debug(GAIM_DEBUG_INFO, "server", "removing NOP\n"); g_source_remove(gc->keepalive); gc->keepalive = 0; } @@ -754,7 +756,7 @@ */ if (flags & IM_FLAG_GAIMUSER) - debug_printf("%s is a gaim user.\n", who); + gaim_debug(GAIM_DEBUG_MISC, "%s is a gaim user.\n", who); /* * We should update the conversation window buttons and menu, @@ -1029,7 +1031,8 @@ } if (!b) { - debug_printf("Error, no such buddy %s\n", name); + gaim_debug(GAIM_DEBUG_ERROR, "server", + "No such buddy: %s\n", name); return; } @@ -1308,7 +1311,8 @@ gaim_event_broadcast(event_chat_leave, g, gaim_chat_get_id(chat)); - debug_printf("Leaving room %s.\n", gaim_conversation_get_name(conv)); + gaim_debug(GAIM_DEBUG_INFO, "server", "Leaving room: %s\n", + gaim_conversation_get_name(conv)); g->buddy_chats = g_slist_remove(g->buddy_chats, conv);
--- a/src/session.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/session.c Sat Apr 26 06:46:08 2003 +0000 @@ -56,13 +56,14 @@ status = IceProcessMessages(connection, NULL, NULL); if (status == IceProcessMessagesIOError) { - debug_printf("Session Management: ICE IO error, closing connection... "); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "ICE IO error, closing connection... "); /* IO error, please disconnect */ IceSetShutdownNegotiation(connection, False); IceCloseConnection(connection); - debug_printf("done\n"); + gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); /* cancel the handler */ return FALSE; @@ -79,7 +80,8 @@ if (opening) { GIOChannel *channel; - debug_printf("Session Management: handling new ICE connection... "); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Handling new ICE connection... "); /* ensure ICE connection is not passed to child processes */ fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); @@ -93,14 +95,15 @@ /* store the input ID as a pointer for when it closes */ *watch_data = (IcePointer)GUINT_TO_POINTER(input_id); } else { - debug_printf("Session Management: handling closed ICE connection... "); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Handling closed ICE connection... "); /* get the input ID back and stop watching it */ input_id = GPOINTER_TO_UINT((gpointer) *watch_data); g_source_remove(input_id); } - debug_printf("done\n"); + gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); } /* We call any handler installed before (or after) ice_init but @@ -111,12 +114,13 @@ */ static void ice_io_error_handler(IceConn connection) { - debug_printf("Session Management: handling ICE IO error... "); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Handling ICE IO error... "); if (ice_installed_io_error_handler) (*ice_installed_io_error_handler)(connection); - debug_printf("done\n"); + gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); } static void ice_init() { @@ -130,7 +134,8 @@ IceAddConnectionWatch(ice_connection_watch, NULL); - debug_printf("Session Management: ICE initialised\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "ICE initialized.\n"); } /* my magic utility function */ @@ -169,7 +174,8 @@ interact_style == SmInteractStyleNone && !shutdown && !fast) { /* this is just a dry run, spit it back */ - debug_printf("Session Management: received first save_yourself\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Received first save_yourself\n"); SmcSaveYourselfDone(conn, True); had_first_save = TRUE; return; @@ -178,7 +184,8 @@ /* tum ti tum... don't add anything else here without * * reading SMlib.PS from an X.org ftp server near you */ - debug_printf("Session Management: received save_yourself\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Received save_yourself\n"); if (save_type == SmSaveGlobal || save_type == SmSaveBoth) { /* may as well do something ... */ @@ -189,16 +196,19 @@ } void session_die(SmcConn conn, SmPointer data) { - debug_printf("Session Management: received die\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Received die\n"); do_quit(); } void session_save_complete(SmcConn conn, SmPointer data) { - debug_printf("Session Management: received save_complete\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Received save_complete\n"); } void session_shutdown_cancelled(SmcConn conn, SmPointer data) { - debug_printf("Session Management: received shutdown_cancelled\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Received shutdown_cancelled\n"); } /* utility functions stolen from Gnome-client */ @@ -279,12 +289,14 @@ if (session != NULL) { /* session is already established, what the hell is going on? */ - debug_printf("Session Management: duplicated call to session_init!\n"); + gaim_debug(GAIM_DEBUG_WARNING, "Session Management", + "Duplicated call to session_init!\n"); return; } if (g_getenv("SESSION_MANAGER") == NULL) { - debug_printf("Session Management: no SESSION_MANAGER found, aborting\n"); + gaim_debug(GAIM_DEBUG_ERROR, "Session Management", + "No SESSION_MANAGER found, aborting.\n"); return; } @@ -301,9 +313,11 @@ callbacks.shutdown_cancelled.client_data = NULL; if (previous_id) { - debug_printf("Session Management: connecting with previous ID %s\n", previous_id); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Connecting with previous ID %s\n", previous_id); } else { - debug_printf("Session Management: connecting with no previous ID\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Connecting with no previous ID\n"); } session = SmcOpenConnection(NULL, "session", SmProtoMajor, SmProtoMinor, SmcSaveYourselfProcMask | @@ -312,15 +326,19 @@ if (session == NULL) { if (error[0] != '\0') { - debug_printf("Session Management: connection failed with error: %s\n", error); + gaim_debug(GAIM_DEBUG_ERROR, "Session Management", + "Connection failed with error: %s\n", error); } else { - debug_printf("Session Management: connection failed with unknown error\n"); + gaim_debug(GAIM_DEBUG_ERROR, "Session Management", + "Connetion failed with unknown error.\n"); } return; } tmp = SmcVendor(session); - debug_printf("Session Management: connected to manager (%s) with client ID %s\n", tmp, client_id); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Connected to manager (%s) with client ID %s\n", + tmp, client_id); g_free(tmp); session_managed = TRUE; @@ -342,7 +360,8 @@ session_set_string(session, SmProgram, g_get_prgname()); myself = g_strdup(argv0); - debug_printf("Session Management: using %s as command\n", myself); + gaim_debug(GAIM_DEBUG_MISC, "Session Management", + "Using %s as command\n", myself); cmd = session_make_command(NULL); session_set_array(session, SmCloneCommand, cmd); @@ -372,6 +391,7 @@ SmcCloseConnection(session, 0, NULL); - debug_printf("Session Management: connection closed\n"); + gaim_debug(GAIM_DEBUG_INFO, "Session Management", + "Connection closed.\n"); #endif /* USE_SM */ }
--- a/src/sound.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/sound.c Sat Apr 26 06:46:08 2003 +0000 @@ -96,7 +96,8 @@ static void check_ao_init() { if(!ao_initialized) { - debug_printf("Initializing sound ouput drivers.\n"); + gaim_debug(GAIM_DEBUG_INFO, "sound", + "Initializing sound output drivers.\n"); ao_initialize(); ao_initialized = TRUE; } @@ -122,12 +123,14 @@ } if(ao_driver != -1) { ao_info *info = ao_driver_info(ao_driver); - debug_printf("Sound output driver loaded: %s\n", info->name); + gaim_debug(GAIM_DEBUG_INFO, "sound", + "Sound output driver loaded: %s\n", info->name); } #endif /* USE_AO */ #ifdef USE_NAS if((sound_options & OPT_SOUND_NAS)) - debug_printf("Sound output driver loaded: NAS output\n"); + gaim_debug(GAIM_DEBUG_INFO, "sound", + "Sound output driver loaded: NAS output\n"); #endif /* USE_NAS */ } @@ -275,9 +278,10 @@ return; #endif /* USE_NAS_AUDIO || USE_AO */ #else /* _WIN32 */ - debug_printf("Playing %s\n", filename); + gaim_debug(GAIM_DEBUG_INFO, "sound", "Playing %s\n", filename); + if (!PlaySound(filename, 0, SND_ASYNC | SND_FILENAME)) - debug_printf("Error playing sound."); + gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); #endif /* _WIN32 */ } @@ -287,7 +291,8 @@ return; if (event >= GAIM_NUM_SOUNDS) { - debug_printf("got request for unknown sound: %d\n", event); + gaim_debug(GAIM_DEBUG_MISC, "sound", + "got request for unknown sound: %d\n", event); return; }
--- a/src/ui.h Sat Apr 26 05:31:26 2003 +0000 +++ b/src/ui.h Sat Apr 26 06:46:08 2003 +0000 @@ -90,12 +90,6 @@ GAIM_BUTTON_VERTICAL } GaimButtonStyle; - -struct debug_window { - GtkWidget *window; - GtkWidget *entry; -}; - /* XXX CUI: save_pos and window_size are used by gaimrc.c which is core. * Need to figure out options saving. Same goes for several global variables as well. */ struct save_pos { @@ -308,7 +302,6 @@ extern void set_option(GtkWidget *, int *); extern void show_prefs(); extern void show_debug(); -extern void toggle_debug(); extern void update_color(GtkWidget *, GtkWidget *); extern void set_default_away(GtkWidget *, gpointer); extern void default_away_menu_init(GtkWidget *);
--- a/src/util.c Sat Apr 26 05:31:26 2003 +0000 +++ b/src/util.c Sat Apr 26 06:46:08 2003 +0000 @@ -913,7 +913,8 @@ ret[j++] = text[i]; } - debug_printf("got: %s, leaving with %s\n", text, ret); + gaim_debug(GAIM_DEBUG_INFO, "add_cr", "got: %s, leaving with %s\n", + text, ret); return ret; } @@ -956,20 +957,25 @@ #ifdef _WIN32 char* result = _mktemp( *fpath ); if( result == NULL ) - debug_printf("gaim_mkstemp: Problem creating the template\n"); + gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", + "Problem creating the template\n"); else { if( (fp = fopen( result, "w+" )) == NULL ) { - debug_printf("Error: Couldn't fopen() in gaim_mkstemp():\n%s\n", result); + gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", + "Couldn't fopen() %s\n", result); } } #else if((fd = mkstemp(*fpath)) == -1) { - debug_printf("Error: Couldn't make \"%s\", error: %d\n", *fpath, errno); + gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", + "Couldn't make \"%s\", error: %d\n", + *fpath, errno); } else { if((fp = fdopen(fd, "r+")) == NULL) { close(fd); - debug_printf("Error: Couldn't fdopen(), error: %d\n", errno); + gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", + "Couldn't fdopen(), error: %d\n", errno); } } #endif @@ -979,7 +985,8 @@ } } } else { - debug_printf("Error: g_get_tmp_dir() failed in gaim_mkstemp()!\n"); + gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", + "g_get_tmp_dir() failed!"); } return fp; @@ -991,8 +998,8 @@ GSList *conn = connections; struct gaim_connection *gc = NULL; - debug_printf("Handling URI: %s\n", uri); - + gaim_debug(GAIM_DEBUG_INFO, "handle_uri", "Handling URI: %s\n", uri); + /* Well, we'd better check to make sure we have at least one AIM account connected. */ while (conn) { @@ -1074,7 +1081,8 @@ group = g_strdup(str->str); g_string_free(str, TRUE); } - debug_printf("who: %s\n", who); + + gaim_debug(GAIM_DEBUG_MISC, "handle_uri", "who: %s\n", who); show_add_buddy(gc, who, group, NULL); g_free(who); if (group)