2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "pspecific.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
bool gTestMode = false;
|
|
|
|
bool gDebug = false;
|
|
|
|
bool gManyInstance = false;
|
|
|
|
QString gKeyFile;
|
2014-11-27 18:20:48 +00:00
|
|
|
QString gWorkingDir, gExeDir, gExeName;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
QStringList gSendPaths;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
QString gDialogLastPath, gDialogHelperPath; // optimize QFileDialog
|
|
|
|
|
|
|
|
bool gSoundNotify = true;
|
|
|
|
bool gDesktopNotify = true;
|
2014-07-18 10:37:34 +00:00
|
|
|
DBINotifyView gNotifyView = dbinvShowPreview;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gStartMinimized = false;
|
|
|
|
bool gAutoStart = false;
|
2014-07-18 10:37:34 +00:00
|
|
|
bool gSendToMenu = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gAutoUpdate = true;
|
|
|
|
TWindowPos gWindowPos;
|
|
|
|
bool gFromAutoStart = false;
|
|
|
|
DBIWorkMode gWorkMode = dbiwmWindowAndTray;
|
|
|
|
DBIConnectionType gConnectionType = dbictAuto;
|
|
|
|
ConnectionProxy gConnectionProxy;
|
|
|
|
bool gSeenTrayTooltip = false;
|
|
|
|
bool gRestartingUpdate = false, gRestarting = false;
|
|
|
|
int32 gLastUpdateCheck = 0;
|
|
|
|
bool gNoStartUpdate = false;
|
|
|
|
bool gStartToSettings = false;
|
|
|
|
int32 gMaxGroupCount = 200;
|
|
|
|
DBIDefaultAttach gDefaultAttach = dbidaDocument;
|
|
|
|
bool gReplaceEmojis = true;
|
|
|
|
bool gAskDownloadPath = false;
|
|
|
|
QString gDownloadPath;
|
|
|
|
|
|
|
|
bool gNeedConfigResave = false;
|
|
|
|
|
|
|
|
bool gCtrlEnter = false;
|
|
|
|
bool gCatsAndDogs = true;
|
|
|
|
|
|
|
|
uint32 gConnectionsInSession = 1;
|
|
|
|
QString gLoggedPhoneNumber;
|
|
|
|
|
|
|
|
QByteArray gLocalSalt;
|
|
|
|
DBIScale gRealScale = dbisAuto, gScreenScale = dbisOne, gConfigScale = dbisAuto;
|
2014-09-20 21:35:46 +00:00
|
|
|
bool gCompressPastedImage = true;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-10-17 12:57:14 +00:00
|
|
|
DBIEmojiTab gEmojiTab = dbietRecent;
|
2014-05-30 08:53:19 +00:00
|
|
|
RecentEmojiPack gRecentEmojis;
|
|
|
|
RecentEmojiPreload gRecentEmojisPreload;
|
|
|
|
|
|
|
|
QString gLangFile;
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
bool gRetina = false;
|
|
|
|
float64 gRetinaFactor = 1.;
|
2014-06-15 12:31:03 +00:00
|
|
|
int32 gIntRetinaFactor = 1;
|
2014-07-08 10:24:21 +00:00
|
|
|
#ifdef Q_OS_MAC
|
2014-06-14 19:32:11 +00:00
|
|
|
bool gCustomNotifies = false;
|
2014-07-08 10:24:21 +00:00
|
|
|
#else
|
|
|
|
bool gCustomNotifies = true;
|
|
|
|
#endif
|
2014-06-16 09:31:10 +00:00
|
|
|
uint64 gInstance = 0.;
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
DBIPlatform gPlatform = dbipWindows;
|
2014-06-25 07:25:55 +00:00
|
|
|
QUrl gUpdateURL = QUrl(qsl("http://tdesktop.com/win/tupdates/current"));
|
2014-06-14 19:32:11 +00:00
|
|
|
#elif defined Q_OS_MAC
|
|
|
|
DBIPlatform gPlatform = dbipMac;
|
2014-06-25 07:25:55 +00:00
|
|
|
QUrl gUpdateURL = QUrl(qsl("http://tdesktop.com/mac/tupdates/current"));
|
2014-07-17 09:42:06 +00:00
|
|
|
#elif defined Q_OS_LINUX32
|
|
|
|
DBIPlatform gPlatform = dbipLinux32;
|
|
|
|
QUrl gUpdateURL = QUrl(qsl("http://tdesktop.com/linux32/tupdates/current"));
|
|
|
|
#elif defined Q_OS_LINUX64
|
|
|
|
DBIPlatform gPlatform = dbipLinux64;
|
2014-06-25 07:25:55 +00:00
|
|
|
QUrl gUpdateURL = QUrl(qsl("http://tdesktop.com/linux/tupdates/current"));
|
2014-06-14 19:32:11 +00:00
|
|
|
#else
|
|
|
|
#error Unknown platform
|
|
|
|
#endif
|
|
|
|
|
2014-11-25 12:15:29 +00:00
|
|
|
bool gContactsReceived = false;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void settingsParseArgs(int argc, char *argv[]) {
|
2014-07-06 03:32:21 +00:00
|
|
|
if (cPlatform() == dbipMac) {
|
|
|
|
gCustomNotifies = false;
|
|
|
|
} else {
|
|
|
|
gCustomNotifies = true;
|
|
|
|
}
|
2014-06-16 09:31:10 +00:00
|
|
|
memset_rand(&gInstance, sizeof(gInstance));
|
2014-06-14 19:32:11 +00:00
|
|
|
gExeDir = psCurrentExeDirectory(argc, argv);
|
2014-11-27 18:20:48 +00:00
|
|
|
gExeName = psCurrentExeName(argc, argv);
|
2014-06-14 19:32:11 +00:00
|
|
|
for (int32 i = 0; i < argc; ++i) {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (string("-release") == argv[i]) {
|
|
|
|
gTestMode = false;
|
|
|
|
} else if (string("-debug") == argv[i]) {
|
|
|
|
gDebug = true;
|
|
|
|
} else if (string("-many") == argv[i]) {
|
|
|
|
gManyInstance = true;
|
|
|
|
} else if (string("-key") == argv[i] && i + 1 < argc) {
|
2014-07-18 10:37:34 +00:00
|
|
|
gKeyFile = QString::fromLocal8Bit(argv[++i]);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else if (string("-autostart") == argv[i]) {
|
|
|
|
gFromAutoStart = true;
|
|
|
|
} else if (string("-noupdate") == argv[i]) {
|
|
|
|
gNoStartUpdate = true;
|
|
|
|
} else if (string("-tosettings") == argv[i]) {
|
|
|
|
gStartToSettings = true;
|
|
|
|
} else if (string("-lang") == argv[i] && i + 1 < argc) {
|
2014-07-18 10:37:34 +00:00
|
|
|
gLangFile = QString(argv[++i]);
|
|
|
|
} else if (string("-sendpath") == argv[i] && i + 1 < argc) {
|
|
|
|
for (++i; i < argc; ++i) {
|
|
|
|
gSendPaths.push_back(QString::fromLocal8Bit(argv[i]));
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const RecentEmojiPack &cGetRecentEmojis() {
|
2014-10-17 12:57:14 +00:00
|
|
|
if (cRecentEmojis().isEmpty()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
RecentEmojiPack r;
|
2014-10-17 12:57:14 +00:00
|
|
|
if (!cRecentEmojisPreload().isEmpty()) {
|
|
|
|
RecentEmojiPreload p(cRecentEmojisPreload());
|
|
|
|
cSetRecentEmojisPreload(RecentEmojiPreload());
|
|
|
|
r.reserve(p.size());
|
|
|
|
for (RecentEmojiPreload::const_iterator i = p.cbegin(), e = p.cend(); i != e; ++i) {
|
2014-11-23 21:49:14 +00:00
|
|
|
uint32 code = ((i->first & 0xFFFFU) == 0xFE0FU) ? ((i->first >> 16) & 0xFFFFU) : i->first;
|
|
|
|
EmojiPtr ep(getEmoji(code));
|
|
|
|
if (!ep) continue;
|
|
|
|
|
|
|
|
if (ep->postfix) {
|
|
|
|
int32 j = 0, l = r.size();
|
|
|
|
for (; j < l; ++j) {
|
|
|
|
if (r[j].first->code == code) {
|
|
|
|
break;
|
2014-11-22 09:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-23 21:49:14 +00:00
|
|
|
if (j < l) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-17 12:57:14 +00:00
|
|
|
}
|
2014-11-23 21:49:14 +00:00
|
|
|
r.push_back(qMakePair(ep, i->second));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-17 12:57:14 +00:00
|
|
|
uint32 defaultRecent[] = {
|
2014-11-22 09:45:54 +00:00
|
|
|
0xD83DDE02U,
|
|
|
|
0xD83DDE18U,
|
2014-11-23 21:49:14 +00:00
|
|
|
0x2764U,
|
2014-11-22 09:45:54 +00:00
|
|
|
0xD83DDE0DU,
|
|
|
|
0xD83DDE0AU,
|
|
|
|
0xD83DDE01U,
|
|
|
|
0xD83DDC4DU,
|
2014-11-23 21:49:14 +00:00
|
|
|
0x263AU,
|
2014-11-22 09:45:54 +00:00
|
|
|
0xD83DDE14U,
|
|
|
|
0xD83DDE04U,
|
|
|
|
0xD83DDE2DU,
|
|
|
|
0xD83DDC8BU,
|
|
|
|
0xD83DDE12U,
|
|
|
|
0xD83DDE33U,
|
|
|
|
0xD83DDE1CU,
|
|
|
|
0xD83DDE48U,
|
|
|
|
0xD83DDE09U,
|
|
|
|
0xD83DDE03U,
|
|
|
|
0xD83DDE22U,
|
|
|
|
0xD83DDE1DU,
|
|
|
|
0xD83DDE31U,
|
|
|
|
0xD83DDE21U,
|
|
|
|
0xD83DDE0FU,
|
|
|
|
0xD83DDE1EU,
|
|
|
|
0xD83DDE05U,
|
|
|
|
0xD83DDE1AU,
|
|
|
|
0xD83DDE4AU,
|
|
|
|
0xD83DDE0CU,
|
|
|
|
0xD83DDE00U,
|
|
|
|
0xD83DDE0BU,
|
|
|
|
0xD83DDE06U,
|
|
|
|
0xD83DDC4CU,
|
|
|
|
0xD83DDE10U,
|
|
|
|
0xD83DDE15U,
|
2014-10-17 12:57:14 +00:00
|
|
|
};
|
|
|
|
for (int32 i = 0, s = sizeof(defaultRecent) / sizeof(defaultRecent[0]); i < s; ++i) {
|
|
|
|
if (r.size() >= EmojiPadPerRow * EmojiPadRowsPerPage) break;
|
|
|
|
|
|
|
|
EmojiPtr ep(getEmoji(defaultRecent[i]));
|
|
|
|
if (!ep) continue;
|
|
|
|
|
|
|
|
int32 j = 0, l = r.size();
|
|
|
|
for (; j < l; ++j) {
|
|
|
|
if (r[j].first == ep) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j < l) continue;
|
|
|
|
|
|
|
|
r.push_back(qMakePair(ep, 1));
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
cSetRecentEmojis(r);
|
|
|
|
}
|
|
|
|
return cRecentEmojis();
|
|
|
|
}
|