2019-05-22 19:11:40 +00:00
|
|
|
/*
|
2020-01-24 10:10:40 +00:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2019-05-22 19:11:40 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2019-11-22 03:32:41 +00:00
|
|
|
namespace ams::mitm::settings {
|
2019-05-22 19:11:40 +00:00
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#define AMS_SETTINGS_MITM_INTERFACE_INFO(C, H) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 0, Result, GetLanguageCode, (sf::Out<ams::settings::LanguageCode> out)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 4, Result, GetRegionCode, (sf::Out<ams::settings::RegionCode> out))
|
|
|
|
|
|
|
|
AMS_SF_DEFINE_MITM_INTERFACE(ISetMitmInterface, AMS_SETTINGS_MITM_INTERFACE_INFO)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class SetMitmService : public sf::MitmServiceImplBase {
|
2019-11-22 03:32:41 +00:00
|
|
|
private:
|
2020-04-08 09:21:35 +00:00
|
|
|
os::Mutex lock{false};
|
2019-11-22 03:32:41 +00:00
|
|
|
cfg::OverrideLocale locale;
|
2020-07-08 00:07:23 +00:00
|
|
|
bool got_locale = false;
|
|
|
|
public:
|
|
|
|
using MitmServiceImplBase::MitmServiceImplBase;
|
2019-11-21 07:58:18 +00:00
|
|
|
public:
|
2019-11-21 12:03:19 +00:00
|
|
|
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
|
2019-11-22 03:32:41 +00:00
|
|
|
/* We will mitm:
|
|
|
|
* - ns and games, to allow for overriding game locales.
|
|
|
|
*/
|
2020-03-08 08:06:23 +00:00
|
|
|
const bool is_game = (ncm::IsApplicationId(client_info.program_id) && !client_info.override_status.IsHbl());
|
|
|
|
return client_info.program_id == ncm::SystemProgramId::Ns || is_game;
|
2019-11-21 07:58:18 +00:00
|
|
|
}
|
2019-11-22 03:32:41 +00:00
|
|
|
private:
|
|
|
|
Result EnsureLocale();
|
2020-07-08 00:07:23 +00:00
|
|
|
public:
|
2019-11-22 03:32:41 +00:00
|
|
|
Result GetLanguageCode(sf::Out<ams::settings::LanguageCode> out);
|
|
|
|
Result GetRegionCode(sf::Out<ams::settings::RegionCode> out);
|
2019-11-21 07:58:18 +00:00
|
|
|
};
|
2020-07-08 00:07:23 +00:00
|
|
|
static_assert(IsISetMitmInterface<SetMitmService>);
|
2019-05-22 19:11:40 +00:00
|
|
|
|
2019-11-21 07:58:18 +00:00
|
|
|
}
|