static inline bool LatestVersion(int *major, int *minor, int *current_line) { u32 http_status = 0; u8* outbuf = NULL; u32 filesize; int line = *current_line; PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, Downloads[DOWNLOAD_VERSION].text); UpdateScreen(); line++; if(!http_request(Downloads[DOWNLOAD_VERSION].url, Downloads[DOWNLOAD_VERSION].max_size)) { PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Failed to retrieve version"); UpdateScreen(); *current_line = line; return false; } http_get_result(&http_status, &outbuf, &filesize); if (((int)*outbuf & 0xF0000000) == 0xF0000000) { if (outbuf != NULL) free(outbuf); *current_line = line; return false; } sscanf((char*)outbuf, " #ifndef %*s #define %*s #define NIN_MAJOR_VERSION %i #define NIN_MINOR_VERSION %i", major, minor); gprintf("major = %i, minor = %i\r\n", *major, *minor); if (outbuf != NULL) free(outbuf); if ((*major <= NIN_MAJOR_VERSION) && (*minor <= NIN_MINOR_VERSION)) { bool still_download = true; PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "You already have the latest version"); line++; PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Download anyway? (A: Yes, B: No)"); line++; UpdateScreen(); while(true) { DrawBuffer(); FPAD_Update(); if (FPAD_Cancel(0)) { gprintf("Cancelling download\n"); still_download = false; break; } if (FPAD_OK(0)) { gprintf("okay\n"); break; } GRRLIB_Render(); } if(!still_download) { *current_line = line; return false; } } *current_line = line; return (*major + *minor) > 0; }
void UpdateNintendont(void) { int selected = 0; u64 delay = ticks_to_millisecs(gettime()) + 500; while(true) { ClearScreen(); PrintInfo(); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*5, "Download Nintendont"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*6, "Download titles.txt"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*7, "Download controllers.zip"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*8, "Return to Settings"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 35, MENU_POS_Y + 20*(5+selected), ARROW_RIGHT); GRRLIB_Render(); FPAD_Update(); if (delay > ticks_to_millisecs(gettime())) continue; if (FPAD_Start(1)) { ClearScreen(); PrintFormat(DEFAULT_SIZE, BLACK, 212, 232, "Returning to loader..."); ExitToLoader(0); } if (FPAD_OK(1)) { if (selected <= DOWNLOAD_CONTROLLERS) Download(selected); else break; } if (FPAD_Down(1)) { delay = ticks_to_millisecs(gettime()) + 150; selected++; if (selected > 3) selected = 0; } if (FPAD_Up(1)) { delay = ticks_to_millisecs(gettime()) + 150; selected--; if (selected < 0) selected = 3; } if (FPAD_Cancel(1)) { break; } } ClearScreen(); return; }