| 1 | // SPDX-FileCopyrightText: Nheko Contributors |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "MatrixClient.h" |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | #include <QMetaType> |
| 10 | #include <QObject> |
| 11 | #include <QStandardPaths> |
| 12 | #include <QString> |
| 13 | |
| 14 | #include <mtx/responses.hpp> |
| 15 | |
| 16 | #include "Logging.h" |
| 17 | #include "UserSettingsPage.h" |
| 18 | |
| 19 | namespace http { |
| 20 | |
| 21 | mtx::http::Client * |
| 22 | client() |
| 23 | { |
| 24 | static auto client_ = [] { |
| 25 | auto c = std::make_shared<mtx::http::Client>(); |
| 26 | |
| 27 | // Disabled by default until CPU usage and reliability improves |
| 28 | if (UserSettings::instance()->qsettings()->value("enable_http3").toBool()) { |
| 29 | nhlog::net()->warn("Enabling http3 support. This is currently usually a worse " |
| 30 | "experience, so you are on your own."); |
| 31 | c->alt_svc_cache_path((QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + |
| 32 | "/curl_alt_svc_cache.txt") |
| 33 | .toStdString()); |
| 34 | } |
| 35 | return c; |
| 36 | }(); |
| 37 | return client_.get(); |
| 38 | } |
| 39 | |
| 40 | bool |
| 41 | is_logged_in() |
| 42 | { |
| 43 | return !client()->access_token().empty(); |
| 44 | } |
| 45 | |
| 46 | void |
| 47 | init() |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | } // namespace http |