2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00: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 13:16:42 +00: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 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
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);
|
|
|
|
bool res = _connectionInited;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
void setConnectionInited(bool connectionInited = true) {
|
|
|
|
QMutexLocker lock(&initLock);
|
|
|
|
_connectionInited = connectionInited;
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void authKeyCreated();
|
2014-11-14 23:23:35 +00:00
|
|
|
void layerWasInited(bool was);
|
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
|