diff options
Diffstat (limited to 'server/include')
-rw-r--r-- | server/include/api_module_base.h | 2 | ||||
-rw-r--r-- | server/include/client.h | 30 | ||||
-rw-r--r-- | server/include/event_subscription_base.h | 42 | ||||
-rw-r--r-- | server/include/event_subscription_event.h | 35 | ||||
-rw-r--r-- | server/include/event_subscription_repeated.h | 38 |
5 files changed, 145 insertions, 2 deletions
diff --git a/server/include/api_module_base.h b/server/include/api_module_base.h index 6f01746..9c1b639 100644 --- a/server/include/api_module_base.h +++ b/server/include/api_module_base.h @@ -49,7 +49,7 @@ class module_base { return settings; } - virtual ~module_base() = 0; + virtual ~module_base(){}; protected: std::map<std::string, setting_s> settings; module_info_base info; diff --git a/server/include/client.h b/server/include/client.h index f9daff6..d6668a3 100644 --- a/server/include/client.h +++ b/server/include/client.h @@ -1,19 +1,47 @@ +/* + Copyright © 2015 Gluzskiy Alexandr (sss) + + This file is part of Unknown Download Manager (UDM). + + UDM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + UDM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UDM. If not, see <http://www.gnu.org/licenses/>. + +*/ + #ifndef CLIENT_H #define CLIENT_H #include <string> +#include <list> +#include "event_subscription_base.h" + +class server_session; class client { public: - client(std::string &client_auth_token); + client(std::string &client_auth_token, server_session *sess = nullptr); + void add_event_subscription(event_subscription_base* e); virtual ~client(); protected: private: //TODO: client subscriptions should be stored here //TODO: list of timers with direct callbacks to functions for periodic subscription (bost::asio::deadline_timer) //TODO: store sessions ptr list + //TODO: some way to call core and mopdules api from here std::string auth_token; + server_session *session; + std::list<event_subscription_base*> subscriptions; }; #endif // CLIENT_H diff --git a/server/include/event_subscription_base.h b/server/include/event_subscription_base.h new file mode 100644 index 0000000..19b184f --- /dev/null +++ b/server/include/event_subscription_base.h @@ -0,0 +1,42 @@ +/* + Copyright © 2015 Gluzskiy Alexandr (sss) + + This file is part of Unknown Download Manager (UDM). + + UDM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + UDM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UDM. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef EVENT_SUBSCRIPTION_H +#define EVENT_SUBSCRIPTION_H + +#include "../../protocol/udm.pb.h" + +//TODO: rework (events and polls separated ?) + +enum EVENT_SUBTYPE { + EVENT_SUBTYPE_REPEATED = 0, //periodic firing based on timer + EVENT_SUBTYPE_EVENT = 1, //fired on event occurs (only can be used for data which support this event type) +}; + +class event_subscription_base +{ +public: + event_subscription_base(){}; + virtual ~event_subscription_base(){}; +protected: + SUBSCRIPTION_TYPE type = SUBSCRIPTION_TYPE::S_DOWNLOAD_STATE_CHANGE; + EVENT_SUBTYPE subtype = EVENT_SUBTYPE::EVENT_SUBTYPE_EVENT; +}; +#endif // EVENT_SUBSCRIPTION_H diff --git a/server/include/event_subscription_event.h b/server/include/event_subscription_event.h new file mode 100644 index 0000000..16172cf --- /dev/null +++ b/server/include/event_subscription_event.h @@ -0,0 +1,35 @@ +/* + Copyright © 2015 Gluzskiy Alexandr (sss) + + This file is part of Unknown Download Manager (UDM). + + UDM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + UDM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UDM. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#ifndef EVENT_SUBSCRIPTION_EVENT_H +#define EVENT_SUBSCRIPTION_EVENT_H + +#include "event_subscription_base.h" + +class event_subscription_event : public event_subscription_base +{ +public: + event_subscription_event(client_event_subscription_request *req); + ~event_subscription_event(); + +}; + +#endif // EVENT_SUBSCRIPTION_EVENT_H diff --git a/server/include/event_subscription_repeated.h b/server/include/event_subscription_repeated.h new file mode 100644 index 0000000..bb676a3 --- /dev/null +++ b/server/include/event_subscription_repeated.h @@ -0,0 +1,38 @@ +/* + Copyright © 2015 Gluzskiy Alexandr (sss) + + This file is part of Unknown Download Manager (UDM). + + UDM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + UDM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UDM. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#ifndef EVENT_SUBSCRIPTION_PERIODIC_H +#define EVENT_SUBSCRIPTION_PERIODIC_H + +#include "event_subscription_base.h" + +class event_subscription_repeated : public event_subscription_base +{ +public: + event_subscription_repeated(client_event_subscription_request *req); + ~event_subscription_repeated(); +private: + bool one_time; + int64_t interval; + +}; + +#endif // EVENT_SUBSCRIPTION_PERIODIC_H |