Make api descriptions unique
[src/app-framework-binder.git] / src / afb-api-so-v2.c
index 8dadada..76bd233 100644 (file)
@@ -18,6 +18,7 @@
 #define _GNU_SOURCE
 #define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO
 
+#include <stdlib.h>
 #include <string.h>
 #include <dlfcn.h>
 #include <assert.h>
@@ -132,7 +133,7 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
        }
 
        /* get the event handler if any */
-       desc->service = afb_svc_create_v2(apiset, share_session, start, onevent, desc->data);
+       desc->service = afb_svc_create_v2(desc->binding->api, apiset, share_session, start, onevent, desc->data);
        if (desc->service == NULL) {
                /* starting error */
                ERROR("Starting service %s failed", desc->binding->api);
@@ -146,6 +147,8 @@ static void update_hooks_cb(void *closure)
 {
        struct api_so_v2 *desc = closure;
        afb_ditf_update_hook(&desc->ditf);
+       if (desc->service)
+               afb_svc_update_hook(desc->service);
 }
 
 static int get_verbosity_cb(void *closure)
@@ -194,7 +197,7 @@ static struct json_object *addperm_key_valint(struct json_object *o, const char
        return addperm_key_val(o, key, json_object_new_int(val));
 }
 
-static struct json_object *make_description(struct api_so_v2 *desc)
+static struct json_object *make_description_openAPIv3(struct api_so_v2 *desc)
 {
        char buffer[256];
        const struct afb_verb_v2 *verb;
@@ -251,7 +254,7 @@ static struct json_object *describe_cb(void *closure)
        struct api_so_v2 *desc = closure;
        struct json_object *r = desc->binding->specification ? json_tokener_parse(desc->binding->specification) : NULL;
        if (!r)
-               r = make_description(desc);
+               r = make_description_openAPIv3(desc);
        return r;
 }