phase 5: transfer service

This commit is contained in:
2026-04-27 01:21:16 +03:00
parent b5c506cf03
commit 895fee6235
49 changed files with 905 additions and 838 deletions
+82
View File
@@ -0,0 +1,82 @@
#include <nxst/app/main_application.hpp>
#include <nxst/domain/util.hpp>
#include <nxst/app/main.hpp>
#include <unistd.h>
namespace ui { extern MainApplication* mainApp; }
static int nxlink_sock = -1;
extern "C" void userAppInit() {
appletInitialize();
hidInitialize();
nsInitialize();
setsysInitialize();
setInitialize();
accountInitialize(AccountServiceType_Administrator);
pmshellInitialize();
socketInitializeDefault();
pdmqryInitialize();
nxlink_sock = nxlinkStdio();
printf("userAppInit\n");
}
extern "C" void userAppExit() {
if (ui::mainApp) {
ui::mainApp->transfer.cancelReceive();
ui::mainApp->transfer.cancelSend();
for (int i = 0; i < 150 &&
(!ui::mainApp->transfer.isReceiveWorkersIdle() ||
!ui::mainApp->transfer.isSendWorkersIdle()); i++) {
usleep(10000);
}
}
if (nxlink_sock != -1) {
close(nxlink_sock);
}
appletExit();
hidExit();
nsExit();
setsysExit();
setExit();
accountExit();
pmshellExit();
socketExit();
pdmqryExit();
}
// Main entrypoint
int main() {
Result res = servicesInit();
if (R_FAILED(res)) {
servicesExit();
exit(res);
}
printf("main");
// First create our renderer, where one can customize SDL or other stuff's
// initialization.
auto renderer_opts = pu::ui::render::RendererInitOptions(
SDL_INIT_EVERYTHING, pu::ui::render::RendererHardwareFlags);
renderer_opts.UseImage(pu::ui::render::IMGAllFlags);
renderer_opts.UseAudio(pu::ui::render::MixerAllFlags);
renderer_opts.UseTTF();
renderer_opts.SetExtraDefaultFontSize(theme::type::Caption);
renderer_opts.SetExtraDefaultFontSize(theme::type::Label);
renderer_opts.SetExtraDefaultFontSize(theme::type::Body);
renderer_opts.SetExtraDefaultFontSize(theme::type::Title);
renderer_opts.SetExtraDefaultFontSize(theme::type::Display);
auto renderer = pu::ui::render::Renderer::New(renderer_opts);
// Create our main application from the renderer
auto main = ui::MainApplication::New(renderer);
main->Prepare();
main->Show();
servicesExit();
return 0;
}
+21
View File
@@ -0,0 +1,21 @@
#include <string>
#include <switch.h>
#include <switch/services/hid.h>
#include <vector>
#include <nxst/app/main_application.hpp>
namespace ui {
MainApplication *mainApp;
void MainApplication::OnLoad() {
mainApp = this;
this->users_layout = UsersLayout::New();
this->titles_layout = TitlesLayout::New();
this->users_layout->SetOnInput(
std::bind(&UsersLayout::onInput, this->users_layout, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4));
this->titles_layout->SetOnInput(std::bind(&TitlesLayout::onInput, this->titles_layout, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4));
this->LoadLayout(this->users_layout);
}
}