pidgin: 99322199: Just a few little cleanups.
markdoliner at pidgin.im
markdoliner at pidgin.im
Mon Jul 21 03:50:53 EDT 2008
-----------------------------------------------------------------
Revision: 9932219978c2a9b1f5c6ebadd9986b0f30e4c8af
Ancestor: 95372365392625833d72f20ad2fabe542e1c9b17
Author: markdoliner at pidgin.im
Date: 2008-07-21T07:46:23
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9932219978c2a9b1f5c6ebadd9986b0f30e4c8af
Modified files:
libpurple/protocols/oscar/oscar.c
libpurple/protocols/oscar/oscar.h
libpurple/protocols/oscar/oscar_data.c
ChangeLog:
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?
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c 86e602ade22c718ed23452fde421fb71d7efb4f9
+++ libpurple/protocols/oscar/oscar.c 999a7e16eccbe7b4fc95d4697d8771cc165b8a6a
@@ -1901,12 +1901,6 @@ static gboolean purple_requesticqstatusn
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 @@ static gboolean purple_requesticqstatusn
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 @@ static int purple_parse_oncoming(OscarDa
{
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 == 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)
- purple_timeout_remove(od->statusnotes_queue_timer);
- od->statusnotes_queue_timer = purple_timeout_add_seconds(2, purple_requesticqstatusnote, gc);
+ if (od->statusnotes_queue_timer == 0)
+ od->statusnotes_queue_timer = purple_timeout_add_seconds(2,
+ purple_requesticqstatusnote, gc);
}
}
}
============================================================
--- libpurple/protocols/oscar/oscar.h 68359c084c30fe040938afe2c60fe62b569bd7ed
+++ libpurple/protocols/oscar/oscar.h 84a9834fe1f1d6ceb97b3a60f9840da96219704e
@@ -544,10 +544,10 @@ struct _OscarData
/** 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 */
============================================================
--- libpurple/protocols/oscar/oscar_data.c 83016ef790171eb6d56d1c6ed803ee38bde2c64e
+++ libpurple/protocols/oscar/oscar_data.c 60814ffef899c7c7e6dbeb041ced471c04fdeb6d
@@ -88,17 +88,16 @@ oscar_data_destroy(OscarData *od)
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);
More information about the Commits
mailing list