diff options
Diffstat (limited to 'src/hs-periphery.h')
-rw-r--r-- | src/hs-periphery.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/hs-periphery.h b/src/hs-periphery.h index d2da39e..3ed98eb 100644 --- a/src/hs-periphery.h +++ b/src/hs-periphery.h @@ -20,33 +20,33 @@ #include <unordered_map> #include "hs-helper.h" -class HS_Periphery { -public: +struct HS_Periphery { virtual int init(afb_api_t api) = 0; virtual void onEvent(afb_api_t api, const char *event, struct json_object *object) = 0; + std::string getAppid() {return my_appid;} + + std::string my_appid; }; class HS_Restriction : public HS_Periphery { public: - HS_Restriction() = default; + HS_Restriction() {my_appid = "restriction";} ~HS_Restriction() = default; + HS_Restriction(HS_Restriction const &) = delete; + HS_Restriction &operator=(HS_Restriction const &) = delete; int init(afb_api_t api); void onEvent(afb_api_t api, const char *event, struct json_object *object); private: - const std::unordered_set<const char*> concerned_event_list { - "windowmanager/RestrictionOn", - "windowmanager/RestrictionOff" + typedef void (HS_Restriction::*func_handler)(afb_api_t, struct json_object*); + const std::unordered_map<std::string, func_handler> concerned_event_list { + {"windowmanager/RestrictionOn", &HS_Restriction::restrictionOn}, + {"windowmanager/RestrictionOff", &HS_Restriction::restrictionOff} }; - inline bool isConcernedEvent(const char* event) const { - return (concerned_event_list.find(event) != concerned_event_list.end()) ? true : false; - } void restrictionOn(afb_api_t api, struct json_object *object); void restrictionOff(afb_api_t api, struct json_object *object); - - std::string m_appid = "restriction"; }; class HS_PeripheryManager { @@ -59,20 +59,12 @@ public: void onEvent(afb_api_t api, const char *event, struct json_object *object); inline bool isPeripheryApp(const char* name) const { - return (periphery_app_list.find(name) != periphery_app_list.end()) ? true : false; + return (periphery_list.find(name) != periphery_list.end()) ? true : false; } private: - const std::unordered_set<const char*> periphery_app_list { - "launcher", - "homescreen", - "onscreenapp", - "restriction" - }; - static HS_PeripheryManager* me; std::unordered_map<std::string, HS_Periphery*> periphery_list; - // HS_Restriction m_restriction; }; #endif // HOMESCREEN_PERIPHERY_H
\ No newline at end of file |