aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-06-13 09:28:39 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-06-13 09:28:39 +0900
commit36ad8522478ef330d0396d256648f679bd600369 (patch)
tree3439ecbccd5cbe3dd5e0b0682eee1424791891fd
parent321f08ed8d0a4d3b1f4bd486e8a4240f4d3443ee (diff)
Add restriction event for als2018sandbox/zheng_wenlong/als2018
-rw-r--r--src/homescreen.c100
-rw-r--r--src/hs-helper.h2
2 files changed, 93 insertions, 9 deletions
diff --git a/src/homescreen.c b/src/homescreen.c
index f1a8fcd..0045b8b 100644
--- a/src/homescreen.c
+++ b/src/homescreen.c
@@ -29,7 +29,7 @@
#include "hs-helper.h"
#include "hmi-debug.h"
-#define COMMAND_EVENT_NUM 4
+#define COMMAND_EVENT_NUM 6
#define EVENT_SUBSCRIBE_ERROR_CODE 100
/* To Do hash table is better */
@@ -43,6 +43,8 @@ static struct event event_list[COMMAND_EVENT_NUM];
static struct afb_event ev_tap_shortcut;
static struct afb_event ev_on_screen_message;
static struct afb_event ev_on_screen_reply;
+static struct afb_event ev_allocateRestriction;
+static struct afb_event ev_releaseRestriction;
static struct afb_event ev_reserved;
static const char _error[] = "error";
@@ -50,6 +52,8 @@ static const char _error[] = "error";
static const char _application_name[] = "application_name";
static const char _display_message[] = "display_message";
static const char _reply_message[] = "reply_message";
+static const char _application_role[] = "Role";
+static const char _args[] = "args";
/*
********** Method of HomeScreen Service (API) **********
@@ -255,17 +259,87 @@ static void unsubscribe(struct afb_req request)
afb_req_success_f(request, res, "homescreen binder unsubscribe event name [%s]", value);
}
+/**
+ * allocateRestriction event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libhomescreen.cpp
+ *
+ * #### Return
+ * Nothing
+ *
+ * #### Note
+ *
+ */
+static void allocateRestriction(struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _args);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ struct json_object* push_obj = json_tokener_parse(value);
+ afb_event_push(ev_allocateRestriction, push_obj);
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to Application
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [allocateRestriction]");
+}
+
+/**
+ * releaseRestriction event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libhomescreen.cpp
+ *
+ * #### Return
+ * Nothing
+ *
+ * #### Note
+ *
+ */
+static void releaseRestriction(struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _args);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ struct json_object* push_obj = json_tokener_parse(value);
+ afb_event_push(ev_releaseRestriction, push_obj);
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to Application
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [releaseRestriction]");
+}
+
/*
* array of the verbs exported to afb-daemon
*/
static const struct afb_verb_v2 verbs[]= {
/* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL */
- { .verb = "ping", .session = AFB_SESSION_NONE, .callback = pingSample, .auth = NULL },
- { .verb = "tap_shortcut", .session = AFB_SESSION_NONE, .callback = tap_shortcut, .auth = NULL },
- { .verb = "on_screen_message", .session = AFB_SESSION_NONE, .callback = on_screen_message, .auth = NULL },
- { .verb = "on_screen_reply", .session = AFB_SESSION_NONE, .callback = on_screen_reply, .auth = NULL },
- { .verb = "subscribe", .session = AFB_SESSION_NONE, .callback = subscribe, .auth = NULL },
- { .verb = "unsubscribe", .session = AFB_SESSION_NONE, .callback = unsubscribe, .auth = NULL },
+ { .verb = "ping", .session = AFB_SESSION_NONE, .callback = pingSample, .auth = NULL },
+ { .verb = "tap_shortcut", .session = AFB_SESSION_NONE, .callback = tap_shortcut, .auth = NULL },
+ { .verb = "on_screen_message", .session = AFB_SESSION_NONE, .callback = on_screen_message, .auth = NULL },
+ { .verb = "on_screen_reply", .session = AFB_SESSION_NONE, .callback = on_screen_reply, .auth = NULL },
+ { .verb = "subscribe", .session = AFB_SESSION_NONE, .callback = subscribe, .auth = NULL },
+ { .verb = "unsubscribe", .session = AFB_SESSION_NONE, .callback = unsubscribe, .auth = NULL },
+ { .verb = "allocateRestriction", .session = AFB_SESSION_NONE, .callback = allocateRestriction, .auth = NULL },
+ { .verb = "releaseRestriction", .session = AFB_SESSION_NONE, .callback = releaseRestriction, .auth = NULL },
{NULL } /* marker for end of the array */
};
@@ -282,7 +356,9 @@ static int init()
ev_tap_shortcut = afb_daemon_make_event(evlist[0]);
ev_on_screen_message = afb_daemon_make_event(evlist[1]);
ev_on_screen_reply = afb_daemon_make_event(evlist[2]);
- ev_reserved = afb_daemon_make_event(evlist[3]);
+ ev_allocateRestriction = afb_daemon_make_event(evlist[3]);
+ ev_releaseRestriction = afb_daemon_make_event(evlist[4]);
+ ev_reserved = afb_daemon_make_event(evlist[5]);
event_list[0].name = evlist[0];
event_list[0].event = &ev_tap_shortcut;
@@ -294,7 +370,13 @@ static int init()
event_list[2].event = &ev_on_screen_reply;
event_list[3].name = evlist[3];
- event_list[3].event = &ev_reserved;
+ event_list[3].event = &ev_allocateRestriction;
+
+ event_list[4].name = evlist[4];
+ event_list[4].event = &ev_releaseRestriction;
+
+ event_list[5].name = evlist[5];
+ event_list[5].event = &ev_reserved;
return 0;
}
diff --git a/src/hs-helper.h b/src/hs-helper.h
index 5ce9eb5..94f8efd 100644
--- a/src/hs-helper.h
+++ b/src/hs-helper.h
@@ -34,6 +34,8 @@ static const char* evlist[] = {
"tap_shortcut",
"on_screen_message",
"on_screen_reply",
+ "allocateRestriction",
+ "releaseRestriction",
"reserved"
};