display useful info in ftp menu (ip, port, user, pass, ssid, passphrase)
This commit is contained in:
@@ -14,4 +14,9 @@ using OnInstallClose = std::function<void(void* user)>;
|
|||||||
void InitInstallMode(void* user, OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close);
|
void InitInstallMode(void* user, OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close);
|
||||||
void DisableInstallMode();
|
void DisableInstallMode();
|
||||||
|
|
||||||
|
unsigned GetPort();
|
||||||
|
bool IsAnon();
|
||||||
|
const char* GetUser();
|
||||||
|
const char* GetPass();
|
||||||
|
|
||||||
} // namespace sphaira::ftpsrv
|
} // namespace sphaira::ftpsrv
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ struct Menu final : MenuBase {
|
|||||||
Mutex m_mutex{};
|
Mutex m_mutex{};
|
||||||
// the below are shared across threads, lock with the above mutex!
|
// the below are shared across threads, lock with the above mutex!
|
||||||
State m_state{State::None};
|
State m_state{State::None};
|
||||||
|
|
||||||
|
const char* m_user{};
|
||||||
|
const char* m_pass{};
|
||||||
|
unsigned m_port{};
|
||||||
|
bool m_anon{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sphaira::ui::menu::ftp
|
} // namespace sphaira::ui::menu::ftp
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ private:
|
|||||||
std::string m_title_sub_heading{};
|
std::string m_title_sub_heading{};
|
||||||
std::string m_sub_heading{};
|
std::string m_sub_heading{};
|
||||||
|
|
||||||
|
protected:
|
||||||
struct tm m_tm{};
|
struct tm m_tm{};
|
||||||
TimeStamp m_poll_timestamp{};
|
TimeStamp m_poll_timestamp{};
|
||||||
u32 m_battery_percetange{};
|
u32 m_battery_percetange{};
|
||||||
|
|||||||
@@ -389,6 +389,26 @@ void DisableInstallMode() {
|
|||||||
g_shared_data.enabled = false;
|
g_shared_data.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned GetPort() {
|
||||||
|
std::scoped_lock lock{g_mutex};
|
||||||
|
return g_ftpsrv_config.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsAnon() {
|
||||||
|
std::scoped_lock lock{g_mutex};
|
||||||
|
return g_ftpsrv_config.anon;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* GetUser() {
|
||||||
|
std::scoped_lock lock{g_mutex};
|
||||||
|
return g_ftpsrv_config.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* GetPass() {
|
||||||
|
std::scoped_lock lock{g_mutex};
|
||||||
|
return g_ftpsrv_config.pass;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sphaira::ftpsrv
|
} // namespace sphaira::ftpsrv
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -148,6 +148,13 @@ Menu::Menu() : MenuBase{"FTP Install (EXPERIMENTAL)"_i18n} {
|
|||||||
|
|
||||||
mutexInit(&m_mutex);
|
mutexInit(&m_mutex);
|
||||||
ftpsrv::InitInstallMode(this, OnInstallStart, OnInstallWrite, OnInstallClose);
|
ftpsrv::InitInstallMode(this, OnInstallStart, OnInstallWrite, OnInstallClose);
|
||||||
|
|
||||||
|
m_port = ftpsrv::GetPort();
|
||||||
|
m_anon = ftpsrv::IsAnon();
|
||||||
|
if (!m_anon) {
|
||||||
|
m_user = ftpsrv::GetUser();
|
||||||
|
m_pass = ftpsrv::GetPass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::~Menu() {
|
Menu::~Menu() {
|
||||||
@@ -213,6 +220,53 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
|
|||||||
mutexLock(&m_mutex);
|
mutexLock(&m_mutex);
|
||||||
ON_SCOPE_EXIT(mutexUnlock(&m_mutex));
|
ON_SCOPE_EXIT(mutexUnlock(&m_mutex));
|
||||||
|
|
||||||
|
if (m_ip) {
|
||||||
|
if (m_type == NifmInternetConnectionType_WiFi) {
|
||||||
|
SetSubHeading("Connection Type: WiFi | Strength: "_i18n + std::to_string(m_strength));
|
||||||
|
} else {
|
||||||
|
SetSubHeading("Connection Type: Ethernet"_i18n);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SetSubHeading("Connection Type: None"_i18n);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float start_x = 80;
|
||||||
|
const float font_size = 22;
|
||||||
|
const float spacing = 33;
|
||||||
|
float start_y = 125;
|
||||||
|
float bounds[4];
|
||||||
|
|
||||||
|
nvgFontSize(vg, font_size);
|
||||||
|
|
||||||
|
// note: textbounds strips spaces...todo: use nvgTextGlyphPositions() instead.
|
||||||
|
#define draw(key, ...) \
|
||||||
|
gfx::textBounds(vg, start_x, start_y, bounds, key.c_str()); \
|
||||||
|
gfx::drawTextArgs(vg, start_x, start_y, font_size, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE, theme->GetColour(ThemeEntryID_TEXT), key.c_str()); \
|
||||||
|
gfx::drawTextArgs(vg, bounds[2], start_y, font_size, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE, theme->GetColour(ThemeEntryID_TEXT_SELECTED), __VA_ARGS__); \
|
||||||
|
start_y += spacing;
|
||||||
|
|
||||||
|
if (m_ip) {
|
||||||
|
draw("Host:"_i18n, " %u.%u.%u.%u", m_ip&0xFF, (m_ip>>8)&0xFF, (m_ip>>16)&0xFF, (m_ip>>24)&0xFF);
|
||||||
|
draw("Port:"_i18n, " %u", m_port);
|
||||||
|
if (!m_anon) {
|
||||||
|
draw("Username:"_i18n, " %s", m_user);
|
||||||
|
draw("Password:"_i18n, " %s", m_pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_type == NifmInternetConnectionType_WiFi) {
|
||||||
|
NifmNetworkProfileData profile{};
|
||||||
|
if (R_SUCCEEDED(nifmGetCurrentNetworkProfile(&profile))) {
|
||||||
|
const auto& settings = profile.wireless_setting_data;
|
||||||
|
std::string passphrase;
|
||||||
|
std::transform(std::cbegin(settings.passphrase), std::cend(settings.passphrase), passphrase.begin(), toascii);
|
||||||
|
draw("SSID:"_i18n, " %.*s", settings.ssid_len, settings.ssid);
|
||||||
|
draw("Passphrase:"_i18n, " %s", passphrase.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef draw
|
||||||
|
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case State::None:
|
case State::None:
|
||||||
gfx::drawTextArgs(vg, SCREEN_WIDTH / 2.f, SCREEN_HEIGHT / 2.f, 36.f, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE, theme->GetColour(ThemeEntryID_TEXT_INFO), "Waiting for connection..."_i18n.c_str());
|
gfx::drawTextArgs(vg, SCREEN_WIDTH / 2.f, SCREEN_HEIGHT / 2.f, 36.f, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE, theme->GetColour(ThemeEntryID_TEXT_INFO), "Waiting for connection..."_i18n.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user