Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
use libzip
use http proxy
add usb settings
apollo-lib host callbacks
about menu update
  • Loading branch information
bucanero committed Dec 3, 2023
1 parent dd3519a commit f27d5a3
Show file tree
Hide file tree
Showing 20 changed files with 350 additions and 108 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

# temporary release until 0.53 is released
- name: Download OpenOrbis Toolchain
run: curl -sL https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/latest/download/toolchain.tar.gz | tar xz -C ./
run: curl -sL https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/download/0.0.1.416/toolchain.tar.gz | tar xz -C ./

- name: Checkout oosdk_libraries
uses: actions/checkout@v3
Expand All @@ -47,6 +47,11 @@ jobs:
- name: Copy makerules
run: cp oosdk_libraries/build_rules.mk OpenOrbis/PS4Toolchain/build_rules.mk

- name: TEMP def update
run: |
curl https://raw.githubusercontent.com/OpenOrbis/OpenOrbis-PS4-Toolchain/master/include/orbis/UserService.h > OpenOrbis/PS4Toolchain/include/orbis/UserService.h
curl https://raw.githubusercontent.com/OpenOrbis/OpenOrbis-PS4-Toolchain/master/include/orbis/_types/user.h > OpenOrbis/PS4Toolchain/include/orbis/_types/user.h
- name: Checkout dbglogger
uses: actions/checkout@v3
with:
Expand All @@ -65,12 +70,6 @@ jobs:
repository: bucanero/libSQLite-ps4
path: libSQLite-ps4

- name: Checkout zip
uses: actions/checkout@v3
with:
repository: bucanero/zip
path: zip

- name: Checkout SDL-PS4
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -124,8 +123,14 @@ jobs:
run: make install

- name: Install zip
working-directory: zip
run: make install
run: |
curl -sL https://libzip.org/download/libzip-1.9.2.tar.gz | tar xz -C ./
cd libzip-1.9.2
cmake --toolchain ../SDL-PS4/cmake/openorbis.cmake -DBUILD_SHARED=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_DOC=OFF -DENABLE_LZMA=OFF -DENABLE_ZSTD=OFF -DENABLE_MBEDTLS=OFF .
make
cp zipconf.h ${OO_PS4_TOOLCHAIN}/include/zipconf.h
cp lib/zip.h ${OO_PS4_TOOLCHAIN}/include/zip.h
cp lib/libzip.a ${OO_PS4_TOOLCHAIN}/lib/libzip.a
- name: Install dbglogger
working-directory: dbglogger
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package metadata.
TITLE := Apollo Save Tool
VERSION := 01.40
VERSION := 01.42
TITLE_ID := APOL00004
CONTENT_ID := IV0000-APOL00004_00-APOLLO0000000PS4

Expand Down
Binary file added assets/images/leon_luna.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum menu_screen_ids
//Textures
enum texture_index
{
leonluna_jpg_index,
leon_luna_jpg_index,
bgimg_jpg_index,
column_1_png_index,
column_2_png_index,
Expand Down
2 changes: 1 addition & 1 deletion include/menu_gui.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
void Draw_AboutMenu_Ani(void);
void Draw_AboutMenu(void);
void Draw_AboutMenu(int ll);

void Draw_UserCheatsMenu_Ani(save_list_t * list);
void Draw_UserCheatsMenu(save_list_t * list, int menuSel, u8 alpha);
Expand Down
10 changes: 5 additions & 5 deletions include/orbisPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ typedef struct OrbisPadConfig
}OrbisPadConfig;

