diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile.am | 13 | ||||
-rw-r--r-- | common/hal-dummy.c | 47 | ||||
-rw-r--r-- | common/hal-libhal.c | 149 | ||||
-rw-r--r-- | common/hal.h | 35 |
4 files changed, 3 insertions, 241 deletions
diff --git a/common/Makefile.am b/common/Makefile.am index c231319b..7dac6b6a 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -1,10 +1,4 @@ -if HAL -hal_sources = hal-libhal.c -else -hal_sources = hal-dummy.c -endif - if INOTIFY notify_sources = notify-inotify.c else @@ -16,8 +10,8 @@ noinst_LIBRARIES = libhelper.a libhelper_a_SOURCES = oui.h oui.c dbus.h dbus.c \ textfile.h textfile.c logging.h logging.c \ dbus-helper.h dbus-helper.c error.h error.c \ - glib-helper.h glib-helper.c sdp-xml.h sdp-xml.c sdp-glib.c \ - hal.h $(hal_sources) notify.h $(notify_sources) + glib-helper.h glib-helper.c notify.h $(notify_sources) \ + sdp-xml.h sdp-xml.c sdp-glib.c noinst_PROGRAMS = test_textfile @@ -25,7 +19,6 @@ test_textfile_LDADD = libhelper.a AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ -EXTRA_DIST = ppoll.h uinput.h hal-dummy.c hal-libhal.c \ - notify-dummy.c notify-inotify.c +EXTRA_DIST = ppoll.h uinput.h notify-dummy.c notify-inotify.c MAINTAINERCLEANFILES = Makefile.in diff --git a/common/hal-dummy.c b/common/hal-dummy.c deleted file mode 100644 index a049cda9..00000000 --- a/common/hal-dummy.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "hal.h" - -int hal_init(DBusConnection *conn) -{ - return 0; -} - -void hal_cleanup(void) -{ -} - -int hal_create_device(struct hal_device *device) -{ - return 0; -} - -int hal_remove_device(struct hal_device *device) -{ - return 0; -} diff --git a/common/hal-libhal.c b/common/hal-libhal.c deleted file mode 100644 index 63b5677e..00000000 --- a/common/hal-libhal.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> - -#include <dbus/dbus.h> -#include <hal/libhal.h> - -#include "logging.h" -#include "dbus.h" - -#include "hal.h" - -static LibHalContext *hal_ctx = NULL; - -static DBusHandlerResult filter_function(DBusConnection *connection, - DBusMessage *message, void *userdata) -{ - info("filter_function: sender=%s destination=%s obj_path=%s interface=%s method=%s", - dbus_message_get_sender (message), - dbus_message_get_destination (message), - dbus_message_get_path (message), - dbus_message_get_interface (message), - dbus_message_get_member (message)); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -int hal_init(DBusConnection *conn) -{ - hal_ctx = libhal_ctx_new(); - if (!hal_ctx) - return -ENOMEM; - - dbus_connection_add_filter(conn, filter_function, NULL, NULL); - - if (libhal_ctx_set_dbus_connection(hal_ctx, conn) == FALSE) { - error("Failed to connect HAL via system bus"); - libhal_ctx_free(hal_ctx); - hal_ctx = NULL; - return -EIO; - } - - if (libhal_ctx_init(hal_ctx, NULL) == FALSE) { - error("Unable to init HAL context"); - libhal_ctx_free(hal_ctx); - hal_ctx = NULL; - return -EIO; - } - - return 0; -} - -void hal_cleanup(void) -{ - if (!hal_ctx) - return; - - libhal_ctx_shutdown(hal_ctx, NULL); - - libhal_ctx_free(hal_ctx); - - hal_ctx = NULL; -} - -int hal_create_device(struct hal_device *device) -{ - DBusError err; - char udi[128], *dev; - char *str = "00000000-0000-1000-8000-00805f9b34fb"; - - dev = libhal_new_device(hal_ctx, NULL); - - 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"); - } - - if (libhal_device_add_capability(hal_ctx, dev, - "bluetooth", NULL) == FALSE) { - error("Failed to add device capability"); - } - - sprintf(udi, "/org/freedesktop/Hal/devices/bluetooth_test"); - - dbus_error_init(&err); - if (libhal_device_claim_interface(hal_ctx, dev, - "org.freedesktop.Hal.Device.MyBluetooth", - " <method name=\"Connect\">\n" - " </method>\n" - " <method name=\"Disconnect\">\n" - " </method>\n", - &err) == FALSE) { - error("Failed to claim to interface: ", err.message); - dbus_error_free(&err); - } - - if (libhal_device_commit_to_gdl(hal_ctx, dev, udi, NULL) == FALSE) { - error("Failed to create HAL device"); - } - - free(dev); - - return 0; -} - -int hal_remove_device(struct hal_device *device) -{ - char udi[128]; - - sprintf(udi, "/org/freedesktop/Hal/devices/bluetooth_test"); - - if (libhal_remove_device(hal_ctx, udi, NULL) == FALSE) { - error("Failed to remove HAL device"); - } - - return 0; -} diff --git a/common/hal.h b/common/hal.h deleted file mode 100644 index 075ceb17..00000000 --- a/common/hal.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include <dbus/dbus.h> - -int hal_init(DBusConnection *conn); -void hal_cleanup(void); - -struct hal_device { - char *udi; - char uuid[37]; -}; - -int hal_create_device(struct hal_device *); -int hal_remove_device(struct hal_device *); |