aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-06-11 17:13:56 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-06-11 17:13:56 +0900
commit690bef15acbffe7245b8a0b15ee4372f1ccea5d3 (patch)
tree0f0af5d3ba2c8e7cfc96caf39b187e85650e4ebf
parent8e6374d5e56f3e00ed08b970f3a95cb7e24407e1 (diff)
fix first time can not got areasandbox/zheng_wenlong/als2019_horizontal_
-rw-r--r--src/homescreen.cpp18
-rw-r--r--src/hs-clientmanager.cpp7
-rw-r--r--src/hs-clientmanager.h4
3 files changed, 22 insertions, 7 deletions
diff --git a/src/homescreen.cpp b/src/homescreen.cpp
index d9fef91..ae98643 100644
--- a/src/homescreen.cpp
+++ b/src/homescreen.cpp
@@ -37,6 +37,8 @@ const char _display_message[] = "display_message";
const char _reply_message[] = "reply_message";
const char _keyData[] = "data";
const char _keyId[] = "id";
+const char _parameter[] = "parameter";
+const char _area[] = "area";
struct hs_handshake {
hs_handshake(int times, int sleep) : m_times(times), m_sleep(sleep) {}
@@ -332,12 +334,16 @@ static void pingSample(afb_req_t request)
static void tap_shortcut (afb_req_t request)
{
int ret = 0;
+ struct json_object *param_obj, *area_obj;
const char* value = afb_req_value(request, _application_id);
- if (value) {
+ if (value
+ && json_object_object_get_ex(afb_req_json(request), _parameter, &param_obj)
+ && json_object_object_get_ex(param_obj, _area, &area_obj)) {
AFB_INFO("request appid = %s.", value);
+ const char* area = json_object_get_string(area_obj);
ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value);
if(ret == AFB_REQ_NOT_STARTED_APPLICATION) {
- g_hs_instance->client_manager->setStartupAppid(std::string(value));
+ g_hs_instance->client_manager->setStartupAppidAndArea(make_pair(std::string(value), std::string(area)));
std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId);
HS_AfmMainProxy afm_proxy;
afm_proxy.start(request->api, id);
@@ -486,11 +492,15 @@ static void unsubscribe(afb_req_t request)
static void showWindow(afb_req_t request)
{
int ret = 0;
+ struct json_object *param_obj, *area_obj;
const char* value = afb_req_value(request, _application_id);
- if (value) {
+ if (value
+ && json_object_object_get_ex(afb_req_json(request), _parameter, &param_obj)
+ && json_object_object_get_ex(param_obj, _area, &area_obj)) {
+ const char* area = json_object_get_string(area_obj);
ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value);
if(ret == AFB_REQ_NOT_STARTED_APPLICATION) {
- g_hs_instance->client_manager->setStartupAppid(std::string(value));
+ g_hs_instance->client_manager->setStartupAppidAndArea(make_pair(std::string(value), std::string(area)));
std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId);
HS_AfmMainProxy afm_proxy;
afm_proxy.start(request->api, id);
diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp
index d84d07b..a1472b8 100644
--- a/src/hs-clientmanager.cpp
+++ b/src/hs-clientmanager.cpp
@@ -20,6 +20,8 @@
#include "hs-apprecover.h"
static const char _homescreen[] = "homescreen";
+static const char _area[] = "area";
+static const char _parameter[] = "parameter";
const std::string _listen_all("all");
HS_ClientManager* HS_ClientManager::me = nullptr;
@@ -267,7 +269,10 @@ bool HS_ClientManager::checkRegisterApp(afb_api_t api, const std::string &appid)
}
else if(startup_appid == appid) {
startup_appid.clear();
- pushEvent("showWindow", nullptr, appid);
+ struct json_object* json_param = json_object_new_object();
+ json_object_object_add(json_param, _area, json_object_new_string(startup_area.c_str()));
+ pushEvent("showWindow", json_param, appid);
+ startup_area.clear();
}
else {
ret = false;
diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h
index c8bc48e..4cb1fad 100644
--- a/src/hs-clientmanager.h
+++ b/src/hs-clientmanager.h
@@ -71,7 +71,7 @@ public:
int handleRequest(afb_req_t request, const char *verb, const char *appid = nullptr);
int pushEvent(const char *event, struct json_object *param, std::string appid = "");
void removeClientCtxt(void *data); // don't use, internal only
- void setStartupAppid(const std::string &appid) {startup_appid = appid;}
+ void setStartupAppidAndArea(const std::pair<std::string, std::string> pair) {startup_appid = pair.first;startup_area = pair.second;}
bool isAppStarted(const std::string &appid);
void addListener(listener_interface* listener);
void removeListener(listener_interface* listener);
@@ -89,7 +89,7 @@ private:
std::unordered_map<std::string, HS_Client*> client_list;
std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
std::mutex mtx;
- std::string startup_appid;
+ std::string startup_appid, startup_area;
};
#endif // HOMESCREEN_CLIENTMANAGER_H \ No newline at end of file