Mercurial > pidgin.yaz
comparison libpurple/log.c @ 29471:d83ee160ffb6
propagate from branch 'im.pidgin.pidgin' (head eb9385f349a20856b9d3f9911dbc8024caa44052)
to branch 'im.pidgin.pidgin.next.minor' (head 439fb2dd7a285d9ca645f65f36ef0f037abe7311)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Wed, 19 Aug 2009 00:46:04 +0000 |
parents | 36f23fdb58b6 |
children | 5d05940859fa |
comparison
equal
deleted
inserted
replaced
29470:7a3458436140 | 29471:d83ee160ffb6 |
---|---|
1127 set->name = name; | 1127 set->name = name; |
1128 set->account = account; | 1128 set->account = account; |
1129 /* set->buddy is always set below */ | 1129 /* set->buddy is always set below */ |
1130 set->normalized_name = g_strdup(purple_normalize(account, name)); | 1130 set->normalized_name = g_strdup(purple_normalize(account, name)); |
1131 | 1131 |
1132 /* Chat for .chat or .system at the end of the name to determine the type. */ | 1132 /* Check for .chat or .system at the end of the name to determine the type. */ |
1133 if (len >= 7) { | 1133 if (len >= 7) { |
1134 gchar *tmp = &name[len - 7]; | 1134 gchar *tmp = &name[len - 7]; |
1135 if (purple_strequal(tmp, ".system")) { | 1135 if (purple_strequal(tmp, ".system")) { |
1136 set->type = PURPLE_LOG_SYSTEM; | 1136 set->type = PURPLE_LOG_SYSTEM; |
1137 *tmp = '\0'; | 1137 *tmp = '\0'; |
1373 { | 1373 { |
1374 char *msg_fixed; | 1374 char *msg_fixed; |
1375 char *image_corrected_msg; | 1375 char *image_corrected_msg; |
1376 char *date; | 1376 char *date; |
1377 char *header; | 1377 char *header; |
1378 char *escaped_from; | |
1378 PurplePlugin *plugin = purple_find_prpl(purple_account_get_protocol_id(log->account)); | 1379 PurplePlugin *plugin = purple_find_prpl(purple_account_get_protocol_id(log->account)); |
1379 PurpleLogCommonLoggerData *data = log->logger_data; | 1380 PurpleLogCommonLoggerData *data = log->logger_data; |
1380 gsize written = 0; | 1381 gsize written = 0; |
1381 | 1382 |
1382 if(!data) { | 1383 if(!data) { |
1410 } | 1411 } |
1411 | 1412 |
1412 /* if we can't write to the file, give up before we hurt ourselves */ | 1413 /* if we can't write to the file, give up before we hurt ourselves */ |
1413 if(!data->file) | 1414 if(!data->file) |
1414 return 0; | 1415 return 0; |
1416 | |
1417 escaped_from = g_markup_escape_text(from, -1); | |
1415 | 1418 |
1416 image_corrected_msg = convert_image_tags(log, message); | 1419 image_corrected_msg = convert_image_tags(log, message); |
1417 purple_markup_html_to_xhtml(image_corrected_msg, &msg_fixed, NULL); | 1420 purple_markup_html_to_xhtml(image_corrected_msg, &msg_fixed, NULL); |
1418 | 1421 |
1419 /* Yes, this breaks encapsulation. But it's a static function and | 1422 /* Yes, this breaks encapsulation. But it's a static function and |
1432 written += fprintf(data->file, "<font size=\"2\">(%s)</font> %s<br/>\n", date, msg_fixed); | 1435 written += fprintf(data->file, "<font size=\"2\">(%s)</font> %s<br/>\n", date, msg_fixed); |
1433 else if (type & PURPLE_MESSAGE_ERROR) | 1436 else if (type & PURPLE_MESSAGE_ERROR) |
1434 written += fprintf(data->file, "<font color=\"#FF0000\"><font size=\"2\">(%s)</font><b> %s</b></font><br/>\n", date, msg_fixed); | 1437 written += fprintf(data->file, "<font color=\"#FF0000\"><font size=\"2\">(%s)</font><b> %s</b></font><br/>\n", date, msg_fixed); |
1435 else if (type & PURPLE_MESSAGE_WHISPER) | 1438 else if (type & PURPLE_MESSAGE_WHISPER) |
1436 written += fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", | 1439 written += fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", |
1437 date, from, msg_fixed); | 1440 date, escaped_from, msg_fixed); |
1438 else if (type & PURPLE_MESSAGE_AUTO_RESP) { | 1441 else if (type & PURPLE_MESSAGE_AUTO_RESP) { |
1439 if (type & PURPLE_MESSAGE_SEND) | 1442 if (type & PURPLE_MESSAGE_SEND) |
1440 written += fprintf(data->file, _("<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); | 1443 written += fprintf(data->file, _("<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, escaped_from, msg_fixed); |
1441 else if (type & PURPLE_MESSAGE_RECV) | 1444 else if (type & PURPLE_MESSAGE_RECV) |
1442 written += fprintf(data->file, _("<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); | 1445 written += fprintf(data->file, _("<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, escaped_from, msg_fixed); |
1443 } else if (type & PURPLE_MESSAGE_RECV) { | 1446 } else if (type & PURPLE_MESSAGE_RECV) { |
1444 if(purple_message_meify(msg_fixed, -1)) | 1447 if(purple_message_meify(msg_fixed, -1)) |
1445 written += fprintf(data->file, "<font color=\"#062585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> %s<br/>\n", | 1448 written += fprintf(data->file, "<font color=\"#062585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> %s<br/>\n", |
1446 date, from, msg_fixed); | 1449 date, escaped_from, msg_fixed); |
1447 else | 1450 else |
1448 written += fprintf(data->file, "<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br/>\n", | 1451 written += fprintf(data->file, "<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br/>\n", |
1449 date, from, msg_fixed); | 1452 date, escaped_from, msg_fixed); |
1450 } else if (type & PURPLE_MESSAGE_SEND) { | 1453 } else if (type & PURPLE_MESSAGE_SEND) { |
1451 if(purple_message_meify(msg_fixed, -1)) | 1454 if(purple_message_meify(msg_fixed, -1)) |
1452 written += fprintf(data->file, "<font color=\"#062585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> %s<br/>\n", | 1455 written += fprintf(data->file, "<font color=\"#062585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> %s<br/>\n", |
1453 date, from, msg_fixed); | 1456 date, escaped_from, msg_fixed); |
1454 else | 1457 else |
1455 written += fprintf(data->file, "<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br/>\n", | 1458 written += fprintf(data->file, "<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br/>\n", |
1456 date, from, msg_fixed); | 1459 date, escaped_from, msg_fixed); |
1457 } else { | 1460 } else { |
1458 purple_debug_error("log", "Unhandled message type.\n"); | 1461 purple_debug_error("log", "Unhandled message type.\n"); |
1459 written += fprintf(data->file, "<font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", | 1462 written += fprintf(data->file, "<font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", |
1460 date, from, msg_fixed); | 1463 date, escaped_from, msg_fixed); |
1461 } | 1464 } |
1462 } | 1465 } |
1463 g_free(date); | 1466 g_free(date); |
1464 g_free(msg_fixed); | 1467 g_free(msg_fixed); |
1468 g_free(escaped_from); | |
1465 fflush(data->file); | 1469 fflush(data->file); |
1466 | 1470 |
1467 return written; | 1471 return written; |
1468 } | 1472 } |
1469 | 1473 |