From: Ronald Tessier <ronald.tessier@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCHv1 4/5] service: Sort conversation list by message date
Date: Wed, 25 Apr 2012 11:01:52 +0200 [thread overview]
Message-ID: <1335344513-2347-5-git-send-email-ronald.tessier@linux.intel.com> (raw)
In-Reply-To: <1335344513-2347-1-git-send-email-ronald.tessier@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1215 bytes --]
---
src/service.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/service.c b/src/service.c
index 2787c3a..1bd4671 100644
--- a/src/service.c
+++ b/src/service.c
@@ -719,6 +719,31 @@ static gboolean get_conversation_get_args(DBusMessage *dbus_msg,
return TRUE;
}
+static gint fill_conversation_sort(gconstpointer a, gconstpointer b)
+{
+ const struct mms_message *msg1 = a;
+ const struct mms_message *msg2 = b;
+ time_t date1, date2;
+
+ if (msg1->type == MMS_MESSAGE_TYPE_SEND_REQ)
+ date1 = msg1->sr.date;
+ else
+ date1 = msg1->rc.date;
+
+ if (msg2->type == MMS_MESSAGE_TYPE_SEND_REQ)
+ date2 = msg2->sr.date;
+ else
+ date2 = msg2->rc.date;
+
+ if (date1 > date2)
+ return 1;
+
+ if (date1 < date2)
+ return -1;
+
+ return 0;
+}
+
static gboolean is_recipient(const char *recipients, const char *number)
{
const char *rec, *num;
@@ -784,6 +809,8 @@ static GList *fill_conversation(const struct mms_service *service,
conversation = g_list_prepend(conversation, value);
}
+ conversation = g_list_sort(conversation, fill_conversation_sort);
+
return conversation;
}
--
1.7.4.1
next prev parent reply other threads:[~2012-04-25 9:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 9:01 [PATCHv1 0/5] mmsd: GetConversation support Ronald Tessier
2012-04-25 9:01 ` [PATCHv1 1/5] service: Add GetConversation method Ronald Tessier
2012-04-27 12:26 ` Marcel Holtmann
2012-04-25 9:01 ` [PATCHv1 2/5] service: Retrieve get_conversation() args Ronald Tessier
2012-04-27 12:25 ` Marcel Holtmann
2012-04-25 9:01 ` [PATCHv1 3/5] service: Fill conversation list with messages Ronald Tessier
2012-04-27 12:25 ` Marcel Holtmann
2012-04-25 9:01 ` Ronald Tessier [this message]
2012-04-27 12:23 ` [PATCHv1 4/5] service: Sort conversation list by message date Marcel Holtmann
2012-04-25 9:01 ` [PATCHv1 5/5] doc: Update service-api.txt Ronald Tessier
2012-04-27 12:20 ` Marcel Holtmann
2012-04-27 13:30 ` Ronald Tessier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335344513-2347-5-git-send-email-ronald.tessier@linux.intel.com \
--to=ronald.tessier@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox