All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v3 00/16] Add DUN support
@ 2011-12-13 14:59 Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 01/16] elect: Add skeleton implementation Daniel Wagner
                   ` (15 more replies)
  0 siblings, 16 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

Hi,

Another update on this one. I splittet some patches more, in order to
make it more easy to review.

This version is now tested and works pretty good. The phone does some
funky stuff, but that is BT only. Tomorrow, I should get a BT sniffer
for getting those bugs fixed. This should only touch BlueZ though.

Here the list of changes for v3:

- use ofono_dbus_get_connection()
- splitting initial patch: dbus configuration and systemd configuration patch
- rename dun.c to dial.c
- change order of adding dial.c
- add ppp gatchat code to dial.c in a separate patch
- use own error name space on dbus (org.ofono.elect.error.Foo)
- pass own Connection Refused error message from bluez
- create and destroy dial object on device creation time. 

cheers,
daniel


Daniel Wagner (16):
  elect: Add skeleton implementation
  elect: Add D-Bus error messages
  elect: Add D-Bus configuration file
  elect: Add systemd configuration file
  elect: Add Manager interface
  elect: Add skeleton implementation for device
  elect: Manager append devices
  bluetooth: Add Serial interface definition
  elect: Add BlueZ hooks to device
  elect: Add device D-Bus interface
  elect: Dis/Connect Serial interface
  elect: Add skeleton dial implementation
  elect: Add ppp callbacks to device
  elect: Add GatChat and PPP handler
  elect: Add test scripts
  elect: Add documentation

 Makefile.am           |   25 ++
 bootstrap-configure   |    1 +
 configure.ac          |    4 +
 doc/elect-api.txt     |   86 ++++++
 elect/dbus.c          |   52 ++++
 elect/device.c        |  697 +++++++++++++++++++++++++++++++++++++++++++++++++
 elect/dial.c          |  206 +++++++++++++++
 elect/elect.conf      |   23 ++
 elect/elect.h         |   88 +++++++
 elect/elect.service   |   11 +
 elect/main.c          |  254 ++++++++++++++++++
 elect/manager.c       |  119 +++++++++
 plugins/bluetooth.h   |    1 +
 test/elect-connect    |   20 ++
 test/elect-disconnect |   20 ++
 test/monitor-elect    |  109 ++++++++
 16 files changed, 1716 insertions(+), 0 deletions(-)
 create mode 100644 doc/elect-api.txt
 create mode 100644 elect/dbus.c
 create mode 100644 elect/device.c
 create mode 100644 elect/dial.c
 create mode 100644 elect/elect.conf
 create mode 100644 elect/elect.h
 create mode 100644 elect/elect.service
 create mode 100644 elect/main.c
 create mode 100644 elect/manager.c
 create mode 100755 test/elect-connect
 create mode 100755 test/elect-disconnect
 create mode 100755 test/monitor-elect

-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 01/16] elect: Add skeleton implementation
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
@ 2011-12-13 14:59 ` Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 02/16] elect: Add D-Bus error messages Daniel Wagner
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am         |   12 +++
 bootstrap-configure |    1 +
 configure.ac        |    4 +
 elect/elect.h       |   46 +++++++++
 elect/main.c        |  255 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 318 insertions(+), 0 deletions(-)
 create mode 100644 elect/elect.h
 create mode 100644 elect/main.c

diff --git a/Makefile.am b/Makefile.am
index 337aeb7..5b7f5ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -647,6 +647,18 @@ tools_lookup_provider_name_SOURCES = plugins/mbpi.c plugins/mbpi.h \
 tools_lookup_provider_name_LDADD = @GLIB_LIBS@
 endif
 
+if ELECT
+
+sbin_PROGRAMS += elect/electd
+
+elect_electd_SOURCES = $(gdbus_sources) \
+			src/log.c src/dbus.c \
+			elect/main.c
+
+elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
+
+endif
+
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
 
 gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
diff --git a/bootstrap-configure b/bootstrap-configure
index db70c66..d80ed8b 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -14,4 +14,5 @@ fi
 		--localstatedir=/var \
 		--enable-capng \
 		--enable-tools \
+		--enable-elect \
 		--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 5e4d34f..f8f3387 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,10 @@ if (test "${enable_tools}" = "yes"); then
 fi
 AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes")
 
+AC_ARG_ENABLE(elect, AC_HELP_STRING([--enable-elect],
+		[enable DUN deamon support]), [enable_elect=${enableval}])
+AM_CONDITIONAL(ELECT, test "${enable_elect}" = "yes")
+
 AC_ARG_ENABLE(atmodem, AC_HELP_STRING([--disable-atmodem],
 				[disable ETSI AT modem support]),
 					[enable_atmodem=${enableval}])
diff --git a/elect/elect.h b/elect/elect.h
new file mode 100644
index 0000000..8786240
--- /dev/null
+++ b/elect/elect.h
@@ -0,0 +1,46 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+
+#include <ofono/types.h>
+
+void __elect_exit(void);
+
+#include <ofono/log.h>
+
+int __ofono_log_init(const char *program, const char *debug,
+					ofono_bool_t detach);
+void __ofono_log_cleanup(void);
+void __ofono_log_enable(struct ofono_debug_desc *start,
+					struct ofono_debug_desc *stop);
+
+#include <ofono/dbus.h>
+
+#define ELECT_SERVICE			"org.ofono.elect"
+
+int __ofono_dbus_init(DBusConnection *conn);
+void __ofono_dbus_cleanup(void);
+
+void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
diff --git a/elect/main.c b/elect/main.c
new file mode 100644
index 0000000..714f8c8
--- /dev/null
+++ b/elect/main.c
@@ -0,0 +1,255 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+
+#include <gdbus.h>
+
+#ifdef HAVE_CAPNG
+#include <cap-ng.h>
+#endif
+
+#include "elect.h"
+
+#define SHUTDOWN_GRACE_SECONDS 10
+
+static GMainLoop *event_loop;
+
+void __elect_exit(void)
+{
+	g_main_loop_quit(event_loop);
+}
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+	__elect_exit();
+	return FALSE;
+}
+
+static unsigned int __terminated = 0;
+
+static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
+							gpointer user_data)
+{
+	struct signalfd_siginfo si;
+	ssize_t result;
+	int fd;
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+		return FALSE;
+
+	fd = g_io_channel_unix_get_fd(channel);
+
+	result = read(fd, &si, sizeof(si));
+	if (result != sizeof(si))
+		return FALSE;
+
+	switch (si.ssi_signo) {
+	case SIGINT:
+	case SIGTERM:
+		if (__terminated == 0) {
+			ofono_info("Terminating");
+			g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
+						quit_eventloop, NULL);
+
+			quit_eventloop(NULL);
+		}
+
+		__terminated = 1;
+		break;
+	}
+
+	return TRUE;
+}
+
+static guint setup_signalfd(void)
+{
+	GIOChannel *channel;
+	guint source;
+	sigset_t mask;
+	int fd;
+
+	sigemptyset(&mask);
+	sigaddset(&mask, SIGINT);
+	sigaddset(&mask, SIGTERM);
+
+	if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
+		perror("Failed to set signal mask");
+		return 0;
+	}
+
+	fd = signalfd(-1, &mask, 0);
+	if (fd < 0) {
+		perror("Failed to create signal descriptor");
+		return 0;
+	}
+
+	channel = g_io_channel_unix_new(fd);
+
+	g_io_channel_set_close_on_unref(channel, TRUE);
+	g_io_channel_set_encoding(channel, NULL, NULL);
+	g_io_channel_set_buffered(channel, FALSE);
+
+	source = g_io_add_watch(channel,
+				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+				signal_handler, NULL);
+
+	g_io_channel_unref(channel);
+
+	return source;
+}
+
+static void system_bus_disconnected(DBusConnection *conn, void *user_data)
+{
+	ofono_error("System bus has disconnected!");
+
+	g_main_loop_quit(event_loop);
+}
+
+static gchar *option_debug = NULL;
+static gboolean option_detach = TRUE;
+static gboolean option_version = FALSE;
+
+static gboolean parse_debug(const char *key, const char *value,
+					gpointer user_data, GError **error)
+{
+	if (value)
+		option_debug = g_strdup(value);
+	else
+		option_debug = g_strdup("*");
+
+	return TRUE;
+}
+
+static GOptionEntry options[] = {
+	{ "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+				G_OPTION_ARG_CALLBACK, parse_debug,
+				"Specify debug options to enable", "DEBUG" },
+	{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
+				G_OPTION_ARG_NONE, &option_detach,
+				"Don't run as daemon in background" },
+	{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
+				"Show version information and exit" },
+	{ NULL },
+};
+
+int main(int argc, char **argv)
+{
+	GOptionContext *context;
+	GError *err = NULL;
+	DBusConnection *conn;
+	DBusError error;
+	guint signal;
+
+#ifdef HAVE_CAPNG
+	/* Drop capabilities */
+	capng_clear(CAPNG_SELECT_BOTH);
+	capng_updatev(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED,
+				CAP_NET_BIND_SERVICE, CAP_NET_ADMIN,
+				CAP_NET_RAW, CAP_SYS_ADMIN, -1);
+	capng_apply(CAPNG_SELECT_BOTH);
+#endif
+
+	context = g_option_context_new(NULL);
+	g_option_context_add_main_entries(context, options, NULL);
+
+	if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) {
+		if (err != NULL) {
+			g_printerr("%s\n", err->message);
+			g_error_free(err);
+			return 1;
+		}
+
+		g_printerr("An unknown error occurred\n");
+		return 1;
+	}
+
+	g_option_context_free(context);
+
+	if (option_version == TRUE) {
+		printf("%s\n", VERSION);
+		exit(0);
+	}
+
+	if (option_detach == TRUE) {
+		if (daemon(0, 0)) {
+			perror("Can't start daemon");
+			return 1;
+		}
+	}
+
+	event_loop = g_main_loop_new(NULL, FALSE);
+
+	signal = setup_signalfd();
+
+	__ofono_log_init(argv[0], option_debug, option_detach);
+
+	dbus_error_init(&error);
+
+	conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, ELECT_SERVICE, &error);
+	if (conn == NULL) {
+		if (dbus_error_is_set(&error) == TRUE) {
+			ofono_error("Unable to hop onto D-Bus: %s",
+					error.message);
+			dbus_error_free(&error);
+		} else {
+			ofono_error("Unable to hop onto D-Bus");
+		}
+
+		goto cleanup;
+	}
+
+	g_dbus_set_disconnect_function(conn, system_bus_disconnected,
+					NULL, NULL);
+
+	__ofono_dbus_init(conn);
+
+	/*
+	 * The reason why this DBG is here is that we have the __stop__debug,
+	 * __start__debug linking symbols in the object. As soon we
+	 * have real DBG we can remove this one again.
+	 */
+	DBG("");
+
+	g_main_loop_run(event_loop);
+
+	__ofono_dbus_cleanup();
+	dbus_connection_unref(conn);
+
+cleanup:
+	g_source_remove(signal);
+
+	g_main_loop_unref(event_loop);
+
+	__ofono_log_cleanup();
+
+	return 0;
+}
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 02/16] elect: Add D-Bus error messages
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 01/16] elect: Add skeleton implementation Daniel Wagner
@ 2011-12-13 14:59 ` Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 03/16] elect: Add D-Bus configuration file Daniel Wagner
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am   |    2 +-
 elect/dbus.c  |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 elect/elect.h |    4 ++++
 3 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100644 elect/dbus.c

diff --git a/Makefile.am b/Makefile.am
index 5b7f5ed..38e5d90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -653,7 +653,7 @@ sbin_PROGRAMS += elect/electd
 
 elect_electd_SOURCES = $(gdbus_sources) \
 			src/log.c src/dbus.c \
-			elect/main.c
+			elect/main.c elect/dbus.c
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/elect/dbus.c b/elect/dbus.c
new file mode 100644
index 0000000..72da441
--- /dev/null
+++ b/elect/dbus.c
@@ -0,0 +1,52 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "elect.h"
+
+#define ELECT_ERROR_INTERFACE "org.ofono.elect.Error"
+
+DBusMessage *__elect_error_invalid_args(DBusMessage *msg)
+{
+	return g_dbus_create_error(msg, ELECT_ERROR_INTERFACE
+					".InvalidArguments",
+					"Invalid arguments in method call");
+}
+
+DBusMessage *__elect_error_failed(DBusMessage *msg)
+{
+	return g_dbus_create_error(msg, ELECT_ERROR_INTERFACE
+					".Failed",
+					"Operation failed");
+}
+
+DBusMessage *__elect_error_connection_refused(DBusMessage *msg)
+{
+	return g_dbus_create_error(msg, ELECT_ERROR_INTERFACE
+					".ConnectionRefused",
+					"Connection Refused");
+}
diff --git a/elect/elect.h b/elect/elect.h
index 8786240..7338c18 100644
--- a/elect/elect.h
+++ b/elect/elect.h
@@ -44,3 +44,7 @@ int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
 
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
+
+DBusMessage *__elect_error_invalid_args(DBusMessage *msg);
+DBusMessage *__elect_error_failed(DBusMessage *msg);
+DBusMessage *__elect_error_connection_refused(DBusMessage *msg);
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 03/16] elect: Add D-Bus configuration file
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 01/16] elect: Add skeleton implementation Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 02/16] elect: Add D-Bus error messages Daniel Wagner
@ 2011-12-13 14:59 ` Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 04/16] elect: Add systemd " Daniel Wagner
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am      |    6 ++++++
 elect/elect.conf |   23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 elect/elect.conf

