diff options
| -rw-r--r-- | common/hal-dummy.c | 5 | ||||
| -rw-r--r-- | common/hal-libhal.c | 49 | ||||
| -rw-r--r-- | common/hal.h | 7 | ||||
| -rw-r--r-- | network/main.c | 2 | 
4 files changed, 49 insertions, 14 deletions
| diff --git a/common/hal-dummy.c b/common/hal-dummy.c index e16a6b67..8d6be05f 100644 --- a/common/hal-dummy.c +++ b/common/hal-dummy.c @@ -35,3 +35,8 @@ int hal_init(DBusConnection *conn)  void hal_cleanup(void)  {  } + +int hal_add_device(struct hal_device *device) +{ +	return 0; +} diff --git a/common/hal-libhal.c b/common/hal-libhal.c index d3fe9717..4ae97098 100644 --- a/common/hal-libhal.c +++ b/common/hal-libhal.c @@ -40,8 +40,6 @@ static LibHalContext *hal_ctx = NULL;  int hal_init(DBusConnection *conn)  { -	char str[64], *udi; -  	hal_ctx = libhal_ctx_new();  	if (!hal_ctx)  		return -ENOMEM; @@ -62,18 +60,6 @@ int hal_init(DBusConnection *conn)  		return -EIO;  	} -	udi = libhal_new_device(hal_ctx, NULL); - -	if (libhal_device_add_capability(hal_ctx, udi, "net", NULL) == FALSE) { -		error("Failed to add device capability"); -	} - -	sprintf(str, "/org/freedesktop/Hal/devices/bluetooth_pan"); - -	if (libhal_device_commit_to_gdl(hal_ctx, udi, str, NULL) == FALSE) { -		error("Failed to add new HAL device"); -	} -  	return 0;  } @@ -88,3 +74,38 @@ void hal_cleanup(void)  	hal_ctx = NULL;  } + +int hal_add_device(struct hal_device *device) +{ +	char udi[128], *dev; +	char *str = "00000000-0000-1000-8000-00805f9b34fb"; + +	dev = libhal_new_device(hal_ctx, NULL); + +	if (libhal_device_add_capability(hal_ctx, dev, +					"bluetooth", NULL) == FALSE) { +		error("Failed to add device capability"); +	} + +	if (libhal_device_set_property_string(hal_ctx, dev, +				"bluetooth.uuid", str, NULL) == FALSE) { +		error("Failed to add UUID property"); +	} + +	if (libhal_device_set_property_bool(hal_ctx, dev, +				"bluetooth.is_connected", FALSE, NULL) == FALSE) { +		error("Failed to add connected state property"); +	} + +	sprintf(udi, "/org/freedesktop/Hal/devices/bluetooth_network_connection_aabbccddeeff"); + +	if (libhal_remove_device(hal_ctx, udi, NULL) == FALSE) { +		error("Can't remove old HAL device"); +	} + +	if (libhal_device_commit_to_gdl(hal_ctx, dev, udi, NULL) == FALSE) { +		error("Failed to add new HAL device"); +	} + +	return 0; +} diff --git a/common/hal.h b/common/hal.h index 5ff86a8a..f2afacad 100644 --- a/common/hal.h +++ b/common/hal.h @@ -25,3 +25,10 @@  int hal_init(DBusConnection *conn);  void hal_cleanup(void); + +struct hal_device { +	char *udi; +	char uuid[37]; +}; + +int hal_add_device(struct hal_device *); diff --git a/network/main.c b/network/main.c index 607285f7..d6c3ac0d 100644 --- a/network/main.c +++ b/network/main.c @@ -69,6 +69,8 @@ int main(int argc, char *argv[])  	hal_init(NULL); +	hal_add_device(NULL); +  	if (network_init() == -1)  		goto fail; | 
