Skip to content

Commit

Permalink
Added new Sys-FTP service manager
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroGamer74 committed Mar 1, 2019
1 parent 31d58c7 commit 6572a20
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include $(DEVKITPRO)/libnx/switch_rules

APP_TITLE := RetroReloaded Updater
APP_AUTHOR := RetroGamer_74
APP_VERSION := 1.3
APP_VERSION := 1.4

ICON := Icon.jpg
TARGET := RetroReloadedUpdater
Expand Down
34 changes: 33 additions & 1 deletion source/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ vector<string> FS::EnumDir(string path) {
return ret;
}

void FS::DeleteFile(string path) {
remove(path.c_str());
}


string FS::GetProdinfoKeyValue(string path) {
std::string dataLine="0";
std::ifstream datafile(path.c_str(),ios_base::binary);
Expand Down Expand Up @@ -167,9 +172,15 @@ string FS::GetFullProdinfoPath()
return config_dir;
}

string FS::GetFullFTPPath()
{
string config_dir = "sdmc:/atmosphere/titles/420000000000000E/flags/boot2.flag";
return config_dir;
}

string FS::GetFullTemplatePath()
{
string config_dir = "sdmc:/";
string config_dir = "sdmc:/";
string basetitle ="/titles/0100000000001000";
string source_path;
string CurrentCFG_Folder;
Expand All @@ -181,6 +192,19 @@ string FS::GetFullTemplatePath()
return source_path;
}

bool FS::IsFTPEnabled()
{
string source_path;
source_path = FS::GetFullFTPPath();

if(FS::CheckFileExists(source_path))
{
return true;
}
else
return false;
}

bool FS::IsProdinfoRW()
{
string source_path;
Expand Down Expand Up @@ -381,6 +405,14 @@ void FS::SetProdinfoMode(int value)
FS::WriteLineFile(FS::GetFullProdinfoPath(), "[config]\nallow_write="+std::to_string(value));
}

void FS::SetFTPStatus(bool value)
{
if(value)
FS::WriteLineFile(FS::GetFullFTPPath(), "");
else
FS::DeleteFile(FS::GetFullFTPPath());
}

