Merge pull request #99 from soarqin/master

Added folder installation function in 'More...' menu
This commit is contained in:
TheOfficialFloW 2016-09-24 09:21:12 +02:00 committed by GitHub
commit ab377d26c1
5 changed files with 192 additions and 83 deletions

View File

@ -108,6 +108,7 @@ void loadLanguage(int id) {
LANGUAGE_ENTRY(RENAME),
LANGUAGE_ENTRY(NEW_FOLDER),
LANGUAGE_ENTRY(INSTALL_ALL),
LANGUAGE_ENTRY(INSTALL_FOLDER),
LANGUAGE_ENTRY(CALCULATE_SHA1),
LANGUAGE_ENTRY(EXPORT_MEDIA),
LANGUAGE_ENTRY(SEARCH),
@ -129,6 +130,7 @@ void loadLanguage(int id) {
LANGUAGE_ENTRY(EXPORT_PICTURES_INFO),
LANGUAGE_ENTRY(EXPORT_SONGS_PICTURES_INFO),
LANGUAGE_ENTRY(INSTALL_ALL_QUESTION),
LANGUAGE_ENTRY(INSTALL_FOLDER_QUESTION),
LANGUAGE_ENTRY(INSTALL_QUESTION),
LANGUAGE_ENTRY(INSTALL_WARNING),
LANGUAGE_ENTRY(HASH_FILE_QUESTION),

View File

@ -66,6 +66,7 @@ enum LanguageContainer {
RENAME,
NEW_FOLDER,
INSTALL_ALL,
INSTALL_FOLDER,
CALCULATE_SHA1,
EXPORT_MEDIA,
SEARCH,
@ -87,6 +88,7 @@ enum LanguageContainer {
EXPORT_PICTURES_INFO,
EXPORT_SONGS_PICTURES_INFO,
INSTALL_ALL_QUESTION,
INSTALL_FOLDER_QUESTION,
INSTALL_QUESTION,
INSTALL_WARNING,
HASH_FILE_QUESTION,

35
main.c
View File

@ -460,12 +460,14 @@ MenuEntry menu_entries[] = {
enum MenuMoreEntrys {
MENU_MORE_ENTRY_INSTALL_ALL,
MENU_MORE_ENTRY_INSTALL_FOLDER,
MENU_MORE_ENTRY_EXPORT_MEDIA,
MENU_MORE_ENTRY_CALCULATE_SHA1,
};
MenuEntry menu_more_entries[] = {
{ INSTALL_ALL, CTX_VISIBILITY_INVISIBLE },
{ INSTALL_FOLDER, CTX_VISIBILITY_INVISIBLE },
{ EXPORT_MEDIA, CTX_VISIBILITY_INVISIBLE },
{ CALCULATE_SHA1, CTX_VISIBILITY_INVISIBLE },
};
@ -572,6 +574,7 @@ void setContextMenuMoreVisibilities() {
// Invisble entries when on '..'
if (strcmp(file_entry->name, DIR_UP) == 0) {
menu_more_entries[MENU_MORE_ENTRY_INSTALL_ALL].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_INSTALL_FOLDER].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_EXPORT_MEDIA].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_CALCULATE_SHA1].visibility = CTX_VISIBILITY_INVISIBLE;
}
@ -579,12 +582,34 @@ void setContextMenuMoreVisibilities() {
// Invisble operations in archives
if (isInArchive()) {
menu_more_entries[MENU_MORE_ENTRY_INSTALL_ALL].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_INSTALL_FOLDER].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_EXPORT_MEDIA].visibility = CTX_VISIBILITY_INVISIBLE;
menu_more_entries[MENU_MORE_ENTRY_CALCULATE_SHA1].visibility = CTX_VISIBILITY_INVISIBLE;
}
if (file_entry->is_folder) {
menu_more_entries[MENU_MORE_ENTRY_CALCULATE_SHA1].visibility = CTX_VISIBILITY_INVISIBLE;
do {
char check_path[MAX_PATH_LENGTH];
SceIoStat stat;
int statres;
if (strcmp(file_list.path, "ux0:app/") == 0 || strcmp(file_list.path, "ux0:patch/") == 0) {
menu_more_entries[MENU_MORE_ENTRY_INSTALL_FOLDER].visibility = CTX_VISIBILITY_INVISIBLE;
break;
}
snprintf(check_path, MAX_PATH_LENGTH, "%s%s/eboot.bin", file_list.path, file_entry->name);
statres = sceIoGetstat(check_path, &stat);
if (statres < 0 || SCE_S_ISDIR(stat.st_mode)) {
menu_more_entries[MENU_MORE_ENTRY_INSTALL_FOLDER].visibility = CTX_VISIBILITY_INVISIBLE;
break;
}
snprintf(check_path, MAX_PATH_LENGTH, "%s%s/sce_sys/param.sfo", file_list.path, file_entry->name);
statres = sceIoGetstat(check_path, &stat);
if (statres < 0 || SCE_S_ISDIR(stat.st_mode)) {
menu_more_entries[MENU_MORE_ENTRY_INSTALL_FOLDER].visibility = CTX_VISIBILITY_INVISIBLE;
break;
}
} while(0);
}
if(file_entry->type != FILE_TYPE_VPK) {
@ -867,6 +892,15 @@ int contextMenuMoreEnterCallback(int pos, void* context) {
break;
}
case MENU_MORE_ENTRY_INSTALL_FOLDER:
{
FileListEntry *file_entry = fileListGetNthEntry(&file_list, base_pos + rel_pos);
snprintf(cur_file, MAX_PATH_LENGTH, "%s%s", file_list.path, file_entry->name);
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_FOLDER_QUESTION]);
dialog_step = DIALOG_STEP_INSTALL_QUESTION;
break;
}
case MENU_MORE_ENTRY_EXPORT_MEDIA:
{
char *message;
@ -1210,6 +1244,7 @@ int dialogSteps() {
}
dialog_step = DIALOG_STEP_NONE;
refresh = 1;
}
break;

View File

@ -367,6 +367,8 @@ int install_thread(SceSize args_size, InstallArguments *args) {
int res;
SceUID thid = -1;
char path[MAX_PATH_LENGTH];
SceIoStat stat;
int isFolder = 0;
// Lock power timers
powerLock();
@ -379,6 +381,67 @@ int install_thread(SceSize args_size, InstallArguments *args) {
removePath(PACKAGE_PARENT, NULL);
sceIoMkdir(PACKAGE_PARENT, 0777);
res = sceIoGetstat(args->file, &stat);
if (res < 0) {
closeWaitDialog();
errorDialog(res);
goto EXIT;
}
if (SCE_S_ISDIR(stat.st_mode)) {
// Check for param.sfo
snprintf(path, MAX_PATH_LENGTH, "%s/sce_sys/param.sfo", args->file);
if (sceIoGetstat(path, &stat) < 0 || SCE_S_ISDIR(stat.st_mode)) {
closeWaitDialog();
errorDialog(-2);
goto EXIT;
}
// Check permissions
snprintf(path, MAX_PATH_LENGTH, "%s/eboot.bin", args->file);
SceUID fd = sceIoOpen(path, SCE_O_RDONLY, 0);
if (fd >= 0) {
char buffer[0x88];
sceIoRead(fd, buffer, sizeof(buffer));
sceIoClose(fd);
// Team molecule's request: Full permission access warning
uint64_t authid = *(uint64_t *)(buffer + 0x80);
if (authid == 0x2F00000000000001 || authid == 0x2F00000000000003) {
closeWaitDialog();
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_WARNING]);
dialog_step = DIALOG_STEP_INSTALL_WARNING;
// Wait for response
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
sceKernelDelayThread(10 * 1000);
}
// Cancelled
if (dialog_step == DIALOG_STEP_CANCELLED) {
closeWaitDialog();
goto EXIT;
}
// Init again
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALLING;
}
}
res = sceIoRename(args->file, PACKAGE_DIR);
if (res < 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
errorDialog(res);
goto EXIT;
}
sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 50);
sceKernelDelayThread(COUNTUP_WAIT);
isFolder = 1;
} else {
// Open archive
res = archiveOpen(args->file);
if (res < 0) {
@ -478,12 +541,15 @@ int install_thread(SceSize args_size, InstallArguments *args) {
errorDialog(res);
goto EXIT;
}
}
// Make head.bin
res = makeHeadBin();
if (res < 0) {
closeWaitDialog();
errorDialog(res);
// If failed, move package folder back
if (isFolder) sceIoRename(PACKAGE_DIR, args->file);
goto EXIT;
}
@ -492,6 +558,8 @@ int install_thread(SceSize args_size, InstallArguments *args) {
if (res < 0) {
closeWaitDialog();
errorDialog(res);
// If failed, move package folder back
if (isFolder) sceIoRename(PACKAGE_DIR, args->file);
goto EXIT;
}

View File

@ -46,6 +46,7 @@ DELETE = "Delete"
RENAME = "Rename"
NEW_FOLDER = "New folder"
INSTALL_ALL = "Install all"
INSTALL_FOLDER = "Install folder"
CALCULATE_SHA1 = "Calculate SHA1"
EXPORT_MEDIA = "Export media"
SEARCH = "Search"
@ -67,6 +68,7 @@ EXPORT_SONGS_INFO = "Exported %d song(s)."
EXPORT_PICTURES_INFO = "Exported %d picture(s)."
EXPORT_SONGS_PICTURES_INFO = "Exported %d song(s) and %d picture(s)."
INSTALL_ALL_QUESTION = "Do you want to install all packages available in this folder?"
INSTALL_FOLDER_QUESTION = "Do you want to install this folder?\Warning: this action will also delete the folder after installation!"
INSTALL_QUESTION = "Do you want to install this package?"
INSTALL_WARNING = "This package requests extended permissions.\It will have access to your personal information.\If you did not obtain it from a trusted source,\please proceed at your own caution.\\Would you like to continue the install?"
HASH_FILE_QUESTION = "SHA1 hashing may take a long time. Continue?"