aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-xreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-09-21 21:25:07 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-10-09 14:08:32 +0200
commit5928e8fc14c2edabc0bc104fff7542819e06d45a (patch)
tree5a03f7b05c6cfb4cf9f9b5c70415a547d841780d /src/afb-xreq.c
parentae5d707f9348b50d44724ec2b091f4528ff0a72b (diff)
Deprecate internal use of afb_event
The deprecation is made in favor of afb_eventid but this can change later in favor of afb_evt_evtid. Change-Id: Ic16cb25dbd97cb1e8d26b3c54b159d46bbf82671 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r--src/afb-xreq.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 8a050705..8ff45c4e 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -104,18 +104,18 @@ struct subcall
};
};
-static int subcall_subscribe_cb(struct afb_xreq *xreq, struct afb_event event)
+static int subcall_subscribe_cb(struct afb_xreq *xreq, struct afb_eventid *eventid)
{
struct subcall *subcall = CONTAINER_OF_XREQ(struct subcall, xreq);
- return afb_xreq_subscribe(subcall->xreq.caller, event);
+ return afb_xreq_subscribe(subcall->xreq.caller, eventid);
}
-static int subcall_unsubscribe_cb(struct afb_xreq *xreq, struct afb_event event)
+static int subcall_unsubscribe_cb(struct afb_xreq *xreq, struct afb_eventid *eventid)
{
struct subcall *subcall = CONTAINER_OF_XREQ(struct subcall, xreq);
- return afb_xreq_unsubscribe(subcall->xreq.caller, event);
+ return afb_xreq_unsubscribe(subcall->xreq.caller, eventid);
}
static void subcall_reply_cb(struct afb_xreq *xreq, int status, struct json_object *result)
@@ -420,35 +420,47 @@ static int xreq_session_set_LOA_cb(struct afb_request *closure, unsigned level)
return afb_context_change_loa(&xreq->context, 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);
+}
+
+static int xreq_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
+{
struct afb_xreq *xreq = from_request(closure);
- return afb_xreq_subscribe(xreq, event);
+ return afb_xreq_subscribe(xreq, eventid);
}
-int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_event event)
+int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_eventid *eventid)
{
if (xreq->listener)
- return afb_evt_add_watch(xreq->listener, event);
+ return afb_evt_add_watch(xreq->listener, eventid);
if (xreq->queryitf->subscribe)
- return xreq->queryitf->subscribe(xreq, event);
+ return xreq->queryitf->subscribe(xreq, eventid);
ERROR("no event listener, subscription impossible");
errno = EINVAL;
return -1;
}
+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);
+}
+
+static int xreq_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid)
+{
struct afb_xreq *xreq = from_request(closure);
- return afb_xreq_unsubscribe(xreq, event);
+ return afb_xreq_unsubscribe(xreq, eventid);
}
-int afb_xreq_unsubscribe(struct afb_xreq *xreq, struct afb_event event)
+int afb_xreq_unsubscribe(struct afb_xreq *xreq, struct afb_eventid *eventid)
{
if (xreq->listener)
- return afb_evt_remove_watch(xreq->listener, event);
+ return afb_evt_remove_watch(xreq->listener, eventid);
if (xreq->queryitf->unsubscribe)
- return xreq->queryitf->unsubscribe(xreq, event);
+ return xreq->queryitf->unsubscribe(xreq, eventid);
ERROR("no event listener, unsubscription impossible");
errno = EINVAL;
return -1;
@@ -630,14 +642,14 @@ static int xreq_hooked_subscribe_cb(struct afb_request *closure, struct afb_even
{
int r = xreq_subscribe_cb(closure, event);
struct afb_xreq *xreq = from_request(closure);
- return afb_hook_xreq_subscribe(xreq, event, r);
+ return afb_hook_xreq_subscribe(xreq, event.closure, r);
}
static int xreq_hooked_unsubscribe_cb(struct afb_request *closure, struct afb_event event)
{
int r = xreq_unsubscribe_cb(closure, event);
struct afb_xreq *xreq = from_request(closure);
- return afb_hook_xreq_unsubscribe(xreq, event, r);
+ return afb_hook_xreq_unsubscribe(xreq, event.closure, 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)