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"
|
|
|
|
|
|
|
|
namespace MTP {
|
|
|
|
namespace internal {
|
|
|
|
|
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
|
|
|
|
2018-04-30 15:49:03 +00:00
|
|
|
TimeMs pingTime() const override;
|
2018-05-17 19:58:00 +00:00
|
|
|
TimeMs 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,
|
|
|
|
int16 protocolDcId) 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);
|
|
|
|
static qint32 handleError(QNetworkReply *reply); // returnes error code
|
|
|
|
|
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
|
|
|
|
2018-04-30 15:49:03 +00:00
|
|
|
TimeMs _pingTime = 0;
|
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace MTP
|