afb-export: prepare to eventid
[src/app-framework-binder.git] / src / afb-export.c
index 90507b6..bd5b61e 100644 (file)
@@ -132,7 +132,7 @@ static void old_vverbose_cb(void *closure, int level, const char *file, int line
        vverbose_cb(closure, level, file, line, NULL, fmt, args);
 }
 
-static struct afb_event event_make_cb(void *closure, const char *name)
+static struct afb_eventid *eventid_make_cb(void *closure, const char *name)
 {
        size_t plen, nlen;
        char *event;
@@ -142,7 +142,7 @@ static struct afb_event event_make_cb(void *closure, const char *name)
        if (export->state == Api_State_Pre_Init) {
                ERROR("[API %s] Bad call to 'afb_daemon_event_make(%s)', must not be in PreInit", export->apiname, name);
                errno = EINVAL;
-               return (struct afb_event){ .itf = NULL, .closure = NULL };
+               return NULL;
        }
 
        /* makes the event name */
@@ -157,6 +157,12 @@ static struct afb_event event_make_cb(void *closure, const char *name)
        return afb_evt_create_event(event);
 }
 
+static struct afb_event event_make_cb(void *closure, const char *name)
+{
+       struct afb_eventid *eventid = eventid_make_cb(closure, name);
+       return (struct afb_event){ .itf = eventid ? eventid->itf : NULL, .closure = eventid };
+}
+
 static int event_broadcast_cb(void *closure, const char *name, struct json_object *object)
 {
        size_t plen, nlen;
@@ -244,11 +250,18 @@ static void hooked_old_vverbose_cb(void *closure, int level, const char *file, i
        hooked_vverbose_cb(closure, level, file, line, NULL, fmt, args);
 }
 
-static struct afb_event hooked_event_make_cb(void *closure, const char *name)
+static struct afb_eventid *hooked_eventid_make_cb(void *closure, const char *name)
 {
        struct afb_export *export = closure;
-       struct afb_event r = event_make_cb(closure, name);
-       return afb_hook_ditf_event_make(export, name, r);
+       struct afb_eventid *r = eventid_make_cb(closure, name);
+       afb_hook_ditf_event_make(export, name, r);
+       return r;
+}
+
+static struct afb_event hooked_event_make_cb(void *closure, const char *name)
+{
+       struct afb_eventid *eventid = hooked_eventid_make_cb(closure, name);
+       return (struct afb_event){ .itf = eventid ? eventid->itf : NULL, .closure = eventid };
 }
 
 static int hooked_event_broadcast_cb(void *closure, const char *name, struct json_object *object)
@@ -405,7 +418,6 @@ struct call_req
        struct jobloop *jobloop;
        struct json_object *result;
        int status;
-       int async;
 };
 
 /*
@@ -529,7 +541,6 @@ static void svc_call(void *closure, const char *api, const char *verb, struct js
        callreq->jobloop = NULL;
        callreq->callback = callback;
        callreq->closure = cbclosure;
-       callreq->async = 1;
 
        /* terminates and frees ressources if needed */
        afb_xreq_process(&callreq->xreq, export->apiset);
@@ -557,7 +568,6 @@ static int svc_call_sync(void *closure, const char *api, const char *verb, struc
                callreq->callback = NULL;
                callreq->result = NULL;
                callreq->status = 0;
-               callreq->async = 0;
                afb_xreq_unhooked_addref(&callreq->xreq); /* avoid early callreq destruction */
                rc = jobs_enter(NULL, 0, callreq_sync_enter, callreq);
                if (rc >= 0)
@@ -743,6 +753,7 @@ struct afb_export *afb_export_create_v2(struct afb_apiset *apiset, const char *a
                export->init.v2 = init;
                export->on_event.v12 = onevent;
                export->export.v2 = data;
+               data->verbosity = verbosity;
                data->daemon.closure = export;
                data->service.closure = export;
                afb_export_update_hook(export);