From: Chris Talbot <chris@talbothome.com> To: ofono@ofono.org, netdev@vger.kernel.org, debian-on-mobile-maintainers@alioth-lists.debian.net, librem-5-dev@lists.community.puri.sm Subject: [PATCH 7/9] Fix Draft and Sent Bugs Date: Sat, 10 Apr 2021 10:23:12 -0400 [thread overview] Message-ID: <9f9d0f40db75ff82a306af14e7879e567dce9821.camel@talbothome.com> (raw) In-Reply-To: <85928d2def5893cd90f823b563369e313e993084.camel@talbothome.com> This patch fixes a few bugs: - Makes sure "sent" has an accurate time - Allows "Draft" to Go to "Sent" on the dbus - Allows the time to be preserved if mmsd is closed and opened --- src/mmsutil.h | 2 ++ src/service.c | 60 +++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/mmsutil.h b/src/mmsutil.h index 00ecc39..ec139f1 100644 --- a/src/mmsutil.h +++ b/src/mmsutil.h @@ -120,12 +120,14 @@ struct mms_retrieve_conf { char *priority; char *msgid; time_t date; + char *datestamp; }; struct mms_send_req { enum mms_message_status status; char *to; time_t date; + char *datestamp; char *content_type; gboolean dr; }; diff --git a/src/service.c b/src/service.c index dede36d..b0c2428 100644 --- a/src/service.c +++ b/src/service.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- 1301 USA * */ +#define _XOPEN_SOURCE 700 #ifdef HAVE_CONFIG_H #include <config.h> @@ -35,6 +36,8 @@ #include <glib.h> #include <glib/gstdio.h> #include <gdbus.h> +#include <time.h> +#include <stdio.h> #include <gweb/gweb.h> @@ -129,6 +132,11 @@ static DBusConnection *connection; static guint32 transaction_id_start = 0; + +static const char *time_to_str(const time_t *t); +void debug_print(const char* s, void* data); + + static void mms_load_settings(struct mms_service *service) { GError *error; @@ -220,6 +228,7 @@ static void emit_msg_status_changed(const char *path, const char *new_status) signal = dbus_message_new_signal(path, MMS_MESSAGE_INTERFACE, "PropertyChanged"); + if (signal == NULL) return; @@ -269,6 +278,7 @@ static DBusMessage *msg_mark_read(DBusConnection *conn, g_free(state); g_key_file_set_boolean(meta, "info", "read", TRUE); + mms->rc.status = MMS_MESSAGE_STATUS_READ; mms_store_meta_close(service->identity, mms->uuid, meta, TRUE); @@ -722,6 +732,7 @@ static gboolean result_request_send_conf(struct mms_request *request) g_key_file_set_string(meta, "info", "state", "sent"); g_key_file_set_string(meta, "info", "id", msg->sc.msgid); + request->msg->sr.status = MMS_MESSAGE_STATUS_SENT; mms_message_free(msg); @@ -1047,6 +1058,7 @@ static DBusMessage *send_message(DBusConnection *conn, struct mms_service *service = data; struct mms_request *request; GKeyFile *meta; + const char *datestr; msg = g_new0(struct mms_message, 1); if (msg == NULL) @@ -1059,7 +1071,13 @@ static DBusMessage *send_message(DBusConnection *conn, msg->sr.dr = service->use_delivery_reports; - if (send_message_get_args(dbus_msg, msg) == FALSE) { + time(&msg->sr.date); + + datestr = time_to_str(&msg->sr.date); + + msg->sr.datestamp = g_strdup(datestr); + + if (send_message_get_args(dbus_msg, msg, service) == FALSE) { mms_debug("Invalid arguments"); release_attachement_data(msg->attachments); @@ -1099,6 +1117,7 @@ static DBusMessage *send_message(DBusConnection *conn, if (meta == NULL) goto release_request; + g_key_file_set_string(meta, "info", "date", msg- >sr.datestamp); g_key_file_set_string(meta, "info", "state", "draft"); if (service->use_delivery_reports) { @@ -1339,10 +1358,12 @@ static gboolean load_message_from_store(const char *service_id, char *state = NULL; gboolean read_status; char *data_path = NULL; + char *datestr = NULL; gboolean success = FALSE; gboolean tainted = FALSE; void *pdu; size_t len; + struct tm tm; meta = mms_store_meta_open(service_id, uuid); if (meta == NULL) @@ -1354,6 +1375,13 @@ static gboolean load_message_from_store(const char *service_id, read_status = g_key_file_get_boolean(meta, "info", "read", NULL); + datestr = g_key_file_get_string(meta, "info", "date", NULL); + if (datestr != NULL) { + strptime(datestr, "%Y-%m-%dT%H:%M:%S%z", &tm); + } else { + mms_error("src/service.c:load_message_from_store() There is no date stamp!"); + } + data_path = mms_store_get_path(service_id, uuid); if (data_path == NULL) goto out; @@ -1372,25 +1400,28 @@ static gboolean load_message_from_store(const char *service_id, msg->uuid = g_strdup(uuid); - if (strcmp(state, "received") == 0 - && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + if (strcmp(state, "received") == 0 && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + msg->rc.datestamp = g_strdup(datestr); + msg->rc.date = mktime(&tm); if (read_status == TRUE) msg->rc.status = MMS_MESSAGE_STATUS_READ; else msg->rc.status = MMS_MESSAGE_STATUS_RECEIVED; - } else if (strcmp(state, "downloaded") == 0 - && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + } else if (strcmp(state, "downloaded") == 0 && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { msg->rc.status = MMS_MESSAGE_STATUS_DOWNLOADED; if (msg->transaction_id == NULL) msg->transaction_id = ""; - } else if (strcmp(state, "sent") == 0 - && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) + } else if (strcmp(state, "sent") == 0 && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) { + msg->sr.datestamp = g_strdup(datestr); + msg->sr.date = mktime(&tm); msg->sr.status = MMS_MESSAGE_STATUS_SENT; - else if (strcmp(state, "draft") == 0 - && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) + } + else if (strcmp(state, "draft") == 0 && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) { + msg->sr.datestamp = g_strdup(datestr); + msg->sr.date = mktime(&tm); msg->sr.status = MMS_MESSAGE_STATUS_DRAFT; - else if (msg->type != MMS_MESSAGE_TYPE_NOTIFICATION_IND && - msg->type != MMS_MESSAGE_TYPE_DELIVERY_IND) + } + else if (msg->type != MMS_MESSAGE_TYPE_NOTIFICATION_IND && msg->type != MMS_MESSAGE_TYPE_DELIVERY_IND) goto out; success = TRUE; @@ -1879,14 +1910,13 @@ static void append_rc_msg_properties(DBusMessageIter *dict, static void append_sr_msg_properties(DBusMessageIter *dict, struct mms_message *msg) { - const char *date = time_to_str(&msg->rc.date); const char *status = mms_message_status_get_string(msg- >sr.status); mms_dbus_dict_append_basic(dict, "Status", DBUS_TYPE_STRING, &status); mms_dbus_dict_append_basic(dict, "Date", - DBUS_TYPE_STRING, &date); + DBUS_TYPE_STRING, &msg- >sr.datestamp); if (msg->sr.to != NULL) append_msg_recipients(dict, msg); @@ -2120,6 +2150,9 @@ static gboolean result_request_notify_resp(struct mms_request *request) if (meta == NULL) return FALSE; + const char *datestr = time_to_str(&msg->rc.date); + msg->rc.datestamp = g_strdup(datestr); + g_key_file_set_string(meta, "info", "date", msg->rc.datestamp); g_key_file_set_string(meta, "info", "state", "received"); mms_store_meta_close(request->service->identity, @@ -2536,7 +2569,6 @@ void mms_service_bearer_notify(struct mms_service *service, mms_bool_t active, if (active == FALSE) goto interface_down; - DBG("interface %s proxy %s", interface, proxy); if (service->web != NULL) { -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Chris Talbot <chris@talbothome.com> To: ofono@ofono.org Subject: [PATCH 7/9] Fix Draft and Sent Bugs Date: Sat, 10 Apr 2021 10:23:12 -0400 [thread overview] Message-ID: <9f9d0f40db75ff82a306af14e7879e567dce9821.camel@talbothome.com> (raw) In-Reply-To: <85928d2def5893cd90f823b563369e313e993084.camel@talbothome.com> [-- Attachment #1: Type: text/plain, Size: 7214 bytes --] This patch fixes a few bugs: - Makes sure "sent" has an accurate time - Allows "Draft" to Go to "Sent" on the dbus - Allows the time to be preserved if mmsd is closed and opened --- src/mmsutil.h | 2 ++ src/service.c | 60 +++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/mmsutil.h b/src/mmsutil.h index 00ecc39..ec139f1 100644 --- a/src/mmsutil.h +++ b/src/mmsutil.h @@ -120,12 +120,14 @@ struct mms_retrieve_conf { char *priority; char *msgid; time_t date; + char *datestamp; }; struct mms_send_req { enum mms_message_status status; char *to; time_t date; + char *datestamp; char *content_type; gboolean dr; }; diff --git a/src/service.c b/src/service.c index dede36d..b0c2428 100644 --- a/src/service.c +++ b/src/service.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- 1301 USA * */ +#define _XOPEN_SOURCE 700 #ifdef HAVE_CONFIG_H #include <config.h> @@ -35,6 +36,8 @@ #include <glib.h> #include <glib/gstdio.h> #include <gdbus.h> +#include <time.h> +#include <stdio.h> #include <gweb/gweb.h> @@ -129,6 +132,11 @@ static DBusConnection *connection; static guint32 transaction_id_start = 0; + +static const char *time_to_str(const time_t *t); +void debug_print(const char* s, void* data); + + static void mms_load_settings(struct mms_service *service) { GError *error; @@ -220,6 +228,7 @@ static void emit_msg_status_changed(const char *path, const char *new_status) signal = dbus_message_new_signal(path, MMS_MESSAGE_INTERFACE, "PropertyChanged"); + if (signal == NULL) return; @@ -269,6 +278,7 @@ static DBusMessage *msg_mark_read(DBusConnection *conn, g_free(state); g_key_file_set_boolean(meta, "info", "read", TRUE); + mms->rc.status = MMS_MESSAGE_STATUS_READ; mms_store_meta_close(service->identity, mms->uuid, meta, TRUE); @@ -722,6 +732,7 @@ static gboolean result_request_send_conf(struct mms_request *request) g_key_file_set_string(meta, "info", "state", "sent"); g_key_file_set_string(meta, "info", "id", msg->sc.msgid); + request->msg->sr.status = MMS_MESSAGE_STATUS_SENT; mms_message_free(msg); @@ -1047,6 +1058,7 @@ static DBusMessage *send_message(DBusConnection *conn, struct mms_service *service = data; struct mms_request *request; GKeyFile *meta; + const char *datestr; msg = g_new0(struct mms_message, 1); if (msg == NULL) @@ -1059,7 +1071,13 @@ static DBusMessage *send_message(DBusConnection *conn, msg->sr.dr = service->use_delivery_reports; - if (send_message_get_args(dbus_msg, msg) == FALSE) { + time(&msg->sr.date); + + datestr = time_to_str(&msg->sr.date); + + msg->sr.datestamp = g_strdup(datestr); + + if (send_message_get_args(dbus_msg, msg, service) == FALSE) { mms_debug("Invalid arguments"); release_attachement_data(msg->attachments); @@ -1099,6 +1117,7 @@ static DBusMessage *send_message(DBusConnection *conn, if (meta == NULL) goto release_request; + g_key_file_set_string(meta, "info", "date", msg- >sr.datestamp); g_key_file_set_string(meta, "info", "state", "draft"); if (service->use_delivery_reports) { @@ -1339,10 +1358,12 @@ static gboolean load_message_from_store(const char *service_id, char *state = NULL; gboolean read_status; char *data_path = NULL; + char *datestr = NULL; gboolean success = FALSE; gboolean tainted = FALSE; void *pdu; size_t len; + struct tm tm; meta = mms_store_meta_open(service_id, uuid); if (meta == NULL) @@ -1354,6 +1375,13 @@ static gboolean load_message_from_store(const char *service_id, read_status = g_key_file_get_boolean(meta, "info", "read", NULL); + datestr = g_key_file_get_string(meta, "info", "date", NULL); + if (datestr != NULL) { + strptime(datestr, "%Y-%m-%dT%H:%M:%S%z", &tm); + } else { + mms_error("src/service.c:load_message_from_store() There is no date stamp!"); + } + data_path = mms_store_get_path(service_id, uuid); if (data_path == NULL) goto out; @@ -1372,25 +1400,28 @@ static gboolean load_message_from_store(const char *service_id, msg->uuid = g_strdup(uuid); - if (strcmp(state, "received") == 0 - && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + if (strcmp(state, "received") == 0 && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + msg->rc.datestamp = g_strdup(datestr); + msg->rc.date = mktime(&tm); if (read_status == TRUE) msg->rc.status = MMS_MESSAGE_STATUS_READ; else msg->rc.status = MMS_MESSAGE_STATUS_RECEIVED; - } else if (strcmp(state, "downloaded") == 0 - && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { + } else if (strcmp(state, "downloaded") == 0 && msg->type == MMS_MESSAGE_TYPE_RETRIEVE_CONF) { msg->rc.status = MMS_MESSAGE_STATUS_DOWNLOADED; if (msg->transaction_id == NULL) msg->transaction_id = ""; - } else if (strcmp(state, "sent") == 0 - && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) + } else if (strcmp(state, "sent") == 0 && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) { + msg->sr.datestamp = g_strdup(datestr); + msg->sr.date = mktime(&tm); msg->sr.status = MMS_MESSAGE_STATUS_SENT; - else if (strcmp(state, "draft") == 0 - && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) + } + else if (strcmp(state, "draft") == 0 && msg->type == MMS_MESSAGE_TYPE_SEND_REQ) { + msg->sr.datestamp = g_strdup(datestr); + msg->sr.date = mktime(&tm); msg->sr.status = MMS_MESSAGE_STATUS_DRAFT; - else if (msg->type != MMS_MESSAGE_TYPE_NOTIFICATION_IND && - msg->type != MMS_MESSAGE_TYPE_DELIVERY_IND) + } + else if (msg->type != MMS_MESSAGE_TYPE_NOTIFICATION_IND && msg->type != MMS_MESSAGE_TYPE_DELIVERY_IND) goto out; success = TRUE; @@ -1879,14 +1910,13 @@ static void append_rc_msg_properties(DBusMessageIter *dict, static void append_sr_msg_properties(DBusMessageIter *dict, struct mms_message *msg) { - const char *date = time_to_str(&msg->rc.date); const char *status = mms_message_status_get_string(msg- >sr.status); mms_dbus_dict_append_basic(dict, "Status", DBUS_TYPE_STRING, &status); mms_dbus_dict_append_basic(dict, "Date", - DBUS_TYPE_STRING, &date); + DBUS_TYPE_STRING, &msg- >sr.datestamp); if (msg->sr.to != NULL) append_msg_recipients(dict, msg); @@ -2120,6 +2150,9 @@ static gboolean result_request_notify_resp(struct mms_request *request) if (meta == NULL) return FALSE; + const char *datestr = time_to_str(&msg->rc.date); + msg->rc.datestamp = g_strdup(datestr); + g_key_file_set_string(meta, "info", "date", msg->rc.datestamp); g_key_file_set_string(meta, "info", "state", "received"); mms_store_meta_close(request->service->identity, @@ -2536,7 +2569,6 @@ void mms_service_bearer_notify(struct mms_service *service, mms_bool_t active, if (active == FALSE) goto interface_down; - DBG("interface %s proxy %s", interface, proxy); if (service->web != NULL) { -- 2.30.2
next prev parent reply other threads:[~2021-04-10 14:24 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-10 14:13 [PATCH 0/9] Updates for mmsd Chris Talbot 2021-04-10 14:13 ` Chris Talbot 2021-04-10 14:17 ` [PATCH 1/9] Fix mmsd to work with T-mobile Chris Talbot 2021-04-10 14:17 ` Chris Talbot 2021-04-10 14:20 ` [PATCH 2/9] Ensure Compatibility with Telus Canada Chris Talbot 2021-04-10 14:20 ` Chris Talbot 2021-04-10 14:20 ` [PATCH 3/9] Ensure Compatibility with AT&T Chris Talbot 2021-04-10 14:20 ` Chris Talbot 2021-04-10 14:21 ` [PATCH 4/9] Fix issue if there is an empty string in encoded text Chris Talbot 2021-04-10 14:21 ` Chris Talbot 2021-04-10 14:22 ` [PATCH 5/9] Allow for a user configurable maximum attachment size Chris Talbot 2021-04-10 14:22 ` Chris Talbot 2021-04-10 14:22 ` [PATCH 6/9] Update README Chris Talbot 2021-04-10 14:22 ` Chris Talbot 2021-04-10 14:23 ` Chris Talbot [this message] 2021-04-10 14:23 ` [PATCH 7/9] Fix Draft and Sent Bugs Chris Talbot 2021-04-10 14:23 ` [PATCH 8/9] Allow Maintainer mode to compile without -WError Chris Talbot 2021-04-10 14:23 ` Chris Talbot 2021-04-10 14:24 ` [PATCH 9/9] Enable support for Modem Manager Chris Talbot 2021-04-10 14:24 ` Chris Talbot 2021-04-14 18:21 ` Forking on MMSD Chris Talbot 2021-04-14 18:21 ` Chris Talbot 2021-04-14 18:30 ` [Debian-on-mobile-maintainers] " Guido Günther 2021-04-14 18:46 ` Chris Talbot 2021-04-15 9:10 ` Guido Günther 2021-04-14 18:39 ` Marius Gripsgard 2021-04-14 18:39 ` Marius Gripsgard 2021-04-14 22:09 ` Bug#985893: " Wookey 2021-04-15 0:12 ` Chris Talbot 2021-04-14 19:29 ` Pavel Machek 2021-04-14 19:29 ` Pavel Machek 2021-04-14 21:11 ` Bug#985893: " Paul Wise [not found] ` <c7ffd7e4d62e5d5ed397f69be180d81588a4cfd1.camel@talbothome.com> 2021-04-14 22:58 ` Pavel Machek 2021-04-14 22:58 ` Pavel Machek 2021-04-15 0:01 ` Chris Talbot 2021-04-27 9:15 ` Pavel Machek 2021-04-27 9:15 ` Pavel Machek 2021-04-29 14:49 ` Chris Talbot 2021-05-18 3:56 ` hoangnambohung -- strict thread matches above, loose matches on Subject: below -- 2021-03-26 10:56 [PATCH 7/9] Fix Draft and Sent Bugs Christopher Talbot 2021-03-26 10:52 Christopher Talbot 2021-02-25 0:39 Patches For MMSD chris 2021-02-25 0:47 ` [PATCH 7/9] Fix Draft and Sent Bugs Christopher Talbot
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=9f9d0f40db75ff82a306af14e7879e567dce9821.camel@talbothome.com \ --to=chris@talbothome.com \ --cc=debian-on-mobile-maintainers@alioth-lists.debian.net \ --cc=librem-5-dev@lists.community.puri.sm \ --cc=netdev@vger.kernel.org \ --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: linkBe 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.