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
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/type_traits.h"
|
|
|
|
#include "base/observer.h"
|
2019-09-26 10:55:35 +00:00
|
|
|
#include "base/call_delayed.h"
|
2019-11-13 14:12:04 +00:00
|
|
|
#include "mtproto/mtproto_proxy_data.h"
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
class History;
|
2016-10-14 18:27:42 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
namespace Data {
|
|
|
|
struct FileOrigin;
|
|
|
|
} // namespace Data
|
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
namespace InlineBots {
|
|
|
|
namespace Layout {
|
|
|
|
class ItemBase;
|
|
|
|
} // namespace Layout
|
|
|
|
} // namespace InlineBots
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace App {
|
2017-10-27 17:00:56 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
template <typename Guard, typename Lambda>
|
2019-08-16 17:07:30 +00:00
|
|
|
[[nodiscard]] inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
|
2018-06-04 15:35:11 +00:00
|
|
|
auto guarded = crl::guard(
|
|
|
|
std::forward<Guard>(object),
|
2017-10-27 17:00:56 +00:00
|
|
|
std::forward<Lambda>(lambda));
|
|
|
|
return [saved = std::move(guarded), duration] {
|
|
|
|
auto copy = saved;
|
2019-09-26 10:55:35 +00:00
|
|
|
base::call_delayed(duration, std::move(copy));
|
2017-10-27 17:00:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
void sendBotCommand(
|
|
|
|
PeerData *peer,
|
|
|
|
UserData *bot,
|
|
|
|
const QString &cmd,
|
|
|
|
MsgId replyTo = 0);
|
2017-03-27 18:11:51 +00:00
|
|
|
bool insertBotCommand(const QString &cmd);
|
2017-12-18 15:44:50 +00:00
|
|
|
void activateBotCommand(
|
|
|
|
not_null<const HistoryItem*> msg,
|
|
|
|
int row,
|
|
|
|
int column);
|
2016-04-11 10:59:01 +00:00
|
|
|
void searchByHashtag(const QString &tag, PeerData *inPeer);
|
|
|
|
void showSettings();
|
2016-03-31 14:06:40 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace App
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
namespace Ui {
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
// Legacy global methods.
|
2015-12-07 18:09:05 +00:00
|
|
|
|
2016-04-30 17:04:14 +00:00
|
|
|
void showPeerProfile(const PeerId &peer);
|
2019-01-04 11:09:48 +00:00
|
|
|
void showPeerProfile(const PeerData *peer);
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerProfile(not_null<const History*> history);
|
2016-04-30 17:04:14 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
void showPeerHistory(const PeerId &peer, MsgId msgId);
|
2018-01-11 19:33:26 +00:00
|
|
|
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
2017-09-20 10:23:57 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
void showPeerHistory(const PeerData *peer, MsgId msgId);
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerHistory(not_null<const History*> history, MsgId msgId);
|
2016-04-11 10:59:01 +00:00
|
|
|
inline void showChatsList() {
|
2017-10-03 13:05:58 +00:00
|
|
|
showPeerHistory(PeerId(0), 0);
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
|
|
|
PeerData *getPeerForMouseAction();
|
2015-12-12 22:29:33 +00:00
|
|
|
|
2016-05-12 16:05:20 +00:00
|
|
|
bool skipPaintEvent(QWidget *widget, QPaintEvent *event);
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Ui
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
enum ClipStopperType {
|
|
|
|
ClipStopperMediaview,
|
|
|
|
ClipStopperSavedGifsPanel,
|
|
|
|
};
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace Notify {
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void userIsBotChanged(UserData *user);
|
|
|
|
void botCommandsChanged(UserData *user);
|
2015-12-22 08:01:02 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
void inlineBotRequesting(bool requesting);
|
|
|
|
void replyMarkupUpdated(const HistoryItem *item);
|
|
|
|
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
2016-08-12 16:28:10 +00:00
|
|
|
bool switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot = nullptr, MsgId samePeerReplyTo = 0);
|
2016-01-01 09:58:05 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void unreadCounterUpdated();
|
2016-03-19 16:55:15 +00:00
|
|
|
|
2016-10-06 16:41:09 +00:00
|
|
|
enum class ScreenCorner {
|
|
|
|
TopLeft = 0,
|
|
|
|
TopRight = 1,
|
|
|
|
BottomRight = 2,
|
|
|
|
BottomLeft = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool IsLeftCorner(ScreenCorner corner) {
|
|
|
|
return (corner == ScreenCorner::TopLeft) || (corner == ScreenCorner::BottomLeft);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsTopCorner(ScreenCorner corner) {
|
|
|
|
return (corner == ScreenCorner::TopLeft) || (corner == ScreenCorner::TopRight);
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Notify
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
#define DeclareReadOnlyVar(Type, Name) const Type &Name();
|
|
|
|
#define DeclareRefVar(Type, Name) DeclareReadOnlyVar(Type, Name) \
|
|
|
|
Type &Ref##Name();
|
|
|
|
#define DeclareVar(Type, Name) DeclareRefVar(Type, Name) \
|
|
|
|
void Set##Name(const Type &Name);
|
|
|
|
|
|
|
|
namespace Adaptive {
|
2017-01-14 18:50:16 +00:00
|
|
|
|
|
|
|
enum class WindowLayout {
|
|
|
|
OneColumn,
|
|
|
|
Normal,
|
2017-09-16 16:53:41 +00:00
|
|
|
ThreeColumn,
|
2017-01-14 18:50:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class ChatLayout {
|
|
|
|
Normal,
|
|
|
|
Wide,
|
2016-02-08 14:54:55 +00:00
|
|
|
};
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Adaptive
|
2016-02-08 14:54:55 +00:00
|
|
|
|
2016-03-17 18:03:08 +00:00
|
|
|
namespace DebugLogging {
|
2016-04-11 10:59:01 +00:00
|
|
|
enum Flags {
|
|
|
|
FileLoaderFlag = 0x00000001,
|
|
|
|
};
|
|
|
|
} // namespace DebugLogging
|
2016-03-17 18:03:08 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
namespace Global {
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
bool started();
|
|
|
|
void start();
|
|
|
|
void finish();
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2017-04-06 16:49:42 +00:00
|
|
|
DeclareRefVar(SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
|
|
|
DeclareRefVar(SingleQueuedInvokation, HandleDelayedPeerUpdates);
|
2016-02-21 17:01:37 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
|
|
|
|
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
|
2016-04-11 10:59:01 +00:00
|
|
|
DeclareVar(bool, AdaptiveForWide);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, AdaptiveChanged);
|
|
|
|
|
2020-02-07 09:43:12 +00:00
|
|
|
DeclareVar(bool, DialogsFiltersEnabled);
|
2016-06-22 18:41:13 +00:00
|
|
|
DeclareVar(bool, ModerateModeEnabled);
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-07-07 16:15:34 +00:00
|
|
|
DeclareVar(bool, ScreenIsLocked);
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
DeclareVar(int32, DebugLoggingFlags);
|
2016-03-17 18:03:08 +00:00
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
constexpr float64 kDefaultVolume = 0.9;
|
|
|
|
|
|
|
|
DeclareVar(float64, RememberedSongVolume);
|
2016-07-12 14:11:59 +00:00
|
|
|
DeclareVar(float64, SongVolume);
|
2016-10-12 19:34:25 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, SongVolumeChanged);
|
2016-07-12 14:11:59 +00:00
|
|
|
DeclareVar(float64, VideoVolume);
|
2016-10-12 19:34:25 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, VideoVolumeChanged);
|
2016-07-12 14:11:59 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
// config
|
|
|
|
DeclareVar(int32, ChatSizeMax);
|
|
|
|
DeclareVar(int32, MegagroupSizeMax);
|
|
|
|
DeclareVar(int32, ForwardedCountMax);
|
|
|
|
DeclareVar(int32, OnlineUpdatePeriod);
|
|
|
|
DeclareVar(int32, OfflineBlurTimeout);
|
|
|
|
DeclareVar(int32, OfflineIdleTimeout);
|
|
|
|
DeclareVar(int32, OnlineFocusTimeout); // not from config
|
|
|
|
DeclareVar(int32, OnlineCloudTimeout);
|
|
|
|
DeclareVar(int32, NotifyCloudDelay);
|
|
|
|
DeclareVar(int32, NotifyDefaultDelay);
|
|
|
|
DeclareVar(int32, PushChatPeriod);
|
|
|
|
DeclareVar(int32, PushChatLimit);
|
|
|
|
DeclareVar(int32, SavedGifsLimit);
|
|
|
|
DeclareVar(int32, EditTimeLimit);
|
2018-03-11 18:50:24 +00:00
|
|
|
DeclareVar(int32, RevokeTimeLimit);
|
|
|
|
DeclareVar(int32, RevokePrivateTimeLimit);
|
|
|
|
DeclareVar(bool, RevokePrivateInbox);
|
2016-07-18 15:39:10 +00:00
|
|
|
DeclareVar(int32, StickersRecentLimit);
|
2017-08-02 15:07:28 +00:00
|
|
|
DeclareVar(int32, StickersFavedLimit);
|
2016-12-13 07:59:57 +00:00
|
|
|
DeclareVar(int32, PinnedDialogsCountMax);
|
2019-04-19 08:47:49 +00:00
|
|
|
DeclareVar(int32, PinnedDialogsInFolderMax);
|
2017-03-10 17:25:43 +00:00
|
|
|
DeclareVar(QString, InternalLinksDomain);
|
2017-11-20 19:54:05 +00:00
|
|
|
DeclareVar(int32, ChannelsReadMediaPeriod);
|
2017-04-28 17:16:14 +00:00
|
|
|
DeclareVar(int32, CallReceiveTimeoutMs);
|
|
|
|
DeclareVar(int32, CallRingTimeoutMs);
|
|
|
|
DeclareVar(int32, CallConnectTimeoutMs);
|
|
|
|
DeclareVar(int32, CallPacketTimeoutMs);
|
2018-06-26 13:58:29 +00:00
|
|
|
DeclareVar(int32, WebFileDcId);
|
|
|
|
DeclareVar(QString, TxtDomainString);
|
2017-04-28 17:16:14 +00:00
|
|
|
DeclareVar(bool, PhoneCallsEnabled);
|
2018-05-02 19:52:57 +00:00
|
|
|
DeclareVar(bool, BlockedMode);
|
2018-10-17 11:38:07 +00:00
|
|
|
DeclareVar(int32, CaptionLengthMax);
|
2017-04-28 17:16:14 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, PhoneCallsEnabledChanged);
|
2016-02-18 16:36:33 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
typedef QMap<PeerId, MsgId> HiddenPinnedMessagesMap;
|
|
|
|
DeclareVar(HiddenPinnedMessagesMap, HiddenPinnedMessages);
|
2016-03-10 10:15:21 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareVar(bool, AskDownloadPath);
|
|
|
|
DeclareVar(QString, DownloadPath);
|
|
|
|
DeclareVar(QByteArray, DownloadPathBookmark);
|
|
|
|
DeclareRefVar(base::Observable<void>, DownloadPathChanged);
|
|
|
|
|
2018-11-30 14:33:12 +00:00
|
|
|
DeclareVar(bool, VoiceMsgPlaybackDoubled);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareVar(bool, SoundNotify);
|
|
|
|
DeclareVar(bool, DesktopNotify);
|
2020-05-12 10:04:53 +00:00
|
|
|
DeclareVar(bool, FlashBounceNotify);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareVar(bool, RestoreSoundNotifyFromTray);
|
2020-05-12 10:04:53 +00:00
|
|
|
DeclareVar(bool, RestoreFlashBounceNotifyFromTray);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareVar(DBINotifyView, NotifyView);
|
2016-10-03 15:07:50 +00:00
|
|
|
DeclareVar(bool, NativeNotifications);
|
2016-10-06 16:41:09 +00:00
|
|
|
DeclareVar(int, NotificationsCount);
|
|
|
|
DeclareVar(Notify::ScreenCorner, NotificationsCorner);
|
|
|
|
DeclareVar(bool, NotificationsDemoIsShown);
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2018-05-06 21:29:53 +00:00
|
|
|
DeclareVar(bool, TryIPv6);
|
2019-11-13 14:12:04 +00:00
|
|
|
DeclareVar(std::vector<MTP::ProxyData>, ProxiesList);
|
|
|
|
DeclareVar(MTP::ProxyData, SelectedProxy);
|
|
|
|
DeclareVar(MTP::ProxyData::Settings, ProxySettings);
|
2018-05-06 21:29:53 +00:00
|
|
|
DeclareVar(bool, UseProxyForCalls);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
|
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
DeclareVar(int, AutoLock);
|
|
|
|
DeclareVar(bool, LocalPasscode);
|
|
|
|
DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, UnreadCounterUpdate);
|
|
|
|
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
|
2019-01-14 06:34:51 +00:00
|
|
|
|
2019-01-05 11:08:02 +00:00
|
|
|
DeclareVar(QString, CallOutputDeviceID);
|
|
|
|
DeclareVar(QString, CallInputDeviceID);
|
|
|
|
DeclareVar(int, CallOutputVolume);
|
|
|
|
DeclareVar(int, CallInputVolume);
|
|
|
|
DeclareVar(bool, CallAudioDuckingEnabled);
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Global
|
2016-02-08 14:54:55 +00:00
|
|
|
|
|
|
|
namespace Adaptive {
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
inline base::Observable<void> &Changed() {
|
|
|
|
return Global::RefAdaptiveChanged();
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
inline bool OneColumn() {
|
2017-01-14 18:50:16 +00:00
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::OneColumn;
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
inline bool Normal() {
|
2017-01-14 18:50:16 +00:00
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::Normal;
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
inline bool ThreeColumn() {
|
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::ThreeColumn;
|
|
|
|
}
|
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
inline bool ChatNormal() {
|
2017-09-16 16:53:41 +00:00
|
|
|
return !Global::AdaptiveForWide()
|
|
|
|
|| (Global::AdaptiveChatLayout() == ChatLayout::Normal);
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ChatWide() {
|
|
|
|
return !ChatNormal();
|
2016-02-08 14:54:55 +00:00
|
|
|
}
|
2016-03-17 18:03:08 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Adaptive
|
|
|
|
|
2016-03-17 18:03:08 +00:00
|
|
|
namespace DebugLogging {
|
2016-04-11 10:59:01 +00:00
|
|
|
|
|
|
|
inline bool FileLoader() {
|
2016-08-27 17:52:05 +00:00
|
|
|
return (Global::DebugLoggingFlags() & FileLoaderFlag) != 0;
|
2016-03-17 18:03:08 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
|
|
|
|
} // namespace DebugLogging
|