Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kirsan31 committed Oct 10, 2018
2 parents 91e391e + 1ec9137 commit 0dc8efb
Show file tree
Hide file tree
Showing 115 changed files with 3,218 additions and 726 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ environments.

## Pull upstream changes into your fork regularly

Telegram Desktop is advancing quickly. It is therefore critical that you pull upstream changes into your fork on a regular basis. Nothing is worse than putting in a days of hard work into a pull request only to have it rejected because it has diverged too far from upstram.
Telegram Desktop is advancing quickly. It is therefore critical that you pull upstream changes into your fork on a regular basis. Nothing is worse than putting in a days of hard work into a pull request only to have it rejected because it has diverged too far from upstream.

To pull in upstream changes:

Expand Down
Binary file added Telegram/Resources/icons/map_point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/map_point@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/menu_fix_order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/menu_fix_order@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/menu_reload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/menu_reload@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_option_location" = "Download path: {path}";
"lng_export_option_html" = "Human-readable HTML";
"lng_export_option_json" = "Machine-readable JSON";
"lng_export_limits" = "From: {from}, to: {till}";
"lng_export_beginning" = "the oldest message";
"lng_export_end" = "present";
"lng_export_from_beginning" = "Reset";
"lng_export_till_end" = "Reset";
"lng_export_start" = "Export";
"lng_export_state_initializing" = "Initializing...";
"lng_export_state_userpics" = "Profile pictures";
Expand Down
2 changes: 1 addition & 1 deletion Telegram/Resources/uwp/AppX/AppxManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="1.4.0.0" />
Version="1.4.2.0" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>
Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Telegram.rc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEVERSION 1,4,2,0
PRODUCTVERSION 1,4,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -52,10 +52,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop"
VALUE "FileVersion", "1.4.0.0"
VALUE "FileVersion", "1.4.2.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2018"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.4.0.0"
VALUE "ProductVersion", "1.4.2.0"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Updater.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEVERSION 1,4,2,0
PRODUCTVERSION 1,4,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop Updater"
VALUE "FileVersion", "1.4.0.0"
VALUE "FileVersion", "1.4.2.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2018"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.4.0.0"
VALUE "ProductVersion", "1.4.2.0"
END
END
BLOCK "VarFileInfo"
Expand Down
68 changes: 36 additions & 32 deletions Telegram/SourceFiles/_other/updater_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For license and copyright information please follow this link:
#include <pwd.h>
#include <string>
#include <deque>
#include <vector>
#include <cstring>
#include <cerrno>
#include <algorithm>
Expand All @@ -23,6 +24,7 @@ For license and copyright information please follow this link:

using std::string;
using std::deque;
using std::vector;
using std::cout;

bool do_mkdir(const char *path) { // from http://stackoverflow.com/questions/675039/how-can-i-create-directory-tree-in-c-linux
Expand Down Expand Up @@ -374,7 +376,7 @@ int main(int argc, char *argv[]) {
}
openLog();

writeLog("Updater started..");
writeLog("Updater started, new argments formatting..");
for (int i = 0; i < argc; ++i) {
writeLog("Argument: '%s'", argv[i]);
}
Expand Down Expand Up @@ -439,43 +441,45 @@ int main(int argc, char *argv[]) {
writeLog("Error: short exe name!");
}

static const int MaxLen = 65536, MaxArgsCount = 128;

char path[MaxLen] = {0};
string fullBinaryPath = exePath + exeName;
strcpy(path, fullBinaryPath.c_str());

char *args[MaxArgsCount] = { 0 };
char p_noupdate[] = "-noupdate";
char p_autostart[] = "-autostart";
char p_debug[] = "-debug";
char p_tosettings[] = "-tosettings";
char p_key[] = "-key";
char p_startintray[] = "-startintray";
char p_testmode[] = "-testmode";
char p_externalupdater[] = "-externalupdater";
char p_workdir[] = "-workdir";
int argIndex = 0;
args[argIndex++] = path;
args[argIndex++] = p_noupdate;
if (autostart) args[argIndex++] = p_autostart;
if (debug) args[argIndex++] = p_debug;
if (startintray) args[argIndex++] = p_startintray;
if (testmode) args[argIndex++] = p_testmode;
if (externalupdater) args[argIndex++] = p_externalupdater;
if (tosettings) args[argIndex++] = p_tosettings;
auto fullBinaryPath = exePath + exeName;
const auto path = fullBinaryPath.c_str();

auto values = vector<string>();
const auto push = [&](string arg) {
// Force null-terminated .data() call result.
values.push_back(arg + char(0));
};
push(path);
push("-noupdate");
if (autostart) push("-autostart");
if (debug) push("-debug");
if (startintray) push("-startintray");
if (testmode) push("-testmode");
if (externalupdater) push("-externalupdater");
if (tosettings) push("-tosettings");
if (key) {
args[argIndex++] = p_key;
args[argIndex++] = key;
push("-key");
push(key);
}
if (customWorkingDir && workdir) {
args[argIndex++] = p_workdir;
args[argIndex++] = workdir;
push("-workdir");
push(workdir);
}

auto args = vector<char*>();
for (auto &arg : values) {
args.push_back(arg.data());
}
args.push_back(nullptr);

pid_t pid = fork();
switch (pid) {
case -1: writeLog("fork() failed!"); return 1;
case 0: execv(path, args); return 1;
case -1:
writeLog("fork() failed!");
return 1;
case 0:
execv(path, args.data());
return 1;
}

writeLog("Executed Telegram, closing log and quitting..");
Expand Down
38 changes: 38 additions & 0 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,43 @@ void ApiWrap::requestDialogEntry(
}).send();
}

