mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Add support for installing 3DSX apps from TitleDB.
This commit is contained in:
parent
8d4748b526
commit
1989c8a6bd
@ -19,7 +19,7 @@ static void action_update_titledb_finished(void* data) {
|
||||
|
||||
void action_install_titledb(linked_list* items, list_item* selected) {
|
||||
char url[64];
|
||||
snprintf(url, INSTALL_URL_MAX, "https://3ds.titledb.com/v1/cia/%lu/download", ((titledb_info*) selected->data)->id);
|
||||
snprintf(url, INSTALL_URL_MAX, "https://3ds.titledb.com/v1/%s/%lu/download", ((titledb_info*) selected->data)->type == TITLEDB_TYPE_CIA ? "cia" : "tdsx", ((titledb_info*) selected->data)->id);
|
||||
|
||||
action_install_url("Install the selected title from TitleDB?", url, NULL, selected, action_update_titledb_finished, action_install_titledb_draw_top);
|
||||
}
|
@ -49,7 +49,7 @@ void action_update_titledb(linked_list* items, list_item* selected) {
|
||||
|
||||
if(info->installed && info->installedVersion < info->latestVersion) {
|
||||
linked_list_add(updates, item);
|
||||
pos += snprintf(urls + pos, (INSTALL_URL_MAX * INSTALL_URLS_MAX) - pos, "https://3ds.titledb.com/v1/cia/%lu/download\n", info->id);
|
||||
pos += snprintf(urls + pos, (INSTALL_URL_MAX * INSTALL_URLS_MAX) - pos, "https://3ds.titledb.com/v1/%s/%lu/download\n", info->type == TITLEDB_TYPE_CIA ? "cia" : "tdsx", info->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,11 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
u32 maxTextSize = 256 * 1024;
|
||||
char* text = (char*) calloc(sizeof(char), maxTextSize);
|
||||
if(text != NULL) {
|
||||
char url[256];
|
||||
snprintf(url, sizeof(url), "https://api.titledb.com/v1/%sonly=id&only=size&only=updated_at&only=version&only=name_s&only=name_l&only=publisher", data->type == TITLEDB_TYPE_CIA ? "cia?only=titleid&" : "smdh?");
|
||||
|
||||
u32 textSize = 0;
|
||||
if(R_SUCCEEDED(res = task_populate_titledb_download(&textSize, text, maxTextSize, "https://api.titledb.com/v1/cia?only=id&only=size&only=updated_at&only=titleid&only=version&only=name_s&only=name_l&only=publisher"))) {
|
||||
if(R_SUCCEEDED(res = task_populate_titledb_download(&textSize, text, maxTextSize, url))) {
|
||||
json_value* json = json_parse(text, textSize);
|
||||
if(json != NULL) {
|
||||
if(json->type == json_array) {
|
||||
@ -83,6 +86,8 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
if(item != NULL) {
|
||||
titledb_info* titledbInfo = (titledb_info*) calloc(1, sizeof(titledb_info));
|
||||
if(titledbInfo != NULL) {
|
||||
titledbInfo->type = data->type;
|
||||
|
||||
for(u32 j = 0; j < val->u.object.length; j++) {
|
||||
char* name = val->u.object.values[j].name;
|
||||
u32 nameLen = val->u.object.values[j].name_length;
|
||||
@ -206,7 +211,7 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
titledb_info* titledbInfo = (titledb_info*) item->data;
|
||||
|
||||
char url[128];
|
||||
snprintf(url, sizeof(url), "https://3ds.titledb.com/v1/cia/%lu/icon_l.bin", titledbInfo->id);
|
||||
snprintf(url, sizeof(url), "https://3ds.titledb.com/v1/%s/%lu/icon_l.bin", data->type == TITLEDB_TYPE_CIA ? "cia" : "smdh", titledbInfo->id);
|
||||
|
||||
u8 icon[0x1200];
|
||||
u32 iconSize = 0;
|
||||
|
@ -71,7 +71,13 @@ typedef struct file_info_s {
|
||||
ticket_info ticketInfo;
|
||||
} file_info;
|
||||
|
||||
typedef enum titledb_type_e {
|
||||
TITLEDB_TYPE_CIA,
|
||||
TITLEDB_TYPE_3DSX
|
||||
} titledb_type;
|
||||
|
||||
typedef struct titledb_info_s {
|
||||
titledb_type type;
|
||||
u32 id;
|
||||
u64 titleId;
|
||||
u16 installedVersion;
|
||||
@ -226,6 +232,7 @@ typedef struct populate_titles_data_s {
|
||||
|
||||
typedef struct populate_titledb_data_s {
|
||||
linked_list* items;
|
||||
titledb_type type;
|
||||
|
||||
volatile bool itemsListed;
|
||||
volatile bool finished;
|
||||
|
@ -12,7 +12,12 @@
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
|
||||
static list_item install = {"Install", COLOR_TEXT, action_install_titledb};
|
||||
static titledb_type section_cia_type = TITLEDB_TYPE_CIA;
|
||||
static list_item section_cia = {"CIA", COLOR_TEXT, §ion_cia_type};
|
||||
static titledb_type section_3dsx_type = TITLEDB_TYPE_3DSX;
|
||||
static list_item section_3dsx = {"3DSX", COLOR_TEXT, §ion_3dsx_type};
|
||||
|
||||
static list_item action_install = {"Install", COLOR_TEXT, action_install_titledb};
|
||||
|
||||
// TODO: Updating disabled pending TitleDB pull request.
|
||||
//static list_item update_all = {"Update All", COLOR_TEXT, action_update_titledb};
|
||||
@ -21,7 +26,7 @@ typedef struct {
|
||||
populate_titledb_data populateData;
|
||||
|
||||
bool populated;
|
||||
} titledb_data;
|
||||
} titledb_section_data;
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -58,7 +63,7 @@ static void titledb_action_update(ui_view* view, void* data, linked_list* items,
|
||||
}
|
||||
|
||||
if(linked_list_size(items) == 0) {
|
||||
linked_list_add(items, &install);
|
||||
linked_list_add(items, &action_install);
|
||||
|
||||
// TODO: Updating disabled pending TitleDB pull request.
|
||||
//linked_list_add(items, &update_all);
|
||||
@ -79,8 +84,8 @@ static void titledb_action_open(linked_list* items, list_item* selected) {
|
||||
list_display("TitleDB Action", "A: Select, B: Return", data, titledb_action_update, titledb_action_draw_top);
|
||||
}
|
||||
|
||||
static void titledb_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) {
|
||||
titledb_data* listData = (titledb_data*) data;
|
||||
static void titledb_section_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) {
|
||||
titledb_section_data* listData = (titledb_section_data*) data;
|
||||
|
||||
if(!listData->populateData.itemsListed) {
|
||||
static const char* text = "Loading title list, please wait...\nNOTE: Cancelling may take up to 15 seconds.";
|
||||
@ -94,8 +99,8 @@ static void titledb_draw_top(ui_view* view, void* data, float x1, float y1, floa
|
||||
}
|
||||
}
|
||||
|
||||
static void titledb_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
titledb_data* listData = (titledb_data*) data;
|
||||
static void titledb_section_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
titledb_section_data* listData = (titledb_section_data*) data;
|
||||
|
||||
if(hidKeysDown() & KEY_B) {
|
||||
if(!listData->populateData.finished) {
|
||||
@ -143,15 +148,40 @@ static void titledb_update(ui_view* view, void* data, linked_list* items, list_i
|
||||
}
|
||||
}
|
||||
|
||||
void titledb_open() {
|
||||
titledb_data* data = (titledb_data*) calloc(1, sizeof(titledb_data));
|
||||
void titledb_section_open(titledb_type type) {
|
||||
titledb_section_data* data = (titledb_section_data*) calloc(1, sizeof(titledb_section_data));
|
||||
if(data == NULL) {
|
||||
error_display(NULL, NULL, "Failed to allocate TitleDB data.");
|
||||
error_display(NULL, NULL, "Failed to allocate TitleDB section data.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data->populateData.type = type;
|
||||
|
||||
data->populateData.finished = true;
|
||||
|
||||
list_display("TitleDB.com", "A: Select, B: Return, X: Refresh", data, titledb_update, titledb_draw_top);
|
||||
list_display("TitleDB.com", "A: Select, B: Return, X: Refresh", data, titledb_section_update, titledb_section_draw_top);
|
||||
}
|
||||
|
||||
static void titledb_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
if(hidKeysDown() & KEY_B) {
|
||||
ui_pop();
|
||||
list_destroy(view);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(selected != NULL && selected->data != NULL && (selectedTouched || (hidKeysDown() & KEY_A))) {
|
||||
titledb_section_open(*(titledb_type*) selected->data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(linked_list_size(items) == 0) {
|
||||
linked_list_add(items, §ion_cia);
|
||||
linked_list_add(items, §ion_3dsx);
|
||||
}
|
||||
}
|
||||
|
||||
void titledb_open() {
|
||||
list_display("TitleDB.com", "A: Select, B: Return", NULL, titledb_update, NULL);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user