hfp: remove duplicated ofono_modem_set_powered
PATCH 1/3 hfp: remove duplicated ofono_modem_set_powered
--- plugins/hfp.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
plugins/hfp.c +0 -2
@@ -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" );
Signature · 1 line
1.6.4.4
PATCH 2/3 hfp: add watch to trigger HUP of the file descriptor
--- plugins/hfp.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
plugins/hfp.c +17 -0
@@ -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);
Signature · 1 line
1.6.4.4
PATCH 3/3 hfp: remove modems if bluetoothd shutdowns without calling Release
--- plugins/hfp.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-)
plugins/hfp.c +26 -2
@@ -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);
Signature · 1 line
1.6.4.4
Re: [PATCH 3/3] hfp: remove modems if bluetoothd shutdowns without calling Release
Hi Gustavo,
Quoted 33 lines
--- plugins/hfp.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-)plugins/hfp.c +15
-0@@ -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);
plugins/hfp.c static struct ofono_modem_driver hfp_driver = { · line 1118
Quoted 4 lines
plugins/hfp.c +1
-0@@ -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
plugins/hfp.c static int hfp_init() · line 1135
Quoted 11 lines
plugins/hfp.c +4
-0static 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?
Quoted 24 lines
plugins/hfp.c +3
-2adapter_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);
plugins/hfp.c remove: · line 1194
Quoted 7 lines
plugins/hfp.c +1
-0@@ -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
Re: [PATCH 2/3] hfp: add watch to trigger HUP of the file descriptor
In reply to Gustavo F. PadovanHi Gustavo,
Quoted 30 lines
--- plugins/hfp.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)plugins/hfp.c +13
-0@@ -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) {
plugins/hfp.c static int service_level_connection(struct ofono_modem · line 517
Quoted 6 lines
plugins/hfp.c +3
-0@@ -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
plugins/hfp.c static int service_level_connection(struct ofono_modem *modem, int fd) · line 520
Quoted 4 lines
plugins/hfp.c +0
-0syntax =g_at_syntax_new_gsmv1 (); chat =g_at_chat_new (io, syntax);g_at_syntax_unref (syntax);
Regards,
-Denis
Hi Gustavo,
Patch has been applied, thanks.
Regards,
-Denis