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
|
|
|
|
2019-11-21 07:58:18 +00:00
|
|
|
class SetMitmService : public sf::IMitmServiceObject {
|
|
|
|
private:
|
|
|
|
enum class CommandId {
|
2019-11-22 03:32:41 +00:00
|
|
|
GetLanguageCode = 0,
|
|
|
|
GetRegionCode = 4,
|
2019-11-21 07:58:18 +00:00
|
|
|
};
|
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;
|
|
|
|
bool got_locale;
|
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
|
|
|
}
|
|
|
|
public:
|
2019-11-22 03:32:41 +00:00
|
|
|
SF_MITM_SERVICE_OBJECT_CTOR(SetMitmService) {
|
|
|
|
this->got_locale = false;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
Result EnsureLocale();
|
2019-11-21 07:58:18 +00:00
|
|
|
protected:
|
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
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
2019-11-22 03:32:41 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(GetLanguageCode),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetRegionCode),
|
2019-11-21 07:58:18 +00:00
|
|
|
};
|
|
|
|
};
|
2019-05-22 19:11:40 +00:00
|
|
|
|
2019-11-21 07:58:18 +00:00
|
|
|
}
|