diff --git a/CMakeLists.txt b/CMakeLists.txt index dc5d33f33a..452b74f1a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,6 +219,16 @@ else() set(CoreLinkType STATIC) endif() +if(NOT ANDROID AND NOT WIN32 AND NOT APPLE) + set(HTTPS_NOT_AVAILABLE ON) +endif() + +# Made this flag negative because it's hopefully quite temporary and didn't +# want to have to update all build systems. +if(HTTPS_NOT_AVAILABLE) + add_definitions(-DHTTPS_NOT_AVAILABLE) +endif() + # Work around for some misfeature of the current glslang build system include_directories(ext/glslang) @@ -2224,9 +2234,13 @@ else() include_directories(ext/zstd/lib) endif() -target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash rcheevos naett ${GlslangLibs} +target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash rcheevos ${GlslangLibs} ${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS}) +if(NOT HTTPS_NOT_AVAILABLE) + target_link_libraries(${CoreLibName} naett) +endif() + target_compile_features(${CoreLibName} PUBLIC cxx_std_17) if(FFmpeg_FOUND) diff --git a/Common/Net/HTTPNaettRequest.cpp b/Common/Net/HTTPNaettRequest.cpp index dd0539cc39..4fce721925 100644 --- a/Common/Net/HTTPNaettRequest.cpp +++ b/Common/Net/HTTPNaettRequest.cpp @@ -1,3 +1,5 @@ +#ifndef HTTPS_NOT_AVAILABLE + #include #include "Common/Net/HTTPRequest.h" @@ -10,7 +12,7 @@ namespace http { HTTPSDownload::HTTPSDownload(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode, const std::string &name) - : Download(url, name, progress_.cancelled), method_(method), postData_(postData), postMime_(postMime), outfile_(outfile), progressBarMode_(progressBarMode) { + : Download(url, name, &cancelled_), method_(method), postData_(postData), postMime_(postMime), outfile_(outfile), progressBarMode_(progressBarMode) { } HTTPSDownload::~HTTPSDownload() { @@ -90,3 +92,5 @@ bool HTTPSDownload::Done() { } } // namespace + +#endif // HTTPS_NOT_AVAILABLE diff --git a/Common/Net/HTTPNaettRequest.h b/Common/Net/HTTPNaettRequest.h index 3dd557086e..6a9f62eba9 100644 --- a/Common/Net/HTTPNaettRequest.h +++ b/Common/Net/HTTPNaettRequest.h @@ -1,9 +1,13 @@ #pragma once -#include "Common/Net/HTTPRequest.h" -#include "ext/naett/naett.h" #include +#include "Common/Net/HTTPRequest.h" + +#ifndef HTTPS_NOT_AVAILABLE + +#include "ext/naett/naett.h" + namespace http { // Really an asynchronous request. @@ -66,3 +70,5 @@ private: }; } // namespace http + +#endif // HTTPS_NOT_AVAILABLE diff --git a/Common/Net/HTTPRequest.cpp b/Common/Net/HTTPRequest.cpp index 988f81b190..318470a09d 100644 --- a/Common/Net/HTTPRequest.cpp +++ b/Common/Net/HTTPRequest.cpp @@ -13,7 +13,11 @@ bool RequestManager::IsHttpsUrl(const std::string &url) { std::shared_ptr RequestManager::StartDownload(const std::string &url, const Path &outfile, ProgressBarMode mode, const char *acceptMime) { std::shared_ptr dl; if (IsHttpsUrl(url)) { +#ifndef HTTPS_NOT_AVAILABLE dl.reset(new HTTPSDownload(RequestMethod::GET, url, "", "", outfile, mode)); +#else + return std::shared_ptr(); +#endif } else { dl.reset(new HTTPDownload(RequestMethod::GET, url, "", "", outfile, mode)); } @@ -36,7 +40,11 @@ std::shared_ptr RequestManager::StartDownloadWithCallback( const char *acceptMime) { std::shared_ptr dl; if (IsHttpsUrl(url)) { +#ifndef HTTPS_NOT_AVAILABLE dl.reset(new HTTPSDownload(RequestMethod::GET, url, "", "", outfile, mode, name)); +#else + return std::shared_ptr(); +#endif } else { dl.reset(new HTTPDownload(RequestMethod::GET, url, "", "", outfile, mode, name)); } @@ -59,7 +67,11 @@ std::shared_ptr RequestManager::AsyncPostWithCallback( const std::string &name) { std::shared_ptr dl; if (IsHttpsUrl(url)) { +#ifndef HTTPS_NOT_AVAILABLE dl.reset(new HTTPSDownload(RequestMethod::POST, url, postData, postMime, Path(), mode, name)); +#else + return std::shared_ptr(); +#endif } else { dl.reset(new HTTPDownload(RequestMethod::POST, url, postData, postMime, Path(), mode, name)); } diff --git a/Common/Net/Resolve.cpp b/Common/Net/Resolve.cpp index 441905777d..2438fc5b33 100644 --- a/Common/Net/Resolve.cpp +++ b/Common/Net/Resolve.cpp @@ -30,11 +30,18 @@ #include "Common/Log.h" #include "Common/TimeUtil.h" +#ifndef HTTPS_NOT_AVAILABLE #include "ext/naett/naett.h" +#endif + +#if PPSSPP_PLATFORM(ANDROID) +#include +extern JavaVM *gJvm; +#endif namespace net { -int g_refCount = 0; +static bool g_naettInitialized; void Init() { @@ -43,10 +50,17 @@ void Init() WSADATA wsaData = {0}; WSAStartup(MAKEWORD(2, 2), &wsaData); #endif - if (g_refCount == 0) { + if (!g_naettInitialized) { +#ifndef HTTPS_NOT_AVAILABLE +#if PPSSPP_PLATFORM(ANDROID) + _assert_(gJvm != nullptr); + naettInit(gJvm); +#else naettInit(NULL); +#endif +#endif + g_naettInitialized = true; } - g_refCount++; } void Shutdown() diff --git a/Common/Render/Text/draw_text_android.cpp b/Common/Render/Text/draw_text_android.cpp index cab0bdca7e..d1e6244cb2 100644 --- a/Common/Render/Text/draw_text_android.cpp +++ b/Common/Render/Text/draw_text_android.cpp @@ -1,4 +1,5 @@ #include "ppsspp_config.h" + #include "Common/Log.h" #include "Common/StringUtils.h" #include "Common/System/Display.h" diff --git a/Common/System/Request.cpp b/Common/System/Request.cpp index dbfcff7c62..8e78352908 100644 --- a/Common/System/Request.cpp +++ b/Common/System/Request.cpp @@ -1,3 +1,5 @@ +#include "ppsspp_config.h" + #include #include "Common/System/Request.h" @@ -6,6 +8,17 @@ #include "Common/File/Path.h" #include "Common/TimeUtil.h" +#if PPSSPP_PLATFORM(ANDROID) + +// Maybe not the most natural place for this, but not sure what would be. It needs to be in the Common project +// unless we want to make another System_ function to retrieve it. + +#include + +JavaVM *gJvm = nullptr; + +#endif + RequestManager g_requestManager; const char *RequestTypeAsString(SystemRequestType type) { diff --git a/Common/UI/IconCache.cpp b/Common/UI/IconCache.cpp index f5b28881a0..830655e3df 100644 --- a/Common/UI/IconCache.cpp +++ b/Common/UI/IconCache.cpp @@ -239,6 +239,7 @@ bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::strin } if (data.empty()) { + _dbg_assert_(false); ERROR_LOG(G3D, "Can't insert empty data into icon cache"); return false; } diff --git a/Core/Util/PortManager.cpp b/Core/Util/PortManager.cpp index 2e70d89233..d4103e0e75 100644 --- a/Core/Util/PortManager.cpp +++ b/Core/Util/PortManager.cpp @@ -54,6 +54,7 @@ PortManager::PortManager(): m_InitState(UPNP_INITSTATE_NONE), m_LocalPort(UPNP_LOCAL_PORT_ANY), m_leaseDuration("43200") { + // Don't call net::Init or similar here, we don't want stuff like that to happen before main. } PortManager::~PortManager() { diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index f46af287ad..955592a492 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -529,6 +529,10 @@ bool System_GetPropertyBool(SystemProperty prop) { return true; case SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR: return true; // FileUtil.cpp: OpenFileInEditor +#ifndef HTTPS_NOT_AVAILABLE + case SYSPROP_SUPPORTS_HTTPS: + return true; +#endif #if PPSSPP_PLATFORM(MAC) case SYSPROP_HAS_FOLDER_BROWSER: case SYSPROP_HAS_FILE_BROWSER: diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 8f5e2e715b..3e9878bf65 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -261,6 +261,7 @@ + @@ -402,6 +403,7 @@ + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 8eb38864dd..2eedf9e8c6 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -94,6 +94,9 @@ {8b92cc15-8e3e-45b1-ba80-ad39b1a9cdc8} + + {403c3154-5e8a-4da1-ba82-8f69bef25e14} + @@ -450,6 +453,9 @@ Net + + ext\naett + @@ -853,6 +859,9 @@ Net + + ext\naett + diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index ca80a429ba..61c737396c 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -158,7 +158,8 @@ static int desiredBackbufferSizeX; static int desiredBackbufferSizeY; // Cache the class loader so we can use it from native threads. Required for TextAndroid. -static JavaVM* gJvm = nullptr; +extern JavaVM *gJvm; + static jobject gClassLoader; static jmethodID gFindClassMethod; @@ -534,6 +535,10 @@ bool System_GetPropertyBool(SystemProperty prop) { } case SYSPROP_HAS_KEYBOARD: return deviceType != DEVICE_TYPE_VR; +#ifndef HTTPS_NOT_AVAILABLE + case SYSPROP_SUPPORTS_HTTPS: + return true; +#endif default: return false; } diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index d87af41ca4..9bbb9b7a74 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -31,7 +31,9 @@ add_subdirectory(snappy) add_subdirectory(udis86) add_subdirectory(SPIRV-Cross-build) add_subdirectory(rcheevos-build) -add_subdirectory(naett-build) +if(NOT HTTPS_NOT_AVAILABLE) + add_subdirectory(naett-build) +endif() if(USE_DISCORD AND NOT IOS AND NOT LIBRETRO) add_subdirectory(discord-rpc-build) endif() diff --git a/ext/naett b/ext/naett index cad8664cf2..6206522f33 160000 --- a/ext/naett +++ b/ext/naett @@ -1 +1 @@ -Subproject commit cad8664cf236cdcf3df09c044ed0bf9e83d52555 +Subproject commit 6206522f33e2bc49fcd0c2063ff8b4e9734416c9 diff --git a/ios/main.mm b/ios/main.mm index 18d23f8517..4ca2f041dd 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -168,7 +168,10 @@ bool System_GetPropertyBool(SystemProperty prop) { #endif case SYSPROP_CAN_JIT: return get_debugged(); - +#ifndef HTTPS_NOT_AVAILABLE + case SYSPROP_SUPPORTS_HTTPS: + return true; +#endif default: return false; } diff --git a/libretro/Makefile.common b/libretro/Makefile.common index f6bba72d5e..8c6a90ca06 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -223,10 +223,9 @@ SOURCES_C += \ $(EXTDIR)/rcheevos/src/rhash/hash.c \ $(EXTDIR)/rcheevos/src/rhash/md5.c -SOURCES_C += - $(EXTDIR)/naett/naett.c - COREFLAGS += -DSTACK_LINE_READER_BUFFER_SIZE=1024 +COREFLAGS += -DHTTPS_NOT_AVAILABLE + ifeq ($(PLATFORM_EXT), android) COREFLAGS += -DHAVE_DLFCN_H else ifneq ($(PLATFORM_EXT), win32)