diff --git a/Makefile.am b/Makefile.am
index 38e5d90..70ea5de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -657,6 +657,12 @@ elect_electd_SOURCES = $(gdbus_sources) \
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
+if DATAFILES
+
+dist_dbusconf_DATA += elect/elect.conf
+
+endif
+
 endif
 
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
diff --git a/elect/elect.conf b/elect/elect.conf
new file mode 100644
index 0000000..548ffe8
--- /dev/null
+++ b/elect/elect.conf
@@ -0,0 +1,23 @@
+<!-- This configuration file specifies the required security policies
+     for oFono elect (DUN) daemon to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+  <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+  <policy user="root">
+    <allow own="org.ofono.elect"/>
+    <allow send_destination="org.ofono.elect"/>
+  </policy>
+
+  <policy at_console="true">
+    <allow send_destination="org.ofono.elect"/>
+  </policy>
+
+  <policy context="default">
+    <deny send_destination="org.ofono.elect"/>
+  </policy>
+
+</busconfig>
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 04/16] elect: Add systemd configuration file
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (2 preceding siblings ...)
  2011-12-13 14:59 ` [RFC v3 03/16] elect: Add D-Bus configuration file Daniel Wagner
@ 2011-12-13 14:59 ` Daniel Wagner
  2011-12-13 14:59 ` [RFC v3 05/16] elect: Add Manager interface Daniel Wagner
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am         |    6 ++++++
 elect/elect.service |   11 +++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 elect/elect.service

diff --git a/Makefile.am b/Makefile.am
index 70ea5de..43311b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -661,6 +661,12 @@ if DATAFILES
 
 dist_dbusconf_DATA += elect/elect.conf
 
+if SYSTEMD
+systemdunitdir += @SYSTEMD_UNITDIR@
+
+systemdunit_DATA += elect/elect.service
+endif
+
 endif
 
 endif
diff --git a/elect/elect.service b/elect/elect.service
new file mode 100644
index 0000000..39d9349
--- /dev/null
+++ b/elect/elect.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=DUN service
+After=syslog.target
+
+[Service]
+Type=dbus
+BusName=org.ofono.elect
+ExecStart=/usr/sbin/electd -n
+
+[Install]
+WantedBy=multi-user.target
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 05/16] elect: Add Manager interface
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (3 preceding siblings ...)
  2011-12-13 14:59 ` [RFC v3 04/16] elect: Add systemd " Daniel Wagner
@ 2011-12-13 14:59 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 06/16] elect: Add skeleton implementation for device Daniel Wagner
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 14:59 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am     |    2 +-
 elect/elect.h   |    6 +++
 elect/main.c    |    9 ++---
 elect/manager.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 107 insertions(+), 7 deletions(-)
 create mode 100644 elect/manager.c

diff --git a/Makefile.am b/Makefile.am
index 43311b0..628cd0b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -653,7 +653,7 @@ sbin_PROGRAMS += elect/electd
 
 elect_electd_SOURCES = $(gdbus_sources) \
 			src/log.c src/dbus.c \
