18 #define AFB_BINDING_VERSION 2 19 #include <afb/afb-binding.h> 26 #include <json-c/json.h> 31 #define COMMAND_EVENT_NUM 3 32 #define EVENT_SUBSCRIBE_ERROR_CODE 100 46 static const char _error[] =
"error";
57 static int pingcount = 0;
58 afb_req_success_f(request, json_object_new_int(pingcount),
"Ping count = %d", pingcount);
59 AFB_NOTICE(
"Verbosity macro at level notice invoked at ping invocation count = %d", pingcount);
78 AFB_NOTICE(
"%s is called.", __FUNCTION__);
84 AFB_NOTICE(
"request params = %s.", value);
86 struct json_object* push_obj = json_object_new_object();
91 afb_req_fail_f(request,
"failed",
"called %s, Unknown palameter", __FUNCTION__);
96 struct json_object *res = json_object_new_object();
99 afb_req_success(request, res,
"afb_event_push event [tap_shortcut]");
115 AFB_NOTICE(
"%s is called.", __FUNCTION__);
121 AFB_NOTICE(
"request params = %s.", value);
123 struct json_object* push_obj = json_object_new_object();
128 afb_req_fail_f(request,
"failed",
"called %s, Unknown palameter", __FUNCTION__);
133 struct json_object *res = json_object_new_object();
136 afb_req_success(request, res,
"afb_event_push event [on_screen_message]");
153 const char *value = afb_req_value(request,
"event");
154 AFB_NOTICE(
"value is %s", value);
160 AFB_NOTICE(
"dedicated event doesn't exist");
169 AFB_NOTICE(
"Please input event name");
173 struct json_object *res = json_object_new_object();
176 afb_req_success_f(request, res,
"homescreen binder subscribe event name [%s]", value);
193 const char *value = afb_req_value(request,
"event");
194 AFB_NOTICE(
"value is %s", value);
200 AFB_NOTICE(
"dedicated event doesn't exist");
209 AFB_NOTICE(
"Please input event name");
213 struct json_object *res = json_object_new_object();
216 afb_req_success_f(request, res,
"homescreen binder unsubscribe event name [%s]", value);
222 static const struct afb_verb_v2
verbs[]= {
224 { .verb =
"ping", .session = AFB_SESSION_NONE, .callback =
pingSample, .auth = NULL },
225 { .verb =
"tap_shortcut", .session = AFB_SESSION_NONE, .callback =
tap_shortcut, .auth = NULL },
226 { .verb =
"on_screen_message", .session = AFB_SESSION_NONE, .callback =
on_screen_message, .auth = NULL },
227 { .verb =
"subscribe", .session = AFB_SESSION_NONE, .callback =
subscribe, .auth = NULL },
228 { .verb =
"unsubscribe", .session = AFB_SESSION_NONE, .callback =
unsubscribe, .auth = NULL },
234 AFB_NOTICE(
"binding preinit (was register)");
240 AFB_NOTICE(
"binding init");
260 AFB_NOTICE(
"on_event %s", event);
265 .specification = NULL,
void hs_add_object_to_json_object_str(struct json_object *j_obj, int count,...)
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 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_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
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,...)