Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth DUN modem prototype
@ 2010-07-30  2:09 Gustavo F. Padovan
  2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
  2010-08-02 14:33 ` [PATCH 1/3] Bluetooth DUN modem prototype Zhang, Zhenhua
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-07-30  2:09 UTC (permalink / raw)
  To: ofono

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

Add a still dummy DUN code, now it can only creates and removes modems.
The DUN plugin follows the HFP one a lot, the is basics a copy of some
HFP plugin's parts.
---
 Makefile.am                 |    6 ++
 drivers/dunmodem/dunmodem.c |   51 +++++++++++
 drivers/dunmodem/dunmodem.h |   29 ++++++
 plugins/bluetooth.c         |   11 +++
 plugins/bluetooth.h         |    2 +
 plugins/dun.c               |  202 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 301 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dunmodem/dunmodem.c
 create mode 100644 drivers/dunmodem/dunmodem.h
 create mode 100644 plugins/dun.c

diff --git a/Makefile.am b/Makefile.am
index e256841..a6f2bff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,6 +179,9 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/hfpmodem/network-registration.c \
 			drivers/hfpmodem/call-volume.c
 
+builtin_modules += dunmodem
+builtin_sources += drivers/dunmodem/dunmodem.h drivers/dunmodem/dunmodem.c
+
 builtin_modules += mbmmodem
 builtin_sources += drivers/atmodem/atutil.h \
 			drivers/mbmmodem/mbmmodem.h \
@@ -242,6 +245,9 @@ builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
 builtin_modules += hfp
 builtin_sources += plugins/hfp.c plugins/bluetooth.h
 
+builtin_modules += dun
+builtin_sources += plugins/dun.c
+
 builtin_modules += palmpre
 builtin_sources += plugins/palmpre.c
 
diff --git a/drivers/dunmodem/dunmodem.c b/drivers/dunmodem/dunmodem.c
new file mode 100644
index 0000000..8658bee
--- /dev/null
+++ b/drivers/dunmodem/dunmodem.c
@@ -0,0 +1,51 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ *  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
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+
+#include "dunmodem.h"
+
+static int dunmodem_init(void)
+{
+	return 0;
+}
+
+static void dunmodem_exit(void)
+{
+}
+
+OFONO_PLUGIN_DEFINE(dunmodem, "Dial-up Networking Driver", VERSION,
+		OFONO_PLUGIN_PRIORITY_DEFAULT, dunmodem_init, dunmodem_exit)
+
diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
new file mode 100644
index 0000000..6bbf7b9
--- /dev/null
+++ b/drivers/dunmodem/dunmodem.h
@@ -0,0 +1,29 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ *  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
+ *
+ */
+#ifndef __DUN_MODEM_H__
+#define __DUN_MODEM_H__
+
+struct dun_data {
+	char *dun_path;
+};
+
+#endif
+
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 5a85eaa..b7ec0d3 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -218,6 +218,9 @@ static void has_uuid(DBusMessageIter *array, gpointer user_data)
 		if (!strcasecmp(uuid, HFP_AG_UUID))
 			*profiles |= HFP_AG;
 
+		if (!strcasecmp(uuid, DUN_GW_UUID))
+			*profiles |= DUN_GW;
+
 		dbus_message_iter_next(&value);
 	}
 }
@@ -276,6 +279,14 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
 		profile->create(path, device_addr, adapter_addr, alias);
 	}
 
+	if ((have_uuid & DUN_GW) && device_addr && adapter_addr) {
+		profile = g_hash_table_lookup(uuid_hash, DUN_GW_UUID);
+		if (!profile || !profile->create)
+			goto done;
+
+		profile->create(path, device_addr, adapter_addr, alias);
+	}
+
 done:
 	dbus_message_unref(reply);
 }
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index fb0d841..09e6efa 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,9 +24,11 @@
 #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
 
 #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
+#define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
 
 /* Profiles bitfield */
 #define HFP_AG 0x01
+#define DUN_GW 0x02
 
 struct bluetooth_profile {
 	const char *name;
diff --git a/plugins/dun.c b/plugins/dun.c
new file mode 100644
index 0000000..9b4288e
--- /dev/null
+++ b/plugins/dun.c
@@ -0,0 +1,202 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ *  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 <string.h>
+#include <errno.h>
+#include <glib.h>
+#include <ofono.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+
+#include <drivers/dunmodem/dunmodem.h>
+
+#include <ofono/dbus.h>
+
+#include "bluetooth.h"
+
+#ifndef DBUS_TYPE_UNIX_FD
+#define DBUS_TYPE_UNIX_FD -1
+#endif
+
+static DBusConnection *connection;
+static GHashTable *modem_hash = NULL;
+
+static int dun_create_modem(const char *device, const char *dev_addr,
+				const char *adapter_addr, const char *alias)
+{
+	struct ofono_modem *modem;
+	struct dun_data *data;
+	char buf[256];
+
+	/* We already have this device in our hash, ignore */
+	if (g_hash_table_lookup(modem_hash, device) != NULL)
+		return -EALREADY;
+
+	ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+			device, dev_addr, adapter_addr);
+
+	strcpy(buf, "dun/");
+	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+
+	modem = ofono_modem_create(buf, "dun");
+	if (modem == NULL)
+		return -ENOMEM;
+
+	data = g_try_new0(struct dun_data, 1);
+	if (!data)
+		goto free;
+
+	data->dun_path = g_strdup(device);
+	if (data->dun_path == NULL)
+		goto free;
+
+	ofono_modem_set_data(modem, data);
+	ofono_modem_set_name(modem, alias);
+	ofono_modem_register(modem);
+
+	g_hash_table_insert(modem_hash, g_strdup(device), modem);
+	return 0;
+
+free:
+	g_free(data);
+	ofono_modem_remove(modem);
+
+	return -ENOMEM;
+}
+
+static gboolean dun_remove_each_modem(gpointer key, gpointer value, gpointer user_data)
+{
+	struct ofono_modem *modem = value;
+
+	ofono_modem_remove(modem);
+
+	return TRUE;
+}
+
+static void dun_remove_all_modem()
+{
+	if (modem_hash == NULL)
+		return;
+
+	g_hash_table_foreach_remove(modem_hash, dun_remove_each_modem, NULL);
+}
+
+static void dun_set_alias(const char *device, const char *alias)
+{
+	struct ofono_modem *modem;
+
+	if (!device || !alias)
+		return;
+
+	modem =	g_hash_table_lookup(modem_hash, device);
+	if (!modem)
+		return;
+
+	ofono_modem_set_name(modem, alias);
+}
+
+static int dun_probe(struct ofono_modem *modem)
+{
+	DBG("%p", modem);
+	return 0;
+}
+
+static void dun_remove(struct ofono_modem *modem)
+{
+	struct dun_data *data = ofono_modem_get_data(modem);
+
+	g_hash_table_remove(modem_hash, data->dun_path);
+
+	g_free(data->dun_path);
+	g_free(data);
+
+	ofono_modem_set_data(modem, NULL);
+}
+
+static int dun_enable(struct ofono_modem *modem)
+{
+	DBG("%p", modem);
+	return 0;
+}
+
+static int dun_disable(struct ofono_modem *modem)
+{
+	DBG("%p", modem);
+	return 0;
+}
+
+static struct ofono_modem_driver dun_driver = {
+	.name		= "dun",
+	.probe		= dun_probe,
+	.remove		= dun_remove,
+	.enable		= dun_enable,
+	.disable	= dun_disable,
+};
+
+static struct bluetooth_profile dun_profile = {
+	.name		= "dun",
+	.create		= dun_create_modem,
+	.remove_all	= dun_remove_all_modem,
+	.set_alias	= dun_set_alias,
+};
+
+static int dun_init()
+{
+	int err;
+
+	if (DBUS_TYPE_UNIX_FD < 0)
+		return -EBADF;
+
+	connection = ofono_dbus_get_connection();
+
+	err = ofono_modem_driver_register(&dun_driver);
+	if (err < 0)
+		return err;
+
+	err = bluetooth_register_uuid(DUN_GW_UUID, &dun_profile);
+	if (err < 0) {
+		ofono_modem_driver_unregister(&dun_driver);
+		return err;
+	}
+
+	modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+						g_free, NULL);
+
+	return 0;
+}
+
+static void dun_exit()
+{
+	bluetooth_unregister_uuid(DUN_GW_UUID);
+	ofono_modem_driver_unregister(&dun_driver);
+
+	g_hash_table_destroy(modem_hash);
+}
+
+OFONO_PLUGIN_DEFINE(dun, "Dial-up Networking Profile Plugins", VERSION,
+			OFONO_PLUGIN_PRIORITY_DEFAULT, dun_init, dun_exit)
-- 
1.7.1.1


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

* [PATCH 2/3] Add dun_enable() function
  2010-07-30  2:09 [PATCH 1/3] Bluetooth DUN modem prototype Gustavo F. Padovan
@ 2010-07-30  2:09 ` Gustavo F. Padovan
  2010-07-30  2:09   ` [PATCH 3/3] Add dun_disable() to power down the modem Gustavo F. Padovan
                     ` (2 more replies)
  2010-08-02 14:33 ` [PATCH 1/3] Bluetooth DUN modem prototype Zhang, Zhenhua
  1 sibling, 3 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-07-30  2:09 UTC (permalink / raw)
  To: ofono

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

dun_enable() is called by setting the Powered property to true.
It creates a rfcomm link throught the BlueZ Serial API.
---
 drivers/dunmodem/dunmodem.h |    1 +
 plugins/bluetooth.h         |    1 +
 plugins/dun.c               |   61 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
index 6bbf7b9..16eb9e7 100644
--- a/drivers/dunmodem/dunmodem.h
+++ b/drivers/dunmodem/dunmodem.h
@@ -23,6 +23,7 @@
 
 struct dun_data {
 	char *dun_path;
+	const char *rfcomm;
 };
 
 #endif
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 09e6efa..c20b36d 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -22,6 +22,7 @@
 #define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
 #define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
 #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
+#define	BLUEZ_SERIAL_INTERFACE		BLUEZ_SERVICE ".Serial"
 
 #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
 #define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
diff --git a/plugins/dun.c b/plugins/dun.c
index 9b4288e..7dc8422 100644
--- a/plugins/dun.c
+++ b/plugins/dun.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <gdbus.h>
 #include <glib.h>
 #include <ofono.h>
 
@@ -138,10 +139,66 @@ static void dun_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 }
 
+static void dun_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct dun_data *data = ofono_modem_get_data(modem);
+	const char *dev;
+	DBusError derr;
+	DBusMessage *reply, *msg;
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	if (ofono_modem_get_powered(modem))
+		goto done;
+
+	if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &dev,
+				DBUS_TYPE_INVALID))
+		goto done;
+
+	data->rfcomm = dev;
+
+	dbus_error_init(&derr);
+	if (!dbus_set_error_from_message(&derr, reply))
+		goto done;
+
+	DBG("Connect reply: %s", derr.message);
+
+	if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
+		msg = dbus_message_new_method_call(BLUEZ_SERVICE,
+				data->dun_path,
+				BLUEZ_SERIAL_INTERFACE, "Disconnect");
+		if (!msg)
+			ofono_error("Disconnect failed");
+		else
+			g_dbus_send_message(connection, msg);
+	}
+
+	ofono_modem_set_powered(modem, FALSE);
+
+	dbus_error_free(&derr);
+
+done:
+	ofono_modem_set_powered(modem, TRUE);
+	dbus_message_unref(reply);
+}
+
 static int dun_enable(struct ofono_modem *modem)
 {
-	DBG("%p", modem);
-	return 0;
+	struct dun_data *data = ofono_modem_get_data(modem);
+	int status;
+	const char *uuid = DUN_GW_UUID;
+
+	status = bluetooth_send_with_reply(data->dun_path,
+					BLUEZ_SERIAL_INTERFACE, "Connect",
+					dun_connect_reply, modem, NULL,
+					15, DBUS_TYPE_STRING, &uuid,
+					DBUS_TYPE_INVALID);
+
+	if (status < 0)
+		return -EINVAL;
+
+	return -EINPROGRESS;
 }
 
 static int dun_disable(struct ofono_modem *modem)
-- 
1.7.1.1


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

* [PATCH 3/3] Add dun_disable() to power down the modem
  2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
@ 2010-07-30  2:09   ` Gustavo F. Padovan
  2010-08-02 14:24   ` [PATCH 2/3] Add dun_enable() function Zhang, Zhenhua
  2010-08-02 14:28   ` Zhang, Zhenhua
  2 siblings, 0 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-07-30  2:09 UTC (permalink / raw)
  To: ofono

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

