# HG changeset patch # User Richard Laager # Date 1124338447 0 # Node ID ef9280fdc5110df3a1d08eb3ffd2023fda39ecc4 # Parent 57fccea36e36092672daf737a5fa3dc5cd974f72 [gaim-migrate @ 13492] Apparently, users like to know when logging is failing. Who knew? committer: Tailor Script diff -r 57fccea36e36 -r ef9280fdc511 plugins/ChangeLog.API --- a/plugins/ChangeLog.API Thu Aug 18 03:14:29 2005 +0000 +++ b/plugins/ChangeLog.API Thu Aug 18 04:14:07 2005 +0000 @@ -75,6 +75,7 @@ * Removed: gaim_gtkconv_get_dest_tab_at_xy(), instead use gaim_gtkconv_get_tab_at_xy() * Added: gtk_imhtml_delete to clear out part of a imhtml buffer + * Changed: gaim_log_new(), added conv parameter Signals: * Changed: "received-im-msg" and "received-chat-msg" to match, both diff -r 57fccea36e36 -r ef9280fdc511 src/account.c --- a/src/account.c Thu Aug 18 03:14:29 2005 +0000 +++ b/src/account.c Thu Aug 18 04:14:07 2005 +0000 @@ -1842,7 +1842,7 @@ gc = gaim_account_get_connection(account); account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, - gaim_account_get_username(account), account, + gaim_account_get_username(account), account, NULL, (gc != NULL && gc->login_time != 0) ? gc->login_time : time(NULL)); } diff -r 57fccea36e36 -r ef9280fdc511 src/conversation.c --- a/src/conversation.c Thu Aug 18 03:14:29 2005 +0000 +++ b/src/conversation.c Thu Aug 18 04:14:07 2005 +0000 @@ -628,7 +628,7 @@ gaim_log_free(conv->log); conv->log = gaim_log_new(GAIM_LOG_CHAT, gaim_conversation_get_name(conv), - account, time(NULL)); + account, conv, time(NULL)); gc = gaim_account_get_connection(account); @@ -686,7 +686,7 @@ g_free, NULL); conv->log = gaim_log_new(type == GAIM_CONV_CHAT ? GAIM_LOG_CHAT : GAIM_LOG_IM, conv->name, account, - time(NULL)); + conv, time(NULL)); /* copy features from the connection. */ conv->features = gc->flags; diff -r 57fccea36e36 -r ef9280fdc511 src/log.c --- a/src/log.c Thu Aug 18 03:14:29 2005 +0000 +++ b/src/log.c Thu Aug 18 04:14:07 2005 +0000 @@ -49,11 +49,13 @@ * PUBLIC LOGGING FUNCTIONS *********************************************** **************************************************************************/ -GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, time_t time) +GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, + GaimConversation *conv, time_t time) { GaimLog *log = g_new0(GaimLog, 1); log->name = g_strdup(gaim_normalize(account, name)); log->account = account; + log->conv = conv; log->time = time; log->type = type; log->logger_data = NULL; @@ -456,12 +458,13 @@ * LOGGERS ****************************************************************** ****************************************************************************/ -void gaim_log_common_writer(GaimLog *log, time_t time, const char *ext) +void gaim_log_common_writer(GaimLog *log, const char *ext) { char date[64]; GaimLogCommonLoggerData *data = log->logger_data; - if(!data) { + if (data == NULL) + { /* This log is new */ char *dir, *filename, *path; @@ -482,9 +485,15 @@ log->logger_data = data = g_new0(GaimLogCommonLoggerData, 1); data->file = g_fopen(path, "a"); - if (!data->file) { + if (data->file == NULL) + { gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", path); + + if (log->conv != NULL) + gaim_conversation_write(log->conv, NULL, _("Logging of this conversation failed."), + GAIM_MESSAGE_ERROR, time(NULL)); + g_free(path); return; } @@ -518,7 +527,7 @@ GaimLogCommonLoggerData *data; time_t stamp = gaim_str_to_time(filename, FALSE); - log = gaim_log_new(type, name, account, stamp); + log = gaim_log_new(type, name, account, NULL, stamp); log->logger = logger; log->logger_data = data = g_new0(GaimLogCommonLoggerData, 1); data->path = g_build_filename(path, filename, NULL); @@ -769,7 +778,7 @@ if(!data) { const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon(log->account, NULL); - gaim_log_common_writer(log, time, ".html"); + gaim_log_common_writer(log, ".html"); data = log->logger_data; @@ -910,7 +919,7 @@ */ const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon(log->account, NULL); - gaim_log_common_writer(log, time, ".txt"); + gaim_log_common_writer(log, ".txt"); data = log->logger_data; @@ -1092,7 +1101,7 @@ newlen--; if (newlen != 0) { - log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); + log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, -1); log->logger = &old_logger; log->time = lasttime; data = g_new0(struct old_logger_data, 1); @@ -1143,7 +1152,7 @@ if (logfound) { if ((newlen = ftell(file) - lastoff) != 0) { - log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); + log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, -1); log->logger = &old_logger; log->time = lasttime; data = g_new0(struct old_logger_data, 1); diff -r 57fccea36e36 -r ef9280fdc511 src/log.h --- a/src/log.h Thu Aug 18 03:14:29 2005 +0000 +++ b/src/log.h Thu Aug 18 04:14:07 2005 +0000 @@ -113,6 +113,7 @@ char *name; /**< The name of this log */ GaimAccount *account; /**< The account this log is taking place on */ + GaimConversation *conv; /**< The conversation being logged */ time_t time; /**< The time this conversation started */ GaimLogLogger *logger; /**< The logging mechanism this log @@ -170,11 +171,12 @@ * @param name The name of this conversation (screenname, chat name, * etc.) * @param account The account the conversation is occurring on + * @param conv The conversation being logged * @param time The time this conversation started * @return The new log */ -GaimLog *gaim_log_new(GaimLogType type, const char *name, - GaimAccount *account, time_t time); +GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, + GaimConversation *conv, time_t time); /** * Frees a log @@ -316,10 +318,9 @@ * file handle and log path. * * @param log The log to write to. - * @param time The time of the item being logged. * @param ext The file extension to give to this log file. */ -void gaim_log_common_writer(GaimLog *log, time_t time, const char *ext); +void gaim_log_common_writer(GaimLog *log, const char *ext); /** * Returns a sorted GList of GaimLogs of the requested type.