-			elect/main.c elect/dbus.c
+			elect/main.c elect/dbus.c elect/manager.c
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/elect/elect.h b/elect/elect.h
index 7338c18..8ecd694 100644
--- a/elect/elect.h
+++ b/elect/elect.h
@@ -39,6 +39,8 @@ void __ofono_log_enable(struct ofono_debug_desc *start,
 #include <ofono/dbus.h>
 
 #define ELECT_SERVICE			"org.ofono.elect"
+#define ELECT_MANAGER_INTERFACE		"org.ofono.elect.Manager"
+#define ELECT_MANAGER_PATH		"/"
 
 int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
@@ -48,3 +50,7 @@ void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
 DBusMessage *__elect_error_invalid_args(DBusMessage *msg);
 DBusMessage *__elect_error_failed(DBusMessage *msg);
 DBusMessage *__elect_error_connection_refused(DBusMessage *msg);
+
+
+int __elect_manager_init(void);
+void __elect_manager_cleanup(void);
diff --git a/elect/main.c b/elect/main.c
index 714f8c8..66c3ea9 100644
--- a/elect/main.c
+++ b/elect/main.c
@@ -232,15 +232,12 @@ int main(int argc, char **argv)
 
 	__ofono_dbus_init(conn);
 
-	/*
-	 * The reason why this DBG is here is that we have the __stop__debug,
-	 * __start__debug linking symbols in the object. As soon we
-	 * have real DBG we can remove this one again.
-	 */
-	DBG("");
+	__elect_manager_init();
 
 	g_main_loop_run(event_loop);
 
+	__elect_manager_cleanup();
+
 	__ofono_dbus_cleanup();
 	dbus_connection_unref(conn);
 
diff --git a/elect/manager.c b/elect/manager.c
new file mode 100644
index 0000000..65c8242
--- /dev/null
+++ b/elect/manager.c
@@ -0,0 +1,97 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <glib.h>
+#include <gdbus.h>
+
+#include "elect.h"
+
+static DBusMessage *manager_get_devices(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	DBusMessage *reply;
+	DBusMessageIter iter;
+	DBusMessageIter array;
+
+	DBG("");
+
+	reply = dbus_message_new_method_return(msg);
+	if (reply == NULL)
+		return NULL;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+					DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+					DBUS_TYPE_OBJECT_PATH_AS_STRING
+					DBUS_TYPE_ARRAY_AS_STRING
+					DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+					DBUS_TYPE_STRING_AS_STRING
+					DBUS_TYPE_VARIANT_AS_STRING
+					DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+					DBUS_STRUCT_END_CHAR_AS_STRING,
+					&array);
+
+	dbus_message_iter_close_container(&iter, &array);
+
+	return reply;
+}
+
+static GDBusMethodTable manager_methods[] = {
+	{ "GetDevices",          "",    "a(oa{sv})",  manager_get_devices },
+	{ }
+};
+
+static GDBusSignalTable manager_signals[] = {
+	{ "DeviceAdded",        "oa{sv}" },
+	{ "DeviceRemoved",      "o" },
+	{ }
+};
+
+int __elect_manager_init(void)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	gboolean ret;
+
+	ret = g_dbus_register_interface(conn, ELECT_MANAGER_PATH,
+					ELECT_MANAGER_INTERFACE,
+					manager_methods, manager_signals,
+					NULL, NULL, NULL);
+
+	if (ret == FALSE)
+		return -1;
+
+	return 0;
+}
+
+void __elect_manager_cleanup(void)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	g_dbus_unregister_interface(conn, ELECT_MANAGER_PATH,
+					ELECT_MANAGER_INTERFACE);
+}
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 06/16] elect: Add skeleton implementation for device
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (4 preceding siblings ...)
  2011-12-13 14:59 ` [RFC v3 05/16] elect: Add Manager interface Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 07/16] elect: Manager append devices Daniel Wagner
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am    |    2 +-
 elect/device.c |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 elect/elect.h  |   15 ++++++++
 elect/main.c   |    4 ++-
 4 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 elect/device.c

diff --git a/Makefile.am b/Makefile.am
index 628cd0b..cdeab8d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -653,7 +653,7 @@ sbin_PROGRAMS += elect/electd
 
 elect_electd_SOURCES = $(gdbus_sources) \
 			src/log.c src/dbus.c \
-			elect/main.c elect/dbus.c elect/manager.c
+			elect/main.c elect/dbus.c elect/manager.c elect/device.c
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/elect/device.c b/elect/device.c
new file mode 100644
index 0000000..1198083
--- /dev/null
+++ b/elect/device.c
@@ -0,0 +1,100 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <netinet/ether.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "elect.h"
+
+static GHashTable *device_hash;
+
+struct elect_device {
+};
+
+const char *__elect_device_get_path(struct elect_device *device)
+{
+	return "/";
+}
+
+void __elect_device_append_properties(struct elect_device *device,
+					DBusMessageIter *dict)
+{
+}
+
+void __elect_device_foreach(elect_device_foreach_func func, void *userdata)
+{
+	GHashTableIter iter;
+	gpointer key, value;
+
+	DBG("");
+
+	g_hash_table_iter_init(&iter, device_hash);
+
+	while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+		struct elect_device *device = value;
+
+		func(device, userdata);
+	}
+}
+
+static void destroy_device(gpointer user)
+{
+	struct elect_device *device = user;
+
+	g_free(device);
+}
+
+static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
+{
+}
+
+void __elect_device_shutdown(void)
+{
+	g_hash_table_foreach(device_hash, device_shutdown, NULL);
+
+	__elect_exit();
+}
+
+int __elect_device_init(void)
+{
+	DBG("");
+
+	device_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+						g_free, destroy_device);
+
+	return 0;
+}
+
+void __elect_device_cleanup(void)
+{
+	DBG("");
+
+	g_hash_table_destroy(device_hash);
+}
diff --git a/elect/elect.h b/elect/elect.h
index 8ecd694..3244a1e 100644
--- a/elect/elect.h
+++ b/elect/elect.h
@@ -54,3 +54,18 @@ DBusMessage *__elect_error_connection_refused(DBusMessage *msg);
 
 int __elect_manager_init(void);
 void __elect_manager_cleanup(void);
+
+
+struct elect_device;
+
+int __elect_device_init(void);
+void __elect_device_cleanup(void);
+void __elect_device_shutdown(void);
+
+typedef void (*elect_device_foreach_func)(struct elect_device *device,
+						void *data);
+void __elect_device_foreach(elect_device_foreach_func cb, void *userdata);
+
+const char *__elect_device_get_path(struct elect_device *device);
+void __elect_device_append_properties(struct elect_device *device,
+					DBusMessageIter *dict);
diff --git a/elect/main.c b/elect/main.c
index 66c3ea9..16303d5 100644
--- a/elect/main.c
+++ b/elect/main.c
@@ -80,7 +80,7 @@ static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
 			g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
 						quit_eventloop, NULL);
 
-			quit_eventloop(NULL);
+			__elect_device_shutdown();
 		}
 
 		__terminated = 1;
@@ -233,9 +233,11 @@ int main(int argc, char **argv)
 	__ofono_dbus_init(conn);
 
 	__elect_manager_init();
+	__elect_device_init();
 
 	g_main_loop_run(event_loop);
 
+	__elect_device_cleanup();
 	__elect_manager_cleanup();
 
 	__ofono_dbus_cleanup();
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 07/16] elect: Manager append devices
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (5 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 06/16] elect: Add skeleton implementation for device Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 08/16] bluetooth: Add Serial interface definition Daniel Wagner
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 elect/manager.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/elect/manager.c b/elect/manager.c
index 65c8242..99ad216 100644
--- a/elect/manager.c
+++ b/elect/manager.c
@@ -30,6 +30,26 @@
 
 #include "elect.h"
 
+static void append_device(struct elect_device *device, void *userdata)
+{
+	DBusMessageIter *array = userdata;
+	const char *path = __elect_device_get_path(device);
+	DBusMessageIter entry, dict;
+
+	dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
+						NULL, &entry);
+	dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
+					&path);
+	dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
+				OFONO_PROPERTIES_ARRAY_SIGNATURE,
+				&dict);
+
+	__elect_device_append_properties(device, &dict);
+
+	dbus_message_iter_close_container(&entry, &dict);
+	dbus_message_iter_close_container(array, &entry);
+}
+
 static DBusMessage *manager_get_devices(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -56,6 +76,8 @@ static DBusMessage *manager_get_devices(DBusConnection *conn,
 					DBUS_STRUCT_END_CHAR_AS_STRING,
 					&array);
 
+	__elect_device_foreach(append_device, &array);
+
 	dbus_message_iter_close_container(&iter, &array);
 
 	return reply;
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 08/16] bluetooth: Add Serial interface definition
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (6 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 07/16] elect: Manager append devices Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 09/16] elect: Add BlueZ hooks to device Daniel Wagner
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 plugins/bluetooth.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index daa1873..4fc16ad 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -27,6 +27,7 @@
 #define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
 #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
 #define	BLUEZ_SERVICE_INTERFACE		BLUEZ_SERVICE ".Service"
+#define BLUEZ_SERIAL_INTERFACE		BLUEZ_SERVICE ".Serial"
 
 #define DBUS_TIMEOUT 15
 
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 09/16] elect: Add BlueZ hooks to device
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (7 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 08/16] bluetooth: Add Serial interface definition Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 10/16] elect: Add device D-Bus interface Daniel Wagner
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am    |    4 +-
 elect/device.c |  141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 142 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cdeab8d..a11176e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -651,8 +651,8 @@ if ELECT
 
 sbin_PROGRAMS += elect/electd
 
-elect_electd_SOURCES = $(gdbus_sources) \
-			src/log.c src/dbus.c \
+elect_electd_SOURCES = $(gdbus_sources) $(btio_sources) \
+			src/log.c src/dbus.c plugins/bluetooth.c \
 			elect/main.c elect/dbus.c elect/manager.c elect/device.c
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/elect/device.c b/elect/device.c
index 1198083..13999fd 100644
--- a/elect/device.c
+++ b/elect/device.c
@@ -31,16 +31,28 @@
 #include <glib.h>
 #include <gdbus.h>
 
+#include "plugins/bluetooth.h"
+
 #include "elect.h"
 
+static int next_device_id = 0;
 static GHashTable *device_hash;
 
 struct elect_device {
+	/* The D-Bus path to this device */
+	char *elect_path;
+
+	/* BlueZ device information */
+	char *path;
+	char *address;
+	char *name;
+
+	DBusPendingCall *call;
 };
 
 const char *__elect_device_get_path(struct elect_device *device)
 {
-	return "/";
+	return  device->elect_path;
 }
 
 void __elect_device_append_properties(struct elect_device *device,
@@ -64,10 +76,129 @@ void __elect_device_foreach(elect_device_foreach_func func, void *userdata)
 	}
 }
 
+static int bt_probe(const char *path, const char *dev_addr,
+				const char *adapter_addr, const char *alias)
+{
+	struct elect_device *device;
+	char buf[256];
+
+	DBG("");
+
+	/* We already have this device in our hash, ignore */
+	if (g_hash_table_lookup(device_hash, path) != NULL)
+		return -EALREADY;
+
+	ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+			path, dev_addr, adapter_addr);
+
+	strcpy(buf, "dun/");
+	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+
+	device = g_try_new0(struct elect_device, 1);
+	if (device == 0) {
+		DBG("Failed to create device data structure");
+		return -ENOMEM;
+	}
+
+	DBG("%p", device);
+
+	device->elect_path = g_strdup_printf("/device%d", next_device_id);
+	if (device->elect_path == NULL)
+		goto free;
+
+	device->path = g_strdup(path);
+	if (device->path == NULL)
+		goto free;
+
+	device->address = g_strdup(dev_addr);
+	if (device->address == NULL)
+		goto free;
+
+	device->name = g_strdup(alias);
+	if (device->name == NULL)
+		goto free;
+
+	g_hash_table_insert(device_hash, g_strdup(path), device);
+
+	next_device_id += 1;
+
+	return 0;
+
+free:
+	g_free(device->path);
+	g_free(device->address);
+	g_free(device->name);
+	g_free(device->elect_path);
+	g_free(device);
+
+	return -ENOMEM;
+}
+
+static gboolean bt_remove_device(gpointer key, gpointer value,
+					gpointer user_data)
+{
+	struct elect_device *device = value;
+	const char *path = key;
+	const char *prefix = user_data;
+
+	DBG("%p", device);
+
+	if (device->call != NULL)
+		dbus_pending_call_cancel(device->call);
+
+	if (prefix && g_str_has_prefix(path, prefix) == FALSE)
+		return FALSE;
+
+	return TRUE;
+}
+
+static void bt_remove(const char *prefix)
+{
+	DBG("%s", prefix);
+
+	if (device_hash == NULL)
+		return;
+
+	g_hash_table_foreach_remove(device_hash, bt_remove_device,
+							(gpointer) prefix);
+}
+
+static void bt_set_alias(const char *path, const char *alias)
+{
+	struct elect_device *device;
+
+	DBG("");
+
+	if (path == NULL || alias == NULL)
+		return;
+
+	device = g_hash_table_lookup(device_hash, path);
+	if (device == NULL)
+		return;
+
+	g_free(device->name);
+	device->name = g_strdup(alias);
+}
+
+static struct bluetooth_profile dun_profile = {
+	.name		= "dun_dt",
+	.probe		= bt_probe,
+	.remove		= bt_remove,
+	.set_alias	= bt_set_alias,
+};
+
 static void destroy_device(gpointer user)
 {
 	struct elect_device *device = user;
 
+	if (device->call)
+		dbus_pending_call_cancel(device->call);
+
+	g_free(device->elect_path);
+	g_free(device->path);
+	g_free(device->address);
+	g_free(device->name);
+
 	g_free(device);
 }
 
@@ -84,8 +215,14 @@ void __elect_device_shutdown(void)
 
 int __elect_device_init(void)
 {
+	int err;
+
 	DBG("");
 
+	err = bluetooth_register_uuid(DUN_GW_UUID, &dun_profile);
+	if (err < 0)
+		return err;
+
 	device_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
 						g_free, destroy_device);
 
@@ -96,5 +233,7 @@ void __elect_device_cleanup(void)
 {
 	DBG("");
 
+	bluetooth_unregister_uuid(DUN_GW_UUID);
+
 	g_hash_table_destroy(device_hash);
 }
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 10/16] elect: Add device D-Bus interface
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (8 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 09/16] elect: Add BlueZ hooks to device Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 11/16] elect: Dis/Connect Serial interface Daniel Wagner
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 elect/device.c |  235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 elect/elect.h  |    1 +
 2 files changed, 236 insertions(+), 0 deletions(-)

diff --git a/elect/device.c b/elect/device.c
index 13999fd..f9a01fd 100644
--- a/elect/device.c
+++ b/elect/device.c
@@ -35,9 +35,17 @@
 
 #include "elect.h"
 
+#define STATIC_IP_NETMASK "255.255.255.255"
+
 static int next_device_id = 0;
 static GHashTable *device_hash;
 
+struct ipv4_settings {
+	char *interface;
+	char *ip;
+	char **nameservers;
+};
+
 struct elect_device {
 	/* The D-Bus path to this device */
 	char *elect_path;
@@ -47,6 +55,9 @@ struct elect_device {
 	char *address;
 	char *name;
 
+	gboolean active;
+	struct ipv4_settings settings;
+
 	DBusPendingCall *call;
 };
 
@@ -55,9 +66,84 @@ const char *__elect_device_get_path(struct elect_device *device)
 	return  device->elect_path;
 }
 
+static void settings_append(struct elect_device *device,
+					DBusMessageIter *iter)
+{
+	DBusMessageIter variant;
+	DBusMessageIter array;
+	char typesig[5];
+	char arraysig[6];
+	const char *method;
+	const char *netmask;
+
+	arraysig[0] = DBUS_TYPE_ARRAY;
+	arraysig[1] = typesig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
+	arraysig[2] = typesig[1] = DBUS_TYPE_STRING;
+	arraysig[3] = typesig[2] = DBUS_TYPE_VARIANT;
+	arraysig[4] = typesig[3] = DBUS_DICT_ENTRY_END_CHAR;
+	arraysig[5] = typesig[4] = '\0';
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
+						arraysig, &variant);
+
+	dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY,
+						typesig, &array);
+
+	if (device->active == FALSE)
+		goto out;
+
+	if (device->settings.interface)
+		ofono_dbus_dict_append(&array, "Interface",
+				DBUS_TYPE_STRING, &device->settings.interface);
+
+	method = "static";
+	ofono_dbus_dict_append(&array, "Method", DBUS_TYPE_STRING, &method);
+
+	if (device->settings.ip)
+		ofono_dbus_dict_append(&array, "Address", DBUS_TYPE_STRING,
+					&device->settings.ip);
+
+	netmask = STATIC_IP_NETMASK;
+	ofono_dbus_dict_append(&array, "Netmask", DBUS_TYPE_STRING,
+					&netmask);
+
+	if (device->settings.nameservers)
+		ofono_dbus_dict_append_array(&array, "DomainNameServers",
+						DBUS_TYPE_STRING,
+						&device->settings.nameservers);
+
+out:
+	dbus_message_iter_close_container(&variant, &array);
+
+	dbus_message_iter_close_container(iter, &variant);
+}
+
+static void settings_append_dict(struct elect_device *device,
+				DBusMessageIter *dict)
+{
+	DBusMessageIter entry;
+	const char *key = "Settings";
+
+	dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+						NULL, &entry);
+
+	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+	settings_append(device, &entry);
+
+	dbus_message_iter_close_container(dict, &entry);
+}
+
 void __elect_device_append_properties(struct elect_device *device,
 					DBusMessageIter *dict)
 {
+	settings_append_dict(device, dict);
+
+	ofono_dbus_dict_append(dict, "Active", DBUS_TYPE_BOOLEAN,
+				&device->active);
+
+	ofono_dbus_dict_append(dict, "Name", DBUS_TYPE_STRING,
+				&device->name);
 }
 
 void __elect_device_foreach(elect_device_foreach_func func, void *userdata)
@@ -76,6 +162,144 @@ void __elect_device_foreach(elect_device_foreach_func func, void *userdata)
 	}
 }
 
+static DBusMessage *device_get_properties(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	struct elect_device *device = 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);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+					OFONO_PROPERTIES_ARRAY_SIGNATURE,
+					&dict);
+
+	__elect_device_append_properties(device, &dict);
+
+	dbus_message_iter_close_container(&iter, &dict);
+
+	return reply;
+}
+
+static DBusMessage *set_property_active(struct elect_device *device,
+					DBusMessage *msg,
+					DBusMessageIter *var)
+{
+	ofono_bool_t active;
+
+	DBG("%p elect_path %s", device, device->elect_path);
+
+	if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN)
+		return __elect_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(var, &active);
+
+	device->active = active;
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *device_set_property(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	struct elect_device *device = data;
+	DBusMessageIter iter, var;
+	const char *name;
+
+	if (dbus_message_iter_init(msg, &iter) == FALSE)
+		return __elect_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+		return __elect_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(&iter, &name);
+	dbus_message_iter_next(&iter);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+		return __elect_error_invalid_args(msg);
+
+	dbus_message_iter_recurse(&iter, &var);
+
+	if (g_str_equal(name, "Active"))
+		return set_property_active(device, msg, &var);
+
+	return __elect_error_invalid_args(msg);
+}
+
+static GDBusMethodTable device_methods[] = {
+	{ "GetProperties",	"",	"a{sv}",	device_get_properties },
+	{ "SetProperty",	"sv",	"",		device_set_property,
+							G_DBUS_METHOD_FLAG_ASYNC },
+	{ }
+};
+
+static GDBusSignalTable device_signals[] = {
+	{ "PropertyChanged",	"sv" },
+	{ }
+};
+
+static int register_device(struct elect_device *device)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	DBusMessage *signal;
+	DBusMessageIter iter;
+	DBusMessageIter dict;
+
+	DBG("%p elect_path %s", device, device->elect_path);
+
+	if (!g_dbus_register_interface(conn, device->elect_path,
+					ELECT_DEVICE_INTERFACE,
+					device_methods, device_signals,
+					NULL, device, NULL)) {
+		ofono_error("Could not register Device %s", device->path);
+		return -EIO;
+	}
+
+	signal = dbus_message_new_signal(ELECT_MANAGER_PATH,
+						ELECT_MANAGER_INTERFACE,
+						"DeviceAdded");
+
+	if (signal == NULL)
+		return -ENOMEM;
+
+	dbus_message_iter_init_append(signal, &iter);
+
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+					&device->elect_path);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+					OFONO_PROPERTIES_ARRAY_SIGNATURE,
+					&dict);
+	__elect_device_append_properties(device, &dict);
+	dbus_message_iter_close_container(&iter, &dict);
+
+	g_dbus_send_message(conn, signal);
+
+	return 0;
+}
+
+static int unregister_device(struct elect_device *device)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	DBG("%p elect_path %s", device, device->elect_path);
+
+	g_dbus_unregister_interface(conn, device->elect_path,
+					ELECT_DEVICE_INTERFACE);
+
+	g_dbus_emit_signal(conn, ELECT_MANAGER_PATH,
+				ELECT_MANAGER_INTERFACE, "DeviceRemoved",
+				DBUS_TYPE_OBJECT_PATH, &device->elect_path,
+				DBUS_TYPE_INVALID);
+
+	return 0;
+}
+
 static int bt_probe(const char *path, const char *dev_addr,
 				const char *adapter_addr, const char *alias)
 {
@@ -120,6 +344,8 @@ static int bt_probe(const char *path, const char *dev_addr,
 
 	g_hash_table_insert(device_hash, g_strdup(path), device);
 
+	register_device(device);
+
 	next_device_id += 1;
 
 	return 0;
@@ -149,6 +375,8 @@ static gboolean bt_remove_device(gpointer key, gpointer value,
 	if (prefix && g_str_has_prefix(path, prefix) == FALSE)
 		return FALSE;
 
+	unregister_device(device);
+
 	return TRUE;
 }
 
@@ -194,6 +422,10 @@ static void destroy_device(gpointer user)
 	if (device->call)
 		dbus_pending_call_cancel(device->call);
 
+	g_free(device->settings.interface);
+	g_free(device->settings.ip);
+	g_strfreev(device->settings.nameservers);
+
 	g_free(device->elect_path);
 	g_free(device->path);
 	g_free(device->address);
@@ -204,6 +436,9 @@ static void destroy_device(gpointer user)
 
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
+	struct elect_device *device = value;
+
+	unregister_device(device);
 }
 
 void __elect_device_shutdown(void)
diff --git a/elect/elect.h b/elect/elect.h
index 3244a1e..b8cccda 100644
--- a/elect/elect.h
+++ b/elect/elect.h
@@ -40,6 +40,7 @@ void __ofono_log_enable(struct ofono_debug_desc *start,
 
 #define ELECT_SERVICE			"org.ofono.elect"
 #define ELECT_MANAGER_INTERFACE		"org.ofono.elect.Manager"
+#define ELECT_DEVICE_INTERFACE		"org.ofono.elect.Device"
 #define ELECT_MANAGER_PATH		"/"
 
 int __ofono_dbus_init(DBusConnection *conn);
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 11/16] elect: Dis/Connect Serial interface
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (9 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 10/16] elect: Add device D-Bus interface Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-15  0:56   ` Denis Kenzior
  2011-12-13 15:00 ` [RFC v3 12/16] elect: Add skeleton dial implementation Daniel Wagner
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 elect/device.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 122 insertions(+), 2 deletions(-)

diff --git a/elect/device.c b/elect/device.c
index f9a01fd..b404546 100644
--- a/elect/device.c
+++ b/elect/device.c
@@ -58,7 +58,10 @@ struct elect_device {
 	gboolean active;
 	struct ipv4_settings settings;
 
+	char *tty;
+
 	DBusPendingCall *call;
+	DBusMessage *pending;
 };
 
 const char *__elect_device_get_path(struct elect_device *device)
@@ -187,11 +190,116 @@ static DBusMessage *device_get_properties(DBusConnection *conn,
 	return reply;
 }
 
+static void bt_disconnect_reply(DBusPendingCall *call, gpointer user_data)
+{
+	struct elect_device *device = user_data;
+	DBusMessage *reply;
+
+	DBG("%p", device);
+
+	reply = dbus_pending_call_steal_reply(call);
+	dbus_message_unref(reply);
+
+	device->call = NULL;
+
+	g_free(device->tty);
+	device->tty = NULL;
+}
+
+static int bt_disconnect(struct elect_device *device)
+{
+	DBusPendingCall *call;
+	int status;
+
+	DBG("%p", device);
+
+	if (device->tty == NULL)
+		return 0;
+
+	status = bluetooth_send_with_reply(device->path,
+					BLUEZ_SERIAL_INTERFACE, "Disconnect",
+					&call, bt_disconnect_reply,
+					device, NULL, DBUS_TIMEOUT,
+					DBUS_TYPE_STRING, &device->tty,
+					DBUS_TYPE_INVALID);
+	if (status < 0)
+		return -EINVAL;
+
+	device->call = call;
+
+	return -EINPROGRESS;
+}
+
+static void bt_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+	struct elect_device *device = user_data;
+	DBusMessage *reply;
+	DBusError derr;
+	char *tty;
+
+	DBG("%p", device);
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	device->call = NULL;
+
+	dbus_error_init(&derr);
+	if (dbus_set_error_from_message(&derr, reply)) {
+		DBG("Connection to bt serial returned with error: %s, %s",
+						derr.name, derr.message);
+
+		dbus_error_free(&derr);
+		goto done;
+	}
+
+	dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &tty,
+			DBUS_TYPE_INVALID);
+
+	DBG("%p tty %s", device, tty);
+
+	device->tty = g_strdup(tty);
+
+done:
+	dbus_message_unref(reply);
+
+	if (device->tty != NULL)
+		reply = dbus_message_new_method_return(device->pending);
+	else
+		reply = __elect_error_failed(device->pending);
+
+	__ofono_dbus_pending_reply(&device->pending, reply);
+
+	device->pending = NULL;
+}
+
+static int bt_connect(struct elect_device *device)
+{
+	DBusPendingCall *call;
+	int status;
+	char *profile = "dun";
+
+	DBG("%p", device);
+
+	status = bluetooth_send_with_reply(device->path,
+					BLUEZ_SERIAL_INTERFACE, "Connect",
+					&call, bt_connect_reply,
+					device, NULL, DBUS_TIMEOUT,
+					DBUS_TYPE_STRING, &profile,
+					DBUS_TYPE_INVALID);
+	if (status < 0)
+		return -EINVAL;
+
+	device->call = call;
+
+	return -EINPROGRESS;
+}
+
 static DBusMessage *set_property_active(struct elect_device *device,
 					DBusMessage *msg,
 					DBusMessageIter *var)
 {
 	ofono_bool_t active;
+	int err;
 
 	DBG("%p elect_path %s", device, device->elect_path);
 
@@ -200,9 +308,17 @@ static DBusMessage *set_property_active(struct elect_device *device,
 
 	dbus_message_iter_get_basic(var, &active);
 
-	device->active = active;
+	if (active)
+		err = bt_connect(device);
+	else
+		err = bt_disconnect(device);
 
-	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+	if (err != -EINPROGRESS && err < 0)
+		return __elect_error_failed(msg);
+
+	device->pending = dbus_message_ref(msg);
+
+	return NULL;
 }
 
 static DBusMessage *device_set_property(DBusConnection *conn,
@@ -419,6 +535,9 @@ static void destroy_device(gpointer user)
 {
 	struct elect_device *device = user;
 
+	if (device->pending)
+		dbus_message_unref(device->pending);
+
 	if (device->call)
 		dbus_pending_call_cancel(device->call);
 
@@ -430,6 +549,7 @@ static void destroy_device(gpointer user)
 	g_free(device->path);
 	g_free(device->address);
 	g_free(device->name);
+	g_free(device->tty);
 
 	g_free(device);
 }
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 12/16] elect: Add skeleton dial implementation
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (10 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 11/16] elect: Dis/Connect Serial interface Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-15  1:15   ` Denis Kenzior
  2011-12-13 15:00 ` [RFC v3 13/16] elect: Add ppp callbacks to device Daniel Wagner
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am   |    3 +-
 elect/dial.c  |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 elect/elect.h |   16 +++++++++++
 3 files changed, 101 insertions(+), 1 deletions(-)
 create mode 100644 elect/dial.c

diff --git a/Makefile.am b/Makefile.am
index a11176e..588183d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -653,7 +653,8 @@ sbin_PROGRAMS += elect/electd
 
 elect_electd_SOURCES = $(gdbus_sources) $(btio_sources) \
 			src/log.c src/dbus.c plugins/bluetooth.c \
-			elect/main.c elect/dbus.c elect/manager.c elect/device.c
+			elect/main.c elect/dbus.c elect/manager.c elect/device.c \
+			elect/dial.c
 
 elect_electd_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/elect/dial.c b/elect/dial.c
new file mode 100644
index 0000000..6f83981
--- /dev/null
+++ b/elect/dial.c
@@ -0,0 +1,83 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+
+#include "elect.h"
+
+struct elect_dial {
+	char *path;
+	void *data;
+
+	elect_dial_connect_cb_t connect_cb;
+	elect_dial_disconnect_cb_t disconnect_cb;
+};
+
+struct elect_dial *__elect_dial_create(elect_dial_connect_cb_t connect_cb,
+				elect_dial_disconnect_cb_t disconnect_cb,
+				void *data)
+{
+	struct elect_dial *dial;
+
+	DBG("");
+
+	dial = g_try_new0(struct elect_dial, 1);
+	if (dial == NULL)
+		return NULL;
+
+	dial->data = data;
+
+	dial->connect_cb = connect_cb;
+	dial->disconnect_cb = disconnect_cb;
+
+	return dial;
+}
+
+int __elect_dial_connect(struct elect_dial *dial, const char *path)
+{
+	DBG("%s", dial->path);
+
+	g_free(dial->path);
+	dial->path = g_strdup(path);	
+
+	return 0;
+}
+
+int __elect_dial_disconnect(struct elect_dial *dial)
+{
+	DBG("%s", dial->path);
+
+	return 0;
+}
+
+void __elect_dial_unref(struct elect_dial *dial)
+{
+	DBG("%s", dial->path);
+
+	g_free(dial->path);
+
+	g_free(dial);
+}
diff --git a/elect/elect.h b/elect/elect.h
index b8cccda..e79acf7 100644
--- a/elect/elect.h
+++ b/elect/elect.h
@@ -70,3 +70,19 @@ void __elect_device_foreach(elect_device_foreach_func cb, void *userdata);
 const char *__elect_device_get_path(struct elect_device *device);
 void __elect_device_append_properties(struct elect_device *device,
 					DBusMessageIter *dict);
+
+
+struct elect_dial;
+
+typedef void (*elect_dial_connect_cb_t)(const char *interface, const char *ip,
+				const char *peer,
+				const char *dns1, const char *dns2,
+				void *data);
+typedef void (*elect_dial_disconnect_cb_t)(void *data);
+
+struct elect_dial *__elect_dial_create(elect_dial_connect_cb_t connect_cb,
+				elect_dial_disconnect_cb_t disconnect_cb,
+				void *data);
+int __elect_dial_connect(struct elect_dial *dial, const char *path);
+int __elect_dial_disconnect(struct elect_dial *dial);
+void __elect_dial_unref(struct elect_dial *dial);
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 13/16] elect: Add ppp callbacks to device
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (11 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 12/16] elect: Add skeleton dial implementation Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 14/16] elect: Add GatChat and PPP handler Daniel Wagner
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 elect/device.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/elect/device.c b/elect/device.c
index b404546..b4cbbfc 100644
--- a/elect/device.c
+++ b/elect/device.c
@@ -59,6 +59,7 @@ struct elect_device {
 	struct ipv4_settings settings;
 
 	char *tty;
+	struct elect_dial *dial;
 
 	DBusPendingCall *call;
 	DBusMessage *pending;
@@ -165,6 +166,27 @@ void __elect_device_foreach(elect_device_foreach_func func, void *userdata)
 	}
 }
 
+static void settings_changed(struct elect_device *device)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	DBusMessage *signal;
+	DBusMessageIter iter;
+	const char *key = "Settings";
+
+	signal = dbus_message_new_signal(device->elect_path,
+					ELECT_DEVICE_INTERFACE,
+					"PropertyChanged");
+
+	if (signal == NULL)
+		return;
+	dbus_message_iter_init_append(signal, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key);
+
+	settings_append(device, &iter);
+
+	g_dbus_send_message(conn, signal);
+}
+
 static DBusMessage *device_get_properties(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -230,6 +252,73 @@ static int bt_disconnect(struct elect_device *device)
 	return -EINPROGRESS;
 }
 
+static void disconnect_cb(void *data)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	struct elect_device *device = data;
+
+	DBG("%p", device);
+
+	g_free(device->settings.interface);
+	g_free(device->settings.ip);
+	g_strfreev(device->settings.nameservers);
+	device->settings.interface = NULL;
+	device->settings.ip = NULL;
+	device->settings.nameservers = NULL;
+
+	device->active = FALSE;
+
+	settings_changed(device);
+	ofono_dbus_signal_property_changed(conn, device->elect_path,
+					ELECT_DEVICE_INTERFACE, "Active",
+					DBUS_TYPE_BOOLEAN, &device->active);
+
+	bt_disconnect(device);
+}
+
+static void connect_cb(const char *interface, const char *ip,
+			const char *peer, const char *dns1, const char *dns2,
+			void *data)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	struct elect_device *device = data;
+	const char *dns[3] = { dns1, dns2, 0 };
+
+	DBG("%p", device);
+
+	g_free(device->settings.interface);
+	device->settings.interface = g_strdup(interface);
+	if (device->settings.interface == NULL)
+		goto err;
+
+	g_free(device->settings.ip);
+	device->settings.ip = g_strdup(ip);
+	if (device->settings.ip == NULL)
+		goto err;
+
+	g_strfreev(device->settings.nameservers);
+	device->settings.nameservers = g_strdupv((gchar **)dns);
+	if (device->settings.nameservers == NULL)
+		goto err;
+
+	device->active = TRUE;
+
+	settings_changed(device);
+	ofono_dbus_signal_property_changed(conn, device->elect_path,
+					ELECT_DEVICE_INTERFACE, "Active",
+					DBUS_TYPE_BOOLEAN, &device->active);
+
+	return;
+
+err:
+	g_free(device->settings.interface);
+	g_free(device->settings.ip);
+	g_strfreev(device->settings.nameservers);
+	device->settings.interface = NULL;
+	device->settings.ip = NULL;
+	device->settings.nameservers = NULL;
+}
+
 static void bt_connect_reply(DBusPendingCall *call, gpointer user_data)
 {
 	struct elect_device *device = user_data;
@@ -258,6 +347,10 @@ static void bt_connect_reply(DBusPendingCall *call, gpointer user_data)
 	DBG("%p tty %s", device, tty);
 
 	device->tty = g_strdup(tty);
+	if (device->tty == NULL)
+		goto done;
+
+	__elect_dial_connect(device->dial, device->tty);
 
 done:
 	dbus_message_unref(reply);
@@ -458,6 +551,10 @@ static int bt_probe(const char *path, const char *dev_addr,
 	if (device->name == NULL)
 		goto free;
 
+	device->dial = __elect_dial_create(connect_cb, disconnect_cb, device);
+	if (device->dial == NULL)
+		goto free;
+
 	g_hash_table_insert(device_hash, g_strdup(path), device);
 
 	register_device(device);
@@ -488,6 +585,9 @@ static gboolean bt_remove_device(gpointer key, gpointer value,
 	if (device->call != NULL)
 		dbus_pending_call_cancel(device->call);
 
+	if (device->dial != NULL)
+		__elect_dial_unref(device->dial);
+
 	if (prefix && g_str_has_prefix(path, prefix) == FALSE)
 		return FALSE;
 
@@ -541,6 +641,9 @@ static void destroy_device(gpointer user)
 	if (device->call)
 		dbus_pending_call_cancel(device->call);
 
+	if (device->dial)
+		__elect_dial_unref(device->dial);
+
 	g_free(device->settings.interface);
 	g_free(device->settings.ip);
 	g_strfreev(device->settings.nameservers);
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 14/16] elect: Add GatChat and PPP handler
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (12 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 13/16] elect: Add ppp callbacks to device Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-15  1:20   ` Denis Kenzior
  2011-12-13 15:00 ` [RFC v3 15/16] elect: Add test scripts Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 16/16] elect: Add documentation Daniel Wagner
  15 siblings, 1 reply; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 Makefile.am  |    2 +-
 elect/dial.c |  125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 588183d..f39035f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -651,7 +651,7 @@ if ELECT
 
 sbin_PROGRAMS += elect/electd
 
-elect_electd_SOURCES = $(gdbus_sources) $(btio_sources) \
+elect_electd_SOURCES = $(gdbus_sources) $(btio_sources) $(gatchat_sources) \
 			src/log.c src/dbus.c plugins/bluetooth.c \
 			elect/main.c elect/dbus.c elect/manager.c elect/device.c \
 			elect/dial.c
diff --git a/elect/dial.c b/elect/dial.c
index 6f83981..01ff4c2 100644
--- a/elect/dial.c
+++ b/elect/dial.c
@@ -24,18 +24,122 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <glib.h>
 
+#include <gatchat.h>
+#include <gattty.h>
+#include <gatppp.h>
+
 #include "elect.h"
 
+static const char *none_prefix[] = { NULL };
+
 struct elect_dial {
 	char *path;
 	void *data;
 
+	GAtPPP *ppp;
+	GAtChat *chat;
+
 	elect_dial_connect_cb_t connect_cb;
 	elect_dial_disconnect_cb_t disconnect_cb;
 };
 
+static void dial_debug(const char *str, void *data)
+{
+	DBG("%s: %s\n", (const char *) data, str);
+}
+
+static void ppp_connect(const char *iface, const char *local, const char *peer,
+			const char *dns1, const char *dns2,
+			gpointer user_data)
+{
+	struct elect_dial *dial = user_data;
+
+	DBG("Network Device: %s\n", iface);
+	DBG("IP Address: %s\n", local);
+	DBG("Peer IP Address: %s\n", peer);
+	DBG("Primary DNS Server: %s\n", dns1);
+	DBG("Secondary DNS Server: %s\n", dns2);
+
+	if (dial->connect_cb)
+		dial->connect_cb(iface, local, peer, dns1, dns2, dial->data);
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+	struct elect_dial *dial = user_data;
+
+	DBG("PPP Link down: %d\n", reason);
+
+	g_at_ppp_unref(dial->ppp);
+	dial->ppp = NULL;
+
+	g_at_chat_resume(dial->chat);
+
+	if (dial->disconnect_cb)
+		dial->disconnect_cb(dial->data);
+}
+
+static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct elect_dial *dial = user_data;
+	GAtIO *io;
+
+	if (!ok) {
+		DBG("Unable to define context\n");
+		return;
+	}
+
+	/* get the data IO channel */
+	io = g_at_chat_get_io(dial->chat);
+
+	/*
+	 * shutdown gatchat or else it tries to take all the input
+	 * from the modem and does not let PPP get it.
+	 */
+	g_at_chat_suspend(dial->chat);
+
+	/* open ppp */
+	dial->ppp = g_at_ppp_new();
+	if (dial->ppp == NULL) {
+		DBG("Unable to create PPP object\n");
+		return;
+	}
+	g_at_ppp_set_debug(dial->ppp, dial_debug, "PPP");
+
+	/* set connect and disconnect callbacks */
+	g_at_ppp_set_connect_function(dial->ppp, ppp_connect, dial);
+	g_at_ppp_set_disconnect_function(dial->ppp, ppp_disconnect, dial);
+
+	/* open the ppp connection */
+	g_at_ppp_open(dial->ppp, io);
+}
+
+static int open_serial(struct elect_dial *dial)
+{
+	GAtSyntax *syntax;
+	GIOChannel *channel;
+
+	channel = g_at_tty_open(dial->path, NULL);
+	if (channel == NULL)
+		return -EIO;
+
+	syntax = g_at_syntax_new_gsm_permissive();
+	dial->chat = g_at_chat_new(channel, syntax);
+	g_io_channel_unref(channel);
+	g_at_syntax_unref(syntax);
+
+	if (dial->chat == NULL)
+		return -EIO;
+
+	g_at_chat_set_debug(dial->chat, dial_debug, "Control");
+
+	return 0;
+}
+
 struct elect_dial *__elect_dial_create(elect_dial_connect_cb_t connect_cb,
 				elect_dial_disconnect_cb_t disconnect_cb,
 				void *data)
@@ -58,11 +162,19 @@ struct elect_dial *__elect_dial_create(elect_dial_connect_cb_t connect_cb,
 
 int __elect_dial_connect(struct elect_dial *dial, const char *path)
 {
+	int err;
 	DBG("%s", dial->path);
 
 	g_free(dial->path);
 	dial->path = g_strdup(path);	
 
+	err = open_serial(dial);
+	if (err < 0)
+		return err;
+
+	g_at_chat_send(dial->chat, "ATD*99#", none_prefix, connect_cb,
+		dial, NULL);
+
 	return 0;
 }
 
@@ -70,12 +182,23 @@ int __elect_dial_disconnect(struct elect_dial *dial)
 {
 	DBG("%s", dial->path);
 
+	if (dial->ppp == NULL)
+		return -EINVAL;
+
+	g_at_ppp_suspend(dial->ppp);
+
 	return 0;
 }
 
 void __elect_dial_unref(struct elect_dial *dial)
 {
-	DBG("%s", dial->path);
+	DBG("");
+
+	if (dial->chat != NULL)
+		g_at_chat_unref(dial->chat);
+
+	if (dial->ppp != NULL)
+		g_at_ppp_unref(dial->ppp);
 
 	g_free(dial->path);
 
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 15/16] elect: Add test scripts
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (13 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 14/16] elect: Add GatChat and PPP handler Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-13 15:00 ` [RFC v3 16/16] elect: Add documentation Daniel Wagner
  15 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 test/elect-connect    |   20 +++++++++
 test/elect-disconnect |   20 +++++++++
 test/monitor-elect    |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100755 test/elect-connect
 create mode 100755 test/elect-disconnect
 create mode 100755 test/monitor-elect

