All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Basic blocks for control channel.
@ 2014-04-07 11:55 jussi.pakkanen
  2014-04-07 11:55 ` [PATCH 2/2] Basic implementation of dbus methods jussi.pakkanen
  2014-04-07 14:02 ` [PATCH 1/2] Basic blocks for control channel Denis Kenzior
  0 siblings, 2 replies; 6+ messages in thread
From: jussi.pakkanen @ 2014-04-07 11:55 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3132 bytes --]

Hello

Here's a revised way of changing phonesim modem configurations at
runtime. It works by adding a dbus interface via which you can add new
modems, delete all existing modems or reset modem status to what it
was at startup. This first patch adds the dbus bits and the second one
calls the corresponding ofono functions.

This patch set is not fully polished yet but should give an idea what
we are aiming for. I'm not fully versed in phonesim's internals so I'm
not sure if I'm poking all the right bits in the dbus functions, so
please verify that with extra care.

Thanks,

---
 plugins/phonesim.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index 5561a05..12cd591 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -35,6 +35,7 @@
 #include <glib.h>
 #include <gatmux.h>
 #include <gatchat.h>
+#include <gdbus.h>
 
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/plugin.h>
@@ -73,6 +74,8 @@ static const char *none_prefix[] = { NULL };
 static const char *ptty_prefix[] = { "+PTTY:", NULL };
 static const char *simstate_prefix[] = { "+SIMSTATE:", NULL };
 static int next_iface = 0;
+static const char CONTROL_PATH[] = "/phonesim";
+static const char CONTROL_INTERFACE[] = "org.ofono.phonesim.Control";
 
 struct phonesim_data {
 	GAtMux *mux;
@@ -1068,6 +1071,55 @@ done:
 	g_key_file_free(keyfile);
 }
 
+static DBusMessage *control_add(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	return NULL;
+}
+
+static DBusMessage *control_remove_all(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	return NULL;
+}
+
+static DBusMessage *control_reset(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	return NULL;
+}
+
+static const GDBusMethodTable control_methods[] = {
+	{ GDBUS_METHOD("Add",
+			NULL, GDBUS_ARGS({ "properties", "sss" }),
+			control_add) },
+	{ GDBUS_METHOD("RemoveAll",
+			NULL, GDBUS_ARGS({ "properties", "" }),
+			control_remove_all) },
+	{ GDBUS_METHOD("Reset",
+			NULL, GDBUS_ARGS({ "properties", "" }),
+			control_reset) },
+	{}
+};
+
+static int setup_control_channel() {
+	int err = 0;
+	DBusConnection *conn = ofono_dbus_get_connection();
+	void *user_data = NULL;
+	g_dbus_register_interface(conn,
+			CONTROL_PATH, CONTROL_INTERFACE,
+			control_methods,
+			NULL,
+			NULL,
+			user_data,
+			NULL);
+	return err;
+}
+
+static void shutdown_control_channel() {
+	g_dbus_unregister_interface(ofono_dbus_get_connection(), CONTROL_PATH, CONTROL_INTERFACE);
+}
+
 static int phonesim_init(void)
 {
 	int err;
@@ -1087,6 +1139,10 @@ static int phonesim_init(void)
 	else
 		parse_config(CONFIGDIR "/phonesim.conf");
 
+	err = setup_control_channel();
+	if (err < 0)
+		return err;
+
 	return 0;
 }
 
@@ -1094,6 +1150,8 @@ static void phonesim_exit(void)
 {
 	GSList *list;
 
+	shutdown_control_channel();
+
 	for (list = modem_list; list; list = list->next) {
 		struct ofono_modem *modem = list->data;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-08 12:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-07 11:55 [PATCH 1/2] Basic blocks for control channel jussi.pakkanen
2014-04-07 11:55 ` [PATCH 2/2] Basic implementation of dbus methods jussi.pakkanen
2014-04-07 14:02 ` [PATCH 1/2] Basic blocks for control channel Denis Kenzior
2014-04-07 20:34   ` Antti =?unknown-8bit?q?Kaijanm=C3=A4ki?=
2014-04-07 21:40     ` Denis Kenzior
2014-04-08 12:24       ` Antti =?unknown-8bit?q?Kaijanm=C3=A4ki?=

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.