2015-12-07 13:05:00 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2015-12-07 13:05:00 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "window.h"
|
|
|
|
#include "mainwidget.h"
|
2016-03-19 16:55:15 +00:00
|
|
|
#include "application.h"
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
#include "boxes/confirmbox.h"
|
|
|
|
|
2015-12-24 20:29:33 +00:00
|
|
|
#include "layerwidget.h"
|
2016-01-11 15:43:29 +00:00
|
|
|
#include "lang.h"
|
2015-12-24 20:29:33 +00:00
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
Q_DECLARE_METATYPE(ClickHandlerPtr);
|
2016-02-16 13:33:33 +00:00
|
|
|
Q_DECLARE_METATYPE(Qt::MouseButton);
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace App {
|
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
void sendBotCommand(PeerData *peer, const QString &cmd, MsgId replyTo) {
|
|
|
|
if (MainWidget *m = main()) m->sendBotCommand(peer, cmd, replyTo);
|
|
|
|
}
|
|
|
|
|
2016-04-01 10:23:40 +00:00
|
|
|
void sendBotCallback(PeerData *peer, const QByteArray &data, MsgId replyTo) {
|
|
|
|
if (MainWidget *m = main()) m->sendBotCallback(peer, data, replyTo);
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2015-12-31 18:34:56 +00:00
|
|
|
bool insertBotCommand(const QString &cmd, bool specialGif) {
|
|
|
|
if (MainWidget *m = main()) return m->insertBotCommand(cmd, specialGif);
|
|
|
|
return false;
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
void activateBotCommand(PeerData *peer, const HistoryMessageReplyMarkup::Button &button, MsgId replyTo) {
|
|
|
|
switch (button.type) {
|
|
|
|
case HistoryMessageReplyMarkup::Button::Default: {
|
|
|
|
// copy string before passing it to the sending method
|
|
|
|
// the original button can be destroyed inside
|
|
|
|
sendBotCommand(peer, QString(button.text), replyTo);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case HistoryMessageReplyMarkup::Button::Callback: {
|
2016-04-01 10:23:40 +00:00
|
|
|
sendBotCallback(peer, button.data, replyTo);
|
2016-03-29 17:17:00 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case HistoryMessageReplyMarkup::Button::Url: {
|
2016-04-01 10:23:40 +00:00
|
|
|
auto url = QString::fromUtf8(button.data);
|
|
|
|
HiddenUrlClickHandler(url).onClick(Qt::LeftButton);
|
2016-03-29 17:17:00 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case HistoryMessageReplyMarkup::Button::RequestLocation: {
|
|
|
|
Ui::showLayer(new InformBox(lang(lng_bot_share_location_unavailable)));
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case HistoryMessageReplyMarkup::Button::RequestPhone: {
|
2016-03-30 16:42:01 +00:00
|
|
|
SharePhoneConfirmBox *box = new SharePhoneConfirmBox(peer);
|
|
|
|
box->connect(box, SIGNAL(confirmed(PeerData*)), App::main(), SLOT(onSharePhoneWithBot(PeerData*)));
|
2016-03-29 17:17:00 +00:00
|
|
|
Ui::showLayer(box);
|
|
|
|
} break;
|
|
|
|
}
|
2016-03-28 12:51:22 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
void searchByHashtag(const QString &tag, PeerData *inPeer) {
|
2016-03-29 17:17:00 +00:00
|
|
|
if (MainWidget *m = main()) m->searchMessages(tag + ' ', (inPeer && inPeer->isChannel() && !inPeer->isMegagroup()) ? inPeer : 0);
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 16:37:21 +00:00
|
|
|
void openPeerByName(const QString &username, MsgId msgId, const QString &startToken) {
|
|
|
|
if (MainWidget *m = main()) m->openPeerByName(username, msgId, startToken);
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void joinGroupByHash(const QString &hash) {
|
|
|
|
if (MainWidget *m = main()) m->joinGroupByHash(hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stickersBox(const QString &name) {
|
|
|
|
if (MainWidget *m = main()) m->stickersBox(MTP_inputStickerSetShortName(MTP_string(name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void openLocalUrl(const QString &url) {
|
|
|
|
if (MainWidget *m = main()) m->openLocalUrl(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool forward(const PeerId &peer, ForwardWhatMessages what) {
|
|
|
|
if (MainWidget *m = main()) return m->onForward(peer, what);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeDialog(History *history) {
|
2016-02-16 11:21:39 +00:00
|
|
|
if (MainWidget *m = main()) {
|
|
|
|
m->removeDialog(history);
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void showSettings() {
|
2016-02-16 11:21:39 +00:00
|
|
|
if (Window *w = wnd()) {
|
|
|
|
w->showSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
void activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) {
|
2016-02-16 11:21:39 +00:00
|
|
|
if (Window *w = wnd()) {
|
2016-03-29 17:17:00 +00:00
|
|
|
qRegisterMetaType<ClickHandlerPtr>();
|
2016-02-16 11:21:39 +00:00
|
|
|
qRegisterMetaType<Qt::MouseButton>();
|
2016-03-29 17:17:00 +00:00
|
|
|
QMetaObject::invokeMethod(w, "app_activateClickHandler", Qt::QueuedConnection, Q_ARG(ClickHandlerPtr, handler), Q_ARG(Qt::MouseButton, button));
|
2016-02-16 11:21:39 +00:00
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-31 14:06:40 +00:00
|
|
|
void logOutDelayed() {
|
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
QMetaObject::invokeMethod(w, "onLogoutSure", Qt::QueuedConnection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
void showStickerPreview(DocumentData *sticker) {
|
2016-02-17 16:37:21 +00:00
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
w->ui_showStickerPreview(sticker);
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hideStickerPreview() {
|
2016-02-17 16:37:21 +00:00
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
w->ui_hideStickerPreview();
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 18:09:05 +00:00
|
|
|
void showLayer(LayeredWidget *box, ShowLayerOptions options) {
|
2015-12-16 15:04:02 +00:00
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
w->ui_showLayer(box, options);
|
|
|
|
} else {
|
|
|
|
delete box;
|
|
|
|
}
|
2015-12-07 18:09:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hideLayer(bool fast) {
|
|
|
|
if (Window *w = App::wnd()) w->ui_showLayer(0, ShowLayerOptions(CloseOtherLayers) | (fast ? ForceFastShowLayer : AnimatedShowLayer));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLayerShown() {
|
|
|
|
if (Window *w = App::wnd()) return w->ui_isLayerShown();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-25 13:09:14 +00:00
|
|
|
bool isMediaViewShown() {
|
|
|
|
if (Window *w = App::wnd()) return w->ui_isMediaViewShown();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-30 19:09:20 +00:00
|
|
|
bool isInlineItemBeingChosen() {
|
|
|
|
if (MainWidget *m = App::main()) return m->ui_isInlineItemBeingChosen();
|
2015-12-27 21:37:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void repaintHistoryItem(const HistoryItem *item) {
|
|
|
|
if (!item) return;
|
|
|
|
if (MainWidget *m = App::main()) m->ui_repaintHistoryItem(item);
|
|
|
|
}
|
|
|
|
|
2015-12-30 19:09:20 +00:00
|
|
|
void repaintInlineItem(const LayoutInlineItem *layout) {
|
2015-12-27 21:37:48 +00:00
|
|
|
if (!layout) return;
|
2015-12-30 19:09:20 +00:00
|
|
|
if (MainWidget *m = App::main()) m->ui_repaintInlineItem(layout);
|
2015-12-22 08:01:02 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 19:09:20 +00:00
|
|
|
bool isInlineItemVisible(const LayoutInlineItem *layout) {
|
|
|
|
if (MainWidget *m = App::main()) return m->ui_isInlineItemVisible(layout);
|
2015-12-27 21:37:48 +00:00
|
|
|
return false;
|
2015-12-13 11:17:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-19 16:55:15 +00:00
|
|
|
void autoplayMediaInlineAsync(const FullMsgId &msgId) {
|
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
QMetaObject::invokeMethod(m, "ui_autoplayMediaInlineAsync", Qt::QueuedConnection, Q_ARG(qint32, msgId.channel), Q_ARG(qint32, msgId.msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-12 22:29:33 +00:00
|
|
|
void showPeerHistory(const PeerId &peer, MsgId msgId, bool back) {
|
2015-12-13 11:36:08 +00:00
|
|
|
if (MainWidget *m = App::main()) m->ui_showPeerHistory(peer, msgId, back);
|
2015-12-12 22:29:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 11:17:15 +00:00
|
|
|
void showPeerHistoryAsync(const PeerId &peer, MsgId msgId) {
|
|
|
|
if (MainWidget *m = App::main()) {
|
2016-01-01 14:48:32 +00:00
|
|
|
QMetaObject::invokeMethod(m, "ui_showPeerHistoryAsync", Qt::QueuedConnection, Q_ARG(quint64, peer), Q_ARG(qint32, msgId));
|
2015-12-13 11:17:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
PeerData *getPeerForMouseAction() {
|
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
return w->ui_getPeerForMouseAction();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-02-10 11:39:48 +00:00
|
|
|
bool hideWindowNoQuit() {
|
2016-03-02 18:34:42 +00:00
|
|
|
if (!App::quitting()) {
|
2016-02-10 11:39:48 +00:00
|
|
|
if (Window *w = App::wnd()) {
|
|
|
|
if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
|
|
|
|
return w->minimizeToTray();
|
|
|
|
} else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
|
|
|
w->hide();
|
2016-02-18 16:36:33 +00:00
|
|
|
w->updateIsActive(Global::OfflineBlurTimeout());
|
2016-02-10 11:39:48 +00:00
|
|
|
w->updateGlobalMenu();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Notify {
|
|
|
|
|
|
|
|
void userIsBotChanged(UserData *user) {
|
2015-12-11 18:11:38 +00:00
|
|
|
if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user);
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 11:17:15 +00:00
|
|
|
void userIsContactChanged(UserData *user, bool fromThisApp) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_userIsContactChanged(user, fromThisApp);
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
void botCommandsChanged(UserData *user) {
|
2015-12-11 18:11:38 +00:00
|
|
|
if (MainWidget *m = App::main()) m->notify_botCommandsChanged(user);
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-01 09:58:05 +00:00
|
|
|
void inlineBotRequesting(bool requesting) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting);
|
|
|
|
}
|
|
|
|
|
2016-04-01 15:32:26 +00:00
|
|
|
void replyMarkupUpdated(const HistoryItem *item) {
|
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
m->notify_replyMarkupUpdated(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
void migrateUpdated(PeerData *peer) {
|
2015-12-11 18:11:38 +00:00
|
|
|
if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer);
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
void clipStopperHidden(ClipStopperType type) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_clipStopperHidden(type);
|
2015-12-25 13:09:14 +00:00
|
|
|
}
|
|
|
|
|
2015-12-12 22:29:33 +00:00
|
|
|
void historyItemLayoutChanged(const HistoryItem *item) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_historyItemLayoutChanged(item);
|
|
|
|
}
|
|
|
|
|
2015-12-31 15:27:21 +00:00
|
|
|
void automaticLoadSettingsChangedGif() {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_automaticLoadSettingsChangedGif();
|
|
|
|
}
|
|
|
|
|
2016-03-19 16:55:15 +00:00
|
|
|
void handlePendingHistoryUpdate() {
|
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
m->notify_handlePendingHistoryUpdate();
|
|
|
|
}
|
2016-03-25 15:20:34 +00:00
|
|
|
for_const (HistoryItem *item, Global::PendingRepaintItems()) {
|
|
|
|
Ui::repaintHistoryItem(item);
|
2016-03-19 16:55:15 +00:00
|
|
|
}
|
|
|
|
Global::RefPendingRepaintItems().clear();
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
|
|
|
|
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in " #Namespace "::" #Name, __FILE__, __LINE__); \
|
|
|
|
return Namespace##Data->Name; \
|
|
|
|
}
|
|
|
|
#define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \
|
|
|
|
Type &Ref##Name() { \
|
|
|
|
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in Global::Ref" #Name, __FILE__, __LINE__); \
|
|
|
|
return Namespace##Data->Name; \
|
|
|
|
}
|
|
|
|
#define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \
|
|
|
|
void Set##Name(const Type &Name) { \
|
|
|
|
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in Global::Set" #Name, __FILE__, __LINE__); \
|
|
|
|
Namespace##Data->Name = Name; \
|
|
|
|
}
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
namespace Sandbox {
|
2016-01-21 06:58:58 +00:00
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
QString LangSystemISO;
|
|
|
|
int32 LangSystem = languageDefault;
|
|
|
|
|
|
|
|
QByteArray LastCrashDump;
|
|
|
|
ConnectionProxy PreLaunchProxy;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Sandbox::internal::Data *SandboxData = 0;
|
2016-02-15 15:52:11 +00:00
|
|
|
uint64 SandboxUserTag = 0;
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
namespace Sandbox {
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
bool CheckBetaVersionDir() {
|
|
|
|
QFile beta(cExeDir() + qsl("TelegramBeta_data/tdata/beta"));
|
|
|
|
if (cBetaVersion()) {
|
|
|
|
cForceWorkingDir(cExeDir() + qsl("TelegramBeta_data/"));
|
2016-02-04 22:16:25 +00:00
|
|
|
QDir().mkpath(cWorkingDir() + qstr("tdata"));
|
2016-01-11 15:43:29 +00:00
|
|
|
if (*BetaPrivateKey) {
|
|
|
|
cSetBetaPrivateKey(QByteArray(BetaPrivateKey));
|
|
|
|
}
|
|
|
|
if (beta.open(QIODevice::WriteOnly)) {
|
|
|
|
QDataStream dataStream(&beta);
|
|
|
|
dataStream.setVersion(QDataStream::Qt_5_3);
|
|
|
|
dataStream << quint64(cRealBetaVersion()) << cBetaPrivateKey();
|
|
|
|
} else {
|
2016-02-04 12:44:39 +00:00
|
|
|
LOG(("FATAL: Could not open '%1' for writing private key!").arg(beta.fileName()));
|
2016-01-11 15:43:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (beta.exists()) {
|
|
|
|
cForceWorkingDir(cExeDir() + qsl("TelegramBeta_data/"));
|
|
|
|
if (beta.open(QIODevice::ReadOnly)) {
|
|
|
|
QDataStream dataStream(&beta);
|
|
|
|
dataStream.setVersion(QDataStream::Qt_5_3);
|
|
|
|
|
|
|
|
quint64 v;
|
|
|
|
QByteArray k;
|
|
|
|
dataStream >> v >> k;
|
|
|
|
if (dataStream.status() == QDataStream::Ok) {
|
|
|
|
cSetBetaVersion(qMax(v, AppVersion * 1000ULL));
|
|
|
|
cSetBetaPrivateKey(k);
|
|
|
|
cSetRealBetaVersion(v);
|
|
|
|
} else {
|
2016-02-04 12:44:39 +00:00
|
|
|
LOG(("FATAL: '%1' is corrupted, reinstall private beta!").arg(beta.fileName()));
|
2016-01-11 15:43:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2016-02-04 12:44:39 +00:00
|
|
|
LOG(("FATAL: could not open '%1' for reading private key!").arg(beta.fileName()));
|
2016-01-11 15:43:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
void WorkingDirReady() {
|
|
|
|
if (QFile(cWorkingDir() + qsl("tdata/withtestmode")).exists()) {
|
|
|
|
cSetTestMode(true);
|
|
|
|
}
|
|
|
|
if (!cDebug() && QFile(cWorkingDir() + qsl("tdata/withdebug")).exists()) {
|
|
|
|
cSetDebug(true);
|
|
|
|
}
|
|
|
|
if (cBetaVersion()) {
|
|
|
|
cSetDevVersion(false);
|
|
|
|
} else if (!cDevVersion() && QFile(cWorkingDir() + qsl("tdata/devversion")).exists()) {
|
|
|
|
cSetDevVersion(true);
|
|
|
|
} else if (DevVersion) {
|
|
|
|
QFile f(cWorkingDir() + qsl("tdata/devversion"));
|
|
|
|
if (!f.exists() && f.open(QIODevice::WriteOnly)) {
|
|
|
|
f.write("1");
|
|
|
|
}
|
|
|
|
}
|
2016-02-15 15:52:11 +00:00
|
|
|
|
|
|
|
srand((int32)time(NULL));
|
|
|
|
|
|
|
|
SandboxUserTag = 0;
|
|
|
|
QFile usertag(cWorkingDir() + qsl("tdata/usertag"));
|
|
|
|
if (usertag.open(QIODevice::ReadOnly)) {
|
|
|
|
if (usertag.read(reinterpret_cast<char*>(&SandboxUserTag), sizeof(uint64)) != sizeof(uint64)) {
|
|
|
|
SandboxUserTag = 0;
|
|
|
|
}
|
|
|
|
usertag.close();
|
|
|
|
}
|
|
|
|
if (!SandboxUserTag) {
|
|
|
|
do {
|
|
|
|
memsetrnd_bad(SandboxUserTag);
|
|
|
|
} while (!SandboxUserTag);
|
|
|
|
|
|
|
|
if (usertag.open(QIODevice::WriteOnly)) {
|
|
|
|
usertag.write(reinterpret_cast<char*>(&SandboxUserTag), sizeof(uint64));
|
|
|
|
usertag.close();
|
|
|
|
}
|
|
|
|
}
|
2016-01-11 15:43:29 +00:00
|
|
|
}
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
void start() {
|
2016-03-18 19:05:08 +00:00
|
|
|
SandboxData = new internal::Data();
|
2016-01-09 12:51:42 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
SandboxData->LangSystemISO = psCurrentLanguage();
|
|
|
|
if (SandboxData->LangSystemISO.isEmpty()) SandboxData->LangSystemISO = qstr("en");
|
2016-01-11 15:43:29 +00:00
|
|
|
QByteArray l = LangSystemISO().toLatin1();
|
|
|
|
for (int32 i = 0; i < languageCount; ++i) {
|
|
|
|
if (l.at(0) == LanguageCodes[i][0] && l.at(1) == LanguageCodes[i][1]) {
|
2016-02-08 14:54:55 +00:00
|
|
|
SandboxData->LangSystem = i;
|
2016-01-11 15:43:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-01-09 11:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
void finish() {
|
2016-02-08 14:54:55 +00:00
|
|
|
delete SandboxData;
|
|
|
|
SandboxData = 0;
|
2016-01-09 11:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 15:52:11 +00:00
|
|
|
uint64 UserTag() {
|
|
|
|
return SandboxUserTag;
|
|
|
|
}
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
DefineReadOnlyVar(Sandbox, QString, LangSystemISO);
|
|
|
|
DefineReadOnlyVar(Sandbox, int32, LangSystem);
|
|
|
|
DefineVar(Sandbox, QByteArray, LastCrashDump);
|
|
|
|
DefineVar(Sandbox, ConnectionProxy, PreLaunchProxy);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
namespace Global {
|
|
|
|
namespace internal {
|
2016-02-21 17:01:37 +00:00
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
struct Data {
|
|
|
|
uint64 LaunchId = 0;
|
2016-03-19 16:55:15 +00:00
|
|
|
SingleDelayedCall HandleHistoryUpdate = { App::app(), "call_handleHistoryUpdate" };
|
2016-02-18 16:36:33 +00:00
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout;
|
|
|
|
bool AdaptiveForWide = true;
|
2016-03-17 18:03:08 +00:00
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
int32 DebugLoggingFlags = 0;
|
|
|
|
|
|
|
|
// config
|
|
|
|
int32 ChatSizeMax = 200;
|
|
|
|
int32 MegagroupSizeMax = 1000;
|
|
|
|
int32 ForwardedCountMax = 100;
|
|
|
|
int32 OnlineUpdatePeriod = 120000;
|
|
|
|
int32 OfflineBlurTimeout = 5000;
|
|
|
|
int32 OfflineIdleTimeout = 30000;
|
|
|
|
int32 OnlineFocusTimeout = 1000;
|
|
|
|
int32 OnlineCloudTimeout = 300000;
|
|
|
|
int32 NotifyCloudDelay = 30000;
|
|
|
|
int32 NotifyDefaultDelay = 1500;
|
|
|
|
int32 ChatBigSize = 10;
|
|
|
|
int32 PushChatPeriod = 60000;
|
|
|
|
int32 PushChatLimit = 2;
|
|
|
|
int32 SavedGifsLimit = 200;
|
|
|
|
int32 EditTimeLimit = 172800;
|
|
|
|
|
|
|
|
HiddenPinnedMessagesMap HiddenPinnedMessages;
|
|
|
|
|
|
|
|
PendingItemsMap PendingRepaintItems;
|
|
|
|
|
2016-03-19 16:55:15 +00:00
|
|
|
Stickers::Sets StickerSets;
|
|
|
|
Stickers::Order StickerSetsOrder;
|
|
|
|
uint64 LastStickersUpdate = 0;
|
|
|
|
|
|
|
|
MTP::DcOptions DcOptions;
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
CircleMasksMap CircleMasks;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Global::internal::Data *GlobalData = 0;
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
namespace Global {
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-01-30 16:31:10 +00:00
|
|
|
bool started() {
|
2016-02-08 14:54:55 +00:00
|
|
|
return GlobalData != 0;
|
2016-01-30 16:31:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
void start() {
|
2016-03-18 19:05:08 +00:00
|
|
|
GlobalData = new internal::Data();
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
memset_rand(&GlobalData->LaunchId, sizeof(GlobalData->LaunchId));
|
2016-01-11 15:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void finish() {
|
2016-02-08 14:54:55 +00:00
|
|
|
delete GlobalData;
|
|
|
|
GlobalData = 0;
|
2016-01-11 15:43:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
DefineReadOnlyVar(Global, uint64, LaunchId);
|
2016-03-19 16:55:15 +00:00
|
|
|
DefineRefVar(Global, SingleDelayedCall, HandleHistoryUpdate);
|
2016-02-21 17:01:37 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
DefineVar(Global, Adaptive::Layout, AdaptiveLayout);
|
2016-02-21 14:27:54 +00:00
|
|
|
DefineVar(Global, bool, AdaptiveForWide);
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-03-17 18:03:08 +00:00
|
|
|
DefineVar(Global, int32, DebugLoggingFlags);
|
|
|
|
|
2016-02-18 16:36:33 +00:00
|
|
|
// config
|
|
|
|
DefineVar(Global, int32, ChatSizeMax);
|
|
|
|
DefineVar(Global, int32, MegagroupSizeMax);
|
|
|
|
DefineVar(Global, int32, ForwardedCountMax);
|
|
|
|
DefineVar(Global, int32, OnlineUpdatePeriod);
|
|
|
|
DefineVar(Global, int32, OfflineBlurTimeout);
|
|
|
|
DefineVar(Global, int32, OfflineIdleTimeout);
|
|
|
|
DefineVar(Global, int32, OnlineFocusTimeout);
|
|
|
|
DefineVar(Global, int32, OnlineCloudTimeout);
|
|
|
|
DefineVar(Global, int32, NotifyCloudDelay);
|
|
|
|
DefineVar(Global, int32, NotifyDefaultDelay);
|
|
|
|
DefineVar(Global, int32, ChatBigSize);
|
|
|
|
DefineVar(Global, int32, PushChatPeriod);
|
|
|
|
DefineVar(Global, int32, PushChatLimit);
|
|
|
|
DefineVar(Global, int32, SavedGifsLimit);
|
|
|
|
DefineVar(Global, int32, EditTimeLimit);
|
|
|
|
|
2016-03-10 10:15:21 +00:00
|
|
|
DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages);
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
DefineRefVar(Global, PendingItemsMap, PendingRepaintItems);
|
|
|
|
|
2016-03-19 16:55:15 +00:00
|
|
|
DefineVar(Global, Stickers::Sets, StickerSets);
|
|
|
|
DefineVar(Global, Stickers::Order, StickerSetsOrder);
|
|
|
|
DefineVar(Global, uint64, LastStickersUpdate);
|
|
|
|
|
|
|
|
DefineVar(Global, MTP::DcOptions, DcOptions);
|
|
|
|
|
2016-03-18 10:18:30 +00:00
|
|
|
DefineRefVar(Global, CircleMasksMap, CircleMasks);
|
|
|
|
|
2016-01-09 11:24:16 +00:00
|
|
|
};
|