Mercurial > pidgin
changeset 23582:a270bd4b5298
Just a few little cleanups.
* I think we try to pair g_strdup() with g_free(). I don't know if
it actually matters, but theoretically it could.
* Changed this to use g_slist_prepend() when adding stuff to the queue.
* Changed purple_requesticqstatusnote() to check if the linked list is
empty and return TRUE as soon as the list becomes empty rather than
on the next call to that function.
* Don't remove and re-add the timer if it's already set. Unless there
was a reason for that?
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 21 Jul 2008 07:46:23 +0000 |
parents | 8c480872b620 |
children | dc359ea9eb9a |
files | libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h libpurple/protocols/oscar/oscar_data.c |
diffstat | 3 files changed, 35 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c Mon Jul 21 06:44:21 2008 +0000 +++ b/libpurple/protocols/oscar/oscar.c Mon Jul 21 07:46:23 2008 +0000 @@ -1901,12 +1901,6 @@ struct aim_ssi_item *ssi_item; aim_tlv_t *note_hash; - if (!od->statusnotes_queue) { - purple_debug_misc("oscar", "No more ICQ status notes to request"); - od->statusnotes_queue_timer = 0; - return FALSE; - } - sn = od->statusnotes_queue->data; ssi_item = aim_ssi_itemlist_finditem(od->ssi.local, @@ -1918,10 +1912,17 @@ aim_icq_getstatusnote(od, sn, note_hash->value, note_hash->length); } } - + od->statusnotes_queue = g_slist_remove(od->statusnotes_queue, sn); - free(sn); - + g_free(sn); + + if (od->statusnotes_queue == NULL) + { + purple_debug_misc("oscar", "No more ICQ status notes to request"); + od->statusnotes_queue_timer = 0; + return FALSE; + } + return TRUE; } @@ -2108,17 +2109,24 @@ { note_hash = aim_tlv_gettlv(ssi_item->data, 0x015c, 1); if (note_hash != NULL) { - /* We do automatic rate limiting, so a flood of requests would not disconnect us. - * However, they would mean that we had to wait a potentially long time to be able to message - * in real time again. Also, since we're requesting with every purple_parse_oncoming() call, - * which often come in groups, we should coalesce to do a single lookup. + /* We do automatic rate limiting at the FLAP level, so + * a flood of requests won't disconnect us. However, + * it WOULD mean that we would have to wait a + * potentially long time to be able to message in real + * time again. Also, since we're requesting with every + * purple_parse_oncoming() call, which often come in + * groups, we should coalesce to do only one lookup per + * buddy. */ - if (!od->statusnotes_queue || (g_slist_find_custom(od->statusnotes_queue, info->sn, (GCompareFunc)strcmp) == NULL)) { - od->statusnotes_queue = g_slist_append(od->statusnotes_queue, g_strdup(info->sn)); - - if (od->statusnotes_queue_timer) - purple_timeout_remove(od->statusnotes_queue_timer); - od->statusnotes_queue_timer = purple_timeout_add_seconds(2, purple_requesticqstatusnote, gc); + if (od->statusnotes_queue == NULL || + g_slist_find_custom(od->statusnotes_queue, info->sn, (GCompareFunc)strcmp) == NULL) + { + od->statusnotes_queue = g_slist_prepend(od->statusnotes_queue, + g_strdup(info->sn)); + + if (od->statusnotes_queue_timer == 0) + od->statusnotes_queue_timer = purple_timeout_add_seconds(2, + purple_requesticqstatusnote, gc); } } }
--- a/libpurple/protocols/oscar/oscar.h Mon Jul 21 06:44:21 2008 +0000 +++ b/libpurple/protocols/oscar/oscar.h Mon Jul 21 07:46:23 2008 +0000 @@ -544,10 +544,10 @@ /** A linked list containing PeerConnections. */ GSList *peer_connections; - + /** Queue of ICQ Status Notes to request. */ GSList *statusnotes_queue; - gint statusnotes_queue_timer; + guint statusnotes_queue_timer; }; /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
--- a/libpurple/protocols/oscar/oscar_data.c Mon Jul 21 06:44:21 2008 +0000 +++ b/libpurple/protocols/oscar/oscar_data.c Mon Jul 21 07:46:23 2008 +0000 @@ -88,17 +88,16 @@ while (od->requesticon) { - gchar *sn = od->requesticon->data; - od->requesticon = g_slist_remove(od->requesticon, sn); - g_free(sn); + g_free(od->requesticon->data); + od->requesticon = g_slist_delete_link(od->requesticon, od->requesticon); } while (od->statusnotes_queue) { - gchar *sn = od->statusnotes_queue->data; - od->statusnotes_queue = g_slist_remove(od->statusnotes_queue, sn); - g_free(sn); + g_free(od->statusnotes_queue->data); + od->statusnotes_queue = g_slist_delete_link(od->statusnotes_queue, + od->statusnotes_queue); } - if (od->statusnotes_queue_timer) + if (od->statusnotes_queue_timer > 0) purple_timeout_remove(od->statusnotes_queue_timer); g_free(od->email); g_free(od->newp);