diff options
-rw-r--r-- | server/include/api_module_base.h | 6 | ||||
-rw-r--r-- | server/include/api_module_metadata_storage.h | 7 | ||||
-rw-r--r-- | server/modules/metadata/flat_files/flat_files.cbp | 4 | ||||
-rw-r--r-- | server/modules/metadata/flat_files/main.cpp | 39 | ||||
-rw-r--r-- | server/modules/metadata/flat_files/main.h | 15 | ||||
-rw-r--r-- | server/src/api_core.cpp | 41 | ||||
-rw-r--r-- | server/src/main.cpp | 27 | ||||
-rw-r--r-- | server/udm-server.cbp | 2 |
8 files changed, 131 insertions, 10 deletions
diff --git a/server/include/api_module_base.h b/server/include/api_module_base.h index a16c38c..27797bc 100644 --- a/server/include/api_module_base.h +++ b/server/include/api_module_base.h @@ -31,9 +31,9 @@ struct module_info class module_base { public: - virtual void load(core_api *a); - virtual const module_info &get_module_info(); - virtual ~module_base(); + virtual void load(core_api *a) = 0; + virtual const module_info &get_module_info() = 0; + virtual ~module_base() =0; }; diff --git a/server/include/api_module_metadata_storage.h b/server/include/api_module_metadata_storage.h index 59dd92c..329a3cf 100644 --- a/server/include/api_module_metadata_storage.h +++ b/server/include/api_module_metadata_storage.h @@ -25,9 +25,10 @@ class module_metadata_storage : public module_base { - virtual bool set(const std::string &module_name, const std::string &setting_name, const std::vector<char> &data); - virtual bool get(const std::string &module_name, const std::string &setting_name, std::vector<char> &data); - virtual bool remove(const std::string &module_name, const std::string &setting_name); + public: + virtual bool set(const std::string &module_name, const std::string &setting_name, const std::vector<char> &data) = 0; + virtual bool get(const std::string &module_name, const std::string &setting_name, std::vector<char> &data) = 0; + virtual bool remove(const std::string &module_name, const std::string &setting_name) = 0; }; diff --git a/server/modules/metadata/flat_files/flat_files.cbp b/server/modules/metadata/flat_files/flat_files.cbp index dad2ece..e297909 100644 --- a/server/modules/metadata/flat_files/flat_files.cbp +++ b/server/modules/metadata/flat_files/flat_files.cbp @@ -7,7 +7,7 @@ <Option compiler="gcc" /> <Build> <Target title="Debug"> - <Option output="bin/Debug/flat_files" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> + <Option output="../../../bin/Debug/modules/metadata/flat_files" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> <Option object_output="obj/Debug/" /> <Option type="3" /> <Option compiler="gcc" /> @@ -18,7 +18,7 @@ </Compiler> </Target> <Target title="Release"> - <Option output="bin/Release/flat_files" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> + <Option output="../../../bin/Release/modules/metadata/flat_files" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> <Option object_output="obj/Release/" /> <Option type="3" /> <Option compiler="gcc" /> diff --git a/server/modules/metadata/flat_files/main.cpp b/server/modules/metadata/flat_files/main.cpp index 6696a76..3015cd5 100644 --- a/server/modules/metadata/flat_files/main.cpp +++ b/server/modules/metadata/flat_files/main.cpp @@ -21,15 +21,52 @@ #include "main.h" +#include <iostream> -core_api *api = nullptr; void storage_impl::load(core_api *a) { api = a; + std::cout<<"flat_files metadata module succesfully loaded\n"; + //TODO: set module_info } + +const module_info &storage_impl::get_module_info() +{ + return info; +} + + +bool storage_impl::set(const std::string &module_name, const std::string &setting_name, const std::vector<char> &data) +{ + //TODO + return true; +} + +bool storage_impl::get(const std::string &module_name, const std::string &setting_name, std::vector<char> &data) +{ + //TODO + return true; +} + +bool storage_impl::remove(const std::string &module_name, const std::string &setting_name) +{ + //TODO + return true; +} + +storage_impl::storage_impl() +{ +} + +module_base::~module_base() +{ +} + + extern "C" void* load() { return new storage_impl; } + diff --git a/server/modules/metadata/flat_files/main.h b/server/modules/metadata/flat_files/main.h index bdcf9e0..706e21d 100644 --- a/server/modules/metadata/flat_files/main.h +++ b/server/modules/metadata/flat_files/main.h @@ -28,7 +28,20 @@ class storage_impl: public module_metadata_storage { - void load(core_api *a); + public: + storage_impl(); + //module base + void load(core_api *a); + const module_info &get_module_info(); + //metadata module + bool set(const std::string &module_name, const std::string &setting_name, const std::vector<char> &data); + bool get(const std::string &module_name, const std::string &setting_name, std::vector<char> &data); + bool remove(const std::string &module_name, const std::string &setting_name); + + private: + module_info info; + core_api *api = nullptr; + }; diff --git a/server/src/api_core.cpp b/server/src/api_core.cpp new file mode 100644 index 0000000..5412624 --- /dev/null +++ b/server/src/api_core.cpp @@ -0,0 +1,41 @@ + +/* + 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 <api_core.h> + + +bool core_api::metadata_set(const module_base *m, const std::string &setting_name, const std::vector<char> &data) +{ + //TODO + return true; +} + +bool core_api::metadata_get(const module_base *m, const std::string &setting_name, std::vector<char> &data) +{ + //TODO + return true; +} + +bool core_api::metadata_remove(const module_base *m, const std::string &setting_name) +{ + //TODO + return true; +} diff --git a/server/src/main.cpp b/server/src/main.cpp index 61a2474..54bb498 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -18,8 +18,35 @@ */ +#include <dlfcn.h> +#include <api_module_metadata_storage.h> + +core_api module_api; + +void module_load_test() +{ + void *lib = dlopen("./modules/metadata/libflat_files.so", RTLD_LAZY); + if(!lib) + { + printf("%s\n", dlerror()); + return; + } + void *fptr = dlsym(lib, "load"); + if(!fptr) + { + printf("%s\n", dlerror()); + dlclose(lib); + return; + } + void *(*f)(void); + f = (void* (*)())fptr; + module_metadata_storage *m = static_cast<module_metadata_storage*>(f()); + m->load(&module_api); +} + int main(int argc, char *argv[]) { + module_load_test(); return 0; } diff --git a/server/udm-server.cbp b/server/udm-server.cbp index ee60bf0..613d1e9 100644 --- a/server/udm-server.cbp +++ b/server/udm-server.cbp @@ -35,6 +35,7 @@ </Compiler> <Linker> <Add library="protobuf" /> + <Add library="dl" /> </Linker> <ExtraCommands> <Add before="[ -d ../protocol ] || mkdir ../protocol" /> @@ -47,6 +48,7 @@ <Unit filename="include/api_module_downloader.h" /> <Unit filename="include/api_module_metadata_storage.h" /> <Unit filename="include/protocol.h" /> + <Unit filename="src/api_core.cpp" /> <Unit filename="src/main.cpp" /> <Unit filename="src/protocol.cpp" /> <Extensions> |