X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-xreq.c;h=9c089bc9e1a60487893d6065649f348a1d1353b1;hb=93c400b717c0562ed71338242bcb717e4c6613d5;hp=8f246b3c84efd460226685a9d6907fdac22aab2d;hpb=4521c1e7ae5371ab9d639adc617d17fb4e8ded0c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-xreq.c b/src/afb-xreq.c index 8f246b3c..9c089bc9 100644 --- a/src/afb-xreq.c +++ b/src/afb-xreq.c @@ -24,6 +24,9 @@ #include #include +#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE) +#define JSON_C_TO_STRING_NOSLASHESCAPE 0 +#endif #include #include @@ -197,12 +200,17 @@ static int xreq_legacy_subscribe_event_x1_cb(struct afb_req_x2 *closure, struct int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_event_x2 *event) { - if (xreq->listener) - return afb_evt_event_x2_add_watch(xreq->listener, event); - if (xreq->queryitf->subscribe) - return xreq->queryitf->subscribe(xreq, event); - ERROR("no event listener, subscription impossible"); - errno = EINVAL; + if (xreq->replied) { + ERROR("request replied, subscription impossible"); + errno = EINVAL; + } else { + if (xreq->listener) + return afb_evt_event_x2_add_watch(xreq->listener, event); + if (xreq->queryitf->subscribe) + return xreq->queryitf->subscribe(xreq, event); + ERROR("no event listener, subscription impossible"); + errno = ENOTSUP; + } return -1; } @@ -219,12 +227,17 @@ static int xreq_legacy_unsubscribe_event_x1_cb(struct afb_req_x2 *closure, struc int afb_xreq_unsubscribe(struct afb_xreq *xreq, struct afb_event_x2 *event) { - if (xreq->listener) - return afb_evt_event_x2_remove_watch(xreq->listener, event); - if (xreq->queryitf->unsubscribe) - return xreq->queryitf->unsubscribe(xreq, event); - ERROR("no event listener, unsubscription impossible"); - errno = EINVAL; + if (xreq->replied) { + ERROR("request replied, unsubscription impossible"); + errno = EINVAL; + } else { + if (xreq->listener) + return afb_evt_event_x2_remove_watch(xreq->listener, event); + if (xreq->queryitf->unsubscribe) + return xreq->queryitf->unsubscribe(xreq, event); + ERROR("no event listener, unsubscription impossible"); + errno = ENOTSUP; + } return -1; } @@ -666,7 +679,7 @@ void afb_xreq_reply_f(struct afb_xreq *xreq, struct json_object *obj, const char const char *afb_xreq_raw(struct afb_xreq *xreq, size_t *size) { struct json_object *obj = xreq_json_cb(xreq_to_req_x2(xreq)); - const char *result = json_object_to_json_string(obj); + const char *result = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_NOSLASHESCAPE); if (size != NULL) *size = strlen(result); return result;