summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-24 10:10:08 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-24 10:10:08 +0000
commit48b5467e20216455a6b9683694cfd31968aa5543 (patch)
tree4169e150c450fcce5de4a7d704d2dc7f5aa8bc31
parentc442974bf9e0261c80d06f91a3761ef82fcf590a (diff)
Move service registration to the manager interface
-rw-r--r--hcid/dbus-database.c30
-rw-r--r--hcid/dbus-manager.c51
2 files changed, 51 insertions, 30 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index f0b13abb..1e0cee3e 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -43,8 +43,6 @@
#include "sdp-xml.h"
#include "dbus-common.h"
#include "dbus-error.h"
-#include "dbus-hci.h"
-#include "dbus-service.h"
#include "dbus-database.h"
static int sdp_server_enable = 0;
@@ -266,38 +264,10 @@ 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 *ident, *name, *desc;
- const char *sender;
-
- 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 struct service_data database_services[] = {
{ "AddServiceRecord", add_service_record },
{ "AddServiceRecordFromXML", add_service_record_from_xml },
{ "RemoveServiceRecord", remove_service_record },
- { "RegisterService", register_service },
{ NULL, NULL }
};
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index a81cbc8e..432e3ac5 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -50,6 +50,7 @@
#include "dbus-security.h"
#include "dbus-service.h"
#include "dbus-manager.h"
+#include "dbus-service.h"
#include "dbus-hci.h"
#include "sdp-xml.h"
@@ -284,6 +285,54 @@ 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 },
@@ -292,6 +341,8 @@ static struct service_data methods[] = {
{ "FindService", find_service },
{ "ListServices", list_services },
{ "ActivateService", activate_service },
+ { "RegisterService", register_service },
+ { "UnregisterService", unregister_service },
{ NULL, NULL }
};