diff --git a/CMakeLists.txt b/CMakeLists.txt index e264283..2aac744 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include("${VITASDK}/share/vita.cmake" REQUIRED) set(VITA_APP_NAME "EasyVPK") set(VITA_TITLEID "ESVPK0009") -set(VITA_VERSION "01.20") +set(VITA_VERSION "01.21") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-psabi -std=c++17 -fpermissive") diff --git a/sce_sys/livearea/contents/template.xml b/sce_sys/livearea/contents/template.xml index f05bd58..228fc10 100644 --- a/sce_sys/livearea/contents/template.xml +++ b/sce_sys/livearea/contents/template.xml @@ -28,7 +28,7 @@ - v1.2.0 + v1.2.1 diff --git a/src/main.cpp b/src/main.cpp index be916dd..28f6097 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,8 +34,8 @@ static int callback(void *data, int argc, char **argv, char **column_name) { return 0; } -void initSceAppUtil() -{ +void initSceAppUtil() { + // Init SceAppUtil SceAppUtilInitParam init_param; SceAppUtilBootParam boot_param; @@ -65,9 +65,8 @@ int getAppData(vector &ret) { sqlite3_rw_init(); int rc = sqlite3_open_v2("ur0:shell/db/app.db", &db, SQLITE_OPEN_READONLY, NULL); - if(rc != SQLITE_OK) { + if (rc != SQLITE_OK) return -1; - } sqlite3_exec(db, "SELECT titleId, title, iconPath FROM tbl_appinfo_icon WHERE NOT titleId=\"NULL\" ORDER BY title ASC", callback, &ret, NULL); @@ -92,7 +91,7 @@ int main() { httpInit(); netInit(); - curlDownload("http://rinnegatamante.it/vitadb/list_hbs_json.php", "ux0:data/Easy_VPK/vpks.json"); + curlDownload("https://vitadb.rinnegatamante.it/list_hbs_json.json", "ux0:data/Easy_VPK/vpks.json"); SharedData sharedData; @@ -115,10 +114,10 @@ int main() { vita2d_draw_texture(bgIMG, 0, 0); - if (pad.buttons != SCE_CTRL_CROSS) sharedData.blockCross = false; + if (pad.buttons != SCE_CTRL_CROSS ) sharedData.blockCross = false; if (pad.buttons != SCE_CTRL_SQUARE) sharedData.blockSquare = false; if (pad.buttons != SCE_CTRL_CIRCLE) sharedData.blockCircle = false; - if (pad.buttons != SCE_CTRL_START) sharedData.blockStart = false; + if (sharedData.scene == 0) listView.draw(sharedData, pad.buttons); @@ -140,11 +139,11 @@ int main() { vita2d_free_font(sharedData.font); vita2d_free_texture(bgIMG); - for (int i=0; i screenshots; diff --git a/src/net/download.cpp b/src/net/download.cpp index 6616882..e4aae60 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -70,6 +70,7 @@ void curlDownload(const char *url, const char *dest) { if(curl) { curl_easy_reset(curl); curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); @@ -86,7 +87,7 @@ void curlDownload(const char *url, const char *dest) { } std::string curlDownloadKeepName(char const*const url, std::string dst) { - CURL *curl; + CURL *curl; SceUID file = sceIoOpen("ux0:data/Easy_VPK/plugin.tmp", SCE_O_CREAT | SCE_O_WRONLY, 0777); SceUID head = sceIoOpen("ux0:data/Easy_VPK/head.tmp", SCE_O_CREAT | SCE_O_WRONLY, 0777); @@ -115,18 +116,15 @@ std::string curlDownloadKeepName(char const*const url, std::string dst) { std::string header = Filesystem::readFile("ux0:data/Easy_VPK/head.tmp"); - if(header.find("filename=\"") != string::npos) { + if (header.find("filename=\"") != string::npos) { header = header.substr(header.find("filename=\"")+10); - header = header.substr(0, header.find("\"")); - } - else if (header.find("location: ") != string::npos) { + } else if (header.find("location: ") != string::npos) { header = header.substr(header.find("location: ")+10); header = header.substr(0, header.find("\n")-1); - while(header.find("/") != string::npos) { + while (header.find("/") != string::npos) header = header.substr(header.find("/")+1); - } } Filesystem::copyFile("ux0:data/Easy_VPK/plugin.tmp", dst+header); diff --git a/src/screens/popup.cpp b/src/screens/popup.cpp index 158742d..3786304 100644 --- a/src/screens/popup.cpp +++ b/src/screens/popup.cpp @@ -64,15 +64,17 @@ char *bytes_string; static CURL *curl_handle = NULL; -static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) -{ - if (abort_download) return -1; +static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) { + + if (abort_download) + return -1; + downloaded_bytes += size * nmemb; return fwrite(ptr, size, nmemb, fh); } -static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata) -{ +static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata) { + if (total_bytes == 0xFFFFFFFF) { char *ptr = strcasestr(buffer, "Content-Length"); if (ptr != NULL) { @@ -81,12 +83,13 @@ static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata abort_download = 1; } } + return nitems * size; } static char asyncUrl[512]; -static void resumeDownload() -{ +static void resumeDownload() { + curl_easy_reset(curl_handle); curl_easy_setopt(curl_handle, CURLOPT_URL, asyncUrl); curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L); @@ -103,11 +106,14 @@ static void resumeDownload() curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, bytes_string); // Dummy curl_easy_setopt(curl_handle, CURLOPT_RESUME_FROM, downloaded_bytes); curl_easy_setopt(curl_handle, CURLOPT_BUFFERSIZE, 524288); + struct curl_slist *headerchunk = NULL; + headerchunk = curl_slist_append(headerchunk, "Accept: */*"); headerchunk = curl_slist_append(headerchunk, "Content-Type: application/json"); headerchunk = curl_slist_append(headerchunk, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); headerchunk = curl_slist_append(headerchunk, "Content-Length: 0"); + curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headerchunk); curl_easy_perform(curl_handle); } @@ -180,7 +186,7 @@ static int downloader_main(unsigned int args, void* arg) { sprintf(base_dir, dl_dir.c_str()); vita2d_init(); - vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF)); + vita2d_set_clear_color(RGBA8(0, 0, 0, 255)); pgf = vita2d_load_default_pgf(); @@ -221,17 +227,16 @@ static int downloader_main(unsigned int args, void* arg) { launchDownload(d_url.c_str()); if (state > DOWNLOADING) { - //if (state >= FINISHED) vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Press X to exit."); if (state >= FINISHED) { if (install_state) vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Finished!\nPress O to exit."); else vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Press X to install. (May take several minutes)\nPress O to Exit"); } if (state < MISSING) - vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(0,255,0,255), 1.0f, "Pack downloaded successfully! (%.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)]); + vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(0,255,0,255), 1.0f, "Files downloaded successfully! (%.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)]); if (state < FINISHED) { - vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Extracting pack, please wait!"); + vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Extracting files, please wait!"); vita2d_pgf_draw_textf(pgf, 20, 300, RGBA8(255,255,255,255), 1.0f, "File: %lu / %lu", zip_idx, zip_total); vita2d_pgf_draw_textf(pgf, 20, 320, RGBA8(255,255,255,255), 1.0f, "Filename: %s", fname); vita2d_pgf_draw_textf(pgf, 20, 340, RGBA8(255,255,255,255), 1.0f, "Filesize: (%.2f %s / %.2f %s)", format(curr_extracted_bytes), sizes[quota(curr_extracted_bytes)], format(file_info.uncompressed_size), sizes[quota(file_info.uncompressed_size)]); @@ -262,8 +267,9 @@ static int downloader_main(unsigned int args, void* arg) { unzGetCurrentFileInfo(zipfile, &file_info, fname, 512, NULL, 0, NULL, 0); sprintf(filename, "%s%s", base_dir, fname); const size_t filename_length = strlen(filename); - if (filename[filename_length - 1] == '/') sceIoMkdir(filename, 0777); - else { + if (filename[filename_length - 1] == '/') { + sceIoMkdir(filename, 0777); + } else { unzOpenCurrentFile(zipfile); f = fopen(filename, "wb"); extract_started = 1; @@ -299,8 +305,10 @@ static int downloader_main(unsigned int args, void* arg) { } else if (state == ERROR) { vita2d_pgf_draw_text(pgf, 20, 200, RGBA8(255,0,0,255), 1.0f, "ERROR: Not enough free space on ux0..."); vita2d_pgf_draw_textf(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Please free %.2f %s and restart this core!", format(total_bytes * 2 - free_storage), sizes[quota(total_bytes * 2 - free_storage)]); - } else if (state == FINISHED) vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(0,255,0,255), 1.0f, "Pack extracted succesfully!"); - } else vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(255,255,255,255), 1.0f, "Downloading pack, please wait. (%.2f %s / %.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)], format(total_bytes), sizes[quota(total_bytes)]); + } else if (state == FINISHED) { + vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(0,255,0,255), 1.0f, "Files extracted succesfully!"); + } + } else vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(255,255,255,255), 1.0f, "Downloading files, please wait. (%.2f %s / %.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)], format(total_bytes), sizes[quota(total_bytes)]); vita2d_end_drawing(); vita2d_swap_buffers(); diff --git a/src/utils/vitaPackage.cpp b/src/utils/vitaPackage.cpp index ae128ae..d7db2cc 100644 --- a/src/utils/vitaPackage.cpp +++ b/src/utils/vitaPackage.cpp @@ -15,19 +15,8 @@ #include #include -#define VHBB_DATA "ux0:/data/VitaHbBrowser" -#define VHBB_RESOURCES "ux0:/app/ESVPK0009/resources" - - #define ntohl __builtin_bswap32 -#define UPDATER_SRC_EBOOT_PATH VHBB_RESOURCES "/updater/eboot.bin" -#define UPDATER_SRC_SFO_PATH VHBB_RESOURCES "/updater/param.sfo" - -#define UPDATER_DST_EBOOT_PATH PACKAGE_TEMP_FOLDER "eboot.bin" -#define UPDATER_DST_SFO_DIR PACKAGE_TEMP_FOLDER "sce_sys/" -#define UPDATER_DST_SFO_PATH PACKAGE_TEMP_FOLDER "sce_sys/param.sfo" - extern unsigned char _binary_assets_head_bin_start; extern unsigned char _binary_assets_head_bin_size; diff --git a/src/utils/vitaPackage.h b/src/utils/vitaPackage.h index 37c961b..60be205 100644 --- a/src/utils/vitaPackage.h +++ b/src/utils/vitaPackage.h @@ -23,7 +23,7 @@ class VitaPackage{ class UpdaterPackage : private VitaPackage { public: - UpdaterPackage() : VitaPackage("VHBBUpdater") {}; + UpdaterPackage() : VitaPackage("EasyVPKUpdater") {}; int InstallUpdater(); };