X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-msg-json.c;h=59af9d96c5b0e5335ed913e547862a715bed2106;hb=bbddc1e584dd01b60042f622f8cecfc69361020b;hp=d5f6f5a5dddc3b01a2cf22f0ad56c0d4a1a6e1f2;hpb=b57505f0f80f6394f04a041df6e808c857b01d4b;p=src%2Fapp-framework-binder.git diff --git a/src/afb-msg-json.c b/src/afb-msg-json.c index d5f6f5a5..59af9d96 100644 --- a/src/afb-msg-json.c +++ b/src/afb-msg-json.c @@ -19,6 +19,8 @@ #include +#include + #include "afb-msg-json.h" #include "afb-context.h" @@ -47,13 +49,15 @@ struct json_object *afb_msg_json_reply(const char *status, const char *info, str if (reqid != NULL) json_object_object_add(request, "reqid", json_object_new_string(reqid)); - token = afb_context_sent_token(context); - if (token != NULL) - json_object_object_add(request, "token", json_object_new_string(token)); + if (context != NULL) { + token = afb_context_sent_token(context); + if (token != NULL) + json_object_object_add(request, "token", json_object_new_string(token)); - uuid = afb_context_sent_uuid(context); - if (uuid != NULL) - json_object_object_add(request, "uuid", json_object_new_string(uuid)); + uuid = afb_context_sent_uuid(context); + if (uuid != NULL) + json_object_object_add(request, "uuid", json_object_new_string(uuid)); + } return msg; } @@ -87,3 +91,20 @@ struct json_object *afb_msg_json_event(const char *event, struct json_object *ob return msg; } +struct afb_arg afb_msg_json_get_arg(struct json_object *object, const char *name) +{ + struct afb_arg arg; + struct json_object *value; + + if (json_object_object_get_ex(object, name, &value)) { + arg.name = name; + arg.value = json_object_get_string(value); + } else { + arg.name = NULL; + arg.value = NULL; + } + arg.path = NULL; + return arg; +} + +