Introduce afb_eventid
[src/app-framework-binder.git] / src / afb-api-dbus.c
index 2f4c4ca..33435a9 100644 (file)
@@ -19,6 +19,7 @@
 #define NO_PLUGIN_VERBOSE_MACRO
 
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
@@ -26,7 +27,7 @@
 #include <systemd/sd-bus.h>
 #include <json-c/json.h>
 
-#include <afb/afb-req-itf.h>
+#include <afb/afb-event.h>
 
 #include "afb-common.h"
 
@@ -237,7 +238,7 @@ static struct dbus_memo *api_dbus_client_memo_make(struct api_dbus *api, struct
 
        memo = malloc(sizeof *memo);
        if (memo != NULL) {
-               afb_xreq_addref(xreq);
+               afb_xreq_unhooked_addref(xreq);
                memo->xreq = xreq;
                memo->msgid = 0;
                memo->api = api;
@@ -261,7 +262,7 @@ static void api_dbus_client_memo_destroy(struct dbus_memo *memo)
                prv = &(*prv)->next;
        }
 
-       afb_xreq_unref(memo->xreq);
+       afb_xreq_unhooked_unref(memo->xreq);
        free(memo);
 }
 
@@ -381,7 +382,7 @@ static struct dbus_event *api_dbus_client_event_search(struct api_dbus *api, int
        struct dbus_event *ev;
 
        ev = api->client.events;
-       while (ev != NULL && (ev->id != id || 0 != strcmp(afb_evt_event_name(ev->event), name)))
+       while (ev != NULL && (ev->id != id || 0 != strcmp(afb_evt_event_fullname(ev->event), name)))
                ev = ev->next;
 
        return ev;
@@ -439,7 +440,7 @@ static void api_dbus_client_event_drop(struct api_dbus *api, int id, const char
        *prv = ev->next;
 
        /* destroys the event */
-       afb_event_drop(ev->event);
+       afb_event_unref(ev->event);
        free(ev);
 }
 
@@ -609,6 +610,7 @@ int afb_api_dbus_add_client(const char *path, struct afb_apiset *apiset)
        /* record it as an API */
        afb_api.closure = api;
        afb_api.itf = &dbus_api_itf;
+       afb_api.group = NULL;
        if (afb_apiset_add(apiset, api->api, afb_api) < 0)
                goto error2;
 
@@ -848,7 +850,7 @@ static int dbus_req_subscribe(struct afb_xreq *xreq, struct afb_event event)
 
        rc = afb_evt_add_watch(dreq->listener->listener, event);
        sd_bus_message_get_cookie(dreq->message, &msgid);
-       afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_event_name(event), afb_evt_event_id(event), "", msgid);
+       afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_event_fullname(event), afb_evt_event_id(event), "", msgid);
        return rc;
 }
 
@@ -859,7 +861,7 @@ static int dbus_req_unsubscribe(struct afb_xreq *xreq, struct afb_event event)
        int rc;
 
        sd_bus_message_get_cookie(dreq->message, &msgid);
-       afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_event_name(event), afb_evt_event_id(event), "", msgid);
+       afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_event_fullname(event), afb_evt_event_id(event), "", msgid);
        rc = afb_evt_remove_watch(dreq->listener->listener, event);
        return rc;
 }