When setting Powered to 0 the link rfcomm is disconnected.
---
 plugins/dun.c |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/plugins/dun.c b/plugins/dun.c
index 7dc8422..6d96696 100644
--- a/plugins/dun.c
+++ b/plugins/dun.c
@@ -201,10 +201,45 @@ static int dun_enable(struct ofono_modem *modem)
 	return -EINPROGRESS;
 }
 
+static void dun_power_down(DBusPendingCall *call, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	DBusMessage *reply;
+	DBusError derr;
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	dbus_error_init(&derr);
+	if (dbus_set_error_from_message(&derr, reply)) {
+		DBG("Disconnect reply: %s", derr.message);
+		dbus_error_free(&derr);
+		goto done;
+	}
+
+	ofono_modem_set_powered(modem, FALSE);
+
+done:
+	dbus_message_unref(reply);
+}
+
 static int dun_disable(struct ofono_modem *modem)
 {
-	DBG("%p", modem);
-	return 0;
+	struct dun_data *data = ofono_modem_get_data(modem);
+	int status;
+
+	if (!ofono_modem_get_powered(modem))
+		return 0;
+
+	status = bluetooth_send_with_reply(data->dun_path,
+				BLUEZ_SERIAL_INTERFACE, "Disconnect",
+				dun_power_down, modem, NULL, 15,
+				DBUS_TYPE_STRING, &data->rfcomm,
+				DBUS_TYPE_INVALID);
+
+	if (status < 0)
+		return -EINVAL;
+
+	return -EINPROGRESS;
 }
 
 static struct ofono_modem_driver dun_driver = {
-- 
1.7.1.1


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

* RE: [PATCH 2/3] Add dun_enable() function
  2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
  2010-07-30  2:09   ` [PATCH 3/3] Add dun_disable() to power down the modem Gustavo F. Padovan
@ 2010-08-02 14:24   ` Zhang, Zhenhua
  2010-08-02 14:28   ` Zhang, Zhenhua
  2 siblings, 0 replies; 7+ messages in thread
From: Zhang, Zhenhua @ 2010-08-02 14:24 UTC (permalink / raw)
  To: ofono

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

Hi Padovan,

Gustavo F. Padovan wrote:
> dun_enable() is called by setting the Powered property to true.
> It creates a rfcomm link throught the BlueZ Serial API.
> ---
>  drivers/dunmodem/dunmodem.h |    1 +
>  plugins/bluetooth.h         |    1 +
>  plugins/dun.c               |   61
>  +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 61
> insertions(+), 2 deletions(-) 
> 
> diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
> index 6bbf7b9..16eb9e7 100644
> --- a/drivers/dunmodem/dunmodem.h
> +++ b/drivers/dunmodem/dunmodem.h
> @@ -23,6 +23,7 @@
> 
>  struct dun_data {
>  	char *dun_path;
> +	const char *rfcomm;
>  };
> 
>  #endif
> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> index 09e6efa..c20b36d 100644
> --- a/plugins/bluetooth.h
> +++ b/plugins/bluetooth.h
> @@ -22,6 +22,7 @@
>  #define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
>  #define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
>  #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
> +#define	BLUEZ_SERIAL_INTERFACE		BLUEZ_SERVICE ".Serial"
> 
>  #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
>  #define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
> diff --git a/plugins/dun.c b/plugins/dun.c
> index 9b4288e..7dc8422 100644
> --- a/plugins/dun.c
> +++ b/plugins/dun.c
> @@ -25,6 +25,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <errno.h>
> +#include <gdbus.h>
>  #include <glib.h>
>  #include <ofono.h>
> 
> @@ -138,10 +139,66 @@ static void dun_remove(struct ofono_modem
>  	*modem) ofono_modem_set_data(modem, NULL);
>  }
> 
> +static void dun_connect_reply(DBusPendingCall *call, gpointer
> user_data) +{
> +	struct ofono_modem *modem = user_data;
> +	struct dun_data *data = ofono_modem_get_data(modem);
> +	const char *dev;
> +	DBusError derr;
> +	DBusMessage *reply, *msg;
> +
> +	reply = dbus_pending_call_steal_reply(call);
> +
> +	if (ofono_modem_get_powered(modem))
> +		goto done;
> +
> +	if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &dev,
> +				DBUS_TYPE_INVALID))
> +		goto done;
> +
> +	data->rfcomm = dev;
> +
> +	dbus_error_init(&derr);
> +	if (!dbus_set_error_from_message(&derr, reply))
> +		goto done;
> +
> +	DBG("Connect reply: %s", derr.message);
> +
> +	if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
> +		msg = dbus_message_new_method_call(BLUEZ_SERVICE,
> +				data->dun_path,
> +				BLUEZ_SERIAL_INTERFACE, "Disconnect");
> +		if (!msg)
> +			ofono_error("Disconnect failed");
> +		else
> +			g_dbus_send_message(connection, msg);
> +	}
> +
> +	ofono_modem_set_powered(modem, FALSE);
> +
> +	dbus_error_free(&derr);
> +
> +done:
> +	ofono_modem_set_powered(modem, TRUE);

You might want to power on modem before jumping to this label. If there's any error
from dbus, you power off but then power on the modem again. It's wrong.

> +	dbus_message_unref(reply);
> +}
> +
>  static int dun_enable(struct ofono_modem *modem)
>  {
> -	DBG("%p", modem);
> -	return 0;
> +	struct dun_data *data = ofono_modem_get_data(modem);
> +	int status;
> +	const char *uuid = DUN_GW_UUID;
> +
> +	status = bluetooth_send_with_reply(data->dun_path,
> +					BLUEZ_SERIAL_INTERFACE, "Connect",
> +					dun_connect_reply, modem, NULL,
> +					15, DBUS_TYPE_STRING, &uuid,
> +					DBUS_TYPE_INVALID);

Shall we define a macro like DBUS_TIMEOUT instead of hard code 15 seconds?
What do you think?

> +	if (status < 0)
> +		return -EINVAL;
> +
> +	return -EINPROGRESS;
>  }
> 
>  static int dun_disable(struct ofono_modem *modem)



Regards,
Zhenhua

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

* RE: [PATCH 2/3] Add dun_enable() function
  2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
  2010-07-30  2:09   ` [PATCH 3/3] Add dun_disable() to power down the modem Gustavo F. Padovan
  2010-08-02 14:24   ` [PATCH 2/3] Add dun_enable() function Zhang, Zhenhua
@ 2010-08-02 14:28   ` Zhang, Zhenhua
  2010-08-03 22:58     ` Gustavo F. Padovan
  2 siblings, 1 reply; 7+ messages in thread
From: Zhang, Zhenhua @ 2010-08-02 14:28 UTC (permalink / raw)
  To: ofono

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

Hi Padovan,

Gustavo F. Padovan wrote:
> dun_enable() is called by setting the Powered property to true.
> It creates a rfcomm link throught the BlueZ Serial API.
> ---
>  drivers/dunmodem/dunmodem.h |    1 +
>  plugins/bluetooth.h         |    1 +
>  plugins/dun.c               |   61
>  +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 61
> insertions(+), 2 deletions(-) 
> 
> diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
> index 6bbf7b9..16eb9e7 100644
> --- a/drivers/dunmodem/dunmodem.h
> +++ b/drivers/dunmodem/dunmodem.h
> @@ -23,6 +23,7 @@
> 
>  struct dun_data {
>  	char *dun_path;
> +	const char *rfcomm;
>  };
> 
>  #endif
> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> index 09e6efa..c20b36d 100644
> --- a/plugins/bluetooth.h
> +++ b/plugins/bluetooth.h
> @@ -22,6 +22,7 @@
>  #define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
>  #define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
>  #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
> +#define	BLUEZ_SERIAL_INTERFACE		BLUEZ_SERVICE ".Serial"
> 
>  #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
>  #define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
> diff --git a/plugins/dun.c b/plugins/dun.c
> index 9b4288e..7dc8422 100644
> --- a/plugins/dun.c
> +++ b/plugins/dun.c
> @@ -25,6 +25,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <errno.h>
> +#include <gdbus.h>
>  #include <glib.h>
>  #include <ofono.h>
> 
> @@ -138,10 +139,66 @@ static void dun_remove(struct ofono_modem
>  	*modem) ofono_modem_set_data(modem, NULL);
>  }
> 
> +static void dun_connect_reply(DBusPendingCall *call, gpointer
> user_data) +{
> +	struct ofono_modem *modem = user_data;
> +	struct dun_data *data = ofono_modem_get_data(modem);
> +	const char *dev;
> +	DBusError derr;
> +	DBusMessage *reply, *msg;
> +
> +	reply = dbus_pending_call_steal_reply(call);
> +
> +	if (ofono_modem_get_powered(modem))
> +		goto done;
> +
> +	if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &dev,
> +				DBUS_TYPE_INVALID))
> +		goto done;
> +
> +	data->rfcomm = dev;

One more comment here, I'd suggest to use g_strdup(dev). Because the device
String is from dbus reply and later we will unref the reply. What do you think?

> +	dbus_error_init(&derr);
> +	if (!dbus_set_error_from_message(&derr, reply))
> +		goto done;
> +
> +	DBG("Connect reply: %s", derr.message);
> +
> +	if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
> +		msg = dbus_message_new_method_call(BLUEZ_SERVICE,
> +				data->dun_path,
> +				BLUEZ_SERIAL_INTERFACE, "Disconnect");
> +		if (!msg)
> +			ofono_error("Disconnect failed");
> +		else
> +			g_dbus_send_message(connection, msg);
> +	}
> +
> +	ofono_modem_set_powered(modem, FALSE);
> +
> +	dbus_error_free(&derr);
> +
> +done:
> +	ofono_modem_set_powered(modem, TRUE);
> +	dbus_message_unref(reply);
> +}
> +
>  static int dun_enable(struct ofono_modem *modem)
>  {
> -	DBG("%p", modem);
> -	return 0;
> +	struct dun_data *data = ofono_modem_get_data(modem);
> +	int status;
> +	const char *uuid = DUN_GW_UUID;
> +
> +	status = bluetooth_send_with_reply(data->dun_path,
> +					BLUEZ_SERIAL_INTERFACE, "Connect",
> +					dun_connect_reply, modem, NULL,
> +					15, DBUS_TYPE_STRING, &uuid,
> +					DBUS_TYPE_INVALID);
> +
> +	if (status < 0)
> +		return -EINVAL;
> +
> +	return -EINPROGRESS;
>  }
> 
>  static int dun_disable(struct ofono_modem *modem)



Regards,
Zhenhua

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

* RE: [PATCH 1/3] Bluetooth DUN modem prototype
  2010-07-30  2:09 [PATCH 1/3] Bluetooth DUN modem prototype Gustavo F. Padovan
  2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
@ 2010-08-02 14:33 ` Zhang, Zhenhua
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang, Zhenhua @ 2010-08-02 14:33 UTC (permalink / raw)
  To: ofono

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

Hi Padovan,

Gustavo F. Padovan wrote:
> Add a still dummy DUN code, now it can only creates and removes
> modems. 
> The DUN plugin follows the HFP one a lot, the is basics a copy of some
> HFP plugin's parts.
> ---
>  Makefile.am                 |    6 ++
>  drivers/dunmodem/dunmodem.c |   51 +++++++++++
>  drivers/dunmodem/dunmodem.h |   29 ++++++
>  plugins/bluetooth.c         |   11 +++
>  plugins/bluetooth.h         |    2 +
>  plugins/dun.c               |  202
>  +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 301
>  insertions(+), 0 deletions(-) create mode 100644
>  drivers/dunmodem/dunmodem.c create mode 100644
>  drivers/dunmodem/dunmodem.h create mode 100644 plugins/dun.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index e256841..a6f2bff 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -179,6 +179,9 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/hfpmodem/network-registration.c \
>  			drivers/hfpmodem/call-volume.c
> 
> +builtin_modules += dunmodem
> +builtin_sources += drivers/dunmodem/dunmodem.h
> drivers/dunmodem/dunmodem.c +
>  builtin_modules += mbmmodem
>  builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/mbmmodem/mbmmodem.h \
> @@ -242,6 +245,9 @@ builtin_sources += plugins/bluetooth.c
>  plugins/bluetooth.h builtin_modules += hfp
>  builtin_sources += plugins/hfp.c plugins/bluetooth.h
> 
> +builtin_modules += dun
> +builtin_sources += plugins/dun.c
> +
>  builtin_modules += palmpre
>  builtin_sources += plugins/palmpre.c
> 
> diff --git a/drivers/dunmodem/dunmodem.c b/drivers/dunmodem/dunmodem.c
> new file mode 100644
> index 0000000..8658bee
> --- /dev/null
> +++ b/drivers/dunmodem/dunmodem.c
> @@ -0,0 +1,51 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
> + *
> + *  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
> +
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <string.h>
> +#include <errno.h>
> +#include <glib.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/plugin.h>
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +
> +#include "dunmodem.h"
> +
> +static int dunmodem_init(void)
> +{
> +	return 0;
> +}
> +
> +static void dunmodem_exit(void)
> +{
> +}
> +
> +OFONO_PLUGIN_DEFINE(dunmodem, "Dial-up Networking Driver", VERSION,
> +		OFONO_PLUGIN_PRIORITY_DEFAULT, dunmodem_init, dunmodem_exit)
> +
> diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
> new file mode 100644
> index 0000000..6bbf7b9
> --- /dev/null
> +++ b/drivers/dunmodem/dunmodem.h
> @@ -0,0 +1,29 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
> + *
> + *  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 + *
> + */
> +#ifndef __DUN_MODEM_H__
> +#define __DUN_MODEM_H__
> +
> +struct dun_data {
> +	char *dun_path;
> +};
> +
> +#endif
> +
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 5a85eaa..b7ec0d3 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -218,6 +218,9 @@ static void has_uuid(DBusMessageIter *array,
>  		gpointer user_data) if (!strcasecmp(uuid, HFP_AG_UUID))
>  			*profiles |= HFP_AG;
> 
> +		if (!strcasecmp(uuid, DUN_GW_UUID))
> +			*profiles |= DUN_GW;
> +
>  		dbus_message_iter_next(&value);
>  	}
>  }
> @@ -276,6 +279,14 @@ static void device_properties_cb(DBusPendingCall
>  		*call, gpointer user_data) profile->create(path, device_addr,
>  	adapter_addr, alias); }
> 
> +	if ((have_uuid & DUN_GW) && device_addr && adapter_addr) {
> +		profile = g_hash_table_lookup(uuid_hash, DUN_GW_UUID);
> +		if (!profile || !profile->create)
> +			goto done;
> +
> +		profile->create(path, device_addr, adapter_addr, alias);
> +	}
> +
>  done:
>  	dbus_message_unref(reply);
>  }
> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> index fb0d841..09e6efa 100644
> --- a/plugins/bluetooth.h
> +++ b/plugins/bluetooth.h
> @@ -24,9 +24,11 @@
>  #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
> 
>  #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
> +#define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
> 
>  /* Profiles bitfield */
>  #define HFP_AG 0x01
> +#define DUN_GW 0x02
> 
>  struct bluetooth_profile {
>  	const char *name;
> diff --git a/plugins/dun.c b/plugins/dun.c
> new file mode 100644
> index 0000000..9b4288e
> --- /dev/null
> +++ b/plugins/dun.c
> @@ -0,0 +1,202 @@
> +/*
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
> + *
> + *  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 <string.h>
> +#include <errno.h>
> +#include <glib.h>
> +#include <ofono.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/plugin.h>
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +
> +#include <drivers/dunmodem/dunmodem.h>
> +
> +#include <ofono/dbus.h>
> +
> +#include "bluetooth.h"
> +
> +#ifndef DBUS_TYPE_UNIX_FD
> +#define DBUS_TYPE_UNIX_FD -1
> +#endif
> +
> +static DBusConnection *connection;
> +static GHashTable *modem_hash = NULL;
> +
> +static int dun_create_modem(const char *device, const char *dev_addr,
> +				const char *adapter_addr, const char *alias)
> +{
> +	struct ofono_modem *modem;
> +	struct dun_data *data;
> +	char buf[256];
> +
> +	/* We already have this device in our hash, ignore */
> +	if (g_hash_table_lookup(modem_hash, device) != NULL)
> +		return -EALREADY;
> +
> +	ofono_info("Using device: %s, devaddr: %s, adapter: %s",
> +			device, dev_addr, adapter_addr);
> +
> +	strcpy(buf, "dun/");
> +	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf)
> - 4); +
> +	modem = ofono_modem_create(buf, "dun");
> +	if (modem == NULL)
> +		return -ENOMEM;
> +
> +	data = g_try_new0(struct dun_data, 1);
> +	if (!data)
> +		goto free;
> +
> +	data->dun_path = g_strdup(device);
> +	if (data->dun_path == NULL)
> +		goto free;
> +
> +	ofono_modem_set_data(modem, data);
> +	ofono_modem_set_name(modem, alias);
> +	ofono_modem_register(modem);
> +
> +	g_hash_table_insert(modem_hash, g_strdup(device), modem);
> +	return 0;
> +
> +free:
> +	g_free(data);
> +	ofono_modem_remove(modem);
> +
> +	return -ENOMEM;
> +}
> +
> +static gboolean dun_remove_each_modem(gpointer key, gpointer value, gpointer user_data)

