1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "mtproto/mtproto_dc_options.h" 11 12 namespace MTP { 13 14 struct ConfigFields { 15 int chatSizeMax = 200; 16 int megagroupSizeMax = 10000; 17 int forwardedCountMax = 100; 18 int onlineUpdatePeriod = 120000; 19 int offlineBlurTimeout = 5000; 20 int offlineIdleTimeout = 30000; 21 int onlineFocusTimeout = 1000; // Not from the server config. 22 int onlineCloudTimeout = 300000; 23 int notifyCloudDelay = 30000; 24 int notifyDefaultDelay = 1500; 25 int savedGifsLimit = 200; 26 int editTimeLimit = 172800; 27 int revokeTimeLimit = 172800; 28 int revokePrivateTimeLimit = 172800; 29 bool revokePrivateInbox = false; 30 int stickersRecentLimit = 30; 31 int stickersFavedLimit = 5; 32 rpl::variable<int> pinnedDialogsCountMax = 5; 33 rpl::variable<int> pinnedDialogsInFolderMax = 100; 34 QString internalLinksDomain = u"https://t.me/"_q; 35 int channelsReadMediaPeriod = 86400 * 7; 36 int callReceiveTimeoutMs = 20000; 37 int callRingTimeoutMs = 90000; 38 int callConnectTimeoutMs = 30000; 39 int callPacketTimeoutMs = 10000; 40 int webFileDcId = 4; 41 QString txtDomainString; 42 rpl::variable<bool> phoneCallsEnabled = true; 43 bool blockedMode = false; 44 int captionLengthMax = 1024; 45 }; 46 47 class Config final { 48 struct PrivateTag { 49 }; 50 51 public: 52 explicit Config(Environment environment); 53 Config(const Config &other); 54 55 [[nodiscard]] QByteArray serialize() const; 56 [[nodiscard]] static std::unique_ptr<Config> FromSerialized( 57 const QByteArray &serialized); 58 dcOptions()59 [[nodiscard]] DcOptions &dcOptions() { 60 return _dcOptions; 61 } dcOptions()62 [[nodiscard]] const DcOptions &dcOptions() const { 63 return _dcOptions; 64 } environment()65 [[nodiscard]] MTP::Environment environment() const { 66 return _dcOptions.environment(); 67 } isTestMode()68 [[nodiscard]] bool isTestMode() const { 69 return _dcOptions.isTestMode(); 70 } 71 72 void apply(const MTPDconfig &data); 73 74 [[nodiscard]] const ConfigFields &values() const; 75 [[nodiscard]] rpl::producer<> updates() const; 76 77 // Set from legacy local stored values. 78 void setChatSizeMax(int value); 79 void setSavedGifsLimit(int value); 80 void setStickersRecentLimit(int value); 81 void setStickersFavedLimit(int value); 82 void setMegagroupSizeMax(int value); 83 void setTxtDomainString(const QString &value); 84 85 private: 86 DcOptions _dcOptions; 87 ConfigFields _fields; 88 89 rpl::event_stream<> _updates; 90 91 }; 92 93 } // namespace MTP