std::string("application-list-changed"),
std::string("registerShortcut"),
std::string("updateShortcut"),
+ std::string("setDestination"),
+ std::string("cancelDestination"),
+ std::string("startNavigation"),
+ std::string("stopNavigation"),
std::string("none")
};
*/
void LibHomeScreen::publishSubscription(void)
{
+ struct json_object* j_obj = json_object_new_array();
for(auto &it : handlers) {
- this->subscribe(LibHomeScreen::event_list[it.first - 1]);
+ json_object_array_add(j_obj, json_object_new_string(LibHomeScreen::event_list[it.first - 1].c_str()));
+ }
+
+ if(!sp_websock) {
+ return;
+ }
+ struct json_object* push_obj = json_object_new_object();
+ json_object_object_add(push_obj, "event", j_obj);
+
+ int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", push_obj, _on_reply_static, this);
+ if (ret < 0) {
+ HMI_ERROR("libhomescreen","Failed to call subscribe.");
}
}
* - Returns 0 on success or -1 in case of error.
*
*/
-int LibHomeScreen::registerShortcut(json_object* json)
+int LibHomeScreen::registerShortcut(const char* application_id, json_object* json)
{
- if(!sp_websock)
- {
- return -1;
- }
+ if(!sp_websock)
+ {
+ return -1;
+ }
+
+ struct json_object* j_obj = json_object_new_object();
+ struct json_object* val = json_object_new_string(application_id);
+ json_object_object_add(j_obj, ApplicationId, val);
+ json_object_object_add(j_obj, "parameter", json);
- return this->call("registerShortcut", json);
+ return this->call("registerShortcut", j_obj);
}
+
/**
- * update shortcut list
+ * update shortcut to launcher
*
- * Call HomeScreen Service's updateShortcut verb to notify shortcut list.
+ * Call HomeScreen Service's updateShortcut verb to update shortcut.
*
* #### Parameters
* - json [in] : This argument should be specified to the json parameters.
* - Returns 0 on success or -1 in case of error.
*
*/
-int LibHomeScreen::updateShortcut(json_object* json)
+int LibHomeScreen::updateShortcut(const char* application_id, json_object* json)
{
- if(!sp_websock)
- {
- return -1;
- }
+ if(!sp_websock)
+ {
+ return -1;
+ }
+
+ struct json_object* j_obj = json_object_new_object();
+ struct json_object* val = json_object_new_string(application_id);
+ json_object_object_add(j_obj, ApplicationId, val);
+ json_object_object_add(j_obj, "parameter", json);
- return this->call("updateShortcut", json);
+ return this->call("updateShortcut", j_obj);
}
+
/************* Callback Function *************/
void LibHomeScreen::on_hangup(void *closure, struct afb_wsj1 *wsj)
break;
}
}
- return (i + 1) < Event_Max ? i : Event_Max;
+ return (i + 1) < Event_Max ? (i + 1) : Event_Max;
}
static bool has_verb(const string& verb)