unsigned FS::MakeDir(string file, unsigned perm) {
return mkdir(file.c_str(), perm);
}
4 changes: 4 additions & 0 deletions source/FS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ using namespace std;
namespace FS {
vector<string> EnumDir(string);
bool DirExists(string dirstr);
void SetFTPStatus(bool value);
void DeleteFile(string path);
unsigned DeleteDirRecursive(string path);
unsigned MakeDir(string file, unsigned perm);
int GetCustomFirmware_ID();
Expand All @@ -50,6 +52,8 @@ namespace FS {
void DoEnableTemplate(string TemplateCode);
string GetFullTemplatePath();
string GetFullProdinfoPath();
string GetFullFTPPath();
bool IsFTPEnabled();
int GetRRReleaseNumber();
void SetProdinfoMode(int value);
string TestFunction();
Expand Down
60 changes: 58 additions & 2 deletions source/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define WIN_HEIGHT 720
#define RR_MINVERSION 124
#define RR_MINVERSIONPRODINFO 133
#define RR_MINVERSIONFTP 135

static u32 currSel = 0;
static u32 currSubSel = 0;
Expand All @@ -37,7 +38,6 @@ static u32 titleY = 30;
static u32 menuX = 55, menuY = 115;
static u32 subX = 411, subY = 88;

// Input vars, updated every iteration of the loop, proper way to access input using CustomUI
static u64 HeldInput = 0;
static u64 PressedInput = 0;
static u64 ReleasedInput = 0;
Expand All @@ -53,13 +53,15 @@ static string SerialNumber; //Switch Serial Number
static u32 CurrentFirmware_ID; //Current CFW ID
static bool TemplateEnabled;
static bool ProdinfoRW;
static bool isFTPEnabled = false;;
static int RRReleaseNumber;

static u32 menuOptionCFWUpdate = 0;
static u32 menuOptionThemeEnable = 1;
static u32 menuOptionSelectTheme = 2;
static u32 menuOptionProdinfo = 3;
static u32 menuOptionAbout = 4;
static u32 menuOptionFTP = 4;
static u32 menuOptionAbout = 5;



Expand Down Expand Up @@ -141,11 +143,17 @@ else
//Help
void UI::optAbout() {
string mode = "";
string ftpStatus = "";
if(FS::IsProdinfoRW())
mode = "RW";
else
mode = "RO";

if(FS::IsFTPEnabled())
ftpStatus="Enabled";
else
ftpStatus="Disabled";

MessageBox(
"About",
"NX FW Version: "+CurrentNXFirmwareVersion +"\n"+
Expand All @@ -154,6 +162,7 @@ void UI::optAbout() {
"\n\n" +
"CFW: "+ CurrentCFG_Name+"\n"+
"PRODINFO MODE: "+ mode + "\n"+
"SYS-FTP STATUS: "+ ftpStatus + "\n"+
"Template: "+CurrentTemplate+"\n"+
//" Located: sdmc:/"+CurrentCFG_Folder+" FWD_ID: "+std::to_string(CurrentFirmware_ID)+"\n"+
"Main developers:\n" +
Expand All @@ -175,6 +184,12 @@ void setMenuOptionValues()
menuOptionAbout = 3;
return;
}

if(RRReleaseNumber >= RR_MINVERSIONPRODINFO && RRReleaseNumber < RR_MINVERSIONFTP)
{
menuOptionAbout = 4;
return;
}
}

void UI::optDisableProdinfo() {
Expand Down Expand Up @@ -207,6 +222,38 @@ void UI::optDisableProdinfo() {

}

void UI::optDisableFTP() {

bool isFTPEnabled = FS::IsFTPEnabled();
string enable = "enable";
string disable = "disable";

string question = "";

if(isFTPEnabled)
question = disable;
else
question = enable;

if(MessageBox("FTP On/Off","Do you want to "+question+"\nFTP as system service?", TYPE_YES_NO)) {

if(isFTPEnabled)
{
FS::SetFTPStatus(false);
MessageBox("Info","FTP has been set to enabled.\nReboot is required to apply changes!",TYPE_OK);
}
else
{
FS::SetFTPStatus(true);
MessageBox("Info","FTP has been set to disabled.\nReboot is required to apply changes!",TYPE_OK);
}

}

}

//remove template

//remove template
void UI::optDisableTemplate() {
int result;
Expand Down Expand Up @@ -279,6 +326,10 @@ void UI::RePaintMenu()
{
mainMenu.push_back(MenuOption("Prodinfo RW","RO/RW Prodinfo",nullptr));
}
if(RRReleaseNumber >= RR_MINVERSIONFTP)
{
mainMenu.push_back(MenuOption("FTP On/Off","Enable/Disable FTP",nullptr));
}
mainMenu.push_back(MenuOption("About", "About RetroReloaded Updater.", bind(&UI::optAbout, this)));


Expand All @@ -297,6 +348,10 @@ void UI::RePaintMenu()
mainMenu[menuOptionProdinfo].subMenu.push_back(MenuOption("Prodinfo RO/RW", "",bind(&UI::optDisableProdinfo, this)));
}

if(RRReleaseNumber >= RR_MINVERSIONFTP)
{
mainMenu[menuOptionFTP].subMenu.push_back(MenuOption("FTP On/Off", "",bind(&UI::optDisableFTP, this)));
}
}

void UI::drawTemplatesOption(){
Expand Down Expand Up @@ -427,6 +482,7 @@ void UI::setInstance(UI ui) {

TemplateEnabled = FS::IsTemplatedEnabled();
ProdinfoRW = FS::IsProdinfoRW();
isFTPEnabled = FS::IsFTPEnabled();
setMenuOptionValues();

if(RRReleaseNumber < RR_MINVERSION)
Expand Down
1 change: 1 addition & 0 deletions source/UI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class UI
void optUpdateHB();
void optDisableTemplate();
void optDisableProdinfo();
void optDisableFTP();
void EnableRRTheme();
void EnableSBTheme();
void drawTemplatesOption();
Expand Down

0 comments on commit 6572a20

Please sign in to comment.