diff options
| author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2009-01-20 16:34:40 -0300 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2009-01-21 12:26:20 -0300 | 
| commit | be2320f464ee361ec05be6d94201829282006d7e (patch) | |
| tree | 2e9b98c4134b0fa623820de65911c35a417e5b3a /src | |
| parent | a2da56b3aa57890db60205c9e75618c264bec6b0 (diff) | |
Fix bug which prevents emitting DeviceDisappered.
Diffstat (limited to 'src')
| -rw-r--r-- | src/adapter.c | 62 | ||||
| -rw-r--r-- | src/dbus-hci.c | 5 | 
2 files changed, 30 insertions, 37 deletions
| diff --git a/src/adapter.c b/src/adapter.c index c4fa3212..ca41be7f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -176,20 +176,6 @@ static inline DBusMessage *unsupported_major_class(DBusMessage *msg)  			"Unsupported Major Class");  } -static void send_out_of_range(const char *path, GSList *l) -{ -	while (l) { -		const char *peer_addr = l->data; - -		g_dbus_emit_signal(connection, path, -				ADAPTER_INTERFACE, "DeviceDisappeared", -				DBUS_TYPE_STRING, &peer_addr, -				DBUS_TYPE_INVALID); - -		l = l->next; -	} -} -  static int found_device_cmp(const struct remote_dev_info *d1,  			const struct remote_dev_info *d2)  { @@ -635,6 +621,11 @@ static void session_remove(struct session_req *req)  		debug("Stopping discovery"); +		g_slist_foreach(adapter->found_devices, (GFunc) dev_info_free, +				NULL); +		g_slist_free(adapter->found_devices); +		adapter->found_devices = NULL; +  		if (adapter->state & STD_INQUIRY)  			cancel_discovery(adapter);  		else if (adapter->scheduler_id) @@ -2416,18 +2407,9 @@ void adapter_set_state(struct btd_adapter *adapter, int state)  		adapter->scheduler_id = g_timeout_add_seconds(main_opts.inqmode,  				(GSourceFunc) start_inquiry, adapter); -	if (!discov_active && adapter->found_devices) { -		g_slist_foreach(adapter->found_devices, -					(GFunc) dev_info_free, NULL); -		g_slist_free(adapter->found_devices); -		adapter->found_devices = NULL; -	} - -	if (!discov_active && adapter->oor_devices) { -		g_slist_foreach(adapter->oor_devices, (GFunc) g_free, NULL); -		g_slist_free(adapter->oor_devices); -		adapter->oor_devices = NULL; -	} +	/* Send out of range */ +	if (!discov_active) +		adapter_update_oor_devices(adapter);  	emit_property_changed(connection, path,  				ADAPTER_INTERFACE, "Discovering", @@ -2527,30 +2509,46 @@ int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)  	if (!dev)  		return -1; -	adapter->found_devices = g_slist_remove(adapter->found_devices, dev); -	dev_info_free(dev); +	dev->name_status = NAME_NOT_REQUIRED;  	return 0;  }  void adapter_update_oor_devices(struct btd_adapter *adapter)  { -	GSList *l = adapter->found_devices; +	GSList *l;  	struct remote_dev_info *dev;  	bdaddr_t tmp; -	send_out_of_range(adapter->path, adapter->oor_devices); +	for (l = adapter->oor_devices; l; l = l->next) { +		char *address = l->data; +		struct remote_dev_info match; + +		memset(&match, 0, sizeof(struct remote_dev_info)); +		str2ba(address, &match.bdaddr); + +		g_dbus_emit_signal(connection, adapter->path, +				ADAPTER_INTERFACE, "DeviceDisappeared", +				DBUS_TYPE_STRING, &address, +				DBUS_TYPE_INVALID); + +		dev = adapter_search_found_devices(adapter, &match); +		if (!dev) +			continue; + +		adapter->found_devices = g_slist_remove(adapter->found_devices, dev); +		dev_info_free(dev); +	}  	g_slist_foreach(adapter->oor_devices, (GFunc) free, NULL);  	g_slist_free(adapter->oor_devices);  	adapter->oor_devices = NULL; -	while (l) { +	for (l = adapter->found_devices; l; l = l->next) {  		dev = l->data;  		baswap(&tmp, &dev->bdaddr);  		adapter->oor_devices = g_slist_append(adapter->oor_devices,  							batostr(&tmp)); -		l = l->next;  	}  } diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 85805906..562e6652 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -556,11 +556,6 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)  	path = adapter_get_path(adapter); -	/* Out of range verification */ -	if ((adapter_get_state(adapter) & PERIODIC_INQUIRY) && -				!(adapter_get_state(adapter) & STD_INQUIRY)) -		adapter_update_oor_devices(adapter); -  	/*  	 * The following scenarios can happen:  	 * 1. standard inquiry: always send discovery completed signal | 
