X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dbus.c;h=c0bc57a8acbee8d4cd2a20182cc90e22d206ca2d;hb=26bca5f8a8c6f9403a84945a5cd914b6da948efd;hp=5b75bfa0b912e52170d3eb52e31f917cc04de6c0;hpb=09027206b4629a3446bf88e58ca2e7e1252e39f1;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index 5b75bfa0..c0bc57a8 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 "IoT.bzh" + * Copyright (C) 2015, 2016 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#define NO_PLUGIN_VERBOSE_MACRO #include #include @@ -25,8 +26,8 @@ #include #include -#include "afb-plugin.h" -#include "afb-req-itf.h" +#include +#include #include "afb-common.h" @@ -91,6 +92,10 @@ static struct api_dbus *make_api_dbus_3(int system, const char *path, size_t pat goto error2; } api->api++; + if (!afb_apis_is_valid_api_name(api->api)) { + errno = EINVAL; + goto error2; + } /* the name/interface is copied after the path */ api->name = &api->path[pathlen + 1]; @@ -418,7 +423,7 @@ static void dbus_req_reply(struct dbus_req *dreq, uint8_t type, const char *firs static void dbus_req_success(struct dbus_req *dreq, struct json_object *obj, const char *info) { - dbus_req_reply(dreq, RETOK, json_object_to_json_string(obj), info); + dbus_req_reply(dreq, RETOK, json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN), info); } static void dbus_req_fail(struct dbus_req *dreq, const char *status, const char *info) @@ -511,7 +516,7 @@ static void afb_api_dbus_server_send_event(struct api_dbus *api, const char *eve int rc; rc = sd_bus_emit_signal(api->sdbus, api->path, api->name, - "event", "ss", event, json_object_to_json_string(object)); + "event", "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN)); if (rc < 0) ERROR("error while emiting event %s", event); json_object_put(object);