1
0
Fork 1
forked from suyu/suyu

time: Implement missing services

Implements GetTotalLocationNameCount LoadLocationNameList and
GetTimeZoneRuleVersion.

tz-manager: Fix sign issue
This commit is contained in:
Narr the Reg 2022-07-14 10:37:03 -05:00 committed by lat9nq
parent 8d52dc163a
commit a40e0fdf9e
7 changed files with 106 additions and 11 deletions

View file

@ -103,7 +103,7 @@ struct TimeManager::Impl final {
void SetupTimeZoneManager(std::string location_name, void SetupTimeZoneManager(std::string location_name,
Clock::SteadyClockTimePoint time_zone_updated_time_point, Clock::SteadyClockTimePoint time_zone_updated_time_point,
std::size_t total_location_name_count, u128 time_zone_rule_version, std::vector<std::string> location_names, u128 time_zone_rule_version,
FileSys::VirtualFile& vfs_file) { FileSys::VirtualFile& vfs_file) {
if (time_zone_content_manager.GetTimeZoneManager().SetDeviceLocationNameWithTimeZoneRule( if (time_zone_content_manager.GetTimeZoneManager().SetDeviceLocationNameWithTimeZoneRule(
location_name, vfs_file) != ResultSuccess) { location_name, vfs_file) != ResultSuccess) {
@ -113,7 +113,8 @@ struct TimeManager::Impl final {
time_zone_content_manager.GetTimeZoneManager().SetUpdatedTime(time_zone_updated_time_point); time_zone_content_manager.GetTimeZoneManager().SetUpdatedTime(time_zone_updated_time_point);
time_zone_content_manager.GetTimeZoneManager().SetTotalLocationNameCount( time_zone_content_manager.GetTimeZoneManager().SetTotalLocationNameCount(
total_location_name_count); location_names.size());
time_zone_content_manager.GetTimeZoneManager().SetLocationNames(location_names);
time_zone_content_manager.GetTimeZoneManager().SetTimeZoneRuleVersion( time_zone_content_manager.GetTimeZoneManager().SetTimeZoneRuleVersion(
time_zone_rule_version); time_zone_rule_version);
time_zone_content_manager.GetTimeZoneManager().MarkAsInitialized(); time_zone_content_manager.GetTimeZoneManager().MarkAsInitialized();
@ -283,10 +284,10 @@ void TimeManager::UpdateLocalSystemClockTime(s64 posix_time) {
void TimeManager::SetupTimeZoneManager(std::string location_name, void TimeManager::SetupTimeZoneManager(std::string location_name,
Clock::SteadyClockTimePoint time_zone_updated_time_point, Clock::SteadyClockTimePoint time_zone_updated_time_point,
std::size_t total_location_name_count, std::vector<std::string> location_names,
u128 time_zone_rule_version, u128 time_zone_rule_version,
FileSys::VirtualFile& vfs_file) { FileSys::VirtualFile& vfs_file) {
impl->SetupTimeZoneManager(location_name, time_zone_updated_time_point, impl->SetupTimeZoneManager(location_name, time_zone_updated_time_point, location_names,
total_location_name_count, time_zone_rule_version, vfs_file); time_zone_rule_version, vfs_file);
} }
} // namespace Service::Time } // namespace Service::Time

View file

@ -61,7 +61,7 @@ public:
void SetupTimeZoneManager(std::string location_name, void SetupTimeZoneManager(std::string location_name,
Clock::SteadyClockTimePoint time_zone_updated_time_point, Clock::SteadyClockTimePoint time_zone_updated_time_point,
std::size_t total_location_name_count, u128 time_zone_rule_version, std::vector<std::string> location_names, u128 time_zone_rule_version,
FileSys::VirtualFile& vfs_file); FileSys::VirtualFile& vfs_file);
private: private:

View file

@ -82,8 +82,8 @@ void TimeZoneContentManager::Initialize(TimeManager& time_manager) {
GetTimeZoneInfoFile(timezone_setting, vfs_file) == ResultSuccess) { GetTimeZoneInfoFile(timezone_setting, vfs_file) == ResultSuccess) {
const auto time_point{ const auto time_point{
time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)}; time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)};
time_manager.SetupTimeZoneManager(timezone_setting, time_point, location_name_cache.size(), time_manager.SetupTimeZoneManager(timezone_setting, time_point, location_name_cache, {},
{}, vfs_file); vfs_file);
} else { } else {
time_zone_manager.MarkAsInitialized(); time_zone_manager.MarkAsInitialized();
} }

View file

@ -1076,4 +1076,36 @@ Result TimeZoneManager::GetDeviceLocationName(LocationName& value) const {
return ResultSuccess; return ResultSuccess;
} }
Result TimeZoneManager::GetTotalLocationNameCount(s32& count) const {
if (!is_initialized) {
return ERROR_UNINITIALIZED_CLOCK;
}
count = static_cast<u32>(total_location_name_count);
return ResultSuccess;
}
Result TimeZoneManager::GetTimeZoneRuleVersion(u128& version) const {
if (!is_initialized) {
return ERROR_UNINITIALIZED_CLOCK;
}
version = time_zone_rule_version;
return ResultSuccess;
}
Result TimeZoneManager::LoadLocationNameList(std::vector<LocationName>& values) const {
if (!is_initialized) {
return ERROR_UNINITIALIZED_CLOCK;
}
for (const auto& name : total_location_names) {
LocationName entry{};
std::memcpy(entry.data(), name.c_str(), name.size());
values.push_back(entry);
}
return ResultSuccess;
}
} // namespace Service::Time::TimeZone } // namespace Service::Time::TimeZone

View file

@ -21,6 +21,10 @@ public:
total_location_name_count = value; total_location_name_count = value;
} }
void SetLocationNames(std::vector<std::string> location_names) {
total_location_names = location_names;
}
void SetTimeZoneRuleVersion(const u128& value) { void SetTimeZoneRuleVersion(const u128& value) {
time_zone_rule_version = value; time_zone_rule_version = value;
} }
@ -33,6 +37,9 @@ public:
FileSys::VirtualFile& vfs_file); FileSys::VirtualFile& vfs_file);
Result SetUpdatedTime(const Clock::SteadyClockTimePoint& value); Result SetUpdatedTime(const Clock::SteadyClockTimePoint& value);
Result GetDeviceLocationName(TimeZone::LocationName& value) const; Result GetDeviceLocationName(TimeZone::LocationName& value) const;
Result GetTotalLocationNameCount(s32& count) const;
Result GetTimeZoneRuleVersion(u128& version) const;
Result LoadLocationNameList(std::vector<TimeZone::LocationName>& values) const;
Result ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const; Result ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const;
Result ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const; Result ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const;
Result ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const; Result ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const;
@ -46,6 +53,7 @@ private:
std::string device_location_name{"GMT"}; std::string device_location_name{"GMT"};
u128 time_zone_rule_version{}; u128 time_zone_rule_version{};
std::size_t total_location_name_count{}; std::size_t total_location_name_count{};
std::vector<std::string> total_location_names{};
Clock::SteadyClockTimePoint time_zone_update_time_point{ Clock::SteadyClockTimePoint time_zone_update_time_point{
Clock::SteadyClockTimePoint::GetRandom()}; Clock::SteadyClockTimePoint::GetRandom()};
}; };

