Add support for the config and storage API. Bump version to 0.6

This commit is contained in:
Maschell
2021-04-07 00:23:23 +02:00
parent ed792716fe
commit 13ed348f43
34 changed files with 28162 additions and 98 deletions

View File

@@ -48,7 +48,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
strncpy(plugin_meta_data->license, pluginMetaInfo.getLicense().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
if (pluginMetaInfo.getBuildTimestamp().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
DEBUG_FUNCTION_LINE("Warning: build timestampt will be truncated.");
DEBUG_FUNCTION_LINE("Warning: build timestamp will be truncated.");
}
strncpy(plugin_meta_data->buildTimestamp, pluginMetaInfo.getBuildTimestamp().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
@@ -58,6 +58,11 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
}
strncpy(plugin_meta_data->descripion, pluginMetaInfo.getDescription().c_str(), MAXIMUM_PLUGIN_DESCRIPTION_LENGTH - 1);
if (pluginMetaInfo.getId().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
DEBUG_FUNCTION_LINE("Warning: plugin id will be truncated.");
}
strncpy(plugin_meta_data->id, pluginMetaInfo.getId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
plugin_meta_data->size = pluginMetaInfo.getSize();
auto pluginInfo = plugin.getPluginInformation();

View File

@@ -8,4 +8,5 @@ PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other)
this->buildtimestamp = other.buildtimestamp;
this->description = other.description;
this->size = other.size;
this->id = other.id;
}

View File

@@ -52,6 +52,10 @@ public:
return this->size;
}
[[nodiscard]] const std::string getId() const {
return this->id;
}
private:
PluginMetaInformation() = default;
@@ -83,12 +87,17 @@ private:
this->size = _size;
}
void setId(const std::string &id) {
this->id = id;
}
std::string name;
std::string author;
std::string version;
std::string license;
std::string buildtimestamp;
std::string description;
std::string id;
size_t size{};
friend class PluginMetaInformationFactory;

View File

@@ -81,7 +81,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
}
// Get meta information and check WUPS version:
if (psec->get_name().compare(".wups.meta") == 0) {
if (psec->get_name() == ".wups.meta") {
const void *sectionData = psec->get_data();
uint32_t sectionSize = psec->get_size();
@@ -92,7 +92,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
continue;
}
auto firstFound = std::string(curEntry).find_first_of("=");
auto firstFound = std::string(curEntry).find_first_of('=');
if (firstFound != std::string::npos) {
curEntry[firstFound] = '\0';
std::string key(curEntry);
@@ -110,8 +110,10 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
pluginInfo.setBuildTimestamp(value);
} else if (key.compare("description") == 0) {
pluginInfo.setDescription(value);
} else if (key.compare("id") == 0) {
pluginInfo.setId(value);
} else if (key.compare("wups") == 0) {
if (value.compare("0.5") != 0) {
if (value.compare("0.6") != 0) {
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return std::nullopt;
}