MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / network_update_thread

Function network_update_thread

network_update.c:40–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38extern unsigned char _binary_resources_updater_param_bin_size;
39
40int network_update_thread(SceSize args, void *argp) {
41 uint64_t size = 0;
42 if (getDownloadFileSize(BASE_ADDRESS VERSION_URL, &size) >= 0 && size == sizeof(uint32_t)) {
43 int res = downloadFile(BASE_ADDRESS VERSION_URL, VITASHELL_VERSION_FILE, NULL);
44 if (res <= 0)
45 goto EXIT;
46
47 // Read version
48 uint32_t version = 0;
49 ReadFile(VITASHELL_VERSION_FILE, &version, sizeof(uint32_t));
50 sceIoRemove(VITASHELL_VERSION_FILE);
51
52 // Only show update question if no dialog is running
53 if (getDialogStep() == DIALOG_STEP_NONE) {
54 // New update available
55 if (version > VITASHELL_VERSION) {
56 int major = (version >> 0x18) & 0xFF;
57 int minor = (version >> 0x10) & 0xFF;
58
59 char version_string[8];
60 sprintf(version_string, "%X.%02X", major, minor);
61 if (version_string[3] == '0')
62 version_string[3] = '\0';
63
64 // Update question
65 initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[UPDATE_QUESTION], version_string);
66 setDialogStep(DIALOG_STEP_UPDATE_QUESTION);
67
68 // Wait for response
69 while (getDialogStep() == DIALOG_STEP_UPDATE_QUESTION) {
70 sceKernelDelayThread(10 * 1000);
71 }
72
73 // No
74 if (getDialogStep() == DIALOG_STEP_NONE) {
75 goto EXIT;
76 }
77
78 // Yes
79 return downloadFileProcess(BASE_ADDRESS "/VitaShell.vpk", VITASHELL_UPDATE_FILE, DIALOG_STEP_DOWNLOADED);
80 }
81 }
82 }
83
84EXIT:
85 return sceKernelExitDeleteThread(0);
86}
87
88void installUpdater() {
89 // Recursively clean up pkg directory

Callers

nothing calls this directly

Calls 7

getDownloadFileSizeFunction · 0.85
downloadFileFunction · 0.85
ReadFileFunction · 0.85
getDialogStepFunction · 0.85
initMessageDialogFunction · 0.85
setDialogStepFunction · 0.85
downloadFileProcessFunction · 0.85

Tested by

no test coverage detected