View file

@ -15,10 +15,10 @@ ITimeZoneService::ITimeZoneService(Core::System& system_,
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"},
{1, nullptr, "SetDeviceLocationName"}, {1, nullptr, "SetDeviceLocationName"},
{2, nullptr, "GetTotalLocationNameCount"}, {2, &ITimeZoneService::GetTotalLocationNameCount, "GetTotalLocationNameCount"},
{3, nullptr, "LoadLocationNameList"}, {3, &ITimeZoneService::LoadLocationNameList, "LoadLocationNameList"},
{4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"}, {4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"},
{5, nullptr, "GetTimeZoneRuleVersion"}, {5, &ITimeZoneService::GetTimeZoneRuleVersion, "GetTimeZoneRuleVersion"},
{6, nullptr, "GetDeviceLocationNameAndUpdatedTime"}, {6, nullptr, "GetDeviceLocationNameAndUpdatedTime"},
{100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"},
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
@ -45,6 +45,57 @@ void ITimeZoneService::GetDeviceLocationName(HLERequestContext& ctx) {
rb.PushRaw(location_name); rb.PushRaw(location_name);
} }
void ITimeZoneService::GetTotalLocationNameCount(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called");
s32 count{};
if (const Result result{
time_zone_content_manager.GetTimeZoneManager().GetTotalLocationNameCount(count)};
result != ResultSuccess) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
return;
}
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(count);
}
void ITimeZoneService::LoadLocationNameList(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called");
std::vector<TimeZone::LocationName> location_names{};
if (const Result result{
time_zone_content_manager.GetTimeZoneManager().LoadLocationNameList(location_names)};
result != ResultSuccess) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
return;
}
ctx.WriteBuffer(location_names);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(static_cast<s32>(location_names.size()));
}
void ITimeZoneService::GetTimeZoneRuleVersion(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called");
u128 rule_version{};
if (const Result result{
time_zone_content_manager.GetTimeZoneManager().GetTimeZoneRuleVersion(rule_version)};
result != ResultSuccess) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
return;
}
IPC::ResponseBuilder rb{ctx, 6};
rb.Push(ResultSuccess);
rb.PushRaw(rule_version);
}
void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) { void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const auto raw_location_name{rp.PopRaw<std::array<u8, 0x24>>()}; const auto raw_location_name{rp.PopRaw<std::array<u8, 0x24>>()};

View file

@ -22,6 +22,9 @@ public:
private: private:
void GetDeviceLocationName(HLERequestContext& ctx); void GetDeviceLocationName(HLERequestContext& ctx);
void GetTotalLocationNameCount(HLERequestContext& ctx);
void LoadLocationNameList(HLERequestContext& ctx);
void GetTimeZoneRuleVersion(HLERequestContext& ctx);
void LoadTimeZoneRule(HLERequestContext& ctx); void LoadTimeZoneRule(HLERequestContext& ctx);
void ToCalendarTime(HLERequestContext& ctx); void ToCalendarTime(HLERequestContext& ctx);
void ToCalendarTimeWithMyRule(HLERequestContext& ctx); void ToCalendarTimeWithMyRule(HLERequestContext& ctx);