Skip to contentSkip to conversation

mmsd: Add GetProperties method

PATCH In review Ronald Tessier 2 participants 7 messages Aug 9, 2012

lore
Share & tools
lore
#0 lore raw

cover mmsd: Add GetProperties method

This patch concerns mmsd and is related to delivery-report flag setting. Describe and implement the GetProperties DBus api.
Add a test script to retrieve service properties.

Ronald Tessier (3):
service: Add DBus method to get service properties
doc: Describe GetProperties in service-api
test: Add a test script to get service properties

 doc/service-api.txt |    7 +++++++
 src/service.c       |   29 +++++++++++++++++++++++++++++
 test/get-properties |   26 ++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100755 test/get-properties

--
1.7.9.5

#1 lore raw

PATCH 1/3 service: Add DBus method to get service properties

---
 src/service.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
src/service.c +29 -0
index 22d19c7..db9c514 100644
@@ -887,6 +887,31 @@ out:
 	return reply;
 }
 
+static DBusMessage *get_properties(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	struct mms_service *service = data;
+	DBusMessage *reply;
+	DBusMessageIter iter;
+	DBusMessageIter dict;
+
+	reply = dbus_message_new_method_return(msg);
+	if (reply == NULL)
+		return NULL;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	mms_dbus_dict_open(&iter, &dict);
+
+	mms_dbus_dict_append_basic(&dict, "UseDeliveryReports",
+					DBUS_TYPE_BOOLEAN,
+					&service->use_delivery_reports);
+
+	mms_dbus_dict_close(&iter, &dict);
+
+	return reply;
+}
+
 static DBusMessage *set_property(DBusConnection *conn, DBusMessage *dbus_msg,
 								void *data)
 {
@@ -1069,6 +1094,10 @@ static const GDBusMethodTable service_methods[] = {
 			GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
 			NULL,
 			set_property) },
+	{ GDBUS_METHOD("GetProperties",
+			NULL,
+			GDBUS_ARGS({ "properties", "a{sv}" }),
+			get_properties) },
 	{ }
 };
 
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 1/3] service: Add DBus method to get service properties

Hi Ronald,

Quoted 4 lines · Ronald Tessier
---
  src/service.c |   29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)

Patch has been applied, thanks.

Regards,
-Denis

#3 lore raw

PATCH 2/3 doc: Describe GetProperties in service-api

In reply to Ronald Tessier
---
 doc/service-api.txt |    7 +++++++
 1 file changed, 7 insertions(+)
doc/service-api.txt +7 -0
index 25f2d0d..1bf820e 100644
@@ -36,6 +36,13 @@ Methods		array{object,dict} GetMessages()
 			Possible Errors: [service].Error.InvalidArguments
 					 [service].Error.TransientFailure
 
+		dict GetProperties()
+
+			Returns properties for the manager object. See
+			the properties section for available properties.
+
+			Possible Errors: [service].Error.NotImplemented
+
 		object SendMessage(array{string} recipients, string smil,
 					array{string id, string content-type,
 							string filename})
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH 2/3] doc: Describe GetProperties in service-api

Hi Ronald,

Quoted 4 lines · Ronald Tessier
---
  doc/service-api.txt |    7 +++++++
  1 file changed, 7 insertions(+)

Patch has been applied, thanks.

Regards,
-Denis

#5 lore raw

PATCH 3/3 test: Add a test script to get service properties

In reply to Ronald Tessier
---
 test/get-properties |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 test/get-properties
test/get-properties new file +26 -0
new file mode 100755
index 0000000..8887fcb
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+bus = dbus.SessionBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono.mms', '/org/ofono/mms'),
+					'org.ofono.mms.Manager')
+
+services = manager.GetServices()
+path = services[0][0]
+
+service = dbus.Interface(bus.get_object('org.ofono.mms', path),
+						'org.ofono.mms.Service')
+
+properties = service.GetProperties()
+
+for p in properties:
+	if len(properties[p].__str__()) > 0:
+		print "%s Service Manager rule is: %s" %\
+				(p, properties[p])
+		print "------------------------------------------" \
+			"-----------------"
+	else:
+		print "%s Service Manager rule disabled" % (p)
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH 3/3] test: Add a test script to get service properties

Hi Ronald,

Quoted 27 lines · Ronald Tessier
---
  test/get-properties |   26 ++++++++++++++++++++++++++
  1 file changed, 26 insertions(+)

create mode 100755 test/get-properties

test/get-properties new file +16 -0
new file mode 100755
index 0000000..8887fcb
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+bus = dbus.SessionBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono.mms', '/org/ofono/mms'),
+					'org.ofono.mms.Manager')
+
+services = manager.GetServices()
+path = services[0][0]
+
+service = dbus.Interface(bus.get_object('org.ofono.mms', path),
+						'org.ofono.mms.Service')
+

test/get-properties line 26

Quoted 10 lines
test/get-properties new file +10 -0
+properties = service.GetProperties()
+
+for p in properties:
+	if len(properties[p].__str__())>  0:
+		print "%s Service Manager rule is: %s" %\
+				(p, properties[p])
+		print "------------------------------------------" \
+			"-----------------"
+	else:
+		print "%s Service Manager rule disabled" % (p)

Please model this script after list-modems in ofono. Name it list-services.

Regards,
-Denis