Mercurial > pidgin
comparison src/log.c @ 9892:284a84477ee9
[gaim-migrate @ 10780]
(20:58:51) datallah: "this should make windows suck less..."
i don't think that's possible. but it might make gaim on win32 suck less.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 28 Aug 2004 00:56:30 +0000 |
parents | 49900c3a8f55 |
children | 248c3f88ce99 |
comparison
equal
deleted
inserted
replaced
9891:67dbf65e76cf | 9892:284a84477ee9 |
---|---|
72 } | 72 } |
73 | 73 |
74 void gaim_log_write(GaimLog *log, GaimMessageFlags type, | 74 void gaim_log_write(GaimLog *log, GaimMessageFlags type, |
75 const char *from, time_t time, const char *message) | 75 const char *from, time_t time, const char *message) |
76 { | 76 { |
77 struct _gaim_logsize_user lu; | |
78 | |
79 g_return_if_fail(log); | 77 g_return_if_fail(log); |
80 g_return_if_fail(log->logger); | 78 g_return_if_fail(log->logger); |
81 g_return_if_fail(log->logger->write); | 79 g_return_if_fail(log->logger->write); |
82 | 80 |
83 if ((log->type == GAIM_LOG_IM && | 81 if ((log->type == GAIM_LOG_IM && |
84 gaim_prefs_get_bool("/core/logging/log_ims")) || | 82 gaim_prefs_get_bool("/core/logging/log_ims")) || |
85 (log->type == GAIM_LOG_CHAT && | 83 (log->type == GAIM_LOG_CHAT && |
86 gaim_prefs_get_bool("/core/logging/log_chats")) || | 84 gaim_prefs_get_bool("/core/logging/log_chats")) || |
87 (log->type == GAIM_LOG_SYSTEM && | 85 (log->type == GAIM_LOG_SYSTEM && |
88 gaim_prefs_get_bool("/core/logging/log_system"))) { | 86 gaim_prefs_get_bool("/core/logging/log_system"))) { |
87 struct _gaim_logsize_user *lu; | |
89 (log->logger->write)(log, type, from, time, message); | 88 (log->logger->write)(log, type, from, time, message); |
90 lu.name = g_strdup(gaim_normalize(log->account, log->name)); | 89 |
91 lu.account = log->account; | 90 lu = g_new(struct _gaim_logsize_user, 1); |
92 g_hash_table_remove(logsize_users, &lu); | 91 |
93 g_free(lu.name); | 92 lu->name = g_strdup(gaim_normalize(log->account, log->name)); |
93 lu->account = log->account; | |
94 g_hash_table_remove(logsize_users, lu); | |
95 g_free(lu->name); | |
96 g_free(lu); | |
94 } | 97 } |
95 } | 98 } |
96 | 99 |
97 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags) | 100 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags) |
98 { | 101 { |
341 | 344 |
342 if(!data) { | 345 if(!data) { |
343 /* This log is new */ | 346 /* This log is new */ |
344 char *ud = gaim_user_dir(); | 347 char *ud = gaim_user_dir(); |
345 char *acct_name = g_strdup(gaim_normalize(log->account, | 348 char *acct_name = g_strdup(gaim_normalize(log->account, |
346 gaim_account_get_username(log->account))); | 349 gaim_account_get_username(log->account))); |
347 char *target; | 350 char *target; |
348 char *dir; | 351 char *dir; |
349 char *filename, *path; | 352 char *filename, *path; |
350 | 353 |
351 if (log->type == GAIM_LOG_CHAT) { | 354 if (log->type == GAIM_LOG_CHAT) { |
352 target = g_strdup_printf("%s.chat", gaim_normalize(log->account, | 355 target = g_strdup_printf("%s.chat", gaim_normalize(log->account, |
353 log->name)); | 356 log->name)); |
354 } else if(log->type == GAIM_LOG_SYSTEM) { | 357 } else if(log->type == GAIM_LOG_SYSTEM) { |
355 target = g_strdup(".system"); | 358 target = g_strdup(".system"); |
356 } else { | 359 } else { |
357 target = g_strdup(gaim_normalize(log->account, log->name)); | 360 target = g_strdup(gaim_normalize(log->account, log->name)); |
358 } | 361 } |
374 log->logger_data = data = g_new0(struct generic_logger_data, 1); | 377 log->logger_data = data = g_new0(struct generic_logger_data, 1); |
375 | 378 |
376 data->file = fopen(path, "a"); | 379 data->file = fopen(path, "a"); |
377 if (!data->file) { | 380 if (!data->file) { |
378 gaim_debug(GAIM_DEBUG_ERROR, "log", | 381 gaim_debug(GAIM_DEBUG_ERROR, "log", |
379 "Could not create log file %s\n", filename); | 382 "Could not create log file %s\n", path); |
380 g_free(path); | 383 g_free(path); |
381 return; | 384 return; |
382 } | 385 } |
383 g_free(path); | 386 g_free(path); |
384 } | 387 } |
582 fprintf(data->file, | 585 fprintf(data->file, |
583 "<h3>Conversation with %s at %s on %s (%s)</h3>\n", | 586 "<h3>Conversation with %s at %s on %s (%s)</h3>\n", |
584 log->name, date, gaim_account_get_username(log->account), prpl); | 587 log->name, date, gaim_account_get_username(log->account), prpl); |
585 | 588 |
586 } | 589 } |
590 | |
591 /* if we can't write to the file, give up before we hurt ourselves */ | |
592 if(!data->file) | |
593 return; | |
587 | 594 |
588 gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); | 595 gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); |
589 | 596 |
590 if(log->type == GAIM_LOG_SYSTEM){ | 597 if(log->type == GAIM_LOG_SYSTEM){ |
591 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&time)); | 598 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&time)); |