Compare commits

..

7 Commits

Author SHA1 Message Date
John Preston
be2abd594f Alpha version 1.3.4.
- Bug fixes and other minor improvements.
2018-06-07 22:29:27 +03:00
John Preston
75a40b83ae Notify settings unknown => draw chats as muted.
Also request common notify settings at the app launch.
2018-06-07 22:28:09 +03:00
John Preston
472a677bca Fix crash in special scan upload. 2018-06-07 22:11:55 +03:00
John Preston
dca6e10beb Fix markdown apply to text with emoji. 2018-06-07 22:00:46 +03:00
John Preston
122ab94f3d Fix text color glitch after palette update.
Once again fixes #4774.
2018-06-07 21:25:10 +03:00
John Preston
2ab40de8b9 Alpha version 1.3.3.
- Bug fixes and other minor improvements.
2018-06-07 10:50:34 +03:00
John Preston
35659536c5 Fix first passcode unlock.
Fixes #4811.
2018-06-07 10:44:38 +03:00
20 changed files with 176 additions and 121 deletions

View File

@@ -1643,7 +1643,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_passport_delete_email_sure" = "Are you sure you want to delete your email address?";
"lng_passport_delete_phone" = "Delete phone number";
"lng_passport_delete_phone_sure" = "Are you sure you want to delete your phone number?";
"lng_passport_success" = "Authorization successfull!";
"lng_passport_success" = "Authorization successful!";
"lng_passport_stop_sure" = "Are you sure you want to stop this authorization?";
"lng_passport_stop" = "Stop";
"lng_passport_restart_sure" = "An unexpected error has occurred. Perhaps some changes were made from a different Telegram application. Would you like to restart this authorization?";

View File

@@ -9,7 +9,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="1.3.2.0" />
Version="1.3.4.0" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>

View File

