summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/api_core.cpp35
-rw-r--r--server/src/modules_handler.cpp16
2 files changed, 37 insertions, 14 deletions
diff --git a/server/src/api_core.cpp b/server/src/api_core.cpp
index 66df614..b407928 100644
--- a/server/src/api_core.cpp
+++ b/server/src/api_core.cpp
@@ -30,7 +30,6 @@ extern runtime_config_s runtime_config;
bool core_api::metadata_set(module_base *m, const std::string &setting_name, const std::vector<char> &data)
{
- //TODO: respect per module metadata modules definition
//print data
/* std::cout<<"printing data in core set api:\n";
for(auto i = data.begin(), end = data.end(); i != end; ++i)
@@ -44,27 +43,51 @@ bool core_api::metadata_set(module_base *m, const std::string &setting_name, con
bool core_api::metadata_get(module_base *m, const std::string &setting_name, std::vector<char> &data)
{
- //TODO
runtime_config.default_metadata_storage->get(m->get_module_info().name, setting_name, data);
return true;
}
bool core_api::metadata_remove(module_base *m, const std::string &setting_name)
{
- //TODO
runtime_config.default_metadata_storage->remove(m->get_module_info().name, setting_name);
return true;
}
std::map<std::string, std::string> core_api::get_module_settings(module_base *m)
{
- //TODO:
std::map<std::string, std::string> settings;
std::string module = "modules.";
module += m->get_module_info().name;
- for(auto i = runtime_config.config_file.get_child(module).begin(), end = runtime_config.config_file.get_child(module).end(); i != end; ++i)
+ try{
+ for(auto i : runtime_config.config_file.get_child(module))
{
- settings[i->first] = i->second.get_value<std::string>("");
+ settings[i.first] = i.second.get_value<std::string>("");
+ }
+ }
+ catch(...)
+ {
+ //TODO:
}
return settings;
}
+
+
+std::map<std::string, std::string> core_api::get_core_settings()
+{
+ std::map<std::string, std::string> settings_;
+ try{
+ for(auto it : runtime_config.config_file.get_child("server")) //load server node
+ {
+ std::string val = it.second.get_value<std::string>("empty_value"); //TODO: something better here. we need to avoid subtrees and empty vars
+ if(val == "" || val == "empty_value")
+ continue;
+
+ settings_[it.first] = it.second.get_value<std::string>("");
+ }
+ }
+ catch(...)
+ {
+ //TODO:
+ }
+ return settings_;
+}
diff --git a/server/src/modules_handler.cpp b/server/src/modules_handler.cpp
index 65148ef..78a6ad7 100644
--- a/server/src/modules_handler.cpp
+++ b/server/src/modules_handler.cpp
@@ -49,7 +49,7 @@ void modules_handler::load_metadata_modules(const std::string &path)
if(!lib)
{
printf("failed to open library \"%s\" with error: %s\n", i->path().c_str(), dlerror());
- return;
+ continue;
}
void *fptr = dlsym(lib, "udm_metadata_module_load");
@@ -57,7 +57,7 @@ void modules_handler::load_metadata_modules(const std::string &path)
{
printf("failed to find symbol \"udm_metadata_module_load\" in library %s with error %s\n", i->path().c_str(), dlerror());
dlclose(lib);
- return;
+ continue;
}
module_metadata_storage *(*f)(void);
f = (module_metadata_storage *(*)(void))fptr;
@@ -76,18 +76,18 @@ void modules_handler::load_downloader_modules(const std::string &path)
{
for(boost::filesystem::directory_iterator i(path), end = boost::filesystem::directory_iterator(); i != end; ++i)
{
- void *lib = dlopen(i->path().generic_string().c_str(), RTLD_LAZY);
+ void *lib = dlopen(i->path().generic_string().c_str(), RTLD_LAZY |RTLD_GLOBAL);
if(!lib)
{
printf("failed to open library \"%s\" with error: %s\n", i->path().c_str(), dlerror());
- return;
+ continue;
}
void *fptr = dlsym(lib, "udm_downloader_module_load");
if(!fptr)
{
printf("failed to find symbol \"udm_downloader_module_load\" in library %s with error %s\n", i->path().c_str(), dlerror());
dlclose(lib);
- return;
+ continue;
}
module_downloader *(*f)(void);
f = (module_downloader *(*)(void))fptr;
@@ -169,9 +169,9 @@ void modules_handler::load_modules()
load_metadata_modules(self_dir + "/modules/metadata");
load_metadata_modules(replace_home_var("~/.share/udm/modules/metadata"));
load_metadata_modules("/usr/lib/udm/modules/metadata");
- load_downloader_modules(self_dir + "/modules/downloader");
- load_downloader_modules(replace_home_var("~/.share/udm/modules/downloader"));
- load_downloader_modules("/usr/lib/udm/modules/downloader");
+ load_downloader_modules(self_dir + "/modules/downloaders");
+ load_downloader_modules(replace_home_var("~/.share/udm/modules/downloaders"));
+ load_downloader_modules("/usr/lib/udm/modules/downloaders");
load_modules_settings();
}