Here the function exceeds 80 characters. So we should add a return after gpointer value.

Btw, I meet following message when applying your patch. I'd suggest you to remove extra line
at EOF.

Applying: ...
/home/zzhan17/ofono/.git/rebase-apply/patch:42: new blank line at EOF.
+
/home/zzhan17/ofono/.git/rebase-apply/patch:99: new blank line at EOF.
+
warning: 2 lines add whitespace errors.

> +{
> +	struct ofono_modem *modem = value;
> +
> +	ofono_modem_remove(modem);
> +
> +	return TRUE;
> +}
> +
> +static void dun_remove_all_modem()
> +{
> +	if (modem_hash == NULL)
> +		return;
> +
> +	g_hash_table_foreach_remove(modem_hash, dun_remove_each_modem,
> NULL); +}
> +
> +static void dun_set_alias(const char *device, const char *alias)
> +{
> +	struct ofono_modem *modem;
> +
> +	if (!device || !alias)
> +		return;
> +
> +	modem =	g_hash_table_lookup(modem_hash, device);
> +	if (!modem)
> +		return;
> +
> +	ofono_modem_set_name(modem, alias);
> +}
> +
> +static int dun_probe(struct ofono_modem *modem)
> +{
> +	DBG("%p", modem);
> +	return 0;
> +}
> +
> +static void dun_remove(struct ofono_modem *modem)
> +{
> +	struct dun_data *data = ofono_modem_get_data(modem);
> +
> +	g_hash_table_remove(modem_hash, data->dun_path);
> +
> +	g_free(data->dun_path);
> +	g_free(data);
> +
> +	ofono_modem_set_data(modem, NULL);
> +}
> +
> +static int dun_enable(struct ofono_modem *modem)
> +{
> +	DBG("%p", modem);
> +	return 0;
> +}
> +
> +static int dun_disable(struct ofono_modem *modem)
> +{
> +	DBG("%p", modem);
> +	return 0;
> +}
> +
> +static struct ofono_modem_driver dun_driver = {
> +	.name		= "dun",
> +	.probe		= dun_probe,
> +	.remove		= dun_remove,
> +	.enable		= dun_enable,
> +	.disable	= dun_disable,
> +};
> +
> +static struct bluetooth_profile dun_profile = {
> +	.name		= "dun",
> +	.create		= dun_create_modem,
> +	.remove_all	= dun_remove_all_modem,
> +	.set_alias	= dun_set_alias,
> +};
> +
> +static int dun_init()
> +{
> +	int err;
> +
> +	if (DBUS_TYPE_UNIX_FD < 0)
> +		return -EBADF;
> +
> +	connection = ofono_dbus_get_connection();
> +
> +	err = ofono_modem_driver_register(&dun_driver);
> +	if (err < 0)
> +		return err;
> +
> +	err = bluetooth_register_uuid(DUN_GW_UUID, &dun_profile);
> +	if (err < 0) {
> +		ofono_modem_driver_unregister(&dun_driver);
> +		return err;
> +	}
> +
> +	modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> +						g_free, NULL);
> +
> +	return 0;
> +}
> +
> +static void dun_exit()
> +{
> +	bluetooth_unregister_uuid(DUN_GW_UUID);
> +	ofono_modem_driver_unregister(&dun_driver);
> +
> +	g_hash_table_destroy(modem_hash);
> +}
> +
> +OFONO_PLUGIN_DEFINE(dun, "Dial-up Networking Profile Plugins",
> VERSION, +			OFONO_PLUGIN_PRIORITY_DEFAULT, dun_init, dun_exit)



