Use coeurl for networking

Something is still wrong on shutdown, need to debug that.
And CI will fail.
This commit is contained in:
Nicolas Werner 2021-06-30 02:43:36 +02:00
parent 78c69a8f7b
commit 00f251753e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
6 changed files with 97 additions and 67 deletions

View file

@ -20,27 +20,22 @@ include("cmake/HunterGate.cmake")
HunterGate( HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.288.tar.gz" URL "https://github.com/cpp-pm/hunter/archive/v0.23.288.tar.gz"
SHA1 "6c9b2bc606d86ae31f96a62fc68f0a593024815b" SHA1 "6c9b2bc606d86ae31f96a62fc68f0a593024815b"
) )
option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED}) option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${HUNTER_ENABLED})
option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog."
${HUNTER_ENABLED})
option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED}) option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED})
option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." ${HUNTER_ENABLED})
${HUNTER_ENABLED}) option(USE_BUNDLED_CMARK "Use the bundled version of cmark." ${HUNTER_ENABLED})
option(USE_BUNDLED_CMARK "Use the bundled version of cmark." option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json." ${HUNTER_ENABLED})
${HUNTER_ENABLED}) option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL." OFF)
option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json."
${HUNTER_ENABLED})
option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL."
OFF)
option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED}) option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED})
option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." ${HUNTER_ENABLED})
${HUNTER_ENABLED}) option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." ${HUNTER_ENABLED})
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt5Keychain." ${HUNTER_ENABLED})
${HUNTER_ENABLED}) option(USE_BUNDLED_COEURL "Use a bundled version of the Curl wrapper"
option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt5Keychain."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_LIBEVENT "Use the bundled version of spdlog." ${HUNTER_ENABLED})
option(USE_BUNDLED_LIBCURL "Use the bundled version of spdlog." ${HUNTER_ENABLED})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
@ -119,6 +114,38 @@ if (BUILD_DOCS)
endif (DOXYGEN_FOUND) endif (DOXYGEN_FOUND)
endif() endif()
#
## coeurl
#
## Need to repeat all libevent deps?!?
if (USE_BUNDLED_LIBEVENT)
hunter_add_package(Libevent)
find_package(Libevent CONFIG REQUIRED)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libevent_core REQUIRED IMPORTED_TARGET libevent_core)
if (WIN32)
pkg_check_modules(libevent_windows REQUIRED IMPORTED_TARGET libevent_windows)
else()
pkg_check_modules(libevent_pthreads REQUIRED IMPORTED_TARGET
libevent_pthreads)
endif()
endif()
# curl
if (USE_BUNDLED_LIBCURL)
hunter_add_package(CURL)
find_package(CURL CONFIG REQUIRED)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl)
endif()
# spdlog
if(USE_BUNDLED_SPDLOG)
hunter_add_package(spdlog)
endif()
find_package(spdlog 1.0.0 CONFIG REQUIRED)
# #
# LMDB # LMDB
@ -156,7 +183,7 @@ if (USE_BUNDLED_QTKEYCHAIN)
set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "") set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(qt5keychain) FetchContent_MakeAvailable(qt5keychain)
else() else()
find_package(Qt5Keychain REQUIRED) find_package(Qt5Keychain REQUIRED)
endif() endif()
if (APPLE) if (APPLE)
@ -339,13 +366,6 @@ set(SRC_FILES
include(FeatureSummary) include(FeatureSummary)
if(USE_BUNDLED_BOOST)
hunter_add_package(Boost COMPONENTS iostreams system thread)
endif()
find_package(Boost 1.70 REQUIRED
COMPONENTS iostreams
system
thread)
if(USE_BUNDLED_OPENSSL) if(USE_BUNDLED_OPENSSL)
hunter_add_package(OpenSSL) hunter_add_package(OpenSSL)
@ -604,14 +624,11 @@ target_include_directories(nheko PRIVATE src includes third_party/blurhash third
# Fixup bundled keychain include dirs # Fixup bundled keychain include dirs
if (USE_BUNDLED_QTKEYCHAIN) if (USE_BUNDLED_QTKEYCHAIN)
target_include_directories(nheko PRIVATE ${qt5keychain_SOURCE_DIR} ${qt5keychain_BINARY_DIR}) target_include_directories(nheko PRIVATE ${qt5keychain_SOURCE_DIR} ${qt5keychain_BINARY_DIR})
endif() endif()
target_link_libraries(nheko PRIVATE target_link_libraries(nheko PRIVATE
MatrixClient::MatrixClient MatrixClient::MatrixClient
Boost::iostreams
Boost::system
Boost::thread
cmark::cmark cmark::cmark
spdlog::spdlog spdlog::spdlog
Qt5::Widgets Qt5::Widgets
@ -628,7 +645,7 @@ target_link_libraries(nheko PRIVATE
SingleApplication::SingleApplication) SingleApplication::SingleApplication)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
target_precompile_headers(nheko target_precompile_headers(nheko
PRIVATE PRIVATE
<string> <string>
<algorithm> <algorithm>
@ -644,6 +661,24 @@ if (TARGET PkgConfig::GSTREAMER)
endif() endif()
endif() endif()
if(USE_BUNDLED_COEURL)
include(FetchContent)
FetchContent_Declare(
coeurl
GIT_REPOSITORY https://nheko.im/Nheko-Reborn/coeurl.git
GIT_TAG 417821a07cfe4429b08a2efed5e480a498087afd
)
FetchContent_MakeAvailable(coeurl)
target_link_libraries(nheko PUBLIC coeurl::coeurl)
elseif(coeurl_DIR)
find_package(coeurl CONFIG REQUIRED)
target_link_libraries(nheko PUBLIC coeurl::coeurl)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(coeurl REQUIRED IMPORTED_TARGET coeurl)
target_link_libraries(nheko PUBLIC PkgConfig::coeurl)
endif()
if(MSVC) if(MSVC)
target_link_libraries(nheko PRIVATE ntdll) target_link_libraries(nheko PRIVATE ntdll)
endif() endif()

View file

@ -136,10 +136,10 @@ choco install nheko-reborn
- Qt5 (5.12 or greater). Required for overlapping hover handlers in Qml. - Qt5 (5.12 or greater). Required for overlapping hover handlers in Qml.
- CMake 3.15 or greater. (Lower version may work, but may break boost linking) - CMake 3.15 or greater. (Lower version may work, but may break boost linking)
- [mtxclient](https://github.com/Nheko-Reborn/mtxclient) - [mtxclient](https://github.com/Nheko-Reborn/mtxclient)
- [coeurl](https://nheko.im/nheko-reborn/coeurl)
- [LMDB](https://symas.com/lightning-memory-mapped-database/) - [LMDB](https://symas.com/lightning-memory-mapped-database/)
- [lmdb++](https://github.com/hoytech/lmdbxx) - [lmdb++](https://github.com/hoytech/lmdbxx)
- [cmark](https://github.com/commonmark/cmark) 0.29 or greater. - [cmark](https://github.com/commonmark/cmark) 0.29 or greater.
- Boost 1.70 or greater.
- [libolm](https://gitlab.matrix.org/matrix-org/olm) - [libolm](https://gitlab.matrix.org/matrix-org/olm)
- [spdlog](https://github.com/gabime/spdlog) - [spdlog](https://github.com/gabime/spdlog)
- [GStreamer](https://gitlab.freedesktop.org/gstreamer) 1.18.0 or greater (optional, needed for VoIP support). - [GStreamer](https://gitlab.freedesktop.org/gstreamer) 1.18.0 or greater (optional, needed for VoIP support).
@ -163,7 +163,6 @@ If you experience build issues and you are trying to link `mtxclient` library wi
The bundle flags are currently: The bundle flags are currently:
- USE_BUNDLED_BOOST
- USE_BUNDLED_SPDLOG - USE_BUNDLED_SPDLOG
- USE_BUNDLED_OLM - USE_BUNDLED_OLM
- USE_BUNDLED_GTEST - USE_BUNDLED_GTEST
@ -173,7 +172,9 @@ The bundle flags are currently:
- USE_BUNDLED_MTXCLIENT - USE_BUNDLED_MTXCLIENT
- USE_BUNDLED_LMDB - USE_BUNDLED_LMDB
- USE_BUNDLED_LMDBXX - USE_BUNDLED_LMDBXX
- USE_BUNDLED_TWEENY - USE_BUNDLED_COEURL
- USE_BUNDLED_LIBCURL
- USE_BUNDLED_LIBEVENT
A note on bundled OpenSSL: You need to explicitly enable it and it will not be using your system certificate directory by default, if you enable it. You need to override that at runtime with the SSL_CERT_FILE variable. On Windows it will still be using your system certificates though, since it loads them from the system store instead of the OpenSSL directory. A note on bundled OpenSSL: You need to explicitly enable it and it will not be using your system certificate directory by default, if you enable it. You need to override that at runtime with the SSL_CERT_FILE variable. On Windows it will still be using your system certificates though, since it loads them from the system store instead of the OpenSSL directory.

View file

@ -550,7 +550,7 @@ ChatPage::startInitialSync()
nhlog::net()->error("initial sync error: {} {} {} {}", nhlog::net()->error("initial sync error: {} {} {} {}",
err->parse_error, err->parse_error,
status_code, status_code,
err->error_code.message(), err->error_code,
err_code); err_code);
// non http related errors // non http related errors
@ -677,7 +677,7 @@ ChatPage::trySync()
nhlog::net()->error("initial sync error: {} {} {} {}", nhlog::net()->error("initial sync error: {} {} {} {}",
err->parse_error, err->parse_error,
status_code, status_code,
err->error_code.message(), err->error_code,
err_code); err_code);
emit tryDelayedSyncCb(); emit tryDelayedSyncCb();
return; return;

View file

@ -263,9 +263,7 @@ LoginPage::onMatrixIdEntered()
http::client()->well_known([this](const mtx::responses::WellKnown &res, http::client()->well_known([this](const mtx::responses::WellKnown &res,
mtx::http::RequestErr err) { mtx::http::RequestErr err) {
if (err) { if (err) {
using namespace boost::beast::http; if (err->status_code == 404) {
if (err->status_code == status::not_found) {
nhlog::net()->info("Autodiscovery: No .well-known."); nhlog::net()->info("Autodiscovery: No .well-known.");
checkHomeserverVersion(); checkHomeserverVersion();
return; return;
@ -282,8 +280,9 @@ LoginPage::onMatrixIdEntered()
emit versionErrorCb(tr("Autodiscovery failed. Unknown error when " emit versionErrorCb(tr("Autodiscovery failed. Unknown error when "
"requesting .well-known.")); "requesting .well-known."));
nhlog::net()->error("Autodiscovery failed. Unknown error when " nhlog::net()->error("Autodiscovery failed. Unknown error when "
"requesting .well-known. {}", "requesting .well-known. {} {}",
err->error_code.message()); err->status_code,
err->error_code);
return; return;
} }
@ -301,9 +300,7 @@ LoginPage::checkHomeserverVersion()
http::client()->versions( http::client()->versions(
[this](const mtx::responses::Versions &, mtx::http::RequestErr err) { [this](const mtx::responses::Versions &, mtx::http::RequestErr err) {
if (err) { if (err) {
using namespace boost::beast::http; if (err->status_code == 404) {
if (err->status_code == status::not_found) {
emit versionErrorCb(tr("The required endpoints were not found. " emit versionErrorCb(tr("The required endpoints were not found. "
"Possibly not a Matrix server.")); "Possibly not a Matrix server."));
return; return;

View file

@ -289,7 +289,7 @@ RegisterPage::RegisterPage(QWidget *parent)
} }
// The server requires registration flows. // The server requires registration flows.
if (err->status_code == boost::beast::http::status::unauthorized) { if (err->status_code == 401) {
if (err->matrix_error.unauthorized.flows.empty()) { if (err->matrix_error.unauthorized.flows.empty()) {
nhlog::net()->warn( nhlog::net()->warn(
"failed to retrieve registration flows: ({}) " "failed to retrieve registration flows: ({}) "
@ -431,9 +431,7 @@ RegisterPage::onRegisterButtonClicked()
[this, username, password](const mtx::responses::WellKnown &res, [this, username, password](const mtx::responses::WellKnown &res,
mtx::http::RequestErr err) { mtx::http::RequestErr err) {
if (err) { if (err) {
using namespace boost::beast::http; if (err->status_code == 404) {
if (err->status_code == status::not_found) {
nhlog::net()->info("Autodiscovery: No .well-known."); nhlog::net()->info("Autodiscovery: No .well-known.");
checkVersionAndRegister(username, password); checkVersionAndRegister(username, password);
return; return;
@ -450,8 +448,9 @@ RegisterPage::onRegisterButtonClicked()
emit versionErrorCb(tr("Autodiscovery failed. Unknown error when " emit versionErrorCb(tr("Autodiscovery failed. Unknown error when "
"requesting .well-known.")); "requesting .well-known."));
nhlog::net()->error("Autodiscovery failed. Unknown error when " nhlog::net()->error("Autodiscovery failed. Unknown error when "
"requesting .well-known. {}", "requesting .well-known. {} {}",
err->error_code.message()); err->status_code,
err->error_code);
return; return;
} }
@ -471,9 +470,7 @@ RegisterPage::checkVersionAndRegister(const std::string &username, const std::st
http::client()->versions( http::client()->versions(
[this, username, password](const mtx::responses::Versions &, mtx::http::RequestErr err) { [this, username, password](const mtx::responses::Versions &, mtx::http::RequestErr err) {
if (err) { if (err) {
using namespace boost::beast::http; if (err->status_code == 404) {
if (err->status_code == status::not_found) {
emit versionErrorCb(tr("The required endpoints were not found. " emit versionErrorCb(tr("The required endpoints were not found. "
"Possibly not a Matrix server.")); "Possibly not a Matrix server."));
return; return;
@ -504,7 +501,7 @@ RegisterPage::checkVersionAndRegister(const std::string &username, const std::st
} }
// The server requires registration flows. // The server requires registration flows.
if (err->status_code == boost::beast::http::status::unauthorized) { if (err->status_code == 401) {
if (err->matrix_error.unauthorized.flows.empty()) { if (err->matrix_error.unauthorized.flows.empty()) {
nhlog::net()->warn( nhlog::net()->warn(
"failed to retrieve registration flows1: ({}) " "failed to retrieve registration flows1: ({}) "

View file

@ -181,7 +181,7 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
roomid_.toStdString(), roomid_.toStdString(),
[this](const mtx::pushrules::PushRule &rule, mtx::http::RequestErr &err) { [this](const mtx::pushrules::PushRule &rule, mtx::http::RequestErr &err) {
if (err) { if (err) {
if (err->status_code == boost::beast::http::status::not_found) if (err->status_code == 404)
http::client()->get_pushrules( http::client()->get_pushrules(
"global", "global",
"room", "room",