2024-04-30 22:01:42 +01:00
|
|
|
/*
|
|
|
|
* title_metadata_task.hpp
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020-2024, DarkMatterCore <pabloacurielz@gmail.com>.
|
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef __TITLE_METADATA_TASK_HPP__
|
|
|
|
#define __TITLE_METADATA_TASK_HPP__
|
|
|
|
|
|
|
|
#include <borealis.hpp>
|
|
|
|
|
|
|
|
#include "../core/nxdt_utils.h"
|
|
|
|
#include "../core/title.h"
|
|
|
|
|
|
|
|
namespace nxdt::tasks
|
|
|
|
{
|
2024-05-05 23:41:41 +01:00
|
|
|
/* Used to hold an application metadata array + its number of elements. */
|
|
|
|
typedef struct {
|
|
|
|
TitleApplicationMetadata **app_metadata;
|
|
|
|
u32 app_metadata_count;
|
|
|
|
} TitleApplicationMetadataInfo;
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Custom event type. */
|
2024-05-05 23:41:41 +01:00
|
|
|
typedef brls::Event<const TitleApplicationMetadataInfo&> UserTitleEvent;
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Title metadata task. */
|
2024-05-05 23:41:41 +01:00
|
|
|
/* Its event provides a const reference to a TitleApplicationMetadataInfo with metadata for user titles (system titles don't change at runtime). */
|
2024-04-30 22:01:42 +01:00
|
|
|
class TitleMetadataTask: public brls::RepeatingTask
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
UserTitleEvent user_title_event;
|
|
|
|
|
2024-05-05 23:41:41 +01:00
|
|
|
TitleApplicationMetadataInfo system_metadata_info{};
|
|
|
|
TitleApplicationMetadataInfo user_metadata_info{};
|
2024-04-30 22:01:42 +01:00
|
|
|
|
2024-05-05 23:41:41 +01:00
|
|
|
void PopulateApplicationMetadataInfo(bool is_system);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void run(retro_time_t current_time) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TitleMetadataTask();
|
|
|
|
~TitleMetadataTask();
|
|
|
|
|
|
|
|
/* Intentionally left here to let views retrieve title metadata on-demand. */
|
2024-05-05 23:41:41 +01:00
|
|
|
ALWAYS_INLINE const TitleApplicationMetadataInfo& GetApplicationMetadataInfo(bool is_system)
|
2024-05-05 20:42:32 +01:00
|
|
|
{
|
2024-05-05 23:41:41 +01:00
|
|
|
return (is_system ? this->system_metadata_info : this->user_metadata_info);
|
2024-05-05 20:42:32 +01:00
|
|
|
}
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
ALWAYS_INLINE UserTitleEvent::Subscription RegisterListener(UserTitleEvent::Callback cb)
|
|
|
|
{
|
|
|
|
return this->user_title_event.subscribe(cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE void UnregisterListener(UserTitleEvent::Subscription subscription)
|
|
|
|
{
|
|
|
|
this->user_title_event.unsubscribe(subscription);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __TITLE_METADATA_TASK_HPP__ */
|