summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/ns/ns.h
blob: d017f10fc11848995c9ab719b75031f0ab808859 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "core/hle/service/service.h"

namespace Core {
class System;
}

namespace Service {

namespace FileSystem {
class FileSystemController;
} // namespace FileSystem

namespace NS {

class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> {
public:
    explicit IApplicationManagerInterface(Core::System& system_);
    ~IApplicationManagerInterface() override;

    Result GetApplicationDesiredLanguage(u8* out_desired_language, u32 supported_languages);
    Result ConvertApplicationLanguageToLanguageCode(u64* out_language_code,
                                                    u8 application_language);

private:
    void GetApplicationControlData(HLERequestContext& ctx);
    void GetApplicationDesiredLanguage(HLERequestContext& ctx);
    void ConvertApplicationLanguageToLanguageCode(HLERequestContext& ctx);
};

class IContentManagementInterface final : public ServiceFramework<IContentManagementInterface> {
public:
    explicit IContentManagementInterface(Core::System& system_);
    ~IContentManagementInterface() override;

private:
    void GetTotalSpaceSize(HLERequestContext& ctx);
    void GetFreeSpaceSize(HLERequestContext& ctx);
};

class IDocumentInterface final : public ServiceFramework<IDocumentInterface> {
public:
    explicit IDocumentInterface(Core::System& system_);
    ~IDocumentInterface() override;

private:
    void ResolveApplicationContentPath(HLERequestContext& ctx);
    void GetRunningApplicationProgramId(HLERequestContext& ctx);
};

class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> {
public:
    explicit IDownloadTaskInterface(Core::System& system_);
    ~IDownloadTaskInterface() override;
};

class IECommerceInterface final : public ServiceFramework<IECommerceInterface> {
public:
    explicit IECommerceInterface(Core::System& system_);
    ~IECommerceInterface() override;
};

class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> {
public:
    explicit IFactoryResetInterface(Core::System& system_);
    ~IFactoryResetInterface() override;
};

class IReadOnlyApplicationRecordInterface final
    : public ServiceFramework<IReadOnlyApplicationRecordInterface> {
public:
    explicit IReadOnlyApplicationRecordInterface(Core::System& system_);
    ~IReadOnlyApplicationRecordInterface() override;

private:
    void HasApplicationRecord(HLERequestContext& ctx);
    void IsDataCorruptedResult(HLERequestContext& ctx);
};

class IReadOnlyApplicationControlDataInterface final
    : public ServiceFramework<IReadOnlyApplicationControlDataInterface> {
public:
    explicit IReadOnlyApplicationControlDataInterface(Core::System& system_);
    ~IReadOnlyApplicationControlDataInterface() override;

private:
    void GetApplicationControlData(HLERequestContext& ctx);
};

class NS final : public ServiceFramework<NS> {
public:
    explicit NS(const char* name, Core::System& system_);
    ~NS() override;

    std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const;

private:
    template <typename T, typename... Args>
    void PushInterface(HLERequestContext& ctx) {
        LOG_DEBUG(Service_NS, "called");

        IPC::ResponseBuilder rb{ctx, 2, 0, 1};
        rb.Push(ResultSuccess);
        rb.PushIpcInterface<T>(system);
    }

    void PushIApplicationManagerInterface(HLERequestContext& ctx) {
        LOG_DEBUG(Service_NS, "called");

        IPC::ResponseBuilder rb{ctx, 2, 0, 1};
        rb.Push(ResultSuccess);
        rb.PushIpcInterface<IApplicationManagerInterface>(system);
    }

    template <typename T, typename... Args>
    std::shared_ptr<T> GetInterface(Args&&... args) const {
        static_assert(std::is_base_of_v<SessionRequestHandler, T>,
                      "Not a base of ServiceFrameworkBase");

        return std::make_shared<T>(std::forward<Args>(args)...);
    }
};

void LoopProcess(Core::System& system);

} // namespace NS
} // namespace Service