libpurple/log.c

changeset 38622
0d8e51f600c9
parent 38621
1412d6b993e9
child 38625
a7857c688deb
equal deleted inserted replaced
38621:1412d6b993e9 38622:0d8e51f600c9
102 { 102 {
103 g_return_if_fail(log); 103 g_return_if_fail(log);
104 if (log->logger && log->logger->finalize) 104 if (log->logger && log->logger->finalize)
105 log->logger->finalize(log); 105 log->logger->finalize(log);
106 g_free(log->name); 106 g_free(log->name);
107 g_date_time_unref(log->time); 107 if (log->time)
108 g_date_time_unref(log->time);
108 109
109 PURPLE_DBUS_UNREGISTER_POINTER(log); 110 PURPLE_DBUS_UNREGISTER_POINTER(log);
110 g_slice_free(PurpleLog, log); 111 g_slice_free(PurpleLog, log);
111 } 112 }
112 113
1684 1685
1685 if(strchr(buf, '\r')) 1686 if(strchr(buf, '\r'))
1686 newlen--; 1687 newlen--;
1687 1688
1688 if (newlen != 0) { 1689 if (newlen != 0) {
1689 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, NULL); 1690 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
1690 log->logger = old_logger; 1691 log->logger = old_logger;
1691 log->time = g_date_time_ref(lasttime);
1692 1692
1693 /* IMPORTANT: Always set all members of struct old_logger_data */ 1693 /* IMPORTANT: Always set all members of struct old_logger_data */
1694 data = g_slice_new(struct old_logger_data); 1694 data = g_slice_new(struct old_logger_data);
1695 1695
1696 data->pathref = purple_stringref_ref(pathref); 1696 data->pathref = purple_stringref_ref(pathref);
1739 } else if (purple_strequal(month_str, "Nov")) { 1739 } else if (purple_strequal(month_str, "Nov")) {
1740 month = 11; 1740 month = 11;
1741 } else if (purple_strequal(month_str, "Dec")) { 1741 } else if (purple_strequal(month_str, "Dec")) {
1742 month = 12; 1742 month = 12;
1743 } 1743 }
1744 if (lasttime)
1745 g_date_time_unref(lasttime);
1744 lasttime = g_date_time_new_local(year, month, day, 1746 lasttime = g_date_time_new_local(year, month, day,
1745 hour, minute, second); 1747 hour, minute, second);
1746 } 1748 }
1747 } 1749 }
1748 1750
1749 if (logfound) { 1751 if (logfound) {
1750 if ((newlen = ftell(file) - lastoff) != 0) { 1752 if ((newlen = ftell(file) - lastoff) != 0) {
1751 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, NULL); 1753 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
1752 log->logger = old_logger; 1754 log->logger = old_logger;
1753 log->time = g_date_time_ref(lasttime);
1754 1755
1755 /* IMPORTANT: Always set all members of struct old_logger_data */ 1756 /* IMPORTANT: Always set all members of struct old_logger_data */
1756 data = g_slice_new(struct old_logger_data); 1757 data = g_slice_new(struct old_logger_data);
1757 1758
1758 data->pathref = purple_stringref_ref(pathref); 1759 data->pathref = purple_stringref_ref(pathref);
1765 if (index != NULL) 1766 if (index != NULL)
1766 fprintf(index, "%d\t%d\t%lu\n", data->offset, data->length, (unsigned long)log->time); 1767 fprintf(index, "%d\t%d\t%lu\n", data->offset, data->length, (unsigned long)log->time);
1767 } 1768 }
1768 } 1769 }
1769 1770
1771 if (lasttime)
1772 g_date_time_unref(lasttime);
1770 purple_stringref_unref(pathref); 1773 purple_stringref_unref(pathref);
1771 fclose(file); 1774 fclose(file);
1772 if (index != NULL) 1775 if (index != NULL)
1773 { 1776 {
1774 fclose(index); 1777 fclose(index);

mercurial