diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
index d62e2cf..3fbff87 100644
--- a/src/gatt-dbus.c
+++ b/src/gatt-dbus.c
struct external_app {
char *owner;
char *path;
+ DBusMessage *reg;
GDBusClient *client;
GSList *proxies;
unsigned int watch;
external_apps = g_slist_remove(external_apps, eapp);
g_dbus_client_unref(eapp->client);
+ if (eapp->reg)
+ dbus_message_unref(eapp->reg);
g_free(eapp->owner);
g_free(eapp->path);
{
struct external_app *eapp = user_data;
GDBusProxy *proxy;
+ DBusConnection *conn = btd_get_dbus_connection();
+ DBusMessage *reply;
if (eapp->proxies == NULL)
goto fail;
DBG("Added GATT service %s", eapp->path);
- return;
+ reply = dbus_message_new_method_return(eapp->reg);
+ goto reply;
fail:
error("Could not register external service: %s", eapp->path);
+
+ reply = btd_error_invalid_args(eapp->reg);
+ /* TODO: missing eapp cleanup */
+
+reply:
+ dbus_message_unref(eapp->reg);
+ eapp->reg = NULL;
+
+ g_dbus_send_message(conn, reply);
}
static struct external_app *new_external_app(DBusConnection *conn,
- const char *sender, const char *path)
+ DBusMessage *msg, const char *path)
{
struct external_app *eapp;
GDBusClient *client;
+ const char *sender = dbus_message_get_sender(msg);
client = g_dbus_client_new(conn, sender, "/");
if (client == NULL)
}
eapp->owner = g_strdup(sender);
+ eapp->reg = dbus_message_ref(msg);
eapp->client = client;
eapp->path = g_strdup(path);
if (g_slist_find_custom(external_apps, path, external_app_path_cmp))
return btd_error_already_exists(msg);
- eapp = new_external_app(conn, dbus_message_get_sender(msg), path);
+ eapp = new_external_app(conn, msg, path);
if (eapp == NULL)
return btd_error_failed(msg, "Not enough resources");
DBG("New app %p: %s", eapp, path);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ return NULL;
}
static DBusMessage *unregister_service(DBusConnection *conn,
}
static const GDBusMethodTable methods[] = {
- { GDBUS_EXPERIMENTAL_METHOD("RegisterService",
+ { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterService",
GDBUS_ARGS({ "service", "o"},
{ "options", "a{sv}"}),
NULL, register_service) },