From: José Bollo Date: Tue, 30 May 2017 08:41:56 +0000 (+0200) Subject: Record API names in service descriptors X-Git-Tag: dab_3.99.2~44 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=4db507f7d53a09cf3f572dedcc304f334970ce06;p=src%2Fapp-framework-binder.git Record API names in service descriptors Change-Id: Ie437a6987df7f27a4a68b9c022d8cad8ab4f2cfe Signed-off-by: José Bollo --- diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c index f367820d..b7b29e44 100644 --- a/src/afb-api-so-v1.c +++ b/src/afb-api-so-v1.c @@ -108,7 +108,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_v1(apiset, share_session, init, onevent); + desc->service = afb_svc_create_v1(desc->binding->v1.prefix, apiset, share_session, init, onevent); if (desc->service == NULL) { /* starting error */ ERROR("Starting service %s failed", desc->binding->v1.prefix); diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c index 1c5fe520..11fa334b 100644 --- a/src/afb-api-so-v2.c +++ b/src/afb-api-so-v2.c @@ -133,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); diff --git a/src/afb-svc.c b/src/afb-svc.c index b492520c..fad13286 100644 --- a/src/afb-svc.c +++ b/src/afb-svc.c @@ -42,6 +42,9 @@ */ struct afb_svc { + /* api/prefix */ + const char *api; + /* session of the service */ struct afb_session *session; @@ -128,6 +131,7 @@ static void svc_free(struct afb_svc *svc) * Allocates a new service */ static struct afb_svc *afb_svc_alloc( + const char *api, struct afb_apiset *apiset, int share_session ) @@ -142,6 +146,7 @@ static struct afb_svc *afb_svc_alloc( } /* instanciate the apiset */ + svc->api = api; svc->apiset = afb_apiset_addref(apiset); /* instanciate the session */ @@ -171,17 +176,18 @@ error: * Creates a new service */ struct afb_svc *afb_svc_create_v1( - struct afb_apiset *apiset, - int share_session, - int (*start)(struct afb_service service), - void (*on_event)(const char *event, struct json_object *object) + const char *api, + struct afb_apiset *apiset, + int share_session, + int (*start)(struct afb_service service), + void (*on_event)(const char *event, struct json_object *object) ) { int rc; struct afb_svc *svc; /* allocates the svc handler */ - svc = afb_svc_alloc(apiset, share_session); + svc = afb_svc_alloc(api, apiset, share_session); if (svc == NULL) goto error; @@ -211,6 +217,7 @@ error: * Creates a new service */ struct afb_svc *afb_svc_create_v2( + const char *api, struct afb_apiset *apiset, int share_session, int (*start)(), @@ -222,7 +229,7 @@ struct afb_svc *afb_svc_create_v2( struct afb_svc *svc; /* allocates the svc handler */ - svc = afb_svc_alloc(apiset, share_session); + svc = afb_svc_alloc(api, apiset, share_session); if (svc == NULL) goto error; data->service = to_afb_service(svc); diff --git a/src/afb-svc.h b/src/afb-svc.h index 347716d2..84b03d83 100644 --- a/src/afb-svc.h +++ b/src/afb-svc.h @@ -23,12 +23,14 @@ struct afb_apiset; struct afb_binding_data_v2; extern struct afb_svc *afb_svc_create_v1( + const char *api, struct afb_apiset *apiset, int share_session, int (*start)(struct afb_service service), void (*on_event)(const char *event, struct json_object *object)); extern struct afb_svc *afb_svc_create_v2( + const char *api, struct afb_apiset *apiset, int share_session, int (*start)(),