2014-05-30 12:53:19 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 13:47:38 +03:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 16:16:42 +03:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 22:31:31 +04:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-03-24 15:57:10 +03:00
|
|
|
namespace MTP {
|
2017-02-24 20:15:41 +03:00
|
|
|
|
|
|
|
class Instance;
|
2017-06-26 20:38:16 +03:00
|
|
|
class AuthKey;
|
|
|
|
using AuthKeyPtr = std::shared_ptr<AuthKey>;
|
2017-02-24 20:15:41 +03:00
|
|
|
|
2016-03-24 15:57:10 +03:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class Dcenter : public QObject {
|
2014-05-30 12:53:19 +04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-08-17 11:31:24 +03:00
|
|
|
Dcenter(not_null<Instance*> instance, DcId dcId, AuthKeyPtr &&key);
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
QReadWriteLock *keyMutex() const;
|
2016-03-24 15:57:10 +03:00
|
|
|
const AuthKeyPtr &getKey() const;
|
2017-02-24 20:15:41 +03:00
|
|
|
void setKey(AuthKeyPtr &&key);
|
2014-05-30 12:53:19 +04:00
|
|
|
void destroyKey();
|
|
|
|
|
|
|
|
bool connectionInited() const {
|
|
|
|
QMutexLocker lock(&initLock);
|
|
|
|
bool res = _connectionInited;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
void setConnectionInited(bool connectionInited = true) {
|
|
|
|
QMutexLocker lock(&initLock);
|
|
|
|
_connectionInited = connectionInited;
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void authKeyCreated();
|
2014-11-15 02:23:35 +03:00
|
|
|
void layerWasInited(bool was);
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void authKeyWrite();
|
|
|
|
|
|
|
|
private:
|
|
|
|
mutable QReadWriteLock keyLock;
|
|
|
|
mutable QMutex initLock;
|
2017-08-17 11:31:24 +03:00
|
|
|
not_null<Instance*> _instance;
|
2017-02-24 20:15:41 +03:00
|
|
|
DcId _id = 0;
|
2016-03-24 15:57:10 +03:00
|
|
|
AuthKeyPtr _key;
|
2017-02-24 20:15:41 +03:00
|
|
|
bool _connectionInited = false;
|
2016-10-05 19:56:27 +03:00
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
};
|
|
|
|
|
2016-03-24 15:57:10 +03:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace MTP
|