Atmosphere/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp

56 lines
2 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* 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-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:
os::Mutex lock;
cfg::OverrideLocale locale;
bool got_locale;
2019-11-21 07:58:18 +00:00
public:
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.
*/
const bool is_game = (ncm::IsApplicationProgramId(client_info.program_id) && !client_info.override_status.IsHbl());
return client_info.program_id == ncm::ProgramId::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-11-21 07:58:18 +00:00
}