Skip to content

Commit

Permalink
Updated to v3.24
Browse files Browse the repository at this point in the history
  • Loading branch information
GrapheneCt committed Aug 17, 2024
1 parent 8b1bb91 commit 0988d29
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 81 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ eboot2.bin
param.sfo
param2.sfo
PSVita_Debug
PSVita_Release
PSVita_Release
build
2 changes: 2 additions & 0 deletions BGFTP/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ int main()
sceSysmoduleLoadModule(SCE_SYSMODULE_BG_APP_UTIL);
sceBgAppUtilStartBgApp(0);

common_exit(0);

return 0;
}
2 changes: 1 addition & 1 deletion BGFTP/param.sfx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<paramsfo>
<param key="APP_VER">03.23</param>
<param key="APP_VER">03.24</param>
<param key="ATTRIBUTE">16814080</param>
<param key="ATTRIBUTE_MINOR">17</param>
<param key="ATTRIBUTE2">0</param>
Expand Down
50 changes: 38 additions & 12 deletions BGFTP_bgapp/ftpvita.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <rtc.h>

#define UNUSED(x) (void)(x)
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))

#define NET_CTL_ERROR_NOT_TERMINATED 0x80412102

Expand Down Expand Up @@ -52,6 +53,7 @@ static struct {
static void *net_memory = NULL;
static int ftp_initialized = 0;
static unsigned int file_buf_size = DEFAULT_FILE_BUF_SIZE;
static unsigned int active_op_count = 0;
static SceNetInAddr vita_addr;
static SceUID server_thid;
static int server_sockfd;
Expand Down Expand Up @@ -510,23 +512,29 @@ static void send_file(ftpvita_client_info_t *client, const char *path)
unsigned char *buffer;
SceUID fd;
unsigned int bytes_read;
unsigned int op_buf_size;

active_op_count++;

op_buf_size = ALIGN(file_buf_size / active_op_count, 4 * 1024);

DEBUG("Opening: %s\n", path);

if ((fd = sceIoOpen(path, SCE_O_RDONLY, 0777)) >= 0) {

sceIoLseek32(fd, client->restore_point, SCE_SEEK_SET);

buffer = malloc(file_buf_size);
buffer = malloc(op_buf_size);
if (buffer == NULL) {
client_send_ctrl_msg(client, "550 Could not allocate memory." FTPVITA_EOL);
active_op_count--;
return;
}

client_open_data_connection(client);
client_send_ctrl_msg(client, "150 Opening Image mode data transfer." FTPVITA_EOL);

while ((bytes_read = sceIoRead (fd, buffer, file_buf_size)) > 0) {
while ((bytes_read = sceIoRead (fd, buffer, op_buf_size)) > 0) {
client_send_data_raw(client, buffer, bytes_read);
}

Expand All @@ -540,6 +548,8 @@ static void send_file(ftpvita_client_info_t *client, const char *path)
} else {
client_send_ctrl_msg(client, "550 File not found." FTPVITA_EOL);
}

active_op_count--;
}

/* This function generates an FTP full-path with the input path (relative or absolute)
Expand Down Expand Up @@ -576,6 +586,11 @@ static void receive_file(ftpvita_client_info_t *client, const char *path)
unsigned char *buffer;
SceUID fd;
int bytes_recv;
unsigned int op_buf_size;

active_op_count++;

op_buf_size = ALIGN(file_buf_size / active_op_count, 4 * 1024);

DEBUG("Opening: %s\n", path);

Expand All @@ -591,16 +606,17 @@ static void receive_file(ftpvita_client_info_t *client, const char *path)

if ((fd = sceIoOpen(path, mode, 0777)) >= 0) {

buffer = malloc(file_buf_size);
buffer = malloc(op_buf_size);
if (buffer == NULL) {
client_send_ctrl_msg(client, "550 Could not allocate memory." FTPVITA_EOL);
active_op_count--;
return;
}

client_open_data_connection(client);
client_send_ctrl_msg(client, "150 Opening Image mode data transfer." FTPVITA_EOL);

while ((bytes_recv = client_recv_data_raw(client, buffer, file_buf_size)) > 0) {
while ((bytes_recv = client_recv_data_raw(client, buffer, op_buf_size)) > 0) {
sceIoWrite(fd, buffer, bytes_recv);
}

Expand All @@ -620,6 +636,8 @@ static void receive_file(ftpvita_client_info_t *client, const char *path)
} else {
client_send_ctrl_msg(client, "550 File not found." FTPVITA_EOL);
}

active_op_count--;
}

static void cmd_STOR_func(ftpvita_client_info_t *client)
Expand Down Expand Up @@ -1067,7 +1085,7 @@ static int server_thread(SceSize args, void *argp)
return 0;
}

int ftpvita_init(char *vita_ip, unsigned short int *vita_port)
int ftpvita_init(char *vita_ip, unsigned short *vita_port)
{
int ret;
int i;
Expand Down Expand Up @@ -1105,6 +1123,13 @@ int ftpvita_init(char *vita_ip, unsigned short int *vita_port)
if (netctl_init < 0 && netctl_init != NET_CTL_ERROR_NOT_TERMINATED)
goto error_netctlinit;

sceNetCtlInetGetState(&ret);

while (ret != SCE_NET_CTL_STATE_IPOBTAINED) {
sceNetCtlInetGetState(&ret);
sceKernelDelayThread(10000);
}

/* Get IP address */
ret = sceNetCtlInetGetInfo(SCE_NET_CTL_INFO_IP_ADDRESS, &info);
DEBUG("sceNetCtlInetGetInfo(): 0x%08X\n", ret);
Expand Down Expand Up @@ -1143,22 +1168,23 @@ int ftpvita_init(char *vita_ip, unsigned short int *vita_port)

return 0;

error_netctlgetinfo:
if (netctl_init == 0) {
sceNetCtlTerm();
netctl_init = -1;
}
error_netctlinit:
error_netctlgetinfo:
error_netinit:
error_netstat:
if (net_init == 0) {
sceNetTerm();
net_init = -1;
}
error_netinit:
if (netctl_init == 0) {
sceNetCtlTerm();
netctl_init = -1;
}
if (net_memory) {
free(net_memory);
net_memory = NULL;
}
error_netstat:

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion BGFTP_bgapp/ftpvita.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
typedef void (*ftpvita_log_cb_t)(const char *);

/* Returns PSVita's IP and FTP port. 0 on success */
int ftpvita_init(char *vita_ip, unsigned short int *vita_port);
int ftpvita_init(char *vita_ip, unsigned short *vita_port);
void ftpvita_fini();
int ftpvita_is_initialized();
int ftpvita_add_device(const char *devname);
Expand Down
66 changes: 1 addition & 65 deletions BGFTP_bgapp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ extern unsigned int sce_process_preload_disabled = (SCE_PROCESS_PRELOAD_DISABLED
// Libc parameters
unsigned int sceLibcHeapSize = 14 * 1024 * 1024;

typedef struct SceAppMgrEvent {
int event; /* Event ID */
SceUID appId; /* Application ID. Added when required by the event */
char param[56]; /* Parameters to pass with the event */
} SceAppMgrEvent;

/* appmgr */
extern int sceAppMgrReceiveEvent(SceAppMgrEvent *appEvent);

void sendNotification(const char *text, ...)
{
SceNotificationUtilSendParam param;
Expand Down Expand Up @@ -67,7 +58,7 @@ void ftpvita_init_app()
{
char vita_ip[16];
int state;
unsigned short int vita_port;
unsigned short vita_port;

ftpvita_set_file_buf_size(6 * 1024 * 1024);

Expand Down Expand Up @@ -97,61 +88,6 @@ void ftpvita_init_app()

int main()
{
/* network check */

SceAppMgrEvent appEvent;
int plane, wifi, dialogShown;
uint32_t inSize, outSize;
dialogShown = 0;

sceRegMgrGetKeyInt("/CONFIG/NET", "wifi_flag", &wifi);
sceRegMgrGetKeyInt("/CONFIG/SYSTEM", "flight_mode", &plane);

if (!wifi || plane) {

sceSysmoduleLoadModule(SCE_SYSMODULE_INCOMING_DIALOG);

sceIncomingDialogInit(0);

SceIncomingDialogParam params;
sceIncomingDialogParamInit(&params);
sceClibStrncpy((char *)params.titleId, "GRVA00002", sizeof(params.titleId));
params.timeout = 0x7FFFFFF0;

SceCesUcsContext context;

sceCesUcsContextInit(&context);
sceCesUtf8StrToUtf16Str(
&context,
"OK",
6,
&inSize,
(uint16_t *)params.acceptText,
0x20,
&outSize);

sceCesUcsContextInit(&context);
sceCesUtf8StrToUtf16Str(
&context,
"Wi-Fi is disabled or system is in airplane mode.",
95,
&inSize,
(uint16_t *)params.dialogText,
0x40,
&outSize);

sceIncomingDialogOpen(&params);

while (1) {
sceAppMgrReceiveEvent(&appEvent);
if (appEvent.event == 0x20000004 && dialogShown)
sceAppMgrDestroyAppByAppId(-2);
else if (appEvent.event == 0x20000004)
dialogShown = 1;
sceKernelDelayThread(10000);
}
}

/* BG application*/

sceSysmoduleLoadModule(SCE_SYSMODULE_NOTIFICATION_UTIL);
Expand Down
2 changes: 1 addition & 1 deletion BGFTP_bgapp/param.sfx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<paramsfo>
<param key="APP_VER">03.23</param>
<param key="APP_VER">03.24</param>
<param key="ATTRIBUTE">528384</param>
<param key="ATTRIBUTE2">0</param>
<param key="CATEGORY">gdd</param>
Expand Down

0 comments on commit 0988d29

Please sign in to comment.