X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dbus.c;h=0ac4f4995bd354d1f9581196fd2f3384d7c08549;hb=eaf5670e9d10b5d7c066043e7563706cf1e01bd5;hp=139c6472657ae186230a69bbef6eb4bc1c3b8ec2;hpb=6dfeafe7e4fa582b3db3f950136bc97f8611fc6d;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index 139c6472..0ac4f499 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -368,15 +368,19 @@ static int api_dbus_client_on_broadcast_event(sd_bus_message *m, void *userdata, { struct json_object *object; const char *event, *data; + const unsigned char *uuid; + size_t szuuid; + uint8_t hop; enum json_tokener_error jerr; - int rc = sd_bus_message_read(m, "ss", &event, &data); + + int rc = sd_bus_message_read(m, "ssayy", &event, &data, &uuid, &szuuid, &hop); if (rc < 0) ERROR("unreadable broadcasted event"); else { object = json_tokener_parse_verbose(data, &jerr); if (jerr != json_tokener_success) object = json_object_new_string(data); - afb_evt_broadcast(event, object); + afb_evt_rebroadcast(event, object, uuid, hop); } return 1; } @@ -632,10 +636,10 @@ error: /******************* event structures for server part **********************************/ -static void afb_api_dbus_server_event_add(void *closure, const char *event, int eventid); -static void afb_api_dbus_server_event_remove(void *closure, const char *event, int eventid); -static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object); -static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const char *uuid); +static void afb_api_dbus_server_event_add(void *closure, const char *event, uint16_t eventid); +static void afb_api_dbus_server_event_remove(void *closure, const char *event, uint16_t eventid); +static void afb_api_dbus_server_event_push(void *closure, const char *event, uint16_t eventid, struct json_object *object); +static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop); /* the interface for events broadcasting */ static const struct afb_evt_itf evt_broadcast_itf = { @@ -900,31 +904,32 @@ end: sd_bus_message_unref(msg); } -static void afb_api_dbus_server_event_add(void *closure, const char *event, int eventid) +static void afb_api_dbus_server_event_add(void *closure, const char *event, uint16_t eventid) { afb_api_dbus_server_event_send(closure, '+', event, eventid, "", 0); } -static void afb_api_dbus_server_event_remove(void *closure, const char *event, int eventid) +static void afb_api_dbus_server_event_remove(void *closure, const char *event, uint16_t eventid) { afb_api_dbus_server_event_send(closure, '-', event, eventid, "", 0); } -static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object) +static void afb_api_dbus_server_event_push(void *closure, const char *event, uint16_t eventid, struct json_object *object) { const char *data = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE); afb_api_dbus_server_event_send(closure, '!', event, eventid, data, 0); json_object_put(object); } -static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const char *uuid) +static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop) { int rc; struct api_dbus *api; api = closure; rc = sd_bus_emit_signal(api->sdbus, api->path, api->name, "broadcast", - "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE)); + "ssayy", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE), + uuid, UUID_BINARY_LENGTH, hop); if (rc < 0) ERROR("error while broadcasting event %s", event); json_object_put(object); @@ -976,7 +981,7 @@ static int api_dbus_server_on_object_called(sd_bus_message *message, void *userd /* fulfill the request and emit it */ dreq->xreq.context.flags = flags; - dreq->xreq.cred = afb_cred_mixed_on_behalf_import(listener->origin->cred, uuid, creds && creds[0] ? creds : NULL); + dreq->xreq.cred = afb_cred_mixed_on_behalf_import(listener->origin->cred, &dreq->xreq.context, creds && creds[0] ? creds : NULL); dreq->message = sd_bus_message_ref(message); dreq->json = json_tokener_parse_verbose(dreq->request, &jerr); if (jerr != json_tokener_success) {