diff options
| -rw-r--r-- | serial/manager.c | 31 | ||||
| -rw-r--r-- | serial/port.c | 30 | ||||
| -rw-r--r-- | serial/port.h | 3 | 
3 files changed, 36 insertions, 28 deletions
| diff --git a/serial/manager.c b/serial/manager.c index e9166504..064629f2 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -74,17 +74,21 @@  static DBusConnection *connection = NULL; -static int serial_probe(struct btd_device *device, const sdp_record_t *rec, -			const char *name, const char *uuid) +static int serial_probe(struct btd_device *device, const char *uuid)  {  	struct btd_adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device);  	sdp_list_t *protos;  	int ch;  	bdaddr_t src, dst; +	const sdp_record_t *rec;  	DBG("path %s", path); +	rec = btd_device_get_record(device, uuid); +	if (!rec) +		return -EINVAL; +  	if (sdp_get_access_protos(rec, &protos) < 0)  		return -EINVAL; @@ -100,8 +104,7 @@ static int serial_probe(struct btd_device *device, const sdp_record_t *rec,  	adapter_get_address(adapter, &src);  	device_get_address(device, &dst); -	return port_register(connection, path, &src, &dst, name, -			uuid, ch); +	return port_register(connection, path, &src, &dst, uuid, ch);  }  static void serial_remove(struct btd_device *device, const char *uuid) @@ -116,14 +119,12 @@ static void serial_remove(struct btd_device *device, const char *uuid)  static int port_probe(struct btd_device *device, GSList *uuids)  { -	const sdp_record_t *record; - -	record = btd_device_get_record(device, uuids->data); -	if (!record) -		return -1; +	while (uuids) { +		serial_probe(device, uuids->data); +		uuids = uuids->next; +	} -	return serial_probe(device, record, SERIAL_PORT_NAME, -				SERIAL_PORT_UUID); +	return 0;  }  static void port_remove(struct btd_device *device) @@ -133,13 +134,7 @@ static void port_remove(struct btd_device *device)  static int dialup_probe(struct btd_device *device, GSList *uuids)  { -	const sdp_record_t *record; - -	record = btd_device_get_record(device, uuids->data); -	if (!record) -		return -1; - -	return serial_probe(device, record, DIALUP_NET_NAME, DIALUP_NET_UUID); +	return serial_probe(device, DIALUP_NET_UUID);  }  static void dialup_remove(struct btd_device *device) diff --git a/serial/port.c b/serial/port.c index dc146e79..a446616f 100644 --- a/serial/port.c +++ b/serial/port.c @@ -72,7 +72,6 @@ struct serial_port {  	DBusMessage	*msg;		/* for name listener handling */  	int16_t		id;		/* RFCOMM device id */  	uint8_t		channel;	/* RFCOMM channel */ -	char		*name;		/* service friendly name */  	char		*uuid;		/* service identification */  	char		*dev;		/* RFCOMM device name */  	guint		listener_id; @@ -101,15 +100,33 @@ static struct serial_port *find_port(GSList *ports, const char *pattern)  	for (l = ports; l != NULL; l = l->next) {  		struct serial_port *port = l->data; - -		if (!strcasecmp(port->name, pattern)) -			return port; +		uuid_t uuid; +		char *uuid_str; +		int ret;  		if (!strcasecmp(port->uuid, pattern))  			return port;  		if (port->dev && !strcmp(port->dev, pattern))  			return port; + +		/* The following steps converts a potential friendly-name to a +		 * UUID-128 string and compares it with the port UUID (which is +		 * also stored as a UUID-128 string */ + +		if (bt_string2uuid(&uuid, pattern) < 0) +			continue; + +		uuid_str = bt_uuid2string(&uuid); +		if (!uuid_str) +			continue; + +		ret = strcasecmp(port->uuid, uuid_str); + +		g_free(uuid_str); + +		if (ret == 0) +			return port;  	}  	return NULL; @@ -154,7 +171,6 @@ static void serial_port_free(struct serial_port *port)  {  	if (port->id)  		port_release(port); -	g_free(port->name);  	g_free(port->uuid);  	g_free(port);  } @@ -427,8 +443,7 @@ static struct serial_device *create_serial_device(DBusConnection *conn,  }  int port_register(DBusConnection *conn, const char *path, bdaddr_t *src, -		  bdaddr_t *dst, const char *name, const char *uuid, -		  uint8_t channel) +		  bdaddr_t *dst, const char *uuid, uint8_t channel)  {  	struct serial_device *device;  	struct serial_port *port; @@ -445,7 +460,6 @@ int port_register(DBusConnection *conn, const char *path, bdaddr_t *src,  		return 0;  	port = g_new0(struct serial_port, 1); -	port->name = g_strdup(name);  	port->uuid = g_strdup(uuid);  	port->channel = channel;  	port->device = device; diff --git a/serial/port.h b/serial/port.h index 381abe0c..6002ae02 100644 --- a/serial/port.h +++ b/serial/port.h @@ -24,7 +24,6 @@  void port_release_all(void);  int port_register(DBusConnection *conn, const char *path, bdaddr_t *src, -		  bdaddr_t *dst, const char *name, const char *uuid, -		  uint8_t channel); +		  bdaddr_t *dst, const char *name, uint8_t channel);  int port_unregister(const char *path, const char *uuid); | 
