/*
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDebug>
#include <QFile>
#include <QImageReader>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMimeDatabase>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QPixmap>
#include <QProcessEnvironment>
#include <QSettings>
#include <QUrlQuery>
#include <QtConcurrent>
#include <mtx/errors.hpp>
#include "MatrixClient.h"
#include <mtxclient/http/client.hpp>
namespace {
std::unique_ptr<MatrixClient> instance_ = nullptr;
}
namespace http {
std::shared_ptr<mtx::http::Client> client_ = nullptr;
void
init()
{
if (!instance_)
instance_ = std::make_unique<MatrixClient>();
}
MatrixClient *
client()
{
return instance_.get();
}
}
MatrixClient::MatrixClient(QObject *parent)
: QNetworkAccessManager(parent)
, clientApiUrl_{"/_matrix/client/r0"}
, mediaApiUrl_{"/_matrix/media/r0"}
, serverProtocol_{"https"}
{
qRegisterMetaType<mtx::responses