- HMI_NOTICE("homescreen-service","Please input application_id");
- ret = AFB_EVENT_BAD_REQUEST;
- }
- return ret;
-}
-
-/**
- * hideWindow event
- *
- * #### Parameters
- * - request : the request
- *
- * #### Return
- * 0 : success
- * others : fail
- *
- */
-int HS_ClientManager::hideWindow(afb_req_t request)
-{
- int ret = 0;
- const char* value = afb_req_value(request, _application_id);
- if (value) {
- HMI_NOTICE("homescreen-service","request params = %s.", value);
- std::lock_guard<std::mutex> lock(this->mtx);
- auto ip = client_list.find(std::string(value));
- if(ip != client_list.end()) {
- ret = ip->second->hideWindow(request);
+ std::string id(appid);
+ auto ip = client_list.find(id);
+ if(ip != client_list.end()) {
+ // for showWindow verb we need to verify if the app is (still)
+ // running, and return the appropriate value to attempt to start it
+ // again. This 'problem' is avoided if the application itself
+ // subscribes and with that process, to install a callback that
+ // automatically removes the application from client_list.
+ // That is exactly how "subscribe" verb is handled below.
+ if (strcasecmp(verb, "showWindow") == 0) {
+ ret = is_application_running(id, client_list);
+ if (ret == AFB_REQ_NOT_STARTED_APPLICATION) {
+ AFB_INFO("%s is not running. Will attempt to start it", appid);
+ return ret;
+ }
+ }
+ AFB_INFO("%s found to be running. Forwarding request to the client", appid);
+ ret = ip->second->handleRequest(request, verb);