Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH v4 1/3] hfp_ag_bluez5: Create a hash to store connections
@ 2013-04-19 15:00 Paulo Borges
  2013-04-19 15:00 ` [PATCH v4 2/3] hfp_ag_bluez5: Add watch for G_IO_HUP when connect Paulo Borges
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paulo Borges @ 2013-04-19 15:00 UTC (permalink / raw)
  To: ofono

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

We need to store active connections so we can disconnect them at
RequestDisconnect().

When we remove a connection from the hash, we also close it.
---
 plugins/hfp_ag_bluez5.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index c171c87..edc76e6 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -48,6 +48,17 @@
 static guint modemwatch_id;
 static GList *modems;
 static GHashTable *sim_hash = NULL;
+static GHashTable *connection_hash;
+
+static void connection_removed_notify(gpointer data)
+{
+	int fd = GPOINTER_TO_INT(data);
+
+	DBG("%d", fd);
+
+	shutdown(fd, SHUT_RDWR);
+	close(fd);
+}
 
 static DBusMessage *profile_new_connection(DBusConnection *conn,
 						DBusMessage *msg, void *data)
@@ -251,6 +262,9 @@ static int hfp_ag_init(void)
 	modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
 	__ofono_modem_foreach(call_modemwatch, NULL);
 
+	connection_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+					g_free, connection_removed_notify);
+
 	return 0;
 }
 
@@ -262,6 +276,8 @@ static void hfp_ag_exit(void)
 	g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
 						BLUEZ_PROFILE_INTERFACE);
 
+	g_hash_table_destroy(connection_hash);
+
 	g_list_free(modems);
 	g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
 	g_hash_table_destroy(sim_hash);
-- 
1.7.9.5


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

end of thread, other threads:[~2013-04-19 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-19 15:00 [PATCH v4 1/3] hfp_ag_bluez5: Create a hash to store connections Paulo Borges
2013-04-19 15:00 ` [PATCH v4 2/3] hfp_ag_bluez5: Add watch for G_IO_HUP when connect Paulo Borges
2013-04-19 15:01 ` [PATCH v4 3/3] hfp_ag_bluez5: Implement RequestDisconnection() Paulo Borges
2013-04-19 15:36 ` [PATCH v4 1/3] hfp_ag_bluez5: Create a hash to store connections Denis Kenzior

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