@@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,2,0
PRODUCTVERSION 1,3,2,0
FILEVERSION 1,3,4,0
PRODUCTVERSION 1,3,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -52,10 +52,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop"
VALUE "FileVersion", "1.3.2.0"
VALUE "FileVersion", "1.3.4.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2018"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.3.2.0"
VALUE "ProductVersion", "1.3.4.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,2,0
PRODUCTVERSION 1,3,2,0
FILEVERSION 1,3,4,0
PRODUCTVERSION 1,3,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop Updater"
VALUE "FileVersion", "1.3.2.0"
VALUE "FileVersion", "1.3.4.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2018"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.3.2.0"
VALUE "ProductVersion", "1.3.4.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -417,8 +417,9 @@ public:
if (range.first == range.second) {
return 0;
}
const auto result = (range.second - range.first);
impl().erase(range.first, range.second);
return (range.second - range.first);
return result;
}
iterator erase(const_iterator where) {

View File

@@ -297,8 +297,9 @@ public:
if (range.first == range.second) {
return 0;
}
const auto result = (range.second - range.first);
impl().erase(range.first, range.second);
return (range.second - range.first);
return result;
}
iterator erase(const_iterator where) {

View File

@@ -609,19 +609,21 @@ void MessageLinksParser::parse() {
const auto markdownTagsEnd = markdownTags.end();
const auto markdownTagsAllow = [&](int from, int length) {
while (markdownTag != markdownTagsEnd
&& (markdownTag->start + markdownTag->length <= from
&& (markdownTag->adjustedStart
+ markdownTag->adjustedLength <= from
|| !markdownTag->closed)) {
++markdownTag;
continue;
}
if (markdownTag == markdownTagsEnd
|| markdownTag->start >= from + length) {
|| markdownTag->adjustedStart >= from + length) {
return true;
}
// Ignore http-links that are completely inside some tags.
// This will allow sending http://test.com/__test__/test correctly.
return (markdownTag->start > from
|| markdownTag->start + markdownTag->length < from + length);
return (markdownTag->adjustedStart > from)
|| (markdownTag->adjustedStart
+ markdownTag->adjustedLength < from + length);
};
const auto len = text.size();

View File

@@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 1003002;
constexpr str_const AppVersionStr = "1.3.2";
constexpr int AppVersion = 1003004;
constexpr str_const AppVersionStr = "1.3.4";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View File

@@ -1741,7 +1741,7 @@ bool Session::notifyIsMuted(
if (const auto until = settings.muteUntil()) {
return resultFromUntil(*until);
}
return false;
return true;
}
bool Session::notifySilentPosts(not_null<const PeerData*> peer) const {

View File

@@ -2198,9 +2198,6 @@ void History::applyDialog(const MTPDdialog &data) {
MTP_notifyPeer(data.vpeer),
data.vnotify_settings);
// Request default notification settings for this type of chat.
Auth().data().requestNotifySettings(peer);
if (data.has_draft() && data.vdraft.type() == mtpc_draftMessage) {
Data::applyPeerCloudDraft(peer->id, data.vdraft.c_draftMessage());
}

View File

@@ -3700,6 +3700,9 @@ void MainWidget::mtpPing() {
}
void MainWidget::start(const MTPUser *self) {
Auth().api().requestNotifySettings(MTP_inputNotifyUsers());
Auth().api().requestNotifySettings(MTP_inputNotifyChats());
if (!self) {
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
return;
@@ -3713,7 +3716,7 @@ void MainWidget::start(const MTPUser *self) {
Local::readSavedPeers();
cSetOtherOnline(0);
if (auto user = App::feedUsers(MTP_vector<MTPUser>(1, *self))) {
if (const auto user = App::feedUsers(MTP_vector<MTPUser>(1, *self))) {
user->loadUserpic();
}

View File

@@ -128,9 +128,11 @@ void MainWindow::firstShow() {
}
void MainWindow::clearWidgetsHook() {
Expects(_passcodeLock == nullptr || !Global::LocalPasscode());
auto wasMain = (_main != nullptr);
_passcodeLock.destroy();
_main.destroy();
_passcodeLock.destroy();
_intro.destroy();
if (wasMain) {
App::clearHistories();
@@ -177,18 +179,20 @@ void MainWindow::clearPasscodeLock() {
_passcodeLock.destroy();
if (_intro) {
_intro->showAnimated(bg, true);
} else {
Assert(_main != nullptr);
} else if (_main) {
_main->showAnimated(bg, true);
Messenger::Instance().checkStartUrl();
} else {
Messenger::Instance().startMtp();
if (AuthSession::Exists()) {
setupMain();
} else {
setupIntro();
}
}
}
void MainWindow::setupIntro() {
if (_intro && !_intro->isHidden() && !_main) {
return;
}
Ui::hideSettingsAndLayer(anim::type::instant);
auto animated = (_main || _passcodeLock);
@@ -273,13 +277,13 @@ void MainWindow::sendServiceHistoryRequest() {
}
void MainWindow::setupMain(const MTPUser *self) {
Expects(AuthSession::Exists());
auto animated = (_intro || _passcodeLock);
auto bg = animated ? grabInner() : QPixmap();
clearWidgets();
Assert(AuthSession::Exists());
_main.create(bodyWidget(), controller());
_main->show();
updateControlsGeometry();

View File

@@ -151,24 +151,19 @@ Messenger::Messenger(not_null<Core::Launcher*> launcher)
if (state == Local::ReadMapPassNeeded) {
Global::SetLocalPasscode(true);
Global::RefLocalPasscodeChanged().notify();
lockByPasscode();
DEBUG_LOG(("Application Info: passcode needed..."));
} else {
DEBUG_LOG(("Application Info: local map read..."));
startMtp();
}
DEBUG_LOG(("Application Info: MTP started..."));
DEBUG_LOG(("Application Info: showing."));
if (state == Local::ReadMapPassNeeded) {
lockByPasscode();
} else {
DEBUG_LOG(("Application Info: MTP started..."));
if (AuthSession::Exists()) {
_window->setupMain();
} else {
_window->setupIntro();
}
}
DEBUG_LOG(("Application Info: showing."));
_window->firstShow();
if (cStartToSettings()) {
@@ -1037,8 +1032,12 @@ void Messenger::lockByPasscode() {
}
void Messenger::unlockPasscode() {
cSetPasscodeBadTries(0);
clearPasscodeLock();
_window->clearPasscodeLock();
}
void Messenger::clearPasscodeLock() {
cSetPasscodeBadTries(0);
_passcodeLock = false;
}
@@ -1202,6 +1201,7 @@ void Messenger::loggedOut() {
Global::SetLocalPasscode(false);
Global::RefLocalPasscodeChanged().notify();
}
clearPasscodeLock();
Media::Player::mixer()->stopAndClear();
if (const auto w = getActiveWindow()) {
w->tempDirDelete(Local::ClearManagerAll);

View File

@@ -233,6 +233,7 @@ private:
void photoUpdated(const FullMsgId &msgId, const MTPInputFile &file);
void resetAuthorizationKeys();
void authSessionDestroy();
void clearPasscodeLock();
void loggedOut();
not_null<Core::Launcher*> _launcher;

View File

@@ -539,7 +539,9 @@ void PanelController::uploadSpecialScan(
QByteArray &&content) {
Expects(_editScope != nullptr);
Expects(_editDocument != nullptr);
Expects(_editScope->selfieRequired);
Expects(_editDocument->requiresSpecialScan(
type,
_editScope->selfieRequired));
_form->uploadSpecialScan(_editDocument, type, std::move(content));
}
@@ -547,7 +549,9 @@ void PanelController::uploadSpecialScan(
void PanelController::deleteSpecialScan(SpecialFile type) {
Expects(_editScope != nullptr);
Expects(_editDocument != nullptr);
Expects(_editScope->selfieRequired);
Expects(_editDocument->requiresSpecialScan(
type,
_editScope->selfieRequired));
_form->deleteSpecialScan(_editDocument, type);
}
@@ -555,7 +559,9 @@ void PanelController::deleteSpecialScan(SpecialFile type) {
void PanelController::restoreSpecialScan(SpecialFile type) {
Expects(_editScope != nullptr);
Expects(_editDocument != nullptr);
Expects(_editScope->selfieRequired);
Expects(_editDocument->requiresSpecialScan(
type,
_editScope->selfieRequired));
_form->restoreSpecialScan(_editDocument, type);
}

View File

@@ -272,12 +272,22 @@ public:
, _items(_expressions.size()) {
}
void feed(const QString &text, const QString &textTag) {
// Here we use the fact that text either contains only emoji
// { adjustedTextLength = text.size() * (emojiLength - 1) }
// or contains no emoji at all and can have tag edges in the middle
// { adjustedTextLength = 0 }.
//
// Otherwise we would have to pass emoji positions inside text.
void feed(
const QString &text,
int adjustedTextLength,
const QString &textTag) {
if (!_tags) {
return;
}
const auto guard = gsl::finally([&] {
_currentLength += text.size();
_currentInternalLength += text.size();
_currentAdjustedLength += adjustedTextLength;
});
if (!textTag.isEmpty()) {
finishTags();
@@ -290,7 +300,7 @@ public:
while (true) {
for (; tryFinishTag != _currentFreeTag; ++tryFinishTag) {
auto &tag = (*_tags)[tryFinishTag];
if (tag.length >= 0) {
if (tag.internalLength >= 0) {
continue;
}
@@ -298,8 +308,12 @@ public:
Assert(i != end(_tagIndices));
const auto tagIndex = i->second;
_items[tagIndex].applyOffset(
tag.start + tag.tag.size() + 1 - _currentLength);
const auto atLeastOffset =
tag.internalStart
+ tag.tag.size()
+ 1
- _currentInternalLength;
_items[tagIndex].applyOffset(atLeastOffset);
fillItem(
tagIndex,
@@ -311,10 +325,7 @@ public:
const auto position = matchPosition(tagIndex, Edge::Close);
if (position < kInvalidPosition) {
const auto till = position + tag.tag.size();
finishTag(
tryFinishTag,
_currentLength + till,
true);
finishTag(tryFinishTag, till, true);
_items[tagIndex].applyOffset(till);
}
}
@@ -325,9 +336,7 @@ public:
if (min < 0) {
return;
}
startTag(
_currentLength + matchPosition(min, Edge::Open),
_expressions[min].tag);
startTag(matchPosition(min, Edge::Open), _expressions[min].tag);
}
}
@@ -342,13 +351,18 @@ public:
}
private:
void finishTag(int index, int end, bool closed) {
void finishTag(int index, int offsetFromAccumulated, bool closed) {
Expects(_tags != nullptr);
Expects(index >= 0 && index < _tags->size());
auto &tag = (*_tags)[index];
if (tag.length < 0) {
tag.length = end - tag.start;
if (tag.internalLength < 0) {
tag.internalLength = _currentInternalLength
+ offsetFromAccumulated
- tag.internalStart;
tag.adjustedLength = _currentAdjustedLength
+ offsetFromAccumulated
- tag.adjustedStart;
tag.closed = closed;
}
if (index == _currentTag) {
@@ -369,25 +383,33 @@ private:
}
const auto endPosition = newlinePosition(
text,
std::max(0, tag.start + 1 - _currentLength));
std::max(0, tag.internalStart + 1 - _currentInternalLength));
if (matchPosition(tagIndex, Edge::Close) <= endPosition) {
return false;
}
finishTag(index, _currentLength + endPosition, false);
finishTag(index, endPosition, false);
return true;
}
void finishTags() {
while (_currentTag != _currentFreeTag) {
finishTag(_currentTag, _currentLength, false);
finishTag(_currentTag, 0, false);
}
}
void startTag(int offset, const QString &tag) {
void startTag(int offsetFromAccumulated, const QString &tag) {
Expects(_tags != nullptr);
const auto newTag = InputField::MarkdownTag{
_currentInternalLength + offsetFromAccumulated,
-1,
_currentAdjustedLength + offsetFromAccumulated,
-1,
false,
tag
};
if (_currentFreeTag < _tags->size()) {
(*_tags)[_currentFreeTag] = { offset, -1, false, tag };
(*_tags)[_currentFreeTag] = newTag;
} else {
_tags->push_back({ offset, -1, false, tag });
_tags->push_back(newTag);
}
++_currentFreeTag;
}
@@ -447,7 +469,8 @@ private:
int _currentTag = 0;
int _currentFreeTag = 0;
int _currentLength = 0;
int _currentInternalLength = 0;
int _currentAdjustedLength = 0;
};
@@ -1246,6 +1269,16 @@ void InputField::updatePalette() {
}
}
}
cursor = textCursor();
if (!cursor.hasSelection()) {
auto format = cursor.charFormat();
format.merge(PrepareTagFormat(
_st,
format.property(kTagProperty).toString()));
cursor.setCharFormat(format);
setTextCursor(cursor);
}
}
void InputField::onTouchTimer() {
@@ -1752,11 +1785,11 @@ QString InputField::getTextPart(
if (full || !text.isEmpty()) {
lastTag = format.property(kTagProperty).toString();
tagAccumulator.feed(lastTag, result.size());
markdownTagAccumulator.feed(text, lastTag);
}
auto begin = text.data();
auto ch = begin;
auto adjustedLength = text.size();
for (const auto end = begin + text.size(); ch != end; ++ch) {
if (IsNewline(*ch) && ch->unicode() != '\r') {
*ch = QLatin1Char('\n');
@@ -1768,6 +1801,7 @@ QString InputField::getTextPart(
if (ch > begin) {
result.append(begin, ch - begin);
}
adjustedLength += (emojiText.size() - 1);
if (!emojiText.isEmpty()) {
result.append(emojiText);
}
@@ -1778,12 +1812,16 @@ QString InputField::getTextPart(
if (ch > begin) {
result.append(begin, ch - begin);
}
if (full || !text.isEmpty()) {
markdownTagAccumulator.feed(text, adjustedLength, lastTag);
}
}
block = block.next();
if (block != till) {
result.append('\n');
markdownTagAccumulator.feed(newline, lastTag);
markdownTagAccumulator.feed(newline, 1, lastTag);
}
}
@@ -2141,14 +2179,17 @@ void InputField::highlightMarkdown() {
from = b;
};
for (const auto &tag : _lastMarkdownTags) {
if (tag.start > from) {
applyColor(from, tag.start, QColor(0, 0, 0));
} else if (tag.start < from) {
if (tag.internalStart > from) {
applyColor(from, tag.internalStart, QColor(0, 0, 0));
} else if (tag.internalStart < from) {
continue;
}
applyColor(tag.start, tag.start + tag.length, tag.closed
? QColor(0, 128, 0)
: QColor(128, 0, 0));
applyColor(
tag.internalStart,
tag.internalStart + tag.internalLength,
(tag.closed
? QColor(0, 128, 0)
: QColor(128, 0, 0)));
}
auto cursor = textCursor();
cursor.movePosition(QTextCursor::End);
@@ -2342,36 +2383,38 @@ TextWithTags InputField::getTextWithAppliedMarkdown() const {
const auto linksEnd = links.end();
for (const auto &tag : _lastMarkdownTags) {
const auto tagLength = int(tag.tag.size());
if (!tag.closed || tag.start < from) {
if (!tag.closed || tag.adjustedStart < from) {
continue;
}
const auto entityLength = tag.length - 2 * tagLength;
const auto entityLength = tag.adjustedLength - 2 * tagLength;
if (entityLength <= 0) {
continue;
}
addOriginalTagsUpTill(tag.start);
addOriginalTagsUpTill(tag.adjustedStart);
const auto tagAdjustedEnd = tag.adjustedStart + tag.adjustedLength;
if (originalTag != originalTagsEnd
&& originalTag->offset < tag.start + tag.length) {
&& originalTag->offset < tagAdjustedEnd) {
continue;
}
while (link != linksEnd
&& link->offset() + link->length() <= tag.start) {
&& link->offset() + link->length() <= tag.adjustedStart) {
++link;
}
if (link != linksEnd
&& link->offset() < tag.start + tag.length
&& (link->offset() + link->length() > tag.start + tag.length
|| link->offset() < tag.start)) {
&& link->offset() < tagAdjustedEnd
&& (link->offset() + link->length() > tagAdjustedEnd
|| link->offset() < tag.adjustedStart)) {
continue;
}
addOriginalTextUpTill(tag.start);
addOriginalTextUpTill(tag.adjustedStart);
result.tags.push_back(TextWithTags::Tag{
int(result.text.size()),
entityLength,
tag.tag });
result.text.append(
originalText.midRef(tag.start + tagLength, entityLength));
from = tag.start + tag.length;
result.text.append(originalText.midRef(
tag.adjustedStart + tagLength,
entityLength));
from = tag.adjustedStart + tag.adjustedLength;
removed += 2 * tagLength;
}
addOriginalTagsUpTill(originalText.size());
@@ -2739,8 +2782,8 @@ void InputField::processInstantReplaces(const QString &appended) {
}
const auto position = textCursor().position();
for (const auto &tag : _lastMarkdownTags) {
if (tag.start < position
&& tag.start + tag.length >= position
if (tag.internalStart < position
&& tag.internalStart + tag.internalLength >= position
&& (tag.tag == kTagCode || tag.tag == kTagPre)) {
return;
}

View File

@@ -125,8 +125,14 @@ public:
using TagList = TextWithTags::Tags;
struct MarkdownTag {
int start = 0;
int length = 0;
// With each emoji being QChar::ObjectReplacementCharacter.
int internalStart = 0;
int internalLength = 0;
// Adjusted by emoji to match _lastTextWithTags.
int adjustedStart = 0;
int adjustedLength = 0;
bool closed = false;
QString tag;
};

View File

@@ -132,35 +132,18 @@ void PasscodeLockWidget::submit() {
return;
}
if (App::main()) {
if (Local::checkPasscode(_passcode->text().toUtf8())) {
Messenger::Instance().unlockPasscode(); // Destroys this widget.
return;
} else {
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
cSetPasscodeLastTry(getms(true));
error();
return;
}
} else {
if (Local::readMap(_passcode->text().toUtf8()) != Local::ReadMapPassNeeded) {
cSetPasscodeBadTries(0);
Messenger::Instance().startMtp();
// Destroys this widget.
if (AuthSession::Exists()) {
App::wnd()->setupMain();
} else {
App::wnd()->setupIntro();
}
} else {
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
cSetPasscodeLastTry(getms(true));
error();
return;
}
const auto passcode = _passcode->text().toUtf8();
const auto correct = App::main()
? Local::checkPasscode(passcode)
: (Local::readMap(passcode) != Local::ReadMapPassNeeded);
if (!correct) {
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
cSetPasscodeLastTry(getms(true));
error();
return;
}
Messenger::Instance().unlockPasscode(); // Destroys this widget.
}
void PasscodeLockWidget::error() {

View File

@@ -1,6 +1,6 @@
AppVersion 1003002
AppVersion 1003004
AppVersionStrMajor 1.3
AppVersionStrSmall 1.3.2
AppVersionStr 1.3.2
AppVersionStrSmall 1.3.4
AppVersionStr 1.3.4
AlphaChannel 1
BetaVersion 0

View File

@@ -1,3 +1,11 @@
1.3.4 alpha (07.06.18)
- Bug fixes and other minor improvements.
1.3.3 alpha (07.06.18)
- Bug fixes and other minor improvements.
1.3.2 alpha (07.06.18)
- Bug fixes and other minor improvements.