2 * Copyright (c) 2017 Panasonic Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 #include <ilm/ilm_control.h>
34 #include <libwindowmanager.h>
35 #include <libhomescreen.hpp>
37 #define AGL_FATAL(fmt, ...) fatal("ERROR: " fmt "\n", ##__VA_ARGS__)
38 #define AGL_WARN(fmt, ...) warn("WARNING: " fmt "\n", ##__VA_ARGS__)
39 #define AGL_DEBUG(fmt, ...) debug("DEBUG: " fmt "\n", ##__VA_ARGS__)
40 #define AGL_TRACE(file,line) debug("%s:%d\n", file,line);
42 void fatal (const char* format, ...);
43 void warn (const char* format, ...);
44 void debug (const char* format, ...);
49 ILMControl(notificationFunc callback, void *user_data) {
51 ilm_registerNotification(callback, user_data);
55 ilm_unregisterNotification();
57 AGL_DEBUG("ilm_destory().\n");
64 virtual void register_surfpid(pid_t surf_pid) = 0;
65 virtual void unregister_surfpid(pid_t surf_pid) = 0;
66 virtual pid_t find_surfpid_by_rid(pid_t app_pid) = 0;
68 virtual int launch(std::string& name) = 0;
69 virtual void loop(volatile sig_atomic_t& e_flag) = 0;
74 class POSIXLauncher : public Launcher
77 std::vector<pid_t> m_pid_v;
80 std::vector<std::string> m_args_v;
82 void register_surfpid(pid_t surf_pid);
83 void unregister_surfpid(pid_t surf_pid);
84 pid_t find_surfpid_by_rid(pid_t rid);
86 int launch(std::string& name);
87 void loop(volatile sig_atomic_t& e_flag);
90 class AFMLauncher : public Launcher
93 std::map<int, int> m_pgids; // pair of <afm:rid, ivi:pid>
96 void register_surfpid(pid_t surf_pid);
97 void unregister_surfpid(pid_t surf_pid);
98 pid_t find_surfpid_by_rid(pid_t app_pid);
101 class AFMDBusLauncher : public AFMLauncher
104 int launch(std::string& name);
105 void loop(volatile sig_atomic_t& e_flag) {
106 while (!(e_flag)) { sleep(60*60*24); } }
109 int get_dbus_message_bus(GBusType bus_type, GDBusConnection* &conn);
111 const char* DBUS_SERVICE = "org.AGL.afm.user";
112 const char* DBUS_PATH = "/org/AGL/afm/user";
113 const char* DBUS_INTERFACE = "org.AGL.afm.user";
116 class AFMWebSocketLauncher : public AFMLauncher
118 // not implemented yet
120 int launch(std::string& name) { return 0; }
121 void loop(volatile sig_atomic_t& e_flag) {
122 while (!(e_flag)) { sleep(60*60*24); } }
128 RunXDG(int port, const char* token, const char* id);
131 void notify_ivi_control_cb(ilmObjectType object, t_ilm_uint id,
133 static void notify_ivi_control_cb_static (ilmObjectType object,
146 Launcher *m_launcher;
148 LibWindowmanager *m_wm;
152 std::map<int, int> m_surfaces; // pair of <afm:rid, ivi:id>
154 bool m_pending_create = false;
159 int parse_config(const char *file);
161 void setup_surface(int id);