void ApiWrap::requestDialogEntries(
std::vector<not_null<History*>> histories) {
const auto already = [&](not_null<History*> history) {
const auto [i, ok] = _dialogRequests.try_emplace(history);
return !ok;
};
histories.erase(ranges::remove_if(histories, already), end(histories));
if (histories.empty()) {
return;
}
auto peers = QVector<MTPInputDialogPeer>();
peers.reserve(histories.size());
for (const auto history : histories) {
peers.push_back(MTP_inputDialogPeer(history->peer->input));
}
const auto finalize = [=](std::vector<not_null<History*>> histories) {
for (const auto history : histories) {
if (const auto callbacks = _dialogRequests.take(history)) {
for (const auto callback : *callbacks) {
callback();
}
}
}
};
request(MTPmessages_GetPeerDialogs(
MTP_vector(std::move(peers))
)).done([=](const MTPmessages_PeerDialogs &result) {
applyPeerDialogs(result);
for (const auto history : histories) {
historyDialogEntryApplied(history);
}
finalize(histories);
}).fail([=](const RPCError &error) {
finalize(histories);
}).send();
}

void ApiWrap::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) {
Expects(dialogs.type() == mtpc_messages_peerDialogs);

Expand Down Expand Up @@ -4313,6 +4350,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
options.replyTo = message.replyTo;
options.generateLocal = true;
options.webPageId = message.webPageId;
options.handleSupportSwitch = message.handleSupportSwitch;
sendAction(options);

if (!peer->canWrite()) {
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/apiwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
void requestDialogEntry(
not_null<History*> history,
Fn<void()> callback = nullptr);
void requestDialogEntries(std::vector<not_null<History*>> histories);
//void applyFeedSources(const MTPDchannels_feedSources &data); // #feed
//void setFeedChannels(
// not_null<Data::Feed*> feed,
Expand Down Expand Up @@ -262,6 +263,7 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
WebPageId webPageId = 0;
bool clearDraft = false;
bool generateLocal = true;
bool handleSupportSwitch = false;
};
rpl::producer<SendOptions> sendActions() const {
return _sendActions.events();
Expand Down Expand Up @@ -323,6 +325,7 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
MsgId replyTo = 0;
WebPageId webPageId = 0;
bool clearDraft = true;
bool handleSupportSwitch = false;
};
void sendMessage(MessageToSend &&message);
void sendInlineResult(
Expand Down
9 changes: 3 additions & 6 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,6 @@ namespace App {

void historyClearMsgs() {
::dependentItems.clear();

const auto oldData = base::take(msgsData);
const auto oldChannelData = base::take(channelMsgsData);
for (const auto item : oldData) {
Expand All @@ -1266,6 +1265,9 @@ namespace App {
delete item;
}
}
for (const auto data : base::take(::locationsData)) {
delete data;
}

clearMousedItems();
}
Expand Down Expand Up @@ -1589,11 +1591,6 @@ namespace App {
}
}

bool isValidPhone(QString phone) {
phone = phone.replace(QRegularExpression(qsl("[^\\d]")), QString());
return phone.length() >= 8 || phone == qsl("777") || phone == qsl("333") || phone == qsl("111") || (phone.startsWith(qsl("42")) && (phone.length() == 2 || phone.length() == 5 || phone == qsl("4242")));
}

void quit() {
if (quitting()) {
return;
Expand Down
2 changes: 0 additions & 2 deletions Telegram/SourceFiles/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ namespace App {

void checkImageCacheSize();

bool isValidPhone(QString phone);

enum LaunchState {
Launched = 0,
QuitRequested = 1,
Expand Down
49 changes: 47 additions & 2 deletions Telegram/SourceFiles/auth_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ For license and copyright information please follow this link:
#include "window/section_widget.h"
#include "chat_helpers/tabbed_selector.h"
#include "boxes/send_files_box.h"
#include "ui/widgets/input_fields.h"
#include "support/support_common.h"
#include "support/support_templates.h"
#include "observer_peer.h"

namespace {
Expand All @@ -35,7 +38,9 @@ AuthSessionSettings::Variables::Variables()
: sendFilesWay(SendFilesWay::Album)
, selectorTab(ChatHelpers::SelectorTab::Emoji)
, floatPlayerColumn(Window::Column::Second)
, floatPlayerCorner(RectPart::TopRight) {
, floatPlayerCorner(RectPart::TopRight)
, sendSubmitWay(Ui::InputSubmitSettings::Enter)
, supportSwitch(Support::SwitchSettings::None) {
}

QByteArray AuthSessionSettings::serialize() const {
Expand Down Expand Up @@ -74,6 +79,9 @@ QByteArray AuthSessionSettings::serialize() const {
stream << qint32(_variables.thirdSectionExtendedBy);
stream << qint32(_variables.sendFilesWay);
stream << qint32(_variables.callsPeerToPeer.current());
stream << qint32(_variables.sendSubmitWay);
stream << qint32(_variables.supportSwitch);
stream << qint32(_variables.supportFixChatsOrder ? 1 : 0);
}
return result;
}
Expand All @@ -100,6 +108,10 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
int thirdSectionExtendedBy = _variables.thirdSectionExtendedBy;
qint32 sendFilesWay = static_cast<qint32>(_variables.sendFilesWay);
qint32 callsPeerToPeer = qint32(_variables.callsPeerToPeer.current());
qint32 sendSubmitWay = static_cast<qint32>(_variables.sendSubmitWay);
qint32 supportSwitch = static_cast<qint32>(_variables.supportSwitch);
qint32 supportFixChatsOrder = _variables.supportFixChatsOrder ? 1 : 0;

stream >> selectorTab;
stream >> lastSeenWarningSeen;
if (!stream.atEnd()) {
Expand Down Expand Up @@ -154,6 +166,11 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
if (!stream.atEnd()) {
stream >> callsPeerToPeer;
}
if (!stream.atEnd()) {
stream >> sendSubmitWay;
stream >> supportSwitch;
stream >> supportFixChatsOrder;
}
if (stream.status() != QDataStream::Ok) {
LOG(("App Error: "
"Bad data for AuthSessionSettings::constructFromSerialized()"));
Expand Down Expand Up @@ -206,6 +223,20 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
case Calls::PeerToPeer::Contacts:
case Calls::PeerToPeer::Nobody: _variables.callsPeerToPeer = uncheckedCallsPeerToPeer; break;
}
auto uncheckedSendSubmitWay = static_cast<Ui::InputSubmitSettings>(
sendSubmitWay);
switch (uncheckedSendSubmitWay) {
case Ui::InputSubmitSettings::Enter:
case Ui::InputSubmitSettings::CtrlEnter: _variables.sendSubmitWay = uncheckedSendSubmitWay; break;
}
auto uncheckedSupportSwitch = static_cast<Support::SwitchSettings>(
supportSwitch);
switch (uncheckedSupportSwitch) {
case Support::SwitchSettings::None:
case Support::SwitchSettings::Next:
case Support::SwitchSettings::Previous: _variables.supportSwitch = uncheckedSupportSwitch; break;
}
_variables.supportFixChatsOrder = (supportFixChatsOrder ? 1 : 0);
}

void AuthSessionSettings::setTabbedSelectorSectionEnabled(bool enabled) {
Expand Down Expand Up @@ -292,7 +323,11 @@ AuthSession::AuthSession(const MTPUser &user)
, _storage(std::make_unique<Storage::Facade>())
, _notifications(std::make_unique<Window::Notifications::System>(this))
, _data(std::make_unique<Data::Session>(this))
, _changelogs(Core::Changelogs::Create(this)) {
, _changelogs(Core::Changelogs::Create(this))
, _supportTemplates(
(Support::ValidateAccount(user)
? std::make_unique<Support::Templates>(this)
: nullptr)) {
App::feedUser(user);

_saveDataTimer.setCallback([=] {
Expand Down Expand Up @@ -391,4 +426,14 @@ void AuthSession::checkAutoLockIn(TimeMs time) {
_autoLockTimer.callOnce(time);
}

bool AuthSession::supportMode() const {
return (_supportTemplates != nullptr);
}

not_null<Support::Templates*> AuthSession::supportTemplates() const {
Expects(supportMode());

return _supportTemplates.get();
}

AuthSession::~AuthSession() = default;
Loading

0 comments on commit 0dc8efb

Please sign in to comment.