Mercurial > hg
comparison mcabber/src/roster.c @ 147:7571de4aed73
[/trunk] Changeset 159 by mikael
* Fix a bug in buddylist_build()
* We now lock the current buddy even not when being in chat mode.
For example, if we're writing to s.o. and he leaves just before
we press enter, we won't write to the wrong buddy...
If the current_buddy is a group, we lock it too.
* Remove MCABBER_TESTUNIT ifdef in roster.h (test program isn't
up-to-date anymore...)
author | mikael |
---|---|
date | Fri, 29 Apr 2005 19:56:28 +0000 |
parents | 6533a231a65e |
children | c3624b2a7059 |
comparison
equal
deleted
inserted
replaced
146:50f23c38743a | 147:7571de4aed73 |
---|---|
303 void buddylist_build(void) | 303 void buddylist_build(void) |
304 { | 304 { |
305 GSList *sl_roster_elt = groups; | 305 GSList *sl_roster_elt = groups; |
306 roster *roster_elt; | 306 roster *roster_elt; |
307 roster *roster_current_buddy = NULL; | 307 roster *roster_current_buddy = NULL; |
308 int pending_group; | |
309 int shrunk_group; | 308 int shrunk_group; |
310 | 309 |
311 // We need to remember which buddy is selected. | 310 // We need to remember which buddy is selected. |
312 if (current_buddy) | 311 if (current_buddy) |
313 roster_current_buddy = BUDDATA(current_buddy); | 312 roster_current_buddy = BUDDATA(current_buddy); |
321 | 320 |
322 // Create the new list | 321 // Create the new list |
323 while (sl_roster_elt) { | 322 while (sl_roster_elt) { |
324 GSList *sl_roster_usrelt; | 323 GSList *sl_roster_usrelt; |
325 roster *roster_usrelt; | 324 roster *roster_usrelt; |
325 guint pending_group = FALSE; | |
326 roster_elt = (roster*) sl_roster_elt->data; | 326 roster_elt = (roster*) sl_roster_elt->data; |
327 | 327 |
328 // Add the group now unless hide_offline_buddies is set, | 328 // Add the group now unless hide_offline_buddies is set, |
329 // in which case we'll add it only if an online buddy belongs to it. | 329 // in which case we'll add it only if an online buddy belongs to it. |
330 if (!hide_offline_buddies) | 330 // We take care to keep the current_buddy in the list, too. |
331 if (!hide_offline_buddies || roster_elt == roster_current_buddy) | |
331 buddylist = g_list_append(buddylist, roster_elt); | 332 buddylist = g_list_append(buddylist, roster_elt); |
332 else | 333 else |
333 pending_group = TRUE; | 334 pending_group = TRUE; |
334 | 335 |
335 shrunk_group = roster_elt->flags & ROSTER_FLAG_HIDE; | 336 shrunk_group = roster_elt->flags & ROSTER_FLAG_HIDE; |
336 | 337 |
337 sl_roster_usrelt = roster_elt->list; | 338 sl_roster_usrelt = roster_elt->list; |
338 while (sl_roster_usrelt) { | 339 while (sl_roster_usrelt) { |
342 // - hide_offline_buddies is FALSE | 343 // - hide_offline_buddies is FALSE |
343 // - buddy is not offline | 344 // - buddy is not offline |
344 // - buddy has a lock (for example the buddy window is currently open) | 345 // - buddy has a lock (for example the buddy window is currently open) |
345 // - buddy has a pending (non-read) message | 346 // - buddy has a pending (non-read) message |
346 // - group isn't hidden (shrunk) | 347 // - group isn't hidden (shrunk) |
347 if (!hide_offline_buddies || | 348 // - this is the current_buddy |
349 if (!hide_offline_buddies || roster_usrelt == roster_current_buddy || | |
348 (buddy_getstatus((gpointer)roster_usrelt) != offline) || | 350 (buddy_getstatus((gpointer)roster_usrelt) != offline) || |
349 (buddy_getflags((gpointer)roster_usrelt) & | 351 (buddy_getflags((gpointer)roster_usrelt) & |
350 (ROSTER_FLAG_LOCK | ROSTER_FLAG_MSG))) { | 352 (ROSTER_FLAG_LOCK | ROSTER_FLAG_MSG))) { |
351 // This user should be added. Maybe the group hasn't been added yet? | 353 // This user should be added. Maybe the group hasn't been added yet? |
352 if (hide_offline_buddies && pending_group) { | 354 if (pending_group && |
355 (hide_offline_buddies || roster_usrelt == roster_current_buddy)) { | |
353 // It hasn't been done yet | 356 // It hasn't been done yet |
354 buddylist = g_list_append(buddylist, roster_elt); | 357 buddylist = g_list_append(buddylist, roster_elt); |
355 pending_group = FALSE; | 358 pending_group = FALSE; |
356 } | 359 } |
357 // Add user | 360 // Add user |