WUPS 0.6.1 support

This commit is contained in:
Maschell
2021-10-01 17:25:48 +02:00
parent aa90e2478b
commit fe2e7d6fa9
9 changed files with 48 additions and 24 deletions

View File

@@ -55,10 +55,10 @@ 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.");
if (pluginMetaInfo.getStorageId().length() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
DEBUG_FUNCTION_LINE("Warning: plugin storage id will be truncated.");
}
strncpy(plugin_meta_data->id, pluginMetaInfo.getId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
strncpy(plugin_meta_data->storageId, pluginMetaInfo.getStorageId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
plugin_meta_data->size = pluginMetaInfo.getSize();
@@ -202,6 +202,7 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
metaInformation.setDescription(meta->descripion);
metaInformation.setSize(meta->size);
metaInformation.setName(meta->name);
metaInformation.setStorageId(meta->storageId);
plugin_data_t *data = &(plugin_data->data);
@@ -237,6 +238,18 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
curPluginInformation.addHookData(curHook);
}
bool storageHasId = true;
for(auto const &value : curPluginInformation.getHookDataList()){
if(value.getType() == WUPS_LOADER_HOOK_INIT_STORAGE &&
metaInformation.getStorageId().empty()){
storageHasId = false;
}
}
if(!storageHasId){
DEBUG_FUNCTION_LINE("Plugin is using the storage API but has not set an ID");
continue;
}
/* load function replacement data */
uint32_t functionReplaceCount = plugin_data->info.number_used_functions;

View File

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

View File

@@ -48,8 +48,8 @@ public:
return this->description;
}
[[nodiscard]] const std::string &getId() const {
return this->id;
[[nodiscard]] const std::string &getStorageId() const {
return this->storageId;
}
[[nodiscard]] size_t getSize() const {
@@ -87,8 +87,8 @@ private:
this->size = _size;
}
void setId(const std::string &_id) {
this->id = _id;
void setStorageId(const std::string &_storageId) {
this->storageId = _storageId;
}
std::string name;
@@ -97,7 +97,7 @@ private:
std::string license;
std::string buildtimestamp;
std::string description;
std::string id;
std::string storageId;
size_t size{};
friend class PluginMetaInformationFactory;

View File

@@ -110,10 +110,10 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
pluginInfo.setBuildTimestamp(value);
} else if (key == "description") {
pluginInfo.setDescription(value);
} else if (key == "id") {
pluginInfo.setId(value);
} else if (key == "storage_id") {
pluginInfo.setStorageId(value);
} else if (key == "wups") {
if (value != "0.6") {
if (value != "0.6.1") {
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return std::nullopt;
}