Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cy33hc committed Apr 24, 2022
1 parent 6ccc3e5 commit e9c300f
Show file tree
Hide file tree
Showing 53 changed files with 11,570 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build
.vscode

# Prerequisites
*.d

Expand Down
92 changes: 92 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()

project(ftpclient)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(VITA_APP_NAME "Ftp Client")
set(VITA_TITLEID "FTPCLIENT")
set(VITA_VERSION "01.00")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")

include_directories(
src
)

add_executable(${PROJECT_NAME}
src/textures.cpp
src/fs.cpp
src/main.cpp
src/inifile.c
src/config.cpp
src/style.cpp
src/ime_dialog.cpp
src/net.cpp
src/ftpclient.cpp
src/vitaaudiolib.c
src/gui.cpp
src/windows.cpp
src/actions.cpp
src/updater.cpp
src/sfo.cpp
src/audio.c
src/ogg.c
src/sha1.c
src/zip.c
src/unzip.c
src/ioapi.c
)

target_link_libraries(${PROJECT_NAME}
debugnet
vorbisfile
vorbis
ogg
vita2d
png
imgui_vita2d
stdc++
c
z
SceCommonDialog_stub
SceLibKernel_stub
SceDisplay_stub
SceGxm_stub
SceSysmodule_stub
SceCtrl_stub
SceTouch_stub
SceAudio_stub
SceHid_stub
SceNet_stub
SceNetCtl_stub
SceHttp_stub
SceSsl_stub
ScePspnetAdhoc_stub
ScePromoterUtil_stub
SceShellSvc_stub
m
SceAppMgr_stub
SceAppUtil_stub
SceShaccCg_stub
)

vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE)
vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} eboot.bin
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE sce_sys/icon0.png sce_sys/icon0.png
FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
FILE default_style.ini default_style.ini
FILE head.bin head.bin
FILE music.ogg music.ogg
)
44 changes: 44 additions & 0 deletions default_style.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[Style]
Text=1.00,1.00,1.00,1.00
TextDisabled=0.50,0.50,0.50,1.00
WindowBackgroud=0.06,0.06,0.06,0.94
ChildBackground=0.00,0.00,0.00,0.00
PopupBackground=0.08,0.08,0.08,0.94
Border=0.43,0.43,0.50,0.50
BorderShadhow=0.00,0.00,0.00,0.00
FrameBackground=0.16,0.29,0.48,0.54
FrameBackgroundHovered=0.26,0.59,0.98,0.40
FrameBackgroundActive=0.26,0.59,0.98,0.67
TitleBackground=0.04,0.04,0.04,1.00
TitleBackgroundActive=0.16,0.29,0.48,1.00
TitleBackgroundCollapsed=0.00,0.00,0.00,0.51
MenuBarBackground=0.14,0.14,0.14,1.00
ScrollbarBackground=0.02,0.02,0.02,0.53
ScrollbarGrab=0.31,0.31,0.31,1.00
ScrollbarGrabHovered=0.41,0.41,0.41,1.00
ScrollbarGrabActive=0.51,0.51,0.51,1.00
CheckMark=0.26,0.59,0.98,1.00
SliderGrab=0.24,0.52,0.88,1.00
SliderGrabActive=0.26,0.59,0.98,1.00
Button=0.26,0.59,0.98,0.40
ButtonHovered=0.26,0.59,0.98,1.00
ButtonActive=0.06,0.53,0.98,1.00
Header=0.26,0.59,0.98,0.31
HeaderHovered=0.26,0.59,0.98,0.80
HeaderActive=0.26,0.59,0.98,1.00
Separator=0.43,0.43,0.50,0.50
SeparatorHovered=0.10,0.40,0.75,0.78
SeparatorActive=0.10,0.40,0.75,1.00
ResizeGrip=0.26,0.59,0.98,0.25
ResizeHovered=0.26,0.59,0.98,0.67
ResizeGripActive=0.26,0.59,0.98,0.95
Tab=0.18,0.35,0.58,0.86
TabHovered=0.26,0.59,0.98,0.80
TabActive=0.31,0.31,0.31,1.00
TabUnocused=0.07,0.10,0.15,0.97
TabUnocusedActive=0.14,0.26,0.42,0.76
TextSelectedBackground=0.26,0.59,0.98,0.35
NavigationHighlight=0.26,0.59,0.98,1.00
NavigationWindowingHighlight=1.00,1.00,1.00,0.70
NavigationWindowingDimBackground=0.80,0.80,0.80,0.20
ModalWindowDimBackground=0.80,0.80,0.80,0.35
Binary file added head.bin
Binary file not shown.
Binary file added music.ogg
Binary file not shown.
Binary file added sce_sys/icon0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sce_sys/livearea/contents/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sce_sys/livearea/contents/startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions sce_sys/livearea/contents/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<livearea style="psmobile" format-ver="01.00" content-rev="1">
<livearea-background>
<image>bg.png</image>
</livearea-background>

<gate>
<startup-image>startup.png</startup-image>
</gate>
</livearea>
87 changes: 87 additions & 0 deletions src/actions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include "fs.h"
#include "config.h"
#include "windows.h"
#include "ftpclient.h"

