18 #define AFB_BINDING_VERSION 2 19 #include <afb/afb-binding.h> 26 #include <json-c/json.h> 31 #define COMMAND_EVENT_NUM 4 32 #define EVENT_SUBSCRIBE_ERROR_CODE 100 47 static const char _error[] =
"error";
59 static int pingcount = 0;
60 afb_req_success_f(request, json_object_new_int(pingcount),
"Ping count = %d", pingcount);
61 HMI_NOTICE(
"homescreen-service",
"Verbosity macro at level notice invoked at ping invocation count = %d", pingcount);
85 HMI_NOTICE(
"homescreen-service",
"request params = %s.", value);
87 struct json_object* push_obj = json_object_new_object();
92 afb_req_fail_f(request,
"failed",
"called %s, Unknown palameter", __FUNCTION__);
97 struct json_object *res = json_object_new_object();
100 afb_req_success(request, res,
"afb_event_push event [tap_shortcut]");
116 HMI_NOTICE(
"homescreen-service",
"is called.");
122 HMI_NOTICE(
"homescreen-service",
"request params = %s.", value);
124 struct json_object* push_obj = json_object_new_object();
129 afb_req_fail_f(request,
"failed",
"called %s, Unknown palameter", __FUNCTION__);
134 struct json_object *res = json_object_new_object();
137 afb_req_success(request, res,
"afb_event_push event [on_screen_message]");
153 HMI_NOTICE(
"homescreen-service",
"is called.");
159 HMI_NOTICE(
"homescreen-service",
"request params = %s.", value);
161 struct json_object* push_obj = json_object_new_object();
166 afb_req_fail_f(request,
"failed",
"called %s, Unknown palameter", __FUNCTION__);
171 struct json_object *res = json_object_new_object();
174 afb_req_success(request, res,
"afb_event_push event [on_screen_reply]");
191 const char *value = afb_req_value(request,
"event");
192 HMI_NOTICE(
"homescreen-service",
"value is %s", value);
198 HMI_NOTICE(
"homescreen-service",
"dedicated event doesn't exist");
207 HMI_NOTICE(
"homescreen-service",
"Please input event name");
211 struct json_object *res = json_object_new_object();
214 afb_req_success_f(request, res,
"homescreen binder subscribe event name [%s]", value);
231 const char *value = afb_req_value(request,
"event");
232 HMI_NOTICE(
"homescreen-service",
"value is %s", value);
238 HMI_NOTICE(
"homescreen-service",
"dedicated event doesn't exist");
247 HMI_NOTICE(
"homescreen-service",
"Please input event name");
251 struct json_object *res = json_object_new_object();
254 afb_req_success_f(request, res,
"homescreen binder unsubscribe event name [%s]", value);
260 static const struct afb_verb_v2
verbs[]= {
262 { .verb =
"ping", .session = AFB_SESSION_NONE, .callback =
pingSample, .auth = NULL },
263 { .verb =
"tap_shortcut", .session = AFB_SESSION_NONE, .callback =
tap_shortcut, .auth = NULL },
264 { .verb =
"on_screen_message", .session = AFB_SESSION_NONE, .callback =
on_screen_message, .auth = NULL },
265 { .verb =
"on_screen_reply", .session = AFB_SESSION_NONE, .callback =
on_screen_reply, .auth = NULL },
266 { .verb =
"subscribe", .session = AFB_SESSION_NONE, .callback =
subscribe, .auth = NULL },
267 { .verb =
"unsubscribe", .session = AFB_SESSION_NONE, .callback =
unsubscribe, .auth = NULL },
273 HMI_NOTICE(
"homescreen-service",
"binding preinit (was register)");
279 HMI_NOTICE(
"homescreen-service",
"binding init");
303 HMI_NOTICE(
"homescreen-service",
"on_event %s", event);
308 .specification = NULL,
void hs_add_object_to_json_object_str(struct json_object *j_obj, int count,...)
#define HMI_NOTICE(prefix, args,...)
static void tap_shortcut(struct afb_req request)
static const char _application_name[]
static struct afb_event ev_reserved
static const char _error[]
static void pingSample(struct afb_req request)
static void onevent(const char *event, struct json_object *object)
static void on_screen_reply(struct afb_req request)
static const char * evlist[]
static void unsubscribe(struct afb_req request)
int hs_search_event_name_index(const char *value)
static struct afb_event ev_on_screen_reply
static struct afb_event ev_on_screen_message
#define COMMAND_EVENT_NUM
static void on_screen_message(struct afb_req request)
static const struct afb_verb_v2 verbs[]
static struct event event_list[COMMAND_EVENT_NUM]
static const char _display_message[]
static void subscribe(struct afb_req request)
#define EVENT_SUBSCRIBE_ERROR_CODE
static struct afb_event ev_tap_shortcut
static const char _reply_message[]
const struct afb_binding_v2 afbBindingV2
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)