int orbisPadInit(void);
void orbisPadFinish();
OrbisPadConfig *orbisPadGetConf();
void orbisPadFinish(void);
OrbisPadConfig *orbisPadGetConf(void);
bool orbisPadGetButtonHold(unsigned int filter);
bool orbisPadGetButtonPressed(unsigned int filter);
bool orbisPadGetButtonReleased(unsigned int filter);
unsigned int orbisPadGetCurrentButtonsPressed();
unsigned int orbisPadGetCurrentButtonsReleased();
unsigned int orbisPadGetCurrentButtonsPressed(void);
unsigned int orbisPadGetCurrentButtonsReleased(void);
void orbisPadSetCurrentButtonsPressed(unsigned int buttons);
void orbisPadSetCurrentButtonsReleased(unsigned int buttons);
int orbisPadUpdate();
int orbisPadUpdate(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define APOLLO_LOCAL_CACHE APOLLO_PATH "cache/"
#define APOLLO_UPDATE_URL "https://api.github.com/repos/bucanero/apollo-ps4/releases/latest"

#define MAX_USB_DEVICES 6
#define MAX_USB_DEVICES 8
#define USB0_PATH "/mnt/usb0/"
#define USB1_PATH "/mnt/usb1/"
#define USB_PATH "/mnt/usb%d/"
Expand Down
3 changes: 2 additions & 1 deletion include/settings.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define APOLLO_VERSION "1.4.0" //Apollo PS4 version (about menu)
#define APOLLO_VERSION "1.4.2" //Apollo PS4 version (about menu)

#define MENU_TITLE_OFF 45 //Offset of menu title text from menu mini icon
#define MENU_ICON_OFF 105 //X Offset to start printing menu mini icon
Expand Down Expand Up @@ -32,6 +32,7 @@ typedef struct
uint8_t doSort;
uint8_t doAni;
uint8_t update;
uint8_t usb_dev;
uint32_t user_id;
uint64_t psid[2];
uint64_t account_id;
Expand Down
2 changes: 1 addition & 1 deletion include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ int calculate_hmac_hash(const u8 *data, u64 size, const u8 *key, u32 key_length,
int calculate_file_hmac_hash(const char *file_path, const u8 *key, u32 key_length, u8 output[20]);

u64 align_to_pow2(u64 offset, u64 alignment);
void notifi(const char *p_Uri, const char *p_Format, ...);
void notify_popup(const char *p_Uri, const char *p_Format, ...);

#endif /* !_UTIL_H_ */
2 changes: 1 addition & 1 deletion source/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void stop_loading_screen(void)
end_progress_bar();
}

void notifi(const char *p_Uri, const char *p_Format, ...)
void notify_popup(const char *p_Uri, const char *p_Format, ...)
{
OrbisNotificationRequest s_Request;
memset(&s_Request, '\0', sizeof(s_Request));
Expand Down
103 changes: 83 additions & 20 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <orbis/NetCtl.h>
#include <orbis/SaveData.h>
#include <orbis/UserService.h>
#include <orbis/SystemService.h>
#include <polarssl/md5.h>

#include "saves.h"
Expand All @@ -13,6 +14,7 @@
#include "util.h"
#include "sfo.h"

static char host_buf[256];

static void _set_dest_path(char* path, int dest, const char* folder)
{
Expand Down Expand Up @@ -60,15 +62,15 @@ static void downloadSave(const save_entry_t* entry, const char* file, int dst)
unlink_secure(APOLLO_LOCAL_CACHE "tmpsave.zip");
}

static uint32_t get_filename_id(const char* dir)
static uint32_t get_filename_id(const char* dir, const char* title_id)
{
char path[128];
uint32_t tid = 0;

do
{
tid++;
snprintf(path, sizeof(path), "%s%08d.zip", dir, tid);
snprintf(path, sizeof(path), "%s%s-%08d.zip", dir, title_id, tid);
}
while (file_exists(path) == SUCCESS);

Expand All @@ -77,9 +79,10 @@ static uint32_t get_filename_id(const char* dir)

static void zipSave(const save_entry_t* entry, const char* exp_path)
{
char* export_file;
char export_file[256];
char* tmp;
uint32_t fid;
int ret;

if (mkdirs(exp_path) != SUCCESS)
{
Expand All @@ -89,31 +92,38 @@ static void zipSave(const save_entry_t* entry, const char* exp_path)

init_loading_screen("Exporting save game...");

fid = get_filename_id(exp_path);
asprintf(&export_file, "%s%08d.zip", exp_path, fid);
fid = get_filename_id(exp_path, entry->title_id);
snprintf(export_file, sizeof(export_file), "%s%s-%08d.zip", exp_path, entry->title_id, fid);

tmp = strdup(entry->path);
*strrchr(tmp, '/') = 0;
*strrchr(tmp, '/') = 0;

zip_directory(tmp, entry->path, export_file);
ret = zip_directory(tmp, entry->path, export_file);
free(tmp);

sprintf(export_file, "%s%08x.txt", exp_path, apollo_config.user_id);
FILE* f = fopen(export_file, "a");
if (f)
if (ret)
{
fprintf(f, "%08d.zip=[%s] %s\n", fid, entry->title_id, entry->name);
fclose(f);
}

sprintf(export_file, "%s%08x.xml", exp_path, apollo_config.user_id);
save_xml_owner(export_file);
snprintf(export_file, sizeof(export_file), "%s%08x.txt", exp_path, apollo_config.user_id);
FILE* f = fopen(export_file, "a");
if (f)
{
fprintf(f, "%s-%08d.zip=%s\n", entry->title_id, fid, entry->name);
fclose(f);
}

free(export_file);
free(tmp);
sprintf(export_file, "%s%08x.xml", exp_path, apollo_config.user_id);
save_xml_owner(export_file);
}

stop_loading_screen();
show_message("Zip file successfully saved to:\n%s%08d.zip", exp_path, fid);
if (!ret)
{
show_message("Error! Can't export save game to:\n%s", exp_path);
return;
}

show_message("Zip file successfully saved to:\n%s%s-%08d.zip", exp_path, entry->title_id, fid);
}

static void copySave(const save_entry_t* save, const char* exp_path)
Expand Down Expand Up @@ -266,6 +276,7 @@ void extractArchive(const char* file_path)
case 'z':
case 'Z':
/* ZIP */
strcat(exp_path, "/");
ret = extract_zip(file_path, exp_path);
break;

Expand Down Expand Up @@ -674,7 +685,7 @@ static void enableWebServer(dWebReqHandler_t handler, void* data, int port)
{
OrbisNetCtlInfo info;

memset(&info, 0, sizeof(info));
memset(&info, 0, sizeof(OrbisNetCtlInfo));
sceNetCtlGetInfo(ORBIS_NET_CTL_INFO_IP_ADDRESS, &info);
LOG("Starting local web server %s:%d ...", info.ip_address, port);

Expand Down Expand Up @@ -767,6 +778,58 @@ static void rebuildAppDB(const char* path)
show_message("Database rebuilt successfully!\nLog out for changes to take effect");
}

static void* orbis_host_callback(int id, int* size)
{
OrbisNetCtlInfo info;

memset(host_buf, 0, sizeof(host_buf));

switch (id)
{
case APOLLO_HOST_TEMP_PATH:
return APOLLO_LOCAL_CACHE;

case APOLLO_HOST_SYS_NAME:
if (sceSystemServiceParamGetString(ORBIS_SYSTEM_SERVICE_PARAM_ID_SYSTEM_NAME, host_buf, sizeof(host_buf)) < 0)
LOG("Error getting System name");

if (size) *size = strlen(host_buf);
return host_buf;

case APOLLO_HOST_PSID:
memcpy(host_buf, apollo_config.psid, 16);
if (size) *size = 16;
return host_buf;

case APOLLO_HOST_ACCOUNT_ID:
memcpy(host_buf, &apollo_config.account_id, 8);
*(uint64_t*)host_buf = ES64(*(uint64_t*)host_buf);
if (size) *size = 8;
return host_buf;

case APOLLO_HOST_USERNAME:
if (sceUserServiceGetUserName(apollo_config.user_id, host_buf, sizeof(host_buf)) < 0)
LOG("Error getting Username");

if (size) *size = strlen(host_buf);
return host_buf;

case APOLLO_HOST_LAN_ADDR:
case APOLLO_HOST_WLAN_ADDR:
memset(&info, 0, sizeof(OrbisNetCtlInfo));
if (sceNetCtlGetInfo(ORBIS_NET_CTL_INFO_ETHER_ADDR, &info) < 0)
LOG("Error getting Wlan Ethernet Address");
else
memcpy(host_buf, info.ether_addr, 6);

if (size) *size = 6;
return host_buf;
}

if (size) *size = 1;
return host_buf;
}

static int apply_sfo_patches(save_entry_t* entry, sfo_patch_t* patch)
{
code_entry_t* code;
Expand Down Expand Up @@ -854,7 +917,7 @@ static int apply_cheat_patches(const save_entry_t* entry)
else
snprintf(tmpfile, sizeof(tmpfile), "%s%s", entry->path, filename);

if (!apply_cheat_patch_code(tmpfile, entry->title_id, code, APOLLO_LOCAL_CACHE))
if (!apply_cheat_patch_code(tmpfile, entry->title_id, code, &orbis_host_callback))
{
LOG("Error: failed to apply (%s)", code->name);
ret = 0;
Expand Down
17 changes: 17 additions & 0 deletions source/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static int update_progress(void *p, int64_t dltotal, int64_t dlnow, int64_t ulto

int http_download(const char* url, const char* filename, const char* local_dst, int show_progress)
{
OrbisNetCtlInfo proxy_info;
char full_url[1024];
CURL *curl;
CURLcode res;
Expand Down Expand Up @@ -88,6 +89,22 @@ int http_download(const char* url, const char* filename, const char* local_dst,
// request using SSL for the FTP transfer if available
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);

// check for proxy settings
memset(&proxy_info, 0, sizeof(OrbisNetCtlInfo));
sceNetCtlGetInfo(ORBIS_NET_CTL_INFO_HTTP_PROXY_CONFIG, &proxy_info);

if (proxy_info.http_proxy_config)
{
memset(&proxy_info, 0, sizeof(OrbisNetCtlInfo));
sceNetCtlGetInfo(ORBIS_NET_CTL_INFO_HTTP_PROXY_SERVER, &proxy_info);
curl_easy_setopt(curl, CURLOPT_PROXY, proxy_info.http_proxy_server);
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

memset(&proxy_info, 0, sizeof(OrbisNetCtlInfo));
sceNetCtlGetInfo(ORBIS_NET_CTL_INFO_HTTP_PROXY_PORT, &proxy_info);
curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy_info.http_proxy_port);
}

if (show_progress)
{
init_progress_bar("Downloading...");
Expand Down
Loading

0 comments on commit f27d5a3

Please sign in to comment.