diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/client.cpp | 27 | ||||
-rw-r--r-- | server/src/event_subscription_event.cpp | 32 | ||||
-rw-r--r-- | server/src/event_subscription_repeated.cpp | 32 | ||||
-rw-r--r-- | server/src/server_session.cpp | 42 |
4 files changed, 130 insertions, 3 deletions
diff --git a/server/src/client.cpp b/server/src/client.cpp index 858b230..0990317 100644 --- a/server/src/client.cpp +++ b/server/src/client.cpp @@ -1,10 +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/>. + +*/ + #include "client.h" +#include "server_session.h" -client::client(std::string &client_auth_token) : auth_token(client_auth_token) +client::client(std::string &client_auth_token, server_session *sess) : auth_token(client_auth_token), session(sess) { //ctor } +void client::add_event_subscription(event_subscription_base* e) +{ +} + client::~client() { //dtor diff --git a/server/src/event_subscription_event.cpp b/server/src/event_subscription_event.cpp new file mode 100644 index 0000000..10ca824 --- /dev/null +++ b/server/src/event_subscription_event.cpp @@ -0,0 +1,32 @@ +/* + 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/>. + +*/ + + +#include "event_subscription_event.h" + +event_subscription_event::event_subscription_event(client_event_subscription_request *req) +{ + subtype = EVENT_SUBTYPE_EVENT; +} + +event_subscription_event::~event_subscription_event() +{ +} + diff --git a/server/src/event_subscription_repeated.cpp b/server/src/event_subscription_repeated.cpp new file mode 100644 index 0000000..13e0165 --- /dev/null +++ b/server/src/event_subscription_repeated.cpp @@ -0,0 +1,32 @@ +/* + 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/>. + +*/ + + +#include "event_subscription_repeated.h" + +event_subscription_repeated::event_subscription_repeated(client_event_subscription_request *req) +{ + subtype = EVENT_SUBTYPE_REPEATED; +} + +event_subscription_repeated::~event_subscription_repeated() +{ +} + diff --git a/server/src/server_session.cpp b/server/src/server_session.cpp index 43d8837..113a756 100644 --- a/server/src/server_session.cpp +++ b/server/src/server_session.cpp @@ -27,6 +27,8 @@ #include "socket_wraper.h" #include "client.h" #include "modules_handler.h" +#include "event_subscription_event.h" +#include "event_subscription_repeated.h" extern std::map<std::string, client> clients; extern modules_handler *modules; @@ -280,7 +282,6 @@ bool server_session::handle_command(client_msg *msg) { server_msg m; m.set_type(SERVER_MSG_TYPE::SERVER_AUTH_REPLY); - //TODO: check for already existing auth token std::string server_password = runtime_config.config_file.get<std::string>("server.password", ""); if(server_password.empty()) m.mutable_auth_reply()->set_status(true); @@ -470,6 +471,7 @@ bool server_session::handle_command(client_msg *msg) d->set_module_name(msg->download_add_request().module_name()); d->set_downloaded(dl.downloaded); send_message(&m); + //TODO: fire event break; } } @@ -488,6 +490,10 @@ bool server_session::handle_command(client_msg *msg) { //TODO: handle error } + else + { + //TODO: fire event + } break; } } @@ -507,6 +513,10 @@ bool server_session::handle_command(client_msg *msg) { //TODO: handle error } + else + { + //TODO: fire event + } break; } } @@ -522,16 +532,44 @@ bool server_session::handle_command(client_msg *msg) if(m->get_module_info().name == downloads[i.download_id()].module_name) { auto dm = static_cast<module_downloader *>(m); - if(!dm->delete_download(i.download_id(), i.with_data())); + if(!dm->delete_download(i.download_id(), i.with_data())) { //TODO: handle error } + else + { + //TODO: fire event + } break; } } } } break; + case CLIENT_MSG_TYPE::CLIENT_SUBSCRIPTION_REQUEST: + { + for(auto i : msg->subscription_request()) + { + switch(i.mode()) + { + case SUBSCRIPTION_MODE::S_MODE_EVENT: + { + event_subscription_event *e = new event_subscription_event(&i); + client_->add_event_subscription(e); + } + break; + case SUBSCRIPTION_MODE::S_MODE_REPEATED: + { + event_subscription_repeated *e = new event_subscription_repeated(&i); + client_->add_event_subscription(e); + } + break; + default: + break; + } + } + } + break; default: return false; break; |