mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Use coeurl for networking
Something is still wrong on shutdown, need to debug that. And CI will fail.
This commit is contained in:
parent
78c69a8f7b
commit
00f251753e
6 changed files with 97 additions and 67 deletions
|
@ -22,25 +22,20 @@ HunterGate(
|
|||
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_GTEST "Use the bundled version of Google Test."
|
||||
${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_CMARK "Use the bundled version of cmark."
|
||||
${HUNTER_ENABLED})
|
||||
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_GTEST "Use the bundled version of Google Test." ${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_CMARK "Use the bundled version of cmark." ${HUNTER_ENABLED})
|
||||
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_LMDB "Use the bundled version of lmdb."
|
||||
${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++."
|
||||
${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt5Keychain."
|
||||
option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." ${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." ${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt5Keychain." ${HUNTER_ENABLED})
|
||||
option(USE_BUNDLED_COEURL "Use a bundled version of the Curl wrapper"
|
||||
${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")
|
||||
|
||||
|
@ -119,6 +114,38 @@ if (BUILD_DOCS)
|
|||
endif (DOXYGEN_FOUND)
|
||||
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
|
||||
|
@ -339,13 +366,6 @@ set(SRC_FILES
|
|||
|
||||
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)
|
||||
hunter_add_package(OpenSSL)
|
||||
|
@ -609,9 +629,6 @@ endif()
|
|||
|
||||
target_link_libraries(nheko PRIVATE
|
||||
MatrixClient::MatrixClient
|
||||
Boost::iostreams
|
||||
Boost::system
|
||||
Boost::thread
|
||||
cmark::cmark
|
||||
spdlog::spdlog
|
||||
Qt5::Widgets
|
||||
|
@ -644,6 +661,24 @@ if (TARGET PkgConfig::GSTREAMER)
|
|||
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)
|
||||
target_link_libraries(nheko PRIVATE ntdll)
|
||||
endif()
|
||||
|
|
|
@ -136,10 +136,10 @@ choco install nheko-reborn
|
|||
- 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)
|
||||
- [mtxclient](https://github.com/Nheko-Reborn/mtxclient)
|
||||
- [coeurl](https://nheko.im/nheko-reborn/coeurl)
|
||||
- [LMDB](https://symas.com/lightning-memory-mapped-database/)
|
||||
- [lmdb++](https://github.com/hoytech/lmdbxx)
|
||||
- [cmark](https://github.com/commonmark/cmark) 0.29 or greater.
|
||||
- Boost 1.70 or greater.
|
||||
- [libolm](https://gitlab.matrix.org/matrix-org/olm)
|
||||
- [spdlog](https://github.com/gabime/spdlog)
|
||||
- [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:
|
||||
|
||||
- USE_BUNDLED_BOOST
|
||||
- USE_BUNDLED_SPDLOG
|
||||
- USE_BUNDLED_OLM
|
||||
- USE_BUNDLED_GTEST
|
||||
|
@ -173,7 +172,9 @@ The bundle flags are currently:
|
|||
- USE_BUNDLED_MTXCLIENT
|
||||
- USE_BUNDLED_LMDB
|
||||
- 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.
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ ChatPage::startInitialSync()
|
|||
nhlog::net()->error("initial sync error: {} {} {} {}",
|
||||
err->parse_error,
|
||||
status_code,
|
||||
err->error_code.message(),
|
||||
err->error_code,
|
||||
err_code);
|
||||
|
||||
// non http related errors
|
||||
|
@ -677,7 +677,7 @@ ChatPage::trySync()
|
|||
nhlog::net()->error("initial sync error: {} {} {} {}",
|
||||
err->parse_error,
|
||||
status_code,
|
||||
err->error_code.message(),
|
||||
err->error_code,
|
||||
err_code);
|
||||
emit tryDelayedSyncCb();
|
||||
return;
|
||||
|
|
|
@ -263,9 +263,7 @@ LoginPage::onMatrixIdEntered()
|
|||
http::client()->well_known([this](const mtx::responses::WellKnown &res,
|
||||
mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
using namespace boost::beast::http;
|
||||
|
||||
if (err->status_code == status::not_found) {
|
||||
if (err->status_code == 404) {
|
||||
nhlog::net()->info("Autodiscovery: No .well-known.");
|
||||
checkHomeserverVersion();
|
||||
return;
|
||||
|
@ -282,8 +280,9 @@ LoginPage::onMatrixIdEntered()
|
|||
emit versionErrorCb(tr("Autodiscovery failed. Unknown error when "
|
||||
"requesting .well-known."));
|
||||
nhlog::net()->error("Autodiscovery failed. Unknown error when "
|
||||
"requesting .well-known. {}",
|
||||
err->error_code.message());
|
||||
"requesting .well-known. {} {}",
|
||||
err->status_code,
|
||||
err->error_code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,9 +300,7 @@ LoginPage::checkHomeserverVersion()
|
|||
http::client()->versions(
|
||||
[this](const mtx::responses::Versions &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
using namespace boost::beast::http;
|
||||
|
||||
if (err->status_code == status::not_found) {
|
||||
if (err->status_code == 404) {
|
||||
emit versionErrorCb(tr("The required endpoints were not found. "
|
||||
"Possibly not a Matrix server."));
|
||||
return;
|
||||
|
|
|
@ -289,7 +289,7 @@ RegisterPage::RegisterPage(QWidget *parent)
|
|||
}
|
||||
|
||||
// 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()) {
|
||||
nhlog::net()->warn(
|
||||
"failed to retrieve registration flows: ({}) "
|
||||
|
@ -431,9 +431,7 @@ RegisterPage::onRegisterButtonClicked()
|
|||
[this, username, password](const mtx::responses::WellKnown &res,
|
||||
mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
using namespace boost::beast::http;
|
||||
|
||||
if (err->status_code == status::not_found) {
|
||||
if (err->status_code == 404) {
|
||||
nhlog::net()->info("Autodiscovery: No .well-known.");
|
||||
checkVersionAndRegister(username, password);
|
||||
return;
|
||||
|
@ -450,8 +448,9 @@ RegisterPage::onRegisterButtonClicked()
|
|||
emit versionErrorCb(tr("Autodiscovery failed. Unknown error when "
|
||||
"requesting .well-known."));
|
||||
nhlog::net()->error("Autodiscovery failed. Unknown error when "
|
||||
"requesting .well-known. {}",
|
||||
err->error_code.message());
|
||||
"requesting .well-known. {} {}",
|
||||
err->status_code,
|
||||
err->error_code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -471,9 +470,7 @@ RegisterPage::checkVersionAndRegister(const std::string &username, const std::st
|
|||
http::client()->versions(
|
||||
[this, username, password](const mtx::responses::Versions &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
using namespace boost::beast::http;
|
||||
|
||||
if (err->status_code == status::not_found) {
|
||||
if (err->status_code == 404) {
|
||||
emit versionErrorCb(tr("The required endpoints were not found. "
|
||||
"Possibly not a Matrix server."));
|
||||
return;
|
||||
|
@ -504,7 +501,7 @@ RegisterPage::checkVersionAndRegister(const std::string &username, const std::st
|
|||
}
|
||||
|
||||
// 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()) {
|
||||
nhlog::net()->warn(
|
||||
"failed to retrieve registration flows1: ({}) "
|
||||
|
|
|
@ -181,7 +181,7 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
|
|||
roomid_.toStdString(),
|
||||
[this](const mtx::pushrules::PushRule &rule, mtx::http::RequestErr &err) {
|
||||
if (err) {
|
||||
if (err->status_code == boost::beast::http::status::not_found)
|
||||
if (err->status_code == 404)
|
||||
http::client()->get_pushrules(
|
||||
"global",
|
||||
"room",
|
||||
|
|
Loading…
Reference in a new issue