2016-03-24 15:57:10 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-03-24 15:57:10 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-03-24 15:57:10 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mtproto/connection_abstract.h"
|
|
|
|
|
|
|
|
namespace MTP {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class HTTPConnection : public AbstractConnection {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
HTTPConnection(QThread *thread);
|
|
|
|
|
|
|
|
void sendData(mtpBuffer &buffer) override;
|
|
|
|
void disconnectFromServer() override;
|
2017-02-23 09:57:04 +03:00
|
|
|
void connectTcp(const DcOptions::Endpoint &endpoint) override { // not supported
|
2016-03-24 15:57:10 +03:00
|
|
|
}
|
2017-02-23 09:57:04 +03:00
|
|
|
void connectHttp(const DcOptions::Endpoint &endpoint) override;
|
2016-03-24 15:57:10 +03:00
|
|
|
bool isConnected() const override;
|
|
|
|
bool usingHttpWait() override;
|
|
|
|
bool needHttpWait() override;
|
|
|
|
|
|
|
|
int32 debugState() const override;
|
|
|
|
|
|
|
|
QString transport() const override;
|
|
|
|
|
2017-02-25 19:44:02 +03:00
|
|
|
static mtpBuffer handleResponse(QNetworkReply *reply);
|
|
|
|
static qint32 handleError(QNetworkReply *reply); // returnes error code
|
|
|
|
|
2016-11-24 22:28:23 +03:00
|
|
|
public slots:
|
2016-03-24 15:57:10 +03:00
|
|
|
void requestFinished(QNetworkReply *reply);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum Status {
|
|
|
|
WaitingHttp = 0,
|
|
|
|
UsingHttp,
|
|
|
|
FinishedWork
|
|
|
|
};
|
|
|
|
Status status;
|
|
|
|
MTPint128 httpNonce;
|
|
|
|
MTPDdcOption::Flags _flags;
|
|
|
|
|
|
|
|
QNetworkAccessManager manager;
|
|
|
|
QUrl address;
|
|
|
|
|
|
|
|
typedef QSet<QNetworkReply*> Requests;
|
|
|
|
Requests requests;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace MTP
|