Mercurial > pidgin
changeset 13507:702107dd58f1
[gaim-migrate @ 15883]
I noticed that we were writing "FOO has signed off" noticed to the system log after we disconnected. With the HTML logger, this results in a new <html>...</html> block being added, with a duplicate header and everything. It seems we shouldn't be writing these messages after the system log has been closed.
"Fixing" the HTML logger might be a good idea as well.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 14 Mar 2006 06:59:14 +0000 |
parents | c358be635301 |
children | 9710aeb12c0d |
files | plugins/ChangeLog.API plugins/perl/common/Account.xs src/account.c src/account.h src/connection.c src/status.c |
diffstat | 6 files changed, 76 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Tue Mar 14 06:38:05 2006 +0000 +++ b/plugins/ChangeLog.API Tue Mar 14 06:59:14 2006 +0000 @@ -113,6 +113,7 @@ This means that plugins must be updated to expect such a socket from gaim_proxy_connect() and gaim_network_listen*(). * gaim_gtk_create_imhtml(): Added sw_ret() parameter + * gaim_account_get_log(): Added create parameter Removed: * gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
--- a/plugins/perl/common/Account.xs Tue Mar 14 06:38:05 2006 +0000 +++ b/plugins/perl/common/Account.xs Tue Mar 14 06:59:14 2006 +0000 @@ -181,8 +181,9 @@ } Gaim::Log -gaim_account_get_log(account) +gaim_account_get_log(account, create) Gaim::Account account + gboolean create void gaim_account_destroy_log(account)
--- a/src/account.c Tue Mar 14 06:38:05 2006 +0000 +++ b/src/account.c Tue Mar 14 06:59:14 2006 +0000 @@ -1924,11 +1924,11 @@ } GaimLog * -gaim_account_get_log(GaimAccount *account) +gaim_account_get_log(GaimAccount *account, gboolean create) { g_return_val_if_fail(account != NULL, NULL); - if(!account->system_log){ + if(!account->system_log && create){ GaimPresence *presence; int login_time;
--- a/src/account.h Tue Mar 14 06:38:05 2006 +0000 +++ b/src/account.h Tue Mar 14 06:59:14 2006 +0000 @@ -705,13 +705,18 @@ /** * Returns the system log for an account. - * Create it if it doesn't already exist. * * @param account The account. + * @param create Should it be created if it doesn't exist? * * @return The log. + * + * @note Callers should almost always pass @c FALSE for @a create. + * Passing @c TRUE could result in an existing log being reopened, + * if the log has already been closed, which not all loggers deal + * with appropriately. */ -GaimLog *gaim_account_get_log(GaimAccount *account); +GaimLog *gaim_account_get_log(GaimAccount *account, gboolean create); /** * Frees the system log of an account
--- a/src/connection.c Tue Mar 14 06:38:05 2006 +0000 +++ b/src/connection.c Tue Mar 14 06:59:14 2006 +0000 @@ -262,9 +262,6 @@ } if (gc->state == GAIM_CONNECTED) { -#if 0 - GList *wins; -#endif GaimAccount *account; GaimPresence *presence; @@ -276,14 +273,18 @@ if (gaim_prefs_get_bool("/core/logging/log_system")) { - GaimLog *log = gaim_account_get_log(account); - char *msg = g_strdup_printf(_("+++ %s signed on"), - gaim_account_get_username(account)); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, - gaim_account_get_username(account), - gaim_presence_get_login_time(presence), - msg); - g_free(msg); + GaimLog *log = gaim_account_get_log(account, TRUE); + + if (log != NULL) + { + char *msg = g_strdup_printf(_("+++ %s signed on"), + gaim_account_get_username(account)); + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, + gaim_account_get_username(account), + gaim_presence_get_login_time(presence), + msg); + g_free(msg); + } } if (ops != NULL && ops->connected != NULL) @@ -291,19 +292,6 @@ gaim_blist_add_account(account); - /* - * XXX This is a hack! Remove this and replace it with a better event - * notification system. - */ -#if 0 - /* This looks like it was horribly broken before I got here... */ - /* Why is it updating the first tab of each window? */ - for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { - GaimConvWindow *win = (GaimConvWindow *)wins->data; - gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), - GAIM_CONV_ACCOUNT_ONLINE); - } -#endif gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); serv_set_permit_deny(gc); @@ -318,13 +306,17 @@ if (gaim_prefs_get_bool("/core/logging/log_system")) { - GaimLog *log = gaim_account_get_log(account); - char *msg = g_strdup_printf(_("+++ %s signed off"), - gaim_account_get_username(account)); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, - gaim_account_get_username(account), time(NULL), - msg); - g_free(msg); + GaimLog *log = gaim_account_get_log(account, FALSE); + + if (log != NULL) + { + char *msg = g_strdup_printf(_("+++ %s signed off"), + gaim_account_get_username(account)); + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, + gaim_account_get_username(account), time(NULL), + msg); + g_free(msg); + } } gaim_account_destroy_log(account);
--- a/src/status.c Tue Mar 14 06:38:05 2006 +0000 +++ b/src/status.c Tue Mar 14 06:59:14 2006 +0000 @@ -646,10 +646,14 @@ if (tmp != NULL) { - GaimLog *log = gaim_account_get_log(buddy->account); + GaimLog *log = gaim_account_get_log(buddy->account, FALSE); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, buddy_alias, - current_time, tmp); + if (log != NULL) + { + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, buddy_alias, + current_time, tmp); + } + g_free(tmp); } } @@ -1318,26 +1322,34 @@ { if (gaim_prefs_get_bool("/core/logging/log_system")) { - GaimLog *log = gaim_account_get_log(buddy->account); - char *tmp = g_strdup_printf(_("%s became idle"), - gaim_buddy_get_alias(buddy)); + GaimLog *log = gaim_account_get_log(buddy->account, FALSE); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, - gaim_buddy_get_alias(buddy), current_time, tmp); - g_free(tmp); + if (log != NULL) + { + char *tmp = g_strdup_printf(_("%s became idle"), + gaim_buddy_get_alias(buddy)); + + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, + gaim_buddy_get_alias(buddy), current_time, tmp); + g_free(tmp); + } } } else if (old_idle && !idle) { if (gaim_prefs_get_bool("/core/logging/log_system")) { - GaimLog *log = gaim_account_get_log(buddy->account); - char *tmp = g_strdup_printf(_("%s became unidle"), - gaim_buddy_get_alias(buddy)); + GaimLog *log = gaim_account_get_log(buddy->account, FALSE); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, - gaim_buddy_get_alias(buddy), current_time, tmp); - g_free(tmp); + if (log != NULL) + { + char *tmp = g_strdup_printf(_("%s became unidle"), + gaim_buddy_get_alias(buddy)); + + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, + gaim_buddy_get_alias(buddy), current_time, tmp); + g_free(tmp); + } } } @@ -1390,17 +1402,21 @@ if (gaim_prefs_get_bool("/core/logging/log_system")) { - GaimLog *log = gaim_account_get_log(account); - char *msg; + GaimLog *log = gaim_account_get_log(account, FALSE); + + if (log != NULL) + { + char *msg; - if (idle) - msg = g_strdup_printf(_("+++ %s became idle"), gaim_account_get_username(account)); - else - msg = g_strdup_printf(_("+++ %s became unidle"), gaim_account_get_username(account)); - gaim_log_write(log, GAIM_MESSAGE_SYSTEM, - gaim_account_get_username(account), - idle_time, msg); - g_free(msg); + if (idle) + msg = g_strdup_printf(_("+++ %s became idle"), gaim_account_get_username(account)); + else + msg = g_strdup_printf(_("+++ %s became unidle"), gaim_account_get_username(account)); + gaim_log_write(log, GAIM_MESSAGE_SYSTEM, + gaim_account_get_username(account), + idle_time, msg); + g_free(msg); + } } gc = gaim_account_get_connection(account);