summaryrefslogtreecommitdiffstats
path: root/src/homescreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/homescreen.cpp')
-rw-r--r--src/homescreen.cpp111
1 files changed, 26 insertions, 85 deletions
diff --git a/src/homescreen.cpp b/src/homescreen.cpp
index fdc9e85..b518139 100644
--- a/src/homescreen.cpp
+++ b/src/homescreen.cpp
@@ -23,7 +23,6 @@
#include "hmi-debug.h"
#include "hs-clientmanager.h"
-#define EVENT_SUBSCRIBE_ERROR_CODE 100
const char _error[] = "error";
const char _application_name[] = "application_name";
@@ -59,30 +58,13 @@ static void pingSample(afb_req_t request)
static void tap_shortcut (afb_req_t request)
{
HMI_NOTICE("homescreen-service","called.");
-
- int ret = 0;
- const char* value = afb_req_value(request, _application_name);
- if (value) {
- HMI_NOTICE("homescreen-service","request params = %s.", value);
- // first step get appid from appname, next step change appname to appid
- std::string appid(value);
- std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
- HS_Client* client = g_client_manager->find(appid);
- if(client != nullptr) {
- if(client->tap_shortcut(value) != 0) {
- afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
- return;
- }
- }
- else {
- // app is not started, do nothing
- }
- } else {
- afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ int ret = g_client_manager->tap_shortcut(request);
+ if (ret != 0) {
+ afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
return;
}
- // response to HomeScreen
+ // response to HomeScreen
struct json_object *res = json_object_new_object();
hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
_error, ret);
@@ -104,19 +86,9 @@ static void on_screen_message (afb_req_t request)
{
HMI_NOTICE("homescreen-service","called.");
- int ret = 0;
- const char* value = afb_req_value(request, _display_message);
- if (value) {
-
- HMI_NOTICE("homescreen-service","request params = %s.", value);
- for(auto m : g_client_manager->getAllClient()) {
- if(m->on_screen_message(request, value) != 0) {
- afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
- return;
- }
- }
- } else {
- afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ int ret = g_client_manager->on_screen_message(request);
+ if (ret != 0) {
+ afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
return;
}
@@ -142,19 +114,9 @@ static void on_screen_reply (afb_req_t request)
{
HMI_NOTICE("homescreen-service","called.");
- int ret = 0;
- const char* value = afb_req_value(request, _reply_message);
- if (value) {
-
- HMI_NOTICE("homescreen-service","request params = %s.", value);
- for(auto m : g_client_manager->getAllClient()) {
- if(m->on_screen_reply(request, value) != 0) {
- afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
- return;
- }
- }
- } else {
- afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ int ret = g_client_manager->on_screen_reply(request);
+ if (ret != 0) {
+ afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
return;
}
@@ -177,26 +139,19 @@ static void on_screen_reply (afb_req_t request)
*/
static void subscribe(afb_req_t request)
{
- const char *value = afb_req_value(request, "event");
- HMI_NOTICE("homescreen-service","value is %s", value);
- int ret = 0;
- if(value) {
- std::string appid(afb_req_get_application_id(request));
- std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
- if(g_client_manager->getClient(request, appid)->subscribe(request, value) != 0) {
- afb_req_fail_f(request, "afb_req_subscribe failed", "called %s.", __FUNCTION__);
- return;
- }
- }
- else {
- HMI_NOTICE("homescreen-service","Please input event name");
- ret = EVENT_SUBSCRIBE_ERROR_CODE;
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = g_client_manager->subscribe(request);
+ if(ret) {
+ afb_req_fail_f(request, "afb_req_subscribe failed", "called %s.", __FUNCTION__);
+ return;
}
+
/*create response json object*/
struct json_object *res = json_object_new_object();
hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
_error, ret);
- afb_req_success_f(request, res, "homescreen binder subscribe event name [%s]", value);
+ afb_req_success_f(request, res, "homescreen binder subscribe.");
}
/**
@@ -211,33 +166,19 @@ static void subscribe(afb_req_t request)
*/
static void unsubscribe(afb_req_t request)
{
- const char *value = afb_req_value(request, "event");
- HMI_NOTICE("homescreen-service","value is %s", value);
- int ret = 0;
- if(value) {
- std::string appid(afb_req_get_application_id(request));
- std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
- HS_Client* client = g_client_manager->find(appid);
- if(client != nullptr) {
- if(client->unsubscribe(request, value) != 0) {
- afb_req_fail_f(request, "afb_req_unsubscribe failed", "called %s.", __FUNCTION__);
- return;
- }
- }
- else {
- HMI_NOTICE("homescreen-service","not find app's client, unsubscribe failed");
- ret = EVENT_SUBSCRIBE_ERROR_CODE;
- }
- }
- else{
- HMI_NOTICE("homescreen-service","Please input event name");
- ret = EVENT_SUBSCRIBE_ERROR_CODE;
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = g_client_manager->unsubscribe(request);
+ if(ret) {
+ afb_req_fail_f(request, "afb_req_unsubscribe failed", "called %s.", __FUNCTION__);
+ return;
}
+
/*create response json object*/
struct json_object *res = json_object_new_object();
hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
_error, ret);
- afb_req_success_f(request, res, "homescreen binder unsubscribe event name [%s]", value);
+ afb_req_success_f(request, res, "homescreen binder unsubscribe success.");
}
/*