From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 09/12] service: Process delivery_ind notification
Date: Tue, 28 Aug 2012 09:26:50 -0500 [thread overview]
Message-ID: <503CD52A.7090002@gmail.com> (raw)
In-Reply-To: <1345813571-15775-10-git-send-email-ronald.tessier@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4290 bytes --]
Hi Ronald,
On 08/24/2012 08:06 AM, Ronald Tessier wrote:
> ---
> src/service.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 107 insertions(+), 4 deletions(-)
>
> diff --git a/src/service.c b/src/service.c
> index b3ecc1e..44184cb 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -1300,6 +1300,104 @@ static void emit_service_removed(struct mms_service *service)
> &service->path, DBUS_TYPE_INVALID);
> }
>
> +static gboolean get_meta_by_msgid(struct mms_service *service,
> + const char *msgid,
> + char *uuid)
> +{
> + GDir *dir;
> + GKeyFile *meta;
> + const char *file;
> + const char *homedir;
> + const char *service_id;
> + char *service_path;
> +
> + homedir = g_get_home_dir();
> + if (homedir == NULL)
> + return FALSE;
> +
> + service_id = service->identity;
> +
> + service_path = g_strdup_printf("%s/.mms/%s/", homedir, service_id);
> +
> + dir = g_dir_open(service_path, 0, NULL);
> + g_free(service_path);
> + if (dir == NULL)
> + return FALSE;
> +
> + while ((file = g_dir_read_name(dir)) != NULL) {
> + char *id;
> +
> + if (g_str_has_suffix(file, MMS_META_UUID_SUFFIX) == FALSE)
> + continue;
> +
> + if (strlen(file) != MMS_META_UUID_LEN +
> + MMS_META_UUID_SUFFIX_LEN)
> + continue;
> +
> + strncpy(uuid, file, MMS_META_UUID_LEN);
> + uuid[MMS_META_UUID_LEN] = 0;
> +
> + meta = mms_store_meta_open(service_id, uuid);
> + if (meta == NULL)
> + goto bail;
> +
> + id = g_key_file_get_string(meta, "info", "id", NULL);
> + if (id == NULL) {
> + mms_store_meta_close(service_id, uuid, meta, FALSE);
> + continue;
> + }
> +
> + if (g_strcmp0(msgid, id) == 0) {
> + mms_store_meta_close(service_id, uuid, meta, FALSE);
> + g_dir_close(dir);
> + return TRUE;
> + }
> +
> + mms_store_meta_close(service_id, uuid, meta, FALSE);
> + }
> +
> +bail:
> + g_dir_close(dir);
> +
> + return FALSE;
> +}
> +
> +static void process_delivery_ind_notification(struct mms_service *service,
> + struct mms_message *di_msg)
> +{
> + GKeyFile *meta;
> + char uuid[MMS_META_UUID_LEN + 1];
> + char *path;
> + char *to;
> +
> + if (get_meta_by_msgid(service, di_msg->di.msgid, uuid) == FALSE)
> + goto bail;
> +
> + meta = mms_store_meta_open(service->identity, uuid);
> + if (meta == NULL)
> + return;
> +
> + to = g_strdup(di_msg->di.to);
> +
> + mms_address_to_string(to);
> +
> + g_key_file_set_string(meta, "delivery_status", to,
> + delivery_status[di_msg->di.dr_status - 127]);
> +
> + g_free(to);
> +
> + mms_store_meta_close(service->identity, uuid, meta, TRUE);
> +
> + path = g_strdup_printf("%s/%s/%s", MMS_PATH, service->identity, uuid);
> +
> + g_free(path);
> +
> +bail:
> + mms_store_remove(service->identity, di_msg->uuid);
> +
> + mms_message_free(di_msg);
> +}
> +
> static gboolean load_message_from_store(const char *service_id,
> const char *uuid, struct mms_message *msg)
> {
> @@ -1485,6 +1583,7 @@ register_sr:
> }
> } else if (msg->type == MMS_MESSAGE_TYPE_DELIVERY_IND) {
> request = NULL;
> + process_delivery_ind_notification(service, msg);
> } else
> request = NULL;
>
> @@ -1514,15 +1613,17 @@ static void load_messages(struct mms_service *service)
> return;
>
> while ((file = g_dir_read_name(dir)) != NULL) {
> - const size_t suffix_len = 7;
> char *uuid;
> + size_t uuid_len;
>
> - if (g_str_has_suffix(file, ".status") == FALSE)
> + if (g_str_has_suffix(file, MMS_META_UUID_SUFFIX) == FALSE)
> continue;
> - if (strlen(file) - suffix_len == 0)
> +
> + uuid_len = strlen(file) - MMS_META_UUID_SUFFIX_LEN;
> + if (uuid_len == 0)
> continue;
>
> - uuid = g_strndup(file, strlen(file) - suffix_len);
> + uuid = g_strndup(file, uuid_len);
>
> process_message_on_start(service, uuid);
>
This chunk should really be in a separate patch since it is related to
the previous one.
> @@ -2401,6 +2502,8 @@ void mms_service_push_notify(struct mms_service *service,
>
> mms_store_meta_close(service->identity, uuid, meta, TRUE);
>
> + process_delivery_ind_notification(service, msg);
> +
> return;
> }
>
Regards,
-Denis
next prev parent reply other threads:[~2012-08-28 14:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 13:05 [PATCH 00/12] mmsd: (resending) Support Delivery Report notification Ronald Tessier
2012-08-24 13:06 ` [PATCH 01/12] mmsutil: Define mms_delivery_ind struct Ronald Tessier
2012-08-28 13:41 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 02/12] mmsutil: Decode delivery_ind msg Ronald Tessier
2012-08-28 13:41 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 03/12] service: Store msg_id provided by M-Send.conf PDU Ronald Tessier
2012-08-28 13:45 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 04/12] service: Move mms_address_to_string() up Ronald Tessier
2012-08-28 13:46 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 05/12] service: Add a group [delivery_status] in the msg status Ronald Tessier
2012-08-28 13:50 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 06/12] service: Support M-Delivery.ind in mms_service_push_notify() Ronald Tessier
2012-08-28 13:50 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 07/12] service: Support delivery_ind notif on start Ronald Tessier
2012-08-28 14:25 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 08/12] store: Define MMS_META_UUID_XXX len and suffix Ronald Tessier
2012-08-28 14:25 ` Denis Kenzior
2012-08-24 13:06 ` [PATCH 09/12] service: Process delivery_ind notification Ronald Tessier
2012-08-28 14:26 ` Denis Kenzior [this message]
2012-08-24 13:06 ` [PATCH 10/12] service: Send a delivery changed signal Ronald Tessier
2012-08-24 13:06 ` [PATCH 11/12] test: Add ReportChanged to monitored signals Ronald Tessier
2012-08-24 13:06 ` [PATCH 12/12] doc: Add ReportChanged signal description Ronald Tessier
2012-08-28 14:29 ` Denis Kenzior
2012-09-04 15:26 ` Ronald Tessier
2012-09-04 19:20 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2012-08-17 14:35 [PATCH 00/12] mmsd: Support Delivery Report notification Ronald Tessier
2012-08-17 14:35 ` [PATCH 09/12] service: Process delivery_ind notification 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=503CD52A.7090002@gmail.com \
--to=denkenz@gmail.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