diff options
Diffstat (limited to 'xdg-launcher/src/runxdg.hpp')
-rw-r--r-- | xdg-launcher/src/runxdg.hpp | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/xdg-launcher/src/runxdg.hpp b/xdg-launcher/src/runxdg.hpp index 2a94732..fa4ca0b 100644 --- a/xdg-launcher/src/runxdg.hpp +++ b/xdg-launcher/src/runxdg.hpp @@ -23,7 +23,9 @@ #define RUNXDG_HPP #include <string> +#include <vector> #include <map> +#include <algorithm> #include <gio/gio.h> @@ -56,38 +58,78 @@ class ILMControl } }; -class AFM +enum launcher_t { + POSIX, + AFM_DBUS, + AFM_WEBSOCKET, +}; + +class Launcher { public: + virtual void register_surfpid(pid_t surf_pid) = 0; + virtual void unregister_surfpid(pid_t surf_pid) = 0; + virtual pid_t find_surfpid_by_rid(pid_t app_pid) = 0; + virtual int launch(std::string &name) = 0; + virtual void loop(volatile sig_atomic_t* e_flag) = 0; int m_rid; }; -class AFMDBus : public AFM +class POSIXLauncher : public Launcher +{ + private: + std::vector<pid_t> m_pid_v; + + public: + void register_surfpid(pid_t surf_pid); + void unregister_surfpid(pid_t surf_pid); + pid_t find_surfpid_by_rid(pid_t rid); + + int launch(std::string &name); + void loop(volatile sig_atomic_t* e_flag); +}; + +class AFMLauncher : public Launcher +{ + private: + std::map<int, int> m_pgids; // pair of <afm:rid, ivi:pid> + + public: + void register_surfpid(pid_t surf_pid); + void unregister_surfpid(pid_t surf_pid); + pid_t find_surfpid_by_rid(pid_t app_pid); +}; + +class AFMDBusLauncher : public AFMLauncher { public: int launch(std::string &name); + void loop(volatile sig_atomic_t* e_flag) { + while (!(*e_flag)) { sleep(60*60*24); } } + private: - int get_dbus_message_bus(GBusType bus_type, GDBusConnection* &conn); + int get_dbus_message_bus(GBusType bus_type, GDBusConnection* &conn); + + const char* DBUS_SERVICE = "org.AGL.afm.user"; + const char* DBUS_PATH = "/org/AGL/afm/user"; + const char* DBUS_INTERFACE = "org.AGL.afm.user"; }; -class AFMWebSocket : public AFM +class AFMWebSocketLauncher : public AFMLauncher { // not implemented yet public: int launch(std::string &name) { return 0; } -}; - -enum { - AFM_DBUS, - AFM_WEBSOCKET, + void loop(volatile sig_atomic_t* e_flag) { + while (!(*e_flag)) { sleep(60*60*24); } } }; class RunXDG { public: - RunXDG(int bus_type, int port, const char* &token); + RunXDG(enum launcher_t type, int port, const char* &token); void start(void); void notify_ivi_control_cb(ilmObjectType object, t_ilm_uint id, @@ -101,14 +143,13 @@ class RunXDG int m_port; std::string m_token; - AFM *m_afm; + Launcher *m_launcher; LibWindowmanager *m_wm; LibHomeScreen *m_hs; ILMControl *m_ic; std::map<int, int> m_surfaces; // pair of <afm:rid, ivi:id> - std::map<int, int> m_pgids; // pair of <afm:rid, ivi:pid> bool m_pending_create = false; @@ -116,10 +157,6 @@ class RunXDG int init_hs(void); void setup_surface(int id); - - void register_surfpid(pid_t surf_pid); - void unregister_surfpid(pid_t surf_pid); - pid_t find_surfpid_by_rid(pid_t app_pid); }; #endif // RUNXDG_HPP |