summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-03-14 19:25:23 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-03-14 19:25:23 +0000
commit1995ca360f09e8c8d49ee73985638111c3c68d4e (patch)
tree8e4c5f9325befd56fdf3bcadfafb50bcacb62308
parent6a61b7495a0557ce79499a6815cdfbe672bf6cfb (diff)
Send replies to agent register and unregister methods
-rw-r--r--hcid/adapter.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 0b1a3c9f..b509ae43 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -3643,6 +3643,7 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
const char *path, *name;
struct agent *agent;
struct adapter *adapter = data;
+ DBusMessage *reply;
if (!hcid_dbus_use_experimental())
return error_unknown_method(conn, msg);
@@ -3654,18 +3655,24 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
if (adapter->agent)
return error_already_exists(conn, msg, "Agent already exists");
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
name = dbus_message_get_sender(msg);
agent = agent_create(name, path, NULL,
(agent_remove_cb) agent_removed, adapter);
- if (!agent)
+ if (!agent) {
+ dbus_message_unref(reply);
return error_failed(conn, msg, "Failed to create a new agent");
+ }
adapter->agent = agent;
name_listener_add(conn, name, (name_cb_t) agent_exited, adapter);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return send_message_and_unref(conn, reply);
}
static DBusHandlerResult unregister_agent(DBusConnection *conn,
@@ -3673,6 +3680,7 @@ static DBusHandlerResult unregister_agent(DBusConnection *conn,
{
const char *path, *name;
struct adapter *adapter = data;
+ DBusMessage *reply;
if (!hcid_dbus_use_experimental())
return error_unknown_method(conn, msg);
@@ -3686,13 +3694,17 @@ static DBusHandlerResult unregister_agent(DBusConnection *conn,
if (!adapter->agent || !agent_matches(adapter->agent, name, path))
return error_does_not_exist(conn, msg, "No such agent");
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
name_listener_remove(conn, name, (name_cb_t) agent_exited,
adapter);
agent_destroy(adapter->agent, FALSE);
adapter->agent = NULL;
- return DBUS_HANDLER_RESULT_HANDLED;
+ return send_message_and_unref(conn, reply);
}
const char *major_class_str(uint32_t class)