mirror of
https://github.com/joel16/VitaShell.git
synced 2024-11-23 19:59:42 +00:00
Merge pull request #99 from soarqin/master
Added folder installation function in 'More...' menu
This commit is contained in:
commit
ab377d26c1
@ -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),
|
||||
|
@ -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
35
main.c
@ -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) {
|
||||
@ -866,6 +891,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:
|
||||
{
|
||||
@ -1210,6 +1244,7 @@ int dialogSteps() {
|
||||
}
|
||||
|
||||
dialog_step = DIALOG_STEP_NONE;
|
||||
refresh = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -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,104 +381,166 @@ int install_thread(SceSize args_size, InstallArguments *args) {
|
||||
removePath(PACKAGE_PARENT, NULL);
|
||||
sceIoMkdir(PACKAGE_PARENT, 0777);
|
||||
|
||||
// Open archive
|
||||
res = archiveOpen(args->file);
|
||||
res = sceIoGetstat(args->file, &stat);
|
||||
if (res < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// If you cancelled at the time archiveOpen was working,
|
||||
// it would still open the full permission dialog instead of termiating.
|
||||
// So terminate now
|
||||
if (cancelHandler()) {
|
||||
closeWaitDialog();
|
||||
dialog_step = DIALOG_STEP_CANCELLED;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Check for param.sfo
|
||||
snprintf(path, MAX_PATH_LENGTH, "%s/sce_sys/param.sfo", args->file);
|
||||
if (archiveFileGetstat(path, NULL) < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(-2);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
snprintf(path, MAX_PATH_LENGTH, "%s/eboot.bin", args->file);
|
||||
SceUID fd = archiveFileOpen(path, SCE_O_RDONLY, 0);
|
||||
if (fd >= 0) {
|
||||
char buffer[0x88];
|
||||
archiveFileRead(fd, buffer, sizeof(buffer));
|
||||
archiveFileClose(fd);
|
||||
|
||||
// Team molecule's request: Full permission access warning
|
||||
uint64_t authid = *(uint64_t *)(buffer + 0x80);
|
||||
if (authid == 0x2F00000000000001 || authid == 0x2F00000000000003) {
|
||||
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();
|
||||
|
||||
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;
|
||||
errorDialog(-2);
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
// Src path
|
||||
char src_path[MAX_PATH_LENGTH];
|
||||
strcpy(src_path, args->file);
|
||||
addEndSlash(src_path);
|
||||
// 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);
|
||||
|
||||
// Get archive path info
|
||||
uint64_t size = 0;
|
||||
uint32_t folders = 0, files = 0;
|
||||
getArchivePathInfo(src_path, &size, &folders, &files);
|
||||
// Team molecule's request: Full permission access warning
|
||||
uint64_t authid = *(uint64_t *)(buffer + 0x80);
|
||||
if (authid == 0x2F00000000000001 || authid == 0x2F00000000000003) {
|
||||
closeWaitDialog();
|
||||
|
||||
// Check memory card free space
|
||||
if (checkMemoryCardFreeSpace(size))
|
||||
goto EXIT;
|
||||
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_WARNING]);
|
||||
dialog_step = DIALOG_STEP_INSTALL_WARNING;
|
||||
|
||||
// Update thread
|
||||
thid = createStartUpdateThread(size + folders);
|
||||
// Wait for response
|
||||
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
|
||||
sceKernelDelayThread(10 * 1000);
|
||||
}
|
||||
|
||||
// Extract process
|
||||
uint64_t value = 0;
|
||||
// Cancelled
|
||||
if (dialog_step == DIALOG_STEP_CANCELLED) {
|
||||
closeWaitDialog();
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
FileProcessParam param;
|
||||
param.value = &value;
|
||||
param.max = size + folders;
|
||||
param.SetProgress = SetProgress;
|
||||
param.cancelHandler = cancelHandler;
|
||||
// Init again
|
||||
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
|
||||
dialog_step = DIALOG_STEP_INSTALLING;
|
||||
}
|
||||
}
|
||||
|
||||
res = extractArchivePath(src_path, PACKAGE_DIR "/", ¶m);
|
||||
if (res <= 0) {
|
||||
closeWaitDialog();
|
||||
dialog_step = DIALOG_STEP_CANCELLED;
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
}
|
||||
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);
|
||||
|
||||
// Close archive
|
||||
res = archiveClose();
|
||||
if (res < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
isFolder = 1;
|
||||
} else {
|
||||
// Open archive
|
||||
res = archiveOpen(args->file);
|
||||
if (res < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// If you cancelled at the time archiveOpen was working,
|
||||
// it would still open the full permission dialog instead of termiating.
|
||||
// So terminate now
|
||||
if (cancelHandler()) {
|
||||
closeWaitDialog();
|
||||
dialog_step = DIALOG_STEP_CANCELLED;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Check for param.sfo
|
||||
snprintf(path, MAX_PATH_LENGTH, "%s/sce_sys/param.sfo", args->file);
|
||||
if (archiveFileGetstat(path, NULL) < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(-2);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
snprintf(path, MAX_PATH_LENGTH, "%s/eboot.bin", args->file);
|
||||
SceUID fd = archiveFileOpen(path, SCE_O_RDONLY, 0);
|
||||
if (fd >= 0) {
|
||||
char buffer[0x88];
|
||||
archiveFileRead(fd, buffer, sizeof(buffer));
|
||||
archiveFileClose(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;
|
||||
}
|
||||
}
|
||||
|
||||
// Src path
|
||||
char src_path[MAX_PATH_LENGTH];
|
||||
strcpy(src_path, args->file);
|
||||
addEndSlash(src_path);
|
||||
|
||||
// Get archive path info
|
||||
uint64_t size = 0;
|
||||
uint32_t folders = 0, files = 0;
|
||||
getArchivePathInfo(src_path, &size, &folders, &files);
|
||||
|
||||
// Check memory card free space
|
||||
if (checkMemoryCardFreeSpace(size))
|
||||
goto EXIT;
|
||||
|
||||
// Update thread
|
||||
thid = createStartUpdateThread(size + folders);
|
||||
|
||||
// Extract process
|
||||
uint64_t value = 0;
|
||||
|
||||
FileProcessParam param;
|
||||
param.value = &value;
|
||||
param.max = size + folders;
|
||||
param.SetProgress = SetProgress;
|
||||
param.cancelHandler = cancelHandler;
|
||||
|
||||
res = extractArchivePath(src_path, PACKAGE_DIR "/", ¶m);
|
||||
if (res <= 0) {
|
||||
closeWaitDialog();
|
||||
dialog_step = DIALOG_STEP_CANCELLED;
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Close archive
|
||||
res = archiveClose();
|
||||
if (res < 0) {
|
||||
closeWaitDialog();
|
||||
errorDialog(res);
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
// Make head.bin
|
||||
@ -484,6 +548,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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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?"
|
||||
@ -80,4 +82,4 @@ FTP_SERVER = "FTP server is now running at\ftp://%s:%i
|
||||
SYS_INFO = "System software: %s\Model: 0x%08X\MAC address: %s\IP address: %s\Memory card: %s/%s\Battery level: %d%%"
|
||||
UPDATE_QUESTION = "VitaShell %s is now available.\\Do you want to update the application?"
|
||||
TOOLBOX = "Toolbox"
|
||||
SYSINFO_TITLE = "System Information"
|
||||
SYSINFO_TITLE = "System Information"
|
||||
|
Loading…
Reference in New Issue
Block a user