summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-24 14:18:50 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-24 14:18:50 +0000
commit45d7f9ac3228a3b27ef3374e8cec13af1dd4f1fa (patch)
treebce1a4a7d32b7213ba962e76864c8a06dee92f33 /hcid
parente0e5d97ac34119a2cf91d096f20e203d5ffe676d (diff)
Move service registration/authorization methods to database interface
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-api.txt254
-rw-r--r--hcid/dbus-database.c98
-rw-r--r--hcid/dbus-manager.c51
3 files changed, 224 insertions, 179 deletions
diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt
index d6c382ec..2734fab0 100644
--- a/hcid/dbus-api.txt
+++ b/hcid/dbus-api.txt
@@ -187,18 +187,6 @@ Methods uint32 InterfaceVersion()
Valid patterns are the same as for FindService(). If
the service is not running it will be started.
- void RegisterService(string identifier, string name, string description)
-
- This method registers a new service specified by
- its unique identifier. This is only needed for
- services that are not started through the
- Bluetooth daemon.
-
- void UnregisterService(string identifier)
-
- This method unregisters a service specified by
- its unique identifier.
-
Signals void AdapterAdded(string path)
Parameter is object path of added adapter.
@@ -227,6 +215,18 @@ Service org.bluez
Interface org.bluez.Database
Object path /org/bluez or /org/bluez/{hci0,hci1,...}
+Methods void RegisterService(string identifier, string name, string description) [experimental]
+
+ This method registers a new service specified by
+ its unique identifier. This is only needed for
+ services that are not started through the
+ Bluetooth daemon.
+
+ void UnregisterService(string identifier) [experimental]
+
+ This method unregisters a service specified by
+ its unique identifier.
+
uint32 AddServiceRecord(array{byte})
Adds a new service record and returns the assigned
@@ -255,6 +255,23 @@ Object path /org/bluez or /org/bluez/{hci0,hci1,...}
org.bluez.Error.DoesNotExist
org.bluez.Error.Failed
+ void RequestAuthorization(string address, string path) [experimental]
+
+ This method gets called when a service wants to check
+ if a remote device is authorized to perform some
+ action. The authorization request is forwarded to an
+ authorization agent.
+
+ The address parameter is the Bluetooth address of the
+ remote device and the path is an object path provided
+ by the service requesting the authorization.
+
+ void CancelAuthorizationRequest(string address, string path) [experimental]
+
+ This method cancels an authorization process requested
+ by a previous call to RequestAuthorization(). The
+ address and path parameters must match.
+
Adapter hierarchy
=================
@@ -504,7 +521,7 @@ Methods string GetAddress()
Example: "Bluetooth 2.0 + EDR"
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
string GetRemoteRevision(string address)
@@ -516,7 +533,7 @@ Methods string GetAddress()
Example: "HCI 19.2"
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
string GetRemoteManufacturer(string address)
@@ -525,7 +542,7 @@ Methods string GetAddress()
Example: "Nokia Mobile Phones"
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
string GetRemoteCompany(string address)
@@ -565,7 +582,7 @@ Methods string GetAddress()
Example: ["networking", "object transfer"]
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
uint32 GetRemoteClass(string address)
@@ -573,14 +590,14 @@ Methods string GetAddress()
encoded as 32 bit integer.
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
array{byte} GetRemoteFeatures(string address)
Get the remote features encoded as bit mask.
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NotAvailable
+ org.bluez.Error.NotAvailable
string GetRemoteName(string address)
@@ -602,7 +619,7 @@ Methods string GetAddress()
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotReady
- org.bluez.Error.RequestDeferred
+ org.bluez.Error.RequestDeferred
string GetRemoteAlias(string address)
@@ -682,8 +699,8 @@ Methods string GetAddress()
org.bluez.Error.Failed
org.bluez.Error.NoSuchAdapter
org.bluez.Error.InvalidArguments
- org.bluez.Error.NotConnected
- org.bluez.Error.InProgress
+ org.bluez.Error.NotConnected
+ org.bluez.Error.InProgress
void CreateBonding(string address)
@@ -707,14 +724,14 @@ Methods string GetAddress()
Possible errors: org.bluez.Error.NotReady
org.bluez.Error.Failed
org.bluez.Error.InvalidArguments
- org.bluez.Error.AlreadyExists
- org.bluez.Error.InProgress
+ org.bluez.Error.AlreadyExists
+ org.bluez.Error.InProgress
org.bluez.Error.NoSuchAdapter
- org.bluez.Error.ConnectionAttemptFailed
- org.bluez.Error.AuthenticationFailed
- org.bluez.Error.AuthenticationTimeout
- org.bluez.Error.AuthenticationRejected
- org.bluez.Error.AuthenticationCanceled
+ org.bluez.Error.ConnectionAttemptFailed
+ org.bluez.Error.AuthenticationFailed
+ org.bluez.Error.AuthenticationTimeout
+ org.bluez.Error.AuthenticationRejected
+ org.bluez.Error.AuthenticationCanceled
void CancelBondingProcess(string address)
@@ -779,7 +796,7 @@ Methods string GetAddress()
has been established.
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.Failed
+ org.bluez.Error.Failed
void DiscoverDevices()
@@ -850,7 +867,7 @@ Methods string GetAddress()
org.bluez.Error.NotAuthorized
org.bluez.Error.NoSuchAdapter
- boolean IsPeriodicDiscovery()
+ boolean IsPeriodicDiscovery()
Returns true if the periodic inquiry is active and
false if it is switched off.
@@ -898,8 +915,8 @@ Methods string GetAddress()
format.
Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.InProgress
- org.bluez.Error.Failed
+ org.bluez.Error.InProgress
+ org.bluez.Error.Failed
array{string} ListRemoteDevices()
@@ -1017,6 +1034,83 @@ Signals void ModeChanged(string mode)
Signals that a bonding was removed.
+Service hierarchy
+=================
+
+Service org.bluez
+Interface org.bluez.Service
+Object path path from org.bluez.Manager.ListServices()
+
+Methods string GetIdentifier()
+
+ This method returns the service identifier.
+
+ string GetName()
+
+ This method returns the service name.
+
+ string GetDescription()
+
+ This method returns the service description.
+
+ void Start()
+
+ This method tells the system to start the
+ service.
+
+ void Stop()
+
+ This method tells the system to stop the
+ service.
+
+ boolean IsRunning()
+
+ Returns true if the service has been started and
+ is currently active. Otherwise, it returns false.
+
+ array{string} ListUsers() [experimental]
+
+ Returns list of current users (device addresses)
+ of the service.
+
+ void RemoveUser(string address) [experimental]
+
+ Removes a user of the service. The address parameter
+ must match one of the current users of the service.
+
+ void SetTrusted(string address) [experimental]
+
+ Marks the user as trusted.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.AlreadyExists
+
+ boolean IsTrusted(string address) [experimental]
+
+ Returns true if the user is trusted or false otherwise.
+ The address parameter must match one of the
+ current users of the service.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+
+ void RemoveTrust(string address) [experimental]
+
+ Marks the user as not trusted.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.DoesNotExist
+
+Signals void Started()
+
+ The object path of this signal contains which service
+ was started.
+
+ void Stopped()
+
+ The object path of this signal contains which service
+ was stopped.
+
+
Security hierarchy
==================
@@ -1099,102 +1193,6 @@ Methods void RegisterDefaultPasskeyAgent(string path)
match the same value that has been used on
registration.
- void AuthorizeService(string service_path, string address, string action) [experimental]
-
- This method gets called when a service wants to check
- if a remote device is authorized to perform some
- action. The authorization request is forwarded to an
- authorization agent.
-
- The service_path parameter must be the object
- path of the service. The address and action parameters
- correspond to the remote device address and the action
- the remote device is trying to perform.
-
- void CancelAuthorizationProcess(string service_path, string address, string action) [experimental]
-
- This method cancels an authorization process requested
- by a previous call to AuthorizeService(). The
- service_path, address and action parameters must match
- the same values that have been used on registration.
-
-
-Service hierarchy
-=================
-
-Service org.bluez
-Interface org.bluez.Service
-Object path path from org.bluez.Manager.ListServices()
-
-Methods string GetIdentifier()
-
- This method returns the service identifier.
-
- string GetName()
-
- This method returns the service name.
-
- string GetDescription()
-
- This method returns the service description.
-
- void Start()
-
- This method tells the system to start the
- service.
-
- void Stop()
-
- This method tells the system to stop the
- service.
-
- boolean IsRunning()
-
- Returns true if the service has been started and
- is currently active. Otherwise, it returns false.
-
- array{string} ListUsers() [experimental]
-
- Returns list of current users (device addresses)
- of the service.
-
- void RemoveUser(string address) [experimental]
-
- Removes a user of the service. The address parameter
- must match one of the current users of the service.
-
- void SetTrusted(string address) [experimental]
-
- Marks the user as trusted.
-
- Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.AlreadyExists
-
- boolean IsTrusted(string address) [experimental]
-
- Returns true if the user is trusted or false otherwise.
- The address parameter must match one of the
- current users of the service.
-
- Possible errors: org.bluez.Error.InvalidArguments
-
- void RemoveTrust(string address) [experimental]
-
- Marks the user as not trusted.
-
- Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.DoesNotExist
-
-Signals void Started()
-
- The object path of this signal contains which service
- was started.
-
- void Stopped()
-
- The object path of this signal contains which service
- was stopped.
-
PasskeyAgent hierarchy
======================
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index 1e0cee3e..695970f8 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -41,8 +41,10 @@
#include "hcid.h"
#include "sdpd.h"
#include "sdp-xml.h"
+#include "dbus-hci.h"
#include "dbus-common.h"
#include "dbus-error.h"
+#include "dbus-service.h"
#include "dbus-database.h"
static int sdp_server_enable = 0;
@@ -264,10 +266,106 @@ static DBusHandlerResult remove_service_record(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
+static DBusHandlerResult register_service(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ const char *sender, *ident, *name, *desc;
+
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
+ DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &desc,
+ DBUS_TYPE_INVALID) == FALSE)
+ return error_invalid_arguments(conn, msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ if (service_register(sender, ident, name, desc) < 0)
+ return error_failed(conn, msg, EIO);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult unregister_service(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ const char *sender, *ident;
+
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
+ DBUS_TYPE_INVALID) == FALSE)
+ return error_invalid_arguments(conn, msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult request_authorization(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ const char *sender, *address, *path;
+
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE)
+ return error_invalid_arguments(conn, msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult cancel_authorization_request(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ const char *sender, *address, *path;
+
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE)
+ return error_invalid_arguments(conn, msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ return send_message_and_unref(conn, reply);
+}
+
static struct service_data database_services[] = {
{ "AddServiceRecord", add_service_record },
{ "AddServiceRecordFromXML", add_service_record_from_xml },
{ "RemoveServiceRecord", remove_service_record },
+ { "RegisterService", register_service },
+ { "UnregisterService", unregister_service },
+ { "RequestAuthorization", request_authorization },
+ { "CancelAuthorizationRequest", cancel_authorization_request },
{ NULL, NULL }
};
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index 432e3ac5..a81cbc8e 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -50,7 +50,6 @@
#include "dbus-security.h"
#include "dbus-service.h"
#include "dbus-manager.h"
-#include "dbus-service.h"
#include "dbus-hci.h"
#include "sdp-xml.h"
@@ -285,54 +284,6 @@ static DBusHandlerResult activate_service(DBusConnection *conn,
return DBUS_HANDLER_RESULT_HANDLED;
}
-static DBusHandlerResult register_service(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
- const char *sender, *ident, *name, *desc;
-
- if (!hcid_dbus_use_experimental())
- return error_unknown_method(conn, msg);
-
- if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
- DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &desc,
- DBUS_TYPE_INVALID) == FALSE)
- return error_invalid_arguments(conn, msg);
-
- sender = dbus_message_get_sender(msg);
-
- if (service_register(sender, ident, name, desc) < 0)
- return error_failed(conn, msg, EIO);
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
-
- return send_message_and_unref(conn, reply);
-}
-
-static DBusHandlerResult unregister_service(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
- const char *sender, *ident;
-
- if (!hcid_dbus_use_experimental())
- return error_unknown_method(conn, msg);
-
- if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
- DBUS_TYPE_INVALID) == FALSE)
- return error_invalid_arguments(conn, msg);
-
- sender = dbus_message_get_sender(msg);
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
-
- return send_message_and_unref(conn, reply);
-}
-
static struct service_data methods[] = {
{ "InterfaceVersion", interface_version },
{ "DefaultAdapter", default_adapter },
@@ -341,8 +292,6 @@ static struct service_data methods[] = {
{ "FindService", find_service },
{ "ListServices", list_services },
{ "ActivateService", activate_service },
- { "RegisterService", register_service },
- { "UnregisterService", unregister_service },
{ NULL, NULL }
};