annotate src/log.c @ 7745:9cc221f68107

[gaim-migrate @ 8390] go to bed jose committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 04 Dec 2003 08:40:38 +0000
parents 9e122b8f564f
children 68e205e746c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
1 /**
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
2 * @file log.c Logging API
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
3 * @ingroup core
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
4 *
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
5 * gaim
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
6 *
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
7 * Copyright (C) 2003 Buzz Lightyear
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
8 *
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
9 * This program is free software; you can redistribute it and/or modify
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
10 * it under the terms of the GNU General Public License as published by
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
12 * (at your option) any later version.
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
13 *
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
14 * This program is distributed in the hope that it will be useful,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
17 * GNU General Public License for more details.
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
18 *
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
19 * You should have received a copy of the GNU General Public License
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
20 * along with this program; if not, write to the Free Software
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
23
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
24 #include "account.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5839
diff changeset
25 #include "debug.h"
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
26 #include "internal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5839
diff changeset
27 #include "log.h"
5548
80e4ba770f97 [gaim-migrate @ 5949]
Nathan Walp <nwalp@pidgin.im>
parents: 5528
diff changeset
28 #include "prefs.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5839
diff changeset
29 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5839
diff changeset
30
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
31 static GaimLogLogger html_logger;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
32 static GaimLogLogger txt_logger;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
33 static GaimLogLogger old_logger;
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5839
diff changeset
34
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
35 /**************************************************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
36 * PUBLIC LOGGING FUNCTIONS ***********************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
37 **************************************************************************/
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
39 GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, time_t time)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
40 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
41 GaimLog *log = g_new0(GaimLog, 1);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
42 log->name = g_strdup(name);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
43 log->account = account;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
44 log->time = time;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
45 log->logger = gaim_log_logger_get();
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
46 if (log->logger && log->logger->create)
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
47 log->logger->create(log);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
48 return log;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
51 void gaim_log_free(GaimLog *log)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
53 g_return_if_fail(log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
54 if (log->logger && log->logger->finalize)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
55 log->logger->finalize(log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
56 g_free(log->name);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
57 g_free(log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
58 }
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
59
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
61 void gaim_log_write(GaimLog *log, GaimMessageFlags type,
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
62 const char *from, time_t time, const char *message)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
63 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
64 g_return_if_fail(log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
65 g_return_if_fail(log->logger);
7442
d42289ecf0ce [gaim-migrate @ 8047]
Nathan Walp <nwalp@pidgin.im>
parents: 7441
diff changeset
66 g_return_if_fail(log->logger->write);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
67
7555
450b25d8d953 [gaim-migrate @ 8169]
Nathan Walp <nwalp@pidgin.im>
parents: 7554
diff changeset
68 if ((log->type == GAIM_LOG_IM && gaim_prefs_get_bool("/core/logging/log_ims")) ||
450b25d8d953 [gaim-migrate @ 8169]
Nathan Walp <nwalp@pidgin.im>
parents: 7554
diff changeset
69 (log->type == GAIM_LOG_CHAT && gaim_prefs_get_bool("/core/logging/log_chats")))
7553
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
70 (log->logger->write)(log, type, from, time, message);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
73 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 {
7542
ebccd555323b [gaim-migrate @ 8156]
Nathan Walp <nwalp@pidgin.im>
parents: 7541
diff changeset
75 GaimLogReadFlags mflags;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
76 g_return_val_if_fail(log && log->logger, NULL);
7462
5fb4cbf1ac54 [gaim-migrate @ 8075]
Nathan Walp <nwalp@pidgin.im>
parents: 7461
diff changeset
77 if (log->logger->read) {
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7501
diff changeset
78 char *ret = (log->logger->read)(log, flags ? flags : &mflags);
7478
3c21f3084ff0 [gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7473
diff changeset
79 gaim_str_strip_cr(ret);
7462
5fb4cbf1ac54 [gaim-migrate @ 8075]
Nathan Walp <nwalp@pidgin.im>
parents: 7461
diff changeset
80 return ret;
5fb4cbf1ac54 [gaim-migrate @ 8075]
Nathan Walp <nwalp@pidgin.im>
parents: 7461
diff changeset
81 }
7470
ad6435eccf2b [gaim-migrate @ 8083]
Mark Doliner <mark@kingant.net>
parents: 7463
diff changeset
82 return (_("<b><font color=\"red\">The logger has no read function</font></b>"));
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 }
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
84
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
85 int gaim_log_get_size(GaimLog *log)
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
86 {
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
87 g_return_val_if_fail(log && log->logger, 0);
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
88 if (log->logger->size)
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
89 return log->logger->size(log);
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
90 return 0;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
91 }
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
92
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
93 int gaim_log_get_total_size(const char *name, GaimAccount *account)
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
94 {
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
95 GList *logs = gaim_log_get_logs(name, account);
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
96 int size = 0;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
97
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
98
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
99 while (logs) {
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
100 GList *logs2 = logs->next;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
101 GaimLog *log = (GaimLog*)(logs->data);
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
102 size += gaim_log_get_size(log);
7685
9e122b8f564f [gaim-migrate @ 8329]
Ethan Blanton <elb@pidgin.im>
parents: 7676
diff changeset
103 gaim_log_free(log);
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
104 g_list_free_1(logs);
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
105 logs = logs2;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
106 }
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
107
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
108 return size;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
109 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
111 /****************************************************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
112 * LOGGER FUNCTIONS *********************************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
113 ****************************************************************************/
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
115 static GaimLogLogger *current_logger = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
116 static GSList *loggers = NULL;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
117
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
118 static void logger_pref_cb(const char *name, GaimPrefType type,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
119 gpointer value, gpointer data)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
120 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
121 GaimLogLogger *logger;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
122 GSList *l = loggers;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
123 while (l) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
124 logger = l->data;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
125 if (!strcmp(logger->id, value)) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
126 gaim_log_logger_set(logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
127 return;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 }
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
129 l = l->next;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
130 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
131 gaim_log_logger_set(&txt_logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
132 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
135 GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *),
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
136 void(*write)(GaimLog *, GaimMessageFlags, const char *,
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
137 time_t, const char *),
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
138 void(*finalize)(GaimLog *), GList*(*list)(const char*, GaimAccount*),
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
139 char*(*read)(GaimLog*, GaimLogReadFlags*),
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
140 int(*size)(GaimLog*))
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
141 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
142 GaimLogLogger *logger = g_new0(GaimLogLogger, 1);
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
143 logger->create = create;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
144 logger->write = write;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
145 logger->finalize = finalize;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
146 logger->list = list;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
147 logger->read = read;
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
148 logger->size = size;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
149 return logger;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
152 void gaim_log_logger_free(GaimLogLogger *logger)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
154 g_free(logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
155 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
157 void gaim_log_logger_add (GaimLogLogger *logger)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
158 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
159 g_return_if_fail(logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
160 if (g_slist_find(loggers, logger))
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
161 return;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
162 loggers = g_slist_append(loggers, logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
163 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
164
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
165 void gaim_log_logger_remove (GaimLogLogger *logger)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
166 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
167 g_return_if_fail(logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
168 g_slist_remove(loggers, logger);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
171 void gaim_log_logger_set (GaimLogLogger *logger)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
173 g_return_if_fail(logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
174 current_logger = logger;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
175 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
177 GaimLogLogger *gaim_log_logger_get()
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
178 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
179 return current_logger;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
180 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
182 GList *gaim_log_logger_get_options(void)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
183 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
184 GSList *n;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
185 GList *list = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
186 GaimLogLogger *data;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
188 for (n = loggers; n; n = n->next) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
189 data = n->data;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
190 if (!data->write)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
191 continue;
7494
86fe50e88bcd [gaim-migrate @ 8107]
Nathan Walp <nwalp@pidgin.im>
parents: 7491
diff changeset
192 list = g_list_append(list, _(data->name));
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
193 list = g_list_append(list, data->id);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
196 return list;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
197 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
198
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
199 static gint log_compare(gconstpointer y, gconstpointer z)
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
200 {
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
201 const GaimLog *a = y;
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
202 const GaimLog *b = z;
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
203
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
204 return b->time - a->time;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
205 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
206
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
207 GList *gaim_log_get_logs(const char *name, GaimAccount *account)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
208 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
209 GList *logs = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
210 GSList *n;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
211 for (n = loggers; n; n = n->next) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
212 GaimLogLogger *logger = n->data;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
213 if (!logger->list)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
214 continue;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
215 logs = g_list_concat(logs, logger->list(name, account));
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
216 }
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
217
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
218 return g_list_sort(logs, log_compare);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
219 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
220
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
221 void gaim_log_init(void)
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
222 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
223 gaim_prefs_add_none("/core/logging");
7555
450b25d8d953 [gaim-migrate @ 8169]
Nathan Walp <nwalp@pidgin.im>
parents: 7554
diff changeset
224 gaim_prefs_add_bool("/core/logging/log_ims", FALSE);
450b25d8d953 [gaim-migrate @ 8169]
Nathan Walp <nwalp@pidgin.im>
parents: 7554
diff changeset
225 gaim_prefs_add_bool("/core/logging/log_chats", FALSE);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
226 gaim_prefs_add_string("/core/logging/format", "txt");
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
227 gaim_log_logger_add(&html_logger);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
228 gaim_log_logger_add(&txt_logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
229 gaim_log_logger_add(&old_logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
230 gaim_prefs_connect_callback("/core/logging/format",
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
231 logger_pref_cb, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
232 gaim_prefs_trigger_callback("/core/logging/format");
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
233 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
234
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
235 /****************************************************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
236 * LOGGERS ******************************************************************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
237 ****************************************************************************/
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
238
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
239 struct generic_logger_data {
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
240 char *path;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
241 FILE *file;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
242 };
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
243
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
244 static GList *log_lister_common(const char *screenname, GaimAccount *account, const char *ext, GaimLogLogger *logger)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
245 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
246 GDir *dir;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
247 GList *list = NULL;
7628
e293d0c42ccb [gaim-migrate @ 8252]
Ethan Blanton <elb@pidgin.im>
parents: 7623
diff changeset
248 const char *filename;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
249 char *me = g_strdup(gaim_normalize(account, gaim_account_get_username(account)));
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
251 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
252 (gaim_find_prpl(gaim_account_get_protocol(account)))->list_icon(account, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
253 char *path = g_build_filename(gaim_user_dir(), "logs", prpl, me, gaim_normalize(account, screenname), NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
254
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
255 g_free(me);
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
256
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
257 if (!(dir = g_dir_open(path, 0, NULL))) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
258 g_free(path);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
259 return NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
260 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
261 while ((filename = g_dir_read_name(dir))) {
7628
e293d0c42ccb [gaim-migrate @ 8252]
Ethan Blanton <elb@pidgin.im>
parents: 7623
diff changeset
262 if (gaim_str_has_suffix(filename, ext)) {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
263 const char *l = filename;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
264 struct tm time;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
265 GaimLog *log;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
266 struct generic_logger_data *data;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
267 char d[5];
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
268
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
269 strncpy(d, l, 4);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
270 d[4] = '\0';
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
271 time.tm_year = atoi(d) - 1900;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
272 l = l + 5;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
273
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
274 strncpy(d, l, 2);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
275 d[2] = '\0';
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
276 time.tm_mon = atoi(d) - 1;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
277 l = l + 3;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
278
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
279 strncpy(d, l, 2);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
280 time.tm_mday = atoi(d);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
281 l = l + 3;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
282
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
283 strncpy(d, l, 2);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
284 time.tm_hour = atoi(d);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
285 l = l + 2;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
286
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
287 strncpy(d, l, 2);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
288 time.tm_min = atoi(d);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
289 l = l + 2;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
290
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
291 strncpy(d, l, 2);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
292 time.tm_sec = atoi(d);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
293 l = l + 2;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
294 log = gaim_log_new(GAIM_LOG_IM, screenname, account, mktime(&time));
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
295 log->logger = logger;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
296 log->logger_data = data = g_new0(struct generic_logger_data, 1);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
297 data->path = g_build_filename(path, filename, NULL);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
298 list = g_list_append(list, log);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 }
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
301 g_dir_close(dir);
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
302 g_free(path);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
303 return list;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
304 }
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
306 /* Only to be used with logs listed from log_lister_common */
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
307 int log_sizer_common(GaimLog *log)
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
308 {
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
309 struct stat st;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
310 struct generic_logger_data *data = log->logger_data;
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
311
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
312 if (!data->path || stat(data->path, &st))
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
313 st.st_size = 0;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
314
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
315 return st.st_size;
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
316 }
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
317
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
318 #if 0 /* Maybe some other time. */
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
319 /****************
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
320 ** XML LOGGER **
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
321 ****************/
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
322
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
323 static const char *str_from_msg_type (GaimMessageFlags type)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
324 {
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
325
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
326 return "";
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
327
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
328 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
329
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
330 static void xml_logger_write(GaimLog *log,
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
331 GaimMessageFlags type,
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
332 const char *from, time_t time, const char *message)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
333 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
334 char date[64];
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
335 char *xhtml = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
336 if (!log->logger_data) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
337 /* This log is new. We could use the loggers 'new' function, but
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
338 * creating a new file there would result in empty files in the case
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
339 * that you open a convo with someone, but don't say anything.
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
340 */
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
341 char *ud = gaim_user_dir();
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
342 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account)));
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
343 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
344 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
345 char *dir;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
346 FILE *file;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
347
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
348 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.xml", localtime(&log->time));
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
349
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
350 dir = g_build_filename(ud, "logs",
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
351 prpl, guy, gaim_normalize(log->account, log->name), NULL);
7612
3ae88e96dde2 [gaim-migrate @ 8236]
Ethan Blanton <elb@pidgin.im>
parents: 7564
diff changeset
352 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR);
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
353 g_free(guy);
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
354
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
355 char *filename = g_build_filename(dir, date, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
356 g_free(dir);
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
357
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
358 log->logger_data = fopen(filename, "a");
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
359 if (!log->logger_data) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
360 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename);
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
361 g_free(filename);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
362 return;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
363 }
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
364 g_free(filename);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
365 fprintf(log->logger_data, "<?xml version='1.0' encoding='UTF-8' ?>\n"
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
366 "<?xml-stylesheet href='file:///usr/src/web/htdocs/log-stylesheet.xsl' type='text/xml' ?>\n");
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
367
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
368 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time));
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
369 fprintf(log->logger_data, "<conversation time='%s' screenname='%s' protocol='%s'>\n",
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
370 date, log->name, prpl);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
371 }
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
372
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
373 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time));
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
374 gaim_markup_html_to_xhtml(message, &xhtml, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
375 if (from)
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
376 fprintf(log->logger_data, "<message %s %s from='%s' time='%s'>%s</message>\n",
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
377 str_from_msg_type(type),
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
378 type & GAIM_MESSAGE_SEND ? "direction='sent'" :
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
379 type & GAIM_MESSAGE_RECV ? "direction='received'" : "",
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
380 from, date, xhtml);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
381 else
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
382 fprintf(log->logger_data, "<message %s %s time='%s'>%s</message>\n",
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
383 str_from_msg_type(type),
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
384 type & GAIM_MESSAGE_SEND ? "direction='sent'" :
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
385 type & GAIM_MESSAGE_RECV ? "direction='received'" : "",
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
386 date, xhtml):
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
387 fflush(log->logger_data);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
388 g_free(xhtml);
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
389 }
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
390
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
391 static void xml_logger_finalize(GaimLog *log)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
392 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
393 if (log->logger_data) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
394 fprintf(log->logger_data, "</conversation>\n");
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
395 fclose(log->logger_data);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
396 log->logger_data = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
397 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
398 }
7443
df50bd14e161 [gaim-migrate @ 8048]
Luke Schierer <lschiere@pidgin.im>
parents: 7442
diff changeset
399
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
400 static GList *xml_logger_list(const char *sn, GaimAccount *account)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
401 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
402 return log_lister_common(sn, account, ".xml", &xml_logger);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
405 static GaimLogLogger xml_logger = {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
406 N_("XML"), "xml",
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
407 NULL,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
408 xml_logger_write,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
409 xml_logger_finalize,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
410 xml_logger_list,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
411 NULL
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
412 };
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
413 #endif
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
414
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
415 /****************************
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
416 ** HTML LOGGER *************
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
417 ****************************/
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
418
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
419 static void html_logger_write(GaimLog *log, GaimMessageFlags type,
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
420 const char *from, time_t time, const char *message)
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
421 {
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
422 GaimConnection *gc = gaim_account_get_connection(log->account);
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
423 char date[64];
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
424 struct generic_logger_data *data = log->logger_data;
7618
53e38b1ce00a [gaim-migrate @ 8242]
Nathan Walp <nwalp@pidgin.im>
parents: 7616
diff changeset
425 if(!data) {
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
426 /* This log is new */
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
427 char *ud = gaim_user_dir();
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
428 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account)));
7553
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
429 char *chat;
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
430 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
431 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
432 char *dir;
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
433 char *filename;
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
434
7553
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
435 if (log->type == GAIM_LOG_CHAT) {
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
436 chat = g_strdup_printf("%s.chat", guy);
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
437 g_free(guy);
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
438 guy = chat;
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
439 }
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
440
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
441 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.html", localtime(&log->time));
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
442
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
443 dir = g_build_filename(ud, "logs",
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
444 prpl, guy, gaim_normalize(log->account, log->name), NULL);
7612
3ae88e96dde2 [gaim-migrate @ 8236]
Ethan Blanton <elb@pidgin.im>
parents: 7564
diff changeset
445 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR);
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
446 g_free(guy);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
447
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
448 filename = g_build_filename(dir, date, NULL);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
449 g_free(dir);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
450
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
451 log->logger_data = data = g_new0(struct generic_logger_data, 1);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
452
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
453 data->file = fopen(filename, "a");
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
454 if (!data->file) {
7623
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
455 gaim_debug(GAIM_DEBUG_ERROR, "log",
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
456 "Could not create log file %s\n", filename);
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
457 g_free(filename);
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
458 return;
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
459 }
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
460 g_free(filename);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
461 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time));
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
462 fprintf(data->file, "<html><head><title>");
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
463 fprintf(data->file, "Conversation with %s at %s on %s (%s)",
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
464 log->name, date, gaim_account_get_username(log->account), prpl);
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
465 fprintf(data->file, "</title></head><body>");
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
466 fprintf(data->file,
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
467 "<h3>Conversation with %s at %s on %s (%s)</h3>\n",
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
468 log->name, date, gaim_account_get_username(log->account), prpl);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
469 }
7623
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
470
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
471 /* if we can't write to the file, give up before we hurt ourselves */
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
472 if(!data->file)
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
473 return;
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
474
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
475 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time));
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
476 if (type & GAIM_MESSAGE_SYSTEM)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
477 fprintf(data->file, "(%s)<b> %s</b><br/>\n", date, message);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
478 else if (type & GAIM_MESSAGE_WHISPER)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
479 fprintf(data->file, "<font color=\"#6C2585\">(%s)<b> %s:</b></font> %s<br/>\n",
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
480 date, from, message);
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
481 else if (type & GAIM_MESSAGE_AUTO_RESP) {
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
482 if (type & GAIM_MESSAGE_SEND)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
483 fprintf(data->file, _("<font color=\"#16569E\">(%s) <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, message);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
484 else if (type & GAIM_MESSAGE_RECV)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
485 fprintf(data->file, _("<font color=\"#A82F2F\">(%s) <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, message);
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
486 } else if (type & GAIM_MESSAGE_RECV) {
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
487 char *msg = g_strdup(message);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
488 if(gaim_message_meify(msg, -1))
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
489 fprintf(data->file, "<font color=\"#6C2585\">(%s) <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n",
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
490 date, from, gc->prpl->info->name, msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
491 else
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
492 fprintf(data->file, "<font color=\"#A82F2F\">(%s) <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n",
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
493 date, from, gc->prpl->info->name, msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
494 g_free(msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
495 } else if (type & GAIM_MESSAGE_SEND) {
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
496 char *msg = g_strdup(message);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
497 if(gaim_message_meify(msg, -1))
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
498 fprintf(data->file, "<font color=\"#6C2585\">(%s) <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n",
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
499 date, from, gc->prpl->info->name, msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
500 else
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
501 fprintf(data->file, "<font color=\"#16569E\">(%s) <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n",
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
502 date, from, gc->prpl->info->name, msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
503 g_free(msg);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
504 }
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
505 fflush(data->file);
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
506 }
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
507
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
508 static void html_logger_finalize(GaimLog *log)
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
509 {
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
510 struct generic_logger_data *data = log->logger_data;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
511 if (data) {
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
512 if(data->file) {
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
513 fprintf(data->file, "</body></html>");
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
514 fclose(data->file);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
515 }
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
516 g_free(data->path);
7463
f2d82df37252 [gaim-migrate @ 8076]
Nathan Walp <nwalp@pidgin.im>
parents: 7462
diff changeset
517 }
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
518 }
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
519
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
520 static GList *html_logger_list(const char *sn, GaimAccount *account)
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
521 {
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
522 return log_lister_common(sn, account, ".html", &html_logger);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
523 }
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
524
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
525 static char *html_logger_read(GaimLog *log, GaimLogReadFlags *flags)
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
526 {
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
527 char *read, *minus_header;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
528 struct generic_logger_data *data = log->logger_data;
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
529 *flags = GAIM_LOG_READ_NO_NEWLINE;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
530 if (!data || !data->path)
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
531 return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>"));
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
532 if (g_file_get_contents(data->path, &read, NULL, NULL)) {
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
533 minus_header = strchr(read, '\n');
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
534 if (!minus_header)
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
535 minus_header = g_strdup(read);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
536 else
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
537 minus_header = g_strdup(minus_header + 1);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
538 g_free(read);
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
539 return minus_header;
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
540 }
7471
68020c122954 [gaim-migrate @ 8084]
Mark Doliner <mark@kingant.net>
parents: 7470
diff changeset
541 return g_strdup(_("<font color=\"red\"><b>Could not read file: %s</b></font>"));
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
542 }
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
543
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
544 static GaimLogLogger html_logger = {
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
545 N_("HTML"), "html",
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
546 NULL,
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
547 html_logger_write,
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
548 html_logger_finalize,
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
549 html_logger_list,
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
550 html_logger_read,
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
551 log_sizer_common
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
552 };
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
553
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
554
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
555
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
556
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
557 /****************************
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
558 ** PLAIN TEXT LOGGER *******
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
559 ****************************/
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
561 static void txt_logger_write(GaimLog *log,
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
562 GaimMessageFlags type,
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
563 const char *from, time_t time, const char *message)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
564 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
565 char date[64];
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
566 char *stripped = NULL;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
567 struct generic_logger_data *data = log->logger_data;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
568 if (!data) {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
569 /* This log is new. We could use the loggers 'new' function, but
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
570 * creating a new file there would result in empty files in the case
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
571 * that you open a convo with someone, but don't say anything.
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
572 */
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
573 char *ud = gaim_user_dir();
7473
859e4cf4d472 [gaim-migrate @ 8086]
Mark Doliner <mark@kingant.net>
parents: 7472
diff changeset
574 char *filename;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
575 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account)));
7553
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
576 char *chat;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
577 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
578 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
579 char *dir;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
580
7553
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
581 if (log->type == GAIM_LOG_CHAT) {
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
582 chat = g_strdup_printf("%s.chat", guy);
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
583 g_free(guy);
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
584 guy = chat;
7d95978b07d9 [gaim-migrate @ 8167]
Sean Egan <seanegan@gmail.com>
parents: 7542
diff changeset
585 }
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
586 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.txt", localtime(&log->time));
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
587
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
588 dir = g_build_filename(ud, "logs",
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
589 prpl, guy, gaim_normalize(log->account, log->name), NULL);
7612
3ae88e96dde2 [gaim-migrate @ 8236]
Ethan Blanton <elb@pidgin.im>
parents: 7564
diff changeset
590 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR);
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
591 g_free(guy);
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
592
7473
859e4cf4d472 [gaim-migrate @ 8086]
Mark Doliner <mark@kingant.net>
parents: 7472
diff changeset
593 filename = g_build_filename(dir, date, NULL);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
594 g_free(dir);
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
595
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
596 log->logger_data = data = g_new0(struct generic_logger_data, 1);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
597
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
598 data->file = fopen(filename, "a");
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
599 if (!data->file) {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
600 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename);
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
601 g_free(filename);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
602 return;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 }
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
604 g_free(filename);
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
605 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time));
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
606 fprintf(data->file, "Conversation with %s at %s on %s (%s)\n",
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
607 log->name, date, gaim_account_get_username(log->account), prpl);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
608 }
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
609
7623
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
610 /* if we can't write to the file, give up before we hurt ourselves */
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
611 if(!data->file)
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
612 return;
5381f96fc185 [gaim-migrate @ 8247]
Nathan Walp <nwalp@pidgin.im>
parents: 7618
diff changeset
613
7453
6f5918e4f668 [gaim-migrate @ 8066]
Nathan Walp <nwalp@pidgin.im>
parents: 7447
diff changeset
614 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time));
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
615 stripped = gaim_markup_strip_html(message);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
616 if (type & GAIM_MESSAGE_SEND ||
7541
e1d1b60d823b [gaim-migrate @ 8154]
Sean Egan <seanegan@gmail.com>
parents: 7540
diff changeset
617 type & GAIM_MESSAGE_RECV) {
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
618 if (type & GAIM_MESSAGE_AUTO_RESP) {
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
619 fprintf(data->file, _("(%s) %s <AUTO-REPLY>: %s\n"), date, from, stripped);
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
620 } else {
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
621 if(gaim_message_meify(stripped, -1))
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
622 fprintf(data->file, "(%s) ***%s %s\n", date, from,
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
623 stripped);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
624 else
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
625 fprintf(data->file, "(%s) %s: %s\n", date, from,
7564
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
626 stripped);
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
627 }
54b370f7d9bf [gaim-migrate @ 8180]
Nathan Walp <nwalp@pidgin.im>
parents: 7556
diff changeset
628 } else if (type & GAIM_MESSAGE_SYSTEM)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
629 fprintf(data->file, "(%s) %s\n", date, stripped);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
630 else if (type & GAIM_MESSAGE_NO_LOG) {
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
631 /* This shouldn't happen */
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
632 g_free(stripped);
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
633 return;
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
634 } else if (type & GAIM_MESSAGE_WHISPER)
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
635 fprintf(data->file, "(%s) *%s* %s", date, from, stripped);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
636 else
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
637 fprintf(data->file, "(%s) %s%s %s\n", date, from ? from : "", from ? ":" : "", stripped);
7489
8f05bdc08faf [gaim-migrate @ 8102]
Sean Egan <seanegan@gmail.com>
parents: 7478
diff changeset
638
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
639 fflush(data->file);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
640 g_free(stripped);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
641 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
642
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
643 static void txt_logger_finalize(GaimLog *log)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
644 {
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
645 struct generic_logger_data *data = log->logger_data;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
646 if (data) {
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
647 if(data->file)
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
648 fclose(data->file);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
649 if(data->path)
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
650 g_free(data->path);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
651 }
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
652 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
653
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
654 static GList *txt_logger_list(const char *sn, GaimAccount *account)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
655 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
656 return log_lister_common(sn, account, ".txt", &txt_logger);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
657 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
658
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
659 static char *txt_logger_read(GaimLog *log, GaimLogReadFlags *flags)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
660 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
661 char *read, *minus_header;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
662 struct generic_logger_data *data = log->logger_data;
7457
8bc33ec515a1 [gaim-migrate @ 8070]
Nathan Walp <nwalp@pidgin.im>
parents: 7453
diff changeset
663 *flags = 0;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
664 if (!data || !data->path)
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
665 return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>"));
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
666 if (g_file_get_contents(data->path, &read, NULL, NULL)) {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
667 minus_header = strchr(read, '\n');
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
668 if (!minus_header)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
669 minus_header = g_strdup(read);
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
670 else
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
671 minus_header = g_strdup(minus_header + 1);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
672 g_free(read);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
673 return minus_header;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
674 }
7471
68020c122954 [gaim-migrate @ 8084]
Mark Doliner <mark@kingant.net>
parents: 7470
diff changeset
675 return g_strdup(_("<font color=\"red\"><b>Could not read file: %s</b></font>"));
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
676 }
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
677
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
678 static GaimLogLogger txt_logger = {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
679 N_("Plain text"), "txt",
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
680 NULL,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
681 txt_logger_write,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
682 txt_logger_finalize,
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
683 txt_logger_list,
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
684 txt_logger_read,
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
685 log_sizer_common
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
686 };
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
687
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
688 /****************
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
689 * OLD LOGGER ***
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
690 ****************/
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
691
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
692 /* The old logger doesn't write logs, only reads them. This is to include
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
693 * old logs in the log viewer transparently.
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
694 */
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
695
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
696 struct old_logger_data {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
697 char *path;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
698 int offset;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
699 int length;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
700 };
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
701
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
702 static GList *old_logger_list(const char *sn, GaimAccount *account)
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
703 {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
704 FILE *file;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
705 char buf[BUF_LONG];
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
706 struct tm tm;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
707 struct old_logger_data *data = NULL;
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
708 char month[4];
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
709 char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn));
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
710 char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
711 char *newlog;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
712
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
713 GaimLog *log = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
714 GList *list = NULL;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
715
7473
859e4cf4d472 [gaim-migrate @ 8086]
Mark Doliner <mark@kingant.net>
parents: 7472
diff changeset
716 g_free(logfile);
859e4cf4d472 [gaim-migrate @ 8086]
Mark Doliner <mark@kingant.net>
parents: 7472
diff changeset
717
7461
c1ddc403fda4 [gaim-migrate @ 8074]
Nathan Walp <nwalp@pidgin.im>
parents: 7457
diff changeset
718 if (!(file = fopen(path, "rb"))) {
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
719 g_free(path);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
720 return NULL;
7447
0e7a835e2433 [gaim-migrate @ 8058]
Mark Doliner <mark@kingant.net>
parents: 7443
diff changeset
721 }
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
722
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
723 while (fgets(buf, BUF_LONG, file)) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
724 if ((newlog = strstr(buf, "---- New C"))) {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
725 int length;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
726 int offset;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
727 char convostart[32];
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
728 char *temp = strchr(buf, '@');
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
729
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
730 if (temp == NULL || strlen(temp) < 2)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
731 continue;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
732
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
733 temp++;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
734 length = strcspn(temp, "-");
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
735 if (length > 31) length = 31;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
736
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
737 offset = ftell(file);
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
738
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
739 if (data) {
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
740 data->length = offset - data->offset - length;
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
741 if(strstr(buf, "----</H3><BR>")) {
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
742 data->length -=
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
743 strlen("<HR><BR><H3 Align=Center> ---- New Conversation @ ") +
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
744 strlen("----</H3><BR>");
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
745 } else {
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
746 data->length -=
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
747 strlen("---- New Conversation @ ") + strlen("----");
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
748 }
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
749
7461
c1ddc403fda4 [gaim-migrate @ 8074]
Nathan Walp <nwalp@pidgin.im>
parents: 7457
diff changeset
750 if(strchr(buf, '\r'))
c1ddc403fda4 [gaim-migrate @ 8074]
Nathan Walp <nwalp@pidgin.im>
parents: 7457
diff changeset
751 data->length--;
c1ddc403fda4 [gaim-migrate @ 8074]
Nathan Walp <nwalp@pidgin.im>
parents: 7457
diff changeset
752
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
753 if (data->length != 0)
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
754 list = g_list_append(list, log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
755 else
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
756 gaim_log_free(log);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
757 }
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
758
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
759 log = gaim_log_new(GAIM_LOG_IM, sn, account, -1);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
760 log->logger = &old_logger;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
761
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
762 data = g_new0(struct old_logger_data, 1);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
763 data->offset = offset;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
764 data->path = g_strdup(path);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
765 log->logger_data = data;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
766
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
767
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
768 g_snprintf(convostart, length, "%s", temp);
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
769 sscanf(convostart, "%*s %s %d %d:%d:%d %d",
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
770 month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
771 /* Ugly hack, in case current locale is not English */
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
772 if (strcmp(month, "Jan") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
773 tm.tm_mon= 0;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
774 } else if (strcmp(month, "Feb") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
775 tm.tm_mon = 1;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
776 } else if (strcmp(month, "Mar") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
777 tm.tm_mon = 2;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
778 } else if (strcmp(month, "Apr") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
779 tm.tm_mon = 3;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
780 } else if (strcmp(month, "May") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
781 tm.tm_mon = 4;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
782 } else if (strcmp(month, "Jun") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
783 tm.tm_mon = 5;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
784 } else if (strcmp(month, "Jul") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
785 tm.tm_mon = 6;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
786 } else if (strcmp(month, "Aug") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
787 tm.tm_mon = 7;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
788 } else if (strcmp(month, "Sep") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
789 tm.tm_mon = 8;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
790 } else if (strcmp(month, "Oct") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
791 tm.tm_mon = 9;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
792 } else if (strcmp(month, "Nov") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
793 tm.tm_mon = 10;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
794 } else if (strcmp(month, "Dec") == 0) {
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
795 tm.tm_mon = 11;
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
796 }
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7628
diff changeset
797 tm.tm_year -= 1900;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
798 log->time = mktime(&tm);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
799 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
800 }
7613
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
801
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
802 if (data) {
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
803 data->length = ftell(file) - data->offset;
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
804 if (data->length != 0)
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
805 list = g_list_append(list, log);
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
806 else
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
807 gaim_log_free(log);
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
808 }
62d11301b8a6 [gaim-migrate @ 8237]
Nathan Walp <nwalp@pidgin.im>
parents: 7612
diff changeset
809
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
810 g_free(path);
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
811 fclose(file);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
812 return list;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
813 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
814
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
815 static char * old_logger_read (GaimLog *log, GaimLogReadFlags *flags)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
816 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
817 struct old_logger_data *data = log->logger_data;
7461
c1ddc403fda4 [gaim-migrate @ 8074]
Nathan Walp <nwalp@pidgin.im>
parents: 7457
diff changeset
818 FILE *file = fopen(data->path, "rb");
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
819 char *read = g_malloc(data->length + 1);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
820 fseek(file, data->offset, SEEK_SET);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
821 fread(read, data->length, 1, file);
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
822 read[data->length] = '\0';
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
823 *flags = 0;
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
824 if(strstr(read, "<BR>"))
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7431
diff changeset
825 *flags |= GAIM_LOG_READ_NO_NEWLINE;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
826 return read;
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
827 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
828
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
829 static int old_logger_size (GaimLog *log)
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
830 {
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
831 struct old_logger_data *data = log->logger_data;
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
832 return data ? data->length : 0;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
833 }
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
834
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
835 static void old_logger_finalize(GaimLog *log)
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
836 {
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
837 struct old_logger_data *data = log->logger_data;
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
838 g_free(data->path);
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
839 g_free(data);
7556
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
840 }
219903d29401 [gaim-migrate @ 8170]
Sean Egan <seanegan@gmail.com>
parents: 7555
diff changeset
841
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
842 static GaimLogLogger old_logger = {
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
843 "old logger", "old",
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
844 NULL, NULL,
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
845 old_logger_finalize,
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
846 old_logger_list,
7616
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
847 old_logger_read,
a4acf41898c1 [gaim-migrate @ 8240]
Nathan Walp <nwalp@pidgin.im>
parents: 7613
diff changeset
848 old_logger_size
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7322
diff changeset
849 };