Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/buddy_list.c @ 23054:ebad75b719f5
Sun Jun 29 22:00:12 CST 2008 csyfek@gmail.com
* 20080629-fixed-qun-processing
Merged patches from moo, ccpaging and coly
Tickets:
References #6199
Sat Jun 28 13:25:40 CST 2008 csyfek@gmail.com
* 20080628-get-friends
Patches from moo and ccpaging.
Tickets:
Fixes #4956.
Fixes #2998.
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 29 Jun 2008 14:24:21 +0000 |
parents | 55f986ccbb6a |
children | bdb38a8bf721 |
comparison
equal
deleted
inserted
replaced
23053:55f986ccbb6a | 23054:ebad75b719f5 |
---|---|
145 /* process the reply packet for get_buddies_online packet */ | 145 /* process the reply packet for get_buddies_online packet */ |
146 void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) | 146 void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) |
147 { | 147 { |
148 qq_data *qd; | 148 qq_data *qd; |
149 gint len, bytes, bytes_buddy; | 149 gint len, bytes, bytes_buddy; |
150 gint count; | |
150 guint8 *data, position; | 151 guint8 *data, position; |
151 PurpleBuddy *b; | 152 PurpleBuddy *b; |
152 qq_buddy *q_bud; | 153 qq_buddy *q_bud; |
153 qq_friends_online_entry *fe; | 154 qq_friends_online_entry *fe; |
154 | 155 |
171 bytes += qq_get8(&position, data + bytes); | 172 bytes += qq_get8(&position, data + bytes); |
172 | 173 |
173 fe = g_newa(qq_friends_online_entry, 1); | 174 fe = g_newa(qq_friends_online_entry, 1); |
174 fe->s = g_newa(qq_buddy_status, 1); | 175 fe->s = g_newa(qq_buddy_status, 1); |
175 | 176 |
177 count = 0; | |
176 while (bytes < len) { | 178 while (bytes < len) { |
177 /* set flag */ | 179 /* set flag */ |
178 bytes_buddy = bytes; | 180 bytes_buddy = bytes; |
179 /* based on one online buddy entry */ | 181 /* based on one online buddy entry */ |
180 /* ATTTENTION! NEWED in the sub function, but FREED here */ | 182 /* ATTTENTION! NEWED in the sub function, but FREED here */ |
215 q_bud->port = fe->s->port; | 217 q_bud->port = fe->s->port; |
216 q_bud->status = fe->s->status; | 218 q_bud->status = fe->s->status; |
217 q_bud->flag1 = fe->flag1; | 219 q_bud->flag1 = fe->flag1; |
218 q_bud->comm_flag = fe->comm_flag; | 220 q_bud->comm_flag = fe->comm_flag; |
219 qq_update_buddy_contact(gc, q_bud); | 221 qq_update_buddy_contact(gc, q_bud); |
222 count++; | |
220 } else { | 223 } else { |
221 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 224 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
222 "Got an online buddy %d, but not in my buddy list\n", fe->s->uid); | 225 "Got an online buddy %d, but not in my buddy list\n", fe->s->uid); |
223 } | 226 } |
224 | 227 |
230 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 233 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
231 "qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!\n"); | 234 "qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!\n"); |
232 } | 235 } |
233 | 236 |
234 if (position != QQ_FRIENDS_ONLINE_POSITION_END) { | 237 if (position != QQ_FRIENDS_ONLINE_POSITION_END) { |
235 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Has more online buddies, position from %d\n", position); | 238 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d online buddies, nextposition=%u\n", |
236 | 239 count, (guint) position); |
240 if (position != QQ_FRIENDS_ONLINE_POSITION_START) { | |
241 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more online buddies\n"); | |
242 } | |
237 qq_send_packet_get_buddies_online(gc, position); | 243 qq_send_packet_get_buddies_online(gc, position); |
238 } else { | 244 } else { |
245 purple_debug(PURPLE_DEBUG_INFO, "QQ", "All online buddies received\n"); | |
239 qq_send_packet_get_buddies_levels(gc); | 246 qq_send_packet_get_buddies_levels(gc); |
240 qq_refresh_all_buddy_status(gc); | 247 qq_refresh_all_buddy_status(gc); |
241 } | 248 } |
242 } | 249 } |
243 | 250 |
245 /* process reply for get_buddies_list */ | 252 /* process reply for get_buddies_list */ |
246 void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) | 253 void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) |
247 { | 254 { |
248 qq_data *qd; | 255 qq_data *qd; |
249 qq_buddy *q_bud; | 256 qq_buddy *q_bud; |
250 gint len, bytes_expected, i; | 257 gint len, bytes_expected, count; |
251 gint bytes, buddy_bytes; | 258 gint bytes, buddy_bytes; |
252 guint16 position, unknown; | 259 guint16 position, unknown; |
253 guint8 *data, pascal_len; | 260 guint8 *data, pascal_len; |
254 gchar *name; | 261 gchar *name; |
255 PurpleBuddy *b; | 262 PurpleBuddy *b; |
265 return; | 272 return; |
266 } | 273 } |
267 bytes = 0; | 274 bytes = 0; |
268 bytes += qq_get16(&position, data + bytes); | 275 bytes += qq_get16(&position, data + bytes); |
269 /* the following data is buddy list in this packet */ | 276 /* the following data is buddy list in this packet */ |
270 i = 0; | 277 count = 0; |
271 while (bytes < len) { | 278 while (bytes < len) { |
272 q_bud = g_new0(qq_buddy, 1); | 279 q_bud = g_new0(qq_buddy, 1); |
273 /* set flag */ | 280 /* set flag */ |
274 buddy_bytes = bytes; | 281 buddy_bytes = bytes; |
275 /* 000-003: uid */ | 282 /* 000-003: uid */ |
304 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); | 311 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); |
305 g_free(q_bud->nickname); | 312 g_free(q_bud->nickname); |
306 g_free(q_bud); | 313 g_free(q_bud); |
307 continue; | 314 continue; |
308 } else { | 315 } else { |
309 i++; | 316 count++; |
310 } | 317 } |
311 | 318 |
312 if (QQ_DEBUG) { | 319 if (QQ_DEBUG) { |
313 purple_debug(PURPLE_DEBUG_INFO, "QQ", | 320 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
314 "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x\n", | 321 "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x\n", |
330 | 337 |
331 if(bytes > len) { | 338 if(bytes > len) { |
332 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 339 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
333 "qq_process_get_buddies_list_reply: Dangerous error! maybe protocol changed, notify developers!"); | 340 "qq_process_get_buddies_list_reply: Dangerous error! maybe protocol changed, notify developers!"); |
334 } | 341 } |
335 if (position == QQ_FRIENDS_LIST_POSITION_END) { | 342 |
336 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Get friends list done, %d buddies\n", i); | 343 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d buddies, nextposition=%u\n", |
337 qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); | 344 count, (guint) position); |
345 if (position != QQ_FRIENDS_LIST_POSITION_START | |
346 && position != QQ_FRIENDS_LIST_POSITION_END) { | |
347 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more buddies\n"); | |
348 qq_send_packet_get_buddies_list(gc, position); | |
338 } else { | 349 } else { |
339 qq_send_packet_get_buddies_list(gc, position); | 350 purple_debug(PURPLE_DEBUG_INFO, "QQ", "All buddies received. Requesting for online buddies list\n"); |
351 qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_LIST_POSITION_START); | |
340 } | 352 } |
341 } | 353 } |
342 | 354 |
343 void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) | 355 void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) |
344 { | 356 { |
417 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 429 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
418 "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocol changed, notify developers!"); | 430 "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocol changed, notify developers!"); |
419 } | 431 } |
420 | 432 |
421 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); | 433 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); |
422 } | 434 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d buddies and %d groups, nextposition=%u\n", i, j, (guint) position); |
435 if (position != QQ_FRIENDS_ALL_LIST_POSITION_START && position != QQ_FRIENDS_ALL_LIST_POSITION_START) { | |
436 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more buddies and groups\n"); | |
437 qq_send_packet_get_all_list_with_group(gc, position); | |
438 } else { | |
439 purple_debug(PURPLE_DEBUG_INFO, "QQ", "All buddies and groups received\n"); | |
440 } | |
441 } |