2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-04-27 12:02:17 +00:00
|
|
|
|
#include "core/version.h"
|
|
|
|
|
#include "settings.h"
|
2014-09-30 22:50:35 +00:00
|
|
|
|
|
2016-05-04 10:41:41 +00:00
|
|
|
|
constexpr str_const AppNameOld = "Telegram Win (Unofficial)";
|
|
|
|
|
constexpr str_const AppName = "Telegram Desktop";
|
2014-09-30 22:50:35 +00:00
|
|
|
|
|
2016-05-04 10:41:41 +00:00
|
|
|
|
constexpr str_const AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"; // used in updater.cpp and Setup.iss for Windows
|
|
|
|
|
constexpr str_const AppFile = "Telegram";
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
MaxSelectedItems = 100,
|
|
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
|
MaxPhoneCodeLength = 4, // max length of country phone code
|
2015-12-03 18:16:34 +00:00
|
|
|
|
MaxPhoneTailLength = 32, // rest of the phone number, without country code (seen 12 at least), need more for service numbers
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
|
|
MaxScrollSpeed = 37, // 37px per 15ms while select-by-drag
|
|
|
|
|
FingerAccuracyThreshold = 3, // touch flick ignore 3px
|
|
|
|
|
MaxScrollAccelerated = 4000, // 4000px per second
|
|
|
|
|
MaxScrollFlick = 2500, // 2500px per second
|
|
|
|
|
|
|
|
|
|
LocalEncryptIterCount = 4000, // key derivation iteration count
|
|
|
|
|
LocalEncryptNoPwdIterCount = 4, // key derivation iteration count without pwd (not secure anyway)
|
|
|
|
|
LocalEncryptSaltSize = 32, // 256 bit
|
|
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
|
AnimationTimerDelta = 7,
|
2015-12-30 08:36:04 +00:00
|
|
|
|
ClipThreadsCount = 8,
|
2015-12-16 13:35:15 +00:00
|
|
|
|
AverageGifSize = 320 * 240,
|
2015-12-16 14:39:26 +00:00
|
|
|
|
WaitBeforeGifPause = 200, // wait 200ms for gif draw before pausing it
|
2016-01-01 14:48:32 +00:00
|
|
|
|
RecentInlineBotsLimit = 10,
|
2014-07-04 11:12:54 +00:00
|
|
|
|
|
2015-12-17 17:31:28 +00:00
|
|
|
|
AVBlockSize = 4096, // 4Kb for ffmpeg blocksize
|
|
|
|
|
|
2014-07-13 09:50:38 +00:00
|
|
|
|
AutoSearchTimeout = 900, // 0.9 secs
|
2014-07-04 11:12:54 +00:00
|
|
|
|
SearchPerPage = 50,
|
2014-08-15 11:19:32 +00:00
|
|
|
|
SearchManyPerPage = 100,
|
2015-08-28 15:15:56 +00:00
|
|
|
|
LinksOverviewPerPage = 12,
|
2014-08-11 09:03:45 +00:00
|
|
|
|
MediaOverviewStartPerPage = 5,
|
2014-09-04 07:33:44 +00:00
|
|
|
|
|
2015-05-29 18:52:43 +00:00
|
|
|
|
AudioVoiceMsgMaxLength = 100 * 60, // 100 minutes
|
2014-09-04 07:33:44 +00:00
|
|
|
|
AudioVoiceMsgChannels = 2, // stereo
|
2015-01-05 20:17:33 +00:00
|
|
|
|
|
2015-01-10 13:08:30 +00:00
|
|
|
|
StickerMaxSize = 2048, // 2048x2048 is a max image size for sticker
|
2014-10-07 17:57:57 +00:00
|
|
|
|
|
|
|
|
|
MaxZoomLevel = 7, // x8
|
2014-12-15 15:55:45 +00:00
|
|
|
|
ZoomToScreenLevel = 1024, // just constant
|
2014-10-08 07:42:36 +00:00
|
|
|
|
|
|
|
|
|
PreloadHeightsCount = 3, // when 3 screens to scroll left make a preload request
|
2014-10-22 18:39:03 +00:00
|
|
|
|
|
|
|
|
|
SearchPeopleLimit = 5,
|
|
|
|
|
UsernameCheckTimeout = 200,
|
2014-11-05 17:43:32 +00:00
|
|
|
|
|
|
|
|
|
MaxMessageSize = 4096,
|
2014-11-22 09:45:04 +00:00
|
|
|
|
|
2015-04-04 20:01:34 +00:00
|
|
|
|
WebPageUserId = 701000,
|
2015-02-03 15:02:46 +00:00
|
|
|
|
|
2015-02-09 13:26:59 +00:00
|
|
|
|
UpdateDelayConstPart = 8 * 3600, // 8 hour min time between update check requests
|
|
|
|
|
UpdateDelayRandPart = 8 * 3600, // 8 hour max - min time between update check requests
|
2015-03-02 12:34:16 +00:00
|
|
|
|
|
|
|
|
|
WrongPasscodeTimeout = 1500,
|
2015-06-26 09:07:59 +00:00
|
|
|
|
|
|
|
|
|
ChoosePeerByDragTimeout = 1000, // 1 second mouse not moved to choose dialog when dragging a file
|
2014-05-30 08:53:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
inline const GUID &cGUID() {
|
2016-08-31 17:58:46 +00:00
|
|
|
|
#ifndef OS_MAC_STORE
|
2014-05-30 08:53:19 +00:00
|
|
|
|
static const GUID gGuid = { 0x87a94ab0, 0xe370, 0x4cde, { 0x98, 0xd3, 0xac, 0xc1, 0x10, 0xc5, 0x96, 0x7d } };
|
2016-08-31 17:58:46 +00:00
|
|
|
|
#else // OS_MAC_STORE
|
|
|
|
|
static const GUID gGuid = { 0xe51fb841, 0x8c0b, 0x4ef9, { 0x9e, 0x9e, 0x5a, 0x0, 0x78, 0x56, 0x76, 0x27 } };
|
|
|
|
|
#endif // OS_MAC_STORE
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
|
|
return gGuid;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
inline const char *cGUIDStr() {
|
2016-08-31 17:58:46 +00:00
|
|
|
|
#ifndef OS_MAC_STORE
|
2014-05-30 08:53:19 +00:00
|
|
|
|
static const char *gGuidStr = "{87A94AB0-E370-4cde-98D3-ACC110C5967D}";
|
2016-08-31 17:58:46 +00:00
|
|
|
|
#else // OS_MAC_STORE
|
|
|
|
|
static const char *gGuidStr = "{E51FB841-8C0B-4EF9-9E9E-5A0078567627}";
|
|
|
|
|
#endif // OS_MAC_STORE
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
|
|
return gGuidStr;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 18:49:43 +00:00
|
|
|
|
struct BuiltInDc {
|
|
|
|
|
int id;
|
|
|
|
|
const char *ip;
|
|
|
|
|
int port;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const BuiltInDc _builtInDcs[] = {
|
2014-11-25 20:33:11 +00:00
|
|
|
|
{ 1, "149.154.175.50", 443 },
|
|
|
|
|
{ 2, "149.154.167.51", 443 },
|
2015-02-10 12:46:38 +00:00
|
|
|
|
{ 3, "149.154.175.100", 443 },
|
2014-11-25 20:33:11 +00:00
|
|
|
|
{ 4, "149.154.167.91", 443 },
|
|
|
|
|
{ 5, "149.154.171.5", 443 }
|
2014-08-01 18:49:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-06-10 12:48:26 +00:00
|
|
|
|
static const BuiltInDc _builtInDcsIPv6[] = {
|
2018-04-25 09:24:48 +00:00
|
|
|
|
{ 1, "2001:0b28:f23d:f001:0000:0000:0000:000a", 443 },
|
|
|
|
|
{ 2, "2001:067c:04e8:f002:0000:0000:0000:000a", 443 },
|
|
|
|
|
{ 3, "2001:0b28:f23d:f003:0000:0000:0000:000a", 443 },
|
|
|
|
|
{ 4, "2001:067c:04e8:f004:0000:0000:0000:000a", 443 },
|
|
|
|
|
{ 5, "2001:0b28:f23f:f005:0000:0000:0000:000a", 443 }
|
2015-06-10 12:48:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2014-08-01 18:49:43 +00:00
|
|
|
|
static const BuiltInDc _builtInTestDcs[] = {
|
2015-01-23 15:24:36 +00:00
|
|
|
|
{ 1, "149.154.175.10", 443 },
|
2014-12-13 14:26:08 +00:00
|
|
|
|
{ 2, "149.154.167.40", 443 },
|
2015-06-10 12:48:26 +00:00
|
|
|
|
{ 3, "149.154.175.117", 443 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const BuiltInDc _builtInTestDcsIPv6[] = {
|
2018-04-25 09:24:48 +00:00
|
|
|
|
{ 1, "2001:0b28:f23d:f001:0000:0000:0000:000e", 443 },
|
|
|
|
|
{ 2, "2001:067c:04e8:f002:0000:0000:0000:000e", 443 },
|
|
|
|
|
{ 3, "2001:0b28:f23d:f003:0000:0000:0000:000e", 443 }
|
2014-08-01 18:49:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline const BuiltInDc *builtInDcs() {
|
|
|
|
|
return cTestMode() ? _builtInTestDcs : _builtInDcs;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 18:49:43 +00:00
|
|
|
|
inline int builtInDcsCount() {
|
|
|
|
|
return (cTestMode() ? sizeof(_builtInTestDcs) : sizeof(_builtInDcs)) / sizeof(BuiltInDc);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 12:48:26 +00:00
|
|
|
|
inline const BuiltInDc *builtInDcsIPv6() {
|
|
|
|
|
return cTestMode() ? _builtInTestDcsIPv6 : _builtInDcsIPv6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline int builtInDcsCountIPv6() {
|
|
|
|
|
return (cTestMode() ? sizeof(_builtInTestDcsIPv6) : sizeof(_builtInDcsIPv6)) / sizeof(BuiltInDc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
|
static const char *UpdatesPublicKey = "\
|
|
|
|
|
-----BEGIN RSA PUBLIC KEY-----\n\
|
|
|
|
|
MIGJAoGBAMA4ViQrjkPZ9xj0lrer3r23JvxOnrtE8nI69XLGSr+sRERz9YnUptnU\n\
|
|
|
|
|
BZpkIfKaRcl6XzNJiN28cVwO1Ui5JSa814UAiDHzWUqCaXUiUEQ6NmNTneiGx2sQ\n\
|
|
|
|
|
+9PKKlb8mmr3BB9A45ZNwLT6G9AK3+qkZLHojeSA+m84/a6GP4svAgMBAAE=\n\
|
|
|
|
|
-----END RSA PUBLIC KEY-----\
|
|
|
|
|
";
|
|
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
|
static const char *UpdatesPublicBetaKey = "\
|
2015-02-05 14:49:50 +00:00
|
|
|
|
-----BEGIN RSA PUBLIC KEY-----\n\
|
|
|
|
|
MIGJAoGBALWu9GGs0HED7KG7BM73CFZ6o0xufKBRQsdnq3lwA8nFQEvmdu+g/I1j\n\
|
|
|
|
|
0LQ+0IQO7GW4jAgzF/4+soPDb6uHQeNFrlVx1JS9DZGhhjZ5rf65yg11nTCIHZCG\n\
|
|
|
|
|
w/CVnbwQOw0g5GBwwFV3r0uTTvy44xx8XXxk+Qknu4eBCsmrAFNnAgMBAAE=\n\
|
|
|
|
|
-----END RSA PUBLIC KEY-----\
|
|
|
|
|
";
|
|
|
|
|
|
2018-11-04 10:29:30 +00:00
|
|
|
|
#if defined TDESKTOP_API_ID && defined TDESKTOP_API_HASH
|
|
|
|
|
|
|
|
|
|
#define TDESKTOP_API_HASH_TO_STRING_HELPER(V) #V
|
|
|
|
|
#define TDESKTOP_API_HASH_TO_STRING(V) TDESKTOP_API_HASH_TO_STRING_HELPER(V)
|
|
|
|
|
|
|
|
|
|
constexpr auto ApiId = TDESKTOP_API_ID;
|
|
|
|
|
constexpr auto ApiHash = TDESKTOP_API_HASH_TO_STRING(TDESKTOP_API_HASH);
|
|
|
|
|
|
|
|
|
|
#undef TDESKTOP_API_HASH_TO_STRING
|
|
|
|
|
#undef TDESKTOP_API_HASH_TO_STRING_HELPER
|
|
|
|
|
|
|
|
|
|
#else // TDESKTOP_API_ID && TDESKTOP_API_HASH
|
|
|
|
|
|
|
|
|
|
// To build your version of Telegram Desktop you're required to provide
|
|
|
|
|
// your own 'api_id' and 'api_hash' for the Telegram API access.
|
|
|
|
|
//
|
|
|
|
|
// How to obtain your 'api_id' and 'api_hash' is described here:
|
|
|
|
|
// https://core.telegram.org/api/obtaining_api_id
|
|
|
|
|
//
|
|
|
|
|
// If you're building the application not for deployment,
|
|
|
|
|
// but only for test purposes you can comment out the error below.
|
|
|
|
|
//
|
|
|
|
|
// This will allow you to use TEST ONLY 'api_id' and 'api_hash' which are
|
|
|
|
|
// very limited by the Telegram API server.
|
|
|
|
|
//
|
|
|
|
|
// Your users will start getting internal server errors on login
|
|
|
|
|
// if you deploy an app using those 'api_id' and 'api_hash'.
|
|
|
|
|
|
|
|
|
|
#error You are required to provide API_ID and API_HASH.
|
|
|
|
|
|
|
|
|
|
constexpr auto ApiId = 17349;
|
|
|
|
|
constexpr auto ApiHash = "344583e45741c457fe1862106095a5eb";
|
|
|
|
|
|
|
|
|
|
#endif // TDESKTOP_API_ID && TDESKTOP_API_HASH
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
2016-10-03 08:56:03 +00:00
|
|
|
|
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
|
|
|
|
#error "Only little endian is supported!"
|
|
|
|
|
#endif // Q_BYTE_ORDER == Q_BIG_ENDIAN
|
|
|
|
|
|
2018-11-08 05:50:18 +00:00
|
|
|
|
#if (TDESKTOP_ALPHA_VERSION != 0)
|
|
|
|
|
|
|
|
|
|
// Private key for downloading closed alphas.
|
|
|
|
|
#include "../../../TelegramPrivate/alpha_private.h"
|
2015-12-03 18:16:34 +00:00
|
|
|
|
|
|
|
|
|
#else
|
2018-09-26 14:58:09 +00:00
|
|
|
|
static const char *AlphaPrivateKey = "";
|
2015-12-03 18:16:34 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
|
extern QString gKeyFile;
|
|
|
|
|
inline const QString &cDataFile() {
|
|
|
|
|
if (!gKeyFile.isEmpty()) return gKeyFile;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
static const QString res(qsl("data"));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const QString &cTempDir() {
|
|
|
|
|
static const QString res = cWorkingDir() + qsl("tdata/tdld/");
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const QRegularExpression &cRussianLetters() {
|
|
|
|
|
static QRegularExpression regexp(QString::fromUtf8("[а-яА-ЯёЁ]"));
|
|
|
|
|
return regexp;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-08 14:08:54 +00:00
|
|
|
|
inline const QStringList &cImgExtensions() {
|
|
|
|
|
static QStringList result;
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
|
result.reserve(4);
|
|
|
|
|
result.push_back(qsl(".jpg"));
|
|
|
|
|
result.push_back(qsl(".jpeg"));
|
|
|
|
|
result.push_back(qsl(".png"));
|
|
|
|
|
result.push_back(qsl(".gif"));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|
2016-12-08 14:08:54 +00:00
|
|
|
|
return result;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-08 14:08:54 +00:00
|
|
|
|
inline const QStringList &cExtensionsForCompress() {
|
|
|
|
|
static QStringList result;
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
|
result.push_back(qsl(".jpg"));
|
|
|
|
|
result.push_back(qsl(".jpeg"));
|
|
|
|
|
result.push_back(qsl(".png"));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|
2016-12-08 14:08:54 +00:00
|
|
|
|
return result;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
}
|