--- bluez-utils-cvs.orig/hcid/dbus.h 2005-10-17 18:16:53.000000000 -0200 +++ bluez-utils-cvs-hcid/hcid/dbus.h 2005-10-18 08:08:10.000000000 -0200 @@ -111,12 +111,16 @@ #define BLUEZ_HCI_PATH MANAGER_PATH "/" BLUEZ_HCI #define BLUEZ_HCI_INTERFACE MANAGER_INTERFACE "." BLUEZ_HCI -//HCI signals +//Device based HCI signals #define BLUEZ_HCI_INQ_START "InquiryStart" #define BLUEZ_HCI_INQ_COMPLETE "InquiryComplete" #define BLUEZ_HCI_INQ_RESULT "InquiryResult" #define BLUEZ_HCI_REMOTE_NAME "RemoteName" +//HCI signals sent in the BLUEZ_HCI_PATH +#define BLUEZ_HCI_DEV_ADDED "DeviceAdded" +#define BLUEZ_HCI_DEV_REMOVED "DeviceRemoved" + //HCI Provided services #define HCI_PERIODIC_INQ "PeriodicInquiry" #define HCI_CANCEL_PERIODIC_INQ "CancelPeriodic" @@ -169,6 +173,7 @@ DBUS_STRUCT_END_CHAR_AS_STRING\ __END_SIG__ + /* BLUEZ_DBUS_ERROR * EFailed error messages signature is : su * Where the first argument is a string(error message description), --- bluez-utils-cvs.orig/hcid/dbus.c 2005-10-17 18:16:38.000000000 -0200 +++ bluez-utils-cvs-hcid/hcid/dbus.c 2005-10-18 08:05:43.000000000 -0200 @@ -743,7 +743,11 @@ gboolean hcid_dbus_register_device(uint16_t id) { + char dev[BLUETOOTH_DEVICE_NAME_LEN]; struct profile_obj_path_data *ptr = obj_path_table; + DBusMessage *message = NULL; + const char *pdev = dev; + DBusMessageIter iter; int ret = -1; if (!connection) @@ -757,12 +761,43 @@ if (!ret) num_adapters++; + + message = dbus_message_new_signal(BLUEZ_HCI_PATH, + BLUEZ_HCI_INTERFACE, BLUEZ_HCI_DEV_ADDED); + + if (message == NULL) { + syslog(LOG_ERR, "Can't allocate D-BUS remote name message"); + goto failed; + } + + sprintf(dev, "hci%d", id); + + dbus_message_iter_init_append(message, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING ,&pdev); + + if (dbus_connection_send(connection, message, NULL) == FALSE) { + syslog(LOG_ERR, "Can't send D-BUS added device message"); + goto failed; + } + + dbus_connection_flush(connection); + +failed: + /* if the signal can't be sent ignore the error */ + + if (message) + dbus_message_unref(message); + return TRUE; } gboolean hcid_dbus_unregister_device(uint16_t id) { + char dev[BLUETOOTH_DEVICE_NAME_LEN]; struct profile_obj_path_data *ptr = obj_path_table; + DBusMessage *message = NULL; + const char *pdev = dev; + DBusMessageIter iter; int dft_unreg = 0; if (!connection) @@ -777,6 +812,33 @@ ptr->dft_reg = 0; } + + message = dbus_message_new_signal(BLUEZ_HCI_PATH, + BLUEZ_HCI_INTERFACE, BLUEZ_HCI_DEV_REMOVED); + + if (message == NULL) { + syslog(LOG_ERR, "Can't allocate D-BUS device removed message"); + goto failed; + } + + sprintf(dev, "hci%d", id); + + dbus_message_iter_init_append(message, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING ,&pdev); + + if (dbus_connection_send(connection, message, NULL) == FALSE) { + syslog(LOG_ERR, "Can't send D-BUS removed device message"); + goto failed; + } + + dbus_connection_flush(connection); + +failed: + /* if the signal can't be sent ignore the error */ + + if (message) + dbus_message_unref(message); + return TRUE; }