2019-10-25 01:33:41 +00:00
# include "ui/MainApplication.hpp"
# include "util/curl.hpp"
# include "util/util.hpp"
# include "util/unzip.hpp"
2019-10-26 04:38:12 +00:00
# include "config.hpp"
2019-10-25 01:33:41 +00:00
namespace inst : : ui {
extern MainApplication * mainApp ;
}
namespace sig {
void installSigPatches ( ) {
int ourResult = inst : : ui : : mainApp - > CreateShowDialog ( " Install signature patches? " , " Signature patches are required for installing and playing NSP contents! " , { " Install " , " Uninstall " , " Cancel " } , true ) ;
if ( ourResult = = 0 ) {
2019-10-27 21:16:42 +00:00
if ( ! inst : : util : : copyFile ( " sdmc:/bootloader/patches.ini " , inst : : config : : appDir + " /patches.ini.old " ) ) {
2019-10-25 01:33:41 +00:00
if ( inst : : ui : : mainApp - > CreateShowDialog ( " Could not back up old Hekate patches.ini! Install anyway? " , " " , { " Yes " , " No " } , false ) ) return ;
}
2019-10-26 05:58:32 +00:00
std : : string ourPath = inst : : config : : appDir + " patches.zip " ;
2019-10-27 21:16:42 +00:00
bool didDownload = inst : : curl : : downloadFile ( inst : : config : : sigPatchesUrl , ourPath . c_str ( ) ) ;
2019-10-25 01:33:41 +00:00
bool didExtract = false ;
2019-10-26 05:58:32 +00:00
if ( didDownload ) didExtract = inst : : zip : : extractFile ( ourPath , " sdmc:/ " ) ;
2019-10-25 01:33:41 +00:00
else {
inst : : ui : : mainApp - > CreateShowDialog ( " Could not download signature patches! " , " Check your internet connection and try again " , { " OK " } , true ) ;
return ;
}
std : : filesystem : : remove ( ourPath ) ;
if ( didExtract ) inst : : ui : : mainApp - > CreateShowDialog ( " Install complete! " , " Restart your console to apply! " , { " OK " } , true ) ;
else {
inst : : ui : : mainApp - > CreateShowDialog ( " Could not extract files! " , " " , { " OK " } , true ) ;
return ;
}
return ;
} else if ( ourResult = = 1 ) {
2019-10-27 21:16:42 +00:00
if ( ! inst : : util : : copyFile ( inst : : config : : appDir + " /patches.ini.old " , " sdmc:/bootloader/patches.ini " ) ) {
2019-10-25 01:33:41 +00:00
if ( inst : : ui : : mainApp - > CreateShowDialog ( " Unable to restore original Hekate patches.ini! Continue uninstalling? " , " " , { " Yes " , " No " } , false ) ) return ;
2019-10-27 21:16:42 +00:00
} else std : : filesystem : : remove ( inst : : config : : appDir + " /patches.ini.old " ) ;
2019-10-26 05:58:32 +00:00
if ( inst : : util : : removeDirectory ( " sdmc:/atmosphere/exefs_patches/es_patches " ) ) inst : : ui : : mainApp - > CreateShowDialog ( " Uninstall complete " , " Restart your console to apply " , { " OK " } , true ) ;
2019-10-25 01:33:41 +00:00
else inst : : ui : : mainApp - > CreateShowDialog ( " Unable to remove signature patches " , " Files may have been renamed or deleted " , { " OK " } , true ) ;
} else return ;
}
}