summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-10-18 17:31:32 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-10-18 17:31:32 +0000
commita6d4f9cdc6a4d189120dbffeba96a79f72a77c91 (patch)
tree6f4d4d2d7afb688be2cfefd25069c03262db0201 /hcid
parentd4e297cbb9e30d7f6048becfbfcc0937ffd7b0ef (diff)
Add signals for added and removed devices
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus.c62
-rw-r--r--hcid/dbus.h7
2 files changed, 68 insertions, 1 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 1edfc56a..d0e61768 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -743,7 +743,11 @@ void hcid_dbus_exit(void)
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 @@ gboolean hcid_dbus_register_device(uint16_t id)
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 @@ gboolean hcid_dbus_unregister_device(uint16_t id)
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;
}
diff --git a/hcid/dbus.h b/hcid/dbus.h
index c11f1a95..faa19ea4 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -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"
@@ -168,6 +172,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),