1 #pragma once 2 #include "../webserver/cWebem.h" 3 #include "../webserver/request.hpp" 4 5 #define OPTIONS_NONE 0 6 #define OPTIONS_URL_SUBJECT 1 7 #define OPTIONS_URL_BODY 2 8 #define OPTIONS_HTML_SUBJECT 4 9 #define OPTIONS_HTML_BODY 8 10 #define OPTIONS_URL_PARAMS 16 11 12 class CNotificationBase { 13 friend class CNotificationHelper; 14 protected: 15 CNotificationBase(const std::string &subsystemid, const int options = OPTIONS_NONE); 16 virtual ~CNotificationBase(); 17 bool SendMessage( 18 const uint64_t Idx, 19 const std::string &Name, 20 const std::string &Subject, 21 const std::string &Text, 22 const std::string &ExtraData, 23 const bool bFromNotification); 24 bool SendMessageEx( 25 const uint64_t Idx, 26 const std::string &Name, 27 const std::string &Subject, 28 const std::string &Text, 29 const std::string &ExtraData, 30 const int Priority, 31 const std::string &Sound, 32 const bool bFromNotification); 33 void SetConfigValue(const std::string &Key, const std::string &Value); 34 std::string GetSubsystemId(); 35 bool IsInConfig(const std::string &Key); 36 bool IsInConfigString(const std::string &Key); 37 bool IsInConfigInt(const std::string &Key); 38 bool IsInConfigBase64(const std::string &Key); 39 void ConfigFromGetvars(const http::server::request& req, const bool save); 40 virtual bool IsConfigured() = 0; 41 void SetupConfig(const std::string &Key, std::string& Value); 42 void SetupConfig(const std::string &Key, int *Value); 43 void SetupConfigBase64(const std::string &Key, std::string& Value); 44 virtual bool SendMessageImplementation( 45 const uint64_t Idx, 46 const std::string &Name, 47 const std::string &Subject, 48 const std::string &Text, 49 const std::string &ExtraData, 50 const int Priority, 51 const std::string &Sound, 52 const bool bFromNotification) = 0; 53 void LoadConfig(); 54 55 int m_IsEnabled; 56 private: 57 std::mutex SendMessageExMutex; 58 std::string _subsystemid; 59 std::map<std::string, std::string* > _configValues; 60 std::map<std::string, std::string* > _configValuesBase64; 61 std::map<std::string, int* > _configValuesInt; 62 int _options; 63 }; 64