Optimized some stuff

This commit is contained in:
TheFloW 2017-02-24 18:42:34 +01:00
parent 7369612d75
commit 5fceb7387f
12 changed files with 145 additions and 129 deletions

2
file.h
View File

@ -25,7 +25,7 @@
#define MAX_PATH_LENGTH 1024
#define MAX_NAME_LENGTH 256
#define MAX_SHORT_NAME_LENGTH 64
#define MAX_DIR_LEVELS 16
#define MAX_DIR_LEVELS 32
#define DIRECTORY_SIZE (4 * 1024)
#define TRANSFER_SIZE (64 * 1024)

View File

@ -140,7 +140,7 @@ int delete_thread(SceSize args_size, DeleteArguments *args) {
int res = removePath(path, &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -155,7 +155,7 @@ int delete_thread(SceSize args_size, DeleteArguments *args) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_DELETED;
setDialogStep(DIALOG_STEP_DELETED);
EXIT:
if (mark_entry_one)
@ -205,7 +205,7 @@ int copy_thread(SceSize args_size, CopyArguments *args) {
if (cancelHandler()) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
goto EXIT;
}
@ -219,7 +219,7 @@ int copy_thread(SceSize args_size, CopyArguments *args) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_MOVED;
setDialogStep(DIALOG_STEP_MOVED);
} else { // Copy
// Open archive, because when you copy from an archive, you leave the archive to paste
if (args->copy_mode == COPY_MODE_EXTRACT) {
@ -305,7 +305,7 @@ int copy_thread(SceSize args_size, CopyArguments *args) {
}
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -313,7 +313,7 @@ int copy_thread(SceSize args_size, CopyArguments *args) {
int res = copyPath(src_path, dst_path, &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -349,7 +349,7 @@ int copy_thread(SceSize args_size, CopyArguments *args) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_COPIED;
setDialogStep(DIALOG_STEP_COPIED);
}
EXIT:
@ -584,7 +584,7 @@ int export_thread(SceSize args_size, ExportArguments *args) {
int res = exportPath(path, &songs, &pictures, &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -650,7 +650,7 @@ int hash_thread(SceSize args_size, HashArguments *args) {
if (res <= 0) {
// SHA1 Didn't complete successfully, or was cancelled
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}

157
main.c
View File

@ -40,9 +40,13 @@
#include "sfo.h"
#include "coredump.h"
#include "archiveRAR.h"
#include "usb.h"
int _newlib_heap_size_user = 128 * 1024 * 1024;
// Dialog step
static volatile int dialog_step = DIALOG_STEP_NONE;
// File lists
FileList file_list, mark_list, copy_list, install_list;
@ -56,8 +60,8 @@ static char focus_name[MAX_NAME_LENGTH], compress_name[MAX_NAME_LENGTH];
// Position
int base_pos = 0, rel_pos = 0;
static int base_pos_list[MAX_DIR_LEVELS];
static int rel_pos_list[MAX_DIR_LEVELS];
static char base_pos_list[MAX_DIR_LEVELS];
static char rel_pos_list[MAX_DIR_LEVELS];
static int dir_level = 0;
// Modes
@ -67,7 +71,7 @@ int file_type = FILE_TYPE_UNKNOWN;
// Archive
static int is_in_archive = 0;
static int dir_level_archive = -1;
static char dir_level_archive = -1;
enum FileTypes archive_type = FILE_TYPE_ZIP;
// FTP
@ -76,20 +80,32 @@ static unsigned short int vita_port;
static SceUID usbdevice_modid = -1;
static SceKernelLwMutexWork dialog_mutex;
VitaShellConfig vitashell_config;
// Enter and cancel buttons
int SCE_CTRL_ENTER = SCE_CTRL_CROSS, SCE_CTRL_CANCEL = SCE_CTRL_CIRCLE;
// Dialog step
volatile int dialog_step = DIALOG_STEP_NONE;
// Use custom config
int use_custom_config = 1;
int getDialogStep() {
sceKernelLockLwMutex(&dialog_mutex, 1, NULL);
int step = dialog_step;
sceKernelUnlockLwMutex(&dialog_mutex, 1);
return step;
}
void setDialogStep(int step) {
sceKernelLockLwMutex(&dialog_mutex, 1, NULL);
dialog_step = step;
sceKernelUnlockLwMutex(&dialog_mutex, 1);
}
void dirLevelUp() {
base_pos_list[dir_level] = base_pos;
rel_pos_list[dir_level] = rel_pos;
base_pos_list[dir_level] = (char)base_pos;
rel_pos_list[dir_level] = (char)rel_pos;
dir_level++;
base_pos_list[dir_level] = 0;
rel_pos_list[dir_level] = 0;
@ -144,8 +160,8 @@ static void dirUp() {
dir_level = 0;
DIR_UP_RETURN:
base_pos = base_pos_list[dir_level];
rel_pos = rel_pos_list[dir_level];
base_pos = (int)base_pos_list[dir_level];
rel_pos = (int)rel_pos_list[dir_level];
dirUpCloseArchive();
}
@ -319,7 +335,7 @@ static int handleFile(const char *file, FileListEntry *entry) {
case FILE_TYPE_VPK:
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_QUESTION]);
dialog_step = DIALOG_STEP_INSTALL_QUESTION;
setDialogStep(DIALOG_STEP_INSTALL_QUESTION);
break;
case FILE_TYPE_ZIP:
@ -474,7 +490,7 @@ static void initUsb() {
powerLock();
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL, language_container[USB_CONNECTED]);
dialog_step = DIALOG_STEP_USB;
setDialogStep(DIALOG_STEP_USB);
} else {
errorDialog(usbdevice_modid);
}
@ -486,20 +502,20 @@ static int dialogSteps() {
int msg_result = updateMessageDialog();
int ime_result = updateImeDialog();
switch (dialog_step) {
switch (getDialogStep()) {
// Without refresh
case DIALOG_STEP_ERROR:
case DIALOG_STEP_INFO:
case DIALOG_STEP_SYSTEM:
if (msg_result == MESSAGE_DIALOG_RESULT_NONE || msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
case DIALOG_STEP_CANCELLED:
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
break;
case DIALOG_STEP_DELETED:
@ -512,7 +528,7 @@ static int dialogSteps() {
}
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -539,7 +555,7 @@ static int dialogSteps() {
strcpy(focus_name, name);
refresh = REFRESH_MODE_SETFOCUS;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -567,11 +583,11 @@ static int dialogSteps() {
strcpy(focus_name, copy_list.head->name);
// Empty copy list when moved
if (dialog_step == DIALOG_STEP_MOVED)
if (getDialogStep() == DIALOG_STEP_MOVED)
fileListEmpty(&copy_list);
refresh = REFRESH_MODE_SETFOCUS;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -585,7 +601,7 @@ static int dialogSteps() {
}
} else {
if (msg_result == MESSAGE_DIALOG_RESULT_NONE || msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
SceUID fd = sceIoOpen("sdstor0:uma-lp-act-entire", SCE_O_RDONLY, 0);
if (fd >= 0) {
@ -615,12 +631,12 @@ static int dialogSteps() {
}
} else {
if (msg_result == MESSAGE_DIALOG_RESULT_NONE || msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
// Dialog
if (ftpvita_is_initialized()) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL, language_container[FTP_SERVER], vita_ip, vita_port);
dialog_step = DIALOG_STEP_FTP;
setDialogStep(DIALOG_STEP_FTP);
} else {
powerUnlock();
}
@ -632,12 +648,12 @@ static int dialogSteps() {
case DIALOG_STEP_FTP:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
powerUnlock();
ftpvita_fini();
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -652,7 +668,7 @@ static int dialogSteps() {
}
} else {
if (msg_result == MESSAGE_DIALOG_RESULT_NONE || msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
SceUdcdDeviceState state;
sceUdcdGetDeviceState(&state);
@ -677,7 +693,7 @@ static int dialogSteps() {
powerUnlock();
stopUsb(usbdevice_modid);
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -691,7 +707,7 @@ static int dialogSteps() {
args.copy_mode = copy_mode;
args.file_type = file_type;
dialog_step = DIALOG_STEP_COPYING;
setDialogStep(DIALOG_STEP_COPYING);
SceUID thid = sceKernelCreateThread("copy_thread", (SceKernelThreadEntry)copy_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
@ -703,9 +719,9 @@ static int dialogSteps() {
case DIALOG_STEP_DELETE_QUESTION:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[DELETING]);
dialog_step = DIALOG_STEP_DELETE_CONFIRMED;
setDialogStep(DIALOG_STEP_DELETE_CONFIRMED);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -717,7 +733,7 @@ static int dialogSteps() {
args.mark_list = &mark_list;
args.index = base_pos + rel_pos;
dialog_step = DIALOG_STEP_DELETING;
setDialogStep(DIALOG_STEP_DELETING);
SceUID thid = sceKernelCreateThread("delete_thread", (SceKernelThreadEntry)delete_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
@ -729,9 +745,9 @@ static int dialogSteps() {
case DIALOG_STEP_EXPORT_QUESTION:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[EXPORTING]);
dialog_step = DIALOG_STEP_EXPORT_CONFIRMED;
setDialogStep(DIALOG_STEP_EXPORT_CONFIRMED);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -743,7 +759,7 @@ static int dialogSteps() {
args.mark_list = &mark_list;
args.index = base_pos + rel_pos;
dialog_step = DIALOG_STEP_EXPORTING;
setDialogStep(DIALOG_STEP_EXPORTING);
SceUID thid = sceKernelCreateThread("export_thread", (SceKernelThreadEntry)export_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
@ -756,7 +772,7 @@ static int dialogSteps() {
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
char *name = (char *)getImeDialogInputTextUTF8();
if (name[0] == '\0') {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else {
FileListEntry *file_entry = fileListGetNthEntry(&file_list, base_pos + rel_pos);
@ -765,7 +781,7 @@ static int dialogSteps() {
removeEndSlash(old_name);
if (strcasecmp(old_name, name) == 0) { // No change
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else {
char old_path[MAX_PATH_LENGTH];
char new_path[MAX_PATH_LENGTH];
@ -778,12 +794,12 @@ static int dialogSteps() {
errorDialog(res);
} else {
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
}
}
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -792,7 +808,7 @@ static int dialogSteps() {
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
char *name = (char *)getImeDialogInputTextUTF8();
if (name[0] == '\0') {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else {
char path[MAX_PATH_LENGTH];
snprintf(path, MAX_PATH_LENGTH, "%s%s", file_list.path, name);
@ -802,11 +818,11 @@ static int dialogSteps() {
errorDialog(res);
} else {
refresh = REFRESH_MODE_NORMAL;
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
}
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -815,15 +831,15 @@ static int dialogSteps() {
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
char *name = (char *)getImeDialogInputTextUTF8();
if (name[0] == '\0') {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else {
strcpy(compress_name, name);
initImeDialog(language_container[COMPRESSION_LEVEL], "6", 1, SCE_IME_TYPE_NUMBER, 0);
dialog_step = DIALOG_STEP_COMPRESS_LEVEL;
setDialogStep(DIALOG_STEP_COMPRESS_LEVEL);
}
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -832,7 +848,7 @@ static int dialogSteps() {
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
char *level = (char *)getImeDialogInputTextUTF8();
if (level[0] == '\0') {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else {
snprintf(cur_file, MAX_PATH_LENGTH, "%s%s", file_list.path, compress_name);
@ -844,14 +860,14 @@ static int dialogSteps() {
args.path = cur_file;
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[COMPRESSING]);
dialog_step = DIALOG_STEP_COMPRESSING;
setDialogStep(DIALOG_STEP_COMPRESSING);
SceUID thid = sceKernelCreateThread("compress_thread", (SceKernelThreadEntry)compress_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
sceKernelStartThread(thid, sizeof(CompressArguments), &args);
}
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -860,10 +876,10 @@ static int dialogSteps() {
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
// Throw up the progress bar, enter hashing state
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[HASHING]);
dialog_step = DIALOG_STEP_HASH_CONFIRMED;
setDialogStep(DIALOG_STEP_HASH_CONFIRMED);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
// Quit
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -879,7 +895,7 @@ static int dialogSteps() {
HashArguments args;
args.file_path = cur_file;
dialog_step = DIALOG_STEP_HASHING;
setDialogStep(DIALOG_STEP_HASHING);
// Create a thread to run out actual sum
SceUID thid = sceKernelCreateThread("hash_thread", (SceKernelThreadEntry)hash_thread, 0x40, 0x100000, 0, 0, NULL);
@ -892,9 +908,9 @@ static int dialogSteps() {
case DIALOG_STEP_INSTALL_QUESTION:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALL_CONFIRMED;
setDialogStep(DIALOG_STEP_INSTALL_CONFIRMED);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -917,7 +933,7 @@ static int dialogSteps() {
args.file = cur_file;
}
dialog_step = DIALOG_STEP_INSTALLING;
setDialogStep(DIALOG_STEP_INSTALLING);
SceUID thid = sceKernelCreateThread("install_thread", (SceKernelThreadEntry)install_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
@ -928,9 +944,9 @@ static int dialogSteps() {
case DIALOG_STEP_INSTALL_WARNING:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
dialog_step = DIALOG_STEP_INSTALL_WARNING_AGREED;
setDialogStep(DIALOG_STEP_INSTALL_WARNING_AGREED);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
}
break;
@ -939,11 +955,11 @@ static int dialogSteps() {
if (msg_result == MESSAGE_DIALOG_RESULT_NONE || msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
if (install_list.length > 0) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALL_CONFIRMED;
setDialogStep(DIALOG_STEP_INSTALL_CONFIRMED);
break;
}
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
refresh = REFRESH_MODE_NORMAL;
}
@ -952,16 +968,16 @@ static int dialogSteps() {
case DIALOG_STEP_UPDATE_QUESTION:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[DOWNLOADING]);
dialog_step = DIALOG_STEP_DOWNLOADING;
setDialogStep(DIALOG_STEP_DOWNLOADING);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
case DIALOG_STEP_DOWNLOADED:
if (msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_EXTRACTING;
setDialogStep(DIALOG_STEP_EXTRACTING);
SceUID thid = sceKernelCreateThread("update_extract_thread", (SceKernelThreadEntry)update_extract_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0)
@ -973,13 +989,13 @@ static int dialogSteps() {
case DIALOG_STEP_SETTINGS_AGREEMENT:
if (msg_result == MESSAGE_DIALOG_RESULT_YES) {
settingsAgree();
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else if (msg_result == MESSAGE_DIALOG_RESULT_NO) {
settingsDisagree();
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else if (msg_result == MESSAGE_DIALOG_RESULT_FINISHED) {
settingsAgree();
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
@ -991,16 +1007,16 @@ static int dialogSteps() {
strcpy((char *)getImeDialogInitialText(), string);
}
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
}
break;
case DIALOG_STEP_EXTRACTED:
launchAppByUriExit("VSUPDATER");
dialog_step = DIALOG_STEP_NONE;
setDialogStep(DIALOG_STEP_NONE);
break;
}
@ -1030,7 +1046,7 @@ static int fileBrowserMenuCtrl() {
initUsb();
} else {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL, language_container[USB_NOT_CONNECTED]);
dialog_step = DIALOG_STEP_USB_WAIT;
setDialogStep(DIALOG_STEP_USB_WAIT);
}
}
} else if (vitashell_config.select_button == SELECT_BUTTON_MODE_FTP) {
@ -1039,7 +1055,7 @@ static int fileBrowserMenuCtrl() {
int res = ftpvita_init(vita_ip, &vita_port);
if (res < 0) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL, language_container[PLEASE_WAIT]);
dialog_step = DIALOG_STEP_FTP_WAIT;
setDialogStep(DIALOG_STEP_FTP_WAIT);
} else {
initFtp();
}
@ -1051,7 +1067,7 @@ static int fileBrowserMenuCtrl() {
// Dialog
if (ftpvita_is_initialized()) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL, language_container[FTP_SERVER], vita_ip, vita_port);
dialog_step = DIALOG_STEP_FTP;
setDialogStep(DIALOG_STEP_FTP);
}
}
}
@ -1238,7 +1254,7 @@ static int shellMain() {
int refresh = REFRESH_MODE_NONE;
// Control
if (dialog_step != DIALOG_STEP_NONE) {
if (getDialogStep() != DIALOG_STEP_NONE) {
refresh = dialogSteps();
} else {
if (getSettingsMenuStatus() != SETTINGS_MENU_CLOSED) {
@ -1457,6 +1473,9 @@ void ftpvita_PROM(ftpvita_client_info_t *client) {
}
int main(int argc, const char *argv[]) {
// Create mutex
sceKernelCreateLwMutex(&dialog_mutex, "dialog_mutex", 2, 0, NULL);
// Init VitaShell
initVitaShell();

5
main.h
View File

@ -241,10 +241,11 @@ extern VitaShellConfig vitashell_config;
extern int SCE_CTRL_ENTER, SCE_CTRL_CANCEL;
extern volatile int dialog_step;
extern int use_custom_config;
int getDialogStep();
void setDialogStep(int step);
void drawScrollBar(int pos, int n);
void drawShellInfo(const char *path);

View File

@ -22,6 +22,7 @@
#include "context_menu.h"
#include "file.h"
#include "language.h"
#include "property_dialog.h"
#include "message_dialog.h"
#include "ime_dialog.h"
#include "utils.h"
@ -422,7 +423,7 @@ static int contextMenuHomeEnterCallback(int sel, void *context) {
refreshFileList();
} else {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL, language_container[USB_WAIT_ATTACH]);
dialog_step = DIALOG_STEP_USB_ATTACH_WAIT;
setDialogStep(DIALOG_STEP_USB_ATTACH_WAIT);
}
break;
@ -550,7 +551,7 @@ static int contextMenuMainEnterCallback(int sel, void *context) {
}
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[copy_text]);
dialog_step = DIALOG_STEP_PASTE;
setDialogStep(DIALOG_STEP_PASTE);
break;
}
@ -568,7 +569,7 @@ static int contextMenuMainEnterCallback(int sel, void *context) {
}
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, message);
dialog_step = DIALOG_STEP_DELETE_QUESTION;
setDialogStep(DIALOG_STEP_DELETE_QUESTION);
break;
}
@ -582,7 +583,7 @@ static int contextMenuMainEnterCallback(int sel, void *context) {
initImeDialog(language_container[RENAME], name, MAX_NAME_LENGTH, SCE_IME_TYPE_BASIC_LATIN, 0);
dialog_step = DIALOG_STEP_RENAME;
setDialogStep(DIALOG_STEP_RENAME);
break;
}
@ -617,7 +618,7 @@ static int contextMenuMainEnterCallback(int sel, void *context) {
}
initImeDialog(language_container[NEW_FOLDER], path + strlen(file_list.path), MAX_NAME_LENGTH, SCE_IME_TYPE_BASIC_LATIN, 0);
dialog_step = DIALOG_STEP_NEW_FOLDER;
setDialogStep(DIALOG_STEP_NEW_FOLDER);
break;
}
@ -700,7 +701,7 @@ static int contextMenuMoreEnterCallback(int sel, void *context) {
strcat(path, ".zip");
initImeDialog(language_container[ARCHIVE_NAME], path, MAX_NAME_LENGTH, SCE_IME_TYPE_BASIC_LATIN, 0);
dialog_step = DIALOG_STEP_COMPRESS_NAME;
setDialogStep(DIALOG_STEP_COMPRESS_NAME);
break;
}
@ -730,7 +731,7 @@ static int contextMenuMoreEnterCallback(int sel, void *context) {
strcpy(install_list.path, file_list.path);
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_ALL_QUESTION]);
dialog_step = DIALOG_STEP_INSTALL_QUESTION;
setDialogStep(DIALOG_STEP_INSTALL_QUESTION);
break;
}
@ -740,7 +741,7 @@ static int contextMenuMoreEnterCallback(int sel, void *context) {
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;
setDialogStep(DIALOG_STEP_INSTALL_QUESTION);
break;
}
@ -758,7 +759,7 @@ static int contextMenuMoreEnterCallback(int sel, void *context) {
}
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, message);
dialog_step = DIALOG_STEP_EXPORT_QUESTION;
setDialogStep(DIALOG_STEP_EXPORT_QUESTION);
break;
}
@ -766,7 +767,7 @@ static int contextMenuMoreEnterCallback(int sel, void *context) {
{
// Ensure user wants to actually take the hash
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[HASH_FILE_QUESTION]);
dialog_step = DIALOG_STEP_HASH_QUESTION;
setDialogStep(DIALOG_STEP_HASH_QUESTION);
break;
}
}

View File

@ -307,7 +307,7 @@ int compress_thread(SceSize args_size, CompressArguments *args) {
int res = makeZip(args->path, path, strlen(args->file_list->path), args->level, i == 0 ? APPEND_STATUS_CREATE : APPEND_STATUS_ADDINZIP, &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -322,7 +322,7 @@ int compress_thread(SceSize args_size, CompressArguments *args) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_COMPRESSED;
setDialogStep(DIALOG_STEP_COMPRESSED);
EXIT:
if (mark_entry_one)

View File

@ -213,7 +213,7 @@ static int downloadProcess(char *version_string) {
int res = downloadFile(url, VITASHELL_UPDATE_FILE, &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -225,7 +225,7 @@ static int downloadProcess(char *version_string) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_DOWNLOADED;
setDialogStep(DIALOG_STEP_DOWNLOADED);
EXIT:
if (thid >= 0)
@ -252,7 +252,7 @@ int network_update_thread(SceSize args, void *argp) {
sceIoRemove(VITASHELL_VERSION_FILE);
// Only show update question if no dialog is running
if (dialog_step == DIALOG_STEP_NONE) {
if (getDialogStep() == DIALOG_STEP_NONE) {
// New update available
if (version > VITASHELL_VERSION) {
int major = (version >> 0x18) & 0xFF;
@ -265,15 +265,15 @@ int network_update_thread(SceSize args, void *argp) {
// Update question
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[UPDATE_QUESTION], version_string);
dialog_step = DIALOG_STEP_UPDATE_QUESTION;
setDialogStep(DIALOG_STEP_UPDATE_QUESTION);
// Wait for response
while (dialog_step == DIALOG_STEP_UPDATE_QUESTION) {
while (getDialogStep() == DIALOG_STEP_UPDATE_QUESTION) {
sceKernelDelayThread(10 * 1000);
}
// No
if (dialog_step == DIALOG_STEP_NONE) {
if (getDialogStep() == DIALOG_STEP_NONE) {
goto EXIT;
}
@ -354,7 +354,7 @@ int update_extract_thread(SceSize args, void *argp) {
res = extractArchivePath(src_path, PACKAGE_DIR "/", &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -377,7 +377,7 @@ int update_extract_thread(SceSize args, void *argp) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_EXTRACTED;
setDialogStep(DIALOG_STEP_EXTRACTED);
EXIT:
if (thid >= 0)

View File

@ -375,29 +375,29 @@ int install_thread(SceSize args_size, InstallArguments *args) {
closeWaitDialog();
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_WARNING]);
dialog_step = DIALOG_STEP_INSTALL_WARNING;
setDialogStep(DIALOG_STEP_INSTALL_WARNING);
// Wait for response
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
while (getDialogStep() == DIALOG_STEP_INSTALL_WARNING) {
sceKernelDelayThread(10 * 1000);
}
// Cancelled
if (dialog_step == DIALOG_STEP_CANCELLED) {
if (getDialogStep() == DIALOG_STEP_CANCELLED) {
closeWaitDialog();
goto EXIT;
}
// Init again
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALLING;
setDialogStep(DIALOG_STEP_INSTALLING);
}
}
res = sceIoRename(args->file, PACKAGE_DIR);
if (res < 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -419,7 +419,7 @@ int install_thread(SceSize args_size, InstallArguments *args) {
// So terminate now
if (cancelHandler()) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
goto EXIT;
}
@ -437,22 +437,22 @@ int install_thread(SceSize args_size, InstallArguments *args) {
closeWaitDialog();
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[unsafe == 2 ? INSTALL_BRICK_WARNING : INSTALL_WARNING]);
dialog_step = DIALOG_STEP_INSTALL_WARNING;
setDialogStep(DIALOG_STEP_INSTALL_WARNING);
// Wait for response
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
while (getDialogStep() == DIALOG_STEP_INSTALL_WARNING) {
sceKernelDelayThread(10 * 1000);
}
// Cancelled
if (dialog_step == DIALOG_STEP_CANCELLED) {
if (getDialogStep() == DIALOG_STEP_CANCELLED) {
closeWaitDialog();
goto EXIT;
}
// Init again
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALLING;
setDialogStep(DIALOG_STEP_INSTALLING);
}
// Src path
@ -484,7 +484,7 @@ int install_thread(SceSize args_size, InstallArguments *args) {
res = extractArchivePath(src_path, PACKAGE_DIR "/", &param);
if (res <= 0) {
closeWaitDialog();
dialog_step = DIALOG_STEP_CANCELLED;
setDialogStep(DIALOG_STEP_CANCELLED);
errorDialog(res);
goto EXIT;
}
@ -525,7 +525,7 @@ int install_thread(SceSize args_size, InstallArguments *args) {
// Close
sceMsgDialogClose();
dialog_step = DIALOG_STEP_INSTALLED;
setDialogStep(DIALOG_STEP_INSTALLED);
EXIT:
if (thid >= 0)

View File

@ -352,7 +352,7 @@ void settingsMenuCtrl() {
if (option->name == HENKAKU_ENABLE_UNSAFE_HOMEBREW) {
if (*(option->value) == 0) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK, language_container[HENKAKU_UNSAFE_HOMEBREW_MESSAGE]);
dialog_step = DIALOG_STEP_SETTINGS_AGREEMENT;
setDialogStep(DIALOG_STEP_SETTINGS_AGREEMENT);
} else {
*(option->value) = !*(option->value);
}
@ -364,7 +364,7 @@ void settingsMenuCtrl() {
case SETTINGS_OPTION_TYPE_STRING:
initImeDialog(language_container[option->name], option->string, option->size_string, SCE_IME_TYPE_EXTENDED_NUMBER, 0);
dialog_step = DIALOG_STEP_SETTINGS_STRING;
setDialogStep(DIALOG_STEP_SETTINGS_STRING);
break;
case SETTINGS_OPTION_TYPE_CALLBACK:

4
usb.c
View File

@ -21,7 +21,7 @@
#include "file.h"
#include "utils.h"
int remount_thread(SceSize args, void *argp) {
static int remount_thread(SceSize args, void *argp) {
remount(0x800);
return sceKernelExitDeleteThread(0);
}
@ -29,7 +29,7 @@ int remount_thread(SceSize args, void *argp) {
void remountRelaunch(char * const argv[]) {
SceUID thid = sceKernelCreateThread("remount_thread", (SceKernelThreadEntry)remount_thread, 0x40, 0x1000, 0, 0, NULL);
if (thid >= 0)
sceKernelStartThread(thid, 0, NULL);
sceKernelStartThread(thid, 0, NULL);
sceAppMgrLoadExec("app0:eboot.bin", argv, NULL);
}

14
utils.c
View File

@ -70,7 +70,7 @@ void closeWaitDialog() {
void errorDialog(int error) {
if (error < 0) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK, language_container[ERROR], error);
dialog_step = DIALOG_STEP_ERROR;
setDialogStep(DIALOG_STEP_ERROR);
}
}
@ -83,7 +83,7 @@ void infoDialog(const char *msg, ...) {
va_end(list);
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK, string);
dialog_step = DIALOG_STEP_INFO;
setDialogStep(DIALOG_STEP_INFO);
}
int checkMemoryCardFreeSpace(uint64_t size) {
@ -346,10 +346,8 @@ int vshIoMount(int id, const char *path, int permission, int a4, int a5, int a6)
return _vshIoMount(id, path, permission, buf);
}
int remount(int id) {
int res = vshIoUmount(id, 0, 0, 0);
if (res < 0 && res != 0x80010002)
return res;
return vshIoMount(id, NULL, 0, 0, 0, 0);
void remount(int id) {
vshIoUmount(id, 0, 0, 0);
vshIoUmount(id, 1, 0, 0);
vshIoMount(id, NULL, 0, 0, 0, 0);
}

View File

@ -87,9 +87,6 @@ char *strcasestr(const char *haystack, const char *needle);
int vshIoUmount(int id, int a2, int a3, int a4);
int _vshIoMount(int id, const char *path, int permission, void *buf);
int vshIoMount(int id, const char *path, int permission, int a4, int a5, int a6);
int remount(int id);
SceUID startUsb(const char *usbDevicePath, const char *imgFilePath, int type);
int stopUsb(SceUID modid);
void remount(int id);
#endif