2015-12-07 13:05:00 +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.
|
2015-12-07 13:05:00 +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
|
2015-12-07 13:05:00 +00:00
|
|
|
*/
|
2017-09-13 16:57:44 +00:00
|
|
|
#include "facades.h"
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
#include "info/info_memento.h"
|
2016-05-24 16:13:07 +00:00
|
|
|
#include "core/click_handler_types.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2019-02-13 12:36:59 +00:00
|
|
|
#include "media/clip/media_clip_reader.h"
|
2019-06-06 10:21:40 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2020-01-15 13:30:29 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2017-12-18 15:44:50 +00:00
|
|
|
#include "history/history_item_components.h"
|
2019-09-17 16:13:12 +00:00
|
|
|
#include "base/platform/base_platform_info.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_peer.h"
|
|
|
|
#include "data/data_user.h"
|
2016-06-01 20:05:37 +00:00
|
|
|
#include "observer_peer.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2015-12-07 13:05:00 +00:00
|
|
|
#include "mainwidget.h"
|
2017-12-07 13:02:24 +00:00
|
|
|
#include "apiwrap.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
2019-05-22 14:29:02 +00:00
|
|
|
#include "boxes/url_auth_box.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/observer.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2018-01-11 19:33:26 +00:00
|
|
|
#include "history/history_item.h"
|
2019-08-02 13:21:09 +00:00
|
|
|
#include "history/view/media/history_view_media.h"
|
2017-12-09 10:02:51 +00:00
|
|
|
#include "styles/style_history.h"
|
2018-01-04 10:22:53 +00:00
|
|
|
#include "data/data_session.h"
|
2015-12-24 20:29:33 +00:00
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace App {
|
2016-12-09 18:56:01 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) {
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto m = App::main()) {
|
2016-04-14 19:24:42 +00:00
|
|
|
m->sendBotCommand(peer, bot, cmd, replyTo);
|
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-03-29 17:17:00 +00:00
|
|
|
|
2016-11-20 12:54:07 +00:00
|
|
|
void hideSingleUseKeyboard(const HistoryItem *msg) {
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto m = App::main()) {
|
2016-11-20 12:54:07 +00:00
|
|
|
m->hideSingleUseKeyboard(msg->history()->peer, msg->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-27 18:11:51 +00:00
|
|
|
bool insertBotCommand(const QString &cmd) {
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto m = App::main()) {
|
2017-03-27 18:11:51 +00:00
|
|
|
return m->insertBotCommand(cmd);
|
2016-04-14 19:24:42 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
void activateBotCommand(
|
|
|
|
not_null<const HistoryItem*> msg,
|
|
|
|
int row,
|
|
|
|
int column) {
|
2019-05-22 14:29:02 +00:00
|
|
|
const auto button = HistoryMessageMarkupButton::Get(msg->fullId(), row, column);
|
2016-04-11 10:59:01 +00:00
|
|
|
if (!button) return;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
using ButtonType = HistoryMessageMarkupButton::Type;
|
2016-04-11 10:59:01 +00:00
|
|
|
switch (button->type) {
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::Default: {
|
2016-04-11 10:59:01 +00:00
|
|
|
// Copy string before passing it to the sending method
|
|
|
|
// because the original button can be destroyed inside.
|
|
|
|
MsgId replyTo = (msg->id > 0) ? msg->id : 0;
|
2016-04-14 19:24:42 +00:00
|
|
|
sendBotCommand(msg->history()->peer, msg->fromOriginal()->asUser(), QString(button->text), replyTo);
|
2016-04-11 10:59:01 +00:00
|
|
|
} break;
|
|
|
|
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::Callback:
|
|
|
|
case ButtonType::Game: {
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto m = App::main()) {
|
2017-12-18 15:44:50 +00:00
|
|
|
m->app_sendBotCallback(button, msg, row, column);
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
case ButtonType::Buy: {
|
2019-06-19 15:09:03 +00:00
|
|
|
Ui::show(Box<InformBox>(tr::lng_payments_not_supported(tr::now)));
|
2017-03-05 13:39:10 +00:00
|
|
|
} break;
|
|
|
|
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::Url: {
|
2016-04-11 10:59:01 +00:00
|
|
|
auto url = QString::fromUtf8(button->data);
|
2016-12-20 13:03:51 +00:00
|
|
|
auto skipConfirmation = false;
|
|
|
|
if (auto bot = msg->getMessageBot()) {
|
|
|
|
if (bot->isVerified()) {
|
|
|
|
skipConfirmation = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (skipConfirmation) {
|
2018-07-09 18:13:48 +00:00
|
|
|
UrlClickHandler::Open(url);
|
2016-12-20 13:03:51 +00:00
|
|
|
} else {
|
2018-07-09 18:13:48 +00:00
|
|
|
HiddenUrlClickHandler::Open(url);
|
2016-12-20 13:03:51 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
} break;
|
|
|
|
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::RequestLocation: {
|
2016-11-20 12:54:07 +00:00
|
|
|
hideSingleUseKeyboard(msg);
|
2019-06-19 15:09:03 +00:00
|
|
|
Ui::show(Box<InformBox>(tr::lng_bot_share_location_unavailable(tr::now)));
|
2016-04-11 10:59:01 +00:00
|
|
|
} break;
|
|
|
|
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::RequestPhone: {
|
2016-11-20 12:54:07 +00:00
|
|
|
hideSingleUseKeyboard(msg);
|
2017-12-07 13:02:24 +00:00
|
|
|
const auto msgId = msg->id;
|
|
|
|
const auto history = msg->history();
|
2019-06-19 15:09:03 +00:00
|
|
|
Ui::show(Box<ConfirmBox>(tr::lng_bot_share_phone(tr::now), tr::lng_bot_share_phone_confirm(tr::now), [=] {
|
2017-12-07 13:02:24 +00:00
|
|
|
Ui::showPeerHistory(history, ShowAtTheEndMsgId);
|
2019-08-12 12:11:34 +00:00
|
|
|
auto action = Api::SendAction(history);
|
2019-08-30 10:17:18 +00:00
|
|
|
action.clearDraft = false;
|
2019-08-12 12:11:34 +00:00
|
|
|
action.replyTo = msgId;
|
2019-07-24 11:13:51 +00:00
|
|
|
history->session().api().shareContact(
|
|
|
|
history->session().user(),
|
2019-08-12 12:11:34 +00:00
|
|
|
action);
|
2016-12-13 17:07:56 +00:00
|
|
|
}));
|
2016-04-11 10:59:01 +00:00
|
|
|
} break;
|
|
|
|
|
2020-01-15 13:30:29 +00:00
|
|
|
case ButtonType::RequestPoll: {
|
|
|
|
hideSingleUseKeyboard(msg);
|
|
|
|
auto chosen = PollData::Flags();
|
|
|
|
auto disabled = PollData::Flags();
|
|
|
|
if (!button->data.isEmpty()) {
|
|
|
|
disabled |= PollData::Flag::Quiz;
|
|
|
|
if (button->data[0]) {
|
|
|
|
chosen |= PollData::Flag::Quiz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Window::PeerMenuCreatePoll(msg->history()->peer, chosen, disabled);
|
|
|
|
} break;
|
|
|
|
|
2016-09-02 16:11:23 +00:00
|
|
|
case ButtonType::SwitchInlineSame:
|
|
|
|
case ButtonType::SwitchInline: {
|
2016-04-20 12:27:38 +00:00
|
|
|
if (auto m = App::main()) {
|
2016-09-19 10:18:21 +00:00
|
|
|
if (auto bot = msg->getMessageBot()) {
|
2016-08-12 16:28:10 +00:00
|
|
|
auto tryFastSwitch = [bot, &button, msgId = msg->id]() -> bool {
|
2016-09-02 16:11:23 +00:00
|
|
|
auto samePeer = (button->type == ButtonType::SwitchInlineSame);
|
2016-08-12 16:28:10 +00:00
|
|
|
if (samePeer) {
|
|
|
|
Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data), bot, msgId);
|
|
|
|
return true;
|
2019-07-18 08:51:11 +00:00
|
|
|
} else if (bot->isBot() && bot->botInfo->inlineReturnPeerId) {
|
2016-04-11 10:59:01 +00:00
|
|
|
if (Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data))) {
|
|
|
|
return true;
|
2016-04-10 20:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
if (!tryFastSwitch()) {
|
|
|
|
m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data));
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-29 17:17:00 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
} break;
|
2019-05-22 14:29:02 +00:00
|
|
|
|
|
|
|
case ButtonType::Auth:
|
|
|
|
UrlAuthBox::Activate(msg, row, column);
|
|
|
|
break;
|
2016-03-28 12:51:22 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-03-28 12:51:22 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void searchByHashtag(const QString &tag, PeerData *inPeer) {
|
2020-01-26 02:48:42 +00:00
|
|
|
if (const auto window = App::wnd()) {
|
|
|
|
if (const auto controller = window->sessionController()) {
|
|
|
|
if (controller->openedFolder().current()) {
|
|
|
|
controller->closeFolder();
|
|
|
|
}
|
|
|
|
}
|
2017-11-07 07:21:48 +00:00
|
|
|
Ui::hideSettingsAndLayer();
|
2019-01-21 13:42:21 +00:00
|
|
|
Core::App().hideMediaView();
|
2020-01-26 02:48:42 +00:00
|
|
|
if (const auto m = window->mainWidget()) {
|
|
|
|
m->searchMessages(
|
|
|
|
tag + ' ',
|
|
|
|
(inPeer && !inPeer->isUser())
|
|
|
|
? inPeer->owner().history(inPeer).get()
|
|
|
|
: Dialogs::Key());
|
|
|
|
}
|
2017-11-07 07:21:48 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void showSettings() {
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto w = App::wnd()) {
|
2016-04-11 10:59:01 +00:00
|
|
|
w->showSettings();
|
2016-02-16 11:21:39 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-02-16 11:21:39 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace App
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace Ui {
|
2015-12-07 18:09:05 +00:00
|
|
|
|
2016-04-30 17:04:14 +00:00
|
|
|
void showPeerProfile(const PeerId &peer) {
|
2019-06-06 10:21:40 +00:00
|
|
|
if (const auto window = App::wnd()) {
|
|
|
|
if (const auto controller = window->sessionController()) {
|
2017-10-03 13:05:58 +00:00
|
|
|
controller->showPeerInfo(peer);
|
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
void showPeerProfile(const PeerData *peer) {
|
|
|
|
showPeerProfile(peer->id);
|
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerProfile(not_null<const History*> history) {
|
|
|
|
showPeerProfile(history->peer->id);
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
void showPeerHistory(
|
|
|
|
const PeerId &peer,
|
2017-10-03 13:05:58 +00:00
|
|
|
MsgId msgId) {
|
2019-02-19 06:57:53 +00:00
|
|
|
auto ms = crl::now();
|
2017-10-03 13:05:58 +00:00
|
|
|
if (auto m = App::main()) {
|
2017-10-03 17:41:44 +00:00
|
|
|
m->ui_showPeerHistory(
|
|
|
|
peer,
|
|
|
|
Window::SectionShow::Way::ClearStack,
|
|
|
|
msgId);
|
2017-09-20 10:23:57 +00:00
|
|
|
}
|
2018-01-11 19:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void showPeerHistoryAtItem(not_null<const HistoryItem*> item) {
|
|
|
|
showPeerHistory(item->history()->peer->id, item->id);
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2015-12-12 22:29:33 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerHistory(not_null<const History*> history, MsgId msgId) {
|
|
|
|
showPeerHistory(history->peer->id, msgId);
|
|
|
|
}
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
void showPeerHistory(const PeerData *peer, MsgId msgId) {
|
|
|
|
showPeerHistory(peer->id, msgId);
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
PeerData *getPeerForMouseAction() {
|
2019-01-21 13:42:21 +00:00
|
|
|
return Core::App().ui_getPeerForMouseAction();
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-03-29 17:17:00 +00:00
|
|
|
|
2016-05-12 16:05:20 +00:00
|
|
|
bool skipPaintEvent(QWidget *widget, QPaintEvent *event) {
|
|
|
|
if (auto w = App::wnd()) {
|
|
|
|
if (w->contentOverlapped(widget, event)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace Notify {
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void userIsBotChanged(UserData *user) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user);
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void botCommandsChanged(UserData *user) {
|
2016-06-01 20:05:37 +00:00
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
m->notify_botCommandsChanged(user);
|
|
|
|
}
|
|
|
|
peerUpdatedDelayed(user, PeerUpdate::Flag::BotCommandsChanged);
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void inlineBotRequesting(bool requesting) {
|
|
|
|
if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting);
|
|
|
|
}
|
2016-01-01 09:58:05 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void replyMarkupUpdated(const HistoryItem *item) {
|
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
m->notify_replyMarkupUpdated(item);
|
2016-04-01 15:32:26 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-04-01 15:32:26 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) {
|
|
|
|
if (MainWidget *m = App::main()) {
|
|
|
|
m->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
|
2016-04-08 09:20:10 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2016-04-08 09:20:10 +00:00
|
|
|
|
2016-08-12 16:28:10 +00:00
|
|
|
bool switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) {
|
2017-05-22 15:25:49 +00:00
|
|
|
if (auto main = App::main()) {
|
|
|
|
return main->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo);
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-04-08 14:16:52 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void unreadCounterUpdated() {
|
|
|
|
Global::RefHandleUnreadCounterUpdate().call();
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Notify
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
|
2017-08-17 09:06:26 +00:00
|
|
|
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::" #Name); \
|
2016-02-08 14:54:55 +00:00
|
|
|
return Namespace##Data->Name; \
|
|
|
|
}
|
|
|
|
#define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \
|
|
|
|
Type &Ref##Name() { \
|
2017-08-17 09:06:26 +00:00
|
|
|
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name); \
|
2016-02-08 14:54:55 +00:00
|
|
|
return Namespace##Data->Name; \
|
|
|
|
}
|
|
|
|
#define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \
|
|
|
|
void Set##Name(const Type &Name) { \
|
2017-08-17 09:06:26 +00:00
|
|
|
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Set" #Name); \
|
2016-02-08 14:54:55 +00:00
|
|
|
Namespace##Data->Name = Name; \
|
|
|
|
}
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
namespace Global {
|
2016-04-11 10:59:01 +00:00
|
|
|
namespace internal {
|
2016-02-21 17:01:37 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
struct Data {
|
2019-01-21 13:42:21 +00:00
|
|
|
SingleQueuedInvokation HandleUnreadCounterUpdate = { [] { Core::App().call_handleUnreadCounterUpdate(); } };
|
|
|
|
SingleQueuedInvokation HandleDelayedPeerUpdates = { [] { Core::App().call_handleDelayedPeerUpdates(); } };
|
2016-02-18 16:36:33 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal;
|
|
|
|
Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal;
|
2016-04-11 10:59:01 +00:00
|
|
|
bool AdaptiveForWide = true;
|
2016-08-27 04:49:18 +00:00
|
|
|
base::Observable<void> AdaptiveChanged;
|
|
|
|
|
2020-02-07 09:43:12 +00:00
|
|
|
bool DialogsFiltersEnabled = false;
|
|
|
|
FilterId DialogsFilterId = 0;
|
2016-06-22 18:41:13 +00:00
|
|
|
bool ModerateModeEnabled = false;
|
2016-03-17 18:03:08 +00:00
|
|
|
|
2016-07-07 16:15:34 +00:00
|
|
|
bool ScreenIsLocked = false;
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
int32 DebugLoggingFlags = 0;
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
float64 RememberedSongVolume = kDefaultVolume;
|
2016-09-23 16:04:26 +00:00
|
|
|
float64 SongVolume = kDefaultVolume;
|
2016-10-12 19:34:25 +00:00
|
|
|
base::Observable<void> SongVolumeChanged;
|
2016-09-23 16:04:26 +00:00
|
|
|
float64 VideoVolume = kDefaultVolume;
|
2016-10-12 19:34:25 +00:00
|
|
|
base::Observable<void> VideoVolumeChanged;
|
2016-07-12 14:11:59 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
// config
|
|
|
|
int32 ChatSizeMax = 200;
|
2017-07-14 06:46:57 +00:00
|
|
|
int32 MegagroupSizeMax = 10000;
|
2016-04-11 10:59:01 +00:00
|
|
|
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 PushChatPeriod = 60000;
|
|
|
|
int32 PushChatLimit = 2;
|
|
|
|
int32 SavedGifsLimit = 200;
|
|
|
|
int32 EditTimeLimit = 172800;
|
2018-03-11 18:50:24 +00:00
|
|
|
int32 RevokeTimeLimit = 172800;
|
|
|
|
int32 RevokePrivateTimeLimit = 172800;
|
|
|
|
bool RevokePrivateInbox = false;
|
2016-07-18 15:39:10 +00:00
|
|
|
int32 StickersRecentLimit = 30;
|
2017-09-04 13:29:35 +00:00
|
|
|
int32 StickersFavedLimit = 5;
|
2016-12-13 07:59:57 +00:00
|
|
|
int32 PinnedDialogsCountMax = 5;
|
2019-04-19 08:47:49 +00:00
|
|
|
int32 PinnedDialogsInFolderMax = 100;
|
2017-03-10 17:25:43 +00:00
|
|
|
QString InternalLinksDomain = qsl("https://t.me/");
|
2017-11-20 19:54:05 +00:00
|
|
|
int32 ChannelsReadMediaPeriod = 86400 * 7;
|
2017-04-28 17:16:14 +00:00
|
|
|
int32 CallReceiveTimeoutMs = 20000;
|
|
|
|
int32 CallRingTimeoutMs = 90000;
|
|
|
|
int32 CallConnectTimeoutMs = 30000;
|
|
|
|
int32 CallPacketTimeoutMs = 10000;
|
2018-06-26 13:58:29 +00:00
|
|
|
int32 WebFileDcId = cTestMode() ? 2 : 4;
|
|
|
|
QString TxtDomainString = cTestMode()
|
2019-07-15 08:30:38 +00:00
|
|
|
? qsl("tapv3.stel.com")
|
|
|
|
: qsl("apv3.stel.com");
|
2017-04-28 17:16:14 +00:00
|
|
|
bool PhoneCallsEnabled = true;
|
2018-05-02 19:52:57 +00:00
|
|
|
bool BlockedMode = false;
|
2018-10-17 11:38:07 +00:00
|
|
|
int32 CaptionLengthMax = 1024;
|
2017-04-28 17:16:14 +00:00
|
|
|
base::Observable<void> PhoneCallsEnabledChanged;
|
2016-04-11 10:59:01 +00:00
|
|
|
|
|
|
|
HiddenPinnedMessagesMap HiddenPinnedMessages;
|
|
|
|
|
|
|
|
Stickers::Sets StickerSets;
|
|
|
|
Stickers::Order StickerSetsOrder;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time LastStickersUpdate = 0;
|
|
|
|
crl::time LastRecentStickersUpdate = 0;
|
|
|
|
crl::time LastFavedStickersUpdate = 0;
|
2016-06-27 16:25:21 +00:00
|
|
|
Stickers::Order FeaturedStickerSetsOrder;
|
2016-06-28 18:05:38 +00:00
|
|
|
int FeaturedStickerSetsUnreadCount = 0;
|
2016-11-22 09:48:13 +00:00
|
|
|
base::Observable<void> FeaturedStickerSetsUnreadCountChanged;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time LastFeaturedStickersUpdate = 0;
|
2016-07-21 13:57:31 +00:00
|
|
|
Stickers::Order ArchivedStickerSetsOrder;
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
bool AskDownloadPath = false;
|
|
|
|
QString DownloadPath;
|
|
|
|
QByteArray DownloadPathBookmark;
|
|
|
|
base::Observable<void> DownloadPathChanged;
|
|
|
|
|
2018-11-30 14:33:12 +00:00
|
|
|
bool VoiceMsgPlaybackDoubled = false;
|
2016-08-27 04:49:18 +00:00
|
|
|
bool SoundNotify = true;
|
|
|
|
bool DesktopNotify = true;
|
|
|
|
bool RestoreSoundNotifyFromTray = false;
|
|
|
|
DBINotifyView NotifyView = dbinvShowPreview;
|
2016-10-03 15:07:50 +00:00
|
|
|
bool NativeNotifications = false;
|
2016-10-06 16:41:09 +00:00
|
|
|
int NotificationsCount = 3;
|
|
|
|
Notify::ScreenCorner NotificationsCorner = Notify::ScreenCorner::BottomRight;
|
|
|
|
bool NotificationsDemoIsShown = false;
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2019-06-03 14:41:23 +00:00
|
|
|
bool TryIPv6 = !Platform::IsWindows();
|
2019-11-13 14:12:04 +00:00
|
|
|
std::vector<MTP::ProxyData> ProxiesList;
|
|
|
|
MTP::ProxyData SelectedProxy;
|
|
|
|
MTP::ProxyData::Settings ProxySettings = MTP::ProxyData::Settings::System;
|
2018-05-06 21:29:53 +00:00
|
|
|
bool UseProxyForCalls = false;
|
2016-08-27 04:49:18 +00:00
|
|
|
base::Observable<void> ConnectionTypeChanged;
|
2016-08-27 17:52:05 +00:00
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
int AutoLock = 3600;
|
|
|
|
bool LocalPasscode = false;
|
|
|
|
base::Observable<void> LocalPasscodeChanged;
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray };
|
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
base::Observable<void> UnreadCounterUpdate;
|
|
|
|
base::Observable<void> PeerChooseCancel;
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2019-01-05 11:08:02 +00:00
|
|
|
QString CallOutputDeviceID = qsl("default");
|
|
|
|
QString CallInputDeviceID = qsl("default");
|
|
|
|
int CallOutputVolume = 100;
|
|
|
|
int CallInputVolume = 100;
|
|
|
|
bool CallAudioDuckingEnabled = true;
|
2016-04-11 10:59:01 +00:00
|
|
|
};
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace Global
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
Global::internal::Data *GlobalData = nullptr;
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
namespace Global {
|
2016-03-19 16:55:15 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
bool started() {
|
|
|
|
return GlobalData != nullptr;
|
|
|
|
}
|
2016-03-19 16:55:15 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void start() {
|
|
|
|
GlobalData = new internal::Data();
|
2016-03-18 19:05:08 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void finish() {
|
|
|
|
delete GlobalData;
|
|
|
|
GlobalData = nullptr;
|
|
|
|
}
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2017-04-06 16:49:42 +00:00
|
|
|
DefineRefVar(Global, SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
|
|
|
DefineRefVar(Global, SingleQueuedInvokation, HandleDelayedPeerUpdates);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout);
|
|
|
|
DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout);
|
2016-04-11 10:59:01 +00:00
|
|
|
DefineVar(Global, bool, AdaptiveForWide);
|
2016-08-27 04:49:18 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, AdaptiveChanged);
|
|
|
|
|
2020-02-07 09:43:12 +00:00
|
|
|
DefineVar(Global, bool, DialogsFiltersEnabled);
|
|
|
|
DefineVar(Global, FilterId, DialogsFilterId);
|
2016-06-22 18:41:13 +00:00
|
|
|
DefineVar(Global, bool, ModerateModeEnabled);
|
2016-01-30 16:31:10 +00:00
|
|
|
|
2016-07-07 16:15:34 +00:00
|
|
|
DefineVar(Global, bool, ScreenIsLocked);
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
DefineVar(Global, int32, DebugLoggingFlags);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
DefineVar(Global, float64, RememberedSongVolume);
|
2016-07-12 14:11:59 +00:00
|
|
|
DefineVar(Global, float64, SongVolume);
|
2016-10-12 19:34:25 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, SongVolumeChanged);
|
2016-07-12 14:11:59 +00:00
|
|
|
DefineVar(Global, float64, VideoVolume);
|
2016-10-12 19:34:25 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, VideoVolumeChanged);
|
2016-07-12 14:11:59 +00:00
|
|
|
|
2016-04-11 10:59:01 +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, PushChatPeriod);
|
|
|
|
DefineVar(Global, int32, PushChatLimit);
|
|
|
|
DefineVar(Global, int32, SavedGifsLimit);
|
|
|
|
DefineVar(Global, int32, EditTimeLimit);
|
2018-03-11 18:50:24 +00:00
|
|
|
DefineVar(Global, int32, RevokeTimeLimit);
|
|
|
|
DefineVar(Global, int32, RevokePrivateTimeLimit);
|
|
|
|
DefineVar(Global, bool, RevokePrivateInbox);
|
2016-07-18 15:39:10 +00:00
|
|
|
DefineVar(Global, int32, StickersRecentLimit);
|
2017-08-02 15:07:28 +00:00
|
|
|
DefineVar(Global, int32, StickersFavedLimit);
|
2016-12-13 07:59:57 +00:00
|
|
|
DefineVar(Global, int32, PinnedDialogsCountMax);
|
2019-04-19 08:47:49 +00:00
|
|
|
DefineVar(Global, int32, PinnedDialogsInFolderMax);
|
2017-03-10 17:25:43 +00:00
|
|
|
DefineVar(Global, QString, InternalLinksDomain);
|
2017-11-20 19:54:05 +00:00
|
|
|
DefineVar(Global, int32, ChannelsReadMediaPeriod);
|
2017-04-28 17:16:14 +00:00
|
|
|
DefineVar(Global, int32, CallReceiveTimeoutMs);
|
|
|
|
DefineVar(Global, int32, CallRingTimeoutMs);
|
|
|
|
DefineVar(Global, int32, CallConnectTimeoutMs);
|
|
|
|
DefineVar(Global, int32, CallPacketTimeoutMs);
|
2018-06-26 13:58:29 +00:00
|
|
|
DefineVar(Global, int32, WebFileDcId);
|
|
|
|
DefineVar(Global, QString, TxtDomainString);
|
2017-04-28 17:16:14 +00:00
|
|
|
DefineVar(Global, bool, PhoneCallsEnabled);
|
2018-05-02 19:52:57 +00:00
|
|
|
DefineVar(Global, bool, BlockedMode);
|
2018-10-17 11:38:07 +00:00
|
|
|
DefineVar(Global, int32, CaptionLengthMax);
|
2017-04-28 17:16:14 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, PhoneCallsEnabledChanged);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
DefineVar(Global, Stickers::Sets, StickerSets);
|
|
|
|
DefineVar(Global, Stickers::Order, StickerSetsOrder);
|
2019-02-19 06:57:53 +00:00
|
|
|
DefineVar(Global, crl::time, LastStickersUpdate);
|
|
|
|
DefineVar(Global, crl::time, LastRecentStickersUpdate);
|
|
|
|
DefineVar(Global, crl::time, LastFavedStickersUpdate);
|
2016-06-27 16:25:21 +00:00
|
|
|
DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder);
|
2016-06-28 18:05:38 +00:00
|
|
|
DefineVar(Global, int, FeaturedStickerSetsUnreadCount);
|
2016-11-22 09:48:13 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, FeaturedStickerSetsUnreadCountChanged);
|
2019-02-19 06:57:53 +00:00
|
|
|
DefineVar(Global, crl::time, LastFeaturedStickersUpdate);
|
2016-07-21 13:57:31 +00:00
|
|
|
DefineVar(Global, Stickers::Order, ArchivedStickerSetsOrder);
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
DefineVar(Global, bool, AskDownloadPath);
|
|
|
|
DefineVar(Global, QString, DownloadPath);
|
|
|
|
DefineVar(Global, QByteArray, DownloadPathBookmark);
|
|
|
|
DefineRefVar(Global, base::Observable<void>, DownloadPathChanged);
|
|
|
|
|
2018-11-30 14:33:12 +00:00
|
|
|
DefineVar(Global, bool, VoiceMsgPlaybackDoubled);
|
2016-08-27 04:49:18 +00:00
|
|
|
DefineVar(Global, bool, SoundNotify);
|
|
|
|
DefineVar(Global, bool, DesktopNotify);
|
|
|
|
DefineVar(Global, bool, RestoreSoundNotifyFromTray);
|
|
|
|
DefineVar(Global, DBINotifyView, NotifyView);
|
2016-10-03 15:07:50 +00:00
|
|
|
DefineVar(Global, bool, NativeNotifications);
|
2016-10-06 16:41:09 +00:00
|
|
|
DefineVar(Global, int, NotificationsCount);
|
|
|
|
DefineVar(Global, Notify::ScreenCorner, NotificationsCorner);
|
|
|
|
DefineVar(Global, bool, NotificationsDemoIsShown);
|
2016-08-27 04:49:18 +00:00
|
|
|
|
|
|
|
DefineVar(Global, bool, TryIPv6);
|
2019-11-13 14:12:04 +00:00
|
|
|
DefineVar(Global, std::vector<MTP::ProxyData>, ProxiesList);
|
|
|
|
DefineVar(Global, MTP::ProxyData, SelectedProxy);
|
|
|
|
DefineVar(Global, MTP::ProxyData::Settings, ProxySettings);
|
2018-05-06 21:29:53 +00:00
|
|
|
DefineVar(Global, bool, UseProxyForCalls);
|
2016-08-27 04:49:18 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);
|
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
DefineVar(Global, int, AutoLock);
|
|
|
|
DefineVar(Global, bool, LocalPasscode);
|
|
|
|
DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged);
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
|
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
DefineRefVar(Global, base::Observable<void>, UnreadCounterUpdate);
|
|
|
|
DefineRefVar(Global, base::Observable<void>, PeerChooseCancel);
|
2019-01-18 12:27:37 +00:00
|
|
|
|
2019-01-05 11:08:02 +00:00
|
|
|
DefineVar(Global, QString, CallOutputDeviceID);
|
|
|
|
DefineVar(Global, QString, CallInputDeviceID);
|
|
|
|
DefineVar(Global, int, CallOutputVolume);
|
|
|
|
DefineVar(Global, int, CallInputVolume);
|
|
|
|
DefineVar(Global, bool, CallAudioDuckingEnabled);
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Global
|