2024-04-30 22:01:42 +01:00
|
|
|
/*
|
|
|
|
* title_metadata_task.cpp
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <tasks/title_metadata_task.hpp>
|
|
|
|
|
|
|
|
using namespace brls::i18n::literals; /* For _i18n. */
|
|
|
|
|
|
|
|
namespace nxdt::tasks
|
|
|
|
{
|
|
|
|
TitleMetadataTask::TitleMetadataTask() : brls::RepeatingTask(REPEATING_TASK_INTERVAL)
|
|
|
|
{
|
2024-05-05 20:42:32 +01:00
|
|
|
LOG_MSG_DEBUG("Title metadata task started.");
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Get system metadata entries. */
|
2024-05-05 23:41:41 +01:00
|
|
|
this->PopulateApplicationMetadataInfo(true);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Get user metadata entries. */
|
2024-05-05 23:41:41 +01:00
|
|
|
this->PopulateApplicationMetadataInfo(false);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Start task. */
|
|
|
|
brls::RepeatingTask::start();
|
|
|
|
}
|
|
|
|
|
|
|
|
TitleMetadataTask::~TitleMetadataTask()
|
|
|
|
{
|
2024-05-05 23:41:41 +01:00
|
|
|
/* Free application metadata arrays. */
|
|
|
|
if (this->system_metadata_info.app_metadata) free(this->system_metadata_info.app_metadata);
|
|
|
|
if (this->user_metadata_info.app_metadata) free(this->user_metadata_info.app_metadata);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
LOG_MSG_DEBUG("Title metadata task stopped.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleMetadataTask::run(retro_time_t current_time)
|
|
|
|
{
|
|
|
|
brls::RepeatingTask::run(current_time);
|
|
|
|
|
|
|
|
if (titleIsGameCardInfoUpdated())
|
|
|
|
{
|
2024-05-05 23:41:41 +01:00
|
|
|
/* Update user metadata array. */
|
|
|
|
this->PopulateApplicationMetadataInfo(false);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Fire task event. */
|
2024-05-05 23:41:41 +01:00
|
|
|
this->user_title_event.fire(this->user_metadata_info);
|
2024-04-30 22:01:42 +01:00
|
|
|
|
2024-05-05 20:42:32 +01:00
|
|
|
//brls::Application::notify("tasks/notifications/user_titles"_i18n);
|
|
|
|
LOG_MSG_DEBUG("Title info updated.");
|
|
|
|
}
|
2024-04-30 22:01:42 +01:00
|
|
|
}
|
|
|
|
|
2024-05-05 23:41:41 +01:00
|
|
|
void TitleMetadataTask::PopulateApplicationMetadataInfo(bool is_system)
|
2024-04-30 22:01:42 +01:00
|
|
|
{
|
2024-05-05 23:41:41 +01:00
|
|
|
/* Get reference to output struct. */
|
|
|
|
TitleApplicationMetadataInfo& info = (is_system ? this->system_metadata_info : this->user_metadata_info);
|
|
|
|
if (info.app_metadata) free(info.app_metadata);
|
|
|
|
info.app_metadata_count = 0;
|
2024-04-30 22:01:42 +01:00
|
|
|
|
|
|
|
/* Get application metadata entries. */
|
2024-05-05 23:41:41 +01:00
|
|
|
info.app_metadata = titleGetApplicationMetadataEntries(is_system, &(info.app_metadata_count));
|
2024-04-30 22:01:42 +01:00
|
|
|
|
2024-05-05 23:41:41 +01:00
|
|
|
LOG_MSG_DEBUG("Retrieved %u %s metadata %s.", info.app_metadata_count, is_system ? "system" : "user", info.app_metadata_count == 1 ? "entry" : "entries");
|
2024-04-30 22:01:42 +01:00
|
|
|
}
|
|
|
|
}
|