tdesktop/Telegram/SourceFiles/mtproto/special_config_request.h

67 lines
1.4 KiB
C
Raw Normal View History

2017-06-26 17:38:16 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2017-06-26 17:38:16 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2017-06-26 17:38:16 +00:00
*/
#pragma once
2018-05-02 19:27:03 +00:00
#include "base/bytes.h"
2017-06-26 17:38:16 +00:00
namespace MTP {
class SpecialConfigRequest : public QObject {
public:
SpecialConfigRequest(
base::lambda<void(
DcId dcId,
const std::string &ip,
2018-05-02 19:27:03 +00:00
int port,
bytes::const_span secret)> callback,
const QString &phone);
2017-06-26 17:38:16 +00:00
private:
enum class Type {
App,
Dns,
};
struct Attempt {
Type type;
QString domain;
};
struct Request {
Request(not_null<QNetworkReply*> reply);
Request(Request &&other);
Request &operator=(Request &&other);
~Request();
void destroy();
QPointer<QNetworkReply> reply;
};
void sendNextRequest();
void performRequest(const Attempt &attempt);
void requestFinished(Type type, not_null<QNetworkReply*> reply);
QByteArray finalizeRequest(not_null<QNetworkReply*> reply);
2017-06-26 17:38:16 +00:00
void handleResponse(const QByteArray &bytes);
bool decryptSimpleConfig(const QByteArray &bytes);
base::lambda<void(
DcId dcId,
const std::string &ip,
2018-05-02 19:27:03 +00:00
int port,
bytes::const_span secret)> _callback;
QString _phone;
2017-06-26 17:38:16 +00:00
MTPhelp_ConfigSimple _simpleConfig;
QNetworkAccessManager _manager;
std::vector<Attempt> _attempts;
std::vector<Request> _requests;
2017-06-26 17:38:16 +00:00
};
} // namespace MTP