diff options
-rw-r--r-- | src/homescreen.cpp | 41 | ||||
-rw-r--r-- | src/hs-client.cpp | 12 | ||||
-rw-r--r-- | src/hs-client.h | 14 | ||||
-rw-r--r-- | src/hs-clientmanager.cpp | 6 | ||||
-rw-r--r-- | src/hs-clientmanager.h | 6 | ||||
-rw-r--r-- | src/hs-helper.cpp | 6 | ||||
-rw-r--r-- | src/hs-helper.h | 8 |
7 files changed, 47 insertions, 46 deletions
diff --git a/src/homescreen.cpp b/src/homescreen.cpp index a3039c5..fdc9e85 100644 --- a/src/homescreen.cpp +++ b/src/homescreen.cpp @@ -36,7 +36,7 @@ static HS_ClientManager* g_client_manager = HS_ClientManager::instance(); ********** Method of HomeScreen Service (API) ********** */ -static void pingSample(struct afb_req request) +static void pingSample(afb_req_t request) { static int pingcount = 0; afb_req_success_f(request, json_object_new_int(pingcount), "Ping count = %d", pingcount); @@ -56,7 +56,7 @@ static void pingSample(struct afb_req request) * None * */ -static void tap_shortcut (struct afb_req request) +static void tap_shortcut (afb_req_t request) { HMI_NOTICE("homescreen-service","called."); @@ -100,7 +100,7 @@ static void tap_shortcut (struct afb_req request) * None * */ -static void on_screen_message (struct afb_req request) +static void on_screen_message (afb_req_t request) { HMI_NOTICE("homescreen-service","called."); @@ -138,7 +138,7 @@ static void on_screen_message (struct afb_req request) * None * */ -static void on_screen_reply (struct afb_req request) +static void on_screen_reply (afb_req_t request) { HMI_NOTICE("homescreen-service","called."); @@ -175,7 +175,7 @@ static void on_screen_reply (struct afb_req request) * None * */ -static void subscribe(struct afb_req request) +static void subscribe(afb_req_t request) { const char *value = afb_req_value(request, "event"); HMI_NOTICE("homescreen-service","value is %s", value); @@ -209,7 +209,7 @@ static void subscribe(struct afb_req request) * None * */ -static void unsubscribe(struct afb_req request) +static void unsubscribe(afb_req_t request) { const char *value = afb_req_value(request, "event"); HMI_NOTICE("homescreen-service","value is %s", value); @@ -243,14 +243,14 @@ static void unsubscribe(struct afb_req request) /* * array of the verbs exported to afb-daemon */ -static const struct afb_verb_v2 verbs[]= { - /* VERB'S NAME FUNCTION TO CALL authorisation some info SESSION MANAGEMENT */ - { .verb = "ping", .callback = pingSample, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, - { .verb = "tap_shortcut", .callback = tap_shortcut, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, - { .verb = "on_screen_message", .callback = on_screen_message, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, - { .verb = "on_screen_reply", .callback = on_screen_reply, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, - { .verb = "subscribe", .callback = subscribe, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, - { .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE }, +static const afb_verb_t verbs[]= { + /* VERB'S NAME FUNCTION TO CALL */ + { .verb="ping", .callback=pingSample }, + { .verb="tap_shortcut", .callback=tap_shortcut }, + { .verb="on_screen_message", .callback=on_screen_message }, + { .verb="on_screen_reply", .callback=on_screen_reply }, + { .verb="subscribe", .callback=subscribe }, + { .verb="unsubscribe", .callback=unsubscribe }, {NULL } /* marker for end of the array */ }; @@ -258,13 +258,13 @@ static const struct afb_verb_v2 verbs[]= { * homescreen binding preinit function * * #### Parameters - * - null + * - api : the api serving the request * * #### Return * None * */ -static int preinit() +static int preinit(afb_api_t api) { HMI_NOTICE("homescreen-service","binding preinit (was register)"); return 0; @@ -274,13 +274,13 @@ static int preinit() * homescreen binding init function * * #### Parameters - * - null + * - api : the api serving the request * * #### Return * None * */ -static int init() +static int init(afb_api_t api) { HMI_NOTICE("homescreen-service","binding init"); @@ -293,6 +293,7 @@ static int init() * homescreen binding event function * * #### Parameters + * - api : the api serving the request * - event : event name * - object : event json object * @@ -300,12 +301,12 @@ static int init() * None * */ -static void onevent(const char *event, struct json_object *object) +static void onevent(afb_api_t api, const char *event, struct json_object *object) { HMI_NOTICE("homescreen-service","on_event %s", event); } -const struct afb_binding_v2 afbBindingV2 = { +const afb_binding_t afbBindingExport = { .api = "homescreen", .specification = NULL, .info = NULL, diff --git a/src/hs-client.cpp b/src/hs-client.cpp index 807b068..9fc9b61 100644 --- a/src/hs-client.cpp +++ b/src/hs-client.cpp @@ -30,10 +30,10 @@ static const char _type[] = "type"; * None * */ -HS_Client::HS_Client(struct afb_req request, std::string id) : my_id(id) +HS_Client::HS_Client(afb_req_t request, std::string id) : my_id(id) { HMI_NOTICE("homescreen-service","called."); - my_event = afb_daemon_make_event(id.c_str()); + my_event = afb_api_make_event(request->api, id.c_str()); } /** @@ -84,7 +84,7 @@ int HS_Client::tap_shortcut(const char* appname) * result * */ -int HS_Client::on_screen_message(struct afb_req request, const char* message) +int HS_Client::on_screen_message(afb_req_t request, const char* message) { if(!checkEvent(__FUNCTION__)) return 0; @@ -106,7 +106,7 @@ int HS_Client::on_screen_message(struct afb_req request, const char* message) * result * */ -int HS_Client::on_screen_reply(struct afb_req request, const char* message) +int HS_Client::on_screen_reply(afb_req_t request, const char* message) { if(!checkEvent(__FUNCTION__)) return 0; @@ -128,7 +128,7 @@ int HS_Client::on_screen_reply(struct afb_req request, const char* message) * result * */ -int HS_Client::subscribe(struct afb_req request, const char* event) +int HS_Client::subscribe(afb_req_t request, const char* event) { int ret = 0; auto ip = event_list.find(std::string(event)); @@ -149,7 +149,7 @@ int HS_Client::subscribe(struct afb_req request, const char* event) * result * */ -int HS_Client::unsubscribe(struct afb_req request, const char* event) +int HS_Client::unsubscribe(afb_req_t request, const char* event) { int ret = 0; event_list.erase(std::string(event)); diff --git a/src/hs-client.h b/src/hs-client.h index 035f3c4..1b2eb8f 100644 --- a/src/hs-client.h +++ b/src/hs-client.h @@ -24,24 +24,24 @@ class HS_Client { public: - HS_Client(struct afb_req request, const char* id) : HS_Client(request, std::string(id)){} - HS_Client(struct afb_req request, std::string id); + HS_Client(afb_req_t request, const char* id) : HS_Client(request, std::string(id)){} + HS_Client(afb_req_t request, std::string id); HS_Client(HS_Client&) = delete; HS_Client &operator=(HS_Client&) = delete; ~HS_Client(); int tap_shortcut(const char* appname); - int on_screen_message (struct afb_req request, const char* message); - int on_screen_reply (struct afb_req request, const char* message); - int subscribe(struct afb_req request, const char* event); - int unsubscribe(struct afb_req request, const char* event); + int on_screen_message (afb_req_t request, const char* message); + int on_screen_reply (afb_req_t request, const char* message); + int subscribe(afb_req_t request, const char* event); + int unsubscribe(afb_req_t request, const char* event); private: bool checkEvent(const char* event); private: std::string my_id; - struct afb_event my_event; + afb_event_t my_event; std::unordered_map<std::string, int> event_list; }; diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index 3dea3a6..a79e9bb 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -104,7 +104,7 @@ HS_Client* HS_ClientManager::find(std::string appid) * found HS_Client pointer * */ -HS_Client* HS_ClientManager::getClient(afb_req req, std::string appid) +HS_Client* HS_ClientManager::getClient(afb_req_t req, std::string appid) { std::lock_guard<std::mutex> lock(this->mtx); HS_Client* p = nullptr; @@ -148,7 +148,7 @@ std::vector<HS_Client*> HS_ClientManager::getAllClient(void) * HS_ClientCtxt pointer * */ -HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req req, std::string appid) +HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req_t req, std::string appid) { HS_ClientCtxt *ctxt = (HS_ClientCtxt *)afb_req_context_get(req); if (!ctxt) @@ -171,7 +171,7 @@ HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req req, std::string appid * HS_Client pointer * */ -HS_Client* HS_ClientManager::addClient(afb_req req, std::string appid) +HS_Client* HS_ClientManager::addClient(afb_req_t req, std::string appid) { return (client_list[appid] = new HS_Client(req, appid)); } diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h index cb49088..99c6c0b 100644 --- a/src/hs-clientmanager.h +++ b/src/hs-clientmanager.h @@ -47,13 +47,13 @@ public: static HS_ClientManager* instance(void); int init(void); HS_Client* find(std::string appid); - HS_Client* getClient(afb_req req, std::string appid); + HS_Client* getClient(afb_req_t req, std::string appid); std::vector<HS_Client*> getAllClient(void); void removeClientCtxt(void *data); private: - HS_ClientCtxt* createClientCtxt(afb_req req, std::string appid); - HS_Client* addClient(afb_req req, std::string appid); + HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid); + HS_Client* addClient(afb_req_t req, std::string appid); void removeClient(std::string appid); private: diff --git a/src/hs-helper.cpp b/src/hs-helper.cpp index a599fdd..2d8ab7a 100644 --- a/src/hs-helper.cpp +++ b/src/hs-helper.cpp @@ -38,7 +38,7 @@ const char* evlist[] = { * error code * */ -REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id) +REQ_ERROR get_value_uint16(const afb_req_t request, const char *source, uint16_t *out_id) { char* endptr; const char* tmp = afb_req_value (request, source); @@ -74,7 +74,7 @@ REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uin * error code * */ -REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id) +REQ_ERROR get_value_int16(const afb_req_t request, const char *source, int16_t *out_id) { char* endptr; const char* tmp = afb_req_value (request, source); @@ -110,7 +110,7 @@ REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int1 * error code * */ -REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id) +REQ_ERROR get_value_int32(const afb_req_t request, const char *source, int32_t *out_id) { char* endptr; const char* tmp = afb_req_value (request, source); diff --git a/src/hs-helper.h b/src/hs-helper.h index 6aba71e..3195daf 100644 --- a/src/hs-helper.h +++ b/src/hs-helper.h @@ -16,7 +16,7 @@ #ifndef HOMESCREEN_HELPER_H #define HOMESCREEN_HELPER_H -#define AFB_BINDING_VERSION 2 +#define AFB_BINDING_VERSION 3 #include <afb/afb-binding.h> #include <json-c/json.h> @@ -35,9 +35,9 @@ extern const char _application_name[]; extern const char _display_message[]; extern const char _reply_message[]; -REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id); -REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id); -REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id); +REQ_ERROR get_value_uint16(const afb_req_t request, const char *source, uint16_t *out_id); +REQ_ERROR get_value_int16(const afb_req_t request, const char *source, int16_t *out_id); +REQ_ERROR get_value_int32(const afb_req_t request, const char *source, int32_t *out_id); void hs_add_object_to_json_object(struct json_object* j_obj, int count, ...); void hs_add_object_to_json_object_str(struct json_object* j_obj, int count, ...); void hs_add_object_to_json_object_func(struct json_object* j_obj, const char* verb_name, int count, ...); |