diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-24 17:44:08 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-25 14:03:36 -0400 |
commit | 7e70516c3d70e547387daa45126449c518a5fcef (patch) | |
tree | eb4ee9a242535898fc0d6caa43372c4ed6d56e1a | |
parent | d4bd574125fc1c8ad9e3a75e656cf245ccc52769 (diff) |
TextChannel: sort missed pending by timestamp
It's better if missed pending message are stored ordered by date.
-rw-r--r-- | telepathy-logger/text-channel.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/telepathy-logger/text-channel.c b/telepathy-logger/text-channel.c index ca7b2c9..919c8f6 100644 --- a/telepathy-logger/text-channel.c +++ b/telepathy-logger/text-channel.c @@ -513,7 +513,8 @@ on_pending_message_removed_cb (TpTextChannel *self, static gint -pending_message_compare (TpSignalledMessage *m1, TpSignalledMessage *m2) +pending_message_compare_id (TpSignalledMessage *m1, + TpSignalledMessage *m2) { guint id1, id2; @@ -529,6 +530,24 @@ pending_message_compare (TpSignalledMessage *m1, TpSignalledMessage *m2) } +static gint +pending_message_compare_timestamp (TpSignalledMessage *m1, + TpSignalledMessage *m2) +{ + gint64 ts1, ts2; + + ts1 = get_message_timestamp (TP_MESSAGE (m1)); + ts2 = get_message_timestamp (TP_MESSAGE (m2)); + + if (ts1 > ts2) + return 1; + else if (ts1 < ts2) + return -1; + else + return 0; +} + + static void pendingproc_store_pending_messages (TplActionChain *ctx, gpointer user_data) @@ -557,7 +576,7 @@ pendingproc_store_pending_messages (TplActionChain *ctx, tp_text_channel_get_pending_messages (TP_TEXT_CHANNEL (self)); pending_messages = g_list_sort (pending_messages, - (GCompareFunc) pending_message_compare); + (GCompareFunc) pending_message_compare_id); cached_it = cached_messages; pending_it = pending_messages; @@ -642,6 +661,9 @@ pendingproc_store_pending_messages (TplActionChain *ctx, { GList *it; + to_log = g_list_sort (to_log, + (GCompareFunc) pending_message_compare_timestamp); + for (it = to_log; it != NULL; it = g_list_next (it)) on_message_received_cb (TP_TEXT_CHANNEL (self), TP_SIGNALLED_MESSAGE (it->data), self); |