2024-03-24 07:50:30 +01:00
|
|
|
#include "PluginContainer.h"
|
2024-11-27 20:44:20 +01:00
|
|
|
#include "utils/storage/StorageUtils.h"
|
2024-11-27 20:44:36 +01:00
|
|
|
|
2024-08-04 14:12:52 +02:00
|
|
|
PluginContainer::PluginContainer(PluginMetaInformation metaInformation, PluginLinkInformation pluginLinkInformation, std::shared_ptr<PluginData> pluginData)
|
2024-03-24 07:50:30 +01:00
|
|
|
: mMetaInformation(std::move(metaInformation)),
|
2024-08-03 17:23:27 +02:00
|
|
|
mPluginLinkInformation(std::move(pluginLinkInformation)),
|
2024-03-24 07:50:30 +01:00
|
|
|
mPluginData(std::move(pluginData)) {
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
|
|
|
|
PluginContainer::PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)),
|
|
|
|
mPluginLinkInformation(std::move(src.mPluginLinkInformation)),
|
|
|
|
mPluginData(std::move(src.mPluginData)),
|
|
|
|
mPluginConfigData(std::move(src.mPluginConfigData)),
|
|
|
|
mStorageRootItem(src.mStorageRootItem),
|
|
|
|
mInitDone(src.mInitDone)
|
2024-03-24 07:50:30 +01:00
|
|
|
|
|
|
|
{
|
2024-11-27 20:44:20 +01:00
|
|
|
src.mStorageRootItem = {};
|
|
|
|
src.mInitDone = {};
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
PluginContainer &PluginContainer::operator=(PluginContainer &&src) noexcept {
|
2024-03-24 07:50:30 +01:00
|
|
|
if (this != &src) {
|
2024-08-03 17:23:27 +02:00
|
|
|
this->mMetaInformation = std::move(src.mMetaInformation);
|
|
|
|
this->mPluginLinkInformation = std::move(src.mPluginLinkInformation);
|
|
|
|
this->mPluginData = std::move(src.mPluginData);
|
|
|
|
this->mPluginConfigData = std::move(src.mPluginConfigData);
|
|
|
|
this->mStorageRootItem = src.mStorageRootItem;
|
|
|
|
this->mInitDone = src.mInitDone;
|
2024-03-24 07:50:30 +01:00
|
|
|
|
2024-11-27 20:44:20 +01:00
|
|
|
src.mStorageRootItem = nullptr;
|
|
|
|
src.mInitDone = false;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginMetaInformation &PluginContainer::getMetaInformation() const {
|
|
|
|
return this->mMetaInformation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-04 14:12:52 +02:00
|
|
|
const PluginLinkInformation &PluginContainer::getPluginLinkInformation() const {
|
|
|
|
return this->mPluginLinkInformation;
|
2024-08-03 17:23:27 +02:00
|
|
|
}
|
|
|
|
|
2024-08-04 14:12:52 +02:00
|
|
|
PluginLinkInformation &PluginContainer::getPluginLinkInformation() {
|
|
|
|
return this->mPluginLinkInformation;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<PluginData> PluginContainer::getPluginDataCopy() const {
|
|
|
|
return mPluginData;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PluginContainer::getHandle() const {
|
2024-11-27 20:44:20 +01:00
|
|
|
return reinterpret_cast<uint32_t>(this);
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::optional<PluginConfigData> &PluginContainer::getConfigData() const {
|
|
|
|
return mPluginConfigData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginContainer::setConfigData(const PluginConfigData &pluginConfigData) {
|
|
|
|
mPluginConfigData = pluginConfigData;
|
|
|
|
}
|
|
|
|
|
2024-08-04 14:12:52 +02:00
|
|
|
bool PluginContainer::isLinkedAndLoaded() const {
|
|
|
|
return mPluginLinkInformation.hasValidData();
|
|
|
|
}
|
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
WUPSStorageError PluginContainer::OpenStorage() {
|
|
|
|
if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) {
|
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
auto &storageId = getMetaInformation().getStorageId();
|
|
|
|
if (storageId.empty()) {
|
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
2024-11-27 20:44:20 +01:00
|
|
|
auto res = StorageUtils::API::Internal::OpenStorage(storageId, mStorageRootItem);
|
2024-03-24 07:50:30 +01:00
|
|
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) {
|
2024-11-27 20:44:20 +01:00
|
|
|
mStorageRootItem = nullptr;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
WUPSStorageError PluginContainer::CloseStorage() {
|
|
|
|
if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) {
|
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
2024-11-27 20:44:20 +01:00
|
|
|
if (mStorageRootItem == nullptr) {
|
2024-03-24 07:50:30 +01:00
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
2024-11-27 20:44:20 +01:00
|
|
|
return StorageUtils::API::Internal::CloseStorage(mStorageRootItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
wups_storage_root_item PluginContainer::getStorageRootItem() const {
|
|
|
|
return mStorageRootItem;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
2024-11-27 20:44:20 +01:00
|
|
|
|
|
|
|
void PluginContainer::setInitDone(const bool val) {
|
|
|
|
mInitDone = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginContainer::isInitDone() const {
|
|
|
|
return mInitDone;
|
|
|
|
}
|