namespace Actions {

void HandleChangeLocalDirectory(FsEntry *entry)
{
if (!entry->isDir)
return;

if (strcmp(entry->name, "..") == 0)
{
std::string temp_path = std::string(entry->directory);
sprintf(local_directory, "%s", temp_path.substr(0, temp_path.find_last_of("/")).c_str());
sprintf(local_file_to_select, "%s", temp_path.substr(temp_path.find_last_of("/")+1).c_str());
}
else
{
sprintf(local_directory, "%s", entry->path);
sprintf(local_file_to_select, "..");
}
local_files.clear();
local_files = FS::ListDir(local_directory);
FS::Sort(local_files);
selected_local_file = nullptr;
selected_action = NONE;
}

void HandleChangeRemoteDirectory(FtpDirEntry *entry)
{
if (!entry->isDir)
return;

if (strcmp(entry->name, "..") == 0)
{
std::string temp_path = std::string(entry->directory);
if (temp_path.size()>1)
{
if (temp_path.find_last_of("/") == 0)
{
sprintf(remote_directory, "/");
}
else
{
sprintf(remote_directory, "%s", temp_path.substr(0, temp_path.find_last_of("/")).c_str());
}
}
sprintf(remote_file_to_select, "%s", temp_path.substr(temp_path.find_last_of("/")+1).c_str());
}
else
{
sprintf(remote_directory, "%s", entry->path);
sprintf(remote_file_to_select, "..");
}
remote_files.clear();
remote_files = ftpclient->ListDir(remote_directory);
sprintf(status_message, "%s", ftpclient->LastResponse());
FtpClient::Sort(remote_files);
selected_remote_file = nullptr;
selected_action = NONE;
}

void ConnectFTP()
{
if (ftpclient->Connect(ftp_settings.server_ip, ftp_settings.server_port))
{
if (ftpclient->Login(ftp_settings.username, ftp_settings.password))
{
remote_files.clear();
remote_files = ftpclient->ListDir(remote_directory);
FtpClient::Sort(remote_files);
sprintf(status_message, "%s", ftpclient->LastResponse());
}
else
{
snprintf(status_message, 1024, "%s", ftpclient->LastResponse());
}
}
else
{
snprintf(status_message, 1024, "%s", ftpclient->LastResponse());
}
selected_action = NONE;
}
}
26 changes: 26 additions & 0 deletions src/actions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef ACTIONS_H
#define ACTIONS_H

#include "fs.h"

enum ACTIONS {
NONE = 0,
CHANGE_LOCAL_DIRECTORY,
COPY_LOCAL,
PASTE_LOCAL,
DELETE_LOCAL,
CHANGE_REMOTE_DIRECTORY,
COPY_REMOTE,
PASTE_REMOTE,
DELETE_REMOTE,
CONNECT_FTP
};

namespace Actions {

void HandleChangeLocalDirectory(FsEntry *entry);
void HandleChangeRemoteDirectory(FtpDirEntry *entry);
void ConnectFTP();
}

#endif
107 changes: 107 additions & 0 deletions src/audio.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include <psp2/kernel/threadmgr.h>
#include <stdio.h>
#include <string.h>

#include "audio.h"
#include "vitaaudiolib.h"
#include "ogg.h"

enum Audio_FileType {
FILE_TYPE_NONE,
FILE_TYPE_OGG
};

typedef struct {
int (* init)(const char *path);
SceUInt32 (* rate)(void);
SceUInt8 (* channels)(void);
void (* decode)(void *buf, unsigned int length, void *userdata);
SceUInt64 (* position)(void);
SceUInt64 (* length)(void);
SceUInt64 (* seek)(SceUInt64 index);
void (* term)(void);
} Audio_Decoder;

static enum Audio_FileType file_type = FILE_TYPE_NONE;
Audio_Metadata metadata = {0};
static Audio_Metadata empty_metadata = {0};
static Audio_Decoder decoder = {0}, empty_decoder = {0};
SceBool playing = SCE_TRUE, m_paused = SCE_FALSE;

static void Audio_Decode(void *buf, unsigned int length, void *userdata) {
if (playing == SCE_FALSE || m_paused == SCE_TRUE) {
short *buf_short = (short *)buf;
unsigned int count;
for (count = 0; count < length * 2; count++)
*(buf_short + count) = 0;
}
else
(* decoder.decode)(buf, length, userdata);
}

int Audio_Init(const char *path) {
playing = SCE_TRUE;
m_paused = SCE_FALSE;

file_type = FILE_TYPE_OGG;
decoder.init = OGG_Init;
decoder.rate = OGG_GetSampleRate;
decoder.channels = OGG_GetChannels;
decoder.decode = OGG_Decode;
decoder.position = OGG_GetPosition;
decoder.length = OGG_GetLength;
decoder.seek = OGG_Seek;
decoder.term = OGG_Term;

(* decoder.init)(path);
vitaAudioInit((* decoder.rate)(), (* decoder.channels)() == 2? SCE_AUDIO_OUT_MODE_STEREO : SCE_AUDIO_OUT_MODE_MONO);
vitaAudioSetChannelCallback(0, Audio_Decode, NULL);
return 0;
}

SceBool Audio_IsPaused(void) {
return m_paused;
}

void Audio_Pause(void) {
m_paused = !m_paused;
}

void Audio_Stop(void) {
playing = !playing;
}

SceUInt64 Audio_GetPosition(void) {
return (* decoder.position)();
}

SceUInt64 Audio_GetLength(void) {
return (* decoder.length)();
}

SceUInt64 Audio_GetPositionSeconds(void) {
return (Audio_GetPosition() / (* decoder.rate)());
}

SceUInt64 Audio_GetLengthSeconds(void) {
return (Audio_GetLength() / (* decoder.rate)());
}

SceUInt64 Audio_Seek(SceUInt64 index) {
return (* decoder.seek)(index);
}

void Audio_Term(void) {
playing = SCE_TRUE;
m_paused = SCE_FALSE;

vitaAudioSetChannelCallback(0, NULL, NULL); // Clear channel callback
vitaAudioEndPre();
sceKernelDelayThread(100 * 1000);
vitaAudioEnd();
(* decoder.term)();

// Clear metadata struct
metadata = empty_metadata;
decoder = empty_decoder;
}
Loading

0 comments on commit e9c300f

Please sign in to comment.