diff options
author | Sébastien Bianti <sebastien.bianti@linux.intel.com> | 2012-04-27 17:47:04 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-04-29 13:30:09 +0200 |
commit | 10220492e55280694901dfe00027299e837c87f4 (patch) | |
tree | 71319eb03fcc71d6a93a603fab2ee1c3c39f3723 | |
parent | 93c290eac59aac8a5ab23c18a0285b4b39e8033f (diff) | |
download | mmsd-10220492e55280694901dfe00027299e837c87f4.tar.gz |
service: emit signal when send has failed
Event if status doesn't really change, we need to alert the application
by sending the same value "draft" which means the message hasn't been received.
-rw-r--r-- | src/service.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/service.c b/src/service.c index d560476..689a4e1 100644 --- a/src/service.c +++ b/src/service.c @@ -596,16 +596,23 @@ static gboolean result_request_send_conf(struct mms_request *request) size_t len; char *path; - if (request->status != 200) + if (request->msg == NULL) return FALSE; + uuid = request->msg->uuid; + + path = g_strdup_printf("%s/%s/%s", MMS_PATH, service->identity, uuid); + + if (request->status != 200) + goto error; + msg = g_try_new0(struct mms_message, 1); if (msg == NULL) - return FALSE; + goto error; if (mmap_file(request->data_path, &pdu, &len) == FALSE) { mms_message_free(msg); - return FALSE; + goto error; } if (mms_message_decode(pdu, len, msg) == FALSE) { @@ -615,7 +622,7 @@ static gboolean result_request_send_conf(struct mms_request *request) mms_message_free(msg); - return FALSE; + goto error; } mms_debug("response status : %d", msg->sc.rsp_status); @@ -626,26 +633,27 @@ static gboolean result_request_send_conf(struct mms_request *request) unlink(request->data_path); - if (request->msg == NULL) - return FALSE; - - uuid = request->msg->uuid; - meta = mms_store_meta_open(service->identity, uuid); if (meta == NULL) - return FALSE; + goto error; g_key_file_set_string(meta, "info", "state", "sent"); mms_store_meta_close(service->identity, uuid, meta, TRUE); - path = g_strdup_printf("%s/%s/%s", MMS_PATH, service->identity, uuid); - emit_msg_status_changed(path, "sent"); g_free(path); return TRUE; + +error: + if (request->attempt == MAX_ATTEMPTS) + emit_msg_status_changed(path, "draft"); + + g_free(path); + + return FALSE; } static void append_message(const char *path, const struct mms_service *service, |