2017-02-23 10:59: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.
|
2017-02-23 10:59: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
|
2017-02-23 10:59:19 +00:00
|
|
|
*/
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_photo.h"
|
|
|
|
#include "data/data_document.h"
|
2018-01-17 16:21:01 +00:00
|
|
|
#include "data/data_session.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_user.h"
|
2017-04-29 20:06:32 +00:00
|
|
|
#include "base/timer.h"
|
2018-04-18 15:42:02 +00:00
|
|
|
#include "core/update_checker.h"
|
2018-11-16 12:15:14 +00:00
|
|
|
#include "core/shortcuts.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/sandbox.h"
|
2018-11-26 11:55:02 +00:00
|
|
|
#include "core/local_url_handlers.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/launcher.h"
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/localstorage.h"
|
|
|
|
#include "platform/platform_specific.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "mainwindow.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
|
|
|
#include "history/history.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "auth_session.h"
|
2017-04-29 20:06:32 +00:00
|
|
|
#include "apiwrap.h"
|
|
|
|
#include "calls/calls_instance.h"
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_file_parser.h"
|
2017-04-13 08:45:58 +00:00
|
|
|
#include "lang/lang_translator.h"
|
2017-04-18 15:21:03 +00:00
|
|
|
#include "lang/lang_cloud_manager.h"
|
2018-05-24 13:40:19 +00:00
|
|
|
#include "lang/lang_hardcoded.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "observer_peer.h"
|
2018-08-29 13:23:16 +00:00
|
|
|
#include "storage/storage_databases.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "mainwidget.h"
|
2017-08-08 09:31:48 +00:00
|
|
|
#include "mediaview.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "mtproto/dc_options.h"
|
2017-02-24 17:15:41 +00:00
|
|
|
#include "mtproto/mtp_instance.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "media/player/media_player_instance.h"
|
2018-06-04 18:18:52 +00:00
|
|
|
#include "media/media_audio.h"
|
2017-05-03 11:36:39 +00:00
|
|
|
#include "media/media_audio_track.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "window/notifications_manager.h"
|
|
|
|
#include "window/themes/window_theme.h"
|
2018-06-03 13:30:40 +00:00
|
|
|
#include "window/window_lock_widgets.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "history/history_location_manager.h"
|
|
|
|
#include "ui/widgets/tooltip.h"
|
2018-10-23 09:44:42 +00:00
|
|
|
#include "ui/image/image.h"
|
2017-12-28 13:06:06 +00:00
|
|
|
#include "ui/text_options.h"
|
2018-10-13 17:35:30 +00:00
|
|
|
#include "ui/emoji_config.h"
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/serialize_common.h"
|
2017-04-09 18:06:06 +00:00
|
|
|
#include "window/window_controller.h"
|
2017-06-27 20:11:38 +00:00
|
|
|
#include "base/qthelp_regex.h"
|
|
|
|
#include "base/qthelp_url.h"
|
|
|
|
#include "boxes/connection_box.h"
|
|
|
|
#include "boxes/confirm_phone_box.h"
|
2018-05-24 13:40:19 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
2017-06-27 20:11:38 +00:00
|
|
|
#include "boxes/share_box.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
namespace Core {
|
2017-02-23 10:59:19 +00:00
|
|
|
namespace {
|
|
|
|
|
2017-04-29 20:06:32 +00:00
|
|
|
constexpr auto kQuitPreventTimeoutMs = 1500;
|
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
} // namespace
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
struct Application::Private {
|
2017-04-06 19:02:40 +00:00
|
|
|
UserId authSessionUserId = 0;
|
2018-09-11 12:50:40 +00:00
|
|
|
QByteArray authSessionUserSerialized;
|
2018-09-11 14:36:09 +00:00
|
|
|
int32 authSessionUserStreamVersion = 0;
|
2018-01-04 10:22:53 +00:00
|
|
|
std::unique_ptr<AuthSessionSettings> storedAuthSession;
|
2017-02-24 17:15:41 +00:00
|
|
|
MTP::Instance::Config mtpConfig;
|
2017-02-25 16:44:02 +00:00
|
|
|
MTP::AuthKeysList mtpKeysToDestroy;
|
2017-04-29 20:06:32 +00:00
|
|
|
base::Timer quitTimer;
|
2017-02-24 17:15:41 +00:00
|
|
|
};
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
Application::Application(not_null<Launcher*> launcher)
|
2017-12-11 14:45:29 +00:00
|
|
|
: QObject()
|
|
|
|
, _launcher(launcher)
|
2017-05-03 11:36:39 +00:00
|
|
|
, _private(std::make_unique<Private>())
|
2018-08-29 13:23:16 +00:00
|
|
|
, _databases(std::make_unique<Storage::Databases>())
|
2017-04-13 17:59:05 +00:00
|
|
|
, _langpack(std::make_unique<Lang::Instance>())
|
2017-05-12 15:27:19 +00:00
|
|
|
, _audio(std::make_unique<Media::Audio::Instance>())
|
|
|
|
, _logo(Window::LoadLogo())
|
|
|
|
, _logoNoMargin(Window::LoadLogoNoMargin()) {
|
|
|
|
Expects(!_logo.isNull());
|
|
|
|
Expects(!_logoNoMargin.isNull());
|
2019-01-21 13:42:21 +00:00
|
|
|
}
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::run() {
|
2017-04-30 16:03:12 +00:00
|
|
|
Fonts::Start();
|
2017-02-23 10:59:19 +00:00
|
|
|
|
|
|
|
ThirdParty::start();
|
|
|
|
Global::start();
|
2019-01-21 13:42:21 +00:00
|
|
|
refreshGlobalProxy(); // Depends on Global::started().
|
2017-02-23 10:59:19 +00:00
|
|
|
|
|
|
|
startLocalStorage();
|
|
|
|
|
|
|
|
if (Local::oldSettingsVersion() < AppVersion) {
|
|
|
|
psNewVersion();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cLaunchMode() == LaunchModeAutoStart && !cAutoStart()) {
|
|
|
|
psAutoStart(false, true);
|
|
|
|
App::quit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-13 17:59:05 +00:00
|
|
|
_translator = std::make_unique<Lang::Translator>();
|
2019-01-21 13:42:21 +00:00
|
|
|
QCoreApplication::instance()->installTranslator(_translator.get());
|
2017-04-13 17:59:05 +00:00
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
style::startManager();
|
|
|
|
anim::startManager();
|
2017-12-28 13:06:06 +00:00
|
|
|
Ui::InitTextOptions();
|
2018-10-13 17:35:30 +00:00
|
|
|
Ui::Emoji::Init();
|
2019-02-01 07:09:55 +00:00
|
|
|
Media::Player::start(_audio.get());
|
2017-02-23 10:59:19 +00:00
|
|
|
|
|
|
|
DEBUG_LOG(("Application Info: inited..."));
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QCoreApplication::instance()->installNativeEventFilter(
|
|
|
|
psNativeEventFilter());
|
2017-02-23 10:59:19 +00:00
|
|
|
|
|
|
|
cChangeTimeFormat(QLocale::system().timeFormat(QLocale::ShortFormat));
|
|
|
|
|
|
|
|
DEBUG_LOG(("Application Info: starting app..."));
|
|
|
|
|
|
|
|
// Create mime database, so it won't be slow later.
|
|
|
|
QMimeDatabase().mimeTypeForName(qsl("text/plain"));
|
|
|
|
|
|
|
|
_window = std::make_unique<MainWindow>();
|
|
|
|
_window->init();
|
|
|
|
|
2017-09-03 19:10:50 +00:00
|
|
|
auto currentGeometry = _window->geometry();
|
2017-08-08 09:31:48 +00:00
|
|
|
_mediaView = std::make_unique<MediaView>();
|
2017-09-03 19:10:50 +00:00
|
|
|
_window->setGeometry(currentGeometry);
|
2017-08-08 09:31:48 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QCoreApplication::instance()->installEventFilter(this);
|
2019-01-18 11:26:43 +00:00
|
|
|
connect(
|
2019-01-21 13:42:21 +00:00
|
|
|
static_cast<QGuiApplication*>(QCoreApplication::instance()),
|
|
|
|
&QGuiApplication::applicationStateChanged,
|
2019-01-18 11:26:43 +00:00
|
|
|
this,
|
2019-01-21 13:42:21 +00:00
|
|
|
&Application::stateChanged);
|
2017-02-23 10:59:19 +00:00
|
|
|
|
|
|
|
DEBUG_LOG(("Application Info: window created..."));
|
|
|
|
|
2018-11-16 12:15:14 +00:00
|
|
|
startShortcuts();
|
2017-02-23 10:59:19 +00:00
|
|
|
App::initMedia();
|
|
|
|
|
|
|
|
Local::ReadMapState state = Local::readMap(QByteArray());
|
|
|
|
if (state == Local::ReadMapPassNeeded) {
|
|
|
|
Global::SetLocalPasscode(true);
|
|
|
|
Global::RefLocalPasscodeChanged().notify();
|
2018-06-07 07:44:38 +00:00
|
|
|
lockByPasscode();
|
2017-02-23 10:59:19 +00:00
|
|
|
DEBUG_LOG(("Application Info: passcode needed..."));
|
|
|
|
} else {
|
|
|
|
DEBUG_LOG(("Application Info: local map read..."));
|
2017-02-24 17:15:41 +00:00
|
|
|
startMtp();
|
2018-06-07 07:44:38 +00:00
|
|
|
DEBUG_LOG(("Application Info: MTP started..."));
|
2017-03-04 19:36:59 +00:00
|
|
|
if (AuthSession::Exists()) {
|
2017-02-23 10:59:19 +00:00
|
|
|
_window->setupMain();
|
|
|
|
} else {
|
|
|
|
_window->setupIntro();
|
|
|
|
}
|
|
|
|
}
|
2018-06-07 07:44:38 +00:00
|
|
|
DEBUG_LOG(("Application Info: showing."));
|
2017-02-23 10:59:19 +00:00
|
|
|
_window->firstShow();
|
|
|
|
|
|
|
|
if (cStartToSettings()) {
|
|
|
|
_window->showSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
_window->updateIsActive(Global::OnlineFocusTimeout());
|
|
|
|
|
2018-11-16 12:15:14 +00:00
|
|
|
for (const auto &error : Shortcuts::Errors()) {
|
|
|
|
LOG(("Shortcuts Error: %1").arg(error));
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::hideMediaView() {
|
2017-08-08 09:31:48 +00:00
|
|
|
if (_mediaView && !_mediaView->isHidden()) {
|
|
|
|
_mediaView->hide();
|
2017-08-08 09:56:10 +00:00
|
|
|
if (auto activeWindow = getActiveWindow()) {
|
|
|
|
activeWindow->reActivateWindow();
|
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::showPhoto(not_null<const PhotoOpenClickHandler*> link) {
|
2017-12-15 16:25:47 +00:00
|
|
|
const auto item = App::histItemById(link->context());
|
|
|
|
const auto peer = link->peer();
|
|
|
|
return (!item && peer)
|
|
|
|
? showPhoto(link->photo(), peer)
|
2017-08-08 09:31:48 +00:00
|
|
|
: showPhoto(link->photo(), item);
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::showPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
2017-08-08 09:31:48 +00:00
|
|
|
_mediaView->showPhoto(photo, item);
|
|
|
|
_mediaView->activateWindow();
|
|
|
|
_mediaView->setFocus();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::showPhoto(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
not_null<PeerData*> peer) {
|
2017-08-08 09:31:48 +00:00
|
|
|
_mediaView->showPhoto(photo, peer);
|
|
|
|
_mediaView->activateWindow();
|
|
|
|
_mediaView->setFocus();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::showDocument(not_null<DocumentData*> document, HistoryItem *item) {
|
2017-12-10 10:26:58 +00:00
|
|
|
if (cUseExternalVideoPlayer() && document->isVideoFile()) {
|
2017-08-08 09:31:48 +00:00
|
|
|
QDesktopServices::openUrl(QUrl("file:///" + document->location(false).fname));
|
|
|
|
} else {
|
|
|
|
_mediaView->showDocument(document, item);
|
|
|
|
_mediaView->activateWindow();
|
|
|
|
_mediaView->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
PeerData *Application::ui_getPeerForMouseAction() {
|
2017-08-08 09:31:48 +00:00
|
|
|
if (_mediaView && !_mediaView->isHidden()) {
|
|
|
|
return _mediaView->ui_getPeerForMouseAction();
|
|
|
|
} else if (auto main = App::main()) {
|
|
|
|
return main->ui_getPeerForMouseAction();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::eventFilter(QObject *object, QEvent *e) {
|
2017-08-08 09:31:48 +00:00
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
case QEvent::TouchBegin:
|
|
|
|
case QEvent::Wheel: {
|
|
|
|
psUserActionDone();
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case QEvent::ShortcutOverride: {
|
|
|
|
// handle shortcuts ourselves
|
|
|
|
return true;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case QEvent::Shortcut: {
|
2018-11-16 12:15:14 +00:00
|
|
|
const auto event = static_cast<QShortcutEvent*>(e);
|
|
|
|
DEBUG_LOG(("Shortcut event caught: %1"
|
|
|
|
).arg(event->key().toString()));
|
|
|
|
if (Shortcuts::HandleEvent(event)) {
|
2017-08-08 09:31:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case QEvent::ApplicationActivate: {
|
2019-01-21 13:42:21 +00:00
|
|
|
if (object == QCoreApplication::instance()) {
|
2017-08-08 09:31:48 +00:00
|
|
|
psUserActionDone();
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case QEvent::FileOpen: {
|
2019-01-21 13:42:21 +00:00
|
|
|
if (object == QCoreApplication::instance()) {
|
|
|
|
const auto event = static_cast<QFileOpenEvent*>(e);
|
|
|
|
const auto url = QString::fromUtf8(
|
|
|
|
event->url().toEncoded().trimmed());
|
2017-08-08 09:31:48 +00:00
|
|
|
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
|
|
|
cSetStartUrl(url.mid(0, 8192));
|
|
|
|
checkStartUrl();
|
|
|
|
}
|
2018-04-13 05:11:53 +00:00
|
|
|
if (StartUrlRequiresActivate(url)) {
|
|
|
|
_window->activate();
|
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QObject::eventFilter(object, e);
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setCurrentProxy(
|
2018-05-18 12:20:28 +00:00
|
|
|
const ProxyData &proxy,
|
2018-11-05 13:58:24 +00:00
|
|
|
ProxyData::Settings settings) {
|
2018-05-18 12:20:28 +00:00
|
|
|
const auto key = [&](const ProxyData &proxy) {
|
|
|
|
if (proxy.type == ProxyData::Type::Mtproto) {
|
|
|
|
return std::make_pair(proxy.host, proxy.port);
|
|
|
|
}
|
|
|
|
return std::make_pair(QString(), uint32(0));
|
|
|
|
};
|
2018-11-05 13:58:24 +00:00
|
|
|
const auto previousKey = key(
|
|
|
|
(Global::ProxySettings() == ProxyData::Settings::Enabled
|
|
|
|
? Global::SelectedProxy()
|
|
|
|
: ProxyData()));
|
2018-05-18 12:20:28 +00:00
|
|
|
Global::SetSelectedProxy(proxy);
|
2018-11-05 13:58:24 +00:00
|
|
|
Global::SetProxySettings(settings);
|
2019-01-21 13:42:21 +00:00
|
|
|
refreshGlobalProxy();
|
2018-05-18 12:20:28 +00:00
|
|
|
if (_mtproto) {
|
|
|
|
_mtproto->restart();
|
|
|
|
if (previousKey != key(proxy)) {
|
|
|
|
_mtproto->reInitConnection(_mtproto->mainDcId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_mtprotoForKeysDestroy) {
|
|
|
|
_mtprotoForKeysDestroy->restart();
|
|
|
|
}
|
|
|
|
Global::RefConnectionTypeChanged().notify();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::badMtprotoConfigurationError() {
|
2018-11-05 13:58:24 +00:00
|
|
|
if (Global::ProxySettings() == ProxyData::Settings::Enabled
|
|
|
|
&& !_badProxyDisableBox) {
|
|
|
|
const auto disableCallback = [=] {
|
|
|
|
setCurrentProxy(
|
|
|
|
Global::SelectedProxy(),
|
|
|
|
ProxyData::Settings::System);
|
|
|
|
};
|
2018-05-24 13:40:19 +00:00
|
|
|
_badProxyDisableBox = Ui::show(Box<InformBox>(
|
|
|
|
Lang::Hard::ProxyConfigError(),
|
2018-11-05 13:58:24 +00:00
|
|
|
disableCallback));
|
2018-05-24 13:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setMtpMainDcId(MTP::DcId mainDcId) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!_mtproto);
|
2018-05-18 12:20:28 +00:00
|
|
|
|
2017-02-24 17:15:41 +00:00
|
|
|
_private->mtpConfig.mainDcId = mainDcId;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!_mtproto);
|
2018-05-18 12:20:28 +00:00
|
|
|
|
2017-02-25 16:44:02 +00:00
|
|
|
_private->mtpConfig.keys.push_back(std::make_shared<MTP::AuthKey>(MTP::AuthKey::Type::ReadFromFile, dcId, keyData));
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QByteArray Application::serializeMtpAuthorization() const {
|
2017-02-25 16:44:02 +00:00
|
|
|
auto serialize = [this](auto mainDcId, auto &keys, auto &keysToDestroy) {
|
|
|
|
auto keysSize = [](auto &list) {
|
|
|
|
return sizeof(qint32) + list.size() * (sizeof(qint32) + MTP::AuthKey::Data().size());
|
|
|
|
};
|
|
|
|
auto writeKeys = [](QDataStream &stream, auto &keys) {
|
|
|
|
stream << qint32(keys.size());
|
|
|
|
for (auto &key : keys) {
|
|
|
|
stream << qint32(key->dcId());
|
|
|
|
key->write(stream);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-24 17:15:41 +00:00
|
|
|
auto result = QByteArray();
|
2017-02-25 16:44:02 +00:00
|
|
|
auto size = sizeof(qint32) + sizeof(qint32); // userId + mainDcId
|
|
|
|
size += keysSize(keys) + keysSize(keysToDestroy);
|
2017-02-24 17:15:41 +00:00
|
|
|
result.reserve(size);
|
|
|
|
{
|
2017-04-13 17:59:05 +00:00
|
|
|
QDataStream stream(&result, QIODevice::WriteOnly);
|
2017-02-24 17:15:41 +00:00
|
|
|
stream.setVersion(QDataStream::Qt_5_1);
|
|
|
|
|
2017-08-04 14:54:32 +00:00
|
|
|
auto currentUserId = _authSession ? _authSession->userId() : 0;
|
2017-04-03 18:59:13 +00:00
|
|
|
stream << qint32(currentUserId) << qint32(mainDcId);
|
2017-02-25 16:44:02 +00:00
|
|
|
writeKeys(stream, keys);
|
|
|
|
writeKeys(stream, keysToDestroy);
|
2017-04-03 18:59:13 +00:00
|
|
|
|
|
|
|
DEBUG_LOG(("MTP Info: Keys written, userId: %1, dcId: %2").arg(currentUserId).arg(mainDcId));
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
if (_mtproto) {
|
|
|
|
auto keys = _mtproto->getKeysForWrite();
|
2017-02-25 16:44:02 +00:00
|
|
|
auto keysToDestroy = _mtprotoForKeysDestroy ? _mtprotoForKeysDestroy->getKeysForWrite() : MTP::AuthKeysList();
|
|
|
|
return serialize(_mtproto->mainDcId(), keys, keysToDestroy);
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
auto &keys = _private->mtpConfig.keys;
|
2017-02-25 16:44:02 +00:00
|
|
|
auto &keysToDestroy = _private->mtpKeysToDestroy;
|
|
|
|
return serialize(_private->mtpConfig.mainDcId, keys, keysToDestroy);
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setAuthSessionUserId(UserId userId) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!authSession());
|
2018-09-11 14:36:09 +00:00
|
|
|
|
2017-04-06 19:02:40 +00:00
|
|
|
_private->authSessionUserId = userId;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setAuthSessionFromStorage(
|
2018-09-11 14:36:09 +00:00
|
|
|
std::unique_ptr<AuthSessionSettings> data,
|
|
|
|
QByteArray &&selfSerialized,
|
|
|
|
int32 selfStreamVersion) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!authSession());
|
2018-09-11 14:36:09 +00:00
|
|
|
|
2018-11-13 16:03:58 +00:00
|
|
|
DEBUG_LOG(("authSessionUserSerialized set: %1"
|
|
|
|
).arg(selfSerialized.size()));
|
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
_private->storedAuthSession = std::move(data);
|
2018-09-11 14:36:09 +00:00
|
|
|
_private->authSessionUserSerialized = std::move(selfSerialized);
|
|
|
|
_private->authSessionUserStreamVersion = selfStreamVersion;
|
2017-04-06 19:02:40 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
AuthSessionSettings *Application::getAuthSessionSettings() {
|
2017-04-06 19:02:40 +00:00
|
|
|
if (_private->authSessionUserId) {
|
2018-01-04 10:22:53 +00:00
|
|
|
return _private->storedAuthSession
|
|
|
|
? _private->storedAuthSession.get()
|
|
|
|
: nullptr;
|
2017-08-04 14:54:32 +00:00
|
|
|
} else if (_authSession) {
|
2018-01-04 10:22:53 +00:00
|
|
|
return &_authSession->settings();
|
2017-04-06 19:02:40 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setMtpAuthorization(const QByteArray &serialized) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!_mtproto);
|
2017-02-24 17:15:41 +00:00
|
|
|
|
2017-04-13 17:59:05 +00:00
|
|
|
QDataStream stream(serialized);
|
2017-02-24 17:15:41 +00:00
|
|
|
stream.setVersion(QDataStream::Qt_5_1);
|
|
|
|
|
2017-02-25 16:44:02 +00:00
|
|
|
auto userId = Serialize::read<qint32>(stream);
|
|
|
|
auto mainDcId = Serialize::read<qint32>(stream);
|
2017-02-24 17:15:41 +00:00
|
|
|
if (stream.status() != QDataStream::Ok) {
|
|
|
|
LOG(("MTP Error: could not read main fields from serialized mtp authorization."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-06 19:02:40 +00:00
|
|
|
setAuthSessionUserId(userId);
|
2017-02-24 17:15:41 +00:00
|
|
|
_private->mtpConfig.mainDcId = mainDcId;
|
2017-02-25 16:44:02 +00:00
|
|
|
|
|
|
|
auto readKeys = [&stream](auto &keys) {
|
|
|
|
auto count = Serialize::read<qint32>(stream);
|
2017-02-24 17:15:41 +00:00
|
|
|
if (stream.status() != QDataStream::Ok) {
|
2017-02-25 16:44:02 +00:00
|
|
|
LOG(("MTP Error: could not read keys count from serialized mtp authorization."));
|
2017-02-24 17:15:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-25 16:44:02 +00:00
|
|
|
keys.reserve(count);
|
|
|
|
for (auto i = 0; i != count; ++i) {
|
|
|
|
auto dcId = Serialize::read<qint32>(stream);
|
|
|
|
auto keyData = Serialize::read<MTP::AuthKey::Data>(stream);
|
|
|
|
if (stream.status() != QDataStream::Ok) {
|
|
|
|
LOG(("MTP Error: could not read key from serialized mtp authorization."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
keys.push_back(std::make_shared<MTP::AuthKey>(MTP::AuthKey::Type::ReadFromFile, dcId, keyData));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
readKeys(_private->mtpConfig.keys);
|
|
|
|
readKeys(_private->mtpKeysToDestroy);
|
|
|
|
LOG(("MTP Info: read keys, current: %1, to destroy: %2").arg(_private->mtpConfig.keys.size()).arg(_private->mtpKeysToDestroy.size()));
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::startMtp() {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(!_mtproto);
|
2018-04-23 10:24:03 +00:00
|
|
|
|
2019-02-01 07:48:31 +00:00
|
|
|
auto config = base::take(_private->mtpConfig);
|
|
|
|
config.deviceModel = _launcher->deviceModel();
|
|
|
|
config.systemVersion = _launcher->systemVersion();
|
2018-05-02 19:27:03 +00:00
|
|
|
_mtproto = std::make_unique<MTP::Instance>(
|
|
|
|
_dcOptions.get(),
|
|
|
|
MTP::Instance::Mode::Normal,
|
2019-02-01 07:48:31 +00:00
|
|
|
std::move(config));
|
2018-05-02 19:27:03 +00:00
|
|
|
_mtproto->setUserPhone(cLoggedPhoneNumber());
|
2017-02-25 16:44:02 +00:00
|
|
|
_private->mtpConfig.mainDcId = _mtproto->mainDcId();
|
2017-02-24 17:15:41 +00:00
|
|
|
|
2018-05-07 17:44:33 +00:00
|
|
|
_mtproto->setStateChangedHandler([](MTP::ShiftedDcId dc, int32 state) {
|
|
|
|
if (dc == MTP::maindc()) {
|
|
|
|
Global::RefConnectionTypeChanged().notify();
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
_mtproto->setSessionResetHandler([](MTP::ShiftedDcId shiftedDcId) {
|
|
|
|
if (App::main() && shiftedDcId == MTP::maindc()) {
|
|
|
|
App::main()->getDifference();
|
|
|
|
}
|
|
|
|
});
|
2017-02-25 16:44:02 +00:00
|
|
|
|
|
|
|
if (!_private->mtpKeysToDestroy.empty()) {
|
|
|
|
destroyMtpKeys(base::take(_private->mtpKeysToDestroy));
|
|
|
|
}
|
2017-04-06 19:02:40 +00:00
|
|
|
|
|
|
|
if (_private->authSessionUserId) {
|
2018-11-13 16:03:58 +00:00
|
|
|
DEBUG_LOG(("authSessionUserSerialized.size: %1"
|
|
|
|
).arg(_private->authSessionUserSerialized.size()));
|
2018-10-07 09:02:44 +00:00
|
|
|
QDataStream peekStream(_private->authSessionUserSerialized);
|
|
|
|
const auto phone = Serialize::peekUserPhone(
|
|
|
|
_private->authSessionUserStreamVersion,
|
|
|
|
peekStream);
|
|
|
|
const auto flags = MTPDuser::Flag::f_self | (phone.isEmpty()
|
|
|
|
? MTPDuser::Flag()
|
|
|
|
: MTPDuser::Flag::f_phone);
|
2018-09-11 12:50:40 +00:00
|
|
|
authSessionCreate(MTP_user(
|
2018-10-07 09:02:44 +00:00
|
|
|
MTP_flags(flags),
|
2018-09-11 12:50:40 +00:00
|
|
|
MTP_int(base::take(_private->authSessionUserId)),
|
|
|
|
MTPlong(), // access_hash
|
|
|
|
MTPstring(), // first_name
|
|
|
|
MTPstring(), // last_name
|
|
|
|
MTPstring(), // username
|
2018-10-07 09:02:44 +00:00
|
|
|
MTP_string(phone),
|
2018-09-11 12:50:40 +00:00
|
|
|
MTPUserProfilePhoto(),
|
|
|
|
MTPUserStatus(),
|
|
|
|
MTPint(), // bot_info_version
|
|
|
|
MTPstring(), // restriction_reason
|
|
|
|
MTPstring(), // bot_inline_placeholder
|
|
|
|
MTPstring())); // lang_code
|
2018-09-11 14:36:09 +00:00
|
|
|
Local::readSelf(
|
|
|
|
base::take(_private->authSessionUserSerialized),
|
|
|
|
base::take(_private->authSessionUserStreamVersion));
|
2017-04-06 19:02:40 +00:00
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
if (_private->storedAuthSession) {
|
2017-04-06 19:02:40 +00:00
|
|
|
if (_authSession) {
|
2018-11-04 16:51:59 +00:00
|
|
|
_authSession->moveSettingsFrom(
|
2017-11-05 13:57:51 +00:00
|
|
|
std::move(*_private->storedAuthSession));
|
2017-04-06 19:02:40 +00:00
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
_private->storedAuthSession.reset();
|
2017-04-06 19:02:40 +00:00
|
|
|
}
|
2017-04-18 15:21:03 +00:00
|
|
|
|
2018-05-28 05:10:30 +00:00
|
|
|
_langCloudManager = std::make_unique<Lang::CloudManager>(
|
|
|
|
langpack(),
|
|
|
|
mtp());
|
2019-01-21 13:42:21 +00:00
|
|
|
if (!UpdaterDisabled()) {
|
|
|
|
UpdateChecker().setMtproto(mtp());
|
2018-07-11 22:14:44 +00:00
|
|
|
}
|
2018-09-11 14:36:09 +00:00
|
|
|
|
|
|
|
if (_authSession) {
|
|
|
|
// Skip all pending self updates so that we won't Local::writeSelf.
|
|
|
|
Notify::peerUpdatedSendDelayed();
|
2018-11-08 13:06:22 +00:00
|
|
|
|
2018-11-30 14:33:12 +00:00
|
|
|
Media::Player::mixer()->setVoicePlaybackDoubled(
|
|
|
|
Global::VoiceMsgPlaybackDoubled());
|
2018-09-11 14:36:09 +00:00
|
|
|
}
|
2017-02-25 16:44:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::destroyMtpKeys(MTP::AuthKeysList &&keys) {
|
2017-02-25 16:44:02 +00:00
|
|
|
if (keys.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_mtprotoForKeysDestroy) {
|
|
|
|
_mtprotoForKeysDestroy->addKeysForDestroy(std::move(keys));
|
|
|
|
Local::writeMtpData();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto destroyConfig = MTP::Instance::Config();
|
|
|
|
destroyConfig.mainDcId = MTP::Instance::Config::kNoneMainDc;
|
|
|
|
destroyConfig.keys = std::move(keys);
|
2019-02-01 07:48:31 +00:00
|
|
|
destroyConfig.deviceModel = _launcher->deviceModel();
|
|
|
|
destroyConfig.systemVersion = _launcher->systemVersion();
|
|
|
|
_mtprotoForKeysDestroy = std::make_unique<MTP::Instance>(
|
|
|
|
_dcOptions.get(),
|
|
|
|
MTP::Instance::Mode::KeysDestroyer,
|
|
|
|
std::move(destroyConfig));
|
2019-01-18 11:26:43 +00:00
|
|
|
connect(
|
|
|
|
_mtprotoForKeysDestroy.get(),
|
|
|
|
&MTP::Instance::allKeysDestroyed,
|
|
|
|
[=] { allKeysDestroyed(); });
|
2017-02-25 16:44:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::allKeysDestroyed() {
|
2017-02-25 16:44:02 +00:00
|
|
|
LOG(("MTP Info: all keys scheduled for destroy are destroyed."));
|
2019-01-18 11:26:43 +00:00
|
|
|
crl::on_main(this, [=] {
|
|
|
|
_mtprotoForKeysDestroy = nullptr;
|
|
|
|
Local::writeMtpData();
|
|
|
|
});
|
2017-02-25 16:44:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::suggestMainDcId(MTP::DcId mainDcId) {
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(_mtproto != nullptr);
|
2017-02-25 16:44:02 +00:00
|
|
|
|
|
|
|
_mtproto->suggestMainDcId(mainDcId);
|
|
|
|
if (_private->mtpConfig.mainDcId != MTP::Instance::Config::kNotSetMainDc) {
|
|
|
|
_private->mtpConfig.mainDcId = mainDcId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::destroyStaleAuthorizationKeys() {
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(_mtproto != nullptr);
|
2017-02-25 16:44:02 +00:00
|
|
|
|
2018-06-04 18:18:52 +00:00
|
|
|
for (const auto &key : _mtproto->getKeysForWrite()) {
|
2017-02-25 17:15:30 +00:00
|
|
|
// Disable this for now.
|
2017-02-28 16:08:30 +00:00
|
|
|
if (key->type() == MTP::AuthKey::Type::ReadFromFile) {
|
2017-02-25 16:44:02 +00:00
|
|
|
_private->mtpKeysToDestroy = _mtproto->getKeysForWrite();
|
2018-06-04 18:18:52 +00:00
|
|
|
LOG(("MTP Info: destroying stale keys, count: %1"
|
|
|
|
).arg(_private->mtpKeysToDestroy.size()));
|
|
|
|
resetAuthorizationKeys();
|
2017-02-25 16:44:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-02-24 17:15:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::resetAuthorizationKeys() {
|
|
|
|
_mtproto = nullptr;
|
2018-06-04 18:18:52 +00:00
|
|
|
startMtp();
|
|
|
|
Local::writeMtpData();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::startLocalStorage() {
|
2017-02-23 10:59:19 +00:00
|
|
|
_dcOptions = std::make_unique<MTP::DcOptions>();
|
|
|
|
_dcOptions->constructFromBuiltIn();
|
|
|
|
Local::start();
|
2017-02-24 17:15:41 +00:00
|
|
|
subscribe(_dcOptions->changed(), [this](const MTP::DcOptions::Ids &ids) {
|
2017-02-23 10:59:19 +00:00
|
|
|
Local::writeSettings();
|
2017-02-24 17:15:41 +00:00
|
|
|
if (auto instance = mtp()) {
|
|
|
|
for (auto id : ids) {
|
|
|
|
instance->restart(id);
|
|
|
|
}
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
});
|
2018-10-07 11:45:46 +00:00
|
|
|
subscribe(authSessionChanged(), [=] {
|
|
|
|
InvokeQueued(this, [=] {
|
2018-09-11 12:50:40 +00:00
|
|
|
const auto phone = AuthSession::Exists()
|
|
|
|
? Auth().user()->phone()
|
2018-05-02 19:27:03 +00:00
|
|
|
: QString();
|
|
|
|
if (cLoggedPhoneNumber() != phone) {
|
|
|
|
cSetLoggedPhoneNumber(phone);
|
|
|
|
if (_mtproto) {
|
|
|
|
_mtproto->setUserPhone(phone);
|
|
|
|
}
|
|
|
|
Local::writeSettings();
|
|
|
|
}
|
2018-09-11 12:50:40 +00:00
|
|
|
if (_mtproto) {
|
|
|
|
_mtproto->requestConfig();
|
|
|
|
}
|
2018-10-24 08:28:11 +00:00
|
|
|
Platform::SetApplicationIcon(Window::CreateIcon());
|
2018-12-13 08:48:31 +00:00
|
|
|
Shortcuts::ToggleSupportShortcuts(
|
|
|
|
_authSession && _authSession->supportMode());
|
2018-05-02 19:27:03 +00:00
|
|
|
});
|
|
|
|
});
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::forceLogOut(const TextWithEntities &explanation) {
|
2018-06-04 18:18:52 +00:00
|
|
|
const auto box = Ui::show(Box<InformBox>(
|
|
|
|
explanation,
|
|
|
|
lang(lng_passcode_logout)));
|
2018-06-06 11:51:27 +00:00
|
|
|
box->setCloseByEscape(false);
|
|
|
|
box->setCloseByOutsideClick(false);
|
2018-06-04 18:18:52 +00:00
|
|
|
connect(box, &QObject::destroyed, [=] {
|
2018-06-06 11:51:27 +00:00
|
|
|
crl::on_main(this, [=] {
|
|
|
|
if (AuthSession::Exists()) {
|
|
|
|
resetAuthorizationKeys();
|
|
|
|
loggedOut();
|
|
|
|
}
|
2018-06-04 18:18:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::checkLocalTime() {
|
2018-08-08 20:11:28 +00:00
|
|
|
const auto updated = checkms();
|
|
|
|
if (App::main()) App::main()->checkLastUpdate(updated);
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::stateChanged(Qt::ApplicationState state) {
|
2017-02-23 10:59:19 +00:00
|
|
|
if (state == Qt::ApplicationActive) {
|
|
|
|
handleAppActivated();
|
|
|
|
} else {
|
|
|
|
handleAppDeactivated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::handleAppActivated() {
|
2017-02-23 10:59:19 +00:00
|
|
|
checkLocalTime();
|
|
|
|
if (_window) {
|
|
|
|
_window->updateIsActive(Global::OnlineFocusTimeout());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::handleAppDeactivated() {
|
2017-02-23 10:59:19 +00:00
|
|
|
if (_window) {
|
|
|
|
_window->updateIsActive(Global::OfflineBlurTimeout());
|
|
|
|
}
|
|
|
|
Ui::Tooltip::Hide();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::call_handleUnreadCounterUpdate() {
|
2017-02-23 10:59:19 +00:00
|
|
|
Global::RefUnreadCounterUpdate().notify(true);
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::call_handleDelayedPeerUpdates() {
|
2017-02-23 10:59:19 +00:00
|
|
|
Notify::peerUpdatedSendDelayed();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::call_handleObservables() {
|
2017-02-23 10:59:19 +00:00
|
|
|
base::HandleObservables();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::switchDebugMode() {
|
2018-06-05 13:32:26 +00:00
|
|
|
if (Logs::DebugEnabled()) {
|
|
|
|
Logs::SetDebugEnabled(false);
|
2019-01-21 13:42:21 +00:00
|
|
|
_launcher->writeDebugModeSetting();
|
2017-02-23 10:59:19 +00:00
|
|
|
App::restart();
|
|
|
|
} else {
|
2018-06-05 13:32:26 +00:00
|
|
|
Logs::SetDebugEnabled(true);
|
2019-01-21 13:42:21 +00:00
|
|
|
_launcher->writeDebugModeSetting();
|
2017-02-23 10:59:19 +00:00
|
|
|
DEBUG_LOG(("Debug logs started."));
|
|
|
|
Ui::hideLayer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::switchWorkMode() {
|
2017-02-23 10:59:19 +00:00
|
|
|
Global::SetDialogsModeEnabled(!Global::DialogsModeEnabled());
|
|
|
|
Global::SetDialogsMode(Dialogs::Mode::All);
|
|
|
|
Local::writeUserSettings();
|
|
|
|
App::restart();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::switchTestMode() {
|
2017-02-23 10:59:19 +00:00
|
|
|
if (cTestMode()) {
|
|
|
|
QFile(cWorkingDir() + qsl("tdata/withtestmode")).remove();
|
|
|
|
cSetTestMode(false);
|
|
|
|
} else {
|
|
|
|
QFile f(cWorkingDir() + qsl("tdata/withtestmode"));
|
|
|
|
if (f.open(QIODevice::WriteOnly)) {
|
|
|
|
f.write("1");
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
cSetTestMode(true);
|
|
|
|
}
|
|
|
|
App::restart();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::writeInstallBetaVersionsSetting() {
|
|
|
|
_launcher->writeInstallBetaVersionsSetting();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::authSessionCreate(const MTPUser &user) {
|
2017-04-06 19:02:40 +00:00
|
|
|
Expects(_mtproto != nullptr);
|
2018-06-03 13:30:40 +00:00
|
|
|
|
2018-09-11 12:50:40 +00:00
|
|
|
_authSession = std::make_unique<AuthSession>(user);
|
2019-01-21 13:42:21 +00:00
|
|
|
_mtproto->setUpdatesHandler(::rpcDone([](
|
|
|
|
const mtpPrime *from,
|
|
|
|
const mtpPrime *end) {
|
|
|
|
if (const auto main = App::main()) {
|
|
|
|
main->updateReceived(from, end);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
_mtproto->setGlobalFailHandler(::rpcFail([=](const RPCError &error) {
|
|
|
|
crl::on_main(_authSession.get(), [=] { logOut(); });
|
|
|
|
return true;
|
|
|
|
}));
|
2017-04-09 18:06:06 +00:00
|
|
|
authSessionChanged().notify(true);
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::authSessionDestroy() {
|
2017-04-09 18:06:06 +00:00
|
|
|
_private->storedAuthSession.reset();
|
2017-04-06 19:02:40 +00:00
|
|
|
_private->authSessionUserId = 0;
|
2018-09-11 12:50:40 +00:00
|
|
|
_private->authSessionUserSerialized = {};
|
2019-01-21 13:42:21 +00:00
|
|
|
if (_authSession) {
|
|
|
|
unlockTerms();
|
|
|
|
_mtproto->clearGlobalHandlers();
|
|
|
|
_authSession = nullptr;
|
|
|
|
authSessionChanged().notify(true);
|
|
|
|
Notify::unreadCounterUpdated();
|
|
|
|
}
|
2017-02-23 10:59:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
int Application::unreadBadge() const {
|
2019-01-03 12:36:01 +00:00
|
|
|
return _authSession ? _authSession->data().unreadBadge() : 0;
|
2018-12-04 10:32:06 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::unreadBadgeMuted() const {
|
2019-01-03 12:36:01 +00:00
|
|
|
return _authSession ? _authSession->data().unreadBadgeMuted() : false;
|
2018-12-04 10:32:06 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::setInternalLinkDomain(const QString &domain) const {
|
2018-12-04 10:32:06 +00:00
|
|
|
// This domain should start with 'http[s]://' and end with '/'.
|
|
|
|
// Like 'https://telegram.me/' or 'https://t.me/'.
|
|
|
|
auto validate = [](const auto &domain) {
|
|
|
|
const auto prefixes = {
|
2017-03-10 17:25:43 +00:00
|
|
|
qstr("https://"),
|
|
|
|
qstr("http://"),
|
|
|
|
};
|
2018-12-04 10:32:06 +00:00
|
|
|
for (const auto &prefix : prefixes) {
|
2017-03-10 17:25:43 +00:00
|
|
|
if (domain.startsWith(prefix, Qt::CaseInsensitive)) {
|
|
|
|
return domain.endsWith('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
if (validate(domain) && domain != Global::InternalLinksDomain()) {
|
|
|
|
Global::SetInternalLinksDomain(domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QString Application::createInternalLink(const QString &query) const {
|
2017-03-10 17:25:43 +00:00
|
|
|
auto result = createInternalLinkFull(query);
|
|
|
|
auto prefixes = {
|
|
|
|
qstr("https://"),
|
|
|
|
qstr("http://"),
|
|
|
|
};
|
|
|
|
for (auto &prefix : prefixes) {
|
|
|
|
if (result.startsWith(prefix, Qt::CaseInsensitive)) {
|
|
|
|
return result.mid(prefix.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LOG(("Warning: bad internal url '%1'").arg(result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QString Application::createInternalLinkFull(const QString &query) const {
|
2017-03-10 17:25:43 +00:00
|
|
|
return Global::InternalLinksDomain() + query;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::checkStartUrl() {
|
2018-06-03 13:30:40 +00:00
|
|
|
if (!cStartUrl().isEmpty() && !locked()) {
|
2017-06-27 20:11:38 +00:00
|
|
|
auto url = cStartUrl();
|
|
|
|
cSetStartUrl(QString());
|
2018-07-09 18:13:48 +00:00
|
|
|
if (!openLocalUrl(url, {})) {
|
2017-06-27 20:11:38 +00:00
|
|
|
cSetStartUrl(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::openLocalUrl(const QString &url, QVariant context) {
|
2017-06-27 20:11:38 +00:00
|
|
|
auto urlTrimmed = url.trimmed();
|
|
|
|
if (urlTrimmed.size() > 8192) urlTrimmed = urlTrimmed.mid(0, 8192);
|
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
const auto protocol = qstr("tg://");
|
|
|
|
if (!urlTrimmed.startsWith(protocol, Qt::CaseInsensitive) || locked()) {
|
2017-06-27 20:11:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-06-03 13:30:40 +00:00
|
|
|
auto command = urlTrimmed.midRef(protocol.size());
|
2017-06-27 20:11:38 +00:00
|
|
|
|
|
|
|
using namespace qthelp;
|
2018-11-26 11:55:02 +00:00
|
|
|
const auto options = RegExOption::CaseInsensitive;
|
2019-01-21 13:42:21 +00:00
|
|
|
for (const auto &[expression, handler] : LocalUrlHandlers()) {
|
2018-11-26 11:55:02 +00:00
|
|
|
const auto match = regex_match(expression, command, options);
|
|
|
|
if (match) {
|
|
|
|
return handler(match, context);
|
2018-04-18 15:42:02 +00:00
|
|
|
}
|
2017-06-27 20:11:38 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::lockByPasscode() {
|
2018-06-03 13:30:40 +00:00
|
|
|
_passcodeLock = true;
|
|
|
|
_window->setupPasscodeLock();
|
2017-04-15 18:48:54 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::unlockPasscode() {
|
2018-06-07 07:44:38 +00:00
|
|
|
clearPasscodeLock();
|
2018-06-03 13:30:40 +00:00
|
|
|
_window->clearPasscodeLock();
|
2018-06-07 07:44:38 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::clearPasscodeLock() {
|
2018-06-07 07:44:38 +00:00
|
|
|
cSetPasscodeBadTries(0);
|
2018-06-03 13:30:40 +00:00
|
|
|
_passcodeLock = false;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::passcodeLocked() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return _passcodeLock.current();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::passcodeLockChanges() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return _passcodeLock.changes();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::passcodeLockValue() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return _passcodeLock.value();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::lockByTerms(const Window::TermsLock &data) {
|
2018-06-03 13:30:40 +00:00
|
|
|
if (!_termsLock || *_termsLock != data) {
|
|
|
|
_termsLock = std::make_unique<Window::TermsLock>(data);
|
|
|
|
_termsLockChanges.fire(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::unlockTerms() {
|
2018-06-03 13:30:40 +00:00
|
|
|
if (_termsLock) {
|
|
|
|
_termsLock = nullptr;
|
|
|
|
_termsLockChanges.fire(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
std::optional<Window::TermsLock> Application::termsLocked() const {
|
2018-09-21 16:28:46 +00:00
|
|
|
return _termsLock ? base::make_optional(*_termsLock) : std::nullopt;
|
2018-06-03 13:30:40 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::termsLockChanges() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return _termsLockChanges.events();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::termsLockValue() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return rpl::single(
|
|
|
|
_termsLock != nullptr
|
|
|
|
) | rpl::then(termsLockChanges());
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::termsDeleteNow() {
|
2018-06-03 13:30:40 +00:00
|
|
|
MTP::send(MTPaccount_DeleteAccount(MTP_string("Decline ToS update")));
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::locked() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return passcodeLocked() || termsLocked();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::lockChanges() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
return lockValue() | rpl::skip(1);
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
rpl::producer<bool> Application::lockValue() const {
|
2018-06-03 13:30:40 +00:00
|
|
|
using namespace rpl::mappers;
|
|
|
|
return rpl::combine(
|
|
|
|
passcodeLockValue(),
|
|
|
|
termsLockValue(),
|
|
|
|
_1 || _2);
|
2017-04-15 18:48:54 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
MainWindow *Application::getActiveWindow() const {
|
2017-02-23 10:59:19 +00:00
|
|
|
return _window.get();
|
|
|
|
}
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::closeActiveWindow() {
|
2017-08-08 09:56:10 +00:00
|
|
|
if (hideMediaView()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (auto activeWindow = getActiveWindow()) {
|
|
|
|
if (!activeWindow->hideNoQuit()) {
|
|
|
|
activeWindow->close();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
bool Application::minimizeActiveWindow() {
|
2017-08-08 09:56:10 +00:00
|
|
|
hideMediaView();
|
|
|
|
if (auto activeWindow = getActiveWindow()) {
|
|
|
|
if (Global::WorkMode().value() == dbiwmTrayOnly) {
|
|
|
|
activeWindow->minimizeToTray();
|
|
|
|
} else {
|
|
|
|
activeWindow->setWindowState(Qt::WindowMinimized);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QWidget *Application::getFileDialogParent() {
|
2017-08-08 09:31:48 +00:00
|
|
|
return (_mediaView && _mediaView->isVisible()) ? (QWidget*)_mediaView.get() : (QWidget*)getActiveWindow();
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::checkMediaViewActivation() {
|
2017-08-08 09:31:48 +00:00
|
|
|
if (_mediaView && !_mediaView->isHidden()) {
|
|
|
|
_mediaView->activateWindow();
|
2019-01-21 13:42:21 +00:00
|
|
|
QApplication::setActiveWindow(_mediaView.get());
|
2017-08-08 09:31:48 +00:00
|
|
|
_mediaView->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::logOut() {
|
2018-06-04 18:18:52 +00:00
|
|
|
if (_mtproto) {
|
|
|
|
_mtproto->logout(::rpcDone([=] {
|
|
|
|
loggedOut();
|
|
|
|
}), ::rpcFail([=] {
|
|
|
|
loggedOut();
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
// We log out because we've forgotten passcode.
|
|
|
|
// So we just start mtproto from scratch.
|
|
|
|
startMtp();
|
|
|
|
loggedOut();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::loggedOut() {
|
2018-06-04 18:18:52 +00:00
|
|
|
if (Global::LocalPasscode()) {
|
|
|
|
Global::SetLocalPasscode(false);
|
|
|
|
Global::RefLocalPasscodeChanged().notify();
|
|
|
|
}
|
2018-06-07 07:44:38 +00:00
|
|
|
clearPasscodeLock();
|
2018-06-04 18:18:52 +00:00
|
|
|
Media::Player::mixer()->stopAndClear();
|
2018-11-30 14:33:12 +00:00
|
|
|
Global::SetVoiceMsgPlaybackDoubled(false);
|
|
|
|
Media::Player::mixer()->setVoicePlaybackDoubled(false);
|
2019-01-03 12:36:01 +00:00
|
|
|
if (const auto window = getActiveWindow()) {
|
|
|
|
window->tempDirDelete(Local::ClearManagerAll);
|
|
|
|
window->setupIntro();
|
2018-06-04 18:18:52 +00:00
|
|
|
}
|
2018-08-27 11:35:58 +00:00
|
|
|
if (const auto session = authSession()) {
|
2019-01-03 12:36:01 +00:00
|
|
|
session->data().clearLocalStorage();
|
|
|
|
authSessionDestroy();
|
2018-08-27 11:35:58 +00:00
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
if (_mediaView) {
|
|
|
|
hideMediaView();
|
|
|
|
_mediaView->clearData();
|
|
|
|
}
|
2018-06-04 18:18:52 +00:00
|
|
|
Local::reset();
|
|
|
|
|
|
|
|
cSetOtherOnline(0);
|
2018-10-11 15:54:57 +00:00
|
|
|
Images::ClearRemote();
|
2017-08-08 09:31:48 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
QPoint Application::getPointForCallPanelCenter() const {
|
2017-08-08 09:56:10 +00:00
|
|
|
if (auto activeWindow = getActiveWindow()) {
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(activeWindow->windowHandle() != nullptr);
|
2017-08-08 09:56:10 +00:00
|
|
|
if (activeWindow->isActive()) {
|
|
|
|
return activeWindow->geometry().center();
|
|
|
|
}
|
|
|
|
return activeWindow->windowHandle()->screen()->geometry().center();
|
2017-04-19 20:25:48 +00:00
|
|
|
}
|
2017-08-08 09:56:10 +00:00
|
|
|
return QApplication::desktop()->screenGeometry().center();
|
2017-04-19 20:25:48 +00:00
|
|
|
}
|
2017-04-29 20:06:32 +00:00
|
|
|
|
2017-11-21 10:27:37 +00:00
|
|
|
// macOS Qt bug workaround, sometimes no leaveEvent() gets to the nested widgets.
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::registerLeaveSubscription(QWidget *widget) {
|
2017-11-21 10:27:37 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
if (auto topLevel = widget->window()) {
|
|
|
|
if (topLevel == _window.get()) {
|
2017-11-30 18:04:13 +00:00
|
|
|
auto weak = make_weak(widget);
|
2017-12-22 07:05:20 +00:00
|
|
|
auto subscription = _window->leaveEvents(
|
|
|
|
) | rpl::start_with_next([weak] {
|
|
|
|
if (const auto window = weak.data()) {
|
|
|
|
QEvent ev(QEvent::Leave);
|
|
|
|
QGuiApplication::sendEvent(window, &ev);
|
|
|
|
}
|
|
|
|
});
|
2017-11-30 18:04:13 +00:00
|
|
|
_leaveSubscriptions.emplace_back(weak, std::move(subscription));
|
2017-11-21 10:27:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::unregisterLeaveSubscription(QWidget *widget) {
|
2017-11-21 10:27:37 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
_leaveSubscriptions = std::move(
|
|
|
|
_leaveSubscriptions
|
|
|
|
) | ranges::action::remove_if([&](const LeaveSubscription &subscription) {
|
|
|
|
auto pointer = subscription.pointer.data();
|
|
|
|
return !pointer || (pointer == widget);
|
|
|
|
});
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::postponeCall(FnMut<void()> &&callable) {
|
|
|
|
Sandbox::Instance().postponeCall(std::move(callable));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::refreshGlobalProxy() {
|
|
|
|
Sandbox::Instance().refreshGlobalProxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::activateWindowDelayed(not_null<QWidget*> widget) {
|
|
|
|
Sandbox::Instance().activateWindowDelayed(widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::pauseDelayedWindowActivations() {
|
|
|
|
Sandbox::Instance().pauseDelayedWindowActivations();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::resumeDelayedWindowActivations() {
|
|
|
|
Sandbox::Instance().resumeDelayedWindowActivations();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::preventWindowActivation() {
|
|
|
|
pauseDelayedWindowActivations();
|
|
|
|
postponeCall([=] {
|
|
|
|
resumeDelayedWindowActivations();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::QuitAttempt() {
|
2017-04-29 20:06:32 +00:00
|
|
|
auto prevents = false;
|
2019-01-21 13:42:21 +00:00
|
|
|
if (AuthSession::Exists() && !Sandbox::Instance().isSavingSession()) {
|
2019-02-01 09:23:37 +00:00
|
|
|
if (const auto mainwidget = App::main()) {
|
2019-01-31 20:36:15 +00:00
|
|
|
if (mainwidget->isQuitPrevent()) {
|
|
|
|
prevents = true;
|
|
|
|
}
|
|
|
|
}
|
2017-08-04 14:54:32 +00:00
|
|
|
if (Auth().api().isQuitPrevent()) {
|
2017-04-29 20:06:32 +00:00
|
|
|
prevents = true;
|
|
|
|
}
|
2017-08-04 14:54:32 +00:00
|
|
|
if (Auth().calls().isQuitPrevent()) {
|
2017-04-29 20:06:32 +00:00
|
|
|
prevents = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (prevents) {
|
2019-01-21 13:42:21 +00:00
|
|
|
App().quitDelayed();
|
2017-04-29 20:06:32 +00:00
|
|
|
} else {
|
2019-01-18 11:26:43 +00:00
|
|
|
QApplication::quit();
|
2017-04-29 20:06:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::quitPreventFinished() {
|
2017-04-29 20:06:32 +00:00
|
|
|
if (App::quitting()) {
|
|
|
|
QuitAttempt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::quitDelayed() {
|
2017-04-29 20:06:32 +00:00
|
|
|
if (!_private->quitTimer.isActive()) {
|
2019-01-18 11:26:43 +00:00
|
|
|
_private->quitTimer.setCallback([] { QApplication::quit(); });
|
2017-04-29 20:06:32 +00:00
|
|
|
_private->quitTimer.callOnce(kQuitPreventTimeoutMs);
|
|
|
|
}
|
|
|
|
}
|
2018-11-16 12:15:14 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
void Application::startShortcuts() {
|
2018-11-16 12:15:14 +00:00
|
|
|
Shortcuts::Start();
|
|
|
|
|
|
|
|
Shortcuts::Requests(
|
|
|
|
) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
|
|
|
using Command = Shortcuts::Command;
|
|
|
|
request->check(Command::Quit) && request->handle([] {
|
|
|
|
App::quit();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::Lock) && request->handle([=] {
|
|
|
|
if (!passcodeLocked() && Global::LocalPasscode()) {
|
|
|
|
lockByPasscode();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
request->check(Command::Minimize) && request->handle([=] {
|
|
|
|
return minimizeActiveWindow();
|
|
|
|
});
|
|
|
|
request->check(Command::Close) && request->handle([=] {
|
|
|
|
return closeActiveWindow();
|
|
|
|
});
|
|
|
|
}, _lifetime);
|
|
|
|
}
|
2019-01-21 13:42:21 +00:00
|
|
|
|
|
|
|
Application::~Application() {
|
|
|
|
_window.reset();
|
|
|
|
_mediaView.reset();
|
|
|
|
|
|
|
|
// Some MTP requests can be cancelled from data clearing.
|
|
|
|
authSessionDestroy();
|
|
|
|
|
|
|
|
// The langpack manager should be destroyed before MTProto instance,
|
|
|
|
// because it is MTP::Sender and it may have pending requests.
|
|
|
|
_langCloudManager.reset();
|
|
|
|
|
|
|
|
_mtproto.reset();
|
|
|
|
_mtprotoForKeysDestroy.reset();
|
|
|
|
|
|
|
|
Shortcuts::Finish();
|
|
|
|
|
|
|
|
Ui::Emoji::Clear();
|
|
|
|
|
|
|
|
anim::stopManager();
|
|
|
|
|
|
|
|
stopWebLoadManager();
|
|
|
|
App::deinitMedia();
|
|
|
|
|
|
|
|
Window::Theme::Unload();
|
|
|
|
|
2019-02-01 07:09:55 +00:00
|
|
|
Media::Player::finish(_audio.get());
|
2019-01-21 13:42:21 +00:00
|
|
|
style::stopManager();
|
|
|
|
|
|
|
|
Local::finish();
|
|
|
|
Global::finish();
|
|
|
|
ThirdParty::finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
Application &App() {
|
|
|
|
return Sandbox::Instance().application();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Core
|