diff options
| -rw-r--r-- | audio/manager.c | 6 | ||||
| -rw-r--r-- | input/manager.c | 49 | ||||
| -rw-r--r-- | network/manager.c | 76 | ||||
| -rw-r--r-- | serial/manager.c | 41 | ||||
| -rw-r--r-- | src/device.c | 6 | ||||
| -rw-r--r-- | src/driver.h | 6 | 
6 files changed, 110 insertions, 74 deletions
| diff --git a/audio/manager.c b/audio/manager.c index 8278ee25..6d17a5fd 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -672,8 +672,7 @@ static int gateway_server_init(struct audio_adapter *adapter)  	return 0;  } -static int audio_probe(struct btd_device_driver *driver, -			struct btd_device *device, GSList *records) +static int audio_probe(struct btd_device *device, GSList *records)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -700,8 +699,7 @@ static int audio_probe(struct btd_device_driver *driver,  	return 0;  } -static void audio_remove(struct btd_device_driver *driver, -			struct btd_device *device) +static void audio_remove(struct btd_device *device)  {  	struct audio_device *dev;  	const char *destination = device_get_address(device); diff --git a/input/manager.c b/input/manager.c index b18da8e0..4a461b4e 100644 --- a/input/manager.c +++ b/input/manager.c @@ -163,8 +163,16 @@ static int load_stored(const char *source, const char *destination,  	return parse_stored_device_info(value, hidp);  } -int input_probe(struct btd_device_driver *driver, -		struct btd_device *device, GSList *records) +void input_remove(struct btd_device *device, const char *uuid) +{ +	const gchar *path = device_get_path(device); + +	DBG("path %s", path); + +	input_device_unregister(path, uuid); +} + +int hid_probe(struct btd_device *device, GSList *records)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -196,21 +204,15 @@ done:  		g_free(hidp.rd_data);  	return input_device_register(connection, path, &src, &dst, -				driver->uuids[0], hidp.idle_to); +				HID_UUID, hidp.idle_to);  } -void input_remove(struct btd_device_driver *driver, -			struct btd_device *device) +void hid_remove(struct btd_device *device)  { -	const gchar *path = device_get_path(device); - -	DBG("path %s", path); - -	input_device_unregister(path, driver->uuids[0]); +	input_remove(device, HID_UUID);  } -int headset_input_probe(struct btd_device_driver *driver, -			struct btd_device *device, GSList *records) +int headset_probe(struct btd_device *device, GSList *records)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -243,21 +245,26 @@ int headset_input_probe(struct btd_device_driver *driver,  	str2ba(destination, &dst);  	return fake_input_register(connection, path, &src, &dst, -				driver->uuids[0], ch); +				HSP_HS_UUID, ch); +} + +void headset_remove(struct btd_device *device) +{ +	input_remove(device, HSP_HS_UUID);  } -static struct btd_device_driver input_driver = { -	.name	= "input", +static struct btd_device_driver input_hid_driver = { +	.name	= "input-hid",  	.uuids	= BTD_UUIDS(HID_UUID), -	.probe	= input_probe, -	.remove	= input_remove, +	.probe	= hid_probe, +	.remove	= hid_remove,  };  static struct btd_device_driver input_headset_driver = {  	.name	= "input-headset",  	.uuids	= BTD_UUIDS(HSP_HS_UUID), -	.probe	= headset_input_probe, -	.remove	= input_remove, +	.probe	= headset_probe, +	.remove	= headset_remove,  };  int input_manager_init(DBusConnection *conn, GKeyFile *config) @@ -277,7 +284,7 @@ int input_manager_init(DBusConnection *conn, GKeyFile *config)  	server_start(); -	btd_register_device_driver(&input_driver); +	btd_register_device_driver(&input_hid_driver);  	btd_register_device_driver(&input_headset_driver);  	return 0; @@ -287,7 +294,7 @@ void input_manager_exit(void)  {  	server_stop(); -	btd_unregister_device_driver(&input_driver); +	btd_unregister_device_driver(&input_hid_driver);  	btd_unregister_device_driver(&input_headset_driver);  	dbus_connection_unref(connection); diff --git a/network/manager.c b/network/manager.c index 371820cc..c03b7943 100644 --- a/network/manager.c +++ b/network/manager.c @@ -63,14 +63,13 @@ static struct btd_adapter_driver network_nap_server_driver;  static DBusConnection *connection = NULL; -static int network_probe(struct btd_device_driver *driver, -			struct btd_device *device, GSList *records) +static int network_probe(struct btd_device *device, GSList *records, +			uint16_t id)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device);  	const char *source, *destination;  	bdaddr_t src, dst; -	uint16_t id;  	DBG("path %s", path); @@ -79,22 +78,49 @@ static int network_probe(struct btd_device_driver *driver,  	str2ba(source, &src);  	str2ba(destination, &dst); -	id = bnep_service_id(driver->uuids[0]);  	return connection_register(path, &src, &dst, id);  } -static void network_remove(struct btd_device_driver *driver, -			struct btd_device *device) +static void network_remove(struct btd_device *device, uint16_t id)  {  	const gchar *path = device_get_path(device); -	uint16_t id = bnep_service_id(driver->uuids[0]);  	DBG("path %s", path);  	connection_unregister(path, id);  } +static int panu_probe(struct btd_device *device, GSList *records) +{ +	return network_probe(device, records, BNEP_SVC_PANU); +} + +static void panu_remove(struct btd_device *device) +{ +	network_remove(device, BNEP_SVC_PANU); +} + +static int gn_probe(struct btd_device *device, GSList *records) +{ +	return network_probe(device, records, BNEP_SVC_GN); +} + +static void gn_remove(struct btd_device *device) +{ +	network_remove(device, BNEP_SVC_GN); +} + +static int nap_probe(struct btd_device *device, GSList *records) +{ +	return network_probe(device, records, BNEP_SVC_NAP); +} + +static void nap_remove(struct btd_device *device) +{ +	network_remove(device, BNEP_SVC_NAP); +} +  static int network_server_probe(struct adapter *adapter, uint16_t id)  {  	const gchar *path = adapter_get_path(adapter); @@ -121,32 +147,32 @@ static void network_server_remove(struct adapter *adapter, uint16_t id)  	server_unregister(path, id);  } -static int network_panu_server_probe(struct adapter *adapter) +static int panu_server_probe(struct adapter *adapter)  {  	return network_server_probe(adapter, BNEP_SVC_PANU);  } -static int network_gn_server_probe(struct adapter *adapter) +static int gn_server_probe(struct adapter *adapter)  {  	return network_server_probe(adapter, BNEP_SVC_GN);  } -static int network_nap_server_probe(struct adapter *adapter) +static int nap_server_probe(struct adapter *adapter)  {  	return network_server_probe(adapter, BNEP_SVC_NAP);  } -static void network_panu_server_remove(struct adapter *adapter) +static void panu_server_remove(struct adapter *adapter)  {  	network_server_remove(adapter, BNEP_SVC_PANU);  } -static void network_gn_server_remove(struct adapter *adapter) +static void gn_server_remove(struct adapter *adapter)  {  	network_server_remove(adapter, BNEP_SVC_GN);  } -static void network_nap_server_remove(struct adapter *adapter) +static void nap_server_remove(struct adapter *adapter)  {  	network_server_remove(adapter, BNEP_SVC_NAP);  } @@ -154,40 +180,40 @@ static void network_nap_server_remove(struct adapter *adapter)  static struct btd_device_driver network_panu_driver = {  	.name	= "network-panu",  	.uuids	= BTD_UUIDS(PANU_UUID), -	.probe	= network_probe, -	.remove	= network_remove, +	.probe	= panu_probe, +	.remove	= panu_remove,  };  static struct btd_device_driver network_gn_driver = {  	.name	= "network-gn",  	.uuids	= BTD_UUIDS(GN_UUID), -	.probe	= network_probe, -	.remove	= network_remove, +	.probe	= gn_probe, +	.remove	= gn_remove,  };  static struct btd_device_driver network_nap_driver = {  	.name	= "network-nap",  	.uuids	= BTD_UUIDS(NAP_UUID), -	.probe	= network_probe, -	.remove	= network_remove, +	.probe	= nap_probe, +	.remove	= nap_remove,  };  static struct btd_adapter_driver network_panu_server_driver = {  	.name	= "network-panu-server", -	.probe	= network_panu_server_probe, -	.remove	= network_panu_server_remove, +	.probe	= panu_server_probe, +	.remove	= panu_server_remove,  };  static struct btd_adapter_driver network_gn_server_driver = {  	.name	= "network-gn-server", -	.probe	= network_gn_server_probe, -	.remove	= network_gn_server_remove, +	.probe	= gn_server_probe, +	.remove	= gn_server_remove,  };  static struct btd_adapter_driver network_nap_server_driver = {  	.name	= "network-nap-server", -	.probe	= network_nap_server_probe, -	.remove	= network_nap_server_remove, +	.probe	= nap_server_probe, +	.remove	= nap_server_remove,  };  int network_manager_init(DBusConnection *conn, struct network_conf *service_conf) diff --git a/serial/manager.c b/serial/manager.c index ee1bfd16..05af27b4 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -75,9 +75,8 @@  static DBusConnection *connection = NULL; -static int serial_probe(struct btd_device_driver *driver, -			struct btd_device *device, sdp_record_t *rec, -			const char *name) +static int serial_probe(struct btd_device *device, sdp_record_t *rec, +			const char *name, const char *uuid)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -103,45 +102,53 @@ static int serial_probe(struct btd_device_driver *driver,  	str2ba(device_get_address(device), &dst);  	return port_register(connection, path, &src, &dst, name, -			driver->uuids[0], ch); +			uuid, ch);  } -static void serial_remove(struct btd_device_driver *driver, -				struct btd_device *device) +static void serial_remove(struct btd_device *device, const char *uuid)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); -	port_unregister(path, driver->uuids[0]); +	port_unregister(path, uuid);  } -static int port_probe(struct btd_device_driver *driver, -			struct btd_device *device, GSList *records) + +static int port_probe(struct btd_device *device, GSList *records) +{ +	return serial_probe(device, records->data, SERIAL_PORT_NAME, +				SERIAL_PORT_UUID); +} + +static void port_remove(struct btd_device *device) +{ +	return serial_remove(device, SERIAL_PORT_UUID); +} + +static int dialup_probe(struct btd_device *device, GSList *records)  { -	return serial_probe(driver, device, records->data, -			SERIAL_PORT_NAME); +	return serial_probe(device, records->data, DIALUP_NET_NAME, +				DIALUP_NET_UUID);  } -static int dialup_probe(struct btd_device_driver *driver, -			struct btd_device *device, GSList *records) +static void dialup_remove(struct btd_device *device)  { -	return serial_probe(driver, device, records->data, -			DIALUP_NET_NAME); +	return serial_remove(device, DIALUP_NET_UUID);  }  static struct btd_device_driver serial_port_driver = {  	.name	= "serial-port",  	.uuids	= BTD_UUIDS(SERIAL_PORT_UUID),  	.probe	= port_probe, -	.remove	= serial_remove, +	.remove	= port_remove,  };  static struct btd_device_driver serial_dialup_driver = {  	.name	= "serial-dialup",  	.uuids	= BTD_UUIDS(DIALUP_NET_UUID),  	.probe	= dialup_probe, -	.remove	= serial_remove, +	.remove	= dialup_remove,  };  static int proxy_probe(struct adapter *adapter) diff --git a/src/device.c b/src/device.c index ac578f2b..b22695e1 100644 --- a/src/device.c +++ b/src/device.c @@ -574,7 +574,7 @@ void device_remove(DBusConnection *conn, struct btd_device *device)  		struct btd_driver_data *driver_data = list->data;  		driver = driver_data->driver; -		driver->remove(driver, device); +		driver->remove(device);  		g_free(driver_data);  	} @@ -645,7 +645,7 @@ void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *  		if (records) {  			struct btd_driver_data *driver_data = g_new0(struct btd_driver_data, 1); -			err = driver->probe(driver, device, records); +			err = driver->probe(device, records);  			if (err < 0) {  				error("probe failed for driver %s",  							driver->name); @@ -686,7 +686,7 @@ void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t  					(GCompareFunc) strcasecmp))  				continue; -			driver->remove(driver, device); +			driver->remove(device);  			device->drivers = g_slist_remove(device->drivers,  								driver_data); diff --git a/src/driver.h b/src/driver.h index a69ebab1..e27c7de5 100644 --- a/src/driver.h +++ b/src/driver.h @@ -29,10 +29,8 @@ struct btd_device;  struct btd_device_driver {  	const char *name;  	const char **uuids; -	int (*probe) (struct btd_device_driver *driver, -			struct btd_device *device, GSList *records); -	void (*remove) (struct btd_device_driver *driver, -			struct btd_device *device); +	int (*probe) (struct btd_device *device, GSList *records); +	void (*remove) (struct btd_device *device);  };  int btd_register_device_driver(struct btd_device_driver *driver); | 
