All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered
@ 2010-02-15 19:26 Gustavo F. Padovan
  2010-02-15 19:26 ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Gustavo F. Padovan
  2010-02-15 19:39 ` [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Denis Kenzior
  0 siblings, 2 replies; 6+ messages in thread
From: Gustavo F. Padovan @ 2010-02-15 19:26 UTC (permalink / raw)
  To: ofono

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

---
 plugins/hfp.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/plugins/hfp.c b/plugins/hfp.c
index 2d03973..411cfc1 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -110,8 +110,6 @@ static void service_level_conn_failed(struct ofono_modem *modem)
 	struct hfp_data *data = ofono_modem_get_data(modem);
 	DBusMessage *msg;
 
-	ofono_modem_set_powered(modem, FALSE);
-
 	msg = g_dbus_create_error(data->slc_msg, HFP_AGENT_ERROR_INTERFACE
 					".Failed",
 					"HFP Handshake failed");
-- 
1.6.4.4


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

* [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor
  2010-02-15 19:26 [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Gustavo F. Padovan
@ 2010-02-15 19:26 ` Gustavo F. Padovan
  2010-02-15 19:26   ` [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release Gustavo F. Padovan
  2010-02-15 19:36   ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Denis Kenzior
  2010-02-15 19:39 ` [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Denis Kenzior
  1 sibling, 2 replies; 6+ messages in thread
From: Gustavo F. Padovan @ 2010-02-15 19:26 UTC (permalink / raw)
  To: ofono

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

---
 plugins/hfp.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/plugins/hfp.c b/plugins/hfp.c
index 411cfc1..3776dc6 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -482,6 +482,20 @@ error:
 	service_level_conn_failed(modem);
 }
 
+static gboolean hfp_fd_disconnected_cb(GIOChannel *chan, GIOCondition cond,
+		struct ofono_modem *modem)
+{
+	if (cond & G_IO_NVAL)
+		return FALSE;
+
+	if (cond & (G_IO_ERR | G_IO_HUP)) {
+		ofono_modem_set_powered(modem, FALSE);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 /* either oFono or Phone could request SLC connection */
 static int service_level_connection(struct ofono_modem *modem, int fd)
 {
@@ -498,6 +512,9 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
 		return -EIO;
 	}
 
+	g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+	                        (GIOFunc) hfp_fd_disconnected_cb, modem);
+
 	syntax = g_at_syntax_new_gsmv1();
 	chat = g_at_chat_new(io, syntax);
 	g_at_syntax_unref(syntax);
-- 
1.6.4.4


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

* [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release
  2010-02-15 19:26 ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Gustavo F. Padovan
@ 2010-02-15 19:26   ` Gustavo F. Padovan
  2010-02-15 19:41     ` Denis Kenzior
  2010-02-15 19:36   ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Denis Kenzior
  1 sibling, 1 reply; 6+ messages in thread
From: Gustavo F. Padovan @ 2010-02-15 19:26 UTC (permalink / raw)
  To: ofono

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

---
 plugins/hfp.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/plugins/hfp.c b/plugins/hfp.c
index 3776dc6..c63e332 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -911,6 +911,23 @@ done:
 	dbus_message_unref(reply);
 }
 
+static gboolean hfp_remove_each_modem(gpointer key, gpointer value, gpointer user_data)
+{
+	struct ofono_modem *modem = value;
+
+	ofono_modem_remove(modem);
+
+	return TRUE;
+}
+
+static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
+{
+	if (uuid_hash == NULL)
+		return;
+
+	g_hash_table_foreach_remove(uuid_hash, hfp_remove_each_modem, NULL);
+}
+
 static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
 {
 	const char *obj_path = ofono_modem_get_path(modem);
@@ -1098,6 +1115,7 @@ static struct ofono_modem_driver hfp_driver = {
 	.post_sim	= hfp_post_sim,
 };
 
+static guint watch;
 static guint adapter_added_watch;
 static guint adapter_removed_watch;
 static guint uuid_watch;
@@ -1111,6 +1129,10 @@ static int hfp_init()
 
 	connection = ofono_dbus_get_connection();
 
+	watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
+			NULL, bluetooth_disconnect, NULL, NULL);
+
+
 	adapter_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
 						BLUEZ_MANAGER_INTERFACE,
 						"AdapterAdded",
@@ -1126,8 +1148,8 @@ static int hfp_init()
 						"PropertyChanged",
 						property_changed, NULL, NULL);
 
