diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9d514b --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +build/ +Build/ +Output/ +*.nso +*.nro +*.elf +.vscode/ +.vs/ +bin/ +obj/ +target/ +.settings/ +.classpath +.project +*.cmd +*.pfs0 +*.nacp diff --git a/BuildTools/hacbrewpack b/BuildTools/hacbrewpack new file mode 100644 index 0000000..2711a06 Binary files /dev/null and b/BuildTools/hacbrewpack differ diff --git a/BuildTools/hacbrewpack.exe b/BuildTools/hacbrewpack.exe new file mode 100644 index 0000000..e06a186 Binary files /dev/null and b/BuildTools/hacbrewpack.exe differ diff --git a/Freeshop.jpg b/Freeshop.jpg new file mode 100644 index 0000000..005a4b3 Binary files /dev/null and b/Freeshop.jpg differ diff --git a/HtmlDoc/accessible-urls/accessible-urls.txt b/HtmlDoc/accessible-urls/accessible-urls.txt new file mode 100644 index 0000000..be50534 --- /dev/null +++ b/HtmlDoc/accessible-urls/accessible-urls.txt @@ -0,0 +1 @@ +^http* \ No newline at end of file diff --git a/Icon.jpg b/Icon.jpg new file mode 100644 index 0000000..e67f11d Binary files /dev/null and b/Icon.jpg differ diff --git a/Icon.rar b/Icon.rar new file mode 100644 index 0000000..112a472 Binary files /dev/null and b/Icon.rar differ diff --git a/Logo/NintendoLogo.png b/Logo/NintendoLogo.png new file mode 100644 index 0000000..f7b0c3b Binary files /dev/null and b/Logo/NintendoLogo.png differ diff --git a/Logo/StartupMovie.gif b/Logo/StartupMovie.gif new file mode 100644 index 0000000..4dac635 Binary files /dev/null and b/Logo/StartupMovie.gif differ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4501357 --- /dev/null +++ b/Makefile @@ -0,0 +1,200 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +TOPDIR ?= $(CURDIR) +include $(DEVKITPRO)/libnx/switch_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". +# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional) +# +# NO_ICON: if set to anything, do not use icon. +# NO_NACP: if set to anything, no .nacp file is generated. +# APP_TITLE is the name of the app stored in the .nacp file (Optional) +# APP_AUTHOR is the author of the app stored in the .nacp file (Optional) +# APP_VERSION is the version of the app stored in the .nacp file (Optional) +# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) +# ICON is the filename of the icon (.jpg), relative to the project folder. +# If not set, it attempts to use one of the following (in this order): +# - .jpg +# - icon.jpg +# - /default_icon.jpg +#--------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := Source +DATA := data +INCLUDES := Include +EXEFS_SRC := exefs_src +# ROMFS := romfs + +APP_TITLE := BrowseNX +APP_AUTHOR := Kronos2308 +APP_VERSION := 0.2 +APP_TITLEID := 050032A5CF12E001 + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE + +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(ARCH) $(DEFINES) + +CFLAGS += $(INCLUDE) -D__SWITCH__ -DTITLE='"$(APP_TITLE)"' -DVERSION='"$(APP_VERSION)"' + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +LIBS := -lnx + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(LIBNX) + + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/Output/temp/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.jpg) + ifneq (,$(findstring $(TARGET).jpg,$(icons))) + export APP_ICON := $(TOPDIR)/$(TARGET).jpg + else + ifneq (,$(findstring icon.jpg,$(icons))) + export APP_ICON := $(TOPDIR)/icon.jpg + endif + endif +else + export APP_ICON := $(TOPDIR)/$(ICON) +endif + +ifeq ($(strip $(NO_ICON)),) + export NROFLAGS += --icon=$(APP_ICON) +endif + +ifeq ($(strip $(NO_NACP)),) + export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp +endif + +ifneq ($(APP_TITLEID),) + export NACPFLAGS += --titleid=$(APP_TITLEID) +endif + +ifneq ($(ROMFS),) + export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) +endif + +.PHONY: $(BUILD) clean all + +#--------------------------------------------------------------------------------- +all: $(BUILD) + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @[ -d $(CURDIR)/Output/temp ] || mkdir -p $(CURDIR)/Output/temp + @[ -d $(CURDIR)/Output/control ] || mkdir -p $(CURDIR)/Output/control + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + @rm -rf $(CURDIR)/Control + mkdir -p $(CURDIR)/Control + @cp $(OUTPUT).nacp $(CURDIR)/Output/control/control.nacp + @cp $(CURDIR)/Icon.jpg $(CURDIR)/Output/control/icon_AmericanEnglish.dat + @$(CURDIR)/BuildTools/hacbrewpack.exe -k $(CURDIR)/BuildTools/keys.dat --titleid $(APP_TITLEID) --exefsdir $(BUILD)/exefs --noromfs --logodir $(CURDIR)/Logo --controldir $(CURDIR)/Output/control --htmldocdir $(CURDIR)/HtmlDoc --nspdir $(CURDIR)/build + @rm -rf $(CURDIR)/Output/control + @rm -rf $(CURDIR)/Output/temp + @mv $(CURDIR)/build/$(APP_TITLEID).nsp "$(CURDIR)/Output/$(APP_TITLE)[$(APP_TITLEID)][v0].nsp" + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).nso $(TARGET).elf + + +#--------------------------------------------------------------------------------- +else +.PHONY: all + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +all : $(OUTPUT).nso $(OUTPUT).pfs0 $(OUTPUT).nacp + +$(OUTPUT).nso : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SRC) : $(HFILES_BIN) + +#--------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/Source/applet.cpp b/Source/applet.cpp new file mode 100644 index 0000000..88694f2 --- /dev/null +++ b/Source/applet.cpp @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include +#include "applet.hpp" + +extern AccountUid uid; +extern u32 __nx_applet_exit_mode; +extern std::string urlc; + +bool GetAppletMode() +{ + AppletType at = appletGetAppletType(); + if (at != AppletType_Application && at != AppletType_SystemApplication) + { + return true; + } + __nx_applet_exit_mode = 1; + return false; +} + +SwkbdTextCheckResult Keyboard_ValidateText(char *string, size_t size) { + if (strcmp(string, "") == 0) { + strncpy(string, "No has escrito nada!.", size); + return SwkbdTextCheckResult_Bad; + } + + return SwkbdTextCheckResult_OK; +} + +std::string KeyboardCall (std::string hint, std::string text){ + Result ret = 0; + SwkbdConfig swkbd; + static char input_string[256]; + + if (R_FAILED(ret = swkbdCreate(&swkbd, 0))) { + swkbdClose(&swkbd); + return ""; + } + + swkbdConfigMakePresetDefault(&swkbd); + //swkbdConfigSetInitialCursorPos (&swkbd, 0); + if (strlen(hint.c_str()) != 0) + swkbdConfigSetGuideText(&swkbd, hint.c_str()); + + if (strlen(text.c_str()) != 0) + swkbdConfigSetInitialText(&swkbd, text.c_str()); + + swkbdConfigSetTextCheckCallback(&swkbd, Keyboard_ValidateText); + + if (R_FAILED(ret = swkbdShow(&swkbd, input_string, sizeof(input_string)))) { + swkbdClose(&swkbd); + return ""; + } + + swkbdClose(&swkbd); + + char *buf = (char*)malloc(256); + strcpy(buf, input_string); + return std::string(buf); +} + + +Result WebBrowserCall(std::string url,bool nag){ + Result rc = 0; + if (nag){ + url = KeyboardCall ("Escribir URL http://", url); + urlc = url; + if (url.length() <= 0) return 0; + } + + WebCommonConfig config; + WebCommonReply reply; + WebExitReason exitReason = (WebExitReason)0; + // Create the config. There's a number of web*Create() funcs, see libnx web.h. + // webPageCreate/webNewsCreate requires running under a host title which has HtmlDocument content, when the title is an Application. When the title is an Application when using webPageCreate/webNewsCreate, and webConfigSetWhitelist is not used, the whitelist will be loaded from the content. Atmosphère hbl_html can be used to handle this. + rc = webPageCreate(&config, url.c_str()); + + printf("webPageCreate(): 0x%x\n", rc); + if (R_SUCCEEDED(rc)) { + if (nag){ + printf("Try to save logins\n");// + //mount user data to save logins and that stuff + webConfigSetUid(&config,uid); + } + printf("SetMainConfigs\n"); + webConfigSetScreenShot (&config, true); + webConfigSetBootDisplayKind (&config, WebBootDisplayKind_Black); + webConfigSetPageCache (&config, true); + webConfigSetBootLoadingIcon (&config, true); + webConfigSetPageScrollIndicator (&config, true); + webConfigSetMediaPlayerSpeedControl (&config, true); + webConfigSetMediaAutoPlay (&config, true); + if (!nag){ + printf("SetCapConfigs\n"); + webConfigSetDisplayUrlKind (&config, false); + webConfigSetMediaPlayerAutoClose (&config, true); + //webConfigSetFooter(&config, false); + + //play direct links + if(url.substr(9,9) == "-delivery") + webConfigSetBootAsMediaPlayer(&config, true); + + //block redirection + if(url.substr(0,32) == "https://jkanime.net/jkfembed.php") + { + webConfigSetWhitelist(&config, "^https://jkanime\\.net($|/)"); + } else webConfigSetWhitelist(&config, "^http*"); + } + + + // Launch the applet and wait for it to exit. + printf("Running webConfigShow...\n"); + rc = webConfigShow(&config, &reply); // If you don't use reply you can pass NULL for it. + printf("webConfigShow(): 0x%x\n", rc); + + if (R_SUCCEEDED(rc)) { // Normally you can ignore exitReason. + rc = webReplyGetExitReason(&reply, &exitReason); + printf("webReplyGetExitReason(): 0x%x", rc); + if (R_SUCCEEDED(rc)) printf(", 0x%x", exitReason); + printf("\n"); + } + } + return rc; +} + +//KeyboardCall ("Buscar Anime (3 letras minimo.)", ""); diff --git a/Source/applet.hpp b/Source/applet.hpp new file mode 100644 index 0000000..0e6601e --- /dev/null +++ b/Source/applet.hpp @@ -0,0 +1,5 @@ + +#include +std::string KeyboardCall (std::string hint="", std::string text=""); +Result WebBrowserCall(std::string url="",bool nag=false); +bool GetAppletMode(); \ No newline at end of file diff --git a/Source/main.cpp b/Source/main.cpp new file mode 100644 index 0000000..7be846a --- /dev/null +++ b/Source/main.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "applet.hpp" + +AccountUid uid; + +std::string urlc = "https://myrincon.duckdns.org"; +//MAIN INT +int main(int argc, char **argv) +{ + romfsInit(); + socketInitializeDefault(); + Result rc = 0; + rc = accountInitialize(AccountServiceType_Application); + if (R_SUCCEEDED(rc)) { + //accountGetServiceSession (); + accountGetPreselectedUser(&uid); + printf("Goted user\n"); + accountExit(); + } else printf("failed tu get user \n"); + GetAppletMode(); + + while(appletMainLoop()){ + WebBrowserCall(urlc,true); + if (urlc == ""){break;} + } + accountExit(); + hidsysExit(); + socketExit(); + romfsExit(); + + + return 0; +} \ No newline at end of file diff --git a/exefs_src/main.npdm b/exefs_src/main.npdm new file mode 100644 index 0000000..989fe0b Binary files /dev/null and b/exefs_src/main.npdm differ