diff --git a/test/elect-connect b/test/elect-connect
new file mode 100755
index 0000000..09e592e
--- /dev/null
+++ b/test/elect-connect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+	path = sys.argv[1]
+else:
+	manager = dbus.Interface(bus.get_object('org.ofono.elect', '/'),
+			'org.ofono.elect.Manager')
+	devices = manager.GetDevices()
+	path = devices[0][0]
+
+print "Connect device %s..." % path
+device = dbus.Interface(bus.get_object('org.ofono.elect', path),
+						'org.ofono.elect.Device')
+
+device.Connect()
diff --git a/test/elect-disconnect b/test/elect-disconnect
new file mode 100755
index 0000000..76ff74c
--- /dev/null
+++ b/test/elect-disconnect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+	path = sys.argv[1]
+else:
+	manager = dbus.Interface(bus.get_object('org.ofono.elect', '/'),
+			'org.ofono.elect.Manager')
+	devices = manager.GetDevices()
+	path = devices[0][0]
+
+print "Disonnect device %s..." % path
+device = dbus.Interface(bus.get_object('org.ofono.elect', path),
+						'org.ofono.elect.Device')
+
+device.Disconnect()
diff --git a/test/monitor-elect b/test/monitor-elect
new file mode 100755
index 0000000..684f5e3
--- /dev/null
+++ b/test/monitor-elect
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+_dbus2py = {
+	dbus.String : unicode,
+	dbus.UInt32 : int,
+	dbus.Int32 : int,
+	dbus.Int16 : int,
+	dbus.UInt16 : int,
+	dbus.UInt64 : int,
+	dbus.Int64 : int,
+	dbus.Byte : int,
+	dbus.Boolean : bool,
+	dbus.ByteArray : str,
+	dbus.ObjectPath : str
+    }
+
+def dbus2py(d):
+	t = type(d)
+	if t in _dbus2py:
+		return _dbus2py[t](d)
+	if t is dbus.Dictionary:
+		return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
+	if t is dbus.Array and d.signature == "y":
+		return "".join([chr(b) for b in d])
+	if t is dbus.Array or t is list:
+		return [dbus2py(v) for v in d]
+	if t is dbus.Struct or t is tuple:
+		return tuple([dbus2py(v) for v in d])
+	return d
+
+def pretty(d):
+	d = dbus2py(d)
+	t = type(d)
+
+	if t in (dict, tuple, list) and len(d) > 0:
+		if t is dict:
+			d = ", ".join(["%s = %s" % (k, pretty(v))
+					for k, v in d.items()])
+			return "{ %s }" % d
+
+		d = " ".join([pretty(e) for e in d])
+
+		if t is tuple:
+			return "( %s )" % d
+
+	return str(d)
+
+def property_changed(name, value, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value))
+
+def added(name, value, member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s %s" % (iface, member, name, pretty(value))
+
+def removed(name, member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s" % (iface, member, name)
+
+def event(member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s" % (iface, path, member)
+
+def message(msg, args, member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s %s (%s)" % (iface, path, member,
+					str(msg), pretty(args))
+
+def ussd(msg, member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s %s" % (iface, path, member, str(msg))
+
+def value(value, member, path, interface):
+	iface = interface[interface.rfind(".") + 1:]
+	print "{%s} [%s] %s %s" % (iface, path, member, str(value))
+
+if __name__ == '__main__':
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+	bus = dbus.SystemBus()
+
+	bus.add_signal_receiver(property_changed,
+					bus_name="org.ofono.elect",
+					signal_name = "PropertyChanged",
+						path_keyword="path",
+						interface_keyword="interface")
+
+	bus.add_signal_receiver(added,
+					bus_name="org.ofono.elect",
+					signal_name = "DeviceAdded",
+						member_keyword="member",
+						path_keyword="path",
+						interface_keyword="interface")
+
+	bus.add_signal_receiver(removed,
+					bus_name="org.ofono.elect",
+					signal_name = "DeviceRemoved",
+						member_keyword="member",
+						path_keyword="path",
+						interface_keyword="interface")
+
+
+	mainloop = gobject.MainLoop()
+	mainloop.run()
-- 
1.7.8.110.g4cb5d1


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

* [RFC v3 16/16] elect: Add documentation
  2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
                   ` (14 preceding siblings ...)
  2011-12-13 15:00 ` [RFC v3 15/16] elect: Add test scripts Daniel Wagner
@ 2011-12-13 15:00 ` Daniel Wagner
  2011-12-15  1:10   ` Denis Kenzior
  15 siblings, 1 reply; 23+ messages in thread
From: Daniel Wagner @ 2011-12-13 15:00 UTC (permalink / raw)
  To: ofono

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

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

---
 doc/elect-api.txt |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 doc/elect-api.txt

diff --git a/doc/elect-api.txt b/doc/elect-api.txt
new file mode 100644
index 0000000..a603266
--- /dev/null
+++ b/doc/elect-api.txt
@@ -0,0 +1,86 @@
+
+Manager hierarchy
+=================
+
+Service		org.ofono.elect
+Interface	org.ofono.elect.Manager
+Object path	/
+
+Methods		array{object,dict} GetDevices()
+
+			Get an array of device objects and properties
+			that represent the currently attached devices.
+
+			This method call should only be used once when an
+			application starts up. Further device additions
+			and removal shall be monitored via DeviceAdded and
+			DeviceRemoved signals.
+
+Signals		DeviceAdded(object path, dict properties)
+
+			Signal that is sent when a new device is added.  It
+			contains the object path of new device and its
+			properties.
+
+		DeviceRemoved(object path)
+
+			Signal that is sent when a device has been removed.
+			The object path is no longer accessible after this
+			signal and only emitted for reference.
+
+
+Device hierarchy
+================
+
+Service		org.ofono.elect
+Interface	org.ofono.elect.Device
+Object path	/{device0,device1,...}
+
+Methods		dict GetProperties()
+
+			Returns properties for the device object. See
+			the properties section for available properties.
+
+Signals		PropertyChanged(string name, variant value)
+
+			This signal indicates a changed value of the given
+			property.
+
+Properties	string Name [readonly]
+
+			Friendly name of the device.
+
+		boolean Active [readwrite]
+
+			Holds whether the device is connected. A
+			connection will be established when this value
+			is set to true. A existing connection will be
+			teared down when set to false.
+
+		dict Settings [readonly]
+
+			Holds all the IP network settings.
+
+			string Interface [readonly, optional]
+
+				Holds the interface of the network interface
+				used by this connection (e.g. "ppp0" "usb0")
+
+			string Method [readonly, optional]
+
+				Holds the IP network config method.
+					"static"- Set IP network statically
+					"dhcp"  - Set IP network through DHCP
+
+			string Address [readonly, optional]
+
+				Holds the IP address for this connection.
+
+			string Netmask [readonly, optional]
+
+				Holds the Netmask for this connection.
+
+			array{string} DomainNameServers [readonly, optional]
+
+				Holds the list of domain name servers for this
+				connection.
-- 
1.7.8.110.g4cb5d1


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

* Re: [RFC v3 11/16] elect: Dis/Connect Serial interface
  2011-12-13 15:00 ` [RFC v3 11/16] elect: Dis/Connect Serial interface Daniel Wagner
@ 2011-12-15  0:56   ` Denis Kenzior
  0 siblings, 0 replies; 23+ messages in thread
From: Denis Kenzior @ 2011-12-15  0:56 UTC (permalink / raw)
  To: ofono

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

Hi Daniel,

On 12/13/2011 09:00 AM, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> ---
>  elect/device.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 122 insertions(+), 2 deletions(-)
> 

Just taking a very cursory initial look:

<snip>

> +	status = bluetooth_send_with_reply(device->path,
> +					BLUEZ_SERIAL_INTERFACE, "Connect",
> +					&call, bt_connect_reply,
> +					device, NULL, DBUS_TIMEOUT,
> +					DBUS_TYPE_STRING, &profile,
> +					DBUS_TYPE_INVALID);

I still say you don't want to use the RFCOMM tty layer.  You should
probably use ConnectFD instead.

Also, the details of establishing a transport connection should ideally
be abstracted away and implemented in plugins.  That way you can easily
add bluetooth and usb, as well as whatever makes things easier for
testing, e.g. tcp or evel local pseudo-ttys.

Regards,
-Denis

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

* Re: [RFC v3 16/16] elect: Add documentation
  2011-12-13 15:00 ` [RFC v3 16/16] elect: Add documentation Daniel Wagner
@ 2011-12-15  1:10   ` Denis Kenzior
  2011-12-16  8:44     ` Daniel Wagner
  0 siblings, 1 reply; 23+ messages in thread
From: Denis Kenzior @ 2011-12-15  1:10 UTC (permalink / raw)
  To: ofono

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

Hi Daniel,

On 12/13/2011 09:00 AM, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> ---
>  doc/elect-api.txt |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 86 insertions(+), 0 deletions(-)
>  create mode 100644 doc/elect-api.txt

Logically this patch should probably be amongst the first, not dead last ;)

> 
> diff --git a/doc/elect-api.txt b/doc/elect-api.txt
> new file mode 100644
> index 0000000..a603266
> --- /dev/null
> +++ b/doc/elect-api.txt
> @@ -0,0 +1,86 @@
> +
> +Manager hierarchy
> +=================
> +
> +Service		org.ofono.elect
> +Interface	org.ofono.elect.Manager

Any particular reason why the project is named 'elect'?

> +Object path	/
> +
> +Methods		array{object,dict} GetDevices()
> +
> +			Get an array of device objects and properties
> +			that represent the currently attached devices.
> +
> +			This method call should only be used once when an
> +			application starts up. Further device additions
> +			and removal shall be monitored via DeviceAdded and
> +			DeviceRemoved signals.
> +
> +Signals		DeviceAdded(object path, dict properties)
> +
> +			Signal that is sent when a new device is added.  It
> +			contains the object path of new device and its
> +			properties.
> +
> +		DeviceRemoved(object path)
> +
> +			Signal that is sent when a device has been removed.
> +			The object path is no longer accessible after this
> +			signal and only emitted for reference.
> +
> +
> +Device hierarchy
> +================
> +
> +Service		org.ofono.elect
> +Interface	org.ofono.elect.Device
> +Object path	/{device0,device1,...}
> +
> +Methods		dict GetProperties()
> +
> +			Returns properties for the device object. See
> +			the properties section for available properties.
> +
> +Signals		PropertyChanged(string name, variant value)
> +
> +			This signal indicates a changed value of the given
> +			property.
> +
> +Properties	string Name [readonly]
> +
> +			Friendly name of the device.
> +
> +		boolean Active [readwrite]
> +
> +			Holds whether the device is connected. A
> +			connection will be established when this value
> +			is set to true. A existing connection will be
> +			teared down when set to false.
> +
> +		dict Settings [readonly]
> +
> +			Holds all the IP network settings.
> +
> +			string Interface [readonly, optional]
> +
> +				Holds the interface of the network interface
> +				used by this connection (e.g. "ppp0" "usb0")
> +
> +			string Method [readonly, optional]
> +
> +				Holds the IP network config method.
> +					"static"- Set IP network statically
> +					"dhcp"  - Set IP network through DHCP

Actually you should remove this, there is no dhcp configuration with
PPP; it will always be static.

> +
> +			string Address [readonly, optional]
> +
> +				Holds the IP address for this connection.
> +
> +			string Netmask [readonly, optional]
> +
> +				Holds the Netmask for this connection.

Likely this will always be the same value (e.g. point to point netmask).
 Whether you want to still include this is up to you.

> +
> +			array{string} DomainNameServers [readonly, optional]
> +
> +				Holds the list of domain name servers for this
> +				connection.

The obvious part that is missing is the dial string, but I guess you are
leaving it out on purpose for now...

Regards,
-Denis

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

* Re: [RFC v3 12/16] elect: Add skeleton dial implementation
  2011-12-13 15:00 ` [RFC v3 12/16] elect: Add skeleton dial implementation Daniel Wagner
@ 2011-12-15  1:15   ` Denis Kenzior
  0 siblings, 0 replies; 23+ messages in thread
From: Denis Kenzior @ 2011-12-15  1:15 UTC (permalink / raw)
  To: ofono

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

Hi Daniel,

On 12/13/2011 09:00 AM, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> ---
>  Makefile.am   |    3 +-
>  elect/dial.c  |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  elect/elect.h |   16 +++++++++++
>  3 files changed, 101 insertions(+), 1 deletions(-)
>  create mode 100644 elect/dial.c
> 

Personally I'm having trouble seeing what this abstraction is really
buying you.  There's really only one way to establish a PPP connection,
so much of this file is just overhead and can easily live inside
device.c.  But maybe I am missing something here...

Regards,
-Denis

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

* Re: [RFC v3 14/16] elect: Add GatChat and PPP handler
  2011-12-13 15:00 ` [RFC v3 14/16] elect: Add GatChat and PPP handler Daniel Wagner
@ 2011-12-15  1:20   ` Denis Kenzior
  0 siblings, 0 replies; 23+ messages in thread
From: Denis Kenzior @ 2011-12-15  1:20 UTC (permalink / raw)
  To: ofono

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

Hi Daniel,

On 12/13/2011 09:00 AM, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> ---
>  Makefile.am  |    2 +-
>  elect/dial.c |  125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 125 insertions(+), 2 deletions(-)
> 

<snip>

> +static int open_serial(struct elect_dial *dial)
> +{
> +	GAtSyntax *syntax;
> +	GIOChannel *channel;
> +
> +	channel = g_at_tty_open(dial->path, NULL);
> +	if (channel == NULL)
> +		return -EIO;
> +
> +	syntax = g_at_syntax_new_gsm_permissive();
> +	dial->chat = g_at_chat_new(channel, syntax);
> +	g_io_channel_unref(channel);
> +	g_at_syntax_unref(syntax);
> +
> +	if (dial->chat == NULL)
> +		return -EIO;
> +
> +	g_at_chat_set_debug(dial->chat, dial_debug, "Control");
> +
> +	return 0;
> +}
> +

This is another case where the setup of the transport is really breaking
your abstractions.  While this might work for RFCOMM ttys which are just
fake ttys (e.g. no serial options, etc) this won't work for real ttys.
You really need to abstract this part and let the plugins setup the
transports.  Ideally the core should receive a fully set-up file
descriptor and take it from there.

See src/emulator.c inside oFono for some ideas.

Regards,
-Denis

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

* Re: [RFC v3 16/16] elect: Add documentation
  2011-12-15  1:10   ` Denis Kenzior
@ 2011-12-16  8:44     ` Daniel Wagner
  2011-12-16  9:40       ` Marcel Holtmann
  0 siblings, 1 reply; 23+ messages in thread
From: Daniel Wagner @ 2011-12-16  8:44 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

On 15.12.2011 02:10, Denis Kenzior wrote:
>> +Service		org.ofono.elect
>> +Interface	org.ofono.elect.Manager
> 
> Any particular reason why the project is named 'elect'?

No particular reason. I needed a name. dund was already taken. Since DUN
stands for dialup network, I thouhgt "dial up" is like choosing
something. choosed was too long for my choice, therefore a tried it with
a synonym. But I am not particular found of this one. It is a working
title so to speak.

I saw the discussion on IRC. Do we have an agreement on the name now? Is
it "dundee"?

cheers,
daniel

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

* Re: [RFC v3 16/16] elect: Add documentation
  2011-12-16  8:44     ` Daniel Wagner
@ 2011-12-16  9:40       ` Marcel Holtmann
  0 siblings, 0 replies; 23+ messages in thread
From: Marcel Holtmann @ 2011-12-16  9:40 UTC (permalink / raw)
  To: ofono

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

Hi Daniel,

> On 15.12.2011 02:10, Denis Kenzior wrote:
> >> +Service		org.ofono.elect
> >> +Interface	org.ofono.elect.Manager
> > 
> > Any particular reason why the project is named 'elect'?
> 
> No particular reason. I needed a name. dund was already taken. Since DUN
> stands for dialup network, I thouhgt "dial up" is like choosing
> something. choosed was too long for my choice, therefore a tried it with
> a synonym. But I am not particular found of this one. It is a working
> title so to speak.
> 
> I saw the discussion on IRC. Do we have an agreement on the name now? Is
> it "dundee"?

I am all for dundee. That one is actually pretty funny.

Regards

Marcel



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

end of thread, other threads:[~2011-12-16  9:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-13 14:59 [RFC v3 00/16] Add DUN support Daniel Wagner
2011-12-13 14:59 ` [RFC v3 01/16] elect: Add skeleton implementation Daniel Wagner
2011-12-13 14:59 ` [RFC v3 02/16] elect: Add D-Bus error messages Daniel Wagner
2011-12-13 14:59 ` [RFC v3 03/16] elect: Add D-Bus configuration file Daniel Wagner
2011-12-13 14:59 ` [RFC v3 04/16] elect: Add systemd " Daniel Wagner
2011-12-13 14:59 ` [RFC v3 05/16] elect: Add Manager interface Daniel Wagner
2011-12-13 15:00 ` [RFC v3 06/16] elect: Add skeleton implementation for device Daniel Wagner
2011-12-13 15:00 ` [RFC v3 07/16] elect: Manager append devices Daniel Wagner
2011-12-13 15:00 ` [RFC v3 08/16] bluetooth: Add Serial interface definition Daniel Wagner
2011-12-13 15:00 ` [RFC v3 09/16] elect: Add BlueZ hooks to device Daniel Wagner
2011-12-13 15:00 ` [RFC v3 10/16] elect: Add device D-Bus interface Daniel Wagner
2011-12-13 15:00 ` [RFC v3 11/16] elect: Dis/Connect Serial interface Daniel Wagner
2011-12-15  0:56   ` Denis Kenzior
2011-12-13 15:00 ` [RFC v3 12/16] elect: Add skeleton dial implementation Daniel Wagner
2011-12-15  1:15   ` Denis Kenzior
2011-12-13 15:00 ` [RFC v3 13/16] elect: Add ppp callbacks to device Daniel Wagner
2011-12-13 15:00 ` [RFC v3 14/16] elect: Add GatChat and PPP handler Daniel Wagner
2011-12-15  1:20   ` Denis Kenzior
2011-12-13 15:00 ` [RFC v3 15/16] elect: Add test scripts Daniel Wagner
2011-12-13 15:00 ` [RFC v3 16/16] elect: Add documentation Daniel Wagner
2011-12-15  1:10   ` Denis Kenzior
2011-12-16  8:44     ` Daniel Wagner
2011-12-16  9:40       ` Marcel Holtmann

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.