From: Ronald Tessier <ronald.tessier@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCHv2 3/6] service: Process delivery_ind notification
Date: Wed, 12 Sep 2012 15:55:10 +0200 [thread overview]
Message-ID: <1347458113-29039-4-git-send-email-ronald.tessier@linux.intel.com> (raw)
In-Reply-To: <1347458113-29039-1-git-send-email-ronald.tessier@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3159 bytes --]
---
src/service.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
diff --git a/src/service.c b/src/service.c
index ab88370..e867aa1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1300,6 +1300,107 @@ 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);
+
+ mms_store_meta_close(service_id, uuid, meta, FALSE);
+
+ if (id == NULL)
+ continue;
+
+ if (g_strcmp0(msgid, id) == 0) {
+ g_free(id);
+ g_dir_close(dir);
+ return TRUE;
+ }
+
+ g_free(id);
+ }
+
+bail:
+ g_dir_close(dir);
+
+ mms_error("Report received with unmatched message id <%s>", msgid);
+
+ 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 exit;
+
+ 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);
+
+exit:
+ 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 +1586,7 @@ register_sr:
}
} else if (msg->type == MMS_MESSAGE_TYPE_DELIVERY_IND) {
request = NULL;
+ process_delivery_ind_notification(service, msg);
} else
request = NULL;
@@ -2403,6 +2505,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;
}
--
1.7.9.5
next prev parent reply other threads:[~2012-09-12 13:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 13:55 [PATCHv2 0/6] mmsd: support delivery_ind notification Ronald Tessier
2012-09-12 13:55 ` [PATCHv2 1/6] service: Use MMS_META_UUID_SUFFIX Ronald Tessier
2012-09-12 13:55 ` [PATCHv2 2/6] mmsutil: Decode delivery_ind msg Ronald Tessier
2012-09-12 13:55 ` Ronald Tessier [this message]
2012-09-12 13:55 ` [PATCHv2 4/6] doc: Add ReportChanged signal description Ronald Tessier
2012-09-12 13:55 ` [PATCHv2 5/6] test: Add ReportChanged to monitored signals Ronald Tessier
2012-09-12 13:55 ` [PATCHv2 6/6] service: Send a delivery changed signal 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=1347458113-29039-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.