2024-03-24 07:50:30 +01:00
|
|
|
#include "PluginContainer.h"
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginContainer::PluginContainer(PluginMetaInformation metaInformation, std::optional<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)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginContainer::PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)),
|
2024-08-03 17:23:27 +02:00
|
|
|
mPluginLinkInformation(std::move(src.mPluginLinkInformation)),
|
2024-03-24 07:50:30 +01:00
|
|
|
mPluginData(std::move(src.mPluginData)),
|
|
|
|
mPluginConfigData(std::move(src.mPluginConfigData)),
|
|
|
|
storageRootItem(src.storageRootItem)
|
|
|
|
|
|
|
|
{
|
|
|
|
src.storageRootItem = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginContainer &PluginContainer::operator=(PluginContainer &&src) {
|
|
|
|
if (this != &src) {
|
2024-08-03 17:23:27 +02:00
|
|
|
this->mMetaInformation = src.mMetaInformation;
|
|
|
|
this->mPluginLinkInformation = std::move(src.mPluginLinkInformation);
|
|
|
|
this->mPluginData = std::move(src.mPluginData);
|
|
|
|
this->mPluginConfigData = std::move(src.mPluginConfigData);
|
|
|
|
this->storageRootItem = src.storageRootItem;
|
2024-03-24 07:50:30 +01:00
|
|
|
|
2024-03-30 08:44:14 +01:00
|
|
|
src.storageRootItem = nullptr;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginMetaInformation &PluginContainer::getMetaInformation() const {
|
|
|
|
return this->mMetaInformation;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
bool PluginContainer::isPluginLinkedAndLoaded() const {
|
|
|
|
return this->mPluginLinkInformation.has_value();
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const PluginLinkInformation *PluginContainer::getPluginLinkInformation() const {
|
|
|
|
if (this->mPluginLinkInformation.has_value()) {
|
|
|
|
return this->mPluginLinkInformation.operator->();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginLinkInformation *PluginContainer::getPluginLinkInformation() {
|
|
|
|
if (this->mPluginLinkInformation.has_value()) {
|
|
|
|
return this->mPluginLinkInformation.operator->();
|
|
|
|
}
|
|
|
|
return nullptr;
|
2024-03-24 07:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<PluginData> PluginContainer::getPluginDataCopy() const {
|
|
|
|
return mPluginData;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PluginContainer::getHandle() const {
|
|
|
|
return (uint32_t) this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::optional<PluginConfigData> &PluginContainer::getConfigData() const {
|
|
|
|
return mPluginConfigData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginContainer::setConfigData(const PluginConfigData &pluginConfigData) {
|
|
|
|
mPluginConfigData = pluginConfigData;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
auto res = StorageUtils::API::Internal::OpenStorage(storageId, storageRootItem);
|
|
|
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
storageRootItem = nullptr;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
WUPSStorageError PluginContainer::CloseStorage() {
|
|
|
|
if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) {
|
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (storageRootItem == nullptr) {
|
|
|
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
return StorageUtils::API::Internal::CloseStorage(storageRootItem);
|
|
|
|
}
|