merge vui
[apps/agl-service-homescreen.git] / src / hs-vuiadapter.h
diff --git a/src/hs-vuiadapter.h b/src/hs-vuiadapter.h
new file mode 100644 (file)
index 0000000..6bf47b0
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HOMESCREEN_VUIADAPTER_H
+#define HOMESCREEN_VUIADAPTER_H
+
+#include <map>
+#include <memory>
+#include <utility>
+#include "hs-helper.h"
+#include "hs-clientmanager.h"
+
+class Vui_ModuleBase {
+public:
+    explicit Vui_ModuleBase(std::string uid) : m_uid(uid) {}
+    virtual ~Vui_ModuleBase() {}
+    virtual void init(afb_api_t api) = 0;
+    virtual int onEvent(afb_api_t api, const char *event, struct json_object *object) = 0;
+    std::string mouduleId(void) {return m_uid;}
+
+private:
+    std::string m_uid;
+};
+
+class Vui_Navigation : public Vui_ModuleBase, public listener_interface {
+public:
+    explicit Vui_Navigation(std::string uid) : Vui_ModuleBase(uid), listener_interface(uid) {}
+    ~Vui_Navigation() = default;
+
+    virtual void init(afb_api_t api);
+    virtual int onEvent(afb_api_t api, const char *event, struct json_object *object);
+    virtual void notify(afb_api_t api, std::string appid = "");
+
+private:
+    void set_destination(afb_api_t api, struct json_object *object);
+    void cancel_navigation(afb_api_t api, struct json_object *object);
+    void set_destination2poi(afb_api_t api);
+    void start_navigation(afb_api_t api);
+
+    typedef void (Vui_Navigation::*func_handler)(afb_api_t, struct json_object *object);
+    static const std::map<std::string, func_handler> func_list;
+    std::pair<double, double> m_dest;
+    std::pair<bool, bool> m_start_flg;
+};
+
+class HS_VuiAdapter {
+public:
+    HS_VuiAdapter() = default;
+    ~HS_VuiAdapter() = default;
+    HS_VuiAdapter(HS_VuiAdapter const &) = delete;
+    HS_VuiAdapter &operator=(HS_VuiAdapter const &) = delete;
+    HS_VuiAdapter(HS_VuiAdapter &&) = delete;
+    HS_VuiAdapter &operator=(HS_VuiAdapter &&) = delete;
+
+    static HS_VuiAdapter* instance(void);
+    void init(afb_api_t api);
+    int onEvent(afb_api_t api, const char *event, struct json_object *object);
+
+private:
+    static HS_VuiAdapter* me;
+    std::map<std::string, Vui_ModuleBase*> module_list;
+};
+
+#endif // HOMESCREEN_VUIADAPTER_H
\ No newline at end of file