[PATCH 4/5] Move create_path() to bluetooth plugin

Gustavo F. Padovan gustavo at padovan.org
Tue Jun 8 00:43:59 PDT 2010


---
 plugins/bluetooth.c |   22 ++++++++++++++++++++++
 plugins/bluetooth.h |    3 +++
 plugins/hfp.c       |   25 +------------------------
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index b452d73..4b3d94c 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -40,6 +40,28 @@ static DBusConnection *connection;
 static GHashTable *uuid_hash = NULL;
 static GHashTable *adapter_address_hash = NULL;
 
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr, char *buf, int size)
+{
+	int i, j;
+
+	for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
+		if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
+			buf[i++] = adapter_addr[j];
+		else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
+			buf[i++] = adapter_addr[j];
+
+	if (i < size - 1)
+		buf[i++] = '_';
+
+	for (j = 0; dev_addr[j] && i < size - 1; j++)
+		if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
+			buf[i++] = dev_addr[j];
+		else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
+			buf[i++] = dev_addr[j];
+
+	buf[i] = '\0';
+}
+
 static int send_method_call_with_reply(const char *dest, const char *path,
 				const char *interface, const char *method,
 				DBusPendingCallNotifyFunction cb,
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 94ebaf6..430f4cf 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -40,3 +40,6 @@ int bluetooth_register_uuid(const char *uuid,
 				struct bluetooth_profile *profile);
 void bluetooth_unregister_uuid(const char *uuid);
 
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
+							char *buf, int size);
+
diff --git a/plugins/hfp.c b/plugins/hfp.c
index 6fd3464..c2b3711 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -448,29 +448,6 @@ static GDBusMethodTable agent_methods[] = {
 	{ NULL, NULL, NULL, NULL }
 };
 
-static void create_path(const char *dev_addr, const char *adapter_addr,
-			char *buf, int size)
-{
-	int i, j;
-
-	for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
-		if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
-			buf[i++] = adapter_addr[j];
-		else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
-			buf[i++] = adapter_addr[j];
-
-	if (i < size - 1)
-		buf[i++] = '_';
-
-	for (j = 0; dev_addr[j] && i < size - 1; j++)
-		if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
-			buf[i++] = dev_addr[j];
-		else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
-			buf[i++] = dev_addr[j];
-
-	buf[i] = '\0';
-}
-
 static int hfp_create_modem(const char *device, const char *dev_addr,
 				const char *adapter_addr, const char *alias)
 {
@@ -486,7 +463,7 @@ static int hfp_create_modem(const char *device, const char *dev_addr,
 			device, dev_addr, adapter_addr);
 
 	strcpy(buf, "hfp/");
-	create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
 
 	modem = ofono_modem_create(buf, "hfp");
 	if (modem == NULL)
-- 
1.7.1



More information about the ofono mailing list