don't publish updateShortcut event when subscribe
[apps/agl-service-homescreen.git] / src / hs-vuiadapter.h
1 /*
2  * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef HOMESCREEN_VUIADAPTER_H
18 #define HOMESCREEN_VUIADAPTER_H
19
20 #include <map>
21 #include <memory>
22 #include <utility>
23 #include "hs-helper.h"
24 #include "hs-clientmanager.h"
25
26 class Vui_ModuleBase {
27 public:
28     explicit Vui_ModuleBase(std::string uid) : m_uid(uid) {}
29     virtual ~Vui_ModuleBase() {}
30     virtual void init(afb_api_t api) = 0;
31     virtual int onEvent(afb_api_t api, const char *event, struct json_object *object) = 0;
32     std::string mouduleId(void) {return m_uid;}
33
34 private:
35     std::string m_uid;
36 };
37
38 class Vui_Navigation : public Vui_ModuleBase, public listener_interface {
39 public:
40     explicit Vui_Navigation(std::string uid) : Vui_ModuleBase(uid), listener_interface(uid) {}
41     ~Vui_Navigation() = default;
42
43     virtual void init(afb_api_t api);
44     virtual int onEvent(afb_api_t api, const char *event, struct json_object *object);
45     virtual void notify(afb_api_t api, std::string appid = "");
46
47 private:
48     void set_destination(afb_api_t api, struct json_object *object);
49     void cancel_navigation(afb_api_t api, struct json_object *object);
50     void set_destination2poi(afb_api_t api);
51     void start_navigation(afb_api_t api);
52
53     typedef void (Vui_Navigation::*func_handler)(afb_api_t, struct json_object *object);
54     static const std::map<std::string, func_handler> func_list;
55     std::pair<double, double> m_dest;
56     std::pair<bool, bool> m_start_flg;
57 };
58
59 class HS_VuiAdapter {
60 public:
61     HS_VuiAdapter() = default;
62     ~HS_VuiAdapter() = default;
63     HS_VuiAdapter(HS_VuiAdapter const &) = delete;
64     HS_VuiAdapter &operator=(HS_VuiAdapter const &) = delete;
65     HS_VuiAdapter(HS_VuiAdapter &&) = delete;
66     HS_VuiAdapter &operator=(HS_VuiAdapter &&) = delete;
67
68     static HS_VuiAdapter* instance(void);
69     void init(afb_api_t api);
70     int onEvent(afb_api_t api, const char *event, struct json_object *object);
71
72 private:
73     static HS_VuiAdapter* me;
74     std::map<std::string, Vui_ModuleBase*> module_list;
75 };
76
77 #endif // HOMESCREEN_VUIADAPTER_H