-	if (adapter_added_watch == 0 || adapter_removed_watch == 0||
-			uuid_watch == 0) {
+	if (watch == 0 || adapter_added_watch == 0 ||
+			adapter_removed_watch == 0|| uuid_watch == 0) {
 		err = -EIO;
 		goto remove;
 	}
@@ -1150,6 +1172,7 @@ static int hfp_init()
 	return 0;
 
 remove:
+	g_dbus_remove_watch(connection, watch);
 	g_dbus_remove_watch(connection, adapter_added_watch);
 	g_dbus_remove_watch(connection, adapter_removed_watch);
 	g_dbus_remove_watch(connection, uuid_watch);
@@ -1165,6 +1188,7 @@ remove:
 
 static void hfp_exit()
 {
+	g_dbus_remove_watch(connection, watch);
 	g_dbus_remove_watch(connection, adapter_added_watch);
 	g_dbus_remove_watch(connection, adapter_removed_watch);
 	g_dbus_remove_watch(connection, uuid_watch);
-- 
1.6.4.4


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

* Re: [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor
  2010-02-15 19:26 ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Gustavo F. Padovan
  2010-02-15 19:26   ` [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release Gustavo F. Padovan
@ 2010-02-15 19:36   ` Denis Kenzior
  1 sibling, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-02-15 19:36 UTC (permalink / raw)
  To: ofono

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

Hi Gustavo,

> ---
>  plugins/hfp.c |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/plugins/hfp.c b/plugins/hfp.c
> index 411cfc1..3776dc6 100644
> --- a/plugins/hfp.c
> +++ b/plugins/hfp.c
> @@ -482,6 +482,20 @@ error:
>  	service_level_conn_failed(modem);
>  }
> 
> +static gboolean hfp_fd_disconnected_cb(GIOChannel *chan, GIOCondition
>  cond, +		struct ofono_modem *modem)
> +{
> +	if (cond & G_IO_NVAL)
> +		return FALSE;
> +
> +	if (cond & (G_IO_ERR | G_IO_HUP)) {
> +		ofono_modem_set_powered(modem, FALSE);
> +		return FALSE;
> +	}
> +
> +	return TRUE;
> +}
> +
>  /* either oFono or Phone could request SLC connection */
>  static int service_level_connection(struct ofono_modem *modem, int fd)
>  {
> @@ -498,6 +512,9 @@ static int service_level_connection(struct ofono_modem
>  *modem, int fd) return -EIO;
>  	}
> 
> +	g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> +	                        (GIOFunc) hfp_fd_disconnected_cb, modem);
> +

Use g_at_chat_set_disconnect_function

>  	syntax = g_at_syntax_new_gsmv1();
>  	chat = g_at_chat_new(io, syntax);
>  	g_at_syntax_unref(syntax);
> 

Regards,
-Denis

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

* Re: [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered
  2010-02-15 19:26 [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Gustavo F. Padovan
  2010-02-15 19:26 ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Gustavo F. Padovan
@ 2010-02-15 19:39 ` Denis Kenzior
  1 sibling, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-02-15 19:39 UTC (permalink / raw)
  To: ofono

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

Hi Gustavo,

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release
  2010-02-15 19:26   ` [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release Gustavo F. Padovan
@ 2010-02-15 19:41     ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-02-15 19:41 UTC (permalink / raw)
  To: ofono

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

Hi Gustavo,

> ---
>  plugins/hfp.c |   28 ++++++++++++++++++++++++++--
>  1 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/plugins/hfp.c b/plugins/hfp.c
> index 3776dc6..c63e332 100644
> --- a/plugins/hfp.c
> +++ b/plugins/hfp.c
> @@ -911,6 +911,23 @@ done:
>  	dbus_message_unref(reply);
>  }
> 
> +static gboolean hfp_remove_each_modem(gpointer key, gpointer value,
>  gpointer user_data) +{
> +	struct ofono_modem *modem = value;
> +
> +	ofono_modem_remove(modem);
> +
> +	return TRUE;
> +}
> +
> +static void bluetooth_disconnect(DBusConnection *connection, void
>  *user_data) +{
> +	if (uuid_hash == NULL)
> +		return;
> +
> +	g_hash_table_foreach_remove(uuid_hash, hfp_remove_each_modem, NULL);
> +}
> +
>  static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
>  {
>  	const char *obj_path = ofono_modem_get_path(modem);
> @@ -1098,6 +1115,7 @@ static struct ofono_modem_driver hfp_driver = {
>  	.post_sim	= hfp_post_sim,
>  };
> 
> +static guint watch;

Rename this into something more sensible, e.g. bluetoothd_exit_watch

>  static guint adapter_added_watch;
>  static guint adapter_removed_watch;
>  static guint uuid_watch;
> @@ -1111,6 +1129,10 @@ static int hfp_init()
> 
>  	connection = ofono_dbus_get_connection();
> 
> +	watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
> +			NULL, bluetooth_disconnect, NULL, NULL);
> +
> +

Why the extra line?

>  	adapter_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
>  						BLUEZ_MANAGER_INTERFACE,
>  						"AdapterAdded",
> @@ -1126,8 +1148,8 @@ static int hfp_init()
>  						"PropertyChanged",
>  						property_changed, NULL, NULL);
> 
> -	if (adapter_added_watch == 0 || adapter_removed_watch == 0||
> -			uuid_watch == 0) {
> +	if (watch == 0 || adapter_added_watch == 0 ||
> +			adapter_removed_watch == 0|| uuid_watch == 0) {
>  		err = -EIO;
>  		goto remove;
>  	}
> @@ -1150,6 +1172,7 @@ static int hfp_init()
>  	return 0;
> 
>  remove:
> +	g_dbus_remove_watch(connection, watch);
>  	g_dbus_remove_watch(connection, adapter_added_watch);
>  	g_dbus_remove_watch(connection, adapter_removed_watch);
>  	g_dbus_remove_watch(connection, uuid_watch);
> @@ -1165,6 +1188,7 @@ remove:
> 
>  static void hfp_exit()
>  {
> +	g_dbus_remove_watch(connection, watch);
>  	g_dbus_remove_watch(connection, adapter_added_watch);
>  	g_dbus_remove_watch(connection, adapter_removed_watch);
>  	g_dbus_remove_watch(connection, uuid_watch);
> 

Regards,
-Denis

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

end of thread, other threads:[~2010-02-15 19:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-15 19:26 [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Gustavo F. Padovan
2010-02-15 19:26 ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Gustavo F. Padovan
2010-02-15 19:26   ` [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release Gustavo F. Padovan
2010-02-15 19:41     ` Denis Kenzior
2010-02-15 19:36   ` [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor Denis Kenzior
2010-02-15 19:39 ` [PATCH 1/3] hfp: remove duplicated ofono_modem_set_powered Denis Kenzior

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.