Skip to contentSkip to conversation

mmsd: get delivery_report setting

PATCH In review Ronald Tessier 2 participants 7 messages Jul 6, 2012 – Jul 17, 2012

lore
Share & tools
lore
#0 lore raw

cover mmsd: get delivery_report setting

This set of patches concerns mmsd and is related to delivery_report. Add delivery report flag and API (to set its value) to service. Get and track the delivery report setting used by oFono in the message manager and use it in mmsd.

Ronald Tessier (3):
service: manage delivery report setting
ofono: Add support for message_manager tracking
service: use delivery_report in send_req message

 plugins/ofono.c |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/service.c   |   15 +++++++
 src/service.h   |    2 +
 3 files changed, 152 insertions(+)

--
1.7.9.5

#1 lore raw

PATCH 1/3 service: manage delivery report setting

---
 src/service.c |   13 +++++++++++++
 src/service.h |    2 ++
 2 files changed, 15 insertions(+)
src/service.c +13 -0
index 83e1fe1..5913a55 100644
@@ -75,6 +75,7 @@ struct mms_service {
 	char *identity;
 	char *path;
 	char *mmsc;
+	gboolean dr;
 	mms_service_bearer_handler_func_t bearer_handler;
 	void *bearer_data;
 	guint bearer_timeout;
@@ -1849,6 +1850,18 @@ int mms_service_set_bearer_handler(struct mms_service *service,
 	return 0;
 }
 
+int mms_service_set_delivery_report(struct mms_service *service, gboolean dr)
+{
+	DBG("service %p dr %d", service, dr);
+
+	if (service == NULL)
+		return -EINVAL;
+
+	service->dr = dr;
+
+	return 0;
+}
+
 static inline gboolean bearer_is_active(struct mms_service *service)
 {
 	if (service->bearer_setup == TRUE)
src/service.h +2 -0
index 56c0585..bafe8c0 100644
@@ -42,6 +42,8 @@ int mms_service_set_bearer_handler(struct mms_service *service,
 				mms_service_bearer_handler_func_t handler,
 							void *user_data);
 
+int mms_service_set_delivery_report(struct mms_service *service, gboolean dr);
+
 void mms_service_push_notify(struct mms_service *service,
 					unsigned char *data, int len);
 

--
1.7.9.5

#2 lore raw

PATCH 2/3 ofono: Add support for message_manager tracking

In reply to Ronald Tessier
---
 plugins/ofono.c |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 135 insertions(+)
plugins/ofono.c +135 -0
index 45fac91..8f2e71f 100644
@@ -40,6 +40,7 @@
 #define OFONO_SIM_INTERFACE	OFONO_SERVICE ".SimManager"
 #define OFONO_GPRS_INTERFACE	OFONO_SERVICE ".ConnectionManager"
 #define OFONO_CONTEXT_INTERFACE	OFONO_SERVICE ".ConnectionContext"
+#define OFONO_MESSAGE_MANAGER_INTERFACE	OFONO_SERVICE ".MessageManager"
 #define OFONO_PUSH_INTERFACE	OFONO_SERVICE ".PushNotification"
 #define OFONO_AGENT_INTERFACE	OFONO_SERVICE ".PushNotificationAgent"
 
@@ -59,6 +60,7 @@ struct modem_data {
 	dbus_bool_t context_active;
 	char *context_interface;
 	char *context_proxy;
+	dbus_bool_t use_dr;
 };
 
 static GHashTable *modem_list;
@@ -885,6 +887,126 @@ static int get_gprs_properties(struct modem_data *modem)
 	return 0;
 }
 
+static void check_message_mgr_delivery_report(struct modem_data *modem,
+							DBusMessageIter *iter)
+{
+	dbus_bool_t use_dr;
+
+	dbus_message_iter_get_basic(iter, &use_dr);
+
+	if (modem->use_dr == use_dr)
+		return;
+
+	modem->use_dr = use_dr;
+
+	DBG("Use DeliveryReport %d", modem->use_dr);
+
+	mms_service_set_delivery_report(modem->service, modem->use_dr);
+}
+
+static gboolean message_mgr_changed(DBusConnection *connection,
+				DBusMessage *message, void *user_data)
+{
+	struct modem_data *modem;
+	DBusMessageIter iter, value;
+	const char *path, *key;
+
+	if (dbus_message_iter_init(message, &iter) == FALSE)
+		return TRUE;
+
+	path = dbus_message_get_path(message);
+
+	modem = g_hash_table_lookup(modem_list, path);
+	if (modem == NULL)
+		return TRUE;
+
+	dbus_message_iter_get_basic(&iter, &key);
+
+	dbus_message_iter_next(&iter);
+	dbus_message_iter_recurse(&iter, &value);
+
+	if (g_str_equal(key, "UseDeliveryReports") == TRUE)
+		check_message_mgr_delivery_report(modem, &value);
+
+	return TRUE;
+}
+
+static void get_message_mgr_properties_reply(DBusPendingCall *call,
+								void *user_data)
+{
+	struct modem_data *modem = user_data;
+	DBusMessage *reply = dbus_pending_call_steal_reply(call);
+	DBusMessageIter iter, dict;
+	DBusError err;
+
+	dbus_error_init(&err);
+
+	if (dbus_set_error_from_message(&err, reply) == TRUE) {
+		dbus_error_free(&err);
+		goto done;
+	}
+
+	if (dbus_message_has_signature(reply, "a{sv}") == FALSE)
+		goto done;
+
+	if (dbus_message_iter_init(reply, &iter) == FALSE)
+		goto done;
+
+	dbus_message_iter_recurse(&iter, &dict);
+
+	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+		DBusMessageIter entry, value;
+		const char *key;
+
+		dbus_message_iter_recurse(&dict, &entry);
+
+		dbus_message_iter_get_basic(&entry, &key);
+		dbus_message_iter_next(&entry);
+
+		dbus_message_iter_recurse(&entry, &value);
+
+		if (g_str_equal(key, "UseDeliveryReports") == TRUE)
+			check_message_mgr_delivery_report(modem, &value);
+
+		dbus_message_iter_next(&dict);
+	}
+
+done:
+	dbus_message_unref(reply);
+}
+
+static int get_message_mgr_properties(struct modem_data *modem)
+{
+	DBusConnection *conn = modem->conn;
+	DBusMessage *msg;
+	DBusPendingCall *call;
+
+	msg = dbus_message_new_method_call(OFONO_SERVICE, modem->path,
+					OFONO_MESSAGE_MANAGER_INTERFACE,
+					"GetProperties");
+	if (msg == NULL)
+		return -ENOMEM;
+
+	dbus_message_set_auto_start(msg, FALSE);
+
+	if (dbus_connection_send_with_reply(conn, msg, &call, -1) == FALSE) {
+		dbus_message_unref(msg);
+		return -EIO;
+	}
+
+	dbus_message_unref(msg);
+
+	if (call == NULL)
+		return -EINVAL;
+
+	dbus_pending_call_set_notify(call, get_message_mgr_properties_reply,
+							modem, NULL);
+
+	dbus_pending_call_unref(call);
+
+	return 0;
+}
+
 static void check_interfaces(struct modem_data *modem, DBusMessageIter *iter)
 {
 	DBusMessageIter entry;
@@ -963,6 +1085,8 @@ static void check_interfaces(struct modem_data *modem, DBusMessageIter *iter)
 		if (modem->has_push == FALSE && modem->has_agent == TRUE)
 			remove_agent(modem);
 	}
+
+	get_message_mgr_properties(modem);
 }
 
 static void create_modem(DBusConnection *conn,
@@ -982,6 +1106,7 @@ static void create_modem(DBusConnection *conn,
 	modem->has_gprs = FALSE;
 	modem->has_push = FALSE;
 	modem->has_agent = FALSE;
+	modem->use_dr = FALSE;
 
 	modem->service = mms_service_create();
 
@@ -1146,6 +1271,7 @@ static guint gprs_changed_watch;
 static guint context_added_watch;
 static guint context_removed_watch;
 static guint context_changed_watch;
+static guint message_mgr_changed_watch;
 
 static void ofono_connect(DBusConnection *conn, void *user_data)
 {
@@ -1188,6 +1314,10 @@ static void ofono_connect(DBusConnection *conn, void *user_data)
 				OFONO_CONTEXT_INTERFACE, "PropertyChanged",
 						context_changed, NULL, NULL);
 
+	message_mgr_changed_watch = g_dbus_add_signal_watch(conn, NULL, NULL,
+			OFONO_MESSAGE_MANAGER_INTERFACE, "PropertyChanged",
+					message_mgr_changed, NULL, NULL);
+
 	get_modems(conn);
 }
 
@@ -1237,6 +1367,11 @@ static void ofono_disconnect(DBusConnection *conn, void *user_data)
 		context_changed_watch = 0;
 	}
 
+	if (message_mgr_changed_watch > 0) {
+		g_dbus_remove_watch(conn, message_mgr_changed_watch);
+		message_mgr_changed_watch = 0;
+	}
+
 	g_hash_table_destroy(modem_list);
 	modem_list = NULL;
 }
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 service: use delivery_report in send_req message

In reply to Ronald Tessier
---
 src/service.c |    2 ++
 1 file changed, 2 insertions(+)
src/service.c +2 -0
index 5913a55..e3812a7 100644
@@ -918,6 +918,8 @@ static DBusMessage *send_message(DBusConnection *conn,
 	if (msg->transaction_id == NULL)
 		goto release_msg;
 
+	msg->sr.dr = service->dr;
+
 	request = create_request(MMS_REQUEST_TYPE_POST,
 				result_request_send_conf, NULL, service, msg);
 	if (request == NULL)
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Ronald Tessier

Hi Ronald,

Quoted 4 lines · Ronald Tessier

This set of patches concerns mmsd and is related to delivery_report. Add delivery report flag and API (to set its value) to service. Get and track the delivery report setting used by oFono in the message manager and use it in mmsd.

Maybe I'm not seeing something, but why are we tracking the delivery report flag in oFono in mmsd? I'm guessing you want to synchronize the two, but I do not see why you would want to?

Regards,
-Denis

#5 lore raw

Hi Denis,

Quoted 9 lines · Denis Kenzior

Hi Ronald,

Quoted 5 lines · Ronald Tessier

This set of patches concerns mmsd and is related to delivery_report. Add delivery report flag and API (to set its value) to service. Get and track the delivery report setting used by oFono in the message manager
and use it in mmsd.

Quoted 7 lines

Maybe I'm not seeing something, but why are we tracking the delivery report flag in oFono in mmsd? I'm guessing you want to synchronize the two, but I do not see why you would want to?

Regards,
-Denis

This flag is set by the application layer to request delivery report in oFono, since mmsd is an oFono plugin I want to use the same flag for all kind of messages (SMS and MMS) and not add a new flag in mmsd.

If you prefer, I define a new flag (with almost the same API and file settings mechanism) in mmsd. Let me know.

Regards,

Ronald

#6 lore raw

Hi Ronald,

Quoted 20 lines · Ronald Tessier

Hi Denis,

Quoted 9 lines · Denis Kenzior

Hi Ronald,

Quoted 5 lines · Ronald Tessier

This set of patches concerns mmsd and is related to delivery_report. Add delivery report flag and API (to set its value) to service. Get and track the delivery report setting used by oFono in the message manager
and use it in mmsd.

Quoted 7 lines

Maybe I'm not seeing something, but why are we tracking the delivery report flag in oFono in mmsd? I'm guessing you want to synchronize the two, but I do not see why you would want to?

Regards,
-Denis

Quoted 7 lines

This flag is set by the application layer to request delivery report in oFono, since mmsd is an oFono plugin I want to use the same flag for all kind of messages (SMS and MMS) and not add a new flag in mmsd.

If you prefer, I define a new flag (with almost the same API and file settings mechanism) in mmsd. Let me know.

I think that would be a good idea, the two delivery report settings are not really related and should be controlled separately.

Regards,
-Denis