--- a/libpurple/log.c Thu Feb 20 23:56:05 2020 -0600
+++ b/libpurple/log.c Thu Mar 12 23:04:27 2020 -0500
@@ -27,14 +27,12 @@
static GSList *loggers = NULL;
static PurpleLogLogger *html_logger;
static PurpleLogLogger *txt_logger;
-static PurpleLogLogger *old_logger;
struct _purple_logsize_user {
@@ -53,13 +51,6 @@
static char *html_logger_read(PurpleLog *log, PurpleLogReadFlags *flags);
static int html_logger_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
-static GList *old_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account);
-static int old_logger_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
-static char * old_logger_read (PurpleLog *log, PurpleLogReadFlags *flags);
-static int old_logger_size (PurpleLog *log);
-static void old_logger_get_log_sets(PurpleLogSetCallback cb, GHashTable *sets);
-static void old_logger_finalize(PurpleLog *log);
static gsize txt_logger_write(PurpleLog *log, PurpleMessageFlags type,
const char *from, GDateTime *time, const char *message);
static void txt_logger_finalize(PurpleLog *log);
@@ -637,18 +628,6 @@
purple_log_common_is_deletable);
purple_log_logger_add(txt_logger);
- old_logger = purple_log_logger_new("old", _("Old flat format"), 9,
- old_logger_get_log_sets);
- purple_log_logger_add(old_logger);
purple_signal_register(handle, "log-timestamp",
purple_marshal_POINTER__POINTER_POINTER_BOOLEAN,
@@ -681,10 +660,6 @@
purple_log_logger_free(txt_logger);
- purple_log_logger_remove(old_logger);
- purple_log_logger_free(old_logger);
g_hash_table_destroy(logsize_users);
g_hash_table_destroy(logsize_users_decayed);
@@ -1504,413 +1479,3 @@
return purple_log_common_total_sizer(type, name, account, ".txt");
-/* The old logger doesn't write logs, only reads them. This is to include
- * old logs in the log viewer transparently.
-struct old_logger_data {
- PurpleStringref *pathref;
-static GList *old_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
- char *logfile = g_strdup_printf("%s.log", purple_normalize(account, sn));
- char *pathstr = g_build_filename(purple_data_dir(), "logs", logfile, NULL);
- PurpleStringref *pathref = purple_stringref_new(pathstr);
- time_t log_last_modified;
- gint year, month, day, hour, minute, second;
- struct old_logger_data *data = NULL;
- GDateTime *lasttime = NULL;
- file_fd = g_open(purple_stringref_value(pathref), 0, O_RDONLY);
- if (file_fd == -1 || (file = fdopen(file_fd, "rb")) == NULL) {
- purple_debug_error("log",
- "Failed to open log file \"%s\" for reading: %s\n",
- purple_stringref_value(pathref), g_strerror(errno));
- purple_stringref_unref(pathref);
- if (_purple_fstat(file_fd, &st) == -1) {
- purple_stringref_unref(pathref);
- log_last_modified = st.st_mtime;
- /* Change the .log extension to .idx */
- strcpy(pathstr + strlen(pathstr) - 3, "idx");
- index_fd = g_open(pathstr, 0, O_RDONLY);
- if (_purple_fstat(index_fd, &st) != 0) {
- if (st.st_mtime < log_last_modified)
- purple_debug_warning("log", "Index \"%s\" exists, but is older than the log.\n", pathstr);
- /* The index file exists and is at least as new as the log, so open it. */
- if (!(index = fdopen(index_fd, "rb"))) {
- purple_debug_error("log", "Failed to open index file \"%s\" for reading: %s\n",
- pathstr, g_strerror(errno));
- /* Fall through so that we'll parse the log file. */
- purple_debug_info("log", "Using index: %s\n", pathstr);
- while (fgets(buf, BUF_LONG, index))
- unsigned long idx_time;
- if (sscanf(buf, "%d\t%d\t%lu", &lastoff, &newlen, &idx_time) == 3)
- log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, NULL);
- log->logger = old_logger;
- log->time = g_date_time_new_from_unix_local(idx_time);
- /* IMPORTANT: Always set all members of struct old_logger_data */
- data = g_slice_new(struct old_logger_data);
- data->pathref = purple_stringref_ref(pathref);
- data->offset = lastoff;
- log->logger_data = data;
- list = g_list_prepend(list, log);
- purple_stringref_unref(pathref);
- index_tmp = g_strdup_printf("%s.XXXXXX", pathstr);
- if ((index_fd = g_mkstemp(index_tmp)) == -1) {
- purple_debug_error("log", "Failed to open index temp file: %s\n",
- if ((index = fdopen(index_fd, "wb")) == NULL)
- purple_debug_error("log", "Failed to fdopen() index temp file: %s\n",
- while (fgets(buf, BUF_LONG, file)) {
- if (strstr(buf, "---- New C") != NULL) {
- char *temp = strchr(buf, '@');
- if (temp == NULL || strlen(temp) < 2)
- length = strcspn(temp, "-");
- if (length > 31) length = 31;
- newlen = offset - lastoff - length;
- if(strstr(buf, "----</H3><BR>")) {
- sizeof("<HR><BR><H3 Align=Center> ---- New Conversation @ ") +
- sizeof("----</H3><BR>") - 2;
- sizeof("---- New Conversation @ ") + sizeof("----") - 2;
- log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
- log->logger = old_logger;
- /* IMPORTANT: Always set all members of struct old_logger_data */
- data = g_slice_new(struct old_logger_data);
- data->pathref = purple_stringref_ref(pathref);
- data->offset = lastoff;
- log->logger_data = data;
- list = g_list_prepend(list, log);
- fprintf(index, "%d\t%d\t%" G_GINT64_FORMAT "\n",
- data->offset, data->length,
- g_date_time_to_unix(log->time));
- g_snprintf(convostart, length, "%s", temp);
- year = month = day = hour = minute = second = 0;
- if (sscanf(convostart, "%*s %3s %d %d:%d:%d %d", month_str,
- &day, &hour, &minute, &second, &year) != 6)
- purple_debug_warning("log", "invalid date format\n");
- /* Ugly hack, in case current locale is not English */
- month = purple_time_parse_month(month_str);
- g_date_time_unref(lasttime);
- lasttime = g_date_time_new_local(year, month, day,
- if ((newlen = ftell(file) - lastoff) != 0) {
- log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
- log->logger = old_logger;
- /* IMPORTANT: Always set all members of struct old_logger_data */
- data = g_slice_new(struct old_logger_data);
- data->pathref = purple_stringref_ref(pathref);
- data->offset = lastoff;
- log->logger_data = data;
- list = g_list_prepend(list, log);
- fprintf(index, "%d\t%d\t%" G_GINT64_FORMAT "\n", data->offset,
- data->length, g_date_time_to_unix(log->time));
- g_date_time_unref(lasttime);
- purple_stringref_unref(pathref);
- g_return_val_if_reached(list);
- if (g_rename(index_tmp, pathstr))
- purple_debug_warning("log", "Failed to rename index temp file \"%s\" to \"%s\": %s\n",
- index_tmp, pathstr, g_strerror(errno));
- purple_debug_info("log", "Built index: %s\n", pathstr);
-static int old_logger_total_size(PurpleLogType type, const char *name, PurpleAccount *account)
- char *logfile = g_strdup_printf("%s.log", purple_normalize(account, name));
- char *pathstr = g_build_filename(purple_data_dir(), "logs", logfile, NULL);
- if (g_stat(pathstr, &st))
-static char * old_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
- struct old_logger_data *data = log->logger_data;
- const char *path = purple_stringref_value(data->pathref);
- FILE *file = g_fopen(path, "rb");
- g_return_val_if_fail(file, g_strdup(""));
- read = g_malloc(data->length + 1);
- if (fseek(file, data->offset, SEEK_SET) != 0)
- result = fread(read, data->length, 1, file);
- purple_debug_error("log", "Unable to read from log file: %s\n", path);
- read[data->length] = '\0';
- if (strstr(read, "<BR>"))
- *flags |= PURPLE_LOG_READ_NO_NEWLINE;
- return process_txt_log(read, NULL);
-static int old_logger_size (PurpleLog *log)
- struct old_logger_data *data = log->logger_data;
- return data ? data->length : 0;
-static void old_logger_get_log_sets(PurpleLogSetCallback cb, GHashTable *sets)
- char *log_path = g_build_filename(purple_data_dir(), "logs", NULL);
- GDir *log_dir = g_dir_open(log_path, 0, NULL);
- PurpleBlistNode *gnode, *cnode, *bnode;
- /* Don't worry about the cast, name will be filled with a dynamically allocated data shortly. */
- while ((name = (gchar *)g_dir_read_name(log_dir)) != NULL) {
- gboolean found = FALSE;
- /* Unescape the filename. */
- name = g_strdup(purple_unescape_filename(name));
- /* Get the (possibly new) length of name. */
- /* Make sure we're dealing with a log file. */
- if (!purple_strequal(ext, ".log")) {
- /* IMPORTANT: Always set all members of PurpleLogSet */
- set = g_slice_new(PurpleLogSet);
- /* Chat for .chat at the end of the name to determine the type. */
- set->type = PURPLE_LOG_IM;
- char *tmp = &name[len - 9];
- if (purple_strequal(tmp, ".chat")) {
- set->type = PURPLE_LOG_CHAT;
- set->name = set->normalized_name = name;
- /* Search the buddy list to find the account and to determine if this is a buddy. */
- for (gnode = purple_blist_get_default_root();
- !found && gnode != NULL;
- gnode = purple_blist_node_get_sibling_next(gnode)) {
- if (!PURPLE_IS_GROUP(gnode))
- for (cnode = purple_blist_node_get_first_child(gnode);
- !found && cnode != NULL;
- cnode = purple_blist_node_get_sibling_next(cnode))
- if (!PURPLE_IS_CONTACT(cnode))
- for (bnode = purple_blist_node_get_first_child(cnode);
- !found && bnode != NULL;
- bnode = purple_blist_node_get_sibling_next(bnode))
- PurpleBuddy *buddy = (PurpleBuddy *)bnode;
- if (purple_strequal(purple_buddy_get_name(buddy), name)) {
- set->account = purple_buddy_get_account(buddy);
-static void old_logger_finalize(PurpleLog *log)
- struct old_logger_data *data = log->logger_data;
- purple_stringref_unref(data->pathref);
- g_slice_free(struct old_logger_data, data);