comparison plugins/log_reader.c @ 11702:994f1c7bee8b

[gaim-migrate @ 13993] Fix a crash when trying to view logs on an unconnected MSN account. While I tried to debug that, I fixed a couple little things. Apparently I also reworked some of the name heuristics before and didn't commit it. NOTE: This plugin's code still sucks and it should be avoided. :) committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 20 Oct 2005 16:50:00 +0000
parents cd0c8830d881
children ae51c59bf819
comparison
equal deleted inserted replaced
11701:5d7da4056644 11702:994f1c7bee8b
837 } 837 }
838 838
839 their_name = from_name; 839 their_name = from_name;
840 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { 840 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) {
841 const char *friendly_name = gaim_connection_get_display_name(log->account->gc); 841 const char *friendly_name = gaim_connection_get_display_name(log->account->gc);
842 int friendly_name_length = strlen(friendly_name); 842
843 int alias_length = strlen(log->account->alias); 843 if (friendly_name != NULL) {
844 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); 844 int friendly_name_length = strlen(friendly_name);
845 gboolean from_name_matches; 845 int alias_length = strlen(log->account->alias);
846 gboolean to_name_matches; 846 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name);
847 847 gboolean from_name_matches;
848 if (buddy->alias) 848 gboolean to_name_matches;
849 their_name = buddy->alias; 849
850 850 if (buddy && buddy->alias)
851 /* Try to guess which user is me. 851 their_name = buddy->alias;
852 * The first step is to determine if either of the names matches either my 852
853 * friendly name or alias. For this test, "match" is defined as: 853 /* Try to guess which user is me.
854 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ 854 * The first step is to determine if either of the names matches either my
855 */ 855 * friendly name or alias. For this test, "match" is defined as:
856 from_name_matches = ((g_str_has_prefix( 856 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$
857 from_name, friendly_name) && 857 */
858 !isalnum(*(from_name + friendly_name_length))) || 858 from_name_matches = ((g_str_has_prefix(
859 (g_str_has_prefix(from_name, log->account->alias) && 859 from_name, friendly_name) &&
860 !isalnum(*(from_name + alias_length)))); 860 !isalnum(*(from_name + friendly_name_length))) ||
861 861 (g_str_has_prefix(from_name, log->account->alias) &&
862 to_name_matches = ((g_str_has_prefix( 862 !isalnum(*(from_name + alias_length))));
863 to_name, friendly_name) && 863
864 !isalnum(*(to_name + friendly_name_length))) || 864 to_name_matches = ((g_str_has_prefix(
865 (g_str_has_prefix(to_name, log->account->alias) && 865 to_name, friendly_name) &&
866 !isalnum(*(to_name + alias_length)))); 866 !isalnum(*(to_name + friendly_name_length))) ||
867 867 (g_str_has_prefix(to_name, log->account->alias) &&
868 if (from_name_matches) { 868 !isalnum(*(to_name + alias_length))));
869 if (!to_name_matches) { 869
870 name_guessed = NAME_GUESS_ME; 870 if (from_name_matches) {
871 } 871 if (!to_name_matches) {
872 } else if (to_name_matches) { 872 name_guessed = NAME_GUESS_ME;
873 name_guessed = NAME_GUESS_THEM; 873 }
874 } else { 874 } else if (to_name_matches) {
875 if (buddy) { 875 name_guessed = NAME_GUESS_THEM;
876 if (buddy->alias) { 876 } else {
877 if (buddy && buddy->alias) {
877 char *alias = g_strdup(buddy->alias); 878 char *alias = g_strdup(buddy->alias);
878 879
879 /* "Truncate" the string at the first non-alphanumeric 880 /* "Truncate" the string at the first non-alphanumeric
880 * character. The idea is to relax the comparison. 881 * character. The idea is to relax the comparison.
881 */ 882 */