Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/roster.c @ 772:464be13343a9
Store most data in UTF-8 internally
Only chat buffer data is still using 1 byte for char size.
User input still doesn't handle UTF-8 locales.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 25 Mar 2006 18:10:36 +0100 |
parents | ee03b56b93ee |
children | 46304b773a44 |
comparison
equal
deleted
inserted
replaced
771:ce4f8a2129a4 | 772:464be13343a9 |
---|---|
21 | 21 |
22 #define _GNU_SOURCE /* for strcasestr() */ | 22 #define _GNU_SOURCE /* for strcasestr() */ |
23 #include <string.h> | 23 #include <string.h> |
24 | 24 |
25 #include "roster.h" | 25 #include "roster.h" |
26 #include "utils.h" | |
26 | 27 |
27 | 28 |
28 char *strrole[] = { /* Should match enum in roster.h */ | 29 char *strrole[] = { /* Should match enum in roster.h */ |
29 "none", | 30 "none", |
30 "moderator", | 31 "moderator", |
1121 { | 1122 { |
1122 GList *buddy = current_buddy; | 1123 GList *buddy = current_buddy; |
1123 roster *roster_usr; | 1124 roster *roster_usr; |
1124 if (!buddylist || !current_buddy) return NULL; | 1125 if (!buddylist || !current_buddy) return NULL; |
1125 for (;;) { | 1126 for (;;) { |
1127 gchar *jid_locale, *name_locale; | |
1128 char *found = NULL; | |
1129 | |
1126 buddy = g_list_next(buddy); | 1130 buddy = g_list_next(buddy); |
1127 if (!buddy) | 1131 if (!buddy) |
1128 buddy = buddylist; | 1132 buddy = buddylist; |
1129 | 1133 |
1130 roster_usr = (roster*)buddy->data; | 1134 roster_usr = (roster*)buddy->data; |
1131 if (roster_usr->jid && strcasestr(roster_usr->jid, string)) | 1135 |
1132 return buddy; | 1136 jid_locale = from_utf8(roster_usr->jid); |
1133 if (roster_usr->name && strcasestr(roster_usr->name, string)) | 1137 if (jid_locale) { |
1134 return buddy; | 1138 found = strcasestr(jid_locale, string); |
1139 g_free(jid_locale); | |
1140 if (found) | |
1141 return buddy; | |
1142 } | |
1143 name_locale = from_utf8(roster_usr->name); | |
1144 if (name_locale) { | |
1145 found = strcasestr(name_locale, string); | |
1146 g_free(name_locale); | |
1147 if (found) | |
1148 return buddy; | |
1149 } | |
1135 | 1150 |
1136 if (buddy == current_buddy) | 1151 if (buddy == current_buddy) |
1137 return NULL; // Back to the beginning, and no match found | 1152 return NULL; // Back to the beginning, and no match found |
1138 } | 1153 } |
1139 } | 1154 } |
1179 | 1194 |
1180 if (type == ROSTER_TYPE_GROUP) { // (group names) | 1195 if (type == ROSTER_TYPE_GROUP) { // (group names) |
1181 if (btype == ROSTER_TYPE_GROUP) { | 1196 if (btype == ROSTER_TYPE_GROUP) { |
1182 const char *bname = buddy_getname(BUDDATA(buddy)); | 1197 const char *bname = buddy_getname(BUDDATA(buddy)); |
1183 if ((bname) && (*bname)) | 1198 if ((bname) && (*bname)) |
1184 list = g_slist_append(list, g_strdup(bname)); | 1199 list = g_slist_append(list, from_utf8(bname)); |
1185 } | 1200 } |
1186 } else { // ROSTER_TYPE_USER (jid) (or agent, or chatroom...) | 1201 } else { // ROSTER_TYPE_USER (jid) (or agent, or chatroom...) |
1187 const char *bjid = buddy_getjid(BUDDATA(buddy)); | 1202 const char *bjid = buddy_getjid(BUDDATA(buddy)); |
1188 if (bjid) | 1203 if (bjid) |
1189 list = g_slist_append(list, g_strdup(bjid)); | 1204 list = g_slist_append(list, from_utf8(bjid)); |
1190 } | 1205 } |
1191 } | 1206 } |
1192 | 1207 |
1193 return list; | 1208 return list; |
1194 } | 1209 } |