Provide conversions for afb_event and afb_req
[src/app-framework-binder.git] / src / afb-xreq.c
index 8ff45c4..f9f2324 100644 (file)
@@ -396,10 +396,11 @@ static void xreq_context_set_cb(struct afb_request *closure, void *value, void (
        afb_context_set(&xreq->context, value, free_value);
 }
 
-static void xreq_addref_cb(struct afb_request *closure)
+static struct afb_request *xreq_addref_cb(struct afb_request *closure)
 {
        struct afb_xreq *xreq = from_request(closure);
        afb_xreq_unhooked_addref(xreq);
+       return closure;
 }
 
 static void xreq_unref_cb(struct afb_request *closure)
@@ -423,7 +424,7 @@ static int xreq_session_set_LOA_cb(struct afb_request *closure, unsigned level)
 static int xreq_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid);
 static int xreq_subscribe_cb(struct afb_request *closure, struct afb_event event)
 {
-       return xreq_subscribe_eventid_cb(closure, event.closure);
+       return xreq_subscribe_eventid_cb(closure, afb_event_to_eventid(event));
 }
 
 static int xreq_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
@@ -446,7 +447,7 @@ int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_eventid *eventid)
 static int xreq_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid);
 static int xreq_unsubscribe_cb(struct afb_request *closure, struct afb_event event)
 {
-       return xreq_unsubscribe_eventid_cb(closure, event.closure);
+       return xreq_unsubscribe_eventid_cb(closure, afb_event_to_eventid(event));
 }
 
 static int xreq_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
@@ -610,11 +611,11 @@ static void xreq_hooked_context_set_cb(struct afb_request *closure, void *value,
        xreq_context_set_cb(closure, value, free_value);
 }
 
-static void xreq_hooked_addref_cb(struct afb_request *closure)
+static struct afb_request *xreq_hooked_addref_cb(struct afb_request *closure)
 {
        struct afb_xreq *xreq = from_request(closure);
        afb_hook_xreq_addref(xreq);
-       xreq_addref_cb(closure);
+       return xreq_addref_cb(closure);
 }
 
 static void xreq_hooked_unref_cb(struct afb_request *closure)
@@ -638,18 +639,30 @@ static int xreq_hooked_session_set_LOA_cb(struct afb_request *closure, unsigned
        return afb_hook_xreq_session_set_LOA(xreq, level, r);
 }
 
+static int xreq_hooked_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid);
 static int xreq_hooked_subscribe_cb(struct afb_request *closure, struct afb_event event)
 {
-       int r = xreq_subscribe_cb(closure, event);
+       return xreq_hooked_subscribe_eventid_cb(closure, afb_event_to_eventid(event));
+}
+
+static int xreq_hooked_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
+{
+       int r = xreq_subscribe_eventid_cb(closure, eventid);
        struct afb_xreq *xreq = from_request(closure);
-       return afb_hook_xreq_subscribe(xreq, event.closure, r);
+       return afb_hook_xreq_subscribe(xreq, eventid, r);
 }
 
+static int xreq_hooked_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid);
 static int xreq_hooked_unsubscribe_cb(struct afb_request *closure, struct afb_event event)
 {
-       int r = xreq_unsubscribe_cb(closure, event);
+       return xreq_hooked_unsubscribe_eventid_cb(closure, afb_event_to_eventid(event));
+}
+
+static int xreq_hooked_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
+{
+       int r = xreq_unsubscribe_eventid_cb(closure, eventid);
        struct afb_xreq *xreq = from_request(closure);
-       return afb_hook_xreq_unsubscribe(xreq, event.closure, r);
+       return afb_hook_xreq_unsubscribe(xreq, eventid, r);
 }
 
 static void xreq_hooked_subcall_cb(struct afb_request *closure, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *cb_closure)
@@ -756,7 +769,9 @@ const struct afb_request_itf xreq_itf = {
        .subcall_req = xreq_subcall_req_cb,
        .has_permission = xreq_has_permission_cb,
        .get_application_id = xreq_get_application_id_cb,
-       .context_make = xreq_context_make_cb
+       .context_make = xreq_context_make_cb,
+       .subscribe_eventid = xreq_subscribe_eventid_cb,
+       .unsubscribe_eventid = xreq_unsubscribe_eventid_cb,
 };
 
 const struct afb_request_itf xreq_hooked_itf = {
@@ -781,7 +796,9 @@ const struct afb_request_itf xreq_hooked_itf = {
        .subcall_req = xreq_hooked_subcall_req_cb,
        .has_permission = xreq_hooked_has_permission_cb,
        .get_application_id = xreq_hooked_get_application_id_cb,
-       .context_make = xreq_hooked_context_make_cb
+       .context_make = xreq_hooked_context_make_cb,
+       .subscribe_eventid = xreq_hooked_subscribe_eventid_cb,
+       .unsubscribe_eventid = xreq_hooked_unsubscribe_eventid_cb,
 };
 
 /******************************************************************************/