Skip to content

Commit

Permalink
forward by drag-n-drop from media overview, fixed video overview, sti…
Browse files Browse the repository at this point in the history
…ckers enlarged and optimized, preparing version 0.8.34.dev
  • Loading branch information
john-preston committed Jun 28, 2015
1 parent 8e82b88 commit 405dfbe
Show file tree
Hide file tree
Showing 31 changed files with 816 additions and 570 deletions.
8 changes: 4 additions & 4 deletions Telegram/PrepareWin.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@echo OFF

set "AppVersionStrMajor=0.8"
set "AppVersion=8033"
set "AppVersionStrSmall=0.8.33"
set "AppVersionStr=0.8.33"
set "AppVersionStrFull=0.8.33.0"
set "AppVersion=8034"
set "AppVersionStrSmall=0.8.34"
set "AppVersionStr=0.8.34"
set "AppVersionStrFull=0.8.34.0"
set "DevChannel=1"

if %DevChannel% neq 0 goto preparedev
Expand Down
15 changes: 8 additions & 7 deletions Telegram/Resources/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ rbEmoji: flatCheckbox {
bgColor: emojiPanCategories;
disColor: emojiPanCategories;

width: 36px;
width: 42px;
height: 46px;

textTop: 0px;
Expand All @@ -1576,7 +1576,7 @@ rbEmoji: flatCheckbox {
cursor: cursor(pointer);

disabledCursor: cursor(default);
imagePos: point(8px, 12px);
imagePos: point(11px, 12px);
}
rbEmojiRecent: flatCheckbox(rbEmoji) {
imageRect: emojiRecentOver;
Expand Down Expand Up @@ -1642,16 +1642,17 @@ rbEmojiObjects: flatCheckbox(rbEmoji) {
disImageRect: emojiObjectsOver;
chkDisImageRect: emojiObjectsActive;
}
emojiPanPadding: 10px;
emojiPanSize: size(39px, 35px);
emojiPanFullSize: size(300px, 321px);
emojiPanPadding: 12px;
emojiPanSize: size(45px, 41px);
emojiPanWidth: 345px;
emojiPanMaxHeight: 366px;
emojiPanDuration: 200;
emojiPanHover: #f0f4f7;

emojiPanHeader: 42px;
emojiPanHeaderFont: font(fsize semibold);
emojiPanHeaderColor: #999;
emojiPanHeaderLeft: 17px;
emojiPanHeaderLeft: 22px;
emojiPanHeaderTop: 12px;
emojiPanHeaderBg: #fffffff2;

Expand All @@ -1665,7 +1666,7 @@ emojiSwitchStickers: sprite(318px, 328px, 8px, 12px);
emojiSwitchEmoji: sprite(310px, 328px, 8px, 12px);
emojiSwitchColor: #42a8db;

stickerPanSize: size(55px, 55px);
stickerPanSize: size(64px, 64px);
stickerPanPadding: 11px;
stickerPanDelete: sprite(123px, 132px, 12px, 12px);
stickerPanDeleteOpacity: 0.5;
Expand Down
240 changes: 180 additions & 60 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,54 @@ void ApiWrap::requestReplyTo(HistoryReply *reply, MsgId to) {
if (!req.req) _replyToTimer.start(1);
}

void ApiWrap::resolveReplyTo() {
if (_replyToRequests.isEmpty()) return;

QVector<MTPint> ids;
ids.reserve(_replyToRequests.size());
for (ReplyToRequests::const_iterator i = _replyToRequests.cbegin(), e = _replyToRequests.cend(); i != e; ++i) {
if (!i.value().req) {
ids.push_back(MTP_int(i.key()));
}
}
if (!ids.isEmpty()) {
mtpRequestId req = MTP::send(MTPmessages_GetMessages(MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotReplyTo));
for (ReplyToRequests::iterator i = _replyToRequests.begin(), e = _replyToRequests.end(); i != e; ++i) {
i.value().req = req;
}
}
}

void ApiWrap::gotReplyTo(const MTPmessages_Messages &msgs, mtpRequestId req) {
switch (msgs.type()) {
case mtpc_messages_messages:
App::feedUsers(msgs.c_messages_messages().vusers);
App::feedChats(msgs.c_messages_messages().vchats);
App::feedMsgs(msgs.c_messages_messages().vmessages, -1);
break;

case mtpc_messages_messagesSlice:
App::feedUsers(msgs.c_messages_messagesSlice().vusers);
App::feedChats(msgs.c_messages_messagesSlice().vchats);
App::feedMsgs(msgs.c_messages_messagesSlice().vmessages, -1);
break;
}
for (ReplyToRequests::iterator i = _replyToRequests.begin(); i != _replyToRequests.cend();) {
if (i.value().req == req) {
for (QList<HistoryReply*>::const_iterator j = i.value().replies.cbegin(), e = i.value().replies.cend(); j != e; ++j) {
if (*j) {
(*j)->updateReplyTo(true);
} else {
App::main()->updateReplyTo();
}
}
i = _replyToRequests.erase(i);
} else {
++i;
}
}
}

void ApiWrap::requestFullPeer(PeerData *peer) {
if (!peer || _fullRequests.contains(peer)) return;
mtpRequestId req;
Expand All @@ -94,25 +142,6 @@ void ApiWrap::requestFullPeer(PeerData *peer) {
_fullRequests.insert(peer, req);
}

void ApiWrap::requestWebPageDelayed(WebPageData *page) {
if (page->pendingTill <= 0) return;
_webPagesPending.insert(page, 0);
int32 left = (page->pendingTill - unixtime()) * 1000;
if (!_webPagesTimer.isActive() || left <= _webPagesTimer.remainingTime()) {
_webPagesTimer.start((left < 0 ? 0 : left) + 1);
}
}

void ApiWrap::clearWebPageRequest(WebPageData *page) {
_webPagesPending.remove(page);
if (_webPagesPending.isEmpty() && _webPagesTimer.isActive()) _webPagesTimer.stop();
}

void ApiWrap::clearWebPageRequests() {
_webPagesPending.clear();
_webPagesTimer.stop();
}

void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result) {
const MTPDmessages_chatFull &d(result.c_messages_chatFull());
const MTPDchatFull &f(d.vfull_chat.c_chatFull());
Expand Down Expand Up @@ -168,22 +197,143 @@ bool ApiWrap::gotPeerFailed(PeerData *peer, const RPCError &error) {
return true;
}

void ApiWrap::resolveReplyTo() {
if (_replyToRequests.isEmpty()) return;
void ApiWrap::scheduleStickerSetRequest(uint64 setId, uint64 access) {
if (!_stickerSetRequests.contains(setId)) {
_stickerSetRequests.insert(setId, qMakePair(access, 0));
}
}

QVector<MTPint> ids;
ids.reserve(_replyToRequests.size());
for (ReplyToRequests::const_iterator i = _replyToRequests.cbegin(), e = _replyToRequests.cend(); i != e; ++i) {
if (!i.value().req) {
ids.push_back(MTP_int(i.key()));
void ApiWrap::requestStickerSets() {
for (QMap<uint64, QPair<uint64, mtpRequestId> >::iterator i = _stickerSetRequests.begin(), j = i, e = _stickerSetRequests.end(); i != e; i = j) {
if (i.value().second) continue;

++j;
int32 wait = (j == e) ? 0 : 10;
i.value().second = MTP::send(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first))), rpcDone(&ApiWrap::gotStickerSet, i.key()), rpcFail(&ApiWrap::gotStickerSetFail, i.key()), 0, wait);
}
}

void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) {
_stickerSetRequests.remove(setId);

if (result.type() != mtpc_messages_stickerSet) return;
const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());

if (d.vset.type() != mtpc_stickerSet) return;
const MTPDstickerSet &s(d.vset.c_stickerSet());

StickerSets &sets(cRefStickerSets());
StickerSets::iterator it = sets.find(setId);
if (it == sets.cend()) return;

it->access = s.vaccess_hash.v;
it->hash = s.vhash.v;
it->shortName = qs(s.vshort_name);
QString title = qs(s.vtitle);
if ((it->flags & MTPDstickerSet_flag_official) && !title.compare(qstr("Great Minds"), Qt::CaseInsensitive)) {
title = lang(lng_stickers_default_set);
}
it->title = title;
it->flags = s.vflags.v;

const QVector<MTPDocument> &d_docs(d.vdocuments.c_vector().v);
StickerSets::iterator custom = sets.find(CustomStickerSetId);

QSet<DocumentData*> found;
int32 wasCount = -1;
for (int32 i = 0, l = d_docs.size(); i != l; ++i) {
DocumentData *doc = App::feedDocument(d_docs.at(i));
if (!doc || !doc->sticker) continue;

if (wasCount < 0) wasCount = it->stickers.size();
if (it->stickers.indexOf(doc) < 0) {
it->stickers.push_back(doc);
} else {
found.insert(doc);
}

if (custom != sets.cend()) {
int32 index = custom->stickers.indexOf(doc);
if (index >= 0) {
custom->stickers.removeAt(index);
}
}
}
if (!ids.isEmpty()) {
mtpRequestId req = MTP::send(MTPmessages_GetMessages(MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotReplyTo));
for (ReplyToRequests::iterator i = _replyToRequests.begin(), e = _replyToRequests.end(); i != e; ++i) {
i.value().req = req;
if (custom != sets.cend() && custom->stickers.isEmpty()) {
sets.erase(custom);
custom = sets.end();
}

bool writeRecent = false;
RecentStickerPack &recent(cGetRecentStickers());

if (wasCount < 0) { // no stickers received
for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
if (it->stickers.indexOf(i->first) >= 0) {
i = recent.erase(i);
writeRecent = true;
} else {
++i;
}
}
cRefStickerSetsOrder().removeOne(setId);
sets.erase(it);
} else {
for (int32 j = 0, l = wasCount; j < l;) {
if (found.contains(it->stickers.at(j))) {
++j;
} else {
for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
if (it->stickers.at(j) == i->first) {
i = recent.erase(i);
writeRecent = true;
} else {
++i;
}
}
it->stickers.removeAt(j);
--l;
}
}
if (it->stickers.isEmpty()) {
cRefStickerSetsOrder().removeOne(setId);
sets.erase(it);
}
}

if (writeRecent) {
Local::writeUserSettings();
}

Local::writeStickers();

if (App::main()) emit App::main()->stickersUpdated();
}

bool ApiWrap::gotStickerSetFail(uint64 setId, const RPCError &error) {
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;

_stickerSetRequests.remove(setId);
return true;
}

void ApiWrap::requestWebPageDelayed(WebPageData *page) {
if (page->pendingTill <= 0) return;
_webPagesPending.insert(page, 0);
int32 left = (page->pendingTill - unixtime()) * 1000;
if (!_webPagesTimer.isActive() || left <= _webPagesTimer.remainingTime()) {
_webPagesTimer.start((left < 0 ? 0 : left) + 1);
}
}

void ApiWrap::clearWebPageRequest(WebPageData *page) {
_webPagesPending.remove(page);
if (_webPagesPending.isEmpty() && _webPagesTimer.isActive()) _webPagesTimer.stop();
}

void ApiWrap::clearWebPageRequests() {
_webPagesPending.clear();
_webPagesTimer.stop();
}

void ApiWrap::resolveWebPages() {
Expand Down Expand Up @@ -214,36 +364,6 @@ void ApiWrap::resolveWebPages() {
if (m < INT_MAX) _webPagesTimer.start(m * 1000);
}

void ApiWrap::gotReplyTo(const MTPmessages_Messages &msgs, mtpRequestId req) {
switch (msgs.type()) {
case mtpc_messages_messages:
App::feedUsers(msgs.c_messages_messages().vusers);
App::feedChats(msgs.c_messages_messages().vchats);
App::feedMsgs(msgs.c_messages_messages().vmessages, -1);
break;

case mtpc_messages_messagesSlice:
App::feedUsers(msgs.c_messages_messagesSlice().vusers);
App::feedChats(msgs.c_messages_messagesSlice().vchats);
App::feedMsgs(msgs.c_messages_messagesSlice().vmessages, -1);
break;
}
for (ReplyToRequests::iterator i = _replyToRequests.begin(); i != _replyToRequests.cend();) {
if (i.value().req == req) {
for (QList<HistoryReply*>::const_iterator j = i.value().replies.cbegin(), e = i.value().replies.cend(); j != e; ++j) {
if (*j) {
(*j)->updateReplyTo(true);
} else {
App::main()->updateReplyTo();
}
}
i = _replyToRequests.erase(i);
} else {
++i;
}
}
}

void ApiWrap::gotWebPages(const MTPmessages_Messages &msgs, mtpRequestId req) {
const QVector<MTPMessage> *v = 0;
switch (msgs.type()) {
Expand Down
7 changes: 7 additions & 0 deletions Telegram/SourceFiles/apiwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ApiWrap : public QObject, public RPCSender {
void clearWebPageRequest(WebPageData *page);
void clearWebPageRequests();

void scheduleStickerSetRequest(uint64 setId, uint64 access);
void requestStickerSets();

~ApiWrap();

signals:
Expand Down Expand Up @@ -71,4 +74,8 @@ public slots:
WebPagesPending _webPagesPending;
SingleTimer _webPagesTimer;

QMap<uint64, QPair<uint64, mtpRequestId> > _stickerSetRequests;
void gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result);
bool gotStickerSetFail(uint64 setId, const RPCError &error);

};
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ namespace App {
History *h = App::historyLoaded(peer);
if (h) {
h->outboxRead(upTo);
if (!h->peer->chat) {
h->peer->asUser()->madeAction();
}
}
}

Expand Down Expand Up @@ -1577,7 +1580,6 @@ namespace App {
if (api()) api()->clearWebPageRequests();
cSetRecentStickers(RecentStickerPack());
cSetStickersHash(QByteArray());
cSetEmojiStickers(EmojiStickersMap());
cSetStickerSets(StickerSets());
cSetStickerSetsOrder(StickerSetsOrder());
cSetLastStickersUpdate(0);
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ void Application::checkMapVersion() {
psRegisterCustomScheme();
if (Local::oldMapVersion()) {
QString versionFeatures;
if (DevChannel && Local::oldMapVersion() < 8033) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 IPv6 connection checkbox added to Connection Type box in Settings");// .replace('@', qsl("@") + QChar(0x200D));
if (DevChannel && Local::oldMapVersion() < 8034) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Forward photos, media and stickers with drag-n-drop\n\xe2\x80\x94 Drag-n-drop text messages by timestamp to forward them\n\xe2\x80\x94 Larger stickers panel");// .replace('@', qsl("@") + QChar(0x200D));
} else if (!DevChannel && Local::oldMapVersion() < 8030) {
versionFeatures = lng_new_version_text(lt_blog_link, qsl("https://telegram.org/blog/bot-revolution"));// lang(lng_new_version_text).trimmed();
}
Expand Down
Loading

0 comments on commit 405dfbe

Please sign in to comment.