2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
namespace MTP {
|
2017-02-24 17:15:41 +00:00
|
|
|
|
|
|
|
class Instance;
|
2017-06-26 17:38:16 +00:00
|
|
|
class AuthKey;
|
|
|
|
using AuthKeyPtr = std::shared_ptr<AuthKey>;
|
2017-02-24 17:15:41 +00:00
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class Dcenter : public QObject {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
Dcenter(not_null<Instance*> instance, DcId dcId, AuthKeyPtr &&key);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QReadWriteLock *keyMutex() const;
|
2016-03-24 12:57:10 +00:00
|
|
|
const AuthKeyPtr &getKey() const;
|
2017-02-24 17:15:41 +00:00
|
|
|
void setKey(AuthKeyPtr &&key);
|
2014-05-30 08:53:19 +00:00
|
|
|
void destroyKey();
|
|
|
|
|
|
|
|
bool connectionInited() const {
|
|
|
|
QMutexLocker lock(&initLock);
|
2018-05-17 19:58:00 +00:00
|
|
|
return _connectionInited;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
void setConnectionInited(bool connectionInited = true) {
|
|
|
|
QMutexLocker lock(&initLock);
|
|
|
|
_connectionInited = connectionInited;
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void authKeyCreated();
|
2018-05-17 19:58:00 +00:00
|
|
|
void connectionWasInited();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void authKeyWrite();
|
|
|
|
|
|
|
|
private:
|
|
|
|
mutable QReadWriteLock keyLock;
|
|
|
|
mutable QMutex initLock;
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<Instance*> _instance;
|
2017-02-24 17:15:41 +00:00
|
|
|
DcId _id = 0;
|
2016-03-24 12:57:10 +00:00
|
|
|
AuthKeyPtr _key;
|
2017-02-24 17:15:41 +00:00
|
|
|
bool _connectionInited = false;
|
2016-10-05 16:56:27 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2016-03-24 12:57:10 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace MTP
|