diff options
Diffstat (limited to 'hcid/dbus-adapter.c')
-rw-r--r-- | hcid/dbus-adapter.c | 238 |
1 files changed, 159 insertions, 79 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 0466404f..ee9be216 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -3088,89 +3088,169 @@ GSList *service_classes_str(uint32_t class) return l; } -static struct service_data dev_services[] = { - { "GetInfo", adapter_get_info }, - { "GetAddress", adapter_get_address }, - { "GetVersion", adapter_get_version }, - { "GetRevision", adapter_get_revision }, - { "GetManufacturer", adapter_get_manufacturer }, - { "GetCompany", adapter_get_company }, - { "GetMode", adapter_get_mode }, - { "SetMode", adapter_set_mode }, - { "GetDiscoverableTimeout", adapter_get_discoverable_to }, - { "SetDiscoverableTimeout", adapter_set_discoverable_to }, - { "IsConnectable", adapter_is_connectable }, - { "IsDiscoverable", adapter_is_discoverable }, - { "IsConnected", adapter_is_connected }, - { "ListConnections", adapter_list_connections }, - { "GetMajorClass", adapter_get_major_class }, - { "ListAvailableMinorClasses", adapter_list_minor_classes }, - { "GetMinorClass", adapter_get_minor_class }, - { "SetMinorClass", adapter_set_minor_class }, - { "GetServiceClasses", adapter_get_service_classes }, - { "GetName", adapter_get_name }, - { "SetName", adapter_set_name }, +static DBusMethodVTable adapter_methods[] = { + { "GetInfo", adapter_get_info, + "", "{}" }, + { "GetAddress", adapter_get_address, + "", "s" }, + { "GetVersion", adapter_get_version, + "", "s" }, + { "GetRevision", adapter_get_revision, + "", "s" }, + { "GetManufacturer", adapter_get_manufacturer, + "", "s" }, + { "GetCompany", adapter_get_company, + "", "s" }, + { "GetMode", adapter_get_mode, + "", "s" }, + { "SetMode", adapter_set_mode, + "s", "" }, + { "GetDiscoverableTimeout", adapter_get_discoverable_to, + "", "u" }, + { "SetDiscoverableTimeout", adapter_set_discoverable_to, + "u", "" }, + { "IsConnectable", adapter_is_connectable, + "", "b" }, + { "IsDiscoverable", adapter_is_discoverable, + "", "b" }, + { "IsConnected", adapter_is_connected, + "s", "b" }, + { "ListConnections", adapter_list_connections, + "", "as" }, + { "GetMajorClass", adapter_get_major_class, + "", "s" }, + { "ListAvailableMinorClasses", adapter_list_minor_classes, + "", "as" }, + { "GetMinorClass", adapter_get_minor_class, + "", "s" }, + { "SetMinorClass", adapter_set_minor_class, + "s", "" }, + { "GetServiceClasses", adapter_get_service_classes, + "", "as" }, + { "GetName", adapter_get_name, + "", "s" }, + { "SetName", adapter_set_name, + "s", "" }, - { "GetRemoteInfo", adapter_get_remote_info }, - { "GetRemoteServiceRecord", adapter_get_remote_svc }, - { "GetRemoteServiceRecordAsXML", adapter_get_remote_svc_xml }, - { "GetRemoteServiceHandles", adapter_get_remote_svc_handles }, - - { "GetRemoteVersion", adapter_get_remote_version }, - { "GetRemoteRevision", adapter_get_remote_revision }, - { "GetRemoteManufacturer", adapter_get_remote_manufacturer }, - { "GetRemoteCompany", adapter_get_remote_company }, - { "GetRemoteMajorClass", adapter_get_remote_major_class }, - { "GetRemoteMinorClass", adapter_get_remote_minor_class }, - { "GetRemoteServiceClasses", adapter_get_remote_service_cls }, - { "GetRemoteClass", adapter_get_remote_class }, - { "GetRemoteFeatures", adapter_get_remote_features }, - { "GetRemoteName", adapter_get_remote_name }, - { "GetRemoteAlias", adapter_get_remote_alias }, - { "SetRemoteAlias", adapter_set_remote_alias }, - { "ClearRemoteAlias", adapter_clear_remote_alias }, - - { "LastSeen", adapter_last_seen }, - { "LastUsed", adapter_last_used }, - - { "DisconnectRemoteDevice", adapter_dc_remote_device }, - - { "CreateBonding", adapter_create_bonding }, - { "CancelBondingProcess", adapter_cancel_bonding }, - { "RemoveBonding", adapter_remove_bonding }, - { "HasBonding", adapter_has_bonding }, - { "ListBondings", adapter_list_bondings }, - { "GetPinCodeLength", adapter_get_pin_code_length }, - { "GetEncryptionKeySize", adapter_get_encryption_key_size }, - - { "StartPeriodicDiscovery", adapter_start_periodic }, - { "StopPeriodicDiscovery", adapter_stop_periodic }, - { "IsPeriodicDiscovery", adapter_is_periodic }, - { "SetPeriodicDiscoveryNameResolving", adapter_set_pdiscov_resolve }, - { "GetPeriodicDiscoveryNameResolving", adapter_get_pdiscov_resolve }, - - { "DiscoverDevices", adapter_discover_devices }, - { "DiscoverDevicesWithoutNameResolving", adapter_discover_devices }, - { "CancelDiscovery", adapter_cancel_discovery }, - - { "ListRemoteDevices", adapter_list_remote_devices }, - { "ListRecentRemoteDevices", adapter_list_recent_remote_devices }, - - { "SetTrusted", adapter_set_trusted }, - { "IsTrusted", adapter_is_trusted }, - { "RemoveTrust", adapter_remove_trust }, + { "GetRemoteInfo", adapter_get_remote_info, + "s", "{}" }, + { "GetRemoteServiceRecord", adapter_get_remote_svc, + "su", "ay" }, + { "GetRemoteServiceRecordAsXML", adapter_get_remote_svc_xml, + "su", "s" }, + { "GetRemoteServiceHandles", adapter_get_remote_svc_handles, + "ss", "au" }, + + { "GetRemoteVersion", adapter_get_remote_version, + "s", "s" }, + { "GetRemoteRevision", adapter_get_remote_revision, + "s", "s" }, + { "GetRemoteManufacturer", adapter_get_remote_manufacturer, + "s", "s" }, + { "GetRemoteCompany", adapter_get_remote_company, + "s", "s" }, + { "GetRemoteMajorClass", adapter_get_remote_major_class, + "s", "s" }, + { "GetRemoteMinorClass", adapter_get_remote_minor_class, + "s", "s" }, + { "GetRemoteServiceClasses", adapter_get_remote_service_cls, + "s", "as" }, + { "GetRemoteClass", adapter_get_remote_class, + "s", "u" }, + { "GetRemoteFeatures", adapter_get_remote_features, + "s", "ay" }, + { "GetRemoteName", adapter_get_remote_name, + "s", "s" }, + { "GetRemoteAlias", adapter_get_remote_alias, + "s", "s" }, + { "SetRemoteAlias", adapter_set_remote_alias, + "ss", "" }, + { "ClearRemoteAlias", adapter_clear_remote_alias, + "s", "" }, + + { "LastSeen", adapter_last_seen, + "s", "s" }, + { "LastUsed", adapter_last_used, + "s", "s" }, + + { "DisconnectRemoteDevice", adapter_dc_remote_device, + "s", "" }, + + { "CreateBonding", adapter_create_bonding, + "s", "" }, + { "CancelBondingProcess", adapter_cancel_bonding, + "s", "" }, + { "RemoveBonding", adapter_remove_bonding, + "s", "" }, + { "HasBonding", adapter_has_bonding, + "s", "b" }, + { "ListBondings", adapter_list_bondings, + "", "as" }, + { "GetPinCodeLength", adapter_get_pin_code_length, + "s", "y" }, + { "GetEncryptionKeySize", adapter_get_encryption_key_size, + "s", "y" }, + + { "StartPeriodicDiscovery", adapter_start_periodic, + "", "" }, + { "StopPeriodicDiscovery", adapter_stop_periodic, + "", "" }, + { "IsPeriodicDiscovery", adapter_is_periodic, + "", "b" }, + { "SetPeriodicDiscoveryNameResolving", adapter_set_pdiscov_resolve, + "b", "" }, + { "GetPeriodicDiscoveryNameResolving", adapter_get_pdiscov_resolve, + "", "b" }, + + { "DiscoverDevices", adapter_discover_devices, + "", "" }, + { "DiscoverDevicesWithoutNameResolving", adapter_discover_devices, + "", "" }, + { "CancelDiscovery", adapter_cancel_discovery, + "", "" }, + + { "ListRemoteDevices", adapter_list_remote_devices, + "", "as" }, + { "ListRecentRemoteDevices", adapter_list_recent_remote_devices, + "", "as" }, + + { "SetTrusted", adapter_set_trusted, + "s", "" }, + { "IsTrusted", adapter_is_trusted, + "s", "b" }, + { "RemoveTrust", adapter_remove_trust, + "s", "" }, + + { NULL, NULL, NULL, NULL } +}; +static DBusSignalVTable adapter_signals[] = { + { "ModeChanged", "s" }, + { "DiscoverableTimeoutChanged", "u" }, + { "MinorClassChanged", "s" }, + { "NameChanged", "s" }, + { "DiscoveryStarted", "" }, + { "DiscoveryCompleted", "" }, + { "RemoteDeviceFound", "sun" }, + { "RemoteDeviceDisappeared", "s" }, + { "RemoteClassUpdated", "su" }, + { "RemoteNameUpdated", "ss" }, + { "RemoteNameFailed", "s" }, + { "RemoteNameRequested", "s" }, + { "RemoteAliasChanged", "ss" }, + { "RemoteAliasCleared", "s" }, + { "RemoteDeviceConnected", "s" }, + { "RemoteDeviceDisconnectRequested", "s" }, + { "RemoteDeviceDisconnected", "s" }, + { "BondingCreated", "s" }, + { "BondingRemoved", "s" }, { NULL, NULL } }; -DBusHandlerResult handle_adapter_method(DBusConnection *conn, DBusMessage *msg, void *data) +dbus_bool_t adapter_init(DBusConnection *conn, const char *path) { - service_handler_func_t handler; - - handler = find_service_handler(dev_services, msg); - - if (handler) - return handler(conn, msg, data); - else - return error_unknown_method(conn, msg); + return dbus_connection_register_interface(conn, path, ADAPTER_INTERFACE, + adapter_methods, + adapter_signals, NULL); } + |