mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Merge pull request #626 from Nheko-Reborn/curl
Use coeurl for networking
This commit is contained in:
commit
25461b20eb
13 changed files with 184 additions and 105 deletions
|
@ -27,20 +27,21 @@ build-gcc7:
|
|||
- update-alternatives --install /usr/bin/g++ g++ "/usr/bin/${CXX}" 10
|
||||
- update-alternatives --set gcc "/usr/bin/${CC}"
|
||||
- update-alternatives --set g++ "/usr/bin/${CXX}"
|
||||
- rm -rf ../.hunter && mv .hunter ../.hunter || true
|
||||
script:
|
||||
- export PATH="/usr/lib/ccache:${PATH}"
|
||||
- export CMAKE_BUILD_PARALLEL_LEVEL=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
|
||||
- export PATH="/usr/local/bin/:${PATH}"
|
||||
- . "/opt/qt${QT_PKG}/bin/qt${QT_PKG}-env.sh" || true
|
||||
- mkdir -p .deps/usr .hunter
|
||||
- mkdir -p build
|
||||
- cmake -GNinja -H. -Bbuild
|
||||
-DCMAKE_INSTALL_PREFIX=.deps/usr
|
||||
-DHUNTER_ROOT=".hunter"
|
||||
-DHUNTER_ROOT="../.hunter"
|
||||
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BUNDLED_OPENSSL=ON -DUSE_BUNDLED_LMDB=OFF
|
||||
-DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
||||
-DCI_BUILD=ON
|
||||
- cmake --build build
|
||||
after_script:
|
||||
- mv ../.hunter .hunter
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
paths:
|
||||
|
@ -55,13 +56,14 @@ build-macos:
|
|||
- brew reinstall --force python3
|
||||
- brew bundle --file=./.ci/macos/Brewfile --force --cleanup
|
||||
- pip3 install dmgbuild
|
||||
- rm -rf ../.hunter && mv .hunter ../.hunter || true
|
||||
script:
|
||||
- export PATH=/usr/local/opt/qt/bin/:${PATH}
|
||||
- export CMAKE_PREFIX_PATH=/usr/local/opt/qt5
|
||||
- cmake -GNinja -H. -Bbuild
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
-DCMAKE_INSTALL_PREFIX=.deps/usr
|
||||
-DHUNTER_ROOT=".hunter"
|
||||
-DHUNTER_ROOT="../.hunter"
|
||||
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DHUNTER_CONFIGURATION_TYPES=RelWithDebInfo
|
||||
-DUSE_BUNDLED_OPENSSL=ON
|
||||
|
@ -69,6 +71,7 @@ build-macos:
|
|||
-DCI_BUILD=ON
|
||||
- cmake --build build
|
||||
after_script:
|
||||
- mv ../.hunter .hunter
|
||||
- ./.ci/macos/deploy.sh
|
||||
- ./.ci/upload-nightly-gitlab.sh artifacts/nheko-${CI_COMMIT_SHORT_SHA}.dmg
|
||||
artifacts:
|
||||
|
@ -164,7 +167,7 @@ appimage-amd64:
|
|||
# update appimage-builder (optional)
|
||||
- pip3 install --upgrade git+https://www.opencode.net/azubieta/appimagecraft.git
|
||||
|
||||
- apt-get install -y qt5-default qtdeclarative5-dev qttools5-dev qtscript5-dev qtquickcontrols2-5-dev qtmultimedia5-dev libqt5svg5-dev liblmdb-dev libssl-dev git ninja-build qt5keychain-dev libgtest-dev ccache
|
||||
- apt-get install -y qt5-default qtdeclarative5-dev qttools5-dev qtscript5-dev qtquickcontrols2-5-dev qtmultimedia5-dev libqt5svg5-dev liblmdb-dev libssl-dev git ninja-build qt5keychain-dev libgtest-dev ccache libevent-dev libcurl4-openssl-dev
|
||||
- wget https://github.com/Kitware/CMake/releases/download/v3.19.0/cmake-3.19.0-Linux-x86_64.sh && sh cmake-3.19.0-Linux-x86_64.sh --skip-license --prefix=/usr/local
|
||||
- /usr/sbin/update-ccache-symlinks
|
||||
script:
|
||||
|
@ -174,7 +177,6 @@ appimage-amd64:
|
|||
-DHUNTER_ROOT=".hunter"
|
||||
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF
|
||||
-DHUNTER_CONFIGURATION_TYPES=Release
|
||||
-DUSE_BUNDLED_BOOST=ON
|
||||
-DUSE_BUNDLED_SPDLOG=ON
|
||||
-DUSE_BUNDLED_OLM=ON
|
||||
-DUSE_BUNDLED_GTEST=OFF
|
||||
|
@ -184,8 +186,10 @@ appimage-amd64:
|
|||
-DUSE_BUNDLED_MTXCLIENT=ON
|
||||
-DUSE_BUNDLED_LMDB=OFF
|
||||
-DUSE_BUNDLED_LMDBXX=ON
|
||||
-DUSE_BUNDLED_TWEENY=ON
|
||||
-DUSE_BUNDLED_QTKEYCHAIN=OFF
|
||||
-DUSE_BUNDLED_LIBEVENT=OFF
|
||||
-DUSE_BUNDLED_LIBCURL=OFF
|
||||
-DUSE_BUNDLED_COEURL=ON
|
||||
- DESTDIR=`pwd`/AppDir ninja -C build install/local
|
||||
- DESTDIR=`pwd`/AppDir ninja -C build _deps/cmark-build/src/install
|
||||
- mkdir -p AppDir/usr/lib/x86_64-linux-gnu AppDir/lib/x86_64-linux-gnu
|
||||
|
|
|
@ -38,8 +38,11 @@ AppDir:
|
|||
- kimageformat-plugins
|
||||
- libbs2b0
|
||||
- libbz2-1.0
|
||||
- libcurl4
|
||||
- libelf1
|
||||
- libexpat1
|
||||
- libevent-core-2.1-6
|
||||
- libevent-pthreads-2.1-6
|
||||
- libhogweed4
|
||||
- libjpeg-turbo8
|
||||
- libkf5archive5
|
||||
|
|
102
CMakeLists.txt
102
CMakeLists.txt
|
@ -18,29 +18,24 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
|
|||
option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.288.tar.gz"
|
||||
SHA1 "6c9b2bc606d86ae31f96a62fc68f0a593024815b"
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.305.tar.gz"
|
||||
SHA1 "fc8d7a6dac2fa23681847b3872d88d3839b657b0"
|
||||
)
|
||||
|
||||
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
|
||||
|
@ -238,7 +265,10 @@ set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
|
|||
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||
|
||||
cmake_host_system_information(RESULT BUILD_HOST QUERY HOSTNAME)
|
||||
set(BUILD_USER $ENV{USER})
|
||||
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(backtrace_symbols_fd "execinfo.h" HAVE_BACKTRACE_SYMBOLS_FD)
|
||||
|
||||
configure_file(cmake/nheko.h config/nheko.h)
|
||||
|
||||
|
||||
|
@ -339,13 +369,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)
|
||||
|
@ -356,7 +379,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
|||
FetchContent_Declare(
|
||||
MatrixClient
|
||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||
GIT_TAG fdb2016eff4f2e91f17c343e9fcb0bfab5e78b63
|
||||
GIT_TAG 9ecaefe377d4dab688caee186e4a263cb7f105e8
|
||||
)
|
||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||
|
@ -587,6 +610,10 @@ if(WIN32)
|
|||
target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601)
|
||||
else()
|
||||
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
|
||||
|
||||
if (HAVE_BACKTRACE_SYMBOLS_FD AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set_target_properties(nheko PROPERTIES ENABLE_EXPORTS ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -609,9 +636,6 @@ endif()
|
|||
|
||||
target_link_libraries(nheko PRIVATE
|
||||
MatrixClient::MatrixClient
|
||||
Boost::iostreams
|
||||
Boost::system
|
||||
Boost::thread
|
||||
cmark::cmark
|
||||
spdlog::spdlog
|
||||
Qt5::Widgets
|
||||
|
@ -644,6 +668,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.
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
namespace nheko {
|
||||
constexpr auto version = "${PROJECT_VERSION}";
|
||||
constexpr auto build_user = "${BUILD_USER}@${BUILD_HOST}";
|
||||
constexpr auto build_os = "${CMAKE_HOST_SYSTEM_NAME}";
|
||||
constexpr auto enable_debug_log = ${SPDLOG_DEBUG_ON};
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
#define HAVE_BACKTRACE_SYMBOLS_FD ${HAVE_BACKTRACE_SYMBOLS_FD}
|
||||
// clang-format on
|
||||
|
|
|
@ -37,6 +37,19 @@ modules:
|
|||
- prefix=/app
|
||||
no-autogen: true
|
||||
subdir: libraries/liblmdb
|
||||
- name: libevent
|
||||
buildsystem: autotools
|
||||
config-opts:
|
||||
- --disable-shared
|
||||
- --prefix=/app
|
||||
- --disable-openssl
|
||||
sources:
|
||||
- sha256: 92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
|
||||
type: archive
|
||||
url: https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
|
||||
make-install-args:
|
||||
- prefix=/app
|
||||
no-autogen: true
|
||||
- name: cmark
|
||||
buildsystem: cmake-ninja
|
||||
builddir: true
|
||||
|
@ -87,16 +100,6 @@ modules:
|
|||
- sha256: d51a3a8d3efbb1139d7608e28782ea9efea7e7933157e8ff8184901efd8ee760
|
||||
type: archive
|
||||
url: https://github.com/nlohmann/json/archive/v3.7.0.tar.gz
|
||||
- build-commands:
|
||||
- ./bootstrap.sh --with-libraries=thread,system,iostreams --prefix=/app
|
||||
- ./b2 -d0 variant=release link=static threading=multi --layout=system
|
||||
- ./b2 -d0 install
|
||||
buildsystem: simple
|
||||
name: boost
|
||||
sources:
|
||||
- sha256: 59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722
|
||||
type: archive
|
||||
url: https://sourceforge.net/projects/boost/files/boost/1.72.0/boost_1_72_0.tar.bz2
|
||||
- buildsystem: meson
|
||||
name: gstreamer
|
||||
sources:
|
||||
|
@ -142,6 +145,14 @@ modules:
|
|||
tag: 1.18.3
|
||||
type: git
|
||||
url: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad.git
|
||||
- buildsystem: meson
|
||||
config-opts:
|
||||
- -Ddefault_library=static
|
||||
name: coeurl
|
||||
sources:
|
||||
- commit: 417821a07cfe4429b08a2efed5e480a498087afd
|
||||
type: git
|
||||
url: https://nheko.im/nheko-reborn/coeurl.git
|
||||
- config-opts:
|
||||
- -DBUILD_LIB_TESTS=OFF
|
||||
- -DBUILD_LIB_EXAMPLES=OFF
|
||||
|
@ -150,19 +161,9 @@ modules:
|
|||
buildsystem: cmake-ninja
|
||||
name: mtxclient
|
||||
sources:
|
||||
- commit: fdb2016eff4f2e91f17c343e9fcb0bfab5e78b63
|
||||
- commit: 9ecaefe377d4dab688caee186e4a263cb7f105e8
|
||||
type: git
|
||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||
- config-opts:
|
||||
- -DCMAKE_BUILD_TYPE=Release
|
||||
- -DTWEENY_BUILD_DOCUMENTATION=OFF
|
||||
- -DTWEENY_BUILD_EXAMPLES=OFF
|
||||
buildsystem: cmake-ninja
|
||||
name: tweeny
|
||||
sources:
|
||||
- sha256: 482857256a7235646004682912badb6521d361ed6987c8ebdae7986bf64ce694
|
||||
type: archive
|
||||
url: https://github.com/mobius3/tweeny/archive/43f4130f7e4a67c19d870b60864bc2862c19b81f.tar.gz
|
||||
- config-opts:
|
||||
- -DCMAKE_BUILD_TYPE=Release
|
||||
- -DLMDBXX_INCLUDE_DIR=.deps/lmdbxx
|
||||
|
|
|
@ -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
|
||||
|
@ -674,10 +674,10 @@ ChatPage::trySync()
|
|||
return;
|
||||
}
|
||||
|
||||
nhlog::net()->error("initial sync error: {} {} {} {}",
|
||||
nhlog::net()->error("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;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <mtx/events.hpp>
|
||||
#include <mtx/events/encrypted.hpp>
|
||||
|
|
|
@ -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: ({}) "
|
||||
|
|
39
src/main.cpp
39
src/main.cpp
|
@ -40,15 +40,48 @@
|
|||
QQmlDebuggingEnabler enabler;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <boost/stacktrace.hpp>
|
||||
#if HAVE_BACKTRACE_SYMBOLS_FD
|
||||
#include <csignal>
|
||||
#include <execinfo.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void
|
||||
stacktraceHandler(int signum)
|
||||
{
|
||||
std::signal(signum, SIG_DFL);
|
||||
boost::stacktrace::safe_dump_to("./nheko-backtrace.dump");
|
||||
|
||||
// boost::stacktrace::safe_dump_to("./nheko-backtrace.dump");
|
||||
|
||||
// see
|
||||
// https://stackoverflow.com/questions/77005/how-to-automatically-generate-a-stacktrace-when-my-program-crashes/77336#77336
|
||||
void *array[50];
|
||||
size_t size;
|
||||
|
||||
// get void*'s for all entries on the stack
|
||||
size = backtrace(array, 50);
|
||||
|
||||
// print out all the frames to stderr
|
||||
fprintf(stderr, "Error: signal %d:\n", signum);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
|
||||
int file = ::open("/tmp/nheko-crash.dump",
|
||||
O_CREAT | O_WRONLY | O_TRUNC
|
||||
#if defined(S_IWUSR) && defined(S_IRUSR)
|
||||
,
|
||||
S_IWUSR | S_IRUSR
|
||||
#elif defined(S_IWRITE) && defined(S_IREAD)
|
||||
,
|
||||
S_IWRITE | S_IREAD
|
||||
#endif
|
||||
);
|
||||
if (file != -1) {
|
||||
constexpr char header[] = "Error: signal\n";
|
||||
[[maybe_unused]] auto ret = write(file, header, std::size(header) - 1);
|
||||
backtrace_symbols_fd(array, size, file);
|
||||
close(file);
|
||||
}
|
||||
|
||||
std::raise(SIGABRT);
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ InputBar::message(QString msg, MarkdownOverride useMarkdown, bool rainbowify)
|
|||
firstLine = false;
|
||||
body = QString("> <%1> %2\n").arg(related.quoted_user).arg(line);
|
||||
} else {
|
||||
body = QString("%1\n> %2\n").arg(body).arg(line);
|
||||
body += QString("> %1\n").arg(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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