summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/psc/time/time_zone_service.h
blob: 6eb9ddc4b5525f7873aa9bf55088835dba69f179 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "core/hle/service/cmif_types.h"
#include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/psc/time/common.h"
#include "core/hle/service/psc/time/manager.h"
#include "core/hle/service/server_manager.h"
#include "core/hle/service/service.h"

namespace Core {
class System;
}

namespace Tz {
struct Rule;
}

namespace Service::PSC::Time {

class TimeZoneService final : public ServiceFramework<TimeZoneService> {
    using InRule = InLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;
    using OutRule = OutLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;

public:
    explicit TimeZoneService(Core::System& system, StandardSteadyClockCore& clock_core,
                             TimeZone& time_zone, bool can_write_timezone_device_location);

    ~TimeZoneService() override = default;

    Result GetDeviceLocationName(Out<LocationName> out_location_name);
    Result SetDeviceLocationName(LocationName& location_name);
    Result GetTotalLocationNameCount(Out<u32> out_count);
    Result LoadLocationNameList(Out<u32> out_count,
                                OutArray<LocationName, BufferAttr_HipcMapAlias> out_names,
                                u32 index);
    Result LoadTimeZoneRule(OutRule out_rule, LocationName& location_name);
    Result GetTimeZoneRuleVersion(Out<RuleVersion> out_rule_version);
    Result GetDeviceLocationNameAndUpdatedTime(Out<LocationName> location_name,
                                               Out<SteadyClockTimePoint> out_time_point);
    Result SetDeviceLocationNameWithTimeZoneRule(LocationName& location_name,
                                                 InBuffer<BufferAttr_HipcAutoSelect> binary);
    Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
    Result GetDeviceLocationNameOperationEventReadableHandle(
        OutCopyHandle<Kernel::KReadableEvent> out_event);
    Result ToCalendarTime(Out<CalendarTime> out_calendar_time,
                          Out<CalendarAdditionalInfo> out_additional_info, s64 time, InRule rule);
    Result ToCalendarTimeWithMyRule(Out<CalendarTime> out_calendar_time,
                                    Out<CalendarAdditionalInfo> out_additional_info, s64 time);
    Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
                       const CalendarTime& calendar_time, InRule rule);
    Result ToPosixTimeWithMyRule(Out<u32> out_count,
                                 OutArray<s64, BufferAttr_HipcPointer> out_times,
                                 const CalendarTime& calendar_time);

private:
    Core::System& m_system;

    StandardSteadyClockCore& m_clock_core;
    TimeZone& m_time_zone;
    bool m_can_write_timezone_device_location;
};

} // namespace Service::PSC::Time