Regards,
Zhenhua

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

* Re: [PATCH 2/3] Add dun_enable() function
  2010-08-02 14:28   ` Zhang, Zhenhua
@ 2010-08-03 22:58     ` Gustavo F. Padovan
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-08-03 22:58 UTC (permalink / raw)
  To: ofono

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

Hi Zhenhua,

* Zhang, Zhenhua <zhenhua.zhang@intel.com> [2010-08-02 22:28:47 +0800]:

> Hi Padovan,
> 
> Gustavo F. Padovan wrote:
> > dun_enable() is called by setting the Powered property to true.
> > It creates a rfcomm link throught the BlueZ Serial API.
> > ---
> >  drivers/dunmodem/dunmodem.h |    1 +
> >  plugins/bluetooth.h         |    1 +
> >  plugins/dun.c               |   61
> >  +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 61
> > insertions(+), 2 deletions(-) 
> > 
> > diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
> > index 6bbf7b9..16eb9e7 100644
> > --- a/drivers/dunmodem/dunmodem.h
> > +++ b/drivers/dunmodem/dunmodem.h
> > @@ -23,6 +23,7 @@
> > 
> >  struct dun_data {
> >  	char *dun_path;
> > +	const char *rfcomm;
> >  };
> > 
> >  #endif
> > diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> > index 09e6efa..c20b36d 100644
> > --- a/plugins/bluetooth.h
> > +++ b/plugins/bluetooth.h
> > @@ -22,6 +22,7 @@
> >  #define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
> >  #define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
> >  #define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
> > +#define	BLUEZ_SERIAL_INTERFACE		BLUEZ_SERVICE ".Serial"
> > 
> >  #define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
> >  #define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
> > diff --git a/plugins/dun.c b/plugins/dun.c
> > index 9b4288e..7dc8422 100644
> > --- a/plugins/dun.c
> > +++ b/plugins/dun.c
> > @@ -25,6 +25,7 @@
> >  #include <stdio.h>
> >  #include <string.h>
> >  #include <errno.h>
> > +#include <gdbus.h>
> >  #include <glib.h>
> >  #include <ofono.h>
> > 
> > @@ -138,10 +139,66 @@ static void dun_remove(struct ofono_modem
> >  	*modem) ofono_modem_set_data(modem, NULL);
> >  }
> > 
> > +static void dun_connect_reply(DBusPendingCall *call, gpointer
> > user_data) +{
> > +	struct ofono_modem *modem = user_data;
> > +	struct dun_data *data = ofono_modem_get_data(modem);
> > +	const char *dev;
> > +	DBusError derr;
> > +	DBusMessage *reply, *msg;
> > +
> > +	reply = dbus_pending_call_steal_reply(call);
> > +
> > +	if (ofono_modem_get_powered(modem))
> > +		goto done;
> > +
> > +	if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &dev,
> > +				DBUS_TYPE_INVALID))
> > +		goto done;
> > +
> > +	data->rfcomm = dev;
> 
> One more comment here, I'd suggest to use g_strdup(dev). Because the device
> String is from dbus reply and later we will unref the reply. What do you think?
> 

Thanks for all the comments, I fix the patches and resend them. ;)

-- 
Gustavo F. Padovan
http://padovan.org

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

end of thread, other threads:[~2010-08-03 22:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30  2:09 [PATCH 1/3] Bluetooth DUN modem prototype Gustavo F. Padovan
2010-07-30  2:09 ` [PATCH 2/3] Add dun_enable() function Gustavo F. Padovan
2010-07-30  2:09   ` [PATCH 3/3] Add dun_disable() to power down the modem Gustavo F. Padovan
2010-08-02 14:24   ` [PATCH 2/3] Add dun_enable() function Zhang, Zhenhua
2010-08-02 14:28   ` Zhang, Zhenhua
2010-08-03 22:58     ` Gustavo F. Padovan
2010-08-02 14:33 ` [PATCH 1/3] Bluetooth DUN modem prototype Zhang, Zhenhua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox