21 static const char _type[] =
"type";
22 static const char _text[] =
"text";
23 static const char _info[] =
"info";
24 static const char _icon[] =
"icon";
41 my_event = afb_api_make_event(request->api,
id.c_str());
57 afb_event_unref(my_event);
72 if(!checkEvent(__FUNCTION__))
75 HMI_NOTICE(
"homescreen-service",
"%s application_id = %s.", __FUNCTION__, appid);
76 struct json_object* push_obj = json_object_new_object();
79 afb_event_push(my_event, push_obj);
95 if(!checkEvent(__FUNCTION__))
98 HMI_NOTICE(
"homescreen-service",
"push %s event message [%s].", __FUNCTION__, message);
99 struct json_object* push_obj = json_object_new_object();
101 _type, __FUNCTION__);
102 afb_event_push(my_event, push_obj);
118 if(!checkEvent(__FUNCTION__))
121 HMI_NOTICE(
"homescreen-service",
"push %s event message [%s].", __FUNCTION__, message);
122 struct json_object* push_obj = json_object_new_object();
124 _type, __FUNCTION__);
125 afb_event_push(my_event, push_obj);
142 auto ip = event_list.find(std::string(event));
143 if(ip == event_list.end()) {
144 event_list[std::string(event)] = 0;
147 ret = afb_req_subscribe(request, my_event);
168 event_list.erase(std::string(event));
169 if(event_list.empty()) {
170 ret = afb_req_unsubscribe(request, my_event);
186 bool HS_Client::checkEvent(
const char* event)
188 auto ip = event_list.find(std::string(event));
189 if(ip == event_list.end())
211 if(!checkEvent(__FUNCTION__))
214 HMI_NOTICE(
"homescreen-service",
"%s application_id = %s.", __FUNCTION__, appid);
215 struct json_object* push_obj = json_object_new_object();
217 const char* param = afb_req_value(request,
_parameter);
219 const char* req_appid = afb_req_get_application_id(request);
220 struct json_object* param_obj = json_tokener_parse(param);
221 json_object_object_add(param_obj,
_replyto, json_object_new_string(req_appid));
222 json_object_object_add(push_obj,
_parameter, param_obj);
225 HMI_ERROR(
"homescreen-service",
"please input correct parameter.");
228 afb_event_push(my_event, push_obj);
247 if(!checkEvent(__FUNCTION__))
250 HMI_NOTICE(
"homescreen-service",
"%s application_id = %s.", __FUNCTION__);
251 const char* req_appid = afb_req_get_application_id(request);
252 struct json_object* push_obj = json_object_new_object();
254 _type, __FUNCTION__);
255 afb_event_push(my_event, push_obj);
275 if(!checkEvent(__FUNCTION__))
278 HMI_NOTICE(
"homescreen-service",
"%s application_id = %s.", __FUNCTION__, appid);
279 struct json_object* push_obj = json_object_new_object();
281 const char* param = afb_req_value(request,
_parameter);
283 json_object_object_add(push_obj,
_parameter, json_tokener_parse(param));
286 HMI_ERROR(
"homescreen-service",
"please input correct parameter.");
290 afb_event_push(my_event, push_obj);
310 const char *value = afb_req_value(request,
_text);
312 HMI_NOTICE(
"homescreen-service",
"text is %s", value);
313 const char* appid = afb_req_get_application_id(request);
314 struct json_object* param_obj = json_object_new_object();
315 const char *icon = afb_req_value(request,
_icon);
317 json_object_object_add(param_obj,
_icon, json_object_new_string(icon));
318 json_object_object_add(param_obj,
_text, json_object_new_string(value));
319 struct json_object* push_obj = json_object_new_object();
321 json_object_object_add(push_obj,
_parameter, param_obj);
322 afb_event_push(my_event, push_obj);
325 HMI_NOTICE(
"homescreen-service",
"please input icon.");
330 HMI_NOTICE(
"homescreen-service",
"please input text.");
353 const char *value = afb_req_value(request,
_info);
355 HMI_NOTICE(
"homescreen-service",
"info is %s", value);
356 const char* appid = afb_req_get_application_id(request);
357 struct json_object* param_obj = json_object_new_object();
358 json_object_object_add(param_obj,
_info, json_object_new_string(value));
359 struct json_object* push_obj = json_object_new_object();
361 json_object_object_add(push_obj,
_parameter, param_obj);
362 afb_event_push(my_event, push_obj);
365 HMI_NOTICE(
"homescreen-service",
"please input information.");
int subscribe(afb_req_t request, const char *event)
static const char _text[]
#define AFB_REQ_SHOWNOTIFICATION_ERROR
HS_Client(afb_req_t request, const char *id)
const char _reply_message[]
#define HMI_NOTICE(prefix, args,...)
int replyShowWindow(afb_req_t request, const char *appid)
int on_screen_message(afb_req_t request, const char *message)
int showInformation(afb_req_t request)
static const char _parameter[]
int on_screen_reply(afb_req_t request, const char *message)
int unsubscribe(afb_req_t request, const char *event)
static const char _type[]
int showNotification(afb_req_t request)
void hs_add_object_to_json_object_str(struct json_object *j_obj, int count,...)
const char _display_message[]
static const char _icon[]
int showWindow(afb_req_t request, const char *appid)
int hideWindow(afb_req_t request)
#define HMI_ERROR(prefix, args,...)
static const char _replyto[]
static const char _info[]
const char _application_id[]
#define AFB_EVENT_BAD_REQUEST
int tap_shortcut(const char *appid)
#define AFB_REQ_SHOWINFORMATION_ERROR