summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Narr the Reg2022-07-14 10:37:03 -0500
committerGravatar lat9nq2023-06-05 15:15:11 -0400
commita40e0fdf9e287d962108731ebb515ee0fa4ee155 (patch)
treee28c860b01d818cd009c95939f5a87f2e35e3157 /src
parenttime_zone_manager: Implement go_ahead/go_back (diff)
downloadyuzu-a40e0fdf9e287d962108731ebb515ee0fa4ee155.tar.gz
yuzu-a40e0fdf9e287d962108731ebb515ee0fa4ee155.tar.xz
yuzu-a40e0fdf9e287d962108731ebb515ee0fa4ee155.zip
time: Implement missing services
Implements GetTotalLocationNameCount LoadLocationNameList and GetTimeZoneRuleVersion. tz-manager: Fix sign issue
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/time/time_manager.cpp11
-rw-r--r--src/core/hle/service/time/time_manager.h2
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.cpp4
-rw-r--r--src/core/hle/service/time/time_zone_manager.cpp32
-rw-r--r--src/core/hle/service/time/time_zone_manager.h8
-rw-r--r--src/core/hle/service/time/time_zone_service.cpp57
-rw-r--r--src/core/hle/service/time/time_zone_service.h3
7 files changed, 106 insertions, 11 deletions
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp
index 20012afd9..fa0fd0531 100644
--- a/src/core/hle/service/time/time_manager.cpp
+++ b/src/core/hle/service/time/time_manager.cpp
@@ -103,7 +103,7 @@ struct TimeManager::Impl final {
103 103
104 void SetupTimeZoneManager(std::string location_name, 104 void SetupTimeZoneManager(std::string location_name,
105 Clock::SteadyClockTimePoint time_zone_updated_time_point, 105 Clock::SteadyClockTimePoint time_zone_updated_time_point,
106 std::size_t total_location_name_count, u128 time_zone_rule_version, 106 std::vector<std::string> location_names, u128 time_zone_rule_version,
107 FileSys::VirtualFile& vfs_file) { 107 FileSys::VirtualFile& vfs_file) {
108 if (time_zone_content_manager.GetTimeZoneManager().SetDeviceLocationNameWithTimeZoneRule( 108 if (time_zone_content_manager.GetTimeZoneManager().SetDeviceLocationNameWithTimeZoneRule(
109 location_name, vfs_file) != ResultSuccess) { 109 location_name, vfs_file) != ResultSuccess) {
@@ -113,7 +113,8 @@ struct TimeManager::Impl final {
113 113
114 time_zone_content_manager.GetTimeZoneManager().SetUpdatedTime(time_zone_updated_time_point); 114 time_zone_content_manager.GetTimeZoneManager().SetUpdatedTime(time_zone_updated_time_point);
115 time_zone_content_manager.GetTimeZoneManager().SetTotalLocationNameCount( 115 time_zone_content_manager.GetTimeZoneManager().SetTotalLocationNameCount(
116 total_location_name_count); 116 location_names.size());
117 time_zone_content_manager.GetTimeZoneManager().SetLocationNames(location_names);
117 time_zone_content_manager.GetTimeZoneManager().SetTimeZoneRuleVersion( 118 time_zone_content_manager.GetTimeZoneManager().SetTimeZoneRuleVersion(
118 time_zone_rule_version); 119 time_zone_rule_version);
119 time_zone_content_manager.GetTimeZoneManager().MarkAsInitialized(); 120 time_zone_content_manager.GetTimeZoneManager().MarkAsInitialized();
@@ -283,10 +284,10 @@ void TimeManager::UpdateLocalSystemClockTime(s64 posix_time) {
283 284
284void TimeManager::SetupTimeZoneManager(std::string location_name, 285void TimeManager::SetupTimeZoneManager(std::string location_name,
285 Clock::SteadyClockTimePoint time_zone_updated_time_point, 286 Clock::SteadyClockTimePoint time_zone_updated_time_point,
286 std::size_t total_location_name_count, 287 std::vector<std::string> location_names,
287 u128 time_zone_rule_version, 288 u128 time_zone_rule_version,
288 FileSys::VirtualFile& vfs_file) { 289 FileSys::VirtualFile& vfs_file) {
289 impl->SetupTimeZoneManager(location_name, time_zone_updated_time_point, 290 impl->SetupTimeZoneManager(location_name, time_zone_updated_time_point, location_names,
290 total_location_name_count, time_zone_rule_version, vfs_file); 291 time_zone_rule_version, vfs_file);
291} 292}
292} // namespace Service::Time 293} // namespace Service::Time
diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h
index 3848da8bc..84572dbfa 100644
--- a/src/core/hle/service/time/time_manager.h
+++ b/src/core/hle/service/time/time_manager.h
@@ -61,7 +61,7 @@ public:
61 61
62 void SetupTimeZoneManager(std::string location_name, 62 void SetupTimeZoneManager(std::string location_name,
63 Clock::SteadyClockTimePoint time_zone_updated_time_point, 63 Clock::SteadyClockTimePoint time_zone_updated_time_point,
64 std::size_t total_location_name_count, u128 time_zone_rule_version, 64 std::vector<std::string> location_names, u128 time_zone_rule_version,
65 FileSys::VirtualFile& vfs_file); 65 FileSys::VirtualFile& vfs_file);
66 66
67private: 67private:
diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp
index 86a5acc54..5d60be67a 100644
--- a/src/core/hle/service/time/time_zone_content_manager.cpp
+++ b/src/core/hle/service/time/time_zone_content_manager.cpp
@@ -82,8 +82,8 @@ void TimeZoneContentManager::Initialize(TimeManager& time_manager) {
82 GetTimeZoneInfoFile(timezone_setting, vfs_file) == ResultSuccess) { 82 GetTimeZoneInfoFile(timezone_setting, vfs_file) == ResultSuccess) {
83 const auto time_point{ 83 const auto time_point{
84 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)}; 84 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)};
85 time_manager.SetupTimeZoneManager(timezone_setting, time_point, location_name_cache.size(), 85 time_manager.SetupTimeZoneManager(timezone_setting, time_point, location_name_cache, {},
86 {}, vfs_file); 86 vfs_file);
87 } else { 87 } else {
88 time_zone_manager.MarkAsInitialized(); 88 time_zone_manager.MarkAsInitialized();
89 } 89 }
diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp
index 805ffb902..5e507dff2 100644
--- a/src/core/hle/service/time/time_zone_manager.cpp
+++ b/src/core/hle/service/time/time_zone_manager.cpp
@@ -1076,4 +1076,36 @@ Result TimeZoneManager::GetDeviceLocationName(LocationName& value) const {
1076 return ResultSuccess; 1076 return ResultSuccess;
1077} 1077}
1078 1078
1079Result TimeZoneManager::GetTotalLocationNameCount(s32& count) const {
1080 if (!is_initialized) {
1081 return ERROR_UNINITIALIZED_CLOCK;
1082 }
1083 count = static_cast<u32>(total_location_name_count);
1084
1085 return ResultSuccess;
1086}
1087
1088Result TimeZoneManager::GetTimeZoneRuleVersion(u128& version) const {
1089 if (!is_initialized) {
1090 return ERROR_UNINITIALIZED_CLOCK;
1091 }
1092 version = time_zone_rule_version;
1093
1094 return ResultSuccess;
1095}
1096
1097Result TimeZoneManager::LoadLocationNameList(std::vector<LocationName>& values) const {
1098 if (!is_initialized) {
1099 return ERROR_UNINITIALIZED_CLOCK;
1100 }
1101
1102 for (const auto& name : total_location_names) {
1103 LocationName entry{};
1104 std::memcpy(entry.data(), name.c_str(), name.size());
1105 values.push_back(entry);
1106 }
1107
1108 return ResultSuccess;
1109}
1110
1079} // namespace Service::Time::TimeZone 1111} // namespace Service::Time::TimeZone
diff --git a/src/core/hle/service/time/time_zone_manager.h b/src/core/hle/service/time/time_zone_manager.h
index 5ebd4035e..8664f28d1 100644
--- a/src/core/hle/service/time/time_zone_manager.h
+++ b/src/core/hle/service/time/time_zone_manager.h
@@ -21,6 +21,10 @@ public:
21 total_location_name_count = value; 21 total_location_name_count = value;
22 } 22 }
23 23
24 void SetLocationNames(std::vector<std::string> location_names) {
25 total_location_names = location_names;
26 }
27
24 void SetTimeZoneRuleVersion(const u128& value) { 28 void SetTimeZoneRuleVersion(const u128& value) {
25 time_zone_rule_version = value; 29 time_zone_rule_version = value;
26 } 30 }
@@ -33,6 +37,9 @@ public:
33 FileSys::VirtualFile& vfs_file); 37 FileSys::VirtualFile& vfs_file);
34 Result SetUpdatedTime(const Clock::SteadyClockTimePoint& value); 38 Result SetUpdatedTime(const Clock::SteadyClockTimePoint& value);
35 Result GetDeviceLocationName(TimeZone::LocationName& value) const; 39 Result GetDeviceLocationName(TimeZone::LocationName& value) const;
40 Result GetTotalLocationNameCount(s32& count) const;
41 Result GetTimeZoneRuleVersion(u128& version) const;
42 Result LoadLocationNameList(std::vector<TimeZone::LocationName>& values) const;
36 Result ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const; 43 Result ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const;
37 Result ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const; 44 Result ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const;
38 Result ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const; 45 Result ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const;
@@ -46,6 +53,7 @@ private:
46 std::string device_location_name{"GMT"}; 53 std::string device_location_name{"GMT"};
47 u128 time_zone_rule_version{}; 54 u128 time_zone_rule_version{};
48 std::size_t total_location_name_count{}; 55 std::size_t total_location_name_count{};
56 std::vector<std::string> total_location_names{};
49 Clock::SteadyClockTimePoint time_zone_update_time_point{ 57 Clock::SteadyClockTimePoint time_zone_update_time_point{
50 Clock::SteadyClockTimePoint::GetRandom()}; 58 Clock::SteadyClockTimePoint::GetRandom()};
51}; 59};
diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp
index cda8d8343..e8273e152 100644
--- a/src/core/hle/service/time/time_zone_service.cpp
+++ b/src/core/hle/service/time/time_zone_service.cpp
@@ -15,10 +15,10 @@ ITimeZoneService::ITimeZoneService(Core::System& system_,
15 static const FunctionInfo functions[] = { 15 static const FunctionInfo functions[] = {
16 {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, 16 {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"},
17 {1, nullptr, "SetDeviceLocationName"}, 17 {1, nullptr, "SetDeviceLocationName"},
18 {2, nullptr, "GetTotalLocationNameCount"}, 18 {2, &ITimeZoneService::GetTotalLocationNameCount, "GetTotalLocationNameCount"},
19 {3, nullptr, "LoadLocationNameList"}, 19 {3, &ITimeZoneService::LoadLocationNameList, "LoadLocationNameList"},
20 {4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"}, 20 {4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"},
21 {5, nullptr, "GetTimeZoneRuleVersion"}, 21 {5, &ITimeZoneService::GetTimeZoneRuleVersion, "GetTimeZoneRuleVersion"},
22 {6, nullptr, "GetDeviceLocationNameAndUpdatedTime"}, 22 {6, nullptr, "GetDeviceLocationNameAndUpdatedTime"},
23 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, 23 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"},
24 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, 24 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
@@ -45,6 +45,57 @@ void ITimeZoneService::GetDeviceLocationName(HLERequestContext& ctx) {
45 rb.PushRaw(location_name); 45 rb.PushRaw(location_name);
46} 46}
47 47
48void ITimeZoneService::GetTotalLocationNameCount(HLERequestContext& ctx) {
49 LOG_DEBUG(Service_Time, "called");
50
51 s32 count{};
52 if (const Result result{
53 time_zone_content_manager.GetTimeZoneManager().GetTotalLocationNameCount(count)};
54 result != ResultSuccess) {
55 IPC::ResponseBuilder rb{ctx, 2};
56 rb.Push(result);
57 return;
58 }
59
60 IPC::ResponseBuilder rb{ctx, 3};
61 rb.Push(ResultSuccess);
62 rb.Push(count);
63}
64
65void ITimeZoneService::LoadLocationNameList(HLERequestContext& ctx) {
66 LOG_DEBUG(Service_Time, "called");
67
68 std::vector<TimeZone::LocationName> location_names{};
69 if (const Result result{
70 time_zone_content_manager.GetTimeZoneManager().LoadLocationNameList(location_names)};
71 result != ResultSuccess) {
72 IPC::ResponseBuilder rb{ctx, 2};
73 rb.Push(result);
74 return;
75 }
76
77 ctx.WriteBuffer(location_names);
78 IPC::ResponseBuilder rb{ctx, 3};
79 rb.Push(ResultSuccess);
80 rb.Push(static_cast<s32>(location_names.size()));
81}
82void ITimeZoneService::GetTimeZoneRuleVersion(HLERequestContext& ctx) {
83 LOG_DEBUG(Service_Time, "called");
84
85 u128 rule_version{};
86 if (const Result result{
87 time_zone_content_manager.GetTimeZoneManager().GetTimeZoneRuleVersion(rule_version)};
88 result != ResultSuccess) {
89 IPC::ResponseBuilder rb{ctx, 2};
90 rb.Push(result);
91 return;
92 }
93
94 IPC::ResponseBuilder rb{ctx, 6};
95 rb.Push(ResultSuccess);
96 rb.PushRaw(rule_version);
97}
98
48void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) { 99void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) {
49 IPC::RequestParser rp{ctx}; 100 IPC::RequestParser rp{ctx};
50 const auto raw_location_name{rp.PopRaw<std::array<u8, 0x24>>()}; 101 const auto raw_location_name{rp.PopRaw<std::array<u8, 0x24>>()};
diff --git a/src/core/hle/service/time/time_zone_service.h b/src/core/hle/service/time/time_zone_service.h
index ea83b5714..952fcb0e2 100644
--- a/src/core/hle/service/time/time_zone_service.h
+++ b/src/core/hle/service/time/time_zone_service.h
@@ -22,6 +22,9 @@ public:
22 22
23private: 23private:
24 void GetDeviceLocationName(HLERequestContext& ctx); 24 void GetDeviceLocationName(HLERequestContext& ctx);
25 void GetTotalLocationNameCount(HLERequestContext& ctx);
26 void LoadLocationNameList(HLERequestContext& ctx);
27 void GetTimeZoneRuleVersion(HLERequestContext& ctx);
25 void LoadTimeZoneRule(HLERequestContext& ctx); 28 void LoadTimeZoneRule(HLERequestContext& ctx);
26 void ToCalendarTime(HLERequestContext& ctx); 29 void ToCalendarTime(HLERequestContext& ctx);
27 void ToCalendarTimeWithMyRule(HLERequestContext& ctx); 30 void ToCalendarTimeWithMyRule(HLERequestContext& ctx);