Mercurial > pidgin.yaz
comparison libpurple/plugins/log_reader.c @ 24257:848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
time ago. Let's finish gobjectification, and grow some good language
bindings so I can rewrite this in a higher-level language.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 30 Oct 2008 02:36:22 +0000 |
parents | 0d0088b03745 |
children | 750f9b4d8547 |
comparison
equal
deleted
inserted
replaced
24256:0d0088b03745 | 24257:848542528965 |
---|---|
660 } else { | 660 } else { |
661 username = g_strdup(purple_normalize(account, account->username)); | 661 username = g_strdup(purple_normalize(account, account->username)); |
662 } | 662 } |
663 | 663 |
664 if (buddy) { | 664 if (buddy) { |
665 PurpleBlistNode *node = (PurpleBlistNode *)buddy; | 665 purple_blist_node_set_string(PURPLE_BLIST_NODE(buddy), |
666 savedfilename = purple_blist_node_get_string(node, "log_reader_msn_log_filename"); | 666 "log_reader_msn_log_filename", logfile); |
667 } | 667 } |
668 | 668 |
669 if (savedfilename) { | 669 if (savedfilename) { |
670 /* As a special case, we allow the null string to kill the parsing | 670 /* As a special case, we allow the null string to kill the parsing |
671 * straight away. This would allow the user to deal with the case | 671 * straight away. This would allow the user to deal with the case |
1020 } | 1020 } |
1021 } else if (to_name_matches) { | 1021 } else if (to_name_matches) { |
1022 name_guessed = NAME_GUESS_THEM; | 1022 name_guessed = NAME_GUESS_THEM; |
1023 } else { | 1023 } else { |
1024 if (buddy) { | 1024 if (buddy) { |
1025 const gchar *a = NULL, *server_alias = NULL; | 1025 const char *server_alias = NULL; |
1026 gchar *alias = NULL, *temp = NULL; | 1026 char *alias = g_strdup(purple_buddy_get_alias(buddy)); |
1027 | 1027 char *temp; |
1028 a = purple_buddy_get_alias(buddy); | |
1029 if(a) | |
1030 alias = g_strdup(a); | |
1031 | 1028 |
1032 /* "Truncate" the string at the first non-alphanumeric | 1029 /* "Truncate" the string at the first non-alphanumeric |
1033 * character. The idea is to relax the comparison. | 1030 * character. The idea is to relax the comparison. |
1034 */ | 1031 */ |
1035 for (temp = alias; *temp ; temp++) { | 1032 for (temp = alias; *temp ; temp++) { |
1570 if (*line) | 1567 if (*line) |
1571 line++; | 1568 line++; |
1572 g_string_append(formatted, "</b>"); | 1569 g_string_append(formatted, "</b>"); |
1573 footer = NULL; | 1570 footer = NULL; |
1574 } else if (strstr(line, " signed off ")) { | 1571 } else if (strstr(line, " signed off ")) { |
1575 if (buddy != NULL) { | 1572 const char *alias = NULL; |
1576 const gchar *alias = purple_buddy_get_alias(buddy); | 1573 |
1577 | 1574 if (buddy != NULL) |
1578 if(alias != NULL) | 1575 alias = purple_buddy_get_alias(buddy); |
1579 g_string_append_printf(formatted, | 1576 |
1580 _("%s has signed off."), alias); | 1577 if (alias != NULL) { |
1581 else | 1578 g_string_append_printf(formatted, |
1582 g_string_append_printf(formatted, | 1579 _("%s has signed off."), alias); |
1583 _("%s has signed off."), log->name); | |
1584 } else { | 1580 } else { |
1585 g_string_append_printf(formatted, | 1581 g_string_append_printf(formatted, |
1586 _("%s has signed off."), log->name); | 1582 _("%s has signed off."), log->name); |
1587 } | 1583 } |
1588 line = ""; | 1584 line = ""; |
1589 } else if (strstr(line, " signed on ")) { | 1585 } else if (strstr(line, " signed on ")) { |
1590 if (buddy != NULL) { | 1586 const char *alias = NULL; |
1591 const gchar *alias = purple_buddy_get_alias(buddy); | 1587 |
1592 | 1588 if (buddy != NULL) |
1593 if(alias) | 1589 alias = purple_buddy_get_alias(buddy); |
1594 g_string_append(formatted, alias); | 1590 |
1595 else | 1591 if (alias != NULL) |
1596 g_string_append(formatted, log->name); | 1592 g_string_append(formatted, alias); |
1597 } else { | 1593 else |
1598 g_string_append(formatted, log->name); | 1594 g_string_append(formatted, log->name); |
1599 } | 1595 |
1600 line = " logged in."; | 1596 line = " logged in."; |
1601 } else if (purple_str_has_prefix(line, | 1597 } else if (purple_str_has_prefix(line, |
1602 "One or more messages may have been undeliverable.")) { | 1598 "One or more messages may have been undeliverable.")) { |
1603 | 1599 |
1604 g_string_append(formatted, | 1600 g_string_append(formatted, |
1650 | 1646 |
1651 footer = "</span></b>"; | 1647 footer = "</span></b>"; |
1652 } | 1648 } |
1653 } else if (purple_str_has_prefix(line, data->their_nickname)) { | 1649 } else if (purple_str_has_prefix(line, data->their_nickname)) { |
1654 if (buddy != NULL) { | 1650 if (buddy != NULL) { |
1655 const gchar *alias = purple_buddy_get_alias(buddy); | 1651 const char *alias = purple_buddy_get_alias(buddy); |
1656 | 1652 |
1657 if(alias != NULL) { | 1653 if (alias != NULL) { |
1658 line += strlen(data->their_nickname) + 2; | 1654 line += strlen(data->their_nickname) + 2; |
1659 g_string_append_printf(formatted, | 1655 g_string_append_printf(formatted, |
1660 "<span style=\"color: #A82F2F;\">" | 1656 "<span style=\"color: #A82F2F;\">" |
1661 "<b>%s</b></span>: ", alias); | 1657 "<b>%s</b></span>: ", alias); |
1662 } | 1658 } |
2023 "(%u:%02u:%02u) %cM ", hour % 12, | 2019 "(%u:%02u:%02u) %cM ", hour % 12, |
2024 min, sec, (hour >= 12) ? 'P': 'A'); | 2020 min, sec, (hour >= 12) ? 'P': 'A'); |
2025 g_string_append(formatted, "</font> "); | 2021 g_string_append(formatted, "</font> "); |
2026 | 2022 |
2027 if (is_in_message) { | 2023 if (is_in_message) { |
2028 const gchar *alias = NULL; | 2024 const char *alias = NULL; |
2029 | 2025 |
2030 if (buddy_name != NULL && buddy != NULL && | 2026 if (buddy_name != NULL && buddy != NULL && |
2031 (alias = purple_buddy_get_alias(buddy))) | 2027 (alias = purple_buddy_get_alias(buddy))) |
2032 { | 2028 { |
2033 g_string_append_printf(formatted, | 2029 g_string_append_printf(formatted, |
2034 "<span style=\"color: #A82F2F;\">" | 2030 "<span style=\"color: #A82F2F;\">" |
2035 "<b>%s</b></span>: ", alias); | 2031 "<b>%s</b></span>: ", alias); |
2036 } | 2032 } |