All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [RFC v0 04/15] network: Split Network into three btd_profile
Date: Fri, 19 Oct 2012 17:39:21 +0200	[thread overview]
Message-ID: <1350661172-18125-5-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1350661172-18125-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Split the possible roles into three different btd_profile instances, one
role each, in accordance with the rest of the existing profiles.
---
 profiles/network/manager.c | 105 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 86 insertions(+), 19 deletions(-)

diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index fe3324b..eda0bbe 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -73,19 +73,12 @@ done:
 				conf_security ? "true" : "false");
 }
 
-static int network_probe(struct btd_profile *p, struct btd_device *device,
+static int panu_probe(struct btd_profile *p, struct btd_device *device,
 								GSList *uuids)
 {
 	DBG("path %s", device_get_path(device));
 
-	if (g_slist_find_custom(uuids, PANU_UUID, bt_uuid_strcmp))
-		connection_register(device, BNEP_SVC_PANU);
-	if (g_slist_find_custom(uuids, GN_UUID, bt_uuid_strcmp))
-		connection_register(device, BNEP_SVC_GN);
-	if (g_slist_find_custom(uuids, NAP_UUID, bt_uuid_strcmp))
-		connection_register(device, BNEP_SVC_NAP);
-
-	return 0;
+	return connection_register(device, BNEP_SVC_PANU);
 }
 
 static void network_remove(struct btd_profile *p, struct btd_device *device)
@@ -95,17 +88,70 @@ static void network_remove(struct btd_profile *p, struct btd_device *device)
 	connection_unregister(device);
 }
 
-static int network_server_probe(struct btd_profile *p,
+static int panu_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
+{
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
+
+	return server_register(adapter, BNEP_SVC_PANU);
+}
+
+static void panu_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
+{
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
+
+	server_unregister(adapter, BNEP_SVC_PANU);
+}
+
+static int gn_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
+{
+	DBG("path %s", device_get_path(device));
+
+	return connection_register(device, BNEP_SVC_GN);
+}
+
+static int gn_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
+{
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
+
+	return server_register(adapter, BNEP_SVC_GN);
+}
+
+static void gn_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
 	const gchar *path = adapter_get_path(adapter);
 
 	DBG("path %s", path);
 
+	server_unregister(adapter, BNEP_SVC_GN);
+}
+
+static int nap_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
+{
+	DBG("path %s", device_get_path(device));
+
+	return connection_register(device, BNEP_SVC_NAP);
+}
+
+static int nap_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
+{
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
+
 	return server_register(adapter, BNEP_SVC_NAP);
 }
 
-static void network_server_remove(struct btd_profile *p,
+static void nap_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
 	const gchar *path = adapter_get_path(adapter);
@@ -115,14 +161,31 @@ static void network_server_remove(struct btd_profile *p,
 	server_unregister(adapter, BNEP_SVC_NAP);
 }
 
-static struct btd_profile network_profile = {
-	.name		= "network",
-	.remote_uuids	= BTD_UUIDS(PANU_UUID, GN_UUID, NAP_UUID),
-	.device_probe	= network_probe,
+static struct btd_profile panu_profile = {
+	.name		= "network-panu",
+	.remote_uuids	= BTD_UUIDS(PANU_UUID),
+	.device_probe	= panu_probe,
+	.device_remove	= network_remove,
+	.adapter_probe	= panu_server_probe,
+	.adapter_remove	= panu_server_remove,
+};
+
+static struct btd_profile gn_profile = {
+	.name		= "network-gn",
+	.remote_uuids	= BTD_UUIDS(GN_UUID),
+	.device_probe	= gn_probe,
 	.device_remove	= network_remove,
+	.adapter_probe	= gn_server_probe,
+	.adapter_remove	= gn_server_remove,
+};
 
-	.adapter_probe	= network_server_probe,
-	.adapter_remove	= network_server_remove,
+static struct btd_profile nap_profile = {
+	.name		= "network-nap",
+	.remote_uuids	= BTD_UUIDS(NAP_UUID),
+	.device_probe	= nap_probe,
+	.device_remove	= network_remove,
+	.adapter_probe	= nap_server_probe,
+	.adapter_remove	= nap_server_remove,
 };
 
 int network_manager_init(void)
@@ -144,7 +207,9 @@ int network_manager_init(void)
 	if (server_init(conf_security) < 0)
 		return -1;
 
-	btd_profile_register(&network_profile);
+	btd_profile_register(&panu_profile);
+	btd_profile_register(&gn_profile);
+	btd_profile_register(&nap_profile);
 
 	return 0;
 }
@@ -153,7 +218,9 @@ void network_manager_exit(void)
 {
 	server_exit();
 
-	btd_profile_unregister(&network_profile);
+	btd_profile_unregister(&panu_profile);
+	btd_profile_unregister(&gn_profile);
+	btd_profile_unregister(&nap_profile);
 
 	bnep_cleanup();
 }
-- 
1.7.11.7


  parent reply	other threads:[~2012-10-19 15:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19 15:39 [RFC v0 00/15] WIP: btd_profile connect and disconnect Mikel Astiz
2012-10-19 15:39 ` [RFC v0 01/15] network: Specify id while registering server Mikel Astiz
2012-10-19 15:39 ` [RFC v0 02/15] network: Trivial function rename Mikel Astiz
2012-10-19 15:39 ` [RFC v0 03/15] network: Expose internal connection API Mikel Astiz
2012-10-19 15:39 ` Mikel Astiz [this message]
2012-10-19 15:39 ` [RFC v0 05/15] network: Add network .connect and .disconnect Mikel Astiz
2012-10-24 12:28   ` Anderson Lizardo
2012-10-25 10:42     ` Johan Hedberg
2012-10-25 15:53       ` Mikel Astiz
2012-10-25 17:38         ` Johan Hedberg
2012-10-19 15:39 ` [RFC v0 06/15] audio: Split A2DP into three btd_profile Mikel Astiz
2012-10-19 15:39 ` [RFC v0 07/15] audio: Trivial function rename Mikel Astiz
2012-10-19 15:39 ` [RFC v0 08/15] source: Expose internal connection API Mikel Astiz
2012-10-19 15:39 ` [RFC v0 09/15] source: Add profile .connect and .disconnect Mikel Astiz
2012-10-19 15:39 ` [RFC v0 10/15] input: Trivial function rename Mikel Astiz
2012-10-19 15:39 ` [RFC v0 11/15] input: Expose internal disconnection API Mikel Astiz
2012-10-19 15:39 ` [RFC v0 12/15] input: Add profile .disconnect Mikel Astiz
2012-10-25 10:39   ` Johan Hedberg
2012-10-25 15:49     ` Mikel Astiz
2012-10-19 15:39 ` [RFC v0 13/15] profile: Rename org.bluez.Profile->ProfileAgent Mikel Astiz
2012-10-19 16:10   ` Marcel Holtmann
2012-10-19 15:39 ` [RFC v0 14/15] profile: Add object to represent device-profile Mikel Astiz
2012-10-19 15:39 ` [RFC v0 15/15] profile: Add new org.bluez.Profile Mikel Astiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350661172-18125-5-git-send-email-mikel.astiz.oss@gmail.com \
    --to=mikel.astiz.oss@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz@bmw-carit.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.