| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  | This file is part of Telegram Desktop, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | the official desktop application for the Telegram messaging service. | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | For license and copyright information please follow this link: | 
					
						
							|  |  |  | https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-09-13 19:57:44 +03:00
										 |  |  | #include "facades.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-13 20:01:23 +03:00
										 |  |  | #include "info/info_memento.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-24 19:13:07 +03:00
										 |  |  | #include "core/click_handler_types.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-22 18:25:49 +03:00
										 |  |  | #include "media/media_clip_reader.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-15 20:34:41 +03:00
										 |  |  | #include "window/window_controller.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 19:44:50 +04:00
										 |  |  | #include "history/history_item_components.h"
 | 
					
						
							| 
									
										
										
										
											2016-06-01 23:05:37 +03:00
										 |  |  | #include "observer_peer.h"
 | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | #include "mainwindow.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | #include "mainwidget.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-07 17:02:24 +04:00
										 |  |  | #include "apiwrap.h"
 | 
					
						
							| 
									
										
										
										
											2017-02-23 13:59:19 +03:00
										 |  |  | #include "messenger.h"
 | 
					
						
							| 
									
										
										
										
											2017-06-22 02:54:38 +03:00
										 |  |  | #include "auth_session.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-06 17:38:10 +03:00
										 |  |  | #include "boxes/confirm_box.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-30 21:26:45 +03:00
										 |  |  | #include "window/layer_widget.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-13 11:27:10 +03:00
										 |  |  | #include "lang/lang_keys.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-06 17:38:10 +03:00
										 |  |  | #include "base/observer.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-13 15:45:11 +03:00
										 |  |  | #include "history/history.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-11 22:33:26 +03:00
										 |  |  | #include "history/history_item.h"
 | 
					
						
							| 
									
										
										
										
											2017-06-22 18:11:41 +03:00
										 |  |  | #include "history/history_media.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-09 14:02:51 +04:00
										 |  |  | #include "styles/style_history.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-04 13:22:53 +03:00
										 |  |  | #include "data/data_session.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-24 23:29:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | namespace App { | 
					
						
							| 
									
										
										
										
											2016-12-09 21:56:01 +03:00
										 |  |  | namespace internal { | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-04 18:35:11 +03:00
										 |  |  | void CallDelayed(int duration, FnMut<void()> &&lambda) { | 
					
						
							| 
									
										
										
										
											2017-08-03 15:06:29 +02:00
										 |  |  | 	Messenger::Instance().callDelayed(duration, std::move(lambda)); | 
					
						
							| 
									
										
										
										
											2016-12-02 22:16:35 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-09 21:56:01 +03:00
										 |  |  | } // namespace internal
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 22:24:42 +03:00
										 |  |  | void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { | 
					
						
							|  |  |  | 	if (auto m = main()) { | 
					
						
							|  |  |  | 		m->sendBotCommand(peer, bot, cmd, replyTo); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-29 20:17:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-20 15:54:07 +03:00
										 |  |  | void hideSingleUseKeyboard(const HistoryItem *msg) { | 
					
						
							|  |  |  | 	if (auto m = main()) { | 
					
						
							|  |  |  | 		m->hideSingleUseKeyboard(msg->history()->peer, msg->id); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-27 21:11:51 +03:00
										 |  |  | bool insertBotCommand(const QString &cmd) { | 
					
						
							| 
									
										
										
										
											2016-04-14 22:24:42 +03:00
										 |  |  | 	if (auto m = main()) { | 
					
						
							| 
									
										
										
										
											2017-03-27 21:11:51 +03:00
										 |  |  | 		return m->insertBotCommand(cmd); | 
					
						
							| 
									
										
										
										
											2016-04-14 22:24:42 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 19:44:50 +04:00
										 |  |  | void activateBotCommand( | 
					
						
							|  |  |  | 		not_null<const HistoryItem*> msg, | 
					
						
							|  |  |  | 		int row, | 
					
						
							|  |  |  | 		int column) { | 
					
						
							|  |  |  | 	const HistoryMessageMarkupButton *button = nullptr; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	if (auto markup = msg->Get<HistoryMessageReplyMarkup>()) { | 
					
						
							|  |  |  | 		if (row < markup->rows.size()) { | 
					
						
							| 
									
										
										
										
											2016-09-15 22:15:49 +03:00
										 |  |  | 			auto &buttonRow = markup->rows[row]; | 
					
						
							| 
									
										
										
										
											2017-12-18 19:44:50 +04:00
										 |  |  | 			if (column < buttonRow.size()) { | 
					
						
							|  |  |  | 				button = &buttonRow[column]; | 
					
						
							| 
									
										
										
										
											2016-04-06 21:02:22 +04:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (!button) return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 19:44:50 +04:00
										 |  |  | 	using ButtonType = HistoryMessageMarkupButton::Type; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	switch (button->type) { | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::Default: { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04: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 22:24:42 +03:00
										 |  |  | 		sendBotCommand(msg->history()->peer, msg->fromOriginal()->asUser(), QString(button->text), replyTo); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::Callback: | 
					
						
							|  |  |  | 	case ButtonType::Game: { | 
					
						
							| 
									
										
										
										
											2016-09-07 12:04:57 +03:00
										 |  |  | 		if (auto m = main()) { | 
					
						
							| 
									
										
										
										
											2017-12-18 19:44:50 +04:00
										 |  |  | 			m->app_sendBotCallback(button, msg, row, column); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:39:10 +03:00
										 |  |  | 	case ButtonType::Buy: { | 
					
						
							|  |  |  | 		Ui::show(Box<InformBox>(lang(lng_payments_not_supported))); | 
					
						
							|  |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::Url: { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		auto url = QString::fromUtf8(button->data); | 
					
						
							| 
									
										
										
										
											2016-12-20 16:03:51 +03:00
										 |  |  | 		auto skipConfirmation = false; | 
					
						
							|  |  |  | 		if (auto bot = msg->getMessageBot()) { | 
					
						
							|  |  |  | 			if (bot->isVerified()) { | 
					
						
							|  |  |  | 				skipConfirmation = true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (skipConfirmation) { | 
					
						
							| 
									
										
										
										
											2018-07-09 21:13:48 +03:00
										 |  |  | 			UrlClickHandler::Open(url); | 
					
						
							| 
									
										
										
										
											2016-12-20 16:03:51 +03:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-07-09 21:13:48 +03:00
										 |  |  | 			HiddenUrlClickHandler::Open(url); | 
					
						
							| 
									
										
										
										
											2016-12-20 16:03:51 +03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::RequestLocation: { | 
					
						
							| 
									
										
										
										
											2016-11-20 15:54:07 +03:00
										 |  |  | 		hideSingleUseKeyboard(msg); | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 		Ui::show(Box<InformBox>(lang(lng_bot_share_location_unavailable))); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::RequestPhone: { | 
					
						
							| 
									
										
										
										
											2016-11-20 15:54:07 +03:00
										 |  |  | 		hideSingleUseKeyboard(msg); | 
					
						
							| 
									
										
										
										
											2017-12-07 17:02:24 +04:00
										 |  |  | 		const auto msgId = msg->id; | 
					
						
							|  |  |  | 		const auto history = msg->history(); | 
					
						
							|  |  |  | 		Ui::show(Box<ConfirmBox>(lang(lng_bot_share_phone), lang(lng_bot_share_phone_confirm), [=] { | 
					
						
							|  |  |  | 			Ui::showPeerHistory(history, ShowAtTheEndMsgId); | 
					
						
							|  |  |  | 			auto options = ApiWrap::SendOptions(history); | 
					
						
							|  |  |  | 			options.replyTo = msgId; | 
					
						
							| 
									
										
										
										
											2018-09-11 15:50:40 +03:00
										 |  |  | 			Auth().api().shareContact(Auth().user(), options); | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 		})); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 	case ButtonType::SwitchInlineSame: | 
					
						
							|  |  |  | 	case ButtonType::SwitchInline: { | 
					
						
							| 
									
										
										
										
											2016-04-20 15:27:38 +03:00
										 |  |  | 		if (auto m = App::main()) { | 
					
						
							| 
									
										
										
										
											2016-09-19 13:18:21 +03:00
										 |  |  | 			if (auto bot = msg->getMessageBot()) { | 
					
						
							| 
									
										
										
										
											2016-08-12 19:28:10 +03:00
										 |  |  | 				auto tryFastSwitch = [bot, &button, msgId = msg->id]() -> bool { | 
					
						
							| 
									
										
										
										
											2016-09-02 12:11:23 -04:00
										 |  |  | 					auto samePeer = (button->type == ButtonType::SwitchInlineSame); | 
					
						
							| 
									
										
										
										
											2016-08-12 19:28:10 +03:00
										 |  |  | 					if (samePeer) { | 
					
						
							|  |  |  | 						Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data), bot, msgId); | 
					
						
							|  |  |  | 						return true; | 
					
						
							|  |  |  | 					} else if (bot->botInfo && bot->botInfo->inlineReturnPeerId) { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 						if (Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data))) { | 
					
						
							|  |  |  | 							return true; | 
					
						
							| 
									
										
										
										
											2016-04-11 00:59:07 +04:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 					return false; | 
					
						
							|  |  |  | 				}; | 
					
						
							|  |  |  | 				if (!tryFastSwitch()) { | 
					
						
							|  |  |  | 					m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data)); | 
					
						
							| 
									
										
										
										
											2016-04-08 18:16:52 +04:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-03-29 20:17:00 +03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} break; | 
					
						
							| 
									
										
										
										
											2016-03-28 15:51:22 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-28 15:51:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void searchByHashtag(const QString &tag, PeerData *inPeer) { | 
					
						
							| 
									
										
										
										
											2018-02-14 22:38:01 +03:00
										 |  |  | 	if (const auto m = main()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:21:48 +04:00
										 |  |  | 		Ui::hideSettingsAndLayer(); | 
					
						
							|  |  |  | 		Messenger::Instance().hideMediaView(); | 
					
						
							|  |  |  | 		if (inPeer && (!inPeer->isChannel() || inPeer->isMegagroup())) { | 
					
						
							|  |  |  | 			inPeer = nullptr; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-14 22:38:01 +03:00
										 |  |  | 		m->searchMessages( | 
					
						
							|  |  |  | 			tag + ' ', | 
					
						
							|  |  |  | 			(inPeer | 
					
						
							|  |  |  | 				? App::history(inPeer).get() | 
					
						
							| 
									
										
										
										
											2018-02-18 16:23:30 +03:00
										 |  |  | 				: Dialogs::Key())); | 
					
						
							| 
									
										
										
										
											2017-11-07 11:21:48 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void openPeerByName(const QString &username, MsgId msgId, const QString &startToken) { | 
					
						
							|  |  |  | 	if (MainWidget *m = main()) m->openPeerByName(username, msgId, startToken); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void joinGroupByHash(const QString &hash) { | 
					
						
							|  |  |  | 	if (MainWidget *m = main()) m->joinGroupByHash(hash); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void showSettings() { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = wnd()) { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		w->showSettings(); | 
					
						
							| 
									
										
										
										
											2016-02-16 14:21:39 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-16 14:21:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-09 21:13:48 +03:00
										 |  |  | void activateClickHandler(ClickHandlerPtr handler, ClickContext context) { | 
					
						
							|  |  |  | 	crl::on_main(wnd(), [=] { | 
					
						
							|  |  |  | 		handler->onClick(context); | 
					
						
							| 
									
										
										
										
											2018-01-11 22:33:26 +03:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-09 21:13:48 +03:00
										 |  |  | void activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) { | 
					
						
							|  |  |  | 	activateClickHandler(handler, ClickContext{ button }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace App
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | namespace Ui { | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | namespace internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | void showBox( | 
					
						
							|  |  |  | 		object_ptr<BoxContent> content, | 
					
						
							|  |  |  | 		LayerOptions options, | 
					
						
							|  |  |  | 		anim::type animated) { | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 		w->ui_showBox(std::move(content), options, animated); | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace internal
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 00:25:47 +03:00
										 |  |  | void showMediaPreview( | 
					
						
							|  |  |  | 		Data::FileOrigin origin, | 
					
						
							|  |  |  | 		not_null<DocumentData*> document) { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2018-07-14 00:25:47 +03:00
										 |  |  | 		w->ui_showMediaPreview(origin, document); | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 00:25:47 +03:00
										 |  |  | void showMediaPreview(Data::FileOrigin origin, not_null<PhotoData*> photo) { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2018-07-14 00:25:47 +03:00
										 |  |  | 		w->ui_showMediaPreview(origin, photo); | 
					
						
							| 
									
										
										
										
											2016-04-10 22:18:26 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-04-10 22:18:26 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void hideMediaPreview() { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		w->ui_hideMediaPreview(); | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | void hideLayer(anim::type animated) { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2017-09-15 20:34:41 +03:00
										 |  |  | 		w->ui_showBox( | 
					
						
							|  |  |  | 			{ nullptr }, | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 			LayerOption::CloseOther, | 
					
						
							|  |  |  | 			animated); | 
					
						
							| 
									
										
										
										
											2015-12-07 21:09:05 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 21:09:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | void hideSettingsAndLayer(anim::type animated) { | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	if (auto w = App::wnd()) { | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 		w->ui_hideSettingsAndLayer(animated); | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 21:09:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | bool isLayerShown() { | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	if (auto w = App::wnd()) return w->ui_isLayerShown(); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 21:09:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 20:04:14 +03:00
										 |  |  | void showPeerProfile(const PeerId &peer) { | 
					
						
							| 
									
										
										
										
											2017-10-03 14:05:58 +01:00
										 |  |  | 	if (auto window = App::wnd()) { | 
					
						
							|  |  |  | 		if (auto controller = window->controller()) { | 
					
						
							|  |  |  | 			controller->showPeerInfo(peer); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-05-19 15:03:51 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-13 15:45:11 +03:00
										 |  |  | void showPeerProfile(not_null<const History*> history) { | 
					
						
							|  |  |  | 	showPeerProfile(history->peer->id); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | void showPeerHistory( | 
					
						
							|  |  |  | 		const PeerId &peer, | 
					
						
							| 
									
										
										
										
											2017-10-03 14:05:58 +01:00
										 |  |  | 		MsgId msgId) { | 
					
						
							| 
									
										
										
										
											2017-09-26 14:49:16 +03:00
										 |  |  | 	auto ms = getms(); | 
					
						
							| 
									
										
										
										
											2017-10-03 14:05:58 +01:00
										 |  |  | 	if (auto m = App::main()) { | 
					
						
							| 
									
										
										
										
											2017-10-03 18:41:44 +01:00
										 |  |  | 		m->ui_showPeerHistory( | 
					
						
							|  |  |  | 			peer, | 
					
						
							|  |  |  | 			Window::SectionShow::Way::ClearStack, | 
					
						
							|  |  |  | 			msgId); | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-01-11 22:33:26 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void showPeerHistoryAtItem(not_null<const HistoryItem*> item) { | 
					
						
							|  |  |  | 	showPeerHistory(item->history()->peer->id, item->id); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-13 01:29:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-13 15:45:11 +03:00
										 |  |  | void showPeerHistory(not_null<const History*> history, MsgId msgId) { | 
					
						
							|  |  |  | 	showPeerHistory(history->peer->id, msgId); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | PeerData *getPeerForMouseAction() { | 
					
						
							| 
									
										
										
										
											2017-08-08 11:31:48 +02:00
										 |  |  | 	return Messenger::Instance().ui_getPeerForMouseAction(); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-29 20:17:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 19:05:20 +03:00
										 |  |  | bool skipPaintEvent(QWidget *widget, QPaintEvent *event) { | 
					
						
							|  |  |  | 	if (auto w = App::wnd()) { | 
					
						
							|  |  |  | 		if (w->contentOverlapped(widget, event)) { | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace Ui
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | namespace Notify { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void userIsBotChanged(UserData *user) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void botCommandsChanged(UserData *user) { | 
					
						
							| 
									
										
										
										
											2016-06-01 23:05:37 +03:00
										 |  |  | 	if (MainWidget *m = App::main()) { | 
					
						
							|  |  |  | 		m->notify_botCommandsChanged(user); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	peerUpdatedDelayed(user, PeerUpdate::Flag::BotCommandsChanged); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-07 16:05:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void inlineBotRequesting(bool requesting) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-01 17:58:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void replyMarkupUpdated(const HistoryItem *item) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) { | 
					
						
							|  |  |  | 		m->notify_replyMarkupUpdated(item); | 
					
						
							| 
									
										
										
										
											2016-04-01 19:32:26 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-04-01 19:32:26 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) { | 
					
						
							|  |  |  | 		m->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); | 
					
						
							| 
									
										
										
										
											2016-04-08 13:20:10 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-04-08 13:20:10 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-12 19:28:10 +03:00
										 |  |  | bool switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) { | 
					
						
							| 
									
										
										
										
											2017-05-22 18:25:49 +03:00
										 |  |  | 	if (auto main = App::main()) { | 
					
						
							|  |  |  | 		return main->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo); | 
					
						
							| 
									
										
										
										
											2016-04-08 18:16:52 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-04-08 18:16:52 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void migrateUpdated(PeerData *peer) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-11 21:11:38 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void historyMuteUpdated(History *history) { | 
					
						
							|  |  |  | 	if (MainWidget *m = App::main()) m->notify_historyMuteUpdated(history); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-19 19:55:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 22:24:42 +03:00
										 |  |  | void unreadCounterUpdated() { | 
					
						
							|  |  |  | 	Global::RefHandleUnreadCounterUpdate().call(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace Notify
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-08 17:54:55 +03:00
										 |  |  | #define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
 | 
					
						
							| 
									
										
										
										
											2017-08-17 12:06:26 +03:00
										 |  |  | 	AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::" #Name); \ | 
					
						
							| 
									
										
										
										
											2016-02-08 17:54:55 +03:00
										 |  |  | 	return Namespace##Data->Name; \ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \
 | 
					
						
							|  |  |  | Type &Ref##Name() { \ | 
					
						
							| 
									
										
										
										
											2017-08-17 12:06:26 +03:00
										 |  |  | 	AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name); \ | 
					
						
							| 
									
										
										
										
											2016-02-08 17:54:55 +03:00
										 |  |  | 	return Namespace##Data->Name; \ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \
 | 
					
						
							|  |  |  | void Set##Name(const Type &Name) { \ | 
					
						
							| 
									
										
										
										
											2017-08-17 12:06:26 +03:00
										 |  |  | 	AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Set" #Name); \ | 
					
						
							| 
									
										
										
										
											2016-02-08 17:54:55 +03:00
										 |  |  | 	Namespace##Data->Name = Name; \ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | namespace Sandbox { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | namespace internal { | 
					
						
							| 
									
										
										
										
											2016-01-21 14:58:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | struct Data { | 
					
						
							|  |  |  | 	QByteArray LastCrashDump; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 	ProxyData PreLaunchProxy; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace internal
 | 
					
						
							|  |  |  | } // namespace Sandbox
 | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 19:49:42 +03:00
										 |  |  | std::unique_ptr<Sandbox::internal::Data> SandboxData; | 
					
						
							| 
									
										
										
										
											2016-02-15 18:52:11 +03:00
										 |  |  | uint64 SandboxUserTag = 0; | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-08 17:54:55 +03:00
										 |  |  | namespace Sandbox { | 
					
						
							| 
									
										
										
										
											2016-01-09 19:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | bool MoveLegacyAlphaFolder(const QString &folder, const QString &file) { | 
					
						
							|  |  |  | 	const auto was = cExeDir() + folder; | 
					
						
							|  |  |  | 	const auto now = cExeDir() + qsl("TelegramForcePortable"); | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 	if (QDir(was).exists() && !QDir(now).exists()) { | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 		const auto oldFile = was + "/tdata/" + file; | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 		const auto newFile = was + "/tdata/alpha"; | 
					
						
							|  |  |  | 		if (QFile(oldFile).exists() && !QFile(newFile).exists()) { | 
					
						
							|  |  |  | 			if (!QFile(oldFile).copy(newFile)) { | 
					
						
							|  |  |  | 				LOG(("FATAL: Could not copy '%1' to '%2'" | 
					
						
							|  |  |  | 					).arg(oldFile | 
					
						
							|  |  |  | 					).arg(newFile)); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (!QDir().rename(was, now)) { | 
					
						
							|  |  |  | 			LOG(("FATAL: Could not rename '%1' to '%2'" | 
					
						
							|  |  |  | 				).arg(was | 
					
						
							|  |  |  | 				).arg(now)); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | bool MoveLegacyAlphaFolder() { | 
					
						
							|  |  |  | 	if (!MoveLegacyAlphaFolder(qsl("TelegramAlpha_data"), qsl("alpha")) | 
					
						
							|  |  |  | 		|| !MoveLegacyAlphaFolder(qsl("TelegramBeta_data"), qsl("beta"))) { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CheckPortableVersionDir() { | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 	if (!MoveLegacyAlphaFolder()) { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	const auto portable = cExeDir() + qsl("TelegramForcePortable"); | 
					
						
							|  |  |  | 	QFile key(portable + qsl("/tdata/alpha")); | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 	if (cAlphaVersion()) { | 
					
						
							| 
									
										
										
										
											2018-11-08 09:50:18 +04:00
										 |  |  | 		Assert(*AlphaPrivateKey != 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 		cForceWorkingDir(portable + '/'); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		QDir().mkpath(cWorkingDir() + qstr("tdata")); | 
					
						
							| 
									
										
										
										
											2018-11-08 09:50:18 +04:00
										 |  |  | 		cSetAlphaPrivateKey(QByteArray(AlphaPrivateKey)); | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 		if (!key.open(QIODevice::WriteOnly)) { | 
					
						
							| 
									
										
										
										
											2018-10-02 13:22:32 +03:00
										 |  |  | 			LOG(("FATAL: Could not open '%1' for writing private key!" | 
					
						
							|  |  |  | 				).arg(key.fileName())); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 		QDataStream dataStream(&key); | 
					
						
							|  |  |  | 		dataStream.setVersion(QDataStream::Qt_5_3); | 
					
						
							|  |  |  | 		dataStream << quint64(cRealAlphaVersion()) << cAlphaPrivateKey(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 	if (!QDir(portable).exists()) { | 
					
						
							| 
									
										
										
										
											2018-10-02 13:22:32 +03:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	cForceWorkingDir(portable + '/'); | 
					
						
							|  |  |  | 	if (!key.exists()) { | 
					
						
							| 
									
										
										
										
											2018-10-02 13:22:32 +03:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-09 19:21:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!key.open(QIODevice::ReadOnly)) { | 
					
						
							|  |  |  | 		LOG(("FATAL: could not open '%1' for reading private key. " | 
					
						
							|  |  |  | 			"Delete it or reinstall private alpha version." | 
					
						
							|  |  |  | 			).arg(key.fileName())); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	QDataStream dataStream(&key); | 
					
						
							|  |  |  | 	dataStream.setVersion(QDataStream::Qt_5_3); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	quint64 v; | 
					
						
							|  |  |  | 	QByteArray k; | 
					
						
							|  |  |  | 	dataStream >> v >> k; | 
					
						
							|  |  |  | 	if (dataStream.status() != QDataStream::Ok || k.isEmpty()) { | 
					
						
							|  |  |  | 		LOG(("FATAL: '%1' is corrupted. " | 
					
						
							|  |  |  | 			"Delete it or reinstall private alpha version." | 
					
						
							|  |  |  | 			).arg(key.fileName())); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	cSetAlphaVersion(AppVersion * 1000ULL); | 
					
						
							|  |  |  | 	cSetAlphaPrivateKey(k); | 
					
						
							|  |  |  | 	cSetRealAlphaVersion(v); | 
					
						
							|  |  |  | 	return true; | 
					
						
							| 
									
										
										
										
											2018-10-02 13:22:32 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 18:30:42 +03:00
										 |  |  | QString InstallBetaVersionsSettingPath() { | 
					
						
							|  |  |  | 	return cWorkingDir() + qsl("tdata/devversion"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WriteInstallBetaVersionsSetting() { | 
					
						
							|  |  |  | 	QFile f(InstallBetaVersionsSettingPath()); | 
					
						
							|  |  |  | 	if (f.open(QIODevice::WriteOnly)) { | 
					
						
							|  |  |  | 		f.write(cInstallBetaVersion() ? "1" : "0"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | QString DebugModeSettingPath() { | 
					
						
							|  |  |  | 	return cWorkingDir() + qsl("tdata/withdebug"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WriteDebugModeSetting() { | 
					
						
							|  |  |  | 	QFile f(DebugModeSettingPath()); | 
					
						
							|  |  |  | 	if (f.open(QIODevice::WriteOnly)) { | 
					
						
							|  |  |  | 		f.write(Logs::DebugEnabled() ? "1" : "0"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ComputeTestMode() { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	if (QFile(cWorkingDir() + qsl("tdata/withtestmode")).exists()) { | 
					
						
							|  |  |  | 		cSetTestMode(true); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ComputeDebugMode() { | 
					
						
							|  |  |  | 	Logs::SetDebugEnabled(cAlphaVersion() != 0); | 
					
						
							|  |  |  | 	const auto debugModeSettingPath = DebugModeSettingPath(); | 
					
						
							|  |  |  | 	if (QFile(debugModeSettingPath).exists()) { | 
					
						
							|  |  |  | 		QFile f(debugModeSettingPath); | 
					
						
							|  |  |  | 		if (f.open(QIODevice::ReadOnly)) { | 
					
						
							|  |  |  | 			Logs::SetDebugEnabled(f.read(1) != "0"); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ComputeInstallBetaVersions() { | 
					
						
							| 
									
										
										
										
											2018-09-26 18:30:42 +03:00
										 |  |  | 	const auto installBetaSettingPath = InstallBetaVersionsSettingPath(); | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 	if (cAlphaVersion()) { | 
					
						
							| 
									
										
										
										
											2018-09-26 18:11:16 +03:00
										 |  |  | 		cSetInstallBetaVersion(false); | 
					
						
							| 
									
										
										
										
											2018-09-26 18:30:42 +03:00
										 |  |  | 	} else if (QFile(installBetaSettingPath).exists()) { | 
					
						
							|  |  |  | 		QFile f(installBetaSettingPath); | 
					
						
							| 
									
										
										
										
											2018-09-26 18:11:16 +03:00
										 |  |  | 		if (f.open(QIODevice::ReadOnly)) { | 
					
						
							|  |  |  | 			cSetInstallBetaVersion(f.read(1) != "0"); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-09-26 17:58:09 +03:00
										 |  |  | 	} else if (AppBetaVersion) { | 
					
						
							| 
									
										
										
										
											2018-09-26 18:30:42 +03:00
										 |  |  | 		WriteInstallBetaVersionsSetting(); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-15 18:52:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | void ComputeUserTag() { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	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; | 
					
						
							| 
									
										
										
										
											2016-02-15 18:52:11 +03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		usertag.close(); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	if (!SandboxUserTag) { | 
					
						
							|  |  |  | 		do { | 
					
						
							|  |  |  | 			memsetrnd_bad(SandboxUserTag); | 
					
						
							|  |  |  | 		} while (!SandboxUserTag); | 
					
						
							| 
									
										
										
										
											2016-01-09 19:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 		if (usertag.open(QIODevice::WriteOnly)) { | 
					
						
							|  |  |  | 			usertag.write(reinterpret_cast<char*>(&SandboxUserTag), sizeof(uint64)); | 
					
						
							|  |  |  | 			usertag.close(); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-01-09 19:24:16 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-09 19:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:36:27 +03:00
										 |  |  | void WorkingDirReady() { | 
					
						
							|  |  |  | 	srand((int32)time(NULL)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ComputeTestMode(); | 
					
						
							|  |  |  | 	ComputeDebugMode(); | 
					
						
							|  |  |  | 	ComputeInstallBetaVersions(); | 
					
						
							|  |  |  | 	ComputeUserTag(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void start() { | 
					
						
							| 
									
										
										
										
											2017-04-06 19:49:42 +03:00
										 |  |  | 	SandboxData = std::make_unique<internal::Data>(); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-15 18:52:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-20 16:03:51 +03:00
										 |  |  | bool started() { | 
					
						
							|  |  |  | 	return (SandboxData != nullptr); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void finish() { | 
					
						
							| 
									
										
										
										
											2017-04-06 19:49:42 +03:00
										 |  |  | 	SandboxData.reset(); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | uint64 UserTag() { | 
					
						
							|  |  |  | 	return SandboxUserTag; | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Sandbox, QByteArray, LastCrashDump); | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | DefineVar(Sandbox, ProxyData, PreLaunchProxy); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace Sandbox
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | namespace Global { | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | namespace internal { | 
					
						
							| 
									
										
										
										
											2016-02-21 20:01:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | struct Data { | 
					
						
							| 
									
										
										
										
											2017-08-04 16:54:32 +02:00
										 |  |  | 	SingleQueuedInvokation HandleUnreadCounterUpdate = { [] { Messenger::Instance().call_handleUnreadCounterUpdate(); } }; | 
					
						
							|  |  |  | 	SingleQueuedInvokation HandleDelayedPeerUpdates = { [] { Messenger::Instance().call_handleDelayedPeerUpdates(); } }; | 
					
						
							|  |  |  | 	SingleQueuedInvokation HandleObservables = { [] { Messenger::Instance().call_handleObservables(); } }; | 
					
						
							| 
									
										
										
										
											2016-02-18 19:36:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 21:50:16 +03:00
										 |  |  | 	Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal; | 
					
						
							|  |  |  | 	Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	bool AdaptiveForWide = true; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 	base::Observable<void> AdaptiveChanged; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	bool DialogsModeEnabled = false; | 
					
						
							|  |  |  | 	Dialogs::Mode DialogsMode = Dialogs::Mode::All; | 
					
						
							| 
									
										
										
										
											2016-06-22 21:41:13 +03:00
										 |  |  | 	bool ModerateModeEnabled = false; | 
					
						
							| 
									
										
										
										
											2016-03-17 21:03:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-07 19:15:34 +03:00
										 |  |  | 	bool ScreenIsLocked = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	int32 DebugLoggingFlags = 0; | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | 	float64 RememberedSongVolume = kDefaultVolume; | 
					
						
							| 
									
										
										
										
											2016-09-23 19:04:26 +03:00
										 |  |  | 	float64 SongVolume = kDefaultVolume; | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | 	base::Observable<void> SongVolumeChanged; | 
					
						
							| 
									
										
										
										
											2016-09-23 19:04:26 +03:00
										 |  |  | 	float64 VideoVolume = kDefaultVolume; | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | 	base::Observable<void> VideoVolumeChanged; | 
					
						
							| 
									
										
										
										
											2016-07-12 17:11:59 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 	// config
 | 
					
						
							|  |  |  | 	int32 ChatSizeMax = 200; | 
					
						
							| 
									
										
										
										
											2017-07-14 09:46:57 +03:00
										 |  |  | 	int32 MegagroupSizeMax = 10000; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04: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 21:50:24 +03:00
										 |  |  | 	int32 RevokeTimeLimit = 172800; | 
					
						
							|  |  |  | 	int32 RevokePrivateTimeLimit = 172800; | 
					
						
							|  |  |  | 	bool RevokePrivateInbox = false; | 
					
						
							| 
									
										
										
										
											2016-07-18 18:39:10 +03:00
										 |  |  | 	int32 StickersRecentLimit = 30; | 
					
						
							| 
									
										
										
										
											2017-09-04 16:29:35 +03:00
										 |  |  | 	int32 StickersFavedLimit = 5; | 
					
						
							| 
									
										
										
										
											2016-12-13 10:59:57 +03:00
										 |  |  | 	int32 PinnedDialogsCountMax = 5; | 
					
						
							| 
									
										
										
										
											2017-03-10 20:25:43 +03:00
										 |  |  | 	QString InternalLinksDomain = qsl("https://t.me/"); | 
					
						
							| 
									
										
										
										
											2017-11-20 23:54:05 +04:00
										 |  |  | 	int32 ChannelsReadMediaPeriod = 86400 * 7; | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | 	int32 CallReceiveTimeoutMs = 20000; | 
					
						
							|  |  |  | 	int32 CallRingTimeoutMs = 90000; | 
					
						
							|  |  |  | 	int32 CallConnectTimeoutMs = 30000; | 
					
						
							|  |  |  | 	int32 CallPacketTimeoutMs = 10000; | 
					
						
							| 
									
										
										
										
											2018-06-26 14:58:29 +01:00
										 |  |  | 	int32 WebFileDcId = cTestMode() ? 2 : 4; | 
					
						
							|  |  |  | 	QString TxtDomainString = cTestMode() | 
					
						
							|  |  |  | 		? qsl("testapv2.stel.com") | 
					
						
							|  |  |  | 		: qsl("apv2.stel.com"); | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | 	bool PhoneCallsEnabled = true; | 
					
						
							| 
									
										
										
										
											2018-05-02 22:52:57 +03:00
										 |  |  | 	bool BlockedMode = false; | 
					
						
							| 
									
										
										
										
											2018-10-17 14:38:07 +03:00
										 |  |  | 	int32 CaptionLengthMax = 1024; | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | 	base::Observable<void> PhoneCallsEnabledChanged; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	HiddenPinnedMessagesMap HiddenPinnedMessages; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Stickers::Sets StickerSets; | 
					
						
							|  |  |  | 	Stickers::Order StickerSetsOrder; | 
					
						
							| 
									
										
										
										
											2016-12-01 22:20:33 +03:00
										 |  |  | 	TimeMs LastStickersUpdate = 0; | 
					
						
							|  |  |  | 	TimeMs LastRecentStickersUpdate = 0; | 
					
						
							| 
									
										
										
										
											2017-08-02 18:07:28 +03:00
										 |  |  | 	TimeMs LastFavedStickersUpdate = 0; | 
					
						
							| 
									
										
										
										
											2016-06-27 19:25:21 +03:00
										 |  |  | 	Stickers::Order FeaturedStickerSetsOrder; | 
					
						
							| 
									
										
										
										
											2016-06-28 21:05:38 +03:00
										 |  |  | 	int FeaturedStickerSetsUnreadCount = 0; | 
					
						
							| 
									
										
										
										
											2016-11-22 12:48:13 +03:00
										 |  |  | 	base::Observable<void> FeaturedStickerSetsUnreadCountChanged; | 
					
						
							| 
									
										
										
										
											2016-12-01 22:20:33 +03:00
										 |  |  | 	TimeMs LastFeaturedStickersUpdate = 0; | 
					
						
							| 
									
										
										
										
											2016-07-21 16:57:31 +03:00
										 |  |  | 	Stickers::Order ArchivedStickerSetsOrder; | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	CircleMasksMap CircleMasks; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bool AskDownloadPath = false; | 
					
						
							|  |  |  | 	QString DownloadPath; | 
					
						
							|  |  |  | 	QByteArray DownloadPathBookmark; | 
					
						
							|  |  |  | 	base::Observable<void> DownloadPathChanged; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-13 18:56:08 +03:00
										 |  |  | 	bool ReplaceEmoji = true; | 
					
						
							|  |  |  | 	bool SuggestEmoji = true; | 
					
						
							| 
									
										
										
										
											2018-03-19 20:32:33 +04:00
										 |  |  | 	bool SuggestStickersByEmoji = true; | 
					
						
							| 
									
										
										
										
											2018-05-13 18:56:08 +03:00
										 |  |  | 	base::Observable<void> ReplaceEmojiChanged; | 
					
						
							| 
									
										
										
										
											2018-11-08 17:06:22 +04:00
										 |  |  | 	float64 VoiceMsgPlaybackSpeed = 1.; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 	bool SoundNotify = true; | 
					
						
							|  |  |  | 	bool DesktopNotify = true; | 
					
						
							|  |  |  | 	bool RestoreSoundNotifyFromTray = false; | 
					
						
							|  |  |  | 	bool IncludeMuted = true; | 
					
						
							|  |  |  | 	DBINotifyView NotifyView = dbinvShowPreview; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:07:50 +03:00
										 |  |  | 	bool NativeNotifications = false; | 
					
						
							| 
									
										
										
										
											2016-10-06 19:41:09 +03:00
										 |  |  | 	int NotificationsCount = 3; | 
					
						
							|  |  |  | 	Notify::ScreenCorner NotificationsCorner = Notify::ScreenCorner::BottomRight; | 
					
						
							|  |  |  | 	bool NotificationsDemoIsShown = false; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bool TryIPv6 = (cPlatform() == dbipWindows) ? false : true; | 
					
						
							| 
									
										
										
										
											2018-04-27 21:26:45 +04:00
										 |  |  | 	std::vector<ProxyData> ProxiesList; | 
					
						
							|  |  |  | 	ProxyData SelectedProxy; | 
					
						
							| 
									
										
										
										
											2018-11-05 17:58:24 +04:00
										 |  |  | 	ProxyData::Settings ProxySettings = ProxyData::Settings::System; | 
					
						
							| 
									
										
										
										
											2018-05-07 00:29:53 +03:00
										 |  |  | 	bool UseProxyForCalls = false; | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 	base::Observable<void> ConnectionTypeChanged; | 
					
						
							| 
									
										
										
										
											2016-08-27 11:52:05 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-28 13:16:23 -06:00
										 |  |  | 	int AutoLock = 3600; | 
					
						
							|  |  |  | 	bool LocalPasscode = false; | 
					
						
							|  |  |  | 	base::Observable<void> LocalPasscodeChanged; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-04 22:36:59 +03:00
										 |  |  | 	base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-06 20:23:13 +03:00
										 |  |  | 	base::Observable<void> UnreadCounterUpdate; | 
					
						
							|  |  |  | 	base::Observable<void> PeerChooseCancel; | 
					
						
							| 
									
										
										
										
											2016-10-14 20:10:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace internal
 | 
					
						
							|  |  |  | } // namespace Global
 | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | Global::internal::Data *GlobalData = nullptr; | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | namespace Global { | 
					
						
							| 
									
										
										
										
											2016-03-19 19:55:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | bool started() { | 
					
						
							|  |  |  | 	return GlobalData != nullptr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-19 19:55:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void start() { | 
					
						
							|  |  |  | 	GlobalData = new internal::Data(); | 
					
						
							| 
									
										
										
										
											2016-03-18 22:05:08 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | void finish() { | 
					
						
							|  |  |  | 	delete GlobalData; | 
					
						
							|  |  |  | 	GlobalData = nullptr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 19:49:42 +03:00
										 |  |  | DefineRefVar(Global, SingleQueuedInvokation, HandleUnreadCounterUpdate); | 
					
						
							|  |  |  | DefineRefVar(Global, SingleQueuedInvokation, HandleDelayedPeerUpdates); | 
					
						
							|  |  |  | DefineRefVar(Global, SingleQueuedInvokation, HandleObservables); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 21:50:16 +03:00
										 |  |  | DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout); | 
					
						
							|  |  |  | DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout); | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Global, bool, AdaptiveForWide); | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, AdaptiveChanged); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Global, bool, DialogsModeEnabled); | 
					
						
							|  |  |  | DefineVar(Global, Dialogs::Mode, DialogsMode); | 
					
						
							| 
									
										
										
										
											2016-06-22 21:41:13 +03:00
										 |  |  | DefineVar(Global, bool, ModerateModeEnabled); | 
					
						
							| 
									
										
										
										
											2016-01-30 19:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-07 19:15:34 +03:00
										 |  |  | DefineVar(Global, bool, ScreenIsLocked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Global, int32, DebugLoggingFlags); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | DefineVar(Global, float64, RememberedSongVolume); | 
					
						
							| 
									
										
										
										
											2016-07-12 17:11:59 +03:00
										 |  |  | DefineVar(Global, float64, SongVolume); | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, SongVolumeChanged); | 
					
						
							| 
									
										
										
										
											2016-07-12 17:11:59 +03:00
										 |  |  | DefineVar(Global, float64, VideoVolume); | 
					
						
							| 
									
										
										
										
											2016-10-12 22:34:25 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, VideoVolumeChanged); | 
					
						
							| 
									
										
										
										
											2016-07-12 17:11:59 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04: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 21:50:24 +03:00
										 |  |  | DefineVar(Global, int32, RevokeTimeLimit); | 
					
						
							|  |  |  | DefineVar(Global, int32, RevokePrivateTimeLimit); | 
					
						
							|  |  |  | DefineVar(Global, bool, RevokePrivateInbox); | 
					
						
							| 
									
										
										
										
											2016-07-18 18:39:10 +03:00
										 |  |  | DefineVar(Global, int32, StickersRecentLimit); | 
					
						
							| 
									
										
										
										
											2017-08-02 18:07:28 +03:00
										 |  |  | DefineVar(Global, int32, StickersFavedLimit); | 
					
						
							| 
									
										
										
										
											2016-12-13 10:59:57 +03:00
										 |  |  | DefineVar(Global, int32, PinnedDialogsCountMax); | 
					
						
							| 
									
										
										
										
											2017-03-10 20:25:43 +03:00
										 |  |  | DefineVar(Global, QString, InternalLinksDomain); | 
					
						
							| 
									
										
										
										
											2017-11-20 23:54:05 +04:00
										 |  |  | DefineVar(Global, int32, ChannelsReadMediaPeriod); | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | DefineVar(Global, int32, CallReceiveTimeoutMs); | 
					
						
							|  |  |  | DefineVar(Global, int32, CallRingTimeoutMs); | 
					
						
							|  |  |  | DefineVar(Global, int32, CallConnectTimeoutMs); | 
					
						
							|  |  |  | DefineVar(Global, int32, CallPacketTimeoutMs); | 
					
						
							| 
									
										
										
										
											2018-06-26 14:58:29 +01:00
										 |  |  | DefineVar(Global, int32, WebFileDcId); | 
					
						
							|  |  |  | DefineVar(Global, QString, TxtDomainString); | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | DefineVar(Global, bool, PhoneCallsEnabled); | 
					
						
							| 
									
										
										
										
											2018-05-02 22:52:57 +03:00
										 |  |  | DefineVar(Global, bool, BlockedMode); | 
					
						
							| 
									
										
										
										
											2018-10-17 14:38:07 +03:00
										 |  |  | DefineVar(Global, int32, CaptionLengthMax); | 
					
						
							| 
									
										
										
										
											2017-04-28 20:16:14 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, PhoneCallsEnabledChanged); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages); | 
					
						
							| 
									
										
										
										
											2016-01-11 23:43:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineVar(Global, Stickers::Sets, StickerSets); | 
					
						
							|  |  |  | DefineVar(Global, Stickers::Order, StickerSetsOrder); | 
					
						
							| 
									
										
										
										
											2016-12-01 22:20:33 +03:00
										 |  |  | DefineVar(Global, TimeMs, LastStickersUpdate); | 
					
						
							|  |  |  | DefineVar(Global, TimeMs, LastRecentStickersUpdate); | 
					
						
							| 
									
										
										
										
											2017-08-02 18:07:28 +03:00
										 |  |  | DefineVar(Global, TimeMs, LastFavedStickersUpdate); | 
					
						
							| 
									
										
										
										
											2016-06-27 19:25:21 +03:00
										 |  |  | DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder); | 
					
						
							| 
									
										
										
										
											2016-06-28 21:05:38 +03:00
										 |  |  | DefineVar(Global, int, FeaturedStickerSetsUnreadCount); | 
					
						
							| 
									
										
										
										
											2016-11-22 12:48:13 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, FeaturedStickerSetsUnreadCountChanged); | 
					
						
							| 
									
										
										
										
											2016-12-01 22:20:33 +03:00
										 |  |  | DefineVar(Global, TimeMs, LastFeaturedStickersUpdate); | 
					
						
							| 
									
										
										
										
											2016-07-21 16:57:31 +03:00
										 |  |  | DefineVar(Global, Stickers::Order, ArchivedStickerSetsOrder); | 
					
						
							| 
									
										
										
										
											2016-01-09 19:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | DefineRefVar(Global, CircleMasksMap, CircleMasks); | 
					
						
							| 
									
										
										
										
											2016-03-18 13:18:30 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | DefineVar(Global, bool, AskDownloadPath); | 
					
						
							|  |  |  | DefineVar(Global, QString, DownloadPath); | 
					
						
							|  |  |  | DefineVar(Global, QByteArray, DownloadPathBookmark); | 
					
						
							|  |  |  | DefineRefVar(Global, base::Observable<void>, DownloadPathChanged); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-13 18:56:08 +03:00
										 |  |  | DefineVar(Global, bool, ReplaceEmoji); | 
					
						
							|  |  |  | DefineVar(Global, bool, SuggestEmoji); | 
					
						
							| 
									
										
										
										
											2018-03-19 20:32:33 +04:00
										 |  |  | DefineVar(Global, bool, SuggestStickersByEmoji); | 
					
						
							| 
									
										
										
										
											2018-05-13 18:56:08 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, ReplaceEmojiChanged); | 
					
						
							| 
									
										
										
										
											2018-11-08 17:06:22 +04:00
										 |  |  | DefineVar(Global, float64, VoiceMsgPlaybackSpeed); | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | DefineVar(Global, bool, SoundNotify); | 
					
						
							|  |  |  | DefineVar(Global, bool, DesktopNotify); | 
					
						
							|  |  |  | DefineVar(Global, bool, RestoreSoundNotifyFromTray); | 
					
						
							|  |  |  | DefineVar(Global, bool, IncludeMuted); | 
					
						
							|  |  |  | DefineVar(Global, DBINotifyView, NotifyView); | 
					
						
							| 
									
										
										
										
											2016-10-03 18:07:50 +03:00
										 |  |  | DefineVar(Global, bool, NativeNotifications); | 
					
						
							| 
									
										
										
										
											2016-10-06 19:41:09 +03:00
										 |  |  | DefineVar(Global, int, NotificationsCount); | 
					
						
							|  |  |  | DefineVar(Global, Notify::ScreenCorner, NotificationsCorner); | 
					
						
							|  |  |  | DefineVar(Global, bool, NotificationsDemoIsShown); | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | DefineVar(Global, bool, TryIPv6); | 
					
						
							| 
									
										
										
										
											2018-04-27 21:26:45 +04:00
										 |  |  | DefineVar(Global, std::vector<ProxyData>, ProxiesList); | 
					
						
							|  |  |  | DefineVar(Global, ProxyData, SelectedProxy); | 
					
						
							| 
									
										
										
										
											2018-11-05 17:58:24 +04:00
										 |  |  | DefineVar(Global, ProxyData::Settings, ProxySettings); | 
					
						
							| 
									
										
										
										
											2018-05-07 00:29:53 +03:00
										 |  |  | DefineVar(Global, bool, UseProxyForCalls); | 
					
						
							| 
									
										
										
										
											2016-08-26 22:49:18 -06:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-28 13:16:23 -06:00
										 |  |  | DefineVar(Global, int, AutoLock); | 
					
						
							|  |  |  | DefineVar(Global, bool, LocalPasscode); | 
					
						
							|  |  |  | DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-04 22:36:59 +03:00
										 |  |  | DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-06 20:23:13 +03:00
										 |  |  | DefineRefVar(Global, base::Observable<void>, UnreadCounterUpdate); | 
					
						
							|  |  |  | DefineRefVar(Global, base::Observable<void>, PeerChooseCancel); | 
					
						
							| 
									
										
										
										
											2016-10-14 20:10:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 16:03:21 +03:00
										 |  |  | rpl::producer<bool> ReplaceEmojiValue() { | 
					
						
							|  |  |  | 	return rpl::single( | 
					
						
							|  |  |  | 		Global::ReplaceEmoji() | 
					
						
							|  |  |  | 	) | rpl::then(base::ObservableViewer( | 
					
						
							|  |  |  | 		Global::RefReplaceEmojiChanged() | 
					
						
							|  |  |  | 	) | rpl::map([] { | 
					
						
							|  |  |  | 		return Global::ReplaceEmoji(); | 
					
						
							|  |  |  | 	})); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 14:59:01 +04:00
										 |  |  | } // namespace Global
 |