Mercurial > pidgin
comparison src/conversation.c @ 6060:6b4a12cd4caf
[gaim-migrate @ 6510]
a better fix for things that don't set the display_name for a GaimConnection
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 08 Jul 2003 04:05:02 +0000 |
parents | 0bbe26d96e11 |
children | 5e5959d7a85e |
comparison
equal
deleted
inserted
replaced
6059:d8cd876e613e | 6060:6b4a12cd4caf |
---|---|
80 static gboolean | 80 static gboolean |
81 find_nick(GaimConnection *gc, const char *message) | 81 find_nick(GaimConnection *gc, const char *message) |
82 { | 82 { |
83 GaimAccount *account; | 83 GaimAccount *account; |
84 char *msg, *who, *p; | 84 char *msg, *who, *p; |
85 const char *disp; | |
85 int n; | 86 int n; |
86 | 87 |
87 account = gaim_connection_get_account(gc); | 88 account = gaim_connection_get_account(gc); |
88 | 89 |
89 msg = g_utf8_strdown(message, -1); | 90 msg = g_utf8_strdown(message, -1); |
100 } | 101 } |
101 } | 102 } |
102 | 103 |
103 g_free(who); | 104 g_free(who); |
104 | 105 |
105 if (!gaim_utf8_strcasecmp(gaim_account_get_username(account), | 106 disp = gaim_connection_get_display_name(gc); |
106 gaim_connection_get_display_name(gc))) { | 107 |
107 g_free(msg); | 108 |
108 | 109 if(disp) { |
109 return FALSE; | 110 if (!gaim_utf8_strcasecmp(gaim_account_get_username(account), disp)) { |
110 } | |
111 | |
112 who = g_utf8_strdown(gaim_connection_get_display_name(gc), -1); | |
113 n = who ? strlen(who) : 0; | |
114 | |
115 if (n > 0 && (p = strstr(msg, who)) != NULL) { | |
116 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) { | |
117 g_free(who); | |
118 g_free(msg); | 111 g_free(msg); |
119 | 112 |
120 return TRUE; | 113 return FALSE; |
121 } | 114 } |
122 } | 115 |
123 | 116 who = g_utf8_strdown(disp, -1); |
124 g_free(who); | 117 n = who ? strlen(who) : 0; |
118 | |
119 if (n > 0 && (p = strstr(msg, who)) != NULL) { | |
120 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) { | |
121 g_free(who); | |
122 g_free(msg); | |
123 | |
124 return TRUE; | |
125 } | |
126 } | |
127 | |
128 g_free(who); | |
129 } | |
130 | |
125 g_free(msg); | 131 g_free(msg); |
126 | 132 |
127 return FALSE; | 133 return FALSE; |
128 } | 134 } |
129 | 135 |
1853 if (gaim_chat_is_user_ignored(chat, who)) | 1859 if (gaim_chat_is_user_ignored(chat, who)) |
1854 return; | 1860 return; |
1855 | 1861 |
1856 if (!(flags & WFLAG_WHISPER)) { | 1862 if (!(flags & WFLAG_WHISPER)) { |
1857 char *str; | 1863 char *str; |
1864 const char *disp; | |
1858 | 1865 |
1859 str = g_strdup(normalize(who)); | 1866 str = g_strdup(normalize(who)); |
1867 disp = gaim_connection_get_display_name(gc); | |
1860 | 1868 |
1861 if (!gaim_utf8_strcasecmp(str, normalize(gaim_account_get_username(account))) || | 1869 if (!gaim_utf8_strcasecmp(str, normalize(gaim_account_get_username(account))) || |
1862 !gaim_utf8_strcasecmp(str, normalize(gaim_connection_get_display_name(gc)))) { | 1870 (disp && !gaim_utf8_strcasecmp(str, normalize(disp)))) { |
1863 | 1871 |
1864 flags |= WFLAG_SEND; | 1872 flags |= WFLAG_SEND; |
1865 } | 1873 } |
1866 else { | 1874 else { |
1867 flags |= WFLAG_RECV; | 1875 flags |= WFLAG_RECV; |
1868 | 1876 |
1869 if (find_nick(gc, message)) | 1877 if (find_nick(gc, message)) |
1870 flags |= WFLAG_NICK; | 1878 flags |= WFLAG_NICK; |
1871 } | 1879 } |
1872 | 1880 |
1873 g_free(str); | 1881 g_free(str); |
1874 } | 1882 } |
1875 | 1883 |
1876 /* Pass this on to either the ops structure or the default write func. */ | 1884 /* Pass this on to either the ops structure or the default write func. */ |
1877 if (conv->ui_ops != NULL && conv->ui_ops->write_chat != NULL) | 1885 if (conv->ui_ops != NULL && conv->ui_ops->write_chat != NULL) |