static const char _replyto[] = "replyto";
static const char _caller[] = "caller";
+// homescreen-service event and event handler function list
+const std::unordered_map<std::string, HS_Client::func_handler> HS_Client::func_list {
+ {"tap_shortcut", &HS_Client::tap_shortcut},
+ {"showWindow", &HS_Client::showWindow},
+ {"hideWindow", &HS_Client::hideWindow},
+ {"replyShowWindow", &HS_Client::replyShowWindow},
+ {"on_screen_message", &HS_Client::on_screen_message},
+ {"on_screen_reply", &HS_Client::on_screen_reply},
+ {"subscribe", &HS_Client::subscribe},
+ {"unsubscribe", &HS_Client::unsubscribe},
+ {"showNotification", &HS_Client::showNotification},
+ {"showInformation", &HS_Client::showInformation},
+ {"application-list-changed", nullptr}
+};
+
/**
* HS_Client construction function
*
int ret = AFB_EVENT_BAD_REQUEST;
auto ip = func_list.find(std::string(verb));
- if(ip != func_list.end()) {
+ if(ip != func_list.end() && ip->second != nullptr) {
HMI_NOTICE("homescreen-service","[%s]verb found", verb);
ret = (this->*(ip->second))(request);
}
return ret;
+}
+
+/**
+ * push event
+ *
+ * #### Parameters
+ * - event : the event want to push
+ * - param : the parameter contents of event
+ *
+ * #### Return
+ * 0 : success
+ * others : fail
+ *
+ */
+int HS_Client::pushEvent(const char *event, struct json_object *param)
+{
+ if(!checkEvent(event))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","called, event=%s.",event);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _application_id, my_id.c_str(), _type, event);
+ if(param != nullptr)
+ json_object_object_add(push_obj, _parameter, param);
+ afb_event_push(my_event, push_obj);
+ return 0;
}
\ No newline at end of file