summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-19 23:48:01 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-19 23:48:01 +0000
commit9932d3f27fb04f03c560525f312c67b15aeeb85e (patch)
treee2fe5567c98f19c9f394d3d563b5460216deb08c
parent5efa3b9135fb762979bd143a1db31e89ffaae353 (diff)
Add skeleton for database methods
-rw-r--r--hcid/dbus-database.c70
-rw-r--r--hcid/dbus-database.h9
-rw-r--r--hcid/dbus-manager.c8
3 files changed, 84 insertions, 3 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index cf4cbff8..3421c5b3 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -25,4 +25,74 @@
#include <config.h>
#endif
+#include <dbus/dbus.h>
+
+#include "dbus.h"
+#include "hcid.h"
+#include "dbus-common.h"
+#include "dbus-error.h"
#include "dbus-database.h"
+
+static DBusHandlerResult add_service_record(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ dbus_uint32_t handle = 0x12345;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,
+ DBUS_TYPE_INVALID);
+
+ return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ dbus_uint32_t handle = 0x12345;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,
+ DBUS_TYPE_INVALID);
+
+ return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult remove_service_record(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+
+ 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 },
+ { NULL, NULL }
+};
+
+DBusHandlerResult handle_database_method(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ service_handler_func_t handler;
+
+ handler = find_service_handler(database_services, msg);
+
+ if (handler)
+ return handler(conn, msg, data);
+
+ return error_unknown_method(conn, msg);
+}
diff --git a/hcid/dbus-database.h b/hcid/dbus-database.h
index e87dd676..3958dd84 100644
--- a/hcid/dbus-database.h
+++ b/hcid/dbus-database.h
@@ -20,3 +20,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+
+#ifndef __BLUEZ_DBUS_DATABASE_H
+#define __BLUEZ_DBUS_DATABASE_H
+
+#define DATABASE_INTERFACE "org.bluez.Database"
+
+DBusHandlerResult handle_database_method(DBusConnection *conn, DBusMessage *msg, void *data);
+
+#endif /* __BLUEZ_DBUS_DATABSE_H */
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index d66d16b5..480ffd24 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -44,6 +44,7 @@
#include "dbus.h"
#include "dbus-common.h"
#include "dbus-error.h"
+#include "dbus-database.h"
#include "dbus-security.h"
#include "dbus-service.h"
#include "dbus-manager.h"
@@ -571,10 +572,11 @@ DBusHandlerResult handle_manager_method(DBusConnection *conn,
return handler(conn, msg, data);
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- if (!strcmp(iface, SECURITY_INTERFACE))
+ } else if (!strcmp(iface, DATABASE_INTERFACE)) {
+ return handle_database_method(conn, msg, data);
+ } else if (!strcmp(iface, SECURITY_INTERFACE)) {
return handle_security_method(conn, msg, data);
+ }
return error_unknown_method(conn, msg);
}