2016-03-24 12:57:10 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-03-24 12:57:10 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mtproto/connection_abstract.h"
|
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtNetwork/QNetworkAccessManager>
|
|
|
|
#include <QtNetwork/QNetworkReply>
|
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
namespace MTP {
|
2019-12-02 13:10:19 +00:00
|
|
|
namespace details {
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2018-05-17 10:27:27 +00:00
|
|
|
class HttpConnection : public AbstractConnection {
|
2016-03-24 12:57:10 +00:00
|
|
|
public:
|
2018-05-17 19:58:00 +00:00
|
|
|
HttpConnection(QThread *thread, const ProxyData &proxy);
|
|
|
|
|
|
|
|
ConnectionPointer clone(const ProxyData &proxy) override;
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time pingTime() const override;
|
|
|
|
crl::time fullConnectTimeout() const override;
|
2018-06-25 18:55:27 +00:00
|
|
|
void sendData(mtpBuffer &&buffer) override;
|
2016-03-24 12:57:10 +00:00
|
|
|
void disconnectFromServer() override;
|
2018-04-24 19:09:20 +00:00
|
|
|
void connectToServer(
|
2018-05-17 10:27:27 +00:00
|
|
|
const QString &address,
|
2018-04-24 19:09:20 +00:00
|
|
|
int port,
|
|
|
|
const bytes::vector &protocolSecret,
|
2021-06-15 12:45:48 +00:00
|
|
|
int16 protocolDcId,
|
|
|
|
bool protocolForFiles) override;
|
2016-03-24 12:57:10 +00:00
|
|
|
bool isConnected() const override;
|
|
|
|
bool usingHttpWait() override;
|
|
|
|
bool needHttpWait() override;
|
|
|
|
|
|
|
|
int32 debugState() const override;
|
|
|
|
|
|
|
|
QString transport() const override;
|
2018-04-24 19:09:20 +00:00
|
|
|
QString tag() const override;
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2017-02-25 16:44:02 +00:00
|
|
|
static mtpBuffer handleResponse(QNetworkReply *reply);
|
2021-06-15 12:45:48 +00:00
|
|
|
static qint32 handleError(QNetworkReply *reply); // Returns error code.
|
2017-02-25 16:44:02 +00:00
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
private:
|
2018-04-24 19:09:20 +00:00
|
|
|
QUrl url() const;
|
|
|
|
|
2018-05-17 10:27:27 +00:00
|
|
|
void requestFinished(QNetworkReply *reply);
|
|
|
|
|
|
|
|
enum class Status {
|
|
|
|
Waiting = 0,
|
|
|
|
Ready,
|
|
|
|
Finished,
|
2016-03-24 12:57:10 +00:00
|
|
|
};
|
2018-05-17 10:27:27 +00:00
|
|
|
Status _status = Status::Waiting;
|
|
|
|
MTPint128 _checkNonce;
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2018-05-17 10:27:27 +00:00
|
|
|
QNetworkAccessManager _manager;
|
2018-04-24 19:09:20 +00:00
|
|
|
QString _address;
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2018-05-17 10:27:27 +00:00
|
|
|
QSet<QNetworkReply*> _requests;
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _pingTime = 0;
|
2018-04-30 15:49:03 +00:00
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
};
|
|
|
|
|
2019-12-02 13:10:19 +00:00
|
|
|
} // namespace details
|
2016-03-24 12:57:10 +00:00
|
|
|
} // namespace MTP
|