diff --git a/include/wups_backend/PluginMetaInformation.h b/include/wups_backend/PluginMetaInformation.h index 62da9ba..984df76 100644 --- a/include/wups_backend/PluginMetaInformation.h +++ b/include/wups_backend/PluginMetaInformation.h @@ -47,8 +47,8 @@ public: return this->description; } - [[nodiscard]] const std::string &getId() const { - return this->description; + [[nodiscard]] const std::string &getStorageId() const { + return this->storageId; } [[nodiscard]] size_t getSize() const { @@ -61,7 +61,7 @@ public: const std::string& license, const std::string& buildtimestamp, const std::string& description, - const std::string& id, + const std::string& storageId, size_t size); private: @@ -91,8 +91,8 @@ private: this->description = description_; } - void setId(const std::string &id_) { - this->id = id_; + void setStorageId(const std::string &storageId_) { + this->storageId = storageId_; } void setSize(size_t size_) { @@ -105,6 +105,6 @@ private: std::string license; std::string buildtimestamp; std::string description; - std::string id; + std::string storageId; size_t size{}; }; diff --git a/include/wups_backend/import_defines.h b/include/wups_backend/import_defines.h index 077ded2..aeeb0c8 100644 --- a/include/wups_backend/import_defines.h +++ b/include/wups_backend/import_defines.h @@ -18,22 +18,25 @@ #pragma once typedef enum GetPluginInformationInputType { - PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0, - PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1, + PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0, + PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1, } GetPluginInformationInputType; typedef uint32_t plugin_container_handle; typedef uint32_t plugin_data_handle; +#define PLUGIN_INFORMATION_VERSION 0x00000001 + /* plugin_information message */ typedef struct __attribute__((__packed__)) plugin_information { - char id[256]; + uint32_t plugin_information_version; char name[256]; char author[256]; char buildTimestamp[256]; char description[256]; char license[256]; char version[256]; + char storageId[256]; size_t size; } plugin_information; diff --git a/source/PluginMetaInformation.cpp b/source/PluginMetaInformation.cpp index 8956218..977319c 100644 --- a/source/PluginMetaInformation.cpp +++ b/source/PluginMetaInformation.cpp @@ -27,7 +27,7 @@ PluginMetaInformation::PluginMetaInformation(const std::string& name_, const std::string& license_, const std::string& buildtimestamp_, const std::string& description_, - const std::string& id_, + const std::string& storageId_, size_t size_) { this->name = name_; this->author = author_; @@ -36,5 +36,5 @@ PluginMetaInformation::PluginMetaInformation(const std::string& name_, this->description = description_; this->license = license_; this->version = version_; - this->id = id_; + this->storageId = storageId_; } diff --git a/source/PluginUtils.cpp b/source/PluginUtils.cpp index e037f8e..b745656 100644 --- a/source/PluginUtils.cpp +++ b/source/PluginUtils.cpp @@ -28,13 +28,17 @@ std::optional PluginUtils::getMetaInformationForBuffer(ch return std::nullopt; } + if (info.plugin_information_version != PLUGIN_INFORMATION_VERSION) { + return std::nullopt; + } + PluginMetaInformation metaInfo(info.name, info.author, info.version, info.license, info.buildTimestamp, info.description, - info.id, + info.storageId, info.size); return metaInfo; @@ -47,13 +51,16 @@ std::optional PluginUtils::getMetaInformationForPath(cons // DEBUG_FUNCTION_LINE("Failed to load meta infos for %s\n", path.c_str()); return std::nullopt; } + if (info.plugin_information_version != PLUGIN_INFORMATION_VERSION) { + return std::nullopt; + } PluginMetaInformation metaInfo(info.name, info.author, info.version, info.license, info.buildTimestamp, info.description, - info.id, + info.storageId, info.size); return metaInfo; } @@ -100,12 +107,14 @@ std::vector PluginUtils::getLoadedPlugins(uint32_t maxSize) { handles[i] = 0xFFFFFFFF; } - if (WUPSGetLoadedPlugins(handles, maxSize, &realSize) != PLUGIN_BACKEND_API_ERROR_NONE) { + uint32_t plugin_information_version = 0; + + if (WUPSGetLoadedPlugins(handles, maxSize, &realSize, &plugin_information_version) != PLUGIN_BACKEND_API_ERROR_NONE) { free(handles); // DEBUG_FUNCTION_LINE("Failed"); return result; } - if (realSize == 0) { + if (realSize == 0 || plugin_information_version != PLUGIN_INFORMATION_VERSION) { free(handles); // DEBUG_FUNCTION_LINE("realsize is 0"); return result; @@ -139,13 +148,16 @@ std::vector PluginUtils::getLoadedPlugins(uint32_t maxSize) { } for (uint32_t i = 0; i < realSize; i++) { + if (information[i].plugin_information_version != PLUGIN_INFORMATION_VERSION) { + continue; + } PluginMetaInformation metaInfo(information[i].name, information[i].author, information[i].version, information[i].license, information[i].buildTimestamp, information[i].description, - information[i].id, + information[i].storageId, information[i].size); PluginData pluginData((uint32_t) dataHandles[i]); result.emplace_back(pluginData, metaInfo, handles[i]); diff --git a/source/imports.h b/source/imports.h index 9870906..1b32c9e 100644 --- a/source/imports.h +++ b/source/imports.h @@ -45,7 +45,7 @@ extern PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const plug extern PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size); -extern PluginBackendApiErrorType WUPSGetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize); +extern PluginBackendApiErrorType WUPSGetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version); #ifdef __cplusplus }