From b3cc46ee0ffe7bd1a45fe26cdd586d98c0bf8620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Fri, 28 Jun 2019 14:39:37 +0200 Subject: [PATCH] Add stub DiscoveryManager --- gui/CMakeLists.txt | 4 +++- gui/include/discoverymanager.h | 38 ++++++++++++++++++++++++++++++++++ gui/src/discoverymanager.cpp | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 gui/include/discoverymanager.h create mode 100644 gui/src/discoverymanager.cpp diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index a58c9e5..fa0e2ff 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -20,7 +20,9 @@ add_executable(chiaki include/dynamicgridwidget.h src/dynamicgridwidget.cpp include/serveritemwidget.h - src/serveritemwidget.cpp) + src/serveritemwidget.cpp + include/discoverymanager.h + src/discoverymanager.cpp) target_include_directories(chiaki PRIVATE include) target_link_libraries(chiaki chiaki-lib) diff --git a/gui/include/discoverymanager.h b/gui/include/discoverymanager.h new file mode 100644 index 0000000..5147899 --- /dev/null +++ b/gui/include/discoverymanager.h @@ -0,0 +1,38 @@ +/* + * This file is part of Chiaki. + * + * Chiaki 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 3 of the License, or + * (at your option) any later version. + * + * Chiaki 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 Chiaki. If not, see . + */ + +#ifndef CHIAKI_DISCOVERYMANAGER_H +#define CHIAKI_DISCOVERYMANAGER_H + +#include + +#include + +class DiscoveryManager : public QObject +{ + Q_OBJECT + + private: + ChiakiDiscoveryService service; + + public: + explicit DiscoveryManager(QObject *parent = nullptr); + ~DiscoveryManager(); + +}; + +#endif //CHIAKI_DISCOVERYMANAGER_H diff --git a/gui/src/discoverymanager.cpp b/gui/src/discoverymanager.cpp new file mode 100644 index 0000000..836d4a5 --- /dev/null +++ b/gui/src/discoverymanager.cpp @@ -0,0 +1,37 @@ +/* + * This file is part of Chiaki. + * + * Chiaki 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 3 of the License, or + * (at your option) any later version. + * + * Chiaki 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 Chiaki. If not, see . + */ + +#include + +DiscoveryManager::DiscoveryManager(QObject *parent) : QObject(parent) +{ + ChiakiDiscoveryServiceOptions options; + options.ping_ms = 500; + options.servers_max = 16; + + options.send_addr = nullptr; // TODO + options.send_addr_size = 0; // TODO + + ChiakiErrorCode err = chiaki_discovery_service_init(&service, &options, nullptr /* TODO */); + if(err != CHIAKI_ERR_SUCCESS) + throw std::exception(); +} + +DiscoveryManager::~DiscoveryManager() +{ + chiaki_discovery_service_fini(&service); +}