Mercurial > pidgin.yaz
comparison libpurple/protocols/gg/buddylist.c @ 20758:398bfc680c63
gg: Properly handle CP1250 chars in group's name when importing buddylist.
author | Bartoz Oler <bartosz@pidgin.im> |
---|---|
date | Tue, 02 Oct 2007 21:47:50 +0000 |
parents | 44b4e8bd759b |
children | 16734635febf 0b2a1b6f7464 4d20fa86455b |
comparison
equal
deleted
inserted
replaced
20757:9c226e074462 | 20758:398bfc680c63 |
---|---|
25 | 25 |
26 #include "gg.h" | 26 #include "gg.h" |
27 #include "gg-utils.h" | 27 #include "gg-utils.h" |
28 #include "buddylist.h" | 28 #include "buddylist.h" |
29 | 29 |
30 #define F_FIRSTNAME 0 | |
31 #define F_LASTNAME 1 | |
32 /* #define F_ 2 */ | |
33 #define F_NICKNAME 3 | |
34 #define F_PHONE 4 | |
35 #define F_GROUP 5 | |
36 #define F_UIN 6 | |
30 | 37 |
31 /* void ggp_buddylist_send(PurpleConnection *gc) {{{ */ | 38 /* void ggp_buddylist_send(PurpleConnection *gc) {{{ */ |
32 void ggp_buddylist_send(PurpleConnection *gc) | 39 void ggp_buddylist_send(PurpleConnection *gc) |
33 { | 40 { |
34 GGPInfo *info = gc->proto_data; | 41 GGPInfo *info = gc->proto_data; |
88 PurpleBuddy *buddy; | 95 PurpleBuddy *buddy; |
89 PurpleGroup *group; | 96 PurpleGroup *group; |
90 gchar **users_tbl; | 97 gchar **users_tbl; |
91 int i; | 98 int i; |
92 | 99 |
93 /* Don't limit a number of records in a buddylist. */ | 100 /* Don't limit the number of records in a buddylist. */ |
94 users_tbl = g_strsplit(buddylist, "\r\n", -1); | 101 users_tbl = g_strsplit(buddylist, "\r\n", -1); |
95 | 102 |
96 for (i = 0; users_tbl[i] != NULL; i++) { | 103 for (i = 0; users_tbl[i] != NULL; i++) { |
97 gchar **data_tbl; | 104 gchar **data_tbl; |
98 gchar *name, *show, *g; | 105 gchar *name, *show, *g; |
106 "Something is wrong on line %d of the buddylist. Skipping.\n", | 113 "Something is wrong on line %d of the buddylist. Skipping.\n", |
107 i + 1); | 114 i + 1); |
108 continue; | 115 continue; |
109 } | 116 } |
110 | 117 |
111 show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); | 118 show = charset_convert(data_tbl[F_NICKNAME], "CP1250", "UTF-8"); |
112 name = data_tbl[6]; | 119 name = data_tbl[F_UIN]; |
113 if ('\0' == *name) { | 120 if ('\0' == *name) { |
114 purple_debug_warning("gg", | 121 purple_debug_warning("gg", |
115 "Something is wrong on line %d of the buddylist. Skipping.\n", | 122 "Something is wrong on line %d of the buddylist. Skipping.\n", |
116 i + 1); | 123 i + 1); |
117 continue; | 124 continue; |
119 | 126 |
120 if ('\0' == *show) { | 127 if ('\0' == *show) { |
121 show = g_strdup(name); | 128 show = g_strdup(name); |
122 } | 129 } |
123 | 130 |
124 purple_debug_info("gg", "got buddy: name=%s show=%s\n", name, show); | 131 purple_debug_info("gg", "got buddy: name=%s; show=%s\n", name, show); |
125 | 132 |
126 if (purple_find_buddy(purple_connection_get_account(gc), name)) { | 133 if (purple_find_buddy(purple_connection_get_account(gc), name)) { |
127 g_free(show); | 134 g_free(show); |
128 g_strfreev(data_tbl); | 135 g_strfreev(data_tbl); |
129 continue; | 136 continue; |
130 } | 137 } |
131 | 138 |
132 g = g_strdup("Gadu-Gadu"); | 139 g = g_strdup("Gadu-Gadu"); |
133 | 140 |
134 if ('\0' != data_tbl[5]) { | 141 if ('\0' != data_tbl[F_GROUP]) { |
135 /* XXX: Probably buddy should be added to all the groups. */ | 142 /* XXX: Probably buddy should be added to all the groups. */ |
136 /* Hard limit to at most 50 groups */ | 143 /* Hard limit to at most 50 groups */ |
137 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 50); | 144 gchar **group_tbl = g_strsplit(data_tbl[F_GROUP], ",", 50); |
138 if (ggp_array_size(group_tbl) > 0) { | 145 if (ggp_array_size(group_tbl) > 0) { |
139 g_free(g); | 146 g_free(g); |
140 g = g_strdup(group_tbl[0]); | 147 g = charset_convert(group_tbl[0], "CP1250", "UTF-8"); |
141 } | 148 } |
142 g_strfreev(group_tbl); | 149 g_strfreev(group_tbl); |
143 } | 150 } |
144 | 151 |
145 buddy = purple_buddy_new(purple_connection_get_account(gc), name, | 152 buddy = purple_buddy_new(purple_connection_get_account(gc), name, |
146 strlen(show) ? show : NULL); | 153 strlen(show) ? show : NULL); |
147 | 154 |
148 if (!(group = purple_find_group(g))) { | 155 if (!(group = purple_find_group(g))) { |
149 group = purple_group_new(g); | 156 group = purple_group_new(g); |
150 purple_blist_add_group(group, NULL); | 157 purple_blist_add_group(group, NULL); |
151 } | 158 } |
157 g_strfreev(data_tbl); | 164 g_strfreev(data_tbl); |
158 } | 165 } |
159 g_strfreev(users_tbl); | 166 g_strfreev(users_tbl); |
160 | 167 |
161 ggp_buddylist_send(gc); | 168 ggp_buddylist_send(gc); |
162 | |
163 } | 169 } |
164 /* }}} */ | 170 /* }}} */ |
165 | 171 |
166 /* void ggp_buddylist_offline(PurpleConnection *gc) {{{ */ | 172 /* void ggp_buddylist_offline(PurpleConnection *gc) {{{ */ |
167 void ggp_buddylist_offline(PurpleConnection *gc) | 173 void ggp_buddylist_offline(PurpleConnection *gc) |
190 | 196 |
191 if (buddy->account != account) | 197 if (buddy->account != account) |
192 continue; | 198 continue; |
193 | 199 |
194 purple_prpl_got_user_status( | 200 purple_prpl_got_user_status( |
195 purple_connection_get_account(gc), | 201 account, buddy->name, "offline", NULL); |
196 buddy->name, "offline", NULL); | |
197 | 202 |
198 purple_debug_info("gg", | 203 purple_debug_info("gg", |
199 "ggp_buddylist_offline: gone: %s\n", | 204 "ggp_buddylist_offline: gone: %s\n", |
200 buddy->name); | 205 buddy->name); |
201 } | 206 } |