Mercurial > pidgin.yaz
annotate src/log.c @ 9521:9b2f1444811f
[gaim-migrate @ 10348]
Gary Kramlich: Fixing bugs, making friends.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 13 Jul 2004 02:07:28 +0000 |
parents | db95a6641ec1 |
children | 9c78aaa4117e |
rev | line source |
---|---|
7431 | 1 /** |
2 * @file log.c Logging API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7436 | 10 * |
7431 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
4184 | 24 */ |
4195 | 25 |
7431 | 26 #include "account.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
27 #include "debug.h" |
7431 | 28 #include "internal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
29 #include "log.h" |
5548 | 30 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
31 #include "util.h" |
7764 | 32 #include "stringref.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
33 |
8096 | 34 static GSList *loggers = NULL; |
35 | |
7457 | 36 static GaimLogLogger html_logger; |
7431 | 37 static GaimLogLogger txt_logger; |
38 static GaimLogLogger old_logger; | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
39 |
8635 | 40 struct _gaim_logsize_user { |
41 char *name; | |
42 GaimAccount *account; | |
43 }; | |
44 static GHashTable *logsize_users = NULL; | |
45 | |
46 | |
7431 | 47 /************************************************************************** |
48 * PUBLIC LOGGING FUNCTIONS *********************************************** | |
49 **************************************************************************/ | |
4184 | 50 |
7431 | 51 GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, time_t time) |
52 { | |
53 GaimLog *log = g_new0(GaimLog, 1); | |
8635 | 54 log->name = g_strdup(gaim_normalize(account, name)); |
7431 | 55 log->account = account; |
56 log->time = time; | |
8573 | 57 log->type = type; |
8096 | 58 log->logger_data = NULL; |
7431 | 59 log->logger = gaim_log_logger_get(); |
7440 | 60 if (log->logger && log->logger->create) |
61 log->logger->create(log); | |
7431 | 62 return log; |
4184 | 63 } |
64 | |
7431 | 65 void gaim_log_free(GaimLog *log) |
4184 | 66 { |
7431 | 67 g_return_if_fail(log); |
68 if (log->logger && log->logger->finalize) | |
69 log->logger->finalize(log); | |
70 g_free(log->name); | |
71 g_free(log); | |
72 } | |
7436 | 73 |
74 void gaim_log_write(GaimLog *log, GaimMessageFlags type, | |
7431 | 75 const char *from, time_t time, const char *message) |
76 { | |
8635 | 77 struct _gaim_logsize_user lu; |
78 | |
7431 | 79 g_return_if_fail(log); |
80 g_return_if_fail(log->logger); | |
7442 | 81 g_return_if_fail(log->logger->write); |
7431 | 82 |
8635 | 83 if ((log->type == GAIM_LOG_IM && |
84 gaim_prefs_get_bool("/core/logging/log_ims")) || | |
85 (log->type == GAIM_LOG_CHAT && | |
86 gaim_prefs_get_bool("/core/logging/log_chats")) || | |
87 (log->type == GAIM_LOG_SYSTEM && | |
88 gaim_prefs_get_bool("/core/logging/log_system"))) { | |
7553 | 89 (log->logger->write)(log, type, from, time, message); |
8635 | 90 lu.name = g_strdup(gaim_normalize(log->account, log->name)); |
91 lu.account = log->account; | |
92 g_hash_table_remove(logsize_users, &lu); | |
93 g_free(lu.name); | |
94 } | |
4184 | 95 } |
96 | |
7431 | 97 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags) |
4184 | 98 { |
7542 | 99 GaimLogReadFlags mflags; |
7431 | 100 g_return_val_if_fail(log && log->logger, NULL); |
7462 | 101 if (log->logger->read) { |
7535 | 102 char *ret = (log->logger->read)(log, flags ? flags : &mflags); |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7473
diff
changeset
|
103 gaim_str_strip_cr(ret); |
7462 | 104 return ret; |
105 } | |
7470 | 106 return (_("<b><font color=\"red\">The logger has no read function</font></b>")); |
4184 | 107 } |
7616 | 108 |
7556 | 109 int gaim_log_get_size(GaimLog *log) |
110 { | |
111 g_return_val_if_fail(log && log->logger, 0); | |
8096 | 112 |
7556 | 113 if (log->logger->size) |
114 return log->logger->size(log); | |
115 return 0; | |
116 } | |
117 | |
8635 | 118 static guint _gaim_logsize_user_hash(struct _gaim_logsize_user *lu) |
119 { | |
120 return g_str_hash(lu->name); | |
121 } | |
122 | |
123 static guint _gaim_logsize_user_equal(struct _gaim_logsize_user *lu1, | |
124 struct _gaim_logsize_user *lu2) | |
125 { | |
126 return ((!strcmp(lu1->name, lu2->name)) && lu1->account == lu2->account); | |
127 } | |
128 | |
129 static void _gaim_logsize_user_free_key(struct _gaim_logsize_user *lu) | |
130 { | |
131 g_free(lu->name); | |
132 g_free(lu); | |
133 } | |
134 | |
8898 | 135 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account) |
7556 | 136 { |
8635 | 137 int size; |
8096 | 138 GSList *n; |
8635 | 139 struct _gaim_logsize_user *lu; |
8096 | 140 |
8635 | 141 lu = g_new(struct _gaim_logsize_user, 1); |
142 lu->name = g_strdup(gaim_normalize(account, name)); | |
143 lu->account = account; | |
144 | |
145 if((size = GPOINTER_TO_INT(g_hash_table_lookup(logsize_users, lu)))) { | |
146 g_free(lu->name); | |
147 g_free(lu); | |
148 } else { | |
149 for (n = loggers; n; n = n->next) { | |
150 GaimLogLogger *logger = n->data; | |
7616 | 151 |
8635 | 152 if(logger->total_size){ |
8898 | 153 size += (logger->total_size)(type, name, account); |
8635 | 154 } else if(logger->list) { |
8898 | 155 GList *logs = (logger->list)(type, name, account); |
8635 | 156 int this_size = 0; |
157 | |
158 while (logs) { | |
159 GList *logs2 = logs->next; | |
160 GaimLog *log = (GaimLog*)(logs->data); | |
161 this_size += gaim_log_get_size(log); | |
162 gaim_log_free(log); | |
163 g_list_free_1(logs); | |
164 logs = logs2; | |
165 } | |
166 | |
167 size += this_size; | |
8096 | 168 } |
8635 | 169 } |
8096 | 170 |
8635 | 171 g_hash_table_replace(logsize_users, lu, GINT_TO_POINTER(size)); |
7556 | 172 } |
173 return size; | |
174 } | |
4184 | 175 |
7431 | 176 /**************************************************************************** |
177 * LOGGER FUNCTIONS ********************************************************* | |
178 ****************************************************************************/ | |
4184 | 179 |
7431 | 180 static GaimLogLogger *current_logger = NULL; |
7436 | 181 |
7431 | 182 static void logger_pref_cb(const char *name, GaimPrefType type, |
183 gpointer value, gpointer data) | |
184 { | |
185 GaimLogLogger *logger; | |
186 GSList *l = loggers; | |
187 while (l) { | |
188 logger = l->data; | |
189 if (!strcmp(logger->id, value)) { | |
190 gaim_log_logger_set(logger); | |
191 return; | |
4184 | 192 } |
7431 | 193 l = l->next; |
194 } | |
195 gaim_log_logger_set(&txt_logger); | |
196 } | |
4184 | 197 |
198 | |
8898 | 199 GaimLogLogger *gaim_log_logger_new( |
200 void(*create)(GaimLog *), | |
201 void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), | |
202 void(*finalize)(GaimLog *), | |
203 GList*(*list)(GaimLogType type, const char*, GaimAccount*), | |
204 char*(*read)(GaimLog*, GaimLogReadFlags*), | |
205 int(*size)(GaimLog*)) | |
7431 | 206 { |
207 GaimLogLogger *logger = g_new0(GaimLogLogger, 1); | |
7440 | 208 logger->create = create; |
7431 | 209 logger->write = write; |
210 logger->finalize = finalize; | |
211 logger->list = list; | |
212 logger->read = read; | |
7556 | 213 logger->size = size; |
7431 | 214 return logger; |
4184 | 215 } |
216 | |
7431 | 217 void gaim_log_logger_free(GaimLogLogger *logger) |
4184 | 218 { |
7431 | 219 g_free(logger); |
220 } | |
4184 | 221 |
7431 | 222 void gaim_log_logger_add (GaimLogLogger *logger) |
223 { | |
224 g_return_if_fail(logger); | |
225 if (g_slist_find(loggers, logger)) | |
226 return; | |
227 loggers = g_slist_append(loggers, logger); | |
228 } | |
229 | |
230 void gaim_log_logger_remove (GaimLogLogger *logger) | |
231 { | |
232 g_return_if_fail(logger); | |
233 g_slist_remove(loggers, logger); | |
4184 | 234 } |
235 | |
7431 | 236 void gaim_log_logger_set (GaimLogLogger *logger) |
4184 | 237 { |
7431 | 238 g_return_if_fail(logger); |
239 current_logger = logger; | |
7436 | 240 } |
4184 | 241 |
7431 | 242 GaimLogLogger *gaim_log_logger_get() |
243 { | |
244 return current_logger; | |
245 } | |
4184 | 246 |
7431 | 247 GList *gaim_log_logger_get_options(void) |
248 { | |
249 GSList *n; | |
250 GList *list = NULL; | |
251 GaimLogLogger *data; | |
4184 | 252 |
7431 | 253 for (n = loggers; n; n = n->next) { |
254 data = n->data; | |
255 if (!data->write) | |
256 continue; | |
7494 | 257 list = g_list_append(list, _(data->name)); |
7431 | 258 list = g_list_append(list, data->id); |
4184 | 259 } |
260 | |
7431 | 261 return list; |
262 } | |
263 | |
8573 | 264 gint gaim_log_compare(gconstpointer y, gconstpointer z) |
7431 | 265 { |
7436 | 266 const GaimLog *a = y; |
267 const GaimLog *b = z; | |
268 | |
7431 | 269 return b->time - a->time; |
270 } | |
271 | |
8898 | 272 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account) |
7431 | 273 { |
274 GList *logs = NULL; | |
275 GSList *n; | |
276 for (n = loggers; n; n = n->next) { | |
277 GaimLogLogger *logger = n->data; | |
278 if (!logger->list) | |
279 continue; | |
8898 | 280 logs = g_list_concat(logs, logger->list(type, name, account)); |
7431 | 281 } |
7436 | 282 |
8573 | 283 return g_list_sort(logs, gaim_log_compare); |
284 } | |
285 | |
286 GList *gaim_log_get_system_logs(GaimAccount *account) | |
287 { | |
288 GList *logs = NULL; | |
289 GSList *n; | |
290 for (n = loggers; n; n = n->next) { | |
291 GaimLogLogger *logger = n->data; | |
292 if (!logger->list_syslog) | |
293 continue; | |
294 logs = g_list_concat(logs, logger->list_syslog(account)); | |
295 } | |
296 | |
297 return g_list_sort(logs, gaim_log_compare); | |
7431 | 298 } |
299 | |
300 void gaim_log_init(void) | |
7436 | 301 { |
7431 | 302 gaim_prefs_add_none("/core/logging"); |
7555 | 303 gaim_prefs_add_bool("/core/logging/log_ims", FALSE); |
304 gaim_prefs_add_bool("/core/logging/log_chats", FALSE); | |
8573 | 305 gaim_prefs_add_bool("/core/logging/log_system", FALSE); |
306 gaim_prefs_add_bool("/core/logging/log_signon_signoff", FALSE); | |
307 gaim_prefs_add_bool("/core/logging/log_idle_state", FALSE); | |
308 gaim_prefs_add_bool("/core/logging/log_away_state", FALSE); | |
309 gaim_prefs_add_bool("/core/logging/log_own_states", FALSE); | |
310 | |
7431 | 311 gaim_prefs_add_string("/core/logging/format", "txt"); |
7457 | 312 gaim_log_logger_add(&html_logger); |
7431 | 313 gaim_log_logger_add(&txt_logger); |
314 gaim_log_logger_add(&old_logger); | |
315 gaim_prefs_connect_callback("/core/logging/format", | |
316 logger_pref_cb, NULL); | |
317 gaim_prefs_trigger_callback("/core/logging/format"); | |
8635 | 318 |
319 logsize_users = g_hash_table_new_full((GHashFunc)_gaim_logsize_user_hash, | |
320 (GEqualFunc)_gaim_logsize_user_equal, | |
321 (GDestroyNotify)_gaim_logsize_user_free_key, NULL); | |
7431 | 322 } |
323 | |
324 /**************************************************************************** | |
325 * LOGGERS ****************************************************************** | |
326 ****************************************************************************/ | |
327 | |
7616 | 328 struct generic_logger_data { |
329 char *path; | |
330 FILE *file; | |
331 }; | |
332 | |
8898 | 333 static GList *log_lister_common(GaimLogType type, const char *name, GaimAccount *account, const char *ext, GaimLogLogger *logger) |
7431 | 334 { |
335 GDir *dir; | |
336 GList *list = NULL; | |
7628 | 337 const char *filename; |
8111 | 338 char *me; |
339 const char *prpl; | |
340 char *path; | |
341 | |
342 if(!account) | |
343 return NULL; | |
344 | |
8898 | 345 if (type == GAIM_LOG_CHAT) |
346 me = g_strdup_printf("%s.chat", gaim_normalize(account, gaim_account_get_username(account))); | |
347 else | |
348 me = g_strdup(gaim_normalize(account, gaim_account_get_username(account))); | |
4184 | 349 |
7956 | 350 /* does this seem like a bad way to get this component of the path to anyone else? --Nathan */ |
8111 | 351 prpl = GAIM_PLUGIN_PROTOCOL_INFO |
7956 | 352 (gaim_find_prpl(gaim_account_get_protocol_id(account)))->list_icon(account, NULL); |
9500 | 353 if(type == GAIM_LOG_SYSTEM) |
354 path = g_build_filename(gaim_user_dir(),"logs", prpl, me, name, NULL); | |
355 else | |
356 path = g_build_filename(gaim_user_dir(),"logs", prpl, me, gaim_normalize(account, name), NULL); | |
7447 | 357 g_free(me); |
358 | |
7431 | 359 if (!(dir = g_dir_open(path, 0, NULL))) { |
360 g_free(path); | |
361 return NULL; | |
362 } | |
8898 | 363 |
7431 | 364 while ((filename = g_dir_read_name(dir))) { |
8577 | 365 if (gaim_str_has_suffix(filename, ext) && |
366 strlen(filename) == 17 + strlen(ext)) { | |
7431 | 367 GaimLog *log; |
7616 | 368 struct generic_logger_data *data; |
8577 | 369 time_t stamp = gaim_str_to_time(filename, FALSE); |
7431 | 370 |
8898 | 371 log = gaim_log_new(type, name, account, stamp); |
7431 | 372 log->logger = logger; |
7616 | 373 log->logger_data = data = g_new0(struct generic_logger_data, 1); |
374 data->path = g_build_filename(path, filename, NULL); | |
7431 | 375 list = g_list_append(list, log); |
4184 | 376 } |
377 } | |
7431 | 378 g_dir_close(dir); |
7447 | 379 g_free(path); |
7431 | 380 return list; |
381 } | |
4184 | 382 |
7556 | 383 /* Only to be used with logs listed from log_lister_common */ |
7616 | 384 int log_sizer_common(GaimLog *log) |
7556 | 385 { |
386 struct stat st; | |
7616 | 387 struct generic_logger_data *data = log->logger_data; |
7556 | 388 |
7616 | 389 if (!data->path || stat(data->path, &st)) |
7556 | 390 st.st_size = 0; |
391 | |
392 return st.st_size; | |
393 } | |
394 | |
7431 | 395 #if 0 /* Maybe some other time. */ |
7443 | 396 /**************** |
7431 | 397 ** XML LOGGER ** |
398 ****************/ | |
399 | |
400 static const char *str_from_msg_type (GaimMessageFlags type) | |
401 { | |
7443 | 402 |
7431 | 403 return ""; |
7443 | 404 |
7431 | 405 } |
406 | |
7443 | 407 static void xml_logger_write(GaimLog *log, |
408 GaimMessageFlags type, | |
7431 | 409 const char *from, time_t time, const char *message) |
410 { | |
411 char date[64]; | |
412 char *xhtml = NULL; | |
413 if (!log->logger_data) { | |
414 /* This log is new. We could use the loggers 'new' function, but | |
415 * creating a new file there would result in empty files in the case | |
416 * that you open a convo with someone, but don't say anything. | |
417 */ | |
418 char *ud = gaim_user_dir(); | |
419 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account))); | |
420 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO | |
421 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL); | |
422 char *dir; | |
423 FILE *file; | |
424 | |
8898 | 425 if (log->type == GAIM_LOG_CHAT) { |
426 char *chat = g_strdup_printf("%s.chat", guy); | |
427 g_free(guy); | |
428 guy = chat; | |
429 } | |
430 | |
7453 | 431 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.xml", localtime(&log->time)); |
7443 | 432 |
433 dir = g_build_filename(ud, "logs", | |
7431 | 434 prpl, guy, gaim_normalize(log->account, log->name), NULL); |
7612 | 435 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
7447 | 436 g_free(guy); |
7443 | 437 |
7431 | 438 char *filename = g_build_filename(dir, date, NULL); |
439 g_free(dir); | |
7443 | 440 |
7431 | 441 log->logger_data = fopen(filename, "a"); |
442 if (!log->logger_data) { | |
443 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename); | |
7564 | 444 g_free(filename); |
7431 | 445 return; |
446 } | |
7564 | 447 g_free(filename); |
7431 | 448 fprintf(log->logger_data, "<?xml version='1.0' encoding='UTF-8' ?>\n" |
449 "<?xml-stylesheet href='file:///usr/src/web/htdocs/log-stylesheet.xsl' type='text/xml' ?>\n"); | |
7443 | 450 |
7453 | 451 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time)); |
7431 | 452 fprintf(log->logger_data, "<conversation time='%s' screenname='%s' protocol='%s'>\n", |
453 date, log->name, prpl); | |
454 } | |
7443 | 455 |
7453 | 456 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time)); |
7431 | 457 gaim_markup_html_to_xhtml(message, &xhtml, NULL); |
458 if (from) | |
7443 | 459 fprintf(log->logger_data, "<message %s %s from='%s' time='%s'>%s</message>\n", |
460 str_from_msg_type(type), | |
7431 | 461 type & GAIM_MESSAGE_SEND ? "direction='sent'" : |
462 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", | |
463 from, date, xhtml); | |
464 else | |
7443 | 465 fprintf(log->logger_data, "<message %s %s time='%s'>%s</message>\n", |
466 str_from_msg_type(type), | |
7431 | 467 type & GAIM_MESSAGE_SEND ? "direction='sent'" : |
468 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", | |
7443 | 469 date, xhtml): |
7431 | 470 fflush(log->logger_data); |
471 g_free(xhtml); | |
7443 | 472 } |
473 | |
7431 | 474 static void xml_logger_finalize(GaimLog *log) |
475 { | |
476 if (log->logger_data) { | |
477 fprintf(log->logger_data, "</conversation>\n"); | |
478 fclose(log->logger_data); | |
479 log->logger_data = NULL; | |
480 } | |
481 } | |
7443 | 482 |
8898 | 483 static GList *xml_logger_list(GaimLogType type, const char *sn, GaimAccount *account) |
7431 | 484 { |
8898 | 485 return log_lister_common(type, sn, account, ".xml", &xml_logger); |
4184 | 486 } |
487 | |
7431 | 488 static GaimLogLogger xml_logger = { |
489 N_("XML"), "xml", | |
490 NULL, | |
491 xml_logger_write, | |
492 xml_logger_finalize, | |
493 xml_logger_list, | |
8096 | 494 NULL, |
7431 | 495 NULL |
496 }; | |
497 #endif | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
498 |
7431 | 499 /**************************** |
7457 | 500 ** HTML LOGGER ************* |
501 ****************************/ | |
502 | |
503 static void html_logger_write(GaimLog *log, GaimMessageFlags type, | |
504 const char *from, time_t time, const char *message) | |
505 { | |
7489 | 506 GaimConnection *gc = gaim_account_get_connection(log->account); |
7457 | 507 char date[64]; |
7882 | 508 char *msg_fixed; |
7616 | 509 struct generic_logger_data *data = log->logger_data; |
7618 | 510 if(!data) { |
7457 | 511 /* This log is new */ |
512 char *ud = gaim_user_dir(); | |
513 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account))); | |
7553 | 514 char *chat; |
7457 | 515 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO |
7956 | 516 (gaim_find_prpl(gaim_account_get_protocol_id(log->account)))->list_icon(log->account, NULL); |
7457 | 517 char *dir; |
518 char *filename; | |
519 | |
7553 | 520 if (log->type == GAIM_LOG_CHAT) { |
521 chat = g_strdup_printf("%s.chat", guy); | |
522 g_free(guy); | |
523 guy = chat; | |
524 } | |
525 | |
7457 | 526 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.html", localtime(&log->time)); |
527 | |
528 dir = g_build_filename(ud, "logs", | |
529 prpl, guy, gaim_normalize(log->account, log->name), NULL); | |
7612 | 530 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
7457 | 531 g_free(guy); |
532 | |
533 filename = g_build_filename(dir, date, NULL); | |
534 g_free(dir); | |
535 | |
7616 | 536 log->logger_data = data = g_new0(struct generic_logger_data, 1); |
537 | |
538 data->file = fopen(filename, "a"); | |
539 if (!data->file) { | |
7623 | 540 gaim_debug(GAIM_DEBUG_ERROR, "log", |
541 "Could not create log file %s\n", filename); | |
7564 | 542 g_free(filename); |
7457 | 543 return; |
544 } | |
545 g_free(filename); | |
546 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time)); | |
7616 | 547 fprintf(data->file, "<html><head><title>"); |
548 fprintf(data->file, "Conversation with %s at %s on %s (%s)", | |
7457 | 549 log->name, date, gaim_account_get_username(log->account), prpl); |
7616 | 550 fprintf(data->file, "</title></head><body>"); |
551 fprintf(data->file, | |
7457 | 552 "<h3>Conversation with %s at %s on %s (%s)</h3>\n", |
553 log->name, date, gaim_account_get_username(log->account), prpl); | |
554 } | |
7623 | 555 |
556 /* if we can't write to the file, give up before we hurt ourselves */ | |
557 if(!data->file) | |
558 return; | |
559 | |
7882 | 560 gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); |
561 | |
8577 | 562 if(log->type == GAIM_LOG_SYSTEM){ |
563 strftime(date, sizeof(date), "%c", localtime(&time)); | |
564 fprintf(data->file, "---- %s @ %s ----<br/>\n", msg_fixed, date); | |
565 } else { | |
566 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time)); | |
567 if (type & GAIM_MESSAGE_SYSTEM) | |
568 fprintf(data->file, "<font size=\"2\">(%s)</font><b> %s</b><br/>\n", date, msg_fixed); | |
569 else if (type & GAIM_MESSAGE_WHISPER) | |
570 fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", | |
571 date, from, msg_fixed); | |
572 else if (type & GAIM_MESSAGE_AUTO_RESP) { | |
573 if (type & GAIM_MESSAGE_SEND) | |
574 fprintf(data->file, _("<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); | |
575 else if (type & GAIM_MESSAGE_RECV) | |
576 fprintf(data->file, _("<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); | |
577 } else if (type & GAIM_MESSAGE_RECV) { | |
578 if(gaim_message_meify(msg_fixed, -1)) | |
579 fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", | |
580 date, from, gc->prpl->info->name, msg_fixed); | |
581 else | |
582 fprintf(data->file, "<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", | |
583 date, from, gc->prpl->info->name, msg_fixed); | |
584 } else if (type & GAIM_MESSAGE_SEND) { | |
585 if(gaim_message_meify(msg_fixed, -1)) | |
586 fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", | |
587 date, from, gc->prpl->info->name, msg_fixed); | |
588 else | |
589 fprintf(data->file, "<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", | |
590 date, from, gc->prpl->info->name, msg_fixed); | |
591 } | |
7564 | 592 } |
8573 | 593 |
7882 | 594 g_free(msg_fixed); |
7616 | 595 fflush(data->file); |
7457 | 596 } |
597 | |
598 static void html_logger_finalize(GaimLog *log) | |
599 { | |
7616 | 600 struct generic_logger_data *data = log->logger_data; |
601 if (data) { | |
602 if(data->file) { | |
603 fprintf(data->file, "</body></html>"); | |
604 fclose(data->file); | |
605 } | |
606 g_free(data->path); | |
7752 | 607 g_free(data); |
7463 | 608 } |
7457 | 609 } |
610 | |
8898 | 611 static GList *html_logger_list(GaimLogType type, const char *sn, GaimAccount *account) |
7457 | 612 { |
8898 | 613 return log_lister_common(type, sn, account, ".html", &html_logger); |
7457 | 614 } |
615 | |
8573 | 616 static GList *html_logger_list_syslog(GaimAccount *account) |
617 { | |
8898 | 618 return log_lister_common(GAIM_LOG_SYSTEM, ".system", account, ".html", &html_logger); |
8573 | 619 } |
620 | |
7457 | 621 static char *html_logger_read(GaimLog *log, GaimLogReadFlags *flags) |
622 { | |
623 char *read, *minus_header; | |
7616 | 624 struct generic_logger_data *data = log->logger_data; |
7457 | 625 *flags = GAIM_LOG_READ_NO_NEWLINE; |
7616 | 626 if (!data || !data->path) |
627 return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>")); | |
628 if (g_file_get_contents(data->path, &read, NULL, NULL)) { | |
7457 | 629 minus_header = strchr(read, '\n'); |
630 if (!minus_header) | |
631 minus_header = g_strdup(read); | |
632 else | |
633 minus_header = g_strdup(minus_header + 1); | |
634 g_free(read); | |
635 return minus_header; | |
636 } | |
8578 | 637 return g_strdup_printf(_("<font color=\"red\"><b>Could not read file: %s</b></font>"), data->path); |
7457 | 638 } |
639 | |
8573 | 640 static void html_logger_create(GaimLog *log) |
641 { | |
642 if(log->type == GAIM_LOG_SYSTEM){ | |
643 char date[64]; | |
644 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO | |
645 (gaim_find_prpl(gaim_account_get_protocol_id(log->account)))->list_icon(log->account, NULL); | |
646 char *ud = gaim_user_dir(); | |
647 char *dir = g_build_filename(ud, "logs", prpl, log->name, ".system", NULL); | |
648 char *filename; | |
649 struct generic_logger_data *data; | |
650 | |
651 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
652 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.html", localtime(&log->time)); | |
653 filename = g_build_filename(dir, date, NULL); | |
654 g_free(dir); | |
655 | |
656 log->logger_data = data = g_new0(struct generic_logger_data, 1); | |
657 | |
658 data->file = fopen(filename, "a"); | |
659 if (!data->file) { | |
660 gaim_debug(GAIM_DEBUG_ERROR, "log", | |
661 "Could not create log file %s\n", filename); | |
662 g_free(filename); | |
663 return; | |
664 } | |
665 fprintf(data->file, "<html><head><title>"); | |
666 fprintf(data->file, "System Log for %s (%s)", | |
667 gaim_account_get_username(log->account), prpl); | |
668 fprintf(data->file, "</title></head><body>"); | |
669 g_free(filename); | |
670 } | |
671 } | |
672 | |
7457 | 673 static GaimLogLogger html_logger = { |
674 N_("HTML"), "html", | |
8573 | 675 html_logger_create, |
7457 | 676 html_logger_write, |
677 html_logger_finalize, | |
678 html_logger_list, | |
7556 | 679 html_logger_read, |
8096 | 680 log_sizer_common, |
8573 | 681 NULL, |
682 html_logger_list_syslog | |
7457 | 683 }; |
684 | |
685 | |
686 | |
687 | |
688 /**************************** | |
7431 | 689 ** PLAIN TEXT LOGGER ******* |
690 ****************************/ | |
4184 | 691 |
7436 | 692 static void txt_logger_write(GaimLog *log, |
693 GaimMessageFlags type, | |
7431 | 694 const char *from, time_t time, const char *message) |
695 { | |
696 char date[64]; | |
697 char *stripped = NULL; | |
7616 | 698 struct generic_logger_data *data = log->logger_data; |
699 if (!data) { | |
7431 | 700 /* This log is new. We could use the loggers 'new' function, but |
701 * creating a new file there would result in empty files in the case | |
702 * that you open a convo with someone, but don't say anything. | |
8573 | 703 * |
8898 | 704 * The log is also not a system log. Because if it is, data would |
705 * be created in txt_logger_create | |
7431 | 706 */ |
707 char *ud = gaim_user_dir(); | |
708 char *guy = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account))); | |
7553 | 709 char *chat; |
7431 | 710 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO |
7956 | 711 (gaim_find_prpl(gaim_account_get_protocol_id(log->account)))->list_icon(log->account, NULL); |
7431 | 712 char *dir; |
8898 | 713 char *filename; |
7436 | 714 |
7553 | 715 if (log->type == GAIM_LOG_CHAT) { |
716 chat = g_strdup_printf("%s.chat", guy); | |
717 g_free(guy); | |
718 guy = chat; | |
719 } | |
8898 | 720 |
7453 | 721 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.txt", localtime(&log->time)); |
7436 | 722 |
723 dir = g_build_filename(ud, "logs", | |
7431 | 724 prpl, guy, gaim_normalize(log->account, log->name), NULL); |
7612 | 725 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
7447 | 726 g_free(guy); |
7436 | 727 |
7473 | 728 filename = g_build_filename(dir, date, NULL); |
7431 | 729 g_free(dir); |
7436 | 730 |
7616 | 731 log->logger_data = data = g_new0(struct generic_logger_data, 1); |
732 | |
733 data->file = fopen(filename, "a"); | |
734 if (!data->file) { | |
7431 | 735 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename); |
7564 | 736 g_free(filename); |
7431 | 737 return; |
4184 | 738 } |
7447 | 739 g_free(filename); |
7453 | 740 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&log->time)); |
7616 | 741 fprintf(data->file, "Conversation with %s at %s on %s (%s)\n", |
7431 | 742 log->name, date, gaim_account_get_username(log->account), prpl); |
743 } | |
7436 | 744 |
7623 | 745 /* if we can't write to the file, give up before we hurt ourselves */ |
746 if(!data->file) | |
747 return; | |
748 | |
8573 | 749 stripped = gaim_markup_strip_html(message); |
750 | |
751 if(log->type == GAIM_LOG_SYSTEM){ | |
752 strftime(date, sizeof(date), "%c", localtime(&time)); | |
753 fprintf(data->file, "---- %s @ %s ----\n", stripped, date); | |
754 } else { | |
755 strftime(date, sizeof(date), "%H:%M:%S", localtime(&time)); | |
756 if (type & GAIM_MESSAGE_SEND || | |
757 type & GAIM_MESSAGE_RECV) { | |
758 if (type & GAIM_MESSAGE_AUTO_RESP) { | |
759 fprintf(data->file, _("(%s) %s <AUTO-REPLY>: %s\n"), date, | |
760 from, stripped); | |
761 } else { | |
762 if(gaim_message_meify(stripped, -1)) | |
763 fprintf(data->file, "(%s) ***%s %s\n", date, from, | |
764 stripped); | |
765 else | |
766 fprintf(data->file, "(%s) %s: %s\n", date, from, | |
767 stripped); | |
768 } | |
769 } else if (type & GAIM_MESSAGE_SYSTEM) | |
770 fprintf(data->file, "(%s) %s\n", date, stripped); | |
771 else if (type & GAIM_MESSAGE_NO_LOG) { | |
772 /* This shouldn't happen */ | |
773 g_free(stripped); | |
774 return; | |
775 } else if (type & GAIM_MESSAGE_WHISPER) | |
776 fprintf(data->file, "(%s) *%s* %s", date, from, stripped); | |
777 else | |
778 fprintf(data->file, "(%s) %s%s %s\n", date, from ? from : "", | |
779 from ? ":" : "", stripped); | |
780 } | |
781 | |
782 fflush(data->file); | |
783 g_free(stripped); | |
7431 | 784 } |
785 | |
786 static void txt_logger_finalize(GaimLog *log) | |
787 { | |
7616 | 788 struct generic_logger_data *data = log->logger_data; |
789 if (data) { | |
790 if(data->file) | |
791 fclose(data->file); | |
792 if(data->path) | |
793 g_free(data->path); | |
7752 | 794 g_free(data); |
7616 | 795 } |
7431 | 796 } |
797 | |
8898 | 798 static GList *txt_logger_list(GaimLogType type, const char *sn, GaimAccount *account) |
7431 | 799 { |
8898 | 800 return log_lister_common(type, sn, account, ".txt", &txt_logger); |
7431 | 801 } |
802 | |
8573 | 803 static GList *txt_logger_list_syslog(GaimAccount *account) |
804 { | |
8898 | 805 return log_lister_common(GAIM_LOG_SYSTEM, ".system", account, ".txt", &txt_logger); |
8573 | 806 } |
807 | |
7431 | 808 static char *txt_logger_read(GaimLog *log, GaimLogReadFlags *flags) |
809 { | |
8517 | 810 char *read, *minus_header, *minus_header2; |
7616 | 811 struct generic_logger_data *data = log->logger_data; |
7457 | 812 *flags = 0; |
7616 | 813 if (!data || !data->path) |
814 return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>")); | |
815 if (g_file_get_contents(data->path, &read, NULL, NULL)) { | |
7431 | 816 minus_header = strchr(read, '\n'); |
817 if (!minus_header) | |
818 minus_header = g_strdup(read); | |
7436 | 819 else |
7431 | 820 minus_header = g_strdup(minus_header + 1); |
821 g_free(read); | |
8517 | 822 minus_header2 = gaim_escape_html(minus_header); |
823 g_free(minus_header); | |
824 return minus_header2; | |
7431 | 825 } |
8578 | 826 return g_strdup_printf(_("<font color=\"red\"><b>Could not read file: %s</b></font>"), data->path); |
7436 | 827 } |
7431 | 828 |
8573 | 829 static void txt_logger_create(GaimLog *log) |
830 { | |
831 if(log->type == GAIM_LOG_SYSTEM){ | |
832 char date[64]; | |
833 const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO | |
834 (gaim_find_prpl(gaim_account_get_protocol_id(log->account)))->list_icon(log->account, NULL); | |
835 char *ud = gaim_user_dir(); | |
836 char *dir = g_build_filename(ud, "logs", prpl, log->name, ".system", NULL); | |
837 char *filename; | |
838 struct generic_logger_data *data; | |
839 | |
840 gaim_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
841 strftime(date, sizeof(date), "%Y-%m-%d.%H%M%S.txt", localtime(&log->time)); | |
842 filename = g_build_filename(dir, date, NULL); | |
843 g_free(dir); | |
844 | |
845 log->logger_data = data = g_new0(struct generic_logger_data, 1); | |
846 | |
847 data->file = fopen(filename, "a"); | |
848 if (!data->file) { | |
849 gaim_debug(GAIM_DEBUG_ERROR, "log", | |
850 "Could not create log file %s\n", filename); | |
851 g_free(filename); | |
852 return; | |
853 } | |
854 g_free(filename); | |
855 } | |
856 } | |
857 | |
7431 | 858 static GaimLogLogger txt_logger = { |
859 N_("Plain text"), "txt", | |
8573 | 860 txt_logger_create, |
7431 | 861 txt_logger_write, |
862 txt_logger_finalize, | |
863 txt_logger_list, | |
7556 | 864 txt_logger_read, |
8096 | 865 log_sizer_common, |
8573 | 866 NULL, |
867 txt_logger_list_syslog | |
7431 | 868 }; |
869 | |
870 /**************** | |
871 * OLD LOGGER *** | |
872 ****************/ | |
873 | |
874 /* The old logger doesn't write logs, only reads them. This is to include | |
875 * old logs in the log viewer transparently. | |
876 */ | |
877 | |
878 struct old_logger_data { | |
7764 | 879 GaimStringref *pathref; |
7431 | 880 int offset; |
881 int length; | |
882 }; | |
883 | |
8898 | 884 static GList *old_logger_list(GaimLogType type, const char *sn, GaimAccount *account) |
7431 | 885 { |
886 FILE *file; | |
887 char buf[BUF_LONG]; | |
888 struct tm tm; | |
7761 | 889 char month[4]; |
7431 | 890 struct old_logger_data *data = NULL; |
891 char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn)); | |
7764 | 892 char *pathstr = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); |
893 GaimStringref *pathref = gaim_stringref_new(pathstr); | |
7431 | 894 char *newlog; |
7761 | 895 int logfound = 0; |
896 int lastoff = 0; | |
897 int newlen; | |
7791 | 898 time_t lasttime = 0; |
7431 | 899 |
900 GaimLog *log = NULL; | |
901 GList *list = NULL; | |
902 | |
7473 | 903 g_free(logfile); |
7764 | 904 g_free(pathstr); |
7473 | 905 |
7764 | 906 if (!(file = fopen(gaim_stringref_value(pathref), "rb"))) { |
907 gaim_stringref_unref(pathref); | |
7431 | 908 return NULL; |
7447 | 909 } |
7436 | 910 |
7431 | 911 while (fgets(buf, BUF_LONG, file)) { |
912 if ((newlog = strstr(buf, "---- New C"))) { | |
913 int length; | |
914 int offset; | |
915 char convostart[32]; | |
916 char *temp = strchr(buf, '@'); | |
7436 | 917 |
7431 | 918 if (temp == NULL || strlen(temp) < 2) |
919 continue; | |
7436 | 920 |
7431 | 921 temp++; |
922 length = strcspn(temp, "-"); | |
923 if (length > 31) length = 31; | |
7436 | 924 |
7431 | 925 offset = ftell(file); |
7436 | 926 |
7761 | 927 if (logfound) { |
928 newlen = offset - lastoff - length; | |
7436 | 929 if(strstr(buf, "----</H3><BR>")) { |
7761 | 930 newlen -= |
931 sizeof("<HR><BR><H3 Align=Center> ---- New Conversation @ ") + | |
932 sizeof("----</H3><BR>") - 2; | |
7436 | 933 } else { |
7761 | 934 newlen -= |
935 sizeof("---- New Conversation @ ") + sizeof("----") - 2; | |
7436 | 936 } |
937 | |
7461 | 938 if(strchr(buf, '\r')) |
7770 | 939 newlen--; |
7461 | 940 |
7761 | 941 if (newlen != 0) { |
942 log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); | |
943 log->logger = &old_logger; | |
944 log->time = lasttime; | |
945 data = g_new0(struct old_logger_data, 1); | |
946 data->offset = lastoff; | |
947 data->length = newlen; | |
7764 | 948 data->pathref = gaim_stringref_ref(pathref); |
7761 | 949 log->logger_data = data; |
7431 | 950 list = g_list_append(list, log); |
7761 | 951 } |
7431 | 952 } |
953 | |
7761 | 954 logfound = 1; |
955 lastoff = offset; | |
7436 | 956 |
7431 | 957 g_snprintf(convostart, length, "%s", temp); |
7676 | 958 sscanf(convostart, "%*s %s %d %d:%d:%d %d", |
959 month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year); | |
960 /* Ugly hack, in case current locale is not English */ | |
961 if (strcmp(month, "Jan") == 0) { | |
962 tm.tm_mon= 0; | |
963 } else if (strcmp(month, "Feb") == 0) { | |
964 tm.tm_mon = 1; | |
965 } else if (strcmp(month, "Mar") == 0) { | |
966 tm.tm_mon = 2; | |
967 } else if (strcmp(month, "Apr") == 0) { | |
968 tm.tm_mon = 3; | |
969 } else if (strcmp(month, "May") == 0) { | |
970 tm.tm_mon = 4; | |
971 } else if (strcmp(month, "Jun") == 0) { | |
972 tm.tm_mon = 5; | |
973 } else if (strcmp(month, "Jul") == 0) { | |
974 tm.tm_mon = 6; | |
975 } else if (strcmp(month, "Aug") == 0) { | |
976 tm.tm_mon = 7; | |
977 } else if (strcmp(month, "Sep") == 0) { | |
978 tm.tm_mon = 8; | |
979 } else if (strcmp(month, "Oct") == 0) { | |
980 tm.tm_mon = 9; | |
981 } else if (strcmp(month, "Nov") == 0) { | |
982 tm.tm_mon = 10; | |
983 } else if (strcmp(month, "Dec") == 0) { | |
984 tm.tm_mon = 11; | |
985 } | |
986 tm.tm_year -= 1900; | |
7761 | 987 lasttime = mktime(&tm); |
4184 | 988 } |
989 } | |
7613 | 990 |
7761 | 991 if (logfound) { |
992 if ((newlen = ftell(file) - lastoff) != 0) { | |
993 log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); | |
994 log->logger = &old_logger; | |
995 log->time = lasttime; | |
996 data = g_new0(struct old_logger_data, 1); | |
997 data->offset = lastoff; | |
998 data->length = newlen; | |
7764 | 999 data->pathref = gaim_stringref_ref(pathref); |
7761 | 1000 log->logger_data = data; |
7613 | 1001 list = g_list_append(list, log); |
7761 | 1002 } |
7613 | 1003 } |
1004 | |
7764 | 1005 gaim_stringref_unref(pathref); |
7431 | 1006 fclose(file); |
1007 return list; | |
4184 | 1008 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
1009 |
8898 | 1010 static int old_logger_total_size(GaimLogType type, const char *name, GaimAccount *account) |
8096 | 1011 { |
1012 char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, name)); | |
1013 char *pathstr = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); | |
1014 int size; | |
1015 struct stat st; | |
1016 | |
1017 if (stat(pathstr, &st)) | |
1018 size = 0; | |
1019 else | |
1020 size = st.st_size; | |
1021 | |
1022 g_free(logfile); | |
1023 g_free(pathstr); | |
1024 | |
1025 return size; | |
1026 } | |
1027 | |
7616 | 1028 static char * old_logger_read (GaimLog *log, GaimLogReadFlags *flags) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
1029 { |
7431 | 1030 struct old_logger_data *data = log->logger_data; |
7764 | 1031 FILE *file = fopen(gaim_stringref_value(data->pathref), "rb"); |
7431 | 1032 char *read = g_malloc(data->length + 1); |
1033 fseek(file, data->offset, SEEK_SET); | |
1034 fread(read, data->length, 1, file); | |
8370 | 1035 fclose(file); |
7431 | 1036 read[data->length] = '\0'; |
7436 | 1037 *flags = 0; |
1038 if(strstr(read, "<BR>")) | |
1039 *flags |= GAIM_LOG_READ_NO_NEWLINE; | |
7431 | 1040 return read; |
1041 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
1042 |
7616 | 1043 static int old_logger_size (GaimLog *log) |
7556 | 1044 { |
1045 struct old_logger_data *data = log->logger_data; | |
7616 | 1046 return data ? data->length : 0; |
1047 } | |
1048 | |
1049 static void old_logger_finalize(GaimLog *log) | |
1050 { | |
1051 struct old_logger_data *data = log->logger_data; | |
7764 | 1052 gaim_stringref_unref(data->pathref); |
7616 | 1053 g_free(data); |
7556 | 1054 } |
1055 | |
7431 | 1056 static GaimLogLogger old_logger = { |
1057 "old logger", "old", | |
7616 | 1058 NULL, NULL, |
1059 old_logger_finalize, | |
7431 | 1060 old_logger_list, |
7616 | 1061 old_logger_read, |
8096 | 1062 old_logger_size, |
8573 | 1063 old_logger_total_size, |
1064 NULL | |
7431 | 1065 }; |