mirror of https://github.com/procxx/kepka.git
Error handling changed, 'auto' keyword used for MTP types.
All errors that lead to MTP request resending by default error handler now can be handled differently. For example inline bot requests are not being resent on 5XX error codes. + extensive use of auto keyword in MTP types handling.
This commit is contained in:
parent
35d5089f48
commit
8e89486fbc
|
@ -432,7 +432,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\
|
||||||
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
||||||
if (!countedTags.isEmpty()) {
|
if (!countedTags.isEmpty()) {
|
||||||
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
||||||
const QVector<QString> &counted(*j);
|
const auto &counted(*j);
|
||||||
for (int k = 0, s = counted.size(); k < s; ++k) {
|
for (int k = 0, s = counted.size(); k < s; ++k) {
|
||||||
th << "\t" << keysOrder[i] << "__" + j.key() + QString::number(k).toUtf8() << ",\n";
|
th << "\t" << keysOrder[i] << "__" + j.key() + QString::number(k).toUtf8() << ",\n";
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\
|
||||||
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
||||||
if (!countedTags.isEmpty()) {
|
if (!countedTags.isEmpty()) {
|
||||||
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
||||||
const QVector<QString> &counted(*j);
|
const auto &counted(*j);
|
||||||
for (int k = 0, s = counted.size(); k < s; ++k) {
|
for (int k = 0, s = counted.size(); k < s; ++k) {
|
||||||
tcpp << "\t\t\"" << keysOrder[i] << "__" + j.key() + QString::number(k).toUtf8() << "\",\n";
|
tcpp << "\t\t\"" << keysOrder[i] << "__" + j.key() + QString::number(k).toUtf8() << "\",\n";
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\
|
||||||
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
|
||||||
if (!countedTags.isEmpty()) {
|
if (!countedTags.isEmpty()) {
|
||||||
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
for (QMap<QByteArray, QVector<QString> >::const_iterator j = countedTags.cbegin(), e = countedTags.cend(); j != e; ++j) {
|
||||||
const QVector<QString> &counted(*j);
|
const auto &counted(*j);
|
||||||
for (int k = 0, s = counted.size(); k < s; ++k) {
|
for (int k = 0, s = counted.size(); k < s; ++k) {
|
||||||
writeCppKey(tcpp, keysOrder[i] + "__" + j.key() + QString::number(k).toUtf8(), counted[k]);
|
writeCppKey(tcpp, keysOrder[i] + "__" + j.key() + QString::number(k).toUtf8(), counted[k]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,21 +99,21 @@ void ApiWrap::resolveMessageDatas() {
|
||||||
void ApiWrap::gotMessageDatas(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) {
|
void ApiWrap::gotMessageDatas(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) {
|
||||||
switch (msgs.type()) {
|
switch (msgs.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(msgs.c_messages_messages());
|
const auto &d(msgs.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
App::feedMsgs(d.vmessages, NewMessageExisting);
|
App::feedMsgs(d.vmessages, NewMessageExisting);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
|
const auto &d(msgs.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
App::feedMsgs(d.vmessages, NewMessageExisting);
|
App::feedMsgs(d.vmessages, NewMessageExisting);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
|
const auto &d(msgs.c_messages_channelMessages());
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel->ptsReceived(d.vpts.v);
|
channel->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,8 +169,8 @@ void ApiWrap::processFullPeer(PeerData *peer, const MTPUserFull &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mtpRequestId req) {
|
void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mtpRequestId req) {
|
||||||
const MTPDmessages_chatFull &d(result.c_messages_chatFull());
|
const auto &d(result.c_messages_chatFull());
|
||||||
const QVector<MTPChat> &vc(d.vchats.c_vector().v);
|
const auto &vc(d.vchats.c_vector().v);
|
||||||
bool badVersion = false;
|
bool badVersion = false;
|
||||||
if (peer->isChat()) {
|
if (peer->isChat()) {
|
||||||
badVersion = (!vc.isEmpty() && vc.at(0).type() == mtpc_chat && vc.at(0).c_chat().vversion.v < peer->asChat()->version);
|
badVersion = (!vc.isEmpty() && vc.at(0).type() == mtpc_chat && vc.at(0).c_chat().vversion.v < peer->asChat()->version);
|
||||||
|
@ -186,13 +186,13 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||||
LOG(("MTP Error: bad type in gotChatFull for chat: %1").arg(d.vfull_chat.type()));
|
LOG(("MTP Error: bad type in gotChatFull for chat: %1").arg(d.vfull_chat.type()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const MTPDchatFull &f(d.vfull_chat.c_chatFull());
|
const auto &f(d.vfull_chat.c_chatFull());
|
||||||
App::feedParticipants(f.vparticipants, false, false);
|
App::feedParticipants(f.vparticipants, false, false);
|
||||||
const QVector<MTPBotInfo> &v(f.vbot_info.c_vector().v);
|
const auto &v(f.vbot_info.c_vector().v);
|
||||||
for (QVector<MTPBotInfo>::const_iterator i = v.cbegin(), e = v.cend(); i < e; ++i) {
|
for (QVector<MTPBotInfo>::const_iterator i = v.cbegin(), e = v.cend(); i < e; ++i) {
|
||||||
switch (i->type()) {
|
switch (i->type()) {
|
||||||
case mtpc_botInfo: {
|
case mtpc_botInfo: {
|
||||||
const MTPDbotInfo &b(i->c_botInfo());
|
const auto &b(i->c_botInfo());
|
||||||
UserData *user = App::userLoaded(b.vuser_id.v);
|
UserData *user = App::userLoaded(b.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
user->setBotInfo(*i);
|
user->setBotInfo(*i);
|
||||||
|
@ -218,7 +218,7 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||||
LOG(("MTP Error: bad type in gotChatFull for channel: %1").arg(d.vfull_chat.type()));
|
LOG(("MTP Error: bad type in gotChatFull for channel: %1").arg(d.vfull_chat.type()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const MTPDchannelFull &f(d.vfull_chat.c_channelFull());
|
const auto &f(d.vfull_chat.c_channelFull());
|
||||||
PhotoData *photo = App::feedPhoto(f.vchat_photo);
|
PhotoData *photo = App::feedPhoto(f.vchat_photo);
|
||||||
ChannelData *channel = peer->asChannel();
|
ChannelData *channel = peer->asChannel();
|
||||||
channel->flagsFull = f.vflags.v;
|
channel->flagsFull = f.vflags.v;
|
||||||
|
@ -257,11 +257,11 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||||
App::main()->peerUpdated(cfrom);
|
App::main()->peerUpdated(cfrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const QVector<MTPBotInfo> &v(f.vbot_info.c_vector().v);
|
const auto &v(f.vbot_info.c_vector().v);
|
||||||
for (QVector<MTPBotInfo>::const_iterator i = v.cbegin(), e = v.cend(); i < e; ++i) {
|
for (QVector<MTPBotInfo>::const_iterator i = v.cbegin(), e = v.cend(); i < e; ++i) {
|
||||||
switch (i->type()) {
|
switch (i->type()) {
|
||||||
case mtpc_botInfo: {
|
case mtpc_botInfo: {
|
||||||
const MTPDbotInfo &b(i->c_botInfo());
|
const auto &b(i->c_botInfo());
|
||||||
UserData *user = App::userLoaded(b.vuser_id.v);
|
UserData *user = App::userLoaded(b.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
user->setBotInfo(*i);
|
user->setBotInfo(*i);
|
||||||
|
@ -321,7 +321,7 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestId req) {
|
void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestId req) {
|
||||||
const MTPDuserFull &d(result.c_userFull());
|
const auto &d(result.c_userFull());
|
||||||
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
|
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
|
||||||
if (d.has_profile_photo()) {
|
if (d.has_profile_photo()) {
|
||||||
App::feedPhoto(d.vprofile_photo);
|
App::feedPhoto(d.vprofile_photo);
|
||||||
|
@ -351,7 +351,7 @@ void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestI
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::gotPeerFullFailed(PeerData *peer, const RPCError &error) {
|
bool ApiWrap::gotPeerFullFailed(PeerData *peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_fullPeerRequests.remove(peer);
|
_fullPeerRequests.remove(peer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -420,7 +420,7 @@ void ApiWrap::gotChat(PeerData *peer, const MTPmessages_Chats &result) {
|
||||||
_peerRequests.remove(peer);
|
_peerRequests.remove(peer);
|
||||||
|
|
||||||
if (result.type() == mtpc_messages_chats) {
|
if (result.type() == mtpc_messages_chats) {
|
||||||
const QVector<MTPChat> &v(result.c_messages_chats().vchats.c_vector().v);
|
const auto &v(result.c_messages_chats().vchats.c_vector().v);
|
||||||
bool badVersion = false;
|
bool badVersion = false;
|
||||||
if (peer->isChat()) {
|
if (peer->isChat()) {
|
||||||
badVersion = (!v.isEmpty() && v.at(0).type() == mtpc_chat && v.at(0).c_chat().vversion.v < peer->asChat()->version);
|
badVersion = (!v.isEmpty() && v.at(0).type() == mtpc_chat && v.at(0).c_chat().vversion.v < peer->asChat()->version);
|
||||||
|
@ -458,7 +458,7 @@ void ApiWrap::gotUsers(const MTPVector<MTPUser> &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::gotPeerFailed(PeerData *peer, const RPCError &error) {
|
bool ApiWrap::gotPeerFailed(PeerData *peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_peerRequests.remove(peer);
|
_peerRequests.remove(peer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -491,8 +491,8 @@ void ApiWrap::lastParticipantsDone(ChannelData *peer, const MTPchannels_ChannelP
|
||||||
peer->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate;
|
peer->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDchannels_channelParticipants &d(result.c_channels_channelParticipants());
|
const auto &d(result.c_channels_channelParticipants());
|
||||||
const QVector<MTPChannelParticipant> &v(d.vparticipants.c_vector().v);
|
const auto &v(d.vparticipants.c_vector().v);
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
bool added = false, needBotsInfos = false;
|
bool added = false, needBotsInfos = false;
|
||||||
int32 botStatus = peer->mgInfo->botStatus;
|
int32 botStatus = peer->mgInfo->botStatus;
|
||||||
|
@ -555,7 +555,7 @@ void ApiWrap::lastParticipantsDone(ChannelData *peer, const MTPchannels_ChannelP
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::lastParticipantsFail(ChannelData *peer, const RPCError &error, mtpRequestId req) {
|
bool ApiWrap::lastParticipantsFail(ChannelData *peer, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
if (_participantsRequests.value(peer) == req || _participantsRequests.value(peer) == -req) {
|
if (_participantsRequests.value(peer) == req || _participantsRequests.value(peer) == -req) {
|
||||||
_participantsRequests.remove(peer);
|
_participantsRequests.remove(peer);
|
||||||
} else if (_botsRequests.value(peer) == req) {
|
} else if (_botsRequests.value(peer) == req) {
|
||||||
|
@ -578,27 +578,27 @@ void ApiWrap::gotSelfParticipant(ChannelData *channel, const MTPchannels_Channel
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDchannels_channelParticipant &p(result.c_channels_channelParticipant());
|
const auto &p(result.c_channels_channelParticipant());
|
||||||
App::feedUsers(p.vusers);
|
App::feedUsers(p.vusers);
|
||||||
|
|
||||||
switch (p.vparticipant.type()) {
|
switch (p.vparticipant.type()) {
|
||||||
case mtpc_channelParticipantSelf: {
|
case mtpc_channelParticipantSelf: {
|
||||||
const MTPDchannelParticipantSelf &d(p.vparticipant.c_channelParticipantSelf());
|
const auto &d(p.vparticipant.c_channelParticipantSelf());
|
||||||
channel->inviter = d.vinviter_id.v;
|
channel->inviter = d.vinviter_id.v;
|
||||||
channel->inviteDate = date(d.vdate);
|
channel->inviteDate = date(d.vdate);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_channelParticipantCreator: {
|
case mtpc_channelParticipantCreator: {
|
||||||
const MTPDchannelParticipantCreator &d(p.vparticipant.c_channelParticipantCreator());
|
const auto &d(p.vparticipant.c_channelParticipantCreator());
|
||||||
channel->inviter = MTP::authedId();
|
channel->inviter = MTP::authedId();
|
||||||
channel->inviteDate = date(MTP_int(channel->date));
|
channel->inviteDate = date(MTP_int(channel->date));
|
||||||
} break;
|
} break;
|
||||||
case mtpc_channelParticipantModerator: {
|
case mtpc_channelParticipantModerator: {
|
||||||
const MTPDchannelParticipantModerator &d(p.vparticipant.c_channelParticipantModerator());
|
const auto &d(p.vparticipant.c_channelParticipantModerator());
|
||||||
channel->inviter = d.vinviter_id.v;
|
channel->inviter = d.vinviter_id.v;
|
||||||
channel->inviteDate = date(d.vdate);
|
channel->inviteDate = date(d.vdate);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_channelParticipantEditor: {
|
case mtpc_channelParticipantEditor: {
|
||||||
const MTPDchannelParticipantEditor &d(p.vparticipant.c_channelParticipantEditor());
|
const auto &d(p.vparticipant.c_channelParticipantEditor());
|
||||||
channel->inviter = d.vinviter_id.v;
|
channel->inviter = d.vinviter_id.v;
|
||||||
channel->inviteDate = date(d.vdate);
|
channel->inviteDate = date(d.vdate);
|
||||||
} break;
|
} break;
|
||||||
|
@ -609,7 +609,7 @@ void ApiWrap::gotSelfParticipant(ChannelData *channel, const MTPchannels_Channel
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::gotSelfParticipantFail(ChannelData *channel, const RPCError &error) {
|
bool ApiWrap::gotSelfParticipantFail(ChannelData *channel, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.type() == qstr("USER_NOT_PARTICIPANT")) {
|
if (error.type() == qstr("USER_NOT_PARTICIPANT")) {
|
||||||
channel->inviter = -1;
|
channel->inviter = -1;
|
||||||
|
@ -655,7 +655,7 @@ void ApiWrap::kickParticipantDone(KickRequest kick, const MTPUpdates &result, mt
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::kickParticipantFail(KickRequest kick, const RPCError &error, mtpRequestId req) {
|
bool ApiWrap::kickParticipantFail(KickRequest kick, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
_kickRequests.remove(kick);
|
_kickRequests.remove(kick);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -680,10 +680,10 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
|
||||||
_stickerSetRequests.remove(setId);
|
_stickerSetRequests.remove(setId);
|
||||||
|
|
||||||
if (result.type() != mtpc_messages_stickerSet) return;
|
if (result.type() != mtpc_messages_stickerSet) return;
|
||||||
const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
|
const auto &d(result.c_messages_stickerSet());
|
||||||
|
|
||||||
if (d.vset.type() != mtpc_stickerSet) return;
|
if (d.vset.type() != mtpc_stickerSet) return;
|
||||||
const MTPDstickerSet &s(d.vset.c_stickerSet());
|
const auto &s(d.vset.c_stickerSet());
|
||||||
|
|
||||||
Stickers::Sets &sets(Global::RefStickerSets());
|
Stickers::Sets &sets(Global::RefStickerSets());
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
|
@ -695,7 +695,7 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
|
||||||
it->title = stickerSetTitle(s);
|
it->title = stickerSetTitle(s);
|
||||||
it->flags = s.vflags.v;
|
it->flags = s.vflags.v;
|
||||||
|
|
||||||
const QVector<MTPDocument> &d_docs(d.vdocuments.c_vector().v);
|
const auto &d_docs(d.vdocuments.c_vector().v);
|
||||||
auto custom = sets.find(Stickers::CustomSetId);
|
auto custom = sets.find(Stickers::CustomSetId);
|
||||||
|
|
||||||
StickerPack pack;
|
StickerPack pack;
|
||||||
|
@ -735,13 +735,13 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
|
||||||
} else {
|
} else {
|
||||||
it->stickers = pack;
|
it->stickers = pack;
|
||||||
it->emoji.clear();
|
it->emoji.clear();
|
||||||
const QVector<MTPStickerPack> &v(d.vpacks.c_vector().v);
|
const auto &v(d.vpacks.c_vector().v);
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
if (v.at(i).type() != mtpc_stickerPack) continue;
|
if (v.at(i).type() != mtpc_stickerPack) continue;
|
||||||
|
|
||||||
const MTPDstickerPack &pack(v.at(i).c_stickerPack());
|
const auto &pack(v.at(i).c_stickerPack());
|
||||||
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
||||||
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
|
const auto &stickers(pack.vdocuments.c_vector().v);
|
||||||
StickerPack p;
|
StickerPack p;
|
||||||
p.reserve(stickers.size());
|
p.reserve(stickers.size());
|
||||||
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
||||||
|
@ -765,7 +765,7 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiWrap::gotStickerSetFail(uint64 setId, const RPCError &error) {
|
bool ApiWrap::gotStickerSetFail(uint64 setId, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_stickerSetRequests.remove(setId);
|
_stickerSetRequests.remove(setId);
|
||||||
return true;
|
return true;
|
||||||
|
@ -861,21 +861,21 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs
|
||||||
const QVector<MTPMessage> *v = 0;
|
const QVector<MTPMessage> *v = 0;
|
||||||
switch (msgs.type()) {
|
switch (msgs.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(msgs.c_messages_messages());
|
const auto &d(msgs.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
v = &d.vmessages.c_vector().v;
|
v = &d.vmessages.c_vector().v;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
|
const auto &d(msgs.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
v = &d.vmessages.c_vector().v;
|
v = &d.vmessages.c_vector().v;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
|
const auto &d(msgs.c_messages_channelMessages());
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel->ptsReceived(d.vpts.v);
|
channel->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -894,7 +894,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs
|
||||||
if (!v) return;
|
if (!v) return;
|
||||||
QMap<uint64, int32> msgsIds; // copied from feedMsgs
|
QMap<uint64, int32> msgsIds; // copied from feedMsgs
|
||||||
for (int32 i = 0, l = v->size(); i < l; ++i) {
|
for (int32 i = 0, l = v->size(); i < l; ++i) {
|
||||||
const MTPMessage &msg(v->at(i));
|
const auto &msg(v->at(i));
|
||||||
switch (msg.type()) {
|
switch (msg.type()) {
|
||||||
case mtpc_message: msgsIds.insert((uint64(uint32(msg.c_message().vid.v)) << 32) | uint64(i), i); break;
|
case mtpc_message: msgsIds.insert((uint64(uint32(msg.c_message().vid.v)) << 32) | uint64(i), i); break;
|
||||||
case mtpc_messageEmpty: msgsIds.insert((uint64(uint32(msg.c_messageEmpty().vid.v)) << 32) | uint64(i), i); break;
|
case mtpc_messageEmpty: msgsIds.insert((uint64(uint32(msg.c_messageEmpty().vid.v)) << 32) | uint64(i), i); break;
|
||||||
|
|
|
@ -356,16 +356,16 @@ namespace {
|
||||||
|
|
||||||
UserData *feedUsers(const MTPVector<MTPUser> &users, bool emitPeerUpdated) {
|
UserData *feedUsers(const MTPVector<MTPUser> &users, bool emitPeerUpdated) {
|
||||||
UserData *data = 0;
|
UserData *data = 0;
|
||||||
const QVector<MTPUser> &v(users.c_vector().v);
|
const auto &v(users.c_vector().v);
|
||||||
for (QVector<MTPUser>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
for (QVector<MTPUser>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
||||||
const MTPuser &user(*i);
|
const auto &user(*i);
|
||||||
data = 0;
|
data = 0;
|
||||||
bool wasContact = false, minimal = false;
|
bool wasContact = false, minimal = false;
|
||||||
const MTPUserStatus *status = 0, emptyStatus = MTP_userStatusEmpty();
|
const MTPUserStatus *status = 0, emptyStatus = MTP_userStatusEmpty();
|
||||||
|
|
||||||
switch (user.type()) {
|
switch (user.type()) {
|
||||||
case mtpc_userEmpty: {
|
case mtpc_userEmpty: {
|
||||||
const MTPDuserEmpty &d(user.c_userEmpty());
|
const auto &d(user.c_userEmpty());
|
||||||
|
|
||||||
PeerId peer(peerFromUser(d.vid.v));
|
PeerId peer(peerFromUser(d.vid.v));
|
||||||
data = App::user(peer);
|
data = App::user(peer);
|
||||||
|
@ -381,7 +381,7 @@ namespace {
|
||||||
data->contact = -1;
|
data->contact = -1;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_user: {
|
case mtpc_user: {
|
||||||
const MTPDuser &d(user.c_user());
|
const auto &d(user.c_user());
|
||||||
minimal = d.is_min();
|
minimal = d.is_min();
|
||||||
|
|
||||||
PeerId peer(peerFromUser(d.vid.v));
|
PeerId peer(peerFromUser(d.vid.v));
|
||||||
|
@ -514,14 +514,14 @@ namespace {
|
||||||
|
|
||||||
PeerData *feedChats(const MTPVector<MTPChat> &chats, bool emitPeerUpdated) {
|
PeerData *feedChats(const MTPVector<MTPChat> &chats, bool emitPeerUpdated) {
|
||||||
PeerData *data = 0;
|
PeerData *data = 0;
|
||||||
const QVector<MTPChat> &v(chats.c_vector().v);
|
const auto &v(chats.c_vector().v);
|
||||||
for (QVector<MTPChat>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
for (QVector<MTPChat>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
||||||
const MTPchat &chat(*i);
|
const auto &chat(*i);
|
||||||
data = 0;
|
data = 0;
|
||||||
bool minimal = false;
|
bool minimal = false;
|
||||||
switch (chat.type()) {
|
switch (chat.type()) {
|
||||||
case mtpc_chat: {
|
case mtpc_chat: {
|
||||||
const MTPDchat &d(chat.c_chat());
|
const auto &d(chat.c_chat());
|
||||||
|
|
||||||
data = App::chat(peerFromChat(d.vid.v));
|
data = App::chat(peerFromChat(d.vid.v));
|
||||||
data->input = MTP_inputPeerChat(d.vid);
|
data->input = MTP_inputPeerChat(d.vid);
|
||||||
|
@ -533,7 +533,7 @@ namespace {
|
||||||
cdata->date = d.vdate.v;
|
cdata->date = d.vdate.v;
|
||||||
|
|
||||||
if (d.has_migrated_to() && d.vmigrated_to.type() == mtpc_inputChannel) {
|
if (d.has_migrated_to() && d.vmigrated_to.type() == mtpc_inputChannel) {
|
||||||
const MTPDinputChannel &c(d.vmigrated_to.c_inputChannel());
|
const auto &c(d.vmigrated_to.c_inputChannel());
|
||||||
ChannelData *channel = App::channel(peerFromChannel(c.vchannel_id));
|
ChannelData *channel = App::channel(peerFromChannel(c.vchannel_id));
|
||||||
if (!channel->mgInfo) {
|
if (!channel->mgInfo) {
|
||||||
channel->flags |= MTPDchannel::Flag::f_megagroup;
|
channel->flags |= MTPDchannel::Flag::f_megagroup;
|
||||||
|
@ -580,7 +580,7 @@ namespace {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_chatForbidden: {
|
case mtpc_chatForbidden: {
|
||||||
const MTPDchatForbidden &d(chat.c_chatForbidden());
|
const auto &d(chat.c_chatForbidden());
|
||||||
|
|
||||||
data = App::chat(peerFromChat(d.vid.v));
|
data = App::chat(peerFromChat(d.vid.v));
|
||||||
data->input = MTP_inputPeerChat(d.vid);
|
data->input = MTP_inputPeerChat(d.vid);
|
||||||
|
@ -596,7 +596,7 @@ namespace {
|
||||||
cdata->isForbidden = true;
|
cdata->isForbidden = true;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_channel: {
|
case mtpc_channel: {
|
||||||
const MTPDchannel &d(chat.c_channel());
|
const auto &d(chat.c_channel());
|
||||||
|
|
||||||
PeerId peer(peerFromChannel(d.vid.v));
|
PeerId peer(peerFromChannel(d.vid.v));
|
||||||
minimal = d.is_min();
|
minimal = d.is_min();
|
||||||
|
@ -636,7 +636,7 @@ namespace {
|
||||||
cdata->setPhoto(d.vphoto);
|
cdata->setPhoto(d.vphoto);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_channelForbidden: {
|
case mtpc_channelForbidden: {
|
||||||
const MTPDchannelForbidden &d(chat.c_channelForbidden());
|
const auto &d(chat.c_channelForbidden());
|
||||||
|
|
||||||
PeerId peer(peerFromChannel(d.vid.v));
|
PeerId peer(peerFromChannel(d.vid.v));
|
||||||
data = App::channel(peer);
|
data = App::channel(peer);
|
||||||
|
@ -678,18 +678,18 @@ namespace {
|
||||||
ChatData *chat = 0;
|
ChatData *chat = 0;
|
||||||
switch (p.type()) {
|
switch (p.type()) {
|
||||||
case mtpc_chatParticipantsForbidden: {
|
case mtpc_chatParticipantsForbidden: {
|
||||||
const MTPDchatParticipantsForbidden &d(p.c_chatParticipantsForbidden());
|
const auto &d(p.c_chatParticipantsForbidden());
|
||||||
chat = App::chat(d.vchat_id.v);
|
chat = App::chat(d.vchat_id.v);
|
||||||
chat->count = -1;
|
chat->count = -1;
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_chatParticipants: {
|
case mtpc_chatParticipants: {
|
||||||
const MTPDchatParticipants &d(p.c_chatParticipants());
|
const auto &d(p.c_chatParticipants());
|
||||||
chat = App::chat(d.vchat_id.v);
|
chat = App::chat(d.vchat_id.v);
|
||||||
if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result
|
if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result
|
||||||
chat->version = d.vversion.v;
|
chat->version = d.vversion.v;
|
||||||
const QVector<MTPChatParticipant> &v(d.vparticipants.c_vector().v);
|
const auto &v(d.vparticipants.c_vector().v);
|
||||||
chat->count = v.size();
|
chat->count = v.size();
|
||||||
int32 pversion = chat->participants.isEmpty() ? 1 : (chat->participants.begin().value() + 1);
|
int32 pversion = chat->participants.isEmpty() ? 1 : (chat->participants.begin().value() + 1);
|
||||||
chat->invitedByMe = ChatData::InvitedByMe();
|
chat->invitedByMe = ChatData::InvitedByMe();
|
||||||
|
@ -699,17 +699,17 @@ namespace {
|
||||||
int32 uid = 0, inviter = 0;
|
int32 uid = 0, inviter = 0;
|
||||||
switch (i->type()) {
|
switch (i->type()) {
|
||||||
case mtpc_chatParticipantCreator: {
|
case mtpc_chatParticipantCreator: {
|
||||||
const MTPDchatParticipantCreator &p(i->c_chatParticipantCreator());
|
const auto &p(i->c_chatParticipantCreator());
|
||||||
uid = p.vuser_id.v;
|
uid = p.vuser_id.v;
|
||||||
chat->creator = uid;
|
chat->creator = uid;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_chatParticipantAdmin: {
|
case mtpc_chatParticipantAdmin: {
|
||||||
const MTPDchatParticipantAdmin &p(i->c_chatParticipantAdmin());
|
const auto &p(i->c_chatParticipantAdmin());
|
||||||
uid = p.vuser_id.v;
|
uid = p.vuser_id.v;
|
||||||
inviter = p.vinviter_id.v;
|
inviter = p.vinviter_id.v;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_chatParticipant: {
|
case mtpc_chatParticipant: {
|
||||||
const MTPDchatParticipant &p(i->c_chatParticipant());
|
const auto &p(i->c_chatParticipant());
|
||||||
uid = p.vuser_id.v;
|
uid = p.vuser_id.v;
|
||||||
inviter = p.vinviter_id.v;
|
inviter = p.vinviter_id.v;
|
||||||
} break;
|
} break;
|
||||||
|
@ -1013,10 +1013,10 @@ namespace {
|
||||||
void feedMsgs(const QVector<MTPMessage> &msgs, NewMessageType type) {
|
void feedMsgs(const QVector<MTPMessage> &msgs, NewMessageType type) {
|
||||||
QMap<uint64, int32> msgsIds;
|
QMap<uint64, int32> msgsIds;
|
||||||
for (int32 i = 0, l = msgs.size(); i < l; ++i) {
|
for (int32 i = 0, l = msgs.size(); i < l; ++i) {
|
||||||
const MTPMessage &msg(msgs.at(i));
|
const auto &msg(msgs.at(i));
|
||||||
switch (msg.type()) {
|
switch (msg.type()) {
|
||||||
case mtpc_message: {
|
case mtpc_message: {
|
||||||
const MTPDmessage &d(msg.c_message());
|
const auto &d(msg.c_message());
|
||||||
bool needToAdd = true;
|
bool needToAdd = true;
|
||||||
if (type == NewMessageUnread) { // new message, index my forwarded messages to links overview
|
if (type == NewMessageUnread) { // new message, index my forwarded messages to links overview
|
||||||
if (checkEntitiesAndViewsUpdate(d)) { // already in blocks
|
if (checkEntitiesAndViewsUpdate(d)) { // already in blocks
|
||||||
|
@ -1044,17 +1044,17 @@ namespace {
|
||||||
ImagePtr image(const MTPPhotoSize &size) {
|
ImagePtr image(const MTPPhotoSize &size) {
|
||||||
switch (size.type()) {
|
switch (size.type()) {
|
||||||
case mtpc_photoSize: {
|
case mtpc_photoSize: {
|
||||||
const MTPDphotoSize &d(size.c_photoSize());
|
const auto &d(size.c_photoSize());
|
||||||
if (d.vlocation.type() == mtpc_fileLocation) {
|
if (d.vlocation.type() == mtpc_fileLocation) {
|
||||||
const MTPDfileLocation &l(d.vlocation.c_fileLocation());
|
const auto &l(d.vlocation.c_fileLocation());
|
||||||
return ImagePtr(StorageImageLocation(d.vw.v, d.vh.v, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v), d.vsize.v);
|
return ImagePtr(StorageImageLocation(d.vw.v, d.vh.v, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v), d.vsize.v);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_photoCachedSize: {
|
case mtpc_photoCachedSize: {
|
||||||
const MTPDphotoCachedSize &d(size.c_photoCachedSize());
|
const auto &d(size.c_photoCachedSize());
|
||||||
if (d.vlocation.type() == mtpc_fileLocation) {
|
if (d.vlocation.type() == mtpc_fileLocation) {
|
||||||
const MTPDfileLocation &l(d.vlocation.c_fileLocation());
|
const auto &l(d.vlocation.c_fileLocation());
|
||||||
const string &s(d.vbytes.c_string().v);
|
const auto &s(d.vbytes.c_string().v);
|
||||||
QByteArray bytes(s.data(), s.size());
|
QByteArray bytes(s.data(), s.size());
|
||||||
return ImagePtr(StorageImageLocation(d.vw.v, d.vh.v, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v), bytes);
|
return ImagePtr(StorageImageLocation(d.vw.v, d.vh.v, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v), bytes);
|
||||||
} else if (d.vlocation.type() == mtpc_fileLocationUnavailable) {
|
} else if (d.vlocation.type() == mtpc_fileLocationUnavailable) {
|
||||||
|
@ -1069,7 +1069,7 @@ namespace {
|
||||||
|
|
||||||
StorageImageLocation imageLocation(int32 w, int32 h, const MTPFileLocation &loc) {
|
StorageImageLocation imageLocation(int32 w, int32 h, const MTPFileLocation &loc) {
|
||||||
if (loc.type() == mtpc_fileLocation) {
|
if (loc.type() == mtpc_fileLocation) {
|
||||||
const MTPDfileLocation &l(loc.c_fileLocation());
|
const auto &l(loc.c_fileLocation());
|
||||||
return StorageImageLocation(w, h, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v);
|
return StorageImageLocation(w, h, l.vdc_id.v, l.vvolume_id.v, l.vlocal_id.v, l.vsecret.v);
|
||||||
}
|
}
|
||||||
return StorageImageLocation(w, h, 0, 0, 0, 0);
|
return StorageImageLocation(w, h, 0, 0, 0, 0);
|
||||||
|
@ -1078,11 +1078,11 @@ namespace {
|
||||||
StorageImageLocation imageLocation(const MTPPhotoSize &size) {
|
StorageImageLocation imageLocation(const MTPPhotoSize &size) {
|
||||||
switch (size.type()) {
|
switch (size.type()) {
|
||||||
case mtpc_photoSize: {
|
case mtpc_photoSize: {
|
||||||
const MTPDphotoSize &d(size.c_photoSize());
|
const auto &d(size.c_photoSize());
|
||||||
return imageLocation(d.vw.v, d.vh.v, d.vlocation);
|
return imageLocation(d.vw.v, d.vh.v, d.vlocation);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_photoCachedSize: {
|
case mtpc_photoCachedSize: {
|
||||||
const MTPDphotoCachedSize &d(size.c_photoCachedSize());
|
const auto &d(size.c_photoCachedSize());
|
||||||
return imageLocation(d.vw.v, d.vh.v, d.vlocation);
|
return imageLocation(d.vw.v, d.vh.v, d.vlocation);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -1149,9 +1149,9 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
void feedUserLinks(const MTPVector<MTPcontacts_Link> &links, bool emitPeerUpdated) {
|
void feedUserLinks(const MTPVector<MTPcontacts_Link> &links, bool emitPeerUpdated) {
|
||||||
const QVector<MTPcontacts_Link> &v(links.c_vector().v);
|
const auto &v(links.c_vector().v);
|
||||||
for (QVector<MTPcontacts_Link>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
for (QVector<MTPcontacts_Link>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
||||||
const MTPDcontacts_link &dv(i->c_contacts_link());
|
const auto &dv(i->c_contacts_link());
|
||||||
UserData *user = feedUsers(MTP_vector<MTPUser>(1, dv.vuser), false);
|
UserData *user = feedUsers(MTP_vector<MTPUser>(1, dv.vuser), false);
|
||||||
MTPint userId(MTP_int(0));
|
MTPint userId(MTP_int(0));
|
||||||
switch (dv.vuser.type()) {
|
switch (dv.vuser.type()) {
|
||||||
|
@ -1284,7 +1284,7 @@ namespace {
|
||||||
}
|
}
|
||||||
switch (photo.type()) {
|
switch (photo.type()) {
|
||||||
case mtpc_photo: {
|
case mtpc_photo: {
|
||||||
const MTPDphoto &ph(photo.c_photo());
|
const auto &ph(photo.c_photo());
|
||||||
return App::photoSet(ph.vid.v, 0, ph.vaccess_hash.v, ph.vdate.v, ImagePtr(*thumb, "JPG"), ImagePtr(*medium, "JPG"), ImagePtr(*full, "JPG"));
|
return App::photoSet(ph.vid.v, 0, ph.vaccess_hash.v, ph.vdate.v, ImagePtr(*thumb, "JPG"), ImagePtr(*medium, "JPG"), ImagePtr(*full, "JPG"));
|
||||||
} break;
|
} break;
|
||||||
case mtpc_photoEmpty: return App::photo(photo.c_photoEmpty().vid.v);
|
case mtpc_photoEmpty: return App::photo(photo.c_photoEmpty().vid.v);
|
||||||
|
@ -1293,7 +1293,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
PhotoData *feedPhoto(const MTPDphoto &photo, PhotoData *convert) {
|
PhotoData *feedPhoto(const MTPDphoto &photo, PhotoData *convert) {
|
||||||
const QVector<MTPPhotoSize> &sizes(photo.vsizes.c_vector().v);
|
const auto &sizes(photo.vsizes.c_vector().v);
|
||||||
const MTPPhotoSize *thumb = 0, *medium = 0, *full = 0;
|
const MTPPhotoSize *thumb = 0, *medium = 0, *full = 0;
|
||||||
int32 thumbLevel = -1, mediumLevel = -1, fullLevel = -1;
|
int32 thumbLevel = -1, mediumLevel = -1, fullLevel = -1;
|
||||||
for (QVector<MTPPhotoSize>::const_iterator i = sizes.cbegin(), e = sizes.cend(); i != e; ++i) {
|
for (QVector<MTPPhotoSize>::const_iterator i = sizes.cbegin(), e = sizes.cend(); i != e; ++i) {
|
||||||
|
@ -1348,7 +1348,7 @@ namespace {
|
||||||
DocumentData *feedDocument(const MTPdocument &document, const QPixmap &thumb) {
|
DocumentData *feedDocument(const MTPdocument &document, const QPixmap &thumb) {
|
||||||
switch (document.type()) {
|
switch (document.type()) {
|
||||||
case mtpc_document: {
|
case mtpc_document: {
|
||||||
const MTPDdocument &d(document.c_document());
|
const auto &d(document.c_document());
|
||||||
return App::documentSet(d.vid.v, 0, d.vaccess_hash.v, d.vdate.v, d.vattributes.c_vector().v, qs(d.vmime_type), ImagePtr(thumb, "JPG"), d.vdc_id.v, d.vsize.v, StorageImageLocation());
|
return App::documentSet(d.vid.v, 0, d.vaccess_hash.v, d.vdate.v, d.vattributes.c_vector().v, qs(d.vmime_type), ImagePtr(thumb, "JPG"), d.vdc_id.v, d.vsize.v, StorageImageLocation());
|
||||||
} break;
|
} break;
|
||||||
case mtpc_documentEmpty: return App::document(document.c_documentEmpty().vid.v);
|
case mtpc_documentEmpty: return App::document(document.c_documentEmpty().vid.v);
|
||||||
|
@ -1698,7 +1698,7 @@ namespace {
|
||||||
|
|
||||||
MTPPhoto photoFromUserPhoto(MTPint userId, MTPint date, const MTPUserProfilePhoto &photo) {
|
MTPPhoto photoFromUserPhoto(MTPint userId, MTPint date, const MTPUserProfilePhoto &photo) {
|
||||||
if (photo.type() == mtpc_userProfilePhoto) {
|
if (photo.type() == mtpc_userProfilePhoto) {
|
||||||
const MTPDuserProfilePhoto &uphoto(photo.c_userProfilePhoto());
|
const auto &uphoto(photo.c_userProfilePhoto());
|
||||||
|
|
||||||
QVector<MTPPhotoSize> photoSizes;
|
QVector<MTPPhotoSize> photoSizes;
|
||||||
photoSizes.push_back(MTP_photoSize(MTP_string("a"), uphoto.vphoto_small, MTP_int(160), MTP_int(160), MTP_int(0)));
|
photoSizes.push_back(MTP_photoSize(MTP_string("a"), uphoto.vphoto_small, MTP_int(160), MTP_int(160), MTP_int(0)));
|
||||||
|
|
|
@ -835,7 +835,7 @@ void AppClass::chatPhotoCleared(PeerId peer, const MTPUpdates &updates) {
|
||||||
|
|
||||||
void AppClass::selfPhotoDone(const MTPphotos_Photo &result) {
|
void AppClass::selfPhotoDone(const MTPphotos_Photo &result) {
|
||||||
if (!App::self()) return;
|
if (!App::self()) return;
|
||||||
const MTPDphotos_photo &photo(result.c_photos_photo());
|
const auto &photo(result.c_photos_photo());
|
||||||
App::feedPhoto(photo.vphoto);
|
App::feedPhoto(photo.vphoto);
|
||||||
App::feedUsers(photo.vusers);
|
App::feedUsers(photo.vusers);
|
||||||
cancelPhotoUpdate(App::self()->id);
|
cancelPhotoUpdate(App::self()->id);
|
||||||
|
@ -851,7 +851,7 @@ void AppClass::chatPhotoDone(PeerId peer, const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppClass::peerPhotoFail(PeerId peer, const RPCError &error) {
|
bool AppClass::peerPhotoFail(PeerId peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("Application Error: update photo failed %1: %2").arg(error.type()).arg(error.description()));
|
LOG(("Application Error: update photo failed %1: %2").arg(error.type()).arg(error.description()));
|
||||||
cancelPhotoUpdate(peer);
|
cancelPhotoUpdate(peer);
|
||||||
|
|
|
@ -199,7 +199,7 @@ void AddContactBox::onSave() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddContactBox::onSaveUserFail(const RPCError &error) {
|
bool AddContactBox::onSaveUserFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_addRequest = 0;
|
_addRequest = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
|
@ -220,13 +220,13 @@ bool AddContactBox::onSaveUserFail(const RPCError &error) {
|
||||||
void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
|
void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
|
||||||
if (isHidden() || !App::main()) return;
|
if (isHidden() || !App::main()) return;
|
||||||
|
|
||||||
const MTPDcontacts_importedContacts &d(res.c_contacts_importedContacts());
|
const auto &d(res.c_contacts_importedContacts());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
|
|
||||||
const QVector<MTPImportedContact> &v(d.vimported.c_vector().v);
|
const auto &v(d.vimported.c_vector().v);
|
||||||
UserData *user = nullptr;
|
UserData *user = nullptr;
|
||||||
if (!v.isEmpty()) {
|
if (!v.isEmpty()) {
|
||||||
const MTPDimportedContact &c(v.front().c_importedContact());
|
const auto &c(v.front().c_importedContact());
|
||||||
if (c.vclient_id.v != _contactId) return;
|
if (c.vclient_id.v != _contactId) return;
|
||||||
|
|
||||||
user = App::userLoaded(c.vuser_id.v);
|
user = App::userLoaded(c.vuser_id.v);
|
||||||
|
@ -246,7 +246,7 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddContactBox::onSaveUserDone(const MTPcontacts_ImportedContacts &res) {
|
void AddContactBox::onSaveUserDone(const MTPcontacts_ImportedContacts &res) {
|
||||||
const MTPDcontacts_importedContacts &d(res.c_contacts_importedContacts());
|
const auto &d(res.c_contacts_importedContacts());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
emit closed();
|
emit closed();
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ void GroupInfoBox::creationDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupInfoBox::creationFail(const RPCError &error) {
|
bool GroupInfoBox::creationFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_creationRequestId = 0;
|
_creationRequestId = 0;
|
||||||
if (error.type() == "NO_CHAT_TITLE") {
|
if (error.type() == "NO_CHAT_TITLE") {
|
||||||
|
@ -903,7 +903,7 @@ void SetupChannelBox::onUpdateDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetupChannelBox::onUpdateFail(const RPCError &error) {
|
bool SetupChannelBox::onUpdateFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
|
@ -940,7 +940,7 @@ void SetupChannelBox::onCheckDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetupChannelBox::onCheckFail(const RPCError &error) {
|
bool SetupChannelBox::onCheckFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_checkRequestId = 0;
|
_checkRequestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
|
@ -971,7 +971,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
|
bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_checkRequestId = 0;
|
_checkRequestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
|
@ -1128,7 +1128,7 @@ void EditNameTitleBox::onSaveSelfDone(const MTPUser &user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditNameTitleBox::onSaveSelfFail(const RPCError &error) {
|
bool EditNameTitleBox::onSaveSelfFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
QString first = textOneLine(_first.getLastText().trimmed()), last = textOneLine(_last.getLastText().trimmed());
|
QString first = textOneLine(_first.getLastText().trimmed()), last = textOneLine(_last.getLastText().trimmed());
|
||||||
|
@ -1150,7 +1150,7 @@ bool EditNameTitleBox::onSaveSelfFail(const RPCError &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditNameTitleBox::onSaveChatFail(const RPCError &error) {
|
bool EditNameTitleBox::onSaveChatFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_requestId = 0;
|
_requestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
|
@ -1334,7 +1334,7 @@ void EditChannelBox::saveSign() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) {
|
bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
if (req == _saveTitleRequestId) {
|
if (req == _saveTitleRequestId) {
|
||||||
|
|
|
@ -42,13 +42,13 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
|
||||||
App::WallPapers wallpapers;
|
App::WallPapers wallpapers;
|
||||||
|
|
||||||
wallpapers.push_back(App::WallPaper(0, ImagePtr(st::msgBG0), ImagePtr(st::msgBG0)));
|
wallpapers.push_back(App::WallPaper(0, ImagePtr(st::msgBG0), ImagePtr(st::msgBG0)));
|
||||||
const QVector<MTPWallPaper> &v(result.c_vector().v);
|
const auto &v(result.c_vector().v);
|
||||||
for (int i = 0, l = v.size(); i < l; ++i) {
|
for (int i = 0, l = v.size(); i < l; ++i) {
|
||||||
const MTPWallPaper w(v.at(i));
|
const auto &w(v.at(i));
|
||||||
switch (w.type()) {
|
switch (w.type()) {
|
||||||
case mtpc_wallPaper: {
|
case mtpc_wallPaper: {
|
||||||
const MTPDwallPaper &d(w.c_wallPaper());
|
const auto &d(w.c_wallPaper());
|
||||||
const QVector<MTPPhotoSize> &sizes(d.vsizes.c_vector().v);
|
const auto &sizes(d.vsizes.c_vector().v);
|
||||||
const MTPPhotoSize *thumb = 0, *full = 0;
|
const MTPPhotoSize *thumb = 0, *full = 0;
|
||||||
int32 thumbLevel = -1, fullLevel = -1;
|
int32 thumbLevel = -1, fullLevel = -1;
|
||||||
for (QVector<MTPPhotoSize>::const_iterator j = sizes.cbegin(), e = sizes.cend(); j != e; ++j) {
|
for (QVector<MTPPhotoSize>::const_iterator j = sizes.cbegin(), e = sizes.cend(); j != e; ++j) {
|
||||||
|
@ -56,14 +56,14 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
|
||||||
int32 w = 0, h = 0;
|
int32 w = 0, h = 0;
|
||||||
switch (j->type()) {
|
switch (j->type()) {
|
||||||
case mtpc_photoSize: {
|
case mtpc_photoSize: {
|
||||||
const string &s(j->c_photoSize().vtype.c_string().v);
|
const auto &s(j->c_photoSize().vtype.c_string().v);
|
||||||
if (s.size()) size = s[0];
|
if (s.size()) size = s[0];
|
||||||
w = j->c_photoSize().vw.v;
|
w = j->c_photoSize().vw.v;
|
||||||
h = j->c_photoSize().vh.v;
|
h = j->c_photoSize().vh.v;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_photoCachedSize: {
|
case mtpc_photoCachedSize: {
|
||||||
const string &s(j->c_photoCachedSize().vtype.c_string().v);
|
const auto &s(j->c_photoCachedSize().vtype.c_string().v);
|
||||||
if (s.size()) size = s[0];
|
if (s.size()) size = s[0];
|
||||||
w = j->c_photoCachedSize().vw.v;
|
w = j->c_photoCachedSize().vw.v;
|
||||||
h = j->c_photoCachedSize().vh.v;
|
h = j->c_photoCachedSize().vh.v;
|
||||||
|
@ -87,7 +87,7 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_wallPaperSolid: {
|
case mtpc_wallPaperSolid: {
|
||||||
const MTPDwallPaperSolid &d(w.c_wallPaperSolid());
|
const auto &d(w.c_wallPaperSolid());
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ void ConvertToSupergroupBox::convertDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConvertToSupergroupBox::convertFail(const RPCError &error) {
|
bool ConvertToSupergroupBox::convertFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ void PinMessageBox::pinDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PinMessageBox::pinFail(const RPCError &error) {
|
bool PinMessageBox::pinFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ void ContactsInner::addAdminDone(const MTPUpdates &result, mtpRequestId req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsInner::addAdminFail(const RPCError &error, mtpRequestId req) {
|
bool ContactsInner::addAdminFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (req != _addAdminRequestId) return true;
|
if (req != _addAdminRequestId) return true;
|
||||||
|
|
||||||
|
@ -1478,7 +1478,7 @@ void ContactsBox::peopleReceived(const MTPcontacts_Found &result, mtpRequestId r
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsBox::peopleFailed(const RPCError &error, mtpRequestId req) {
|
bool ContactsBox::peopleFailed(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_peopleRequest == req) {
|
if (_peopleRequest == req) {
|
||||||
_peopleRequest = 0;
|
_peopleRequest = 0;
|
||||||
|
@ -1623,7 +1623,7 @@ void ContactsBox::onCreate() {
|
||||||
if (_saveRequestId) return;
|
if (_saveRequestId) return;
|
||||||
|
|
||||||
MTPVector<MTPInputUser> users(MTP_vector<MTPInputUser>(_inner.selectedInputs()));
|
MTPVector<MTPInputUser> users(MTP_vector<MTPInputUser>(_inner.selectedInputs()));
|
||||||
const QVector<MTPInputUser> &v(users.c_vector().v);
|
const auto &v(users.c_vector().v);
|
||||||
if (v.isEmpty() || (v.size() == 1 && v.at(0).type() == mtpc_inputUserSelf)) {
|
if (v.isEmpty() || (v.size() == 1 && v.at(0).type() == mtpc_inputUserSelf)) {
|
||||||
_filter.setFocus();
|
_filter.setFocus();
|
||||||
_filter.showError();
|
_filter.showError();
|
||||||
|
@ -1716,7 +1716,7 @@ void ContactsBox::removeAdminDone(UserData *user, const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsBox::saveAdminsFail(const RPCError &error) {
|
bool ContactsBox::saveAdminsFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return true;
|
if (MTP::isDefaultHandledError(error)) return true;
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
_inner.saving(false);
|
_inner.saving(false);
|
||||||
if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
|
if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
|
||||||
|
@ -1726,7 +1726,7 @@ bool ContactsBox::saveAdminsFail(const RPCError &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsBox::editAdminFail(const RPCError &error) {
|
bool ContactsBox::editAdminFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return true;
|
if (MTP::isDefaultHandledError(error)) return true;
|
||||||
--_saveRequestId;
|
--_saveRequestId;
|
||||||
_inner.chat()->invalidateParticipants();
|
_inner.chat()->invalidateParticipants();
|
||||||
if (!_saveRequestId) {
|
if (!_saveRequestId) {
|
||||||
|
@ -1769,7 +1769,7 @@ void ContactsBox::creationDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsBox::creationFail(const RPCError &error) {
|
bool ContactsBox::creationFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
if (error.type() == "NO_CHAT_TITLE") {
|
if (error.type() == "NO_CHAT_TITLE") {
|
||||||
|
@ -2161,8 +2161,8 @@ void MembersInner::membersReceived(const MTPchannels_ChannelParticipants &result
|
||||||
_loadingRequestId = 0;
|
_loadingRequestId = 0;
|
||||||
|
|
||||||
if (result.type() == mtpc_channels_channelParticipants) {
|
if (result.type() == mtpc_channels_channelParticipants) {
|
||||||
const MTPDchannels_channelParticipants &d(result.c_channels_channelParticipants());
|
const auto &d(result.c_channels_channelParticipants());
|
||||||
const QVector<MTPChannelParticipant> &v(d.vparticipants.c_vector().v);
|
const auto &v(d.vparticipants.c_vector().v);
|
||||||
_rows.reserve(v.size());
|
_rows.reserve(v.size());
|
||||||
_datas.reserve(v.size());
|
_datas.reserve(v.size());
|
||||||
_dates.reserve(v.size());
|
_dates.reserve(v.size());
|
||||||
|
@ -2242,7 +2242,8 @@ void MembersInner::membersReceived(const MTPchannels_ChannelParticipants &result
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MembersInner::membersFailed(const RPCError &error, mtpRequestId req) {
|
bool MembersInner::membersFailed(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2263,7 +2264,7 @@ void MembersInner::kickAdminDone(const MTPUpdates &result, mtpRequestId req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MembersInner::kickFail(const RPCError &error, mtpRequestId req) {
|
bool MembersInner::kickFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_kickBox) _kickBox->onClose();
|
if (_kickBox) _kickBox->onClose();
|
||||||
load();
|
load();
|
||||||
|
|
|
@ -284,35 +284,12 @@ void PasscodeBox::setPasswordDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
if (MTP::isFloodError(error)) {
|
||||||
_setRequest = 0;
|
|
||||||
QString err = error.type();
|
|
||||||
if (err == "PASSWORD_HASH_INVALID") {
|
|
||||||
if (_oldPasscode.isHidden()) {
|
|
||||||
emit reloadPassword();
|
|
||||||
onClose();
|
|
||||||
} else {
|
|
||||||
onBadOldPasscode();
|
|
||||||
}
|
|
||||||
} else if (err == "NEW_PASSWORD_BAD") {
|
|
||||||
_newPasscode.setFocus();
|
|
||||||
_newPasscode.showError();
|
|
||||||
_newError = lang(lng_cloud_password_bad);
|
|
||||||
update();
|
|
||||||
} else if (err == "NEW_SALT_INVALID") {
|
|
||||||
emit reloadPassword();
|
|
||||||
onClose();
|
|
||||||
} else if (err == "EMAIL_INVALID") {
|
|
||||||
_emailError = lang(lng_cloud_password_bad_email);
|
|
||||||
_recoverEmail.setFocus();
|
|
||||||
_recoverEmail.showError();
|
|
||||||
update();
|
|
||||||
} else if (err == "EMAIL_UNCONFIRMED") {
|
|
||||||
Ui::showLayer(new InformBox(lang(lng_cloud_password_almost)));
|
|
||||||
emit reloadPassword();
|
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
if (_oldPasscode.isHidden()) return false;
|
if (_oldPasscode.isHidden()) return false;
|
||||||
|
|
||||||
|
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||||
|
_setRequest = 0;
|
||||||
|
|
||||||
_oldPasscode.selectAll();
|
_oldPasscode.selectAll();
|
||||||
_oldPasscode.setFocus();
|
_oldPasscode.setFocus();
|
||||||
_oldPasscode.showError();
|
_oldPasscode.showError();
|
||||||
|
@ -321,6 +298,36 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||||
_recover.hide();
|
_recover.hide();
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
|
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||||
|
_setRequest = 0;
|
||||||
|
QString err = error.type();
|
||||||
|
if (err == qstr("PASSWORD_HASH_INVALID")) {
|
||||||
|
if (_oldPasscode.isHidden()) {
|
||||||
|
emit reloadPassword();
|
||||||
|
onClose();
|
||||||
|
} else {
|
||||||
|
onBadOldPasscode();
|
||||||
|
}
|
||||||
|
} else if (err == qstr("NEW_PASSWORD_BAD")) {
|
||||||
|
_newPasscode.setFocus();
|
||||||
|
_newPasscode.showError();
|
||||||
|
_newError = lang(lng_cloud_password_bad);
|
||||||
|
update();
|
||||||
|
} else if (err == qstr("NEW_SALT_INVALID")) {
|
||||||
|
emit reloadPassword();
|
||||||
|
onClose();
|
||||||
|
} else if (err == qstr("EMAIL_INVALID")) {
|
||||||
|
_emailError = lang(lng_cloud_password_bad_email);
|
||||||
|
_recoverEmail.setFocus();
|
||||||
|
_recoverEmail.showError();
|
||||||
|
update();
|
||||||
|
} else if (err == qstr("EMAIL_UNCONFIRMED")) {
|
||||||
|
Ui::showLayer(new InformBox(lang(lng_cloud_password_almost)));
|
||||||
|
emit reloadPassword();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -490,7 +497,7 @@ void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasscodeBox::recoverStartFail(const RPCError &error) {
|
bool PasscodeBox::recoverStartFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_pattern = QString();
|
_pattern = QString();
|
||||||
onClose();
|
onClose();
|
||||||
|
@ -587,32 +594,36 @@ void RecoverBox::codeSubmitDone(bool recover, const MTPauth_Authorization &resul
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecoverBox::codeSubmitFail(const RPCError &error) {
|
bool RecoverBox::codeSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
_submitRequest = 0;
|
||||||
|
_error = lang(lng_flood_error);
|
||||||
|
update();
|
||||||
|
_recoverCode.showError();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_submitRequest = 0;
|
_submitRequest = 0;
|
||||||
|
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PASSWORD_EMPTY") {
|
if (err == qstr("PASSWORD_EMPTY")) {
|
||||||
emit reloadPassword();
|
emit reloadPassword();
|
||||||
Ui::showLayer(new InformBox(lang(lng_cloud_password_removed)));
|
Ui::showLayer(new InformBox(lang(lng_cloud_password_removed)));
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PASSWORD_RECOVERY_NA") {
|
} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
|
||||||
onClose();
|
onClose();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PASSWORD_RECOVERY_EXPIRED") {
|
} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
|
||||||
emit recoveryExpired();
|
emit recoveryExpired();
|
||||||
onClose();
|
onClose();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "CODE_INVALID") {
|
} else if (err == qstr("CODE_INVALID")) {
|
||||||
_error = lang(lng_signin_wrong_code);
|
_error = lang(lng_signin_wrong_code);
|
||||||
update();
|
update();
|
||||||
_recoverCode.selectAll();
|
_recoverCode.selectAll();
|
||||||
_recoverCode.setFocus();
|
_recoverCode.setFocus();
|
||||||
_recoverCode.showError();
|
_recoverCode.showError();
|
||||||
return true;
|
return true;
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
_error = lang(lng_flood_error);
|
|
||||||
update();
|
|
||||||
_recoverCode.showError();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
_error = err + ": " + error.description();
|
_error = err + ": " + error.description();
|
||||||
|
|
|
@ -51,8 +51,8 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW
|
||||||
if (_file->photo.type() != mtpc_photoEmpty) {
|
if (_file->photo.type() != mtpc_photoEmpty) {
|
||||||
_file->type = PreparePhoto;
|
_file->type = PreparePhoto;
|
||||||
} else if (_file->document.type() == mtpc_document) {
|
} else if (_file->document.type() == mtpc_document) {
|
||||||
const MTPDdocument &document(_file->document.c_document());
|
const auto &document(_file->document.c_document());
|
||||||
const QVector<MTPDocumentAttribute> &attributes(document.vattributes.c_vector().v);
|
const auto &attributes(document.vattributes.c_vector().v);
|
||||||
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
|
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
|
||||||
if (attributes.at(i).type() == mtpc_documentAttributeAnimated) {
|
if (attributes.at(i).type() == mtpc_documentAttributeAnimated) {
|
||||||
_animated = true;
|
_animated = true;
|
||||||
|
@ -668,7 +668,7 @@ void EditCaptionBox::saveDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditCaptionBox::saveFail(const RPCError &error) {
|
bool EditCaptionBox::saveFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
QString err = error.type();
|
QString err = error.type();
|
||||||
|
|
|
@ -166,7 +166,7 @@ void SessionsInner::terminateDone(uint64 hash, const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionsInner::terminateFail(uint64 hash, const RPCError &error) {
|
bool SessionsInner::terminateFail(uint64 hash, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
TerminateButtons::iterator i = _terminateButtons.find(hash);
|
TerminateButtons::iterator i = _terminateButtons.find(hash);
|
||||||
if (i != _terminateButtons.end()) {
|
if (i != _terminateButtons.end()) {
|
||||||
|
@ -181,7 +181,7 @@ void SessionsInner::terminateAllDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionsInner::terminateAllFail(const RPCError &error) {
|
bool SessionsInner::terminateAllFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
emit allTerminated();
|
emit allTerminated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -294,14 +294,14 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
|
||||||
int32 availOther = availCurrent - st::sessionTerminate.iconPos.x();// -st::sessionTerminate.width - st::sessionTerminateSkip;
|
int32 availOther = availCurrent - st::sessionTerminate.iconPos.x();// -st::sessionTerminate.width - st::sessionTerminateSkip;
|
||||||
|
|
||||||
_list.clear();
|
_list.clear();
|
||||||
const QVector<MTPAuthorization> &v(result.c_account_authorizations().vauthorizations.c_vector().v);
|
const auto &v(result.c_account_authorizations().vauthorizations.c_vector().v);
|
||||||
int32 l = v.size();
|
int32 l = v.size();
|
||||||
if (l > 1) _list.reserve(l - 1);
|
if (l > 1) _list.reserve(l - 1);
|
||||||
|
|
||||||
const CountriesByISO2 &countries(countriesByISO2());
|
const CountriesByISO2 &countries(countriesByISO2());
|
||||||
|
|
||||||
for (int32 i = 0; i < l; ++i) {
|
for (int32 i = 0; i < l; ++i) {
|
||||||
const MTPDauthorization &d(v.at(i).c_authorization());
|
const auto &d(v.at(i).c_authorization());
|
||||||
SessionData data;
|
SessionData data;
|
||||||
data.hash = d.vhash.v;
|
data.hash = d.vhash.v;
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
_pack.clear();
|
_pack.clear();
|
||||||
_emoji.clear();
|
_emoji.clear();
|
||||||
if (set.type() == mtpc_messages_stickerSet) {
|
if (set.type() == mtpc_messages_stickerSet) {
|
||||||
const MTPDmessages_stickerSet &d(set.c_messages_stickerSet());
|
const auto &d(set.c_messages_stickerSet());
|
||||||
const QVector<MTPDocument> &v(d.vdocuments.c_vector().v);
|
const auto &v(d.vdocuments.c_vector().v);
|
||||||
_pack.reserve(v.size());
|
_pack.reserve(v.size());
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
DocumentData *doc = App::feedDocument(v.at(i));
|
DocumentData *doc = App::feedDocument(v.at(i));
|
||||||
|
@ -65,12 +65,12 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
|
|
||||||
_pack.push_back(doc);
|
_pack.push_back(doc);
|
||||||
}
|
}
|
||||||
const QVector<MTPStickerPack> &packs(d.vpacks.c_vector().v);
|
const auto &packs(d.vpacks.c_vector().v);
|
||||||
for (int32 i = 0, l = packs.size(); i < l; ++i) {
|
for (int32 i = 0, l = packs.size(); i < l; ++i) {
|
||||||
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
||||||
const MTPDstickerPack &pack(packs.at(i).c_stickerPack());
|
const auto &pack(packs.at(i).c_stickerPack());
|
||||||
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
||||||
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
|
const auto &stickers(pack.vdocuments.c_vector().v);
|
||||||
StickerPack p;
|
StickerPack p;
|
||||||
p.reserve(stickers.size());
|
p.reserve(stickers.size());
|
||||||
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
||||||
|
@ -83,7 +83,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d.vset.type() == mtpc_stickerSet) {
|
if (d.vset.type() == mtpc_stickerSet) {
|
||||||
const MTPDstickerSet &s(d.vset.c_stickerSet());
|
const auto &s(d.vset.c_stickerSet());
|
||||||
_setTitle = stickerSetTitle(s);
|
_setTitle = stickerSetTitle(s);
|
||||||
_title = st::boxTitleFont->elided(_setTitle, width() - st::boxTitlePosition.x() - st::boxTitleHeight);
|
_title = st::boxTitleFont->elided(_setTitle, width() - st::boxTitlePosition.x() - st::boxTitleHeight);
|
||||||
_setShortName = qs(s.vshort_name);
|
_setShortName = qs(s.vshort_name);
|
||||||
|
@ -107,7 +107,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickerSetInner::failedSet(const RPCError &error) {
|
bool StickerSetInner::failedSet(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ void StickerSetInner::installDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickerSetInner::installFailed(const RPCError &error) {
|
bool StickerSetInner::installFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
Ui::showLayer(new InformBox(lang(lng_stickers_not_found)));
|
Ui::showLayer(new InformBox(lang(lng_stickers_not_found)));
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ void StickersBox::disenableDone(const MTPBool & result, mtpRequestId req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickersBox::disenableFail(const RPCError &error, mtpRequestId req) {
|
bool StickersBox::disenableFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
_disenableRequests.remove(req);
|
_disenableRequests.remove(req);
|
||||||
if (_disenableRequests.isEmpty()) {
|
if (_disenableRequests.isEmpty()) {
|
||||||
saveOrder();
|
saveOrder();
|
||||||
|
@ -831,7 +831,7 @@ void StickersBox::reorderDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickersBox::reorderFail(const RPCError &result) {
|
bool StickersBox::reorderFail(const RPCError &result) {
|
||||||
if (mtpIsFlood(result)) return false;
|
if (MTP::isDefaultHandledError(result)) return false;
|
||||||
_reorderRequest = 0;
|
_reorderRequest = 0;
|
||||||
Global::SetLastStickersUpdate(0);
|
Global::SetLastStickersUpdate(0);
|
||||||
App::main()->updateStickers();
|
App::main()->updateStickers();
|
||||||
|
|
|
@ -202,22 +202,22 @@ void UsernameBox::onUpdateDone(const MTPUser &user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UsernameBox::onUpdateFail(const RPCError &error) {
|
bool UsernameBox::onUpdateFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) {
|
if (err == qstr("USERNAME_NOT_MODIFIED") || _sentUsername == App::self()->username) {
|
||||||
App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(_sentUsername));
|
App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(_sentUsername));
|
||||||
emit closed();
|
emit closed();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "USERNAME_INVALID") {
|
} else if (err == qstr("USERNAME_INVALID")) {
|
||||||
_username.setFocus();
|
_username.setFocus();
|
||||||
_username.showError();
|
_username.showError();
|
||||||
_copiedTextLink = QString();
|
_copiedTextLink = QString();
|
||||||
_errorText = lang(lng_username_invalid);
|
_errorText = lang(lng_username_invalid);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") {
|
} else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) {
|
||||||
_username.setFocus();
|
_username.setFocus();
|
||||||
_username.showError();
|
_username.showError();
|
||||||
_copiedTextLink = QString();
|
_copiedTextLink = QString();
|
||||||
|
@ -242,15 +242,15 @@ void UsernameBox::onCheckDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UsernameBox::onCheckFail(const RPCError &error) {
|
bool UsernameBox::onCheckFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_checkRequestId = 0;
|
_checkRequestId = 0;
|
||||||
QString err(error.type());
|
QString err(error.type());
|
||||||
if (err == "USERNAME_INVALID") {
|
if (err == qstr("USERNAME_INVALID")) {
|
||||||
_errorText = lang(lng_username_invalid);
|
_errorText = lang(lng_username_invalid);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "USERNAME_OCCUPIED" && _checkUsername != App::self()->username) {
|
} else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != App::self()->username) {
|
||||||
_errorText = lang(lng_username_occupied);
|
_errorText = lang(lng_username_occupied);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -953,7 +953,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
|
||||||
History *history = 0;
|
History *history = 0;
|
||||||
switch (i->type()) {
|
switch (i->type()) {
|
||||||
case mtpc_dialog: {
|
case mtpc_dialog: {
|
||||||
const MTPDdialog &d(i->c_dialog());
|
const auto &d(i->c_dialog());
|
||||||
history = App::historyFromDialog(peerFromMTP(d.vpeer), d.vunread_count.v, d.vread_inbox_max_id.v);
|
history = App::historyFromDialog(peerFromMTP(d.vpeer), d.vunread_count.v, d.vread_inbox_max_id.v);
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, history);
|
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, history);
|
||||||
|
@ -961,7 +961,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_dialogChannel: {
|
case mtpc_dialogChannel: {
|
||||||
const MTPDdialogChannel &d(i->c_dialogChannel());
|
const auto &d(i->c_dialogChannel());
|
||||||
PeerData *peer = App::peerLoaded(peerFromMTP(d.vpeer));
|
PeerData *peer = App::peerLoaded(peerFromMTP(d.vpeer));
|
||||||
int32 unreadCount = (peer && peer->isMegagroup()) ? d.vunread_count.v : d.vunread_important_count.v;
|
int32 unreadCount = (peer && peer->isMegagroup()) ? d.vunread_count.v : d.vunread_important_count.v;
|
||||||
History *history = App::historyFromDialog(peerFromMTP(d.vpeer), unreadCount, d.vread_inbox_max_id.v);
|
History *history = App::historyFromDialog(peerFromMTP(d.vpeer), unreadCount, d.vread_inbox_max_id.v);
|
||||||
|
@ -1893,7 +1893,7 @@ void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
|
||||||
for (QVector<MTPDialog>::const_iterator i = dialogs.cbegin(), e = dialogs.cend(); i != e; ++i) {
|
for (QVector<MTPDialog>::const_iterator i = dialogs.cbegin(), e = dialogs.cend(); i != e; ++i) {
|
||||||
switch (i->type()) {
|
switch (i->type()) {
|
||||||
case mtpc_dialog: {
|
case mtpc_dialog: {
|
||||||
const MTPDdialog &d(i->c_dialog());
|
const auto &d(i->c_dialog());
|
||||||
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
|
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
|
||||||
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, h);
|
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, h);
|
||||||
if (d.vunread_count.v >= h->unreadCount) {
|
if (d.vunread_count.v >= h->unreadCount) {
|
||||||
|
@ -1903,7 +1903,7 @@ void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_dialogChannel: {
|
case mtpc_dialogChannel: {
|
||||||
const MTPDdialogChannel &d(i->c_dialogChannel());
|
const auto &d(i->c_dialogChannel());
|
||||||
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
|
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
|
||||||
if (h->peer->isChannel()) {
|
if (h->peer->isChannel()) {
|
||||||
h->peer->asChannel()->ptsReceived(d.vpts.v);
|
h->peer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
|
@ -1932,7 +1932,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
|
||||||
const QVector<MTPMessage> *m = 0;
|
const QVector<MTPMessage> *m = 0;
|
||||||
switch (dialogs.type()) {
|
switch (dialogs.type()) {
|
||||||
case mtpc_messages_dialogs: {
|
case mtpc_messages_dialogs: {
|
||||||
const MTPDmessages_dialogs &data(dialogs.c_messages_dialogs());
|
const auto &data(dialogs.c_messages_dialogs());
|
||||||
App::feedUsers(data.vusers);
|
App::feedUsers(data.vusers);
|
||||||
App::feedChats(data.vchats);
|
App::feedChats(data.vchats);
|
||||||
m = &data.vmessages.c_vector().v;
|
m = &data.vmessages.c_vector().v;
|
||||||
|
@ -1940,7 +1940,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
|
||||||
_dialogsFull = true;
|
_dialogsFull = true;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messages_dialogsSlice: {
|
case mtpc_messages_dialogsSlice: {
|
||||||
const MTPDmessages_dialogsSlice &data(dialogs.c_messages_dialogsSlice());
|
const auto &data(dialogs.c_messages_dialogsSlice());
|
||||||
App::feedUsers(data.vusers);
|
App::feedUsers(data.vusers);
|
||||||
App::feedChats(data.vchats);
|
App::feedChats(data.vchats);
|
||||||
m = &data.vmessages.c_vector().v;
|
m = &data.vmessages.c_vector().v;
|
||||||
|
@ -1966,7 +1966,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
|
||||||
for (int32 i = v->size(); i > 0;) {
|
for (int32 i = v->size(); i > 0;) {
|
||||||
PeerId peer = 0;
|
PeerId peer = 0;
|
||||||
MsgId msgId = 0;
|
MsgId msgId = 0;
|
||||||
const MTPDialog &d(v->at(--i));
|
const auto &d(v->at(--i));
|
||||||
switch (d.type()) {
|
switch (d.type()) {
|
||||||
case mtpc_dialog:
|
case mtpc_dialog:
|
||||||
msgId = d.c_dialog().vtop_message.v;
|
msgId = d.c_dialog().vtop_message.v;
|
||||||
|
@ -1984,7 +1984,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
|
||||||
if (msgId) {
|
if (msgId) {
|
||||||
if (!lastMsgId) lastMsgId = msgId;
|
if (!lastMsgId) lastMsgId = msgId;
|
||||||
for (int32 j = m->size(); j > 0;) {
|
for (int32 j = m->size(); j > 0;) {
|
||||||
const MTPMessage &d(m->at(--j));
|
const auto &d(m->at(--j));
|
||||||
if (idFromMessage(d) == msgId && peerFromMessage(d) == peer) {
|
if (idFromMessage(d) == msgId && peerFromMessage(d) == peer) {
|
||||||
int32 date = dateFromMessage(d);
|
int32 date = dateFromMessage(d);
|
||||||
if (date) lastDate = date;
|
if (date) lastDate = date;
|
||||||
|
@ -2011,7 +2011,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsWidget::dialogsFailed(const RPCError &error, mtpRequestId req) {
|
bool DialogsWidget::dialogsFailed(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("RPC Error: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
LOG(("RPC Error: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
||||||
if (_dialogsRequest == req) {
|
if (_dialogsRequest == req) {
|
||||||
|
@ -2153,7 +2153,7 @@ void DialogsWidget::loadDialogs() {
|
||||||
void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &contacts) {
|
void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &contacts) {
|
||||||
cSetContactsReceived(true);
|
cSetContactsReceived(true);
|
||||||
if (contacts.type() == mtpc_contacts_contacts) {
|
if (contacts.type() == mtpc_contacts_contacts) {
|
||||||
const MTPDcontacts_contacts &d(contacts.c_contacts_contacts());
|
const auto &d(contacts.c_contacts_contacts());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
_inner.contactsReceived(d.vcontacts.c_vector().v);
|
_inner.contactsReceived(d.vcontacts.c_vector().v);
|
||||||
}
|
}
|
||||||
|
@ -2161,7 +2161,7 @@ void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &contacts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsWidget::contactsFailed(const RPCError &error) {
|
bool DialogsWidget::contactsFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2180,10 +2180,10 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
|
||||||
if (_searchRequest == req) {
|
if (_searchRequest == req) {
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(result.c_messages_messages());
|
const auto &d(result.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
const QVector<MTPMessage> &msgs(d.vmessages.c_vector().v);
|
const auto &msgs(d.vmessages.c_vector().v);
|
||||||
if (!_inner.searchReceived(msgs, type, msgs.size())) {
|
if (!_inner.searchReceived(msgs, type, msgs.size())) {
|
||||||
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
||||||
_searchFullMigrated = true;
|
_searchFullMigrated = true;
|
||||||
|
@ -2194,10 +2194,10 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
|
const auto &d(result.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
const QVector<MTPMessage> &msgs(d.vmessages.c_vector().v);
|
const auto &msgs(d.vmessages.c_vector().v);
|
||||||
if (!_inner.searchReceived(msgs, type, d.vcount.v)) {
|
if (!_inner.searchReceived(msgs, type, d.vcount.v)) {
|
||||||
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
||||||
_searchFullMigrated = true;
|
_searchFullMigrated = true;
|
||||||
|
@ -2208,7 +2208,7 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
|
const auto &d(result.c_messages_channelMessages());
|
||||||
if (_searchInPeer && _searchInPeer->isChannel()) {
|
if (_searchInPeer && _searchInPeer->isChannel()) {
|
||||||
_searchInPeer->asChannel()->ptsReceived(d.vpts.v);
|
_searchInPeer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2220,7 +2220,7 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
|
||||||
|
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
const QVector<MTPMessage> &msgs(d.vmessages.c_vector().v);
|
const auto &msgs(d.vmessages.c_vector().v);
|
||||||
if (!_inner.searchReceived(msgs, type, d.vcount.v)) {
|
if (!_inner.searchReceived(msgs, type, d.vcount.v)) {
|
||||||
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
if (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
|
||||||
_searchFullMigrated = true;
|
_searchFullMigrated = true;
|
||||||
|
@ -2262,7 +2262,7 @@ void DialogsWidget::peopleReceived(const MTPcontacts_Found &result, mtpRequestId
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsWidget::searchFailed(DialogsSearchRequestType type, const RPCError &error, mtpRequestId req) {
|
bool DialogsWidget::searchFailed(DialogsSearchRequestType type, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_searchRequest == req) {
|
if (_searchRequest == req) {
|
||||||
_searchRequest = 0;
|
_searchRequest = 0;
|
||||||
|
@ -2276,7 +2276,7 @@ bool DialogsWidget::searchFailed(DialogsSearchRequestType type, const RPCError &
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) {
|
bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_peopleRequest == req) {
|
if (_peopleRequest == req) {
|
||||||
_peopleRequest = 0;
|
_peopleRequest = 0;
|
||||||
|
|
|
@ -3639,7 +3639,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
||||||
bool adding = (it != _inlineCache.cend());
|
bool adding = (it != _inlineCache.cend());
|
||||||
if (result.type() == mtpc_messages_botResults) {
|
if (result.type() == mtpc_messages_botResults) {
|
||||||
const auto &d(result.c_messages_botResults());
|
const auto &d(result.c_messages_botResults());
|
||||||
const QVector<MTPBotInlineResult> &v(d.vresults.c_vector().v);
|
const auto &v(d.vresults.c_vector().v);
|
||||||
uint64 queryId(d.vquery_id.v);
|
uint64 queryId(d.vquery_id.v);
|
||||||
|
|
||||||
if (!adding) {
|
if (!adding) {
|
||||||
|
@ -3656,7 +3656,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
||||||
it.value()->results.reserve(it.value()->results.size() + count);
|
it.value()->results.reserve(it.value()->results.size() + count);
|
||||||
}
|
}
|
||||||
int added = 0;
|
int added = 0;
|
||||||
for_const (const MTPBotInlineResult &res, v) {
|
for_const (const auto &res, v) {
|
||||||
if (UniquePointer<InlineBots::Result> result = InlineBots::Result::create(queryId, res)) {
|
if (UniquePointer<InlineBots::Result> result = InlineBots::Result::create(queryId, res)) {
|
||||||
++added;
|
++added;
|
||||||
it.value()->results.push_back(result.release());
|
it.value()->results.push_back(result.release());
|
||||||
|
@ -3677,8 +3677,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmojiPan::inlineResultsFail(const RPCError &error) {
|
bool EmojiPan::inlineResultsFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
// show error?
|
||||||
|
|
||||||
Notify::inlineBotRequesting(false);
|
Notify::inlineBotRequesting(false);
|
||||||
_inlineRequestId = 0;
|
_inlineRequestId = 0;
|
||||||
return true;
|
return true;
|
||||||
|
@ -4439,7 +4438,7 @@ void MentionsDropdown::updateFiltered(bool resetScroll) {
|
||||||
if (_channel->mgInfo->bots.isEmpty()) {
|
if (_channel->mgInfo->bots.isEmpty()) {
|
||||||
if (!_channel->mgInfo->botStatus && App::api()) App::api()->requestBots(_channel);
|
if (!_channel->mgInfo->botStatus && App::api()) App::api()->requestBots(_channel);
|
||||||
} else {
|
} else {
|
||||||
for_const (auto *user, _channel->mgInfo->bots) {
|
for_const (auto user, _channel->mgInfo->bots) {
|
||||||
if (!user->botInfo) continue;
|
if (!user->botInfo) continue;
|
||||||
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
|
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
|
||||||
if (user->botInfo->commands.isEmpty()) continue;
|
if (user->botInfo->commands.isEmpty()) continue;
|
||||||
|
|
|
@ -45,9 +45,9 @@ namespace App {
|
||||||
|
|
||||||
void activateBotCommand(const HistoryItem *msg, int row, int col) {
|
void activateBotCommand(const HistoryItem *msg, int row, int col) {
|
||||||
const HistoryMessageReplyMarkup::Button *button = nullptr;
|
const HistoryMessageReplyMarkup::Button *button = nullptr;
|
||||||
if (auto *markup = msg->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = msg->Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (row < markup->rows.size()) {
|
if (row < markup->rows.size()) {
|
||||||
const HistoryMessageReplyMarkup::ButtonRow &buttonRow(markup->rows.at(row));
|
const auto &buttonRow(markup->rows.at(row));
|
||||||
if (col < buttonRow.size()) {
|
if (col < buttonRow.size()) {
|
||||||
button = &buttonRow.at(col);
|
button = &buttonRow.at(col);
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ void FileUploader::partLoaded(const MTPBool &result, mtpRequestId requestId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) {
|
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file
|
if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file
|
||||||
currentFailed();
|
currentFailed();
|
||||||
|
|
|
@ -563,7 +563,7 @@ void ChannelHistory::getRangeDifferenceNext(int32 pts) {
|
||||||
|
|
||||||
void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
|
void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
|
||||||
if (group.type() != mtpc_messageGroup) return;
|
if (group.type() != mtpc_messageGroup) return;
|
||||||
const MTPDmessageGroup &d(group.c_messageGroup());
|
const auto &d(group.c_messageGroup());
|
||||||
|
|
||||||
if (onlyImportant()) {
|
if (onlyImportant()) {
|
||||||
_otherNewLoaded = false;
|
_otherNewLoaded = false;
|
||||||
|
@ -1227,7 +1227,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mtpc_message: {
|
case mtpc_message: {
|
||||||
const MTPDmessage m(msg.c_message());
|
const auto &m(msg.c_message());
|
||||||
int badMedia = 0; // 1 - unsupported, 2 - empty
|
int badMedia = 0; // 1 - unsupported, 2 - empty
|
||||||
if (m.has_media()) switch (m.vmedia.type()) {
|
if (m.has_media()) switch (m.vmedia.type()) {
|
||||||
case mtpc_messageMediaEmpty:
|
case mtpc_messageMediaEmpty:
|
||||||
|
@ -1284,16 +1284,16 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageService: {
|
case mtpc_messageService: {
|
||||||
const MTPDmessageService &d(msg.c_messageService());
|
const auto &d(msg.c_messageService());
|
||||||
result = HistoryService::create(this, d);
|
result = HistoryService::create(this, d);
|
||||||
|
|
||||||
if (applyServiceAction) {
|
if (applyServiceAction) {
|
||||||
const MTPmessageAction &action(d.vaction);
|
const auto &action(d.vaction);
|
||||||
switch (d.vaction.type()) {
|
switch (d.vaction.type()) {
|
||||||
case mtpc_messageActionChatAddUser: {
|
case mtpc_messageActionChatAddUser: {
|
||||||
const MTPDmessageActionChatAddUser &d(action.c_messageActionChatAddUser());
|
const auto &d(action.c_messageActionChatAddUser());
|
||||||
if (peer->isMegagroup()) {
|
if (peer->isMegagroup()) {
|
||||||
const QVector<MTPint> &v(d.vusers.c_vector().v);
|
const auto &v(d.vusers.c_vector().v);
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
if (UserData *user = App::userLoaded(peerFromUser(v.at(i)))) {
|
if (UserData *user = App::userLoaded(peerFromUser(v.at(i)))) {
|
||||||
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(user) < 0) {
|
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(user) < 0) {
|
||||||
|
@ -1312,7 +1312,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatJoinedByLink: {
|
case mtpc_messageActionChatJoinedByLink: {
|
||||||
const MTPDmessageActionChatJoinedByLink &d(action.c_messageActionChatJoinedByLink());
|
const auto &d(action.c_messageActionChatJoinedByLink());
|
||||||
if (peer->isMegagroup()) {
|
if (peer->isMegagroup()) {
|
||||||
if (result->from()->isUser()) {
|
if (result->from()->isUser()) {
|
||||||
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(result->from()->asUser()) < 0) {
|
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(result->from()->asUser()) < 0) {
|
||||||
|
@ -1334,7 +1334,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatDeleteUser: {
|
case mtpc_messageActionChatDeleteUser: {
|
||||||
const MTPDmessageActionChatDeleteUser &d(action.c_messageActionChatDeleteUser());
|
const auto &d(action.c_messageActionChatDeleteUser());
|
||||||
PeerId uid = peerFromUser(d.vuser_id);
|
PeerId uid = peerFromUser(d.vuser_id);
|
||||||
if (lastKeyboardFrom == uid) {
|
if (lastKeyboardFrom == uid) {
|
||||||
clearLastKeyboard();
|
clearLastKeyboard();
|
||||||
|
@ -1367,13 +1367,13 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatEditPhoto: {
|
case mtpc_messageActionChatEditPhoto: {
|
||||||
const MTPDmessageActionChatEditPhoto &d(action.c_messageActionChatEditPhoto());
|
const auto &d(action.c_messageActionChatEditPhoto());
|
||||||
if (d.vphoto.type() == mtpc_photo) {
|
if (d.vphoto.type() == mtpc_photo) {
|
||||||
const QVector<MTPPhotoSize> &sizes(d.vphoto.c_photo().vsizes.c_vector().v);
|
const auto &sizes(d.vphoto.c_photo().vsizes.c_vector().v);
|
||||||
if (!sizes.isEmpty()) {
|
if (!sizes.isEmpty()) {
|
||||||
PhotoData *photo = App::feedPhoto(d.vphoto.c_photo());
|
PhotoData *photo = App::feedPhoto(d.vphoto.c_photo());
|
||||||
if (photo) photo->peer = peer;
|
if (photo) photo->peer = peer;
|
||||||
const MTPPhotoSize &smallSize(sizes.front()), &bigSize(sizes.back());
|
const auto &smallSize(sizes.front()), &bigSize(sizes.back());
|
||||||
const MTPFileLocation *smallLoc = 0, *bigLoc = 0;
|
const MTPFileLocation *smallLoc = 0, *bigLoc = 0;
|
||||||
switch (smallSize.type()) {
|
switch (smallSize.type()) {
|
||||||
case mtpc_photoSize: smallLoc = &smallSize.c_photoSize().vlocation; break;
|
case mtpc_photoSize: smallLoc = &smallSize.c_photoSize().vlocation; break;
|
||||||
|
@ -1396,7 +1396,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatEditTitle: {
|
case mtpc_messageActionChatEditTitle: {
|
||||||
const MTPDmessageActionChatEditTitle &d(action.c_messageActionChatEditTitle());
|
const auto &d(action.c_messageActionChatEditTitle());
|
||||||
ChatData *chat = peer->asChat();
|
ChatData *chat = peer->asChat();
|
||||||
if (chat) chat->updateName(qs(d.vtitle), QString(), QString());
|
if (chat) chat->updateName(qs(d.vtitle), QString(), QString());
|
||||||
} break;
|
} break;
|
||||||
|
@ -1404,12 +1404,12 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
|
||||||
case mtpc_messageActionChatMigrateTo: {
|
case mtpc_messageActionChatMigrateTo: {
|
||||||
peer->asChat()->flags |= MTPDchat::Flag::f_deactivated;
|
peer->asChat()->flags |= MTPDchat::Flag::f_deactivated;
|
||||||
|
|
||||||
//const MTPDmessageActionChatMigrateTo &d(action.c_messageActionChatMigrateTo());
|
//const auto &d(action.c_messageActionChatMigrateTo());
|
||||||
//PeerData *channel = App::channelLoaded(d.vchannel_id.v);
|
//PeerData *channel = App::channelLoaded(d.vchannel_id.v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChannelMigrateFrom: {
|
case mtpc_messageActionChannelMigrateFrom: {
|
||||||
//const MTPDmessageActionChannelMigrateFrom &d(action.c_messageActionChannelMigrateFrom());
|
//const auto &d(action.c_messageActionChannelMigrateFrom());
|
||||||
//PeerData *chat = App::chatLoaded(d.vchat_id.v);
|
//PeerData *chat = App::chatLoaded(d.vchat_id.v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -1718,7 +1718,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
|
||||||
|
|
||||||
for (; groupsIt != groupsEnd; ++groupsIt) {
|
for (; groupsIt != groupsEnd; ++groupsIt) {
|
||||||
if (groupsIt->type() != mtpc_messageGroup) continue;
|
if (groupsIt->type() != mtpc_messageGroup) continue;
|
||||||
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
|
const auto &group(groupsIt->c_messageGroup());
|
||||||
if (group.vmin_id.v >= adding->id) break;
|
if (group.vmin_id.v >= adding->id) break;
|
||||||
|
|
||||||
addMessageGroup(group);
|
addMessageGroup(group);
|
||||||
|
@ -1728,7 +1728,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
|
||||||
}
|
}
|
||||||
for (; groupsIt != groupsEnd; ++groupsIt) {
|
for (; groupsIt != groupsEnd; ++groupsIt) {
|
||||||
if (groupsIt->type() != mtpc_messageGroup) continue;
|
if (groupsIt->type() != mtpc_messageGroup) continue;
|
||||||
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
|
const auto &group(groupsIt->c_messageGroup());
|
||||||
|
|
||||||
addMessageGroup(group);
|
addMessageGroup(group);
|
||||||
}
|
}
|
||||||
|
@ -1840,7 +1840,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
|
||||||
|
|
||||||
for (; groupsIt != groupsEnd; ++groupsIt) {
|
for (; groupsIt != groupsEnd; ++groupsIt) {
|
||||||
if (groupsIt->type() != mtpc_messageGroup) continue;
|
if (groupsIt->type() != mtpc_messageGroup) continue;
|
||||||
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
|
const auto &group(groupsIt->c_messageGroup());
|
||||||
if (group.vmin_id.v >= adding->id) break;
|
if (group.vmin_id.v >= adding->id) break;
|
||||||
|
|
||||||
addMessageGroup(group);
|
addMessageGroup(group);
|
||||||
|
@ -1851,7 +1851,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
|
||||||
}
|
}
|
||||||
for (; groupsIt != groupsEnd; ++groupsIt) {
|
for (; groupsIt != groupsEnd; ++groupsIt) {
|
||||||
if (groupsIt->type() != mtpc_messageGroup) continue;
|
if (groupsIt->type() != mtpc_messageGroup) continue;
|
||||||
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
|
const auto &group(groupsIt->c_messageGroup());
|
||||||
|
|
||||||
addMessageGroup(group);
|
addMessageGroup(group);
|
||||||
}
|
}
|
||||||
|
@ -2519,7 +2519,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
|
||||||
const QVector<MTPMessage> *v = 0;
|
const QVector<MTPMessage> *v = 0;
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(result.c_messages_messages());
|
const auto &d(result.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
v = &d.vmessages.c_vector().v;
|
v = &d.vmessages.c_vector().v;
|
||||||
|
@ -2527,7 +2527,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
|
const auto &d(result.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
overviewCountData[overviewIndex] = d.vcount.v;
|
overviewCountData[overviewIndex] = d.vcount.v;
|
||||||
|
@ -2535,7 +2535,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
|
const auto &d(result.c_messages_channelMessages());
|
||||||
if (peer->isChannel()) {
|
if (peer->isChannel()) {
|
||||||
peer->asChannel()->ptsReceived(d.vpts.v);
|
peer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3017,15 +3017,15 @@ void HistoryMessageReplyMarkup::createFromButtonRows(const QVector<MTPKeyboardBu
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.reserve(v.size());
|
rows.reserve(v.size());
|
||||||
for_const(const MTPKeyboardButtonRow &row, v) {
|
for_const (const auto &row, v) {
|
||||||
switch (row.type()) {
|
switch (row.type()) {
|
||||||
case mtpc_keyboardButtonRow: {
|
case mtpc_keyboardButtonRow: {
|
||||||
const MTPDkeyboardButtonRow &r(row.c_keyboardButtonRow());
|
const auto &r(row.c_keyboardButtonRow());
|
||||||
const QVector<MTPKeyboardButton> &b(r.vbuttons.c_vector().v);
|
const auto &b(r.vbuttons.c_vector().v);
|
||||||
if (!b.isEmpty()) {
|
if (!b.isEmpty()) {
|
||||||
ButtonRow buttonRow;
|
ButtonRow buttonRow;
|
||||||
buttonRow.reserve(b.size());
|
buttonRow.reserve(b.size());
|
||||||
for_const(const MTPKeyboardButton &button, b) {
|
for_const (const auto &button, b) {
|
||||||
switch (button.type()) {
|
switch (button.type()) {
|
||||||
case mtpc_keyboardButton: {
|
case mtpc_keyboardButton: {
|
||||||
buttonRow.push_back({ Button::Default, qs(button.c_keyboardButton().vtext), QByteArray(), 0 });
|
buttonRow.push_back({ Button::Default, qs(button.c_keyboardButton().vtext), QByteArray(), 0 });
|
||||||
|
@ -3064,26 +3064,26 @@ void HistoryMessageReplyMarkup::create(const MTPReplyMarkup &markup) {
|
||||||
|
|
||||||
switch (markup.type()) {
|
switch (markup.type()) {
|
||||||
case mtpc_replyKeyboardMarkup: {
|
case mtpc_replyKeyboardMarkup: {
|
||||||
const MTPDreplyKeyboardMarkup &d(markup.c_replyKeyboardMarkup());
|
const auto &d(markup.c_replyKeyboardMarkup());
|
||||||
flags = d.vflags.v;
|
flags = d.vflags.v;
|
||||||
|
|
||||||
createFromButtonRows(d.vrows.c_vector().v);
|
createFromButtonRows(d.vrows.c_vector().v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_replyInlineMarkup: {
|
case mtpc_replyInlineMarkup: {
|
||||||
const MTPDreplyInlineMarkup &d(markup.c_replyInlineMarkup());
|
const auto &d(markup.c_replyInlineMarkup());
|
||||||
flags = MTPDreplyKeyboardMarkup::Flags(0) | MTPDreplyKeyboardMarkup_ClientFlag::f_inline;
|
flags = MTPDreplyKeyboardMarkup::Flags(0) | MTPDreplyKeyboardMarkup_ClientFlag::f_inline;
|
||||||
|
|
||||||
createFromButtonRows(d.vrows.c_vector().v);
|
createFromButtonRows(d.vrows.c_vector().v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_replyKeyboardHide: {
|
case mtpc_replyKeyboardHide: {
|
||||||
const MTPDreplyKeyboardHide &d(markup.c_replyKeyboardHide());
|
const auto &d(markup.c_replyKeyboardHide());
|
||||||
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_zero;
|
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_zero;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_replyKeyboardForceReply: {
|
case mtpc_replyKeyboardForceReply: {
|
||||||
const MTPDreplyKeyboardForceReply &d(markup.c_replyKeyboardForceReply());
|
const auto &d(markup.c_replyKeyboardForceReply());
|
||||||
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -3834,11 +3834,11 @@ void HistoryPhoto::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, int
|
||||||
|
|
||||||
void HistoryPhoto::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
|
void HistoryPhoto::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
|
||||||
if (media.type() == mtpc_messageMediaPhoto) {
|
if (media.type() == mtpc_messageMediaPhoto) {
|
||||||
const MTPPhoto &photo(media.c_messageMediaPhoto().vphoto);
|
const auto &photo(media.c_messageMediaPhoto().vphoto);
|
||||||
App::feedPhoto(photo, _data);
|
App::feedPhoto(photo, _data);
|
||||||
|
|
||||||
if (photo.type() == mtpc_photo) {
|
if (photo.type() == mtpc_photo) {
|
||||||
const QVector<MTPPhotoSize> &sizes(photo.c_photo().vsizes.c_vector().v);
|
const auto &sizes(photo.c_photo().vsizes.c_vector().v);
|
||||||
int32 max = 0;
|
int32 max = 0;
|
||||||
const MTPDfileLocation *maxLocation = 0;
|
const MTPDfileLocation *maxLocation = 0;
|
||||||
for (int32 i = 0, l = sizes.size(); i < l; ++i) {
|
for (int32 i = 0, l = sizes.size(); i < l; ++i) {
|
||||||
|
@ -6734,7 +6734,7 @@ HistoryMessage::HistoryMessage(History *history, const MTPDmessage &msg)
|
||||||
CreateConfig config;
|
CreateConfig config;
|
||||||
|
|
||||||
if (msg.has_fwd_from() && msg.vfwd_from.type() == mtpc_messageFwdHeader) {
|
if (msg.has_fwd_from() && msg.vfwd_from.type() == mtpc_messageFwdHeader) {
|
||||||
const MTPDmessageFwdHeader &f(msg.vfwd_from.c_messageFwdHeader());
|
const auto &f(msg.vfwd_from.c_messageFwdHeader());
|
||||||
if (f.has_from_id() || f.has_channel_id()) {
|
if (f.has_from_id() || f.has_channel_id()) {
|
||||||
config.authorIdOriginal = f.has_channel_id() ? peerFromChannel(f.vchannel_id) : peerFromUser(f.vfrom_id);
|
config.authorIdOriginal = f.has_channel_id() ? peerFromChannel(f.vchannel_id) : peerFromUser(f.vfrom_id);
|
||||||
config.fromIdOriginal = f.has_from_id() ? peerFromUser(f.vfrom_id) : peerFromChannel(f.vchannel_id);
|
config.fromIdOriginal = f.has_from_id() ? peerFromUser(f.vfrom_id) : peerFromChannel(f.vchannel_id);
|
||||||
|
@ -6894,35 +6894,35 @@ void HistoryMessage::initTime() {
|
||||||
void HistoryMessage::initMedia(const MTPMessageMedia *media, QString ¤tText) {
|
void HistoryMessage::initMedia(const MTPMessageMedia *media, QString ¤tText) {
|
||||||
switch (media ? media->type() : mtpc_messageMediaEmpty) {
|
switch (media ? media->type() : mtpc_messageMediaEmpty) {
|
||||||
case mtpc_messageMediaContact: {
|
case mtpc_messageMediaContact: {
|
||||||
const MTPDmessageMediaContact &d(media->c_messageMediaContact());
|
const auto &d(media->c_messageMediaContact());
|
||||||
_media.reset(this, new HistoryContact(d.vuser_id.v, qs(d.vfirst_name), qs(d.vlast_name), qs(d.vphone_number)));
|
_media.reset(this, new HistoryContact(d.vuser_id.v, qs(d.vfirst_name), qs(d.vlast_name), qs(d.vphone_number)));
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messageMediaGeo: {
|
case mtpc_messageMediaGeo: {
|
||||||
const MTPGeoPoint &point(media->c_messageMediaGeo().vgeo);
|
const auto &point(media->c_messageMediaGeo().vgeo);
|
||||||
if (point.type() == mtpc_geoPoint) {
|
if (point.type() == mtpc_geoPoint) {
|
||||||
_media.reset(this, new HistoryLocation(LocationCoords(point.c_geoPoint())));
|
_media.reset(this, new HistoryLocation(LocationCoords(point.c_geoPoint())));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messageMediaVenue: {
|
case mtpc_messageMediaVenue: {
|
||||||
const MTPDmessageMediaVenue &d(media->c_messageMediaVenue());
|
const auto &d(media->c_messageMediaVenue());
|
||||||
if (d.vgeo.type() == mtpc_geoPoint) {
|
if (d.vgeo.type() == mtpc_geoPoint) {
|
||||||
_media.reset(this, new HistoryLocation(LocationCoords(d.vgeo.c_geoPoint()), qs(d.vtitle), qs(d.vaddress)));
|
_media.reset(this, new HistoryLocation(LocationCoords(d.vgeo.c_geoPoint()), qs(d.vtitle), qs(d.vaddress)));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messageMediaPhoto: {
|
case mtpc_messageMediaPhoto: {
|
||||||
const MTPDmessageMediaPhoto &photo(media->c_messageMediaPhoto());
|
const auto &photo(media->c_messageMediaPhoto());
|
||||||
if (photo.vphoto.type() == mtpc_photo) {
|
if (photo.vphoto.type() == mtpc_photo) {
|
||||||
_media.reset(this, new HistoryPhoto(App::feedPhoto(photo.vphoto.c_photo()), qs(photo.vcaption), this));
|
_media.reset(this, new HistoryPhoto(App::feedPhoto(photo.vphoto.c_photo()), qs(photo.vcaption), this));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messageMediaDocument: {
|
case mtpc_messageMediaDocument: {
|
||||||
const MTPDocument &document(media->c_messageMediaDocument().vdocument);
|
const auto &document(media->c_messageMediaDocument().vdocument);
|
||||||
if (document.type() == mtpc_document) {
|
if (document.type() == mtpc_document) {
|
||||||
return initMediaFromDocument(App::feedDocument(document), qs(media->c_messageMediaDocument().vcaption));
|
return initMediaFromDocument(App::feedDocument(document), qs(media->c_messageMediaDocument().vcaption));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messageMediaWebPage: {
|
case mtpc_messageMediaWebPage: {
|
||||||
const MTPWebPage &d(media->c_messageMediaWebPage().vwebpage);
|
const auto &d(media->c_messageMediaWebPage().vwebpage);
|
||||||
switch (d.type()) {
|
switch (d.type()) {
|
||||||
case mtpc_webPageEmpty: break;
|
case mtpc_webPageEmpty: break;
|
||||||
case mtpc_webPagePending: {
|
case mtpc_webPagePending: {
|
||||||
|
@ -7884,8 +7884,8 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
|
|
||||||
switch (action.type()) {
|
switch (action.type()) {
|
||||||
case mtpc_messageActionChatAddUser: {
|
case mtpc_messageActionChatAddUser: {
|
||||||
const MTPDmessageActionChatAddUser &d(action.c_messageActionChatAddUser());
|
const auto &d(action.c_messageActionChatAddUser());
|
||||||
const QVector<MTPint> &v(d.vusers.c_vector().v);
|
const auto &v(d.vusers.c_vector().v);
|
||||||
bool foundSelf = false;
|
bool foundSelf = false;
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
if (v.at(i).v == MTP::authedId()) {
|
if (v.at(i).v == MTP::authedId()) {
|
||||||
|
@ -7926,7 +7926,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatJoinedByLink: {
|
case mtpc_messageActionChatJoinedByLink: {
|
||||||
const MTPDmessageActionChatJoinedByLink &d(action.c_messageActionChatJoinedByLink());
|
const auto &d(action.c_messageActionChatJoinedByLink());
|
||||||
//if (true || peerFromUser(d.vinviter_id) == _from->id) {
|
//if (true || peerFromUser(d.vinviter_id) == _from->id) {
|
||||||
text = lng_action_user_joined_by_link(lt_from, from);
|
text = lng_action_user_joined_by_link(lt_from, from);
|
||||||
//} else {
|
//} else {
|
||||||
|
@ -7940,12 +7940,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatCreate: {
|
case mtpc_messageActionChatCreate: {
|
||||||
const MTPDmessageActionChatCreate &d(action.c_messageActionChatCreate());
|
const auto &d(action.c_messageActionChatCreate());
|
||||||
text = lng_action_created_chat(lt_from, from, lt_title, textClean(qs(d.vtitle)));
|
text = lng_action_created_chat(lt_from, from, lt_title, textClean(qs(d.vtitle)));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChannelCreate: {
|
case mtpc_messageActionChannelCreate: {
|
||||||
const MTPDmessageActionChannelCreate &d(action.c_messageActionChannelCreate());
|
const auto &d(action.c_messageActionChannelCreate());
|
||||||
if (isPost()) {
|
if (isPost()) {
|
||||||
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
|
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -7958,7 +7958,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatDeleteUser: {
|
case mtpc_messageActionChatDeleteUser: {
|
||||||
const MTPDmessageActionChatDeleteUser &d(action.c_messageActionChatDeleteUser());
|
const auto &d(action.c_messageActionChatDeleteUser());
|
||||||
if (peerFromUser(d.vuser_id) == _from->id) {
|
if (peerFromUser(d.vuser_id) == _from->id) {
|
||||||
text = lng_action_user_left(lt_from, from);
|
text = lng_action_user_left(lt_from, from);
|
||||||
} else {
|
} else {
|
||||||
|
@ -7969,7 +7969,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatEditPhoto: {
|
case mtpc_messageActionChatEditPhoto: {
|
||||||
const MTPDmessageActionChatEditPhoto &d(action.c_messageActionChatEditPhoto());
|
const auto &d(action.c_messageActionChatEditPhoto());
|
||||||
if (d.vphoto.type() == mtpc_photo) {
|
if (d.vphoto.type() == mtpc_photo) {
|
||||||
_media.reset(this, new HistoryPhoto(history()->peer, d.vphoto.c_photo(), st::msgServicePhotoWidth));
|
_media.reset(this, new HistoryPhoto(history()->peer, d.vphoto.c_photo(), st::msgServicePhotoWidth));
|
||||||
}
|
}
|
||||||
|
@ -7977,13 +7977,13 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatEditTitle: {
|
case mtpc_messageActionChatEditTitle: {
|
||||||
const MTPDmessageActionChatEditTitle &d(action.c_messageActionChatEditTitle());
|
const auto &d(action.c_messageActionChatEditTitle());
|
||||||
text = isPost() ? lng_action_changed_title_channel(lt_title, textClean(qs(d.vtitle))) : lng_action_changed_title(lt_from, from, lt_title, textClean(qs(d.vtitle)));
|
text = isPost() ? lng_action_changed_title_channel(lt_title, textClean(qs(d.vtitle))) : lng_action_changed_title(lt_from, from, lt_title, textClean(qs(d.vtitle)));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageActionChatMigrateTo: {
|
case mtpc_messageActionChatMigrateTo: {
|
||||||
_flags |= MTPDmessage_ClientFlag::f_is_group_migrate;
|
_flags |= MTPDmessage_ClientFlag::f_is_group_migrate;
|
||||||
const MTPDmessageActionChatMigrateTo &d(action.c_messageActionChatMigrateTo());
|
const auto &d(action.c_messageActionChatMigrateTo());
|
||||||
if (true/*PeerData *channel = App::channelLoaded(d.vchannel_id.v)*/) {
|
if (true/*PeerData *channel = App::channelLoaded(d.vchannel_id.v)*/) {
|
||||||
text = lang(lng_action_group_migrate);
|
text = lang(lng_action_group_migrate);
|
||||||
} else {
|
} else {
|
||||||
|
@ -7993,7 +7993,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
|
|
||||||
case mtpc_messageActionChannelMigrateFrom: {
|
case mtpc_messageActionChannelMigrateFrom: {
|
||||||
_flags |= MTPDmessage_ClientFlag::f_is_group_migrate;
|
_flags |= MTPDmessage_ClientFlag::f_is_group_migrate;
|
||||||
const MTPDmessageActionChannelMigrateFrom &d(action.c_messageActionChannelMigrateFrom());
|
const auto &d(action.c_messageActionChannelMigrateFrom());
|
||||||
if (true/*PeerData *chat = App::chatLoaded(d.vchat_id.v)*/) {
|
if (true/*PeerData *chat = App::chatLoaded(d.vchat_id.v)*/) {
|
||||||
text = lang(lng_action_group_migrate);
|
text = lang(lng_action_group_migrate);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1404,7 +1404,7 @@ public:
|
||||||
_flags &= ~MTPDmessage::Flag::f_media_unread;
|
_flags &= ~MTPDmessage::Flag::f_media_unread;
|
||||||
}
|
}
|
||||||
bool definesReplyKeyboard() const {
|
bool definesReplyKeyboard() const {
|
||||||
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
|
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1417,7 @@ public:
|
||||||
}
|
}
|
||||||
MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const {
|
MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const {
|
||||||
t_assert(definesReplyKeyboard());
|
t_assert(definesReplyKeyboard());
|
||||||
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
|
||||||
return markup->flags;
|
return markup->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,7 +1603,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
MsgId replyToId() const {
|
MsgId replyToId() const {
|
||||||
if (auto *reply = Get<HistoryMessageReply>()) {
|
if (auto reply = Get<HistoryMessageReply>()) {
|
||||||
return reply->replyToId();
|
return reply->replyToId();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1658,7 +1658,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayedDateHeight() const {
|
int displayedDateHeight() const {
|
||||||
if (auto *date = Get<HistoryMessageDate>()) {
|
if (auto date = Get<HistoryMessageDate>()) {
|
||||||
return date->height();
|
return date->height();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1671,7 +1671,7 @@ public:
|
||||||
result += st::msgMargin.top();
|
result += st::msgMargin.top();
|
||||||
}
|
}
|
||||||
result += displayedDateHeight();
|
result += displayedDateHeight();
|
||||||
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) {
|
if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
|
||||||
result += unreadbar->height();
|
result += unreadbar->height();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1737,7 +1737,7 @@ protected:
|
||||||
void recountAttachToPrevious();
|
void recountAttachToPrevious();
|
||||||
|
|
||||||
const HistoryMessageReplyMarkup *inlineReplyMarkup() const {
|
const HistoryMessageReplyMarkup *inlineReplyMarkup() const {
|
||||||
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
|
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
|
||||||
return markup;
|
return markup;
|
||||||
}
|
}
|
||||||
|
@ -1745,7 +1745,7 @@ protected:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const ReplyKeyboard *inlineReplyKeyboard() const {
|
const ReplyKeyboard *inlineReplyKeyboard() const {
|
||||||
if (auto *markup = inlineReplyMarkup()) {
|
if (auto markup = inlineReplyMarkup()) {
|
||||||
return markup->inlineKeyboard.data();
|
return markup->inlineKeyboard.data();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2852,7 +2852,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateDependencyItem() override {
|
bool updateDependencyItem() override {
|
||||||
if (auto *reply = Get<HistoryMessageReply>()) {
|
if (auto reply = Get<HistoryMessageReply>()) {
|
||||||
return reply->updateData(this, true);
|
return reply->updateData(this, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2262,7 +2262,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
||||||
_wasForMsgId = FullMsgId(to->channelId(), to->id);
|
_wasForMsgId = FullMsgId(to->channelId(), to->id);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
const auto *markup = to->Get<HistoryMessageReplyMarkup>();
|
auto markup = to->Get<HistoryMessageReplyMarkup>();
|
||||||
_forceReply = markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
_forceReply = markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
||||||
_maximizeSize = !(markup->flags & MTPDreplyKeyboardMarkup::Flag::f_resize);
|
_maximizeSize = !(markup->flags & MTPDreplyKeyboardMarkup::Flag::f_resize);
|
||||||
_singleUse = _forceReply || (markup->flags & MTPDreplyKeyboardMarkup::Flag::f_single_use);
|
_singleUse = _forceReply || (markup->flags & MTPDreplyKeyboardMarkup::Flag::f_single_use);
|
||||||
|
@ -3260,9 +3260,9 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
_stickersUpdateRequest = 0;
|
_stickersUpdateRequest = 0;
|
||||||
|
|
||||||
if (stickers.type() != mtpc_messages_allStickers) return;
|
if (stickers.type() != mtpc_messages_allStickers) return;
|
||||||
const MTPDmessages_allStickers &d(stickers.c_messages_allStickers());
|
const auto &d(stickers.c_messages_allStickers());
|
||||||
|
|
||||||
const QVector<MTPStickerSet> &d_sets(d.vsets.c_vector().v);
|
const auto &d_sets(d.vsets.c_vector().v);
|
||||||
|
|
||||||
Stickers::Order &setsOrder(Global::RefStickerSetsOrder());
|
Stickers::Order &setsOrder(Global::RefStickerSetsOrder());
|
||||||
setsOrder.clear();
|
setsOrder.clear();
|
||||||
|
@ -3274,7 +3274,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
}
|
}
|
||||||
for (int i = 0, l = d_sets.size(); i != l; ++i) {
|
for (int i = 0, l = d_sets.size(); i != l; ++i) {
|
||||||
if (d_sets.at(i).type() == mtpc_stickerSet) {
|
if (d_sets.at(i).type() == mtpc_stickerSet) {
|
||||||
const MTPDstickerSet &set(d_sets.at(i).c_stickerSet());
|
const auto &set(d_sets.at(i).c_stickerSet());
|
||||||
auto it = sets.find(set.vid.v);
|
auto it = sets.find(set.vid.v);
|
||||||
QString title = stickerSetTitle(set);
|
QString title = stickerSetTitle(set);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
|
@ -3334,7 +3334,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::stickersFailed(const RPCError &error) {
|
bool HistoryWidget::stickersFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("App Fail: Failed to get stickers!"));
|
LOG(("App Fail: Failed to get stickers!"));
|
||||||
|
|
||||||
|
@ -3348,9 +3348,9 @@ void HistoryWidget::savedGifsGot(const MTPmessages_SavedGifs &gifs) {
|
||||||
_savedGifsUpdateRequest = 0;
|
_savedGifsUpdateRequest = 0;
|
||||||
|
|
||||||
if (gifs.type() != mtpc_messages_savedGifs) return;
|
if (gifs.type() != mtpc_messages_savedGifs) return;
|
||||||
const MTPDmessages_savedGifs &d(gifs.c_messages_savedGifs());
|
const auto &d(gifs.c_messages_savedGifs());
|
||||||
|
|
||||||
const QVector<MTPDocument> &d_gifs(d.vgifs.c_vector().v);
|
const auto &d_gifs(d.vgifs.c_vector().v);
|
||||||
|
|
||||||
SavedGifs &saved(cRefSavedGifs());
|
SavedGifs &saved(cRefSavedGifs());
|
||||||
saved.clear();
|
saved.clear();
|
||||||
|
@ -3387,7 +3387,7 @@ void HistoryWidget::saveGifDone(DocumentData *doc, const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::savedGifsFailed(const RPCError &error) {
|
bool HistoryWidget::savedGifsFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("App Fail: Failed to get saved gifs!"));
|
LOG(("App Fail: Failed to get saved gifs!"));
|
||||||
|
|
||||||
|
@ -3851,7 +3851,7 @@ void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequ
|
||||||
|
|
||||||
_reportSpamSettingRequestId = 0;
|
_reportSpamSettingRequestId = 0;
|
||||||
if (result.type() == mtpc_peerSettings) {
|
if (result.type() == mtpc_peerSettings) {
|
||||||
const MTPDpeerSettings &d(result.c_peerSettings());
|
const auto &d(result.c_peerSettings());
|
||||||
DBIPeerReportSpamStatus status = d.is_report_spam() ? dbiprsShowButton : dbiprsHidden;
|
DBIPeerReportSpamStatus status = d.is_report_spam() ? dbiprsShowButton : dbiprsHidden;
|
||||||
if (status != _reportSpamStatus) {
|
if (status != _reportSpamStatus) {
|
||||||
_reportSpamStatus = status;
|
_reportSpamStatus = status;
|
||||||
|
@ -3866,7 +3866,7 @@ void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::reportSpamSettingFail(const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::reportSpamSettingFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (req == _reportSpamSettingRequestId) {
|
if (req == _reportSpamSettingRequestId) {
|
||||||
req = 0;
|
req = 0;
|
||||||
|
@ -4166,7 +4166,7 @@ void HistoryWidget::historyCleared(History *history) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId) {
|
bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||||
PeerData *was = _peer;
|
PeerData *was = _peer;
|
||||||
|
@ -4206,21 +4206,21 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
|
||||||
const QVector<MTPMessageGroup> *histCollapsed = 0;
|
const QVector<MTPMessageGroup> *histCollapsed = 0;
|
||||||
switch (messages.type()) {
|
switch (messages.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(messages.c_messages_messages());
|
const auto &d(messages.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
histList = &d.vmessages.c_vector().v;
|
histList = &d.vmessages.c_vector().v;
|
||||||
count = histList->size();
|
count = histList->size();
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(messages.c_messages_messagesSlice());
|
const auto &d(messages.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
histList = &d.vmessages.c_vector().v;
|
histList = &d.vmessages.c_vector().v;
|
||||||
count = d.vcount.v;
|
count = d.vcount.v;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(messages.c_messages_channelMessages());
|
const auto &d(messages.c_messages_channelMessages());
|
||||||
if (peer && peer->isChannel()) {
|
if (peer && peer->isChannel()) {
|
||||||
peer->asChannel()->ptsReceived(d.vpts.v);
|
peer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4643,7 +4643,7 @@ void HistoryWidget::saveEditMsgDone(History *history, const MTPUpdates &updates,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
if (req == _saveEditMsgRequestId) {
|
if (req == _saveEditMsgRequestId) {
|
||||||
_saveEditMsgRequestId = 0;
|
_saveEditMsgRequestId = 0;
|
||||||
}
|
}
|
||||||
|
@ -4714,7 +4714,7 @@ void HistoryWidget::unblockDone(PeerData *peer, const MTPBool &result, mtpReques
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::unblockFail(const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::unblockFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_unblockRequest == req) _unblockRequest = 0;
|
if (_unblockRequest == req) _unblockRequest = 0;
|
||||||
return false;
|
return false;
|
||||||
|
@ -4768,7 +4768,7 @@ void HistoryWidget::joinDone(const MTPUpdates &result, mtpRequestId req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_unblockRequest == req) _unblockRequest = 0;
|
if (_unblockRequest == req) _unblockRequest = 0;
|
||||||
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||||
|
@ -5218,7 +5218,7 @@ void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button
|
||||||
|
|
||||||
void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req) {
|
void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req) {
|
||||||
if (HistoryItem *item = App::histItemById(info.msgId)) {
|
if (HistoryItem *item = App::histItemById(info.msgId)) {
|
||||||
if (auto *markup = item->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = item->Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (info.row < markup->rows.size() && info.col < markup->rows.at(info.row).size()) {
|
if (info.row < markup->rows.size() && info.col < markup->rows.at(info.row).size()) {
|
||||||
if (markup->rows.at(info.row).at(info.col).requestId == req) {
|
if (markup->rows.at(info.row).at(info.col).requestId == req) {
|
||||||
markup->rows.at(info.row).at(info.col).requestId = 0;
|
markup->rows.at(info.row).at(info.col).requestId = 0;
|
||||||
|
@ -5242,10 +5242,9 @@ void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotC
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::botCallbackFail(BotCallbackInfo info, const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::botCallbackFail(BotCallbackInfo info, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
// show error?
|
||||||
|
|
||||||
if (HistoryItem *item = App::histItemById(info.msgId)) {
|
if (HistoryItem *item = App::histItemById(info.msgId)) {
|
||||||
if (auto *markup = item->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = item->Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (info.row < markup->rows.size() && info.col < markup->rows.at(info.row).size()) {
|
if (info.row < markup->rows.size() && info.col < markup->rows.at(info.row).size()) {
|
||||||
if (markup->rows.at(info.row).at(info.col).requestId == req) {
|
if (markup->rows.at(info.row).at(info.col).requestId == req) {
|
||||||
markup->rows.at(info.row).at(info.col).requestId = 0;
|
markup->rows.at(info.row).at(info.col).requestId = 0;
|
||||||
|
@ -5254,7 +5253,6 @@ bool HistoryWidget::botCallbackFail(BotCallbackInfo info, const RPCError &error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5404,7 +5402,7 @@ void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result)
|
||||||
// Notify::inlineBotRequesting(false);
|
// Notify::inlineBotRequesting(false);
|
||||||
_inlineBotUsername = QString();
|
_inlineBotUsername = QString();
|
||||||
if (result.type() == mtpc_contacts_resolvedPeer) {
|
if (result.type() == mtpc_contacts_resolvedPeer) {
|
||||||
const MTPDcontacts_resolvedPeer &d(result.c_contacts_resolvedPeer());
|
const auto &d(result.c_contacts_resolvedPeer());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
}
|
}
|
||||||
|
@ -5412,7 +5410,7 @@ void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
|
bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_inlineBotResolveRequestId = 0;
|
_inlineBotResolveRequestId = 0;
|
||||||
// Notify::inlineBotRequesting(false);
|
// Notify::inlineBotRequesting(false);
|
||||||
|
@ -6141,7 +6139,7 @@ void HistoryWidget::reportSpamDone(PeerData *peer, const MTPBool &result, mtpReq
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::reportSpamFail(const RPCError &error, mtpRequestId req) {
|
bool HistoryWidget::reportSpamFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (req == _reportSpamRequest) {
|
if (req == _reportSpamRequest) {
|
||||||
_reportSpamRequest = 0;
|
_reportSpamRequest = 0;
|
||||||
|
|
|
@ -92,7 +92,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
const MTPBotInlineMessage *message = nullptr;
|
const MTPBotInlineMessage *message = nullptr;
|
||||||
switch (mtpData.type()) {
|
switch (mtpData.type()) {
|
||||||
case mtpc_botInlineResult: {
|
case mtpc_botInlineResult: {
|
||||||
const MTPDbotInlineResult &r(mtpData.c_botInlineResult());
|
const auto &r(mtpData.c_botInlineResult());
|
||||||
result->_id = qs(r.vid);
|
result->_id = qs(r.vid);
|
||||||
if (r.has_title()) result->_title = qs(r.vtitle);
|
if (r.has_title()) result->_title = qs(r.vtitle);
|
||||||
if (r.has_description()) result->_description = qs(r.vdescription);
|
if (r.has_description()) result->_description = qs(r.vdescription);
|
||||||
|
@ -109,7 +109,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
message = &r.vsend_message;
|
message = &r.vsend_message;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_botInlineMediaResult: {
|
case mtpc_botInlineMediaResult: {
|
||||||
const MTPDbotInlineMediaResult &r(mtpData.c_botInlineMediaResult());
|
const auto &r(mtpData.c_botInlineMediaResult());
|
||||||
result->_id = qs(r.vid);
|
result->_id = qs(r.vid);
|
||||||
if (r.has_title()) result->_title = qs(r.vtitle);
|
if (r.has_title()) result->_title = qs(r.vtitle);
|
||||||
if (r.has_description()) result->_description = qs(r.vdescription);
|
if (r.has_description()) result->_description = qs(r.vdescription);
|
||||||
|
@ -132,7 +132,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
|
|
||||||
switch (message->type()) {
|
switch (message->type()) {
|
||||||
case mtpc_botInlineMessageMediaAuto: {
|
case mtpc_botInlineMessageMediaAuto: {
|
||||||
const MTPDbotInlineMessageMediaAuto &r(message->c_botInlineMessageMediaAuto());
|
const auto &r(message->c_botInlineMessageMediaAuto());
|
||||||
if (result->_type == Type::Photo) {
|
if (result->_type == Type::Photo) {
|
||||||
result->sendData.reset(new internal::SendPhoto(result->_photo, result->_content_url, qs(r.vcaption)));
|
result->sendData.reset(new internal::SendPhoto(result->_photo, result->_content_url, qs(r.vcaption)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +144,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_botInlineMessageText: {
|
case mtpc_botInlineMessageText: {
|
||||||
const MTPDbotInlineMessageText &r(message->c_botInlineMessageText());
|
const auto &r(message->c_botInlineMessageText());
|
||||||
EntitiesInText entities = r.has_entities() ? entitiesFromMTP(r.ventities.c_vector().v) : EntitiesInText();
|
EntitiesInText entities = r.has_entities() ? entitiesFromMTP(r.ventities.c_vector().v) : EntitiesInText();
|
||||||
result->sendData.reset(new internal::SendText(qs(r.vmessage), entities, r.is_no_webpage()));
|
result->sendData.reset(new internal::SendText(qs(r.vmessage), entities, r.is_no_webpage()));
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
|
@ -153,7 +153,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_botInlineMessageMediaGeo: {
|
case mtpc_botInlineMessageMediaGeo: {
|
||||||
const MTPDbotInlineMessageMediaGeo &r(message->c_botInlineMessageMediaGeo());
|
const auto &r(message->c_botInlineMessageMediaGeo());
|
||||||
if (r.vgeo.type() == mtpc_geoPoint) {
|
if (r.vgeo.type() == mtpc_geoPoint) {
|
||||||
result->sendData.reset(new internal::SendGeo(r.vgeo.c_geoPoint()));
|
result->sendData.reset(new internal::SendGeo(r.vgeo.c_geoPoint()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,7 +165,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_botInlineMessageMediaVenue: {
|
case mtpc_botInlineMessageMediaVenue: {
|
||||||
const MTPDbotInlineMessageMediaVenue &r(message->c_botInlineMessageMediaVenue());
|
const auto &r(message->c_botInlineMessageMediaVenue());
|
||||||
if (r.vgeo.type() == mtpc_geoPoint) {
|
if (r.vgeo.type() == mtpc_geoPoint) {
|
||||||
result->sendData.reset(new internal::SendVenue(r.vgeo.c_geoPoint(), qs(r.vvenue_id), qs(r.vprovider), qs(r.vtitle), qs(r.vaddress)));
|
result->sendData.reset(new internal::SendVenue(r.vgeo.c_geoPoint(), qs(r.vvenue_id), qs(r.vprovider), qs(r.vtitle), qs(r.vaddress)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,7 +177,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_botInlineMessageMediaContact: {
|
case mtpc_botInlineMessageMediaContact: {
|
||||||
const MTPDbotInlineMessageMediaContact &r(message->c_botInlineMessageMediaContact());
|
const auto &r(message->c_botInlineMessageMediaContact());
|
||||||
result->sendData.reset(new internal::SendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
|
result->sendData.reset(new internal::SendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
|
|
|
@ -253,7 +253,7 @@ void IntroCode::codeSubmitDone(const MTPauth_Authorization &result) {
|
||||||
stopCheck();
|
stopCheck();
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
code.setDisabled(false);
|
code.setDisabled(false);
|
||||||
const MTPDauth_authorization &d(result.c_auth_authorization());
|
const auto &d(result.c_auth_authorization());
|
||||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||||
showError(lang(lng_server_error));
|
showError(lang(lng_server_error));
|
||||||
return;
|
return;
|
||||||
|
@ -263,31 +263,37 @@ void IntroCode::codeSubmitDone(const MTPauth_Authorization &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroCode::codeSubmitFail(const RPCError &error) {
|
bool IntroCode::codeSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
stopCheck();
|
||||||
|
sentRequest = 0;
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
code.setDisabled(false);
|
||||||
|
code.setFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
stopCheck();
|
stopCheck();
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
code.setDisabled(false);
|
code.setDisabled(false);
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PHONE_NUMBER_INVALID" || err == "PHONE_CODE_EXPIRED") { // show error
|
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error
|
||||||
intro()->onBack();
|
intro()->onBack();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PHONE_CODE_EMPTY" || err == "PHONE_CODE_INVALID") {
|
} else if (err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID")) {
|
||||||
showError(lang(lng_bad_code));
|
showError(lang(lng_bad_code));
|
||||||
code.notaBene();
|
code.notaBene();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PHONE_NUMBER_UNOCCUPIED") { // success, need to signUp
|
} else if (err == qstr("PHONE_NUMBER_UNOCCUPIED")) { // success, need to signUp
|
||||||
intro()->setCode(sentCode);
|
intro()->setCode(sentCode);
|
||||||
intro()->replaceStep(new IntroSignup(intro()));
|
intro()->replaceStep(new IntroSignup(intro()));
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "SESSION_PASSWORD_NEEDED") {
|
} else if (err == qstr("SESSION_PASSWORD_NEEDED")) {
|
||||||
intro()->setCode(sentCode);
|
intro()->setCode(sentCode);
|
||||||
code.setDisabled(false);
|
code.setDisabled(false);
|
||||||
checkRequest.start(1000);
|
checkRequest.start(1000);
|
||||||
sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&IntroCode::gotPassword), rpcFail(&IntroCode::codeSubmitFail));
|
sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&IntroCode::gotPassword), rpcFail(&IntroCode::codeSubmitFail));
|
||||||
return true;
|
return true;
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
showError(lang(lng_flood_error));
|
|
||||||
code.setFocus();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(err + ": " + error.description());
|
showError(err + ": " + error.description());
|
||||||
|
@ -334,7 +340,7 @@ void IntroCode::gotPassword(const MTPaccount_Password &result) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mtpc_account_password: {
|
case mtpc_account_password: {
|
||||||
const MTPDaccount_password &d(result.c_account_password());
|
const auto &d(result.c_account_password());
|
||||||
intro()->setPwdSalt(qba(d.vcurrent_salt));
|
intro()->setPwdSalt(qba(d.vcurrent_salt));
|
||||||
intro()->setHasRecovery(mtpIsTrue(d.vhas_recovery));
|
intro()->setHasRecovery(mtpIsTrue(d.vhas_recovery));
|
||||||
intro()->setPwdHint(qs(d.vhint));
|
intro()->setPwdHint(qs(d.vhint));
|
||||||
|
@ -371,7 +377,7 @@ void IntroCode::noTelegramCodeDone(const MTPauth_SentCode &result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDauth_sentCode &d(result.c_auth_sentCode());
|
const auto &d(result.c_auth_sentCode());
|
||||||
switch (d.vtype.type()) {
|
switch (d.vtype.type()) {
|
||||||
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true);
|
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true);
|
||||||
case mtpc_auth_sentCodeTypeSms:
|
case mtpc_auth_sentCodeTypeSms:
|
||||||
|
@ -388,11 +394,13 @@ void IntroCode::noTelegramCodeDone(const MTPauth_SentCode &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroCode::noTelegramCodeFail(const RPCError &error) {
|
bool IntroCode::noTelegramCodeFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) {
|
if (MTP::isFloodError(error)) {
|
||||||
showError(lang(lng_flood_error));
|
showError(lang(lng_flood_error));
|
||||||
code.setFocus();
|
code.setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(error.type() + ": " + error.description());
|
showError(error.type() + ": " + error.description());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -222,7 +222,7 @@ void IntroPhone::onCheckRequest() {
|
||||||
void IntroPhone::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
void IntroPhone::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||||
stopCheck();
|
stopCheck();
|
||||||
|
|
||||||
const MTPDauth_checkedPhone &d(result.c_auth_checkedPhone());
|
const auto &d(result.c_auth_checkedPhone());
|
||||||
if (mtpIsTrue(d.vphone_registered)) {
|
if (mtpIsTrue(d.vphone_registered)) {
|
||||||
disableAll();
|
disableAll();
|
||||||
showError(QString());
|
showError(QString());
|
||||||
|
@ -248,7 +248,7 @@ void IntroPhone::phoneSubmitDone(const MTPauth_SentCode &result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDauth_sentCode &d(result.c_auth_sentCode());
|
const auto &d(result.c_auth_sentCode());
|
||||||
switch (d.vtype.type()) {
|
switch (d.vtype.type()) {
|
||||||
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true); break;
|
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true); break;
|
||||||
case mtpc_auth_sentCodeTypeSms:
|
case mtpc_auth_sentCodeTypeSms:
|
||||||
|
@ -275,17 +275,22 @@ void IntroPhone::toSignUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroPhone::phoneSubmitFail(const RPCError &error) {
|
bool IntroPhone::phoneSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
stopCheck();
|
||||||
|
sentRequest = 0;
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
enableAll(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
stopCheck();
|
stopCheck();
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PHONE_NUMBER_INVALID") { // show error
|
if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
|
||||||
showError(lang(lng_bad_phone));
|
showError(lang(lng_bad_phone));
|
||||||
enableAll(true);
|
enableAll(true);
|
||||||
return true;
|
return true;
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
showError(lang(lng_flood_error));
|
|
||||||
enableAll(true);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(err + ": " + error.description());
|
showError(err + ": " + error.description());
|
||||||
|
|
|
@ -185,7 +185,7 @@ void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &res
|
||||||
}
|
}
|
||||||
_pwdField.setDisabled(false);
|
_pwdField.setDisabled(false);
|
||||||
_codeField.setDisabled(false);
|
_codeField.setDisabled(false);
|
||||||
const MTPDauth_authorization &d(result.c_auth_authorization());
|
const auto &d(result.c_auth_authorization());
|
||||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||||
showError(lang(lng_server_error));
|
showError(lang(lng_server_error));
|
||||||
return;
|
return;
|
||||||
|
@ -194,22 +194,29 @@ void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &res
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
sentRequest = 0;
|
||||||
|
stopCheck();
|
||||||
|
_codeField.setDisabled(false);
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
_pwdField.setDisabled(false);
|
||||||
|
_pwdField.notaBene();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
stopCheck();
|
stopCheck();
|
||||||
_pwdField.setDisabled(false);
|
_pwdField.setDisabled(false);
|
||||||
_codeField.setDisabled(false);
|
_codeField.setDisabled(false);
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PASSWORD_HASH_INVALID") {
|
if (err == qstr("PASSWORD_HASH_INVALID")) {
|
||||||
showError(lang(lng_signin_bad_password));
|
showError(lang(lng_signin_bad_password));
|
||||||
_pwdField.selectAll();
|
_pwdField.selectAll();
|
||||||
_pwdField.notaBene();
|
_pwdField.notaBene();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PASSWORD_EMPTY") {
|
} else if (err == qstr("PASSWORD_EMPTY")) {
|
||||||
intro()->onBack();
|
intro()->onBack();
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
showError(lang(lng_flood_error));
|
|
||||||
_pwdField.notaBene();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(err + ": " + error.description());
|
showError(err + ": " + error.description());
|
||||||
|
@ -221,30 +228,33 @@ bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
|
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
_codeField.notaBene();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
stopCheck();
|
stopCheck();
|
||||||
_pwdField.setDisabled(false);
|
_pwdField.setDisabled(false);
|
||||||
_codeField.setDisabled(false);
|
_codeField.setDisabled(false);
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PASSWORD_EMPTY") {
|
if (err == qstr("PASSWORD_EMPTY")) {
|
||||||
intro()->onBack();
|
intro()->onBack();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PASSWORD_RECOVERY_NA") {
|
} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
|
||||||
recoverStartFail(error);
|
recoverStartFail(error);
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "PASSWORD_RECOVERY_EXPIRED") {
|
} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
|
||||||
_emailPattern = QString();
|
_emailPattern = QString();
|
||||||
onToPassword();
|
onToPassword();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "CODE_INVALID") {
|
} else if (err == qstr("CODE_INVALID")) {
|
||||||
showError(lang(lng_signin_wrong_code));
|
showError(lang(lng_signin_wrong_code));
|
||||||
_codeField.selectAll();
|
_codeField.selectAll();
|
||||||
_codeField.notaBene();
|
_codeField.notaBene();
|
||||||
return true;
|
return true;
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
showError(lang(lng_flood_error));
|
|
||||||
_codeField.notaBene();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(err + ": " + error.description());
|
showError(err + ": " + error.description());
|
||||||
|
@ -330,7 +340,8 @@ void IntroPwdCheck::onResetSure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroPwdCheck::deleteFail(const RPCError &error) {
|
bool IntroPwdCheck::deleteFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
sentRequest = 0;
|
sentRequest = 0;
|
||||||
showError(lang(lng_server_error));
|
showError(lang(lng_server_error));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -252,7 +252,7 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
|
||||||
stopCheck();
|
stopCheck();
|
||||||
first.setDisabled(false);
|
first.setDisabled(false);
|
||||||
last.setDisabled(false);
|
last.setDisabled(false);
|
||||||
const MTPDauth_authorization &d(result.c_auth_authorization());
|
const auto &d(result.c_auth_authorization());
|
||||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||||
showError(lang(lng_server_error));
|
showError(lang(lng_server_error));
|
||||||
return;
|
return;
|
||||||
|
@ -261,11 +261,27 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntroSignup::nameSubmitFail(const RPCError &error) {
|
bool IntroSignup::nameSubmitFail(const RPCError &error) {
|
||||||
|
if (MTP::isFloodError(error)) {
|
||||||
|
stopCheck();
|
||||||
|
first.setDisabled(false);
|
||||||
|
last.setDisabled(false);
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
if (_invertOrder) {
|
||||||
|
first.setFocus();
|
||||||
|
} else {
|
||||||
|
last.setFocus();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
stopCheck();
|
stopCheck();
|
||||||
first.setDisabled(false);
|
first.setDisabled(false);
|
||||||
last.setDisabled(false);
|
last.setDisabled(false);
|
||||||
const QString &err = error.type();
|
const QString &err = error.type();
|
||||||
if (err == "PHONE_NUMBER_INVALID" || err == "PHONE_CODE_EXPIRED" || err == "PHONE_CODE_EMPTY" || err == "PHONE_CODE_INVALID" || err == "PHONE_NUMBER_OCCUPIED") {
|
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED") ||
|
||||||
|
err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID") ||
|
||||||
|
err == qstr("PHONE_NUMBER_OCCUPIED")) {
|
||||||
intro()->onBack();
|
intro()->onBack();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "FIRSTNAME_INVALID") {
|
} else if (err == "FIRSTNAME_INVALID") {
|
||||||
|
@ -276,14 +292,6 @@ bool IntroSignup::nameSubmitFail(const RPCError &error) {
|
||||||
showError(lang(lng_bad_name));
|
showError(lang(lng_bad_name));
|
||||||
last.setFocus();
|
last.setFocus();
|
||||||
return true;
|
return true;
|
||||||
} else if (mtpIsFlood(error)) {
|
|
||||||
showError(lang(lng_flood_error));
|
|
||||||
if (_invertOrder) {
|
|
||||||
first.setFocus();
|
|
||||||
} else {
|
|
||||||
last.setFocus();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (cDebug()) { // internal server error
|
if (cDebug()) { // internal server error
|
||||||
showError(err + ": " + error.description());
|
showError(err + ": " + error.description());
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
||||||
IntroWidget *signalEmitOn = 0;
|
IntroWidget *signalEmitOn = 0;
|
||||||
QString countryForReg;
|
QString countryForReg;
|
||||||
void gotNearestDC(const MTPNearestDc &result) {
|
void gotNearestDC(const MTPNearestDc &result) {
|
||||||
const MTPDnearestDc &nearest(result.c_nearestDc());
|
const auto &nearest(result.c_nearestDc());
|
||||||
DEBUG_LOG(("Got nearest dc, country: %1, nearest: %2, this: %3").arg(nearest.vcountry.c_string().v.c_str()).arg(nearest.vnearest_dc.v).arg(nearest.vthis_dc.v));
|
DEBUG_LOG(("Got nearest dc, country: %1, nearest: %2, this: %3").arg(nearest.vcountry.c_string().v.c_str()).arg(nearest.vnearest_dc.v).arg(nearest.vthis_dc.v));
|
||||||
MTP::setdc(result.c_nearestDc().vnearest_dc.v, true);
|
MTP::setdc(result.c_nearestDc().vnearest_dc.v, true);
|
||||||
if (countryForReg != nearest.vcountry.c_string().v.c_str()) {
|
if (countryForReg != nearest.vcountry.c_string().v.c_str()) {
|
||||||
|
|
|
@ -965,7 +965,7 @@ DragState MainWidget::getDragState(const QMimeData *mime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::leaveChatFailed(PeerData *peer, const RPCError &error) {
|
bool MainWidget::leaveChatFailed(PeerData *peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.type() == qstr("USER_NOT_PARTICIPANT") || error.type() == qstr("CHAT_ID_INVALID") || error.type() == qstr("PEER_ID_INVALID")) { // left this chat already
|
if (error.type() == qstr("USER_NOT_PARTICIPANT") || error.type() == qstr("CHAT_ID_INVALID") || error.type() == qstr("PEER_ID_INVALID")) { // left this chat already
|
||||||
deleteConversation(peer);
|
deleteConversation(peer);
|
||||||
|
@ -980,7 +980,7 @@ void MainWidget::deleteHistoryAfterLeave(PeerData *peer, const MTPUpdates &updat
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::deleteHistoryPart(PeerData *peer, const MTPmessages_AffectedHistory &result) {
|
void MainWidget::deleteHistoryPart(PeerData *peer, const MTPmessages_AffectedHistory &result) {
|
||||||
const MTPDmessages_affectedHistory &d(result.c_messages_affectedHistory());
|
const auto &d(result.c_messages_affectedHistory());
|
||||||
if (peer && peer->isChannel()) {
|
if (peer && peer->isChannel()) {
|
||||||
if (peer->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
if (peer->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
||||||
peer->asChannel()->ptsApplySkippedUpdates();
|
peer->asChannel()->ptsApplySkippedUpdates();
|
||||||
|
@ -1013,7 +1013,7 @@ void MainWidget::deleteMessages(PeerData *peer, const QVector<MTPint> &ids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::deletedContact(UserData *user, const MTPcontacts_Link &result) {
|
void MainWidget::deletedContact(UserData *user, const MTPcontacts_Link &result) {
|
||||||
const MTPDcontacts_link &d(result.c_contacts_link());
|
const auto &d(result.c_contacts_link());
|
||||||
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
|
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
|
||||||
App::feedUserLink(MTP_int(peerToUser(user->id)), d.vmy_link, d.vforeign_link, false);
|
App::feedUserLink(MTP_int(peerToUser(user->id)), d.vmy_link, d.vforeign_link, false);
|
||||||
App::emitPeerUpdated();
|
App::emitPeerUpdated();
|
||||||
|
@ -1075,7 +1075,7 @@ void MainWidget::deleteAllFromUser(ChannelData *channel, UserData *from) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::deleteAllFromUserPart(DeleteAllFromUserParams params, const MTPmessages_AffectedHistory &result) {
|
void MainWidget::deleteAllFromUserPart(DeleteAllFromUserParams params, const MTPmessages_AffectedHistory &result) {
|
||||||
const MTPDmessages_affectedHistory &d(result.c_messages_affectedHistory());
|
const auto &d(result.c_messages_affectedHistory());
|
||||||
if (params.channel->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
if (params.channel->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
||||||
params.channel->ptsApplySkippedUpdates();
|
params.channel->ptsApplySkippedUpdates();
|
||||||
App::emitPeerUpdated();
|
App::emitPeerUpdated();
|
||||||
|
@ -1126,19 +1126,19 @@ void MainWidget::addParticipants(PeerData *chatOrChannel, const QVector<UserData
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
|
bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
QString text = lang(lng_failed_add_participant);
|
QString text = lang(lng_failed_add_participant);
|
||||||
if (error.type() == "USER_LEFT_CHAT") { // trying to return a user who has left
|
if (error.type() == qstr("USER_LEFT_CHAT")) { // trying to return a user who has left
|
||||||
} else if (error.type() == "USER_KICKED") { // trying to return a user who was kicked by admin
|
} else if (error.type() == qstr("USER_KICKED")) { // trying to return a user who was kicked by admin
|
||||||
text = lang(lng_cant_invite_banned);
|
text = lang(lng_cant_invite_banned);
|
||||||
} else if (error.type() == "USER_PRIVACY_RESTRICTED") {
|
} else if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) {
|
||||||
text = lang(lng_cant_invite_privacy);
|
text = lang(lng_cant_invite_privacy);
|
||||||
} else if (error.type() == "USER_NOT_MUTUAL_CONTACT") { // trying to return user who does not have me in contacts
|
} else if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) { // trying to return user who does not have me in contacts
|
||||||
text = lang(lng_failed_add_not_mutual);
|
text = lang(lng_failed_add_not_mutual);
|
||||||
} else if (error.type() == "USER_ALREADY_PARTICIPANT" && user->botInfo) {
|
} else if (error.type() == qstr("USER_ALREADY_PARTICIPANT") && user->botInfo) {
|
||||||
text = lang(lng_bot_already_in_group);
|
text = lang(lng_bot_already_in_group);
|
||||||
} else if (error.type() == "PEER_FLOOD") {
|
} else if (error.type() == qstr("PEER_FLOOD")) {
|
||||||
text = cantInviteError();
|
text = cantInviteError();
|
||||||
}
|
}
|
||||||
Ui::showLayer(new InformBox(text));
|
Ui::showLayer(new InformBox(text));
|
||||||
|
@ -1146,17 +1146,17 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error) {
|
bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
QString text = lang(lng_failed_add_participant);
|
QString text = lang(lng_failed_add_participant);
|
||||||
if (error.type() == "USER_LEFT_CHAT") { // trying to return banned user to his group
|
if (error.type() == qstr("USER_LEFT_CHAT")) { // trying to return banned user to his group
|
||||||
} else if (error.type() == "USER_KICKED") { // trying to return a user who was kicked by admin
|
} else if (error.type() == qstr("USER_KICKED")) { // trying to return a user who was kicked by admin
|
||||||
text = lang(lng_cant_invite_banned);
|
text = lang(lng_cant_invite_banned);
|
||||||
} else if (error.type() == "USER_PRIVACY_RESTRICTED") {
|
} else if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) {
|
||||||
text = lang(channel->isMegagroup() ? lng_cant_invite_privacy : lng_cant_invite_privacy_channel);
|
text = lang(channel->isMegagroup() ? lng_cant_invite_privacy : lng_cant_invite_privacy_channel);
|
||||||
} else if (error.type() == "USER_NOT_MUTUAL_CONTACT") { // trying to return user who does not have me in contacts
|
} else if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) { // trying to return user who does not have me in contacts
|
||||||
text = lang(channel->isMegagroup() ? lng_failed_add_not_mutual : lng_failed_add_not_mutual_channel);
|
text = lang(channel->isMegagroup() ? lng_failed_add_not_mutual : lng_failed_add_not_mutual_channel);
|
||||||
} else if (error.type() == "PEER_FLOOD") {
|
} else if (error.type() == qstr("PEER_FLOOD")) {
|
||||||
text = cantInviteError();
|
text = cantInviteError();
|
||||||
}
|
}
|
||||||
Ui::showLayer(new InformBox(text));
|
Ui::showLayer(new InformBox(text));
|
||||||
|
@ -1170,7 +1170,7 @@ void MainWidget::kickParticipant(ChatData *chat, UserData *user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
|
bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
error.type();
|
error.type();
|
||||||
return false;
|
return false;
|
||||||
|
@ -1189,21 +1189,21 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
|
||||||
const QVector<MTPMessageGroup> *collapsed = 0;
|
const QVector<MTPMessageGroup> *collapsed = 0;
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(result.c_messages_messages());
|
const auto &d(result.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
v = &d.vmessages.c_vector().v;
|
v = &d.vmessages.c_vector().v;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
|
const auto &d(result.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
v = &d.vmessages.c_vector().v;
|
v = &d.vmessages.c_vector().v;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
|
const auto &d(result.c_messages_channelMessages());
|
||||||
if (peer && peer->isChannel()) {
|
if (peer && peer->isChannel()) {
|
||||||
peer->asChannel()->ptsReceived(d.vpts.v);
|
peer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1261,9 +1261,9 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::sendMessageFail(const RPCError &error) {
|
bool MainWidget::sendMessageFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.type() == qsl("PEER_FLOOD")) {
|
if (error.type() == qstr("PEER_FLOOD")) {
|
||||||
Ui::showLayer(new InformBox(cantInviteError()));
|
Ui::showLayer(new InformBox(cantInviteError()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1639,7 +1639,7 @@ void MainWidget::itemEdited(HistoryItem *item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) {
|
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
MediaOverviewType type = OverviewCount;
|
MediaOverviewType type = OverviewCount;
|
||||||
for (int32 i = 0; i < OverviewCount; ++i) {
|
for (int32 i = 0; i < OverviewCount; ++i) {
|
||||||
|
@ -1732,7 +1732,7 @@ void MainWidget::historyWasRead(PeerData *peer, const MTPmessages_AffectedMessag
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::readRequestFail(PeerData *peer, const RPCError &error) {
|
bool MainWidget::readRequestFail(PeerData *peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
readRequestDone(peer);
|
readRequestDone(peer);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1748,7 +1748,7 @@ void MainWidget::readRequestDone(PeerData *peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::messagesAffected(PeerData *peer, const MTPmessages_AffectedMessages &result) {
|
void MainWidget::messagesAffected(PeerData *peer, const MTPmessages_AffectedMessages &result) {
|
||||||
const MTPDmessages_affectedMessages &d(result.c_messages_affectedMessages());
|
const auto &d(result.c_messages_affectedMessages());
|
||||||
if (peer && peer->isChannel()) {
|
if (peer && peer->isChannel()) {
|
||||||
if (peer->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
if (peer->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
|
||||||
peer->asChannel()->ptsApplySkippedUpdates();
|
peer->asChannel()->ptsApplySkippedUpdates();
|
||||||
|
@ -2012,21 +2012,21 @@ void MainWidget::serviceNotification(const QString &msg, const MTPMessageMedia &
|
||||||
void MainWidget::serviceHistoryDone(const MTPmessages_Messages &msgs) {
|
void MainWidget::serviceHistoryDone(const MTPmessages_Messages &msgs) {
|
||||||
switch (msgs.type()) {
|
switch (msgs.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(msgs.c_messages_messages());
|
const auto &d(msgs.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
App::feedMsgs(d.vmessages, NewMessageLast);
|
App::feedMsgs(d.vmessages, NewMessageLast);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
|
const auto &d(msgs.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
App::feedMsgs(d.vmessages, NewMessageLast);
|
App::feedMsgs(d.vmessages, NewMessageLast);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
|
const auto &d(msgs.c_messages_channelMessages());
|
||||||
LOG(("API Error: received messages.channelMessages! (MainWidget::serviceHistoryDone)"));
|
LOG(("API Error: received messages.channelMessages! (MainWidget::serviceHistoryDone)"));
|
||||||
if (d.has_collapsed()) { // should not be returned
|
if (d.has_collapsed()) { // should not be returned
|
||||||
LOG(("API Error: channels.getMessages and messages.getMessages should not return collapsed groups! (MainWidget::serviceHistoryDone)"));
|
LOG(("API Error: channels.getMessages and messages.getMessages should not return collapsed groups! (MainWidget::serviceHistoryDone)"));
|
||||||
|
@ -2042,7 +2042,7 @@ void MainWidget::serviceHistoryDone(const MTPmessages_Messages &msgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::serviceHistoryFail(const RPCError &error) {
|
bool MainWidget::serviceHistoryFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
App::wnd()->showDelayedServiceMsgs();
|
App::wnd()->showDelayedServiceMsgs();
|
||||||
return false;
|
return false;
|
||||||
|
@ -2205,7 +2205,7 @@ void MainWidget::onViewsIncrement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req) {
|
void MainWidget::viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req) {
|
||||||
const QVector<MTPint> &v(result.c_vector().v);
|
const auto &v(result.c_vector().v);
|
||||||
if (ids.size() == v.size()) {
|
if (ids.size() == v.size()) {
|
||||||
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
|
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
|
||||||
if (i.value() == req) {
|
if (i.value() == req) {
|
||||||
|
@ -2227,7 +2227,7 @@ void MainWidget::viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint>
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::viewsIncrementFail(const RPCError &error, mtpRequestId req) {
|
bool MainWidget::viewsIncrementFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
|
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
|
||||||
if (i.value() == req) {
|
if (i.value() == req) {
|
||||||
|
@ -2641,7 +2641,7 @@ void MainWidget::sentUpdatesReceived(uint64 randomId, const MTPUpdates &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::deleteChannelFailed(const RPCError &error) {
|
bool MainWidget::deleteChannelFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
//if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
|
//if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
|
||||||
// Ui::showLayer(new InformBox(lang(lng_cant_delete_channel)));
|
// Ui::showLayer(new InformBox(lang(lng_cant_delete_channel)));
|
||||||
|
@ -2982,7 +2982,7 @@ void MainWidget::onUpdateNotifySettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::feedUpdateVector(const MTPVector<MTPUpdate> &updates, bool skipMessageIds) {
|
void MainWidget::feedUpdateVector(const MTPVector<MTPUpdate> &updates, bool skipMessageIds) {
|
||||||
const QVector<MTPUpdate> &v(updates.c_vector().v);
|
const auto &v(updates.c_vector().v);
|
||||||
for (QVector<MTPUpdate>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
for (QVector<MTPUpdate>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
||||||
if (skipMessageIds && i->type() == mtpc_updateMessageID) continue;
|
if (skipMessageIds && i->type() == mtpc_updateMessageID) continue;
|
||||||
feedUpdate(*i);
|
feedUpdate(*i);
|
||||||
|
@ -2990,7 +2990,7 @@ void MainWidget::feedUpdateVector(const MTPVector<MTPUpdate> &updates, bool skip
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::feedMessageIds(const MTPVector<MTPUpdate> &updates) {
|
void MainWidget::feedMessageIds(const MTPVector<MTPUpdate> &updates) {
|
||||||
const QVector<MTPUpdate> &v(updates.c_vector().v);
|
const auto &v(updates.c_vector().v);
|
||||||
for (QVector<MTPUpdate>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
for (QVector<MTPUpdate>::const_iterator i = v.cbegin(), e = v.cend(); i != e; ++i) {
|
||||||
if (i->type() == mtpc_updateMessageID) {
|
if (i->type() == mtpc_updateMessageID) {
|
||||||
feedUpdate(*i);
|
feedUpdate(*i);
|
||||||
|
@ -3039,14 +3039,14 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
|
||||||
bool isFinal = true;
|
bool isFinal = true;
|
||||||
switch (diff.type()) {
|
switch (diff.type()) {
|
||||||
case mtpc_updates_channelDifferenceEmpty: {
|
case mtpc_updates_channelDifferenceEmpty: {
|
||||||
const MTPDupdates_channelDifferenceEmpty &d(diff.c_updates_channelDifferenceEmpty());
|
const auto &d(diff.c_updates_channelDifferenceEmpty());
|
||||||
if (d.has_timeout()) timeout = d.vtimeout.v;
|
if (d.has_timeout()) timeout = d.vtimeout.v;
|
||||||
isFinal = d.is_final();
|
isFinal = d.is_final();
|
||||||
channel->ptsInit(d.vpts.v);
|
channel->ptsInit(d.vpts.v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updates_channelDifferenceTooLong: {
|
case mtpc_updates_channelDifferenceTooLong: {
|
||||||
const MTPDupdates_channelDifferenceTooLong &d(diff.c_updates_channelDifferenceTooLong());
|
const auto &d(diff.c_updates_channelDifferenceTooLong());
|
||||||
|
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
|
@ -3083,7 +3083,7 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updates_channelDifference: {
|
case mtpc_updates_channelDifference: {
|
||||||
const MTPDupdates_channelDifference &d(diff.c_updates_channelDifference());
|
const auto &d(diff.c_updates_channelDifference());
|
||||||
|
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats, false);
|
App::feedChats(d.vchats, false);
|
||||||
|
@ -3093,13 +3093,13 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
|
||||||
|
|
||||||
// feed messages and groups, copy from App::feedMsgs
|
// feed messages and groups, copy from App::feedMsgs
|
||||||
History *h = App::history(channel->id);
|
History *h = App::history(channel->id);
|
||||||
const QVector<MTPMessage> &vmsgs(d.vnew_messages.c_vector().v);
|
const auto &vmsgs(d.vnew_messages.c_vector().v);
|
||||||
QMap<uint64, int32> msgsIds;
|
QMap<uint64, int32> msgsIds;
|
||||||
for (int32 i = 0, l = vmsgs.size(); i < l; ++i) {
|
for (int32 i = 0, l = vmsgs.size(); i < l; ++i) {
|
||||||
const MTPMessage &msg(vmsgs.at(i));
|
const auto &msg(vmsgs.at(i));
|
||||||
switch (msg.type()) {
|
switch (msg.type()) {
|
||||||
case mtpc_message: {
|
case mtpc_message: {
|
||||||
const MTPDmessage &d(msg.c_message());
|
const auto &d(msg.c_message());
|
||||||
if (App::checkEntitiesAndViewsUpdate(d)) { // new message, index my forwarded messages to links overview, already in blocks
|
if (App::checkEntitiesAndViewsUpdate(d)) { // new message, index my forwarded messages to links overview, already in blocks
|
||||||
LOG(("Skipping message, because it is already in blocks!"));
|
LOG(("Skipping message, because it is already in blocks!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -3110,12 +3110,12 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
|
||||||
case mtpc_messageService: msgsIds.insert((uint64(uint32(msg.c_messageService().vid.v)) << 32) | uint64(i), i + 1); break;
|
case mtpc_messageService: msgsIds.insert((uint64(uint32(msg.c_messageService().vid.v)) << 32) | uint64(i), i + 1); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const QVector<MTPUpdate> &vother(d.vother_updates.c_vector().v);
|
const auto &vother(d.vother_updates.c_vector().v);
|
||||||
for (int32 i = 0, l = vother.size(); i < l; ++i) {
|
for (int32 i = 0, l = vother.size(); i < l; ++i) {
|
||||||
if (vother.at(i).type() == mtpc_updateChannelGroup) {
|
if (vother.at(i).type() == mtpc_updateChannelGroup) {
|
||||||
const MTPDupdateChannelGroup &updateGroup(vother.at(i).c_updateChannelGroup());
|
const auto &updateGroup(vother.at(i).c_updateChannelGroup());
|
||||||
if (updateGroup.vgroup.type() == mtpc_messageGroup) {
|
if (updateGroup.vgroup.type() == mtpc_messageGroup) {
|
||||||
const MTPDmessageGroup &group(updateGroup.vgroup.c_messageGroup());
|
const auto &group(updateGroup.vgroup.c_messageGroup());
|
||||||
if (updateGroup.vchannel_id.v != peerToChannel(channel->id)) {
|
if (updateGroup.vchannel_id.v != peerToChannel(channel->id)) {
|
||||||
LOG(("API Error: updateChannelGroup with invalid channel_id returned in channelDifference, channelId: %1, channel_id: %2").arg(peerToChannel(channel->id)).arg(updateGroup.vchannel_id.v));
|
LOG(("API Error: updateChannelGroup with invalid channel_id returned in channelDifference, channelId: %1, channel_id: %2").arg(peerToChannel(channel->id)).arg(updateGroup.vchannel_id.v));
|
||||||
continue;
|
continue;
|
||||||
|
@ -3126,14 +3126,14 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
|
||||||
}
|
}
|
||||||
for (QMap<uint64, int32>::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) {
|
for (QMap<uint64, int32>::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) {
|
||||||
if (i.value() > 0) { // add message
|
if (i.value() > 0) { // add message
|
||||||
const MTPMessage &msg(vmsgs.at(i.value() - 1));
|
const auto &msg(vmsgs.at(i.value() - 1));
|
||||||
if (channel->id != peerFromMessage(msg)) {
|
if (channel->id != peerFromMessage(msg)) {
|
||||||
LOG(("API Error: message with invalid peer returned in channelDifference, channelId: %1, peer: %2").arg(peerToChannel(channel->id)).arg(peerFromMessage(msg)));
|
LOG(("API Error: message with invalid peer returned in channelDifference, channelId: %1, peer: %2").arg(peerToChannel(channel->id)).arg(peerFromMessage(msg)));
|
||||||
continue; // wtf
|
continue; // wtf
|
||||||
}
|
}
|
||||||
h->addNewMessage(msg, NewMessageUnread);
|
h->addNewMessage(msg, NewMessageUnread);
|
||||||
} else { // add group
|
} else { // add group
|
||||||
const MTPDupdateChannelGroup &updateGroup(vother.at(-i.value() - 1).c_updateChannelGroup());
|
const auto &updateGroup(vother.at(-i.value() - 1).c_updateChannelGroup());
|
||||||
h->asChannelHistory()->addNewGroup(updateGroup.vgroup);
|
h->asChannelHistory()->addNewGroup(updateGroup.vgroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3164,13 +3164,13 @@ void MainWidget::gotRangeDifference(ChannelData *channel, const MTPupdates_Chann
|
||||||
bool isFinal = true;
|
bool isFinal = true;
|
||||||
switch (diff.type()) {
|
switch (diff.type()) {
|
||||||
case mtpc_updates_channelDifferenceEmpty: {
|
case mtpc_updates_channelDifferenceEmpty: {
|
||||||
const MTPDupdates_channelDifferenceEmpty &d(diff.c_updates_channelDifferenceEmpty());
|
const auto &d(diff.c_updates_channelDifferenceEmpty());
|
||||||
nextRequestPts = d.vpts.v;
|
nextRequestPts = d.vpts.v;
|
||||||
isFinal = d.is_final();
|
isFinal = d.is_final();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updates_channelDifferenceTooLong: {
|
case mtpc_updates_channelDifferenceTooLong: {
|
||||||
const MTPDupdates_channelDifferenceTooLong &d(diff.c_updates_channelDifferenceTooLong());
|
const auto &d(diff.c_updates_channelDifferenceTooLong());
|
||||||
|
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
|
@ -3180,7 +3180,7 @@ void MainWidget::gotRangeDifference(ChannelData *channel, const MTPupdates_Chann
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updates_channelDifference: {
|
case mtpc_updates_channelDifference: {
|
||||||
const MTPDupdates_channelDifference &d(diff.c_updates_channelDifference());
|
const auto &d(diff.c_updates_channelDifference());
|
||||||
|
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats, false);
|
App::feedChats(d.vchats, false);
|
||||||
|
@ -3207,7 +3207,7 @@ void MainWidget::gotRangeDifference(ChannelData *channel, const MTPupdates_Chann
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::failChannelDifference(ChannelData *channel, const RPCError &error) {
|
bool MainWidget::failChannelDifference(ChannelData *channel, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("RPC Error in getChannelDifference: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
LOG(("RPC Error in getChannelDifference: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
||||||
failDifferenceStartTimerFor(channel);
|
failDifferenceStartTimerFor(channel);
|
||||||
|
@ -3215,7 +3215,7 @@ bool MainWidget::failChannelDifference(ChannelData *channel, const RPCError &err
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::gotState(const MTPupdates_State &state) {
|
void MainWidget::gotState(const MTPupdates_State &state) {
|
||||||
const MTPDupdates_state &d(state.c_updates_state());
|
const auto &d(state.c_updates_state());
|
||||||
updSetState(d.vpts.v, d.vdate.v, d.vqts.v, d.vseq.v);
|
updSetState(d.vpts.v, d.vdate.v, d.vqts.v, d.vseq.v);
|
||||||
|
|
||||||
_lastUpdateTime = getms(true);
|
_lastUpdateTime = getms(true);
|
||||||
|
@ -3233,7 +3233,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
|
||||||
|
|
||||||
switch (diff.type()) {
|
switch (diff.type()) {
|
||||||
case mtpc_updates_differenceEmpty: {
|
case mtpc_updates_differenceEmpty: {
|
||||||
const MTPDupdates_differenceEmpty &d(diff.c_updates_differenceEmpty());
|
const auto &d(diff.c_updates_differenceEmpty());
|
||||||
updSetState(_ptsWaiter.current(), d.vdate.v, updQts, d.vseq.v);
|
updSetState(_ptsWaiter.current(), d.vdate.v, updQts, d.vseq.v);
|
||||||
|
|
||||||
_lastUpdateTime = getms(true);
|
_lastUpdateTime = getms(true);
|
||||||
|
@ -3244,10 +3244,10 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
|
||||||
App::emitPeerUpdated();
|
App::emitPeerUpdated();
|
||||||
} break;
|
} break;
|
||||||
case mtpc_updates_differenceSlice: {
|
case mtpc_updates_differenceSlice: {
|
||||||
const MTPDupdates_differenceSlice &d(diff.c_updates_differenceSlice());
|
const auto &d(diff.c_updates_differenceSlice());
|
||||||
feedDifference(d.vusers, d.vchats, d.vnew_messages, d.vother_updates);
|
feedDifference(d.vusers, d.vchats, d.vnew_messages, d.vother_updates);
|
||||||
|
|
||||||
const MTPDupdates_state &s(d.vintermediate_state.c_updates_state());
|
const auto &s(d.vintermediate_state.c_updates_state());
|
||||||
updSetState(s.vpts.v, s.vdate.v, s.vqts.v, s.vseq.v);
|
updSetState(s.vpts.v, s.vdate.v, s.vqts.v, s.vseq.v);
|
||||||
|
|
||||||
_ptsWaiter.setRequesting(false);
|
_ptsWaiter.setRequesting(false);
|
||||||
|
@ -3258,7 +3258,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
|
||||||
App::emitPeerUpdated();
|
App::emitPeerUpdated();
|
||||||
} break;
|
} break;
|
||||||
case mtpc_updates_difference: {
|
case mtpc_updates_difference: {
|
||||||
const MTPDupdates_difference &d(diff.c_updates_difference());
|
const auto &d(diff.c_updates_difference());
|
||||||
feedDifference(d.vusers, d.vchats, d.vnew_messages, d.vother_updates);
|
feedDifference(d.vusers, d.vchats, d.vnew_messages, d.vother_updates);
|
||||||
|
|
||||||
gotState(d.vstate);
|
gotState(d.vstate);
|
||||||
|
@ -3362,7 +3362,7 @@ void MainWidget::feedDifference(const MTPVector<MTPUser> &users, const MTPVector
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::failDifference(const RPCError &error) {
|
bool MainWidget::failDifference(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
LOG(("RPC Error in getDifference: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
LOG(("RPC Error in getDifference: %1 %2: %3").arg(error.code()).arg(error.type()).arg(error.description()));
|
||||||
failDifferenceStartTimerFor(0);
|
failDifferenceStartTimerFor(0);
|
||||||
|
@ -3641,7 +3641,7 @@ void MainWidget::usernameResolveDone(QPair<MsgId, QString> msgIdAndStartToken, c
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
if (result.type() != mtpc_contacts_resolvedPeer) return;
|
if (result.type() != mtpc_contacts_resolvedPeer) return;
|
||||||
|
|
||||||
const MTPDcontacts_resolvedPeer &d(result.c_contacts_resolvedPeer());
|
const auto &d(result.c_contacts_resolvedPeer());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
PeerId peerId = peerFromMTP(d.vpeer);
|
PeerId peerId = peerFromMTP(d.vpeer);
|
||||||
|
@ -3673,7 +3673,7 @@ void MainWidget::usernameResolveDone(QPair<MsgId, QString> msgIdAndStartToken, c
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::usernameResolveFail(QString name, const RPCError &error) {
|
bool MainWidget::usernameResolveFail(QString name, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.code() == 400) {
|
if (error.code() == 400) {
|
||||||
Ui::showLayer(new InformBox(lng_username_not_found(lt_user, name)));
|
Ui::showLayer(new InformBox(lng_username_not_found(lt_user, name)));
|
||||||
|
@ -3684,7 +3684,7 @@ bool MainWidget::usernameResolveFail(QString name, const RPCError &error) {
|
||||||
void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
||||||
switch (invite.type()) {
|
switch (invite.type()) {
|
||||||
case mtpc_chatInvite: {
|
case mtpc_chatInvite: {
|
||||||
const MTPDchatInvite &d(invite.c_chatInvite());
|
const auto &d(invite.c_chatInvite());
|
||||||
ConfirmBox *box = new ConfirmBox(((d.is_channel() && !d.is_megagroup()) ? lng_group_invite_want_join_channel : lng_group_invite_want_join)(lt_title, qs(d.vtitle)), lang(lng_group_invite_join));
|
ConfirmBox *box = new ConfirmBox(((d.is_channel() && !d.is_megagroup()) ? lng_group_invite_want_join_channel : lng_group_invite_want_join)(lt_title, qs(d.vtitle)), lang(lng_group_invite_join));
|
||||||
_inviteHash = hash;
|
_inviteHash = hash;
|
||||||
connect(box, SIGNAL(confirmed()), this, SLOT(onInviteImport()));
|
connect(box, SIGNAL(confirmed()), this, SLOT(onInviteImport()));
|
||||||
|
@ -3692,7 +3692,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_chatInviteAlready: {
|
case mtpc_chatInviteAlready: {
|
||||||
const MTPDchatInviteAlready &d(invite.c_chatInviteAlready());
|
const auto &d(invite.c_chatInviteAlready());
|
||||||
PeerData *chat = App::feedChats(MTP_vector<MTPChat>(1, d.vchat));
|
PeerData *chat = App::feedChats(MTP_vector<MTPChat>(1, d.vchat));
|
||||||
if (chat) {
|
if (chat) {
|
||||||
Ui::showPeerHistory(chat->id, ShowAtUnreadMsgId);
|
Ui::showPeerHistory(chat->id, ShowAtUnreadMsgId);
|
||||||
|
@ -3702,7 +3702,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::inviteCheckFail(const RPCError &error) {
|
bool MainWidget::inviteCheckFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.code() == 400) {
|
if (error.code() == 400) {
|
||||||
Ui::showLayer(new InformBox(lang(lng_group_invite_bad_link)));
|
Ui::showLayer(new InformBox(lang(lng_group_invite_bad_link)));
|
||||||
|
@ -3735,16 +3735,16 @@ void MainWidget::inviteImportDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::inviteImportFail(const RPCError &error) {
|
bool MainWidget::inviteImportFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (error.code() == 400) {
|
if (error.code() == 400) {
|
||||||
Ui::showLayer(new InformBox(lang(error.type() == qsl("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link)));
|
Ui::showLayer(new InformBox(lang(error.type() == qstr("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::startFull(const MTPVector<MTPUser> &users) {
|
void MainWidget::startFull(const MTPVector<MTPUser> &users) {
|
||||||
const QVector<MTPUser> &v(users.c_vector().v);
|
const auto &v(users.c_vector().v);
|
||||||
if (v.isEmpty() || v[0].type() != mtpc_user || !v[0].c_user().is_self()) { // wtf?..
|
if (v.isEmpty() || v[0].type() != mtpc_user || !v[0].c_user().is_self()) { // wtf?..
|
||||||
return App::logOutDelayed();
|
return App::logOutDelayed();
|
||||||
}
|
}
|
||||||
|
@ -3774,7 +3774,7 @@ void MainWidget::applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNoti
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case mtpc_peerNotifySettings: {
|
case mtpc_peerNotifySettings: {
|
||||||
const MTPDpeerNotifySettings &d(settings.c_peerNotifySettings());
|
const auto &d(settings.c_peerNotifySettings());
|
||||||
NotifySettingsPtr setTo = UnknownNotifySettings;
|
NotifySettingsPtr setTo = UnknownNotifySettings;
|
||||||
switch (peer.type()) {
|
switch (peer.type()) {
|
||||||
case mtpc_notifyAll: setTo = globalNotifyAllPtr = &globalNotifyAll; break;
|
case mtpc_notifyAll: setTo = globalNotifyAllPtr = &globalNotifyAll; break;
|
||||||
|
@ -3839,7 +3839,7 @@ void MainWidget::gotNotifySetting(MTPInputNotifyPeer peer, const MTPPeerNotifySe
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::failNotifySetting(MTPInputNotifyPeer peer, const RPCError &error) {
|
bool MainWidget::failNotifySetting(MTPInputNotifyPeer peer, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
gotNotifySetting(peer, MTP_peerNotifySettingsEmpty());
|
gotNotifySetting(peer, MTP_peerNotifySettingsEmpty());
|
||||||
return true;
|
return true;
|
||||||
|
@ -4095,7 +4095,7 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) {
|
||||||
void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
switch (updates.type()) {
|
switch (updates.type()) {
|
||||||
case mtpc_updates: {
|
case mtpc_updates: {
|
||||||
const MTPDupdates &d(updates.c_updates());
|
const auto &d(updates.c_updates());
|
||||||
if (d.vseq.v) {
|
if (d.vseq.v) {
|
||||||
if (d.vseq.v <= updSeq) return;
|
if (d.vseq.v <= updSeq) return;
|
||||||
if (d.vseq.v > updSeq + 1) {
|
if (d.vseq.v > updSeq + 1) {
|
||||||
|
@ -4112,7 +4112,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updatesCombined: {
|
case mtpc_updatesCombined: {
|
||||||
const MTPDupdatesCombined &d(updates.c_updatesCombined());
|
const auto &d(updates.c_updatesCombined());
|
||||||
if (d.vseq_start.v) {
|
if (d.vseq_start.v) {
|
||||||
if (d.vseq_start.v <= updSeq) return;
|
if (d.vseq_start.v <= updSeq) return;
|
||||||
if (d.vseq_start.v > updSeq + 1) {
|
if (d.vseq_start.v > updSeq + 1) {
|
||||||
|
@ -4129,7 +4129,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShort: {
|
case mtpc_updateShort: {
|
||||||
const MTPDupdateShort &d(updates.c_updateShort());
|
const auto &d(updates.c_updateShort());
|
||||||
|
|
||||||
feedUpdate(d.vupdate);
|
feedUpdate(d.vupdate);
|
||||||
|
|
||||||
|
@ -4137,13 +4137,13 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShortMessage: {
|
case mtpc_updateShortMessage: {
|
||||||
const MTPDupdateShortMessage &d(updates.c_updateShortMessage());
|
const auto &d(updates.c_updateShortMessage());
|
||||||
if (!App::userLoaded(d.vuser_id.v) || (d.has_via_bot_id() && !App::userLoaded(d.vvia_bot_id.v))) {
|
if (!App::userLoaded(d.vuser_id.v) || (d.has_via_bot_id() && !App::userLoaded(d.vvia_bot_id.v))) {
|
||||||
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
||||||
return getDifference();
|
return getDifference();
|
||||||
}
|
}
|
||||||
if (d.has_fwd_from() && d.vfwd_from.type() == mtpc_messageFwdHeader) {
|
if (d.has_fwd_from() && d.vfwd_from.type() == mtpc_messageFwdHeader) {
|
||||||
const MTPDmessageFwdHeader &f(d.vfwd_from.c_messageFwdHeader());
|
const auto &f(d.vfwd_from.c_messageFwdHeader());
|
||||||
if (f.has_from_id() && !App::userLoaded(f.vfrom_id.v)) {
|
if (f.has_from_id() && !App::userLoaded(f.vfrom_id.v)) {
|
||||||
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
||||||
return getDifference();
|
return getDifference();
|
||||||
|
@ -4170,7 +4170,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShortChatMessage: {
|
case mtpc_updateShortChatMessage: {
|
||||||
const MTPDupdateShortChatMessage &d(updates.c_updateShortChatMessage());
|
const auto &d(updates.c_updateShortChatMessage());
|
||||||
bool noFrom = !App::userLoaded(d.vfrom_id.v);
|
bool noFrom = !App::userLoaded(d.vfrom_id.v);
|
||||||
if (!App::chatLoaded(d.vchat_id.v) || noFrom || (d.has_via_bot_id() && !App::userLoaded(d.vvia_bot_id.v))) {
|
if (!App::chatLoaded(d.vchat_id.v) || noFrom || (d.has_via_bot_id() && !App::userLoaded(d.vvia_bot_id.v))) {
|
||||||
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
||||||
|
@ -4178,7 +4178,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
return getDifference();
|
return getDifference();
|
||||||
}
|
}
|
||||||
if (d.has_fwd_from() && d.vfwd_from.type() == mtpc_messageFwdHeader) {
|
if (d.has_fwd_from() && d.vfwd_from.type() == mtpc_messageFwdHeader) {
|
||||||
const MTPDmessageFwdHeader &f(d.vfwd_from.c_messageFwdHeader());
|
const auto &f(d.vfwd_from.c_messageFwdHeader());
|
||||||
if (f.has_from_id() && !App::userLoaded(f.vfrom_id.v)) {
|
if (f.has_from_id() && !App::userLoaded(f.vfrom_id.v)) {
|
||||||
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
||||||
return getDifference();
|
return getDifference();
|
||||||
|
@ -4205,7 +4205,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShortSentMessage: {
|
case mtpc_updateShortSentMessage: {
|
||||||
const MTPDupdateShortSentMessage &d(updates.c_updateShortSentMessage());
|
const auto &d(updates.c_updateShortSentMessage());
|
||||||
if (randomId) {
|
if (randomId) {
|
||||||
PeerId peerId = 0;
|
PeerId peerId = 0;
|
||||||
QString text;
|
QString text;
|
||||||
|
@ -4242,7 +4242,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
|
|
||||||
switch (update.type()) {
|
switch (update.type()) {
|
||||||
case mtpc_updateNewMessage: {
|
case mtpc_updateNewMessage: {
|
||||||
const MTPDupdateNewMessage &d(update.c_updateNewMessage());
|
const auto &d(update.c_updateNewMessage());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4266,7 +4266,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateMessageID: {
|
case mtpc_updateMessageID: {
|
||||||
const MTPDupdateMessageID &d(update.c_updateMessageID());
|
const auto &d(update.c_updateMessageID());
|
||||||
FullMsgId msg = App::histItemByRandom(d.vrandom_id.v);
|
FullMsgId msg = App::histItemByRandom(d.vrandom_id.v);
|
||||||
if (msg.msg) {
|
if (msg.msg) {
|
||||||
HistoryItem *msgRow = App::histItemById(msg);
|
HistoryItem *msgRow = App::histItemById(msg);
|
||||||
|
@ -4296,14 +4296,14 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadMessagesContents: {
|
case mtpc_updateReadMessagesContents: {
|
||||||
const MTPDupdateReadMessagesContents &d(update.c_updateReadMessagesContents());
|
const auto &d(update.c_updateReadMessagesContents());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update before applying skipped
|
// update before applying skipped
|
||||||
const QVector<MTPint> &v(d.vmessages.c_vector().v);
|
const auto &v(d.vmessages.c_vector().v);
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
if (HistoryItem *item = App::histItemById(NoChannel, v.at(i).v)) {
|
if (HistoryItem *item = App::histItemById(NoChannel, v.at(i).v)) {
|
||||||
if (item->isMediaUnread()) {
|
if (item->isMediaUnread()) {
|
||||||
|
@ -4320,7 +4320,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadHistoryInbox: {
|
case mtpc_updateReadHistoryInbox: {
|
||||||
const MTPDupdateReadHistoryInbox &d(update.c_updateReadHistoryInbox());
|
const auto &d(update.c_updateReadHistoryInbox());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4333,7 +4333,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadHistoryOutbox: {
|
case mtpc_updateReadHistoryOutbox: {
|
||||||
const MTPDupdateReadHistoryOutbox &d(update.c_updateReadHistoryOutbox());
|
const auto &d(update.c_updateReadHistoryOutbox());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4356,7 +4356,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateWebPage: {
|
case mtpc_updateWebPage: {
|
||||||
const MTPDupdateWebPage &d(update.c_updateWebPage());
|
const auto &d(update.c_updateWebPage());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4371,7 +4371,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateDeleteMessages: {
|
case mtpc_updateDeleteMessages: {
|
||||||
const MTPDupdateDeleteMessages &d(update.c_updateDeleteMessages());
|
const auto &d(update.c_updateDeleteMessages());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4385,7 +4385,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserTyping: {
|
case mtpc_updateUserTyping: {
|
||||||
const MTPDupdateUserTyping &d(update.c_updateUserTyping());
|
const auto &d(update.c_updateUserTyping());
|
||||||
History *history = App::historyLoaded(peerFromUser(d.vuser_id));
|
History *history = App::historyLoaded(peerFromUser(d.vuser_id));
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (history && user) {
|
if (history && user) {
|
||||||
|
@ -4394,7 +4394,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateChatUserTyping: {
|
case mtpc_updateChatUserTyping: {
|
||||||
const MTPDupdateChatUserTyping &d(update.c_updateChatUserTyping());
|
const auto &d(update.c_updateChatUserTyping());
|
||||||
History *history = 0;
|
History *history = 0;
|
||||||
if (PeerData *chat = App::chatLoaded(d.vchat_id.v)) {
|
if (PeerData *chat = App::chatLoaded(d.vchat_id.v)) {
|
||||||
history = App::historyLoaded(chat->id);
|
history = App::historyLoaded(chat->id);
|
||||||
|
@ -4428,7 +4428,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserStatus: {
|
case mtpc_updateUserStatus: {
|
||||||
const MTPDupdateUserStatus &d(update.c_updateUserStatus());
|
const auto &d(update.c_updateUserStatus());
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
switch (d.vstatus.type()) {
|
switch (d.vstatus.type()) {
|
||||||
|
@ -4458,7 +4458,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserName: {
|
case mtpc_updateUserName: {
|
||||||
const MTPDupdateUserName &d(update.c_updateUserName());
|
const auto &d(update.c_updateUserName());
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user->contact <= 0) {
|
if (user->contact <= 0) {
|
||||||
|
@ -4471,7 +4471,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserPhoto: {
|
case mtpc_updateUserPhoto: {
|
||||||
const MTPDupdateUserPhoto &d(update.c_updateUserPhoto());
|
const auto &d(update.c_updateUserPhoto());
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
user->setPhoto(d.vphoto);
|
user->setPhoto(d.vphoto);
|
||||||
|
@ -4494,7 +4494,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateContactRegistered: {
|
case mtpc_updateContactRegistered: {
|
||||||
const MTPDupdateContactRegistered &d(update.c_updateContactRegistered());
|
const auto &d(update.c_updateContactRegistered());
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
if (App::history(user->id)->loadedAtBottom()) {
|
if (App::history(user->id)->loadedAtBottom()) {
|
||||||
|
@ -4504,22 +4504,22 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateContactLink: {
|
case mtpc_updateContactLink: {
|
||||||
const MTPDupdateContactLink &d(update.c_updateContactLink());
|
const auto &d(update.c_updateContactLink());
|
||||||
App::feedUserLink(d.vuser_id, d.vmy_link, d.vforeign_link, false);
|
App::feedUserLink(d.vuser_id, d.vmy_link, d.vforeign_link, false);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNotifySettings: {
|
case mtpc_updateNotifySettings: {
|
||||||
const MTPDupdateNotifySettings &d(update.c_updateNotifySettings());
|
const auto &d(update.c_updateNotifySettings());
|
||||||
applyNotifySetting(d.vpeer, d.vnotify_settings);
|
applyNotifySetting(d.vpeer, d.vnotify_settings);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateDcOptions: {
|
case mtpc_updateDcOptions: {
|
||||||
const MTPDupdateDcOptions &d(update.c_updateDcOptions());
|
const auto &d(update.c_updateDcOptions());
|
||||||
MTP::updateDcOptions(d.vdc_options.c_vector().v);
|
MTP::updateDcOptions(d.vdc_options.c_vector().v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserPhone: {
|
case mtpc_updateUserPhone: {
|
||||||
const MTPDupdateUserPhone &d(update.c_updateUserPhone());
|
const auto &d(update.c_updateUserPhone());
|
||||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
user->setPhone(qs(d.vphone));
|
user->setPhone(qs(d.vphone));
|
||||||
|
@ -4529,23 +4529,23 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNewEncryptedMessage: {
|
case mtpc_updateNewEncryptedMessage: {
|
||||||
const MTPDupdateNewEncryptedMessage &d(update.c_updateNewEncryptedMessage());
|
const auto &d(update.c_updateNewEncryptedMessage());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateEncryptedChatTyping: {
|
case mtpc_updateEncryptedChatTyping: {
|
||||||
const MTPDupdateEncryptedChatTyping &d(update.c_updateEncryptedChatTyping());
|
const auto &d(update.c_updateEncryptedChatTyping());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateEncryption: {
|
case mtpc_updateEncryption: {
|
||||||
const MTPDupdateEncryption &d(update.c_updateEncryption());
|
const auto &d(update.c_updateEncryption());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateEncryptedMessagesRead: {
|
case mtpc_updateEncryptedMessagesRead: {
|
||||||
const MTPDupdateEncryptedMessagesRead &d(update.c_updateEncryptedMessagesRead());
|
const auto &d(update.c_updateEncryptedMessagesRead());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserBlocked: {
|
case mtpc_updateUserBlocked: {
|
||||||
const MTPDupdateUserBlocked &d(update.c_updateUserBlocked());
|
const auto &d(update.c_updateUserBlocked());
|
||||||
if (UserData *user = App::userLoaded(d.vuser_id.v)) {
|
if (UserData *user = App::userLoaded(d.vuser_id.v)) {
|
||||||
user->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked;
|
user->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked;
|
||||||
App::markPeerUpdated(user);
|
App::markPeerUpdated(user);
|
||||||
|
@ -4553,7 +4553,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNewAuthorization: {
|
case mtpc_updateNewAuthorization: {
|
||||||
const MTPDupdateNewAuthorization &d(update.c_updateNewAuthorization());
|
const auto &d(update.c_updateNewAuthorization());
|
||||||
QDateTime datetime = date(d.vdate);
|
QDateTime datetime = date(d.vdate);
|
||||||
|
|
||||||
QString name = App::self()->firstName;
|
QString name = App::self()->firstName;
|
||||||
|
@ -4566,7 +4566,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateServiceNotification: {
|
case mtpc_updateServiceNotification: {
|
||||||
const MTPDupdateServiceNotification &d(update.c_updateServiceNotification());
|
const auto &d(update.c_updateServiceNotification());
|
||||||
if (mtpIsTrue(d.vpopup)) {
|
if (mtpIsTrue(d.vpopup)) {
|
||||||
Ui::showLayer(new InformBox(qs(d.vmessage)));
|
Ui::showLayer(new InformBox(qs(d.vmessage)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -4575,12 +4575,12 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updatePrivacy: {
|
case mtpc_updatePrivacy: {
|
||||||
const MTPDupdatePrivacy &d(update.c_updatePrivacy());
|
const auto &d(update.c_updatePrivacy());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
/////// Channel updates
|
/////// Channel updates
|
||||||
case mtpc_updateChannel: {
|
case mtpc_updateChannel: {
|
||||||
const MTPDupdateChannel &d(update.c_updateChannel());
|
const auto &d(update.c_updateChannel());
|
||||||
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
||||||
App::markPeerUpdated(channel);
|
App::markPeerUpdated(channel);
|
||||||
channel->inviter = 0;
|
channel->inviter = 0;
|
||||||
|
@ -4594,7 +4594,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNewChannelMessage: {
|
case mtpc_updateNewChannelMessage: {
|
||||||
const MTPDupdateNewChannelMessage &d(update.c_updateNewChannelMessage());
|
const auto &d(update.c_updateNewChannelMessage());
|
||||||
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
|
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
|
||||||
if (!channel && !_ptsWaiter.requesting()) {
|
if (!channel && !_ptsWaiter.requesting()) {
|
||||||
MTP_LOG(0, ("getDifference { good - after no channel in updateNewChannelMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
MTP_LOG(0, ("getDifference { good - after no channel in updateNewChannelMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
|
||||||
|
@ -4631,7 +4631,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateEditChannelMessage: {
|
case mtpc_updateEditChannelMessage: {
|
||||||
const MTPDupdateEditChannelMessage &d(update.c_updateEditChannelMessage());
|
const auto &d(update.c_updateEditChannelMessage());
|
||||||
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
|
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
|
||||||
|
|
||||||
if (channel && !_handlingChannelDifference) {
|
if (channel && !_handlingChannelDifference) {
|
||||||
|
@ -4652,7 +4652,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateEditMessage: {
|
case mtpc_updateEditMessage: {
|
||||||
const MTPDupdateEditMessage &d(update.c_updateEditMessage());
|
const auto &d(update.c_updateEditMessage());
|
||||||
|
|
||||||
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
if (!ptsUpdated(d.vpts.v, d.vpts_count.v, update)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4666,7 +4666,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateChannelPinnedMessage: {
|
case mtpc_updateChannelPinnedMessage: {
|
||||||
const MTPDupdateChannelPinnedMessage &d(update.c_updateChannelPinnedMessage());
|
const auto &d(update.c_updateChannelPinnedMessage());
|
||||||
|
|
||||||
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
||||||
if (channel->isMegagroup()) {
|
if (channel->isMegagroup()) {
|
||||||
|
@ -4679,13 +4679,13 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadChannelInbox: {
|
case mtpc_updateReadChannelInbox: {
|
||||||
const MTPDupdateReadChannelInbox &d(update.c_updateReadChannelInbox());
|
const auto &d(update.c_updateReadChannelInbox());
|
||||||
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
|
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
|
||||||
App::feedInboxRead(peerFromChannel(d.vchannel_id.v), d.vmax_id.v);
|
App::feedInboxRead(peerFromChannel(d.vchannel_id.v), d.vmax_id.v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateDeleteChannelMessages: {
|
case mtpc_updateDeleteChannelMessages: {
|
||||||
const MTPDupdateDeleteChannelMessages &d(update.c_updateDeleteChannelMessages());
|
const auto &d(update.c_updateDeleteChannelMessages());
|
||||||
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
|
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
|
||||||
|
|
||||||
if (channel && !_handlingChannelDifference) {
|
if (channel && !_handlingChannelDifference) {
|
||||||
|
@ -4712,7 +4712,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateChannelTooLong: {
|
case mtpc_updateChannelTooLong: {
|
||||||
const MTPDupdateChannelTooLong &d(update.c_updateChannelTooLong());
|
const auto &d(update.c_updateChannelTooLong());
|
||||||
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
|
||||||
if (!d.has_pts() || channel->pts() < d.vpts.v) {
|
if (!d.has_pts() || channel->pts() < d.vpts.v) {
|
||||||
getChannelDifference(channel);
|
getChannelDifference(channel);
|
||||||
|
@ -4721,7 +4721,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateChannelMessageViews: {
|
case mtpc_updateChannelMessageViews: {
|
||||||
const MTPDupdateChannelMessageViews &d(update.c_updateChannelMessageViews());
|
const auto &d(update.c_updateChannelMessageViews());
|
||||||
if (HistoryItem *item = App::histItemById(d.vchannel_id.v, d.vid.v)) {
|
if (HistoryItem *item = App::histItemById(d.vchannel_id.v, d.vid.v)) {
|
||||||
item->setViewsCount(d.vviews.v);
|
item->setViewsCount(d.vviews.v);
|
||||||
}
|
}
|
||||||
|
@ -4729,11 +4729,11 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
|
|
||||||
////// Cloud sticker sets
|
////// Cloud sticker sets
|
||||||
case mtpc_updateNewStickerSet: {
|
case mtpc_updateNewStickerSet: {
|
||||||
const MTPDupdateNewStickerSet &d(update.c_updateNewStickerSet());
|
const auto &d(update.c_updateNewStickerSet());
|
||||||
if (d.vstickerset.type() == mtpc_messages_stickerSet) {
|
if (d.vstickerset.type() == mtpc_messages_stickerSet) {
|
||||||
const MTPDmessages_stickerSet &set(d.vstickerset.c_messages_stickerSet());
|
const auto &set(d.vstickerset.c_messages_stickerSet());
|
||||||
if (set.vset.type() == mtpc_stickerSet) {
|
if (set.vset.type() == mtpc_stickerSet) {
|
||||||
const MTPDstickerSet &s(set.vset.c_stickerSet());
|
const auto &s(set.vset.c_stickerSet());
|
||||||
|
|
||||||
Stickers::Sets &sets(Global::RefStickerSets());
|
Stickers::Sets &sets(Global::RefStickerSets());
|
||||||
auto it = sets.find(s.vid.v);
|
auto it = sets.find(s.vid.v);
|
||||||
|
@ -4741,7 +4741,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
it = sets.insert(s.vid.v, Stickers::Set(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v));
|
it = sets.insert(s.vid.v, Stickers::Set(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<MTPDocument> &v(set.vdocuments.c_vector().v);
|
const auto &v(set.vdocuments.c_vector().v);
|
||||||
it->stickers.clear();
|
it->stickers.clear();
|
||||||
it->stickers.reserve(v.size());
|
it->stickers.reserve(v.size());
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||||
|
@ -4751,12 +4751,12 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
it->stickers.push_back(doc);
|
it->stickers.push_back(doc);
|
||||||
}
|
}
|
||||||
it->emoji.clear();
|
it->emoji.clear();
|
||||||
const QVector<MTPStickerPack> &packs(set.vpacks.c_vector().v);
|
const auto &packs(set.vpacks.c_vector().v);
|
||||||
for (int32 i = 0, l = packs.size(); i < l; ++i) {
|
for (int32 i = 0, l = packs.size(); i < l; ++i) {
|
||||||
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
||||||
const MTPDstickerPack &pack(packs.at(i).c_stickerPack());
|
const auto &pack(packs.at(i).c_stickerPack());
|
||||||
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
||||||
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
|
const auto &stickers(pack.vdocuments.c_vector().v);
|
||||||
StickerPack p;
|
StickerPack p;
|
||||||
p.reserve(stickers.size());
|
p.reserve(stickers.size());
|
||||||
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
||||||
|
@ -4795,9 +4795,9 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateStickerSetsOrder: {
|
case mtpc_updateStickerSetsOrder: {
|
||||||
const MTPDupdateStickerSetsOrder &d(update.c_updateStickerSetsOrder());
|
const auto &d(update.c_updateStickerSetsOrder());
|
||||||
const QVector<MTPlong> &order(d.vorder.c_vector().v);
|
const auto &order(d.vorder.c_vector().v);
|
||||||
const Stickers::Sets &sets(Global::StickerSets());
|
const auto &sets(Global::StickerSets());
|
||||||
Stickers::Order result;
|
Stickers::Order result;
|
||||||
for (int32 i = 0, l = order.size(); i < l; ++i) {
|
for (int32 i = 0, l = order.size(); i < l; ++i) {
|
||||||
if (sets.constFind(order.at(i).v) == sets.cend()) {
|
if (sets.constFind(order.at(i).v) == sets.cend()) {
|
||||||
|
|
|
@ -2079,14 +2079,14 @@ void MediaView::userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mt
|
||||||
const QVector<MTPPhoto> *v = 0;
|
const QVector<MTPPhoto> *v = 0;
|
||||||
switch (photos.type()) {
|
switch (photos.type()) {
|
||||||
case mtpc_photos_photos: {
|
case mtpc_photos_photos: {
|
||||||
const MTPDphotos_photos &d(photos.c_photos_photos());
|
const auto &d(photos.c_photos_photos());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
v = &d.vphotos.c_vector().v;
|
v = &d.vphotos.c_vector().v;
|
||||||
u->photosCount = 0;
|
u->photosCount = 0;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_photos_photosSlice: {
|
case mtpc_photos_photosSlice: {
|
||||||
const MTPDphotos_photosSlice &d(photos.c_photos_photosSlice());
|
const auto &d(photos.c_photos_photosSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
u->photosCount = d.vcount.v;
|
u->photosCount = d.vcount.v;
|
||||||
v = &d.vphotos.c_vector().v;
|
v = &d.vphotos.c_vector().v;
|
||||||
|
@ -2111,7 +2111,7 @@ void MediaView::deletePhotosDone(const MTPVector<MTPlong> &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaView::deletePhotosFail(const RPCError &error) {
|
bool MediaView::deletePhotosFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,7 +440,7 @@ ConnectionPrivate::ConnectionPrivate(QThread *thread, Connection *owner, Session
|
||||||
|
|
||||||
if (!dc) {
|
if (!dc) {
|
||||||
QReadLocker lock(dcOptionsMutex());
|
QReadLocker lock(dcOptionsMutex());
|
||||||
const MTP::DcOptions &options(Global::DcOptions());
|
const auto &options(Global::DcOptions());
|
||||||
if (options.isEmpty()) {
|
if (options.isEmpty()) {
|
||||||
LOG(("MTP Error: connect failed, no DCs"));
|
LOG(("MTP Error: connect failed, no DCs"));
|
||||||
dc = 0;
|
dc = 0;
|
||||||
|
@ -1085,7 +1085,7 @@ void ConnectionPrivate::socketStart(bool afterConfig) {
|
||||||
uint32 port[2][2] = { { 0 } };
|
uint32 port[2][2] = { { 0 } };
|
||||||
{
|
{
|
||||||
QReadLocker lock(dcOptionsMutex());
|
QReadLocker lock(dcOptionsMutex());
|
||||||
const MTP::DcOptions &options(Global::DcOptions());
|
const auto &options(Global::DcOptions());
|
||||||
int32 shifts[2][2][4] = {
|
int32 shifts[2][2][4] = {
|
||||||
{ // IPv4
|
{ // IPv4
|
||||||
{ // TCP IPv4
|
{ // TCP IPv4
|
||||||
|
@ -1592,7 +1592,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_msgs_ack: {
|
case mtpc_msgs_ack: {
|
||||||
MTPMsgsAck msg(from, end);
|
MTPMsgsAck msg(from, end);
|
||||||
const QVector<MTPlong> &ids(msg.c_msgs_ack().vmsg_ids.c_vector().v);
|
const auto &ids(msg.c_msgs_ack().vmsg_ids.c_vector().v);
|
||||||
uint32 idsCount = ids.size();
|
uint32 idsCount = ids.size();
|
||||||
|
|
||||||
DEBUG_LOG(("Message Info: acks received, ids: %1").arg(Logs::vector(ids)));
|
DEBUG_LOG(("Message Info: acks received, ids: %1").arg(Logs::vector(ids)));
|
||||||
|
@ -1610,7 +1610,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_bad_msg_notification: {
|
case mtpc_bad_msg_notification: {
|
||||||
MTPBadMsgNotification msg(from, end);
|
MTPBadMsgNotification msg(from, end);
|
||||||
const MTPDbad_msg_notification &data(msg.c_bad_msg_notification());
|
const auto &data(msg.c_bad_msg_notification());
|
||||||
LOG(("Message Info: bad message notification received (error_code %3) for msg_id = %1, seq_no = %2").arg(data.vbad_msg_id.v).arg(data.vbad_msg_seqno.v).arg(data.verror_code.v));
|
LOG(("Message Info: bad message notification received (error_code %3) for msg_id = %1, seq_no = %2").arg(data.vbad_msg_id.v).arg(data.vbad_msg_seqno.v).arg(data.verror_code.v));
|
||||||
|
|
||||||
mtpMsgId resendId = data.vbad_msg_id.v;
|
mtpMsgId resendId = data.vbad_msg_id.v;
|
||||||
|
@ -1686,7 +1686,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_bad_server_salt: {
|
case mtpc_bad_server_salt: {
|
||||||
MTPBadMsgNotification msg(from, end);
|
MTPBadMsgNotification msg(from, end);
|
||||||
const MTPDbad_server_salt &data(msg.c_bad_server_salt());
|
const auto &data(msg.c_bad_server_salt());
|
||||||
DEBUG_LOG(("Message Info: bad server salt received (error_code %4) for msg_id = %1, seq_no = %2, new salt: %3").arg(data.vbad_msg_id.v).arg(data.vbad_msg_seqno.v).arg(data.vnew_server_salt.v).arg(data.verror_code.v));
|
DEBUG_LOG(("Message Info: bad server salt received (error_code %4) for msg_id = %1, seq_no = %2, new salt: %3").arg(data.vbad_msg_id.v).arg(data.vbad_msg_seqno.v).arg(data.vnew_server_salt.v).arg(data.verror_code.v));
|
||||||
|
|
||||||
mtpMsgId resendId = data.vbad_msg_id.v;
|
mtpMsgId resendId = data.vbad_msg_id.v;
|
||||||
|
@ -1720,7 +1720,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MTPMsgsStateReq msg(from, end);
|
MTPMsgsStateReq msg(from, end);
|
||||||
const QVector<MTPlong> ids(msg.c_msgs_state_req().vmsg_ids.c_vector().v);
|
const auto &ids(msg.c_msgs_state_req().vmsg_ids.c_vector().v);
|
||||||
uint32 idsCount = ids.size();
|
uint32 idsCount = ids.size();
|
||||||
DEBUG_LOG(("Message Info: msgs_state_req received, ids: %1").arg(Logs::vector(ids)));
|
DEBUG_LOG(("Message Info: msgs_state_req received, ids: %1").arg(Logs::vector(ids)));
|
||||||
if (!idsCount) return 1;
|
if (!idsCount) return 1;
|
||||||
|
@ -1767,10 +1767,10 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_msgs_state_info: {
|
case mtpc_msgs_state_info: {
|
||||||
MTPMsgsStateInfo msg(from, end);
|
MTPMsgsStateInfo msg(from, end);
|
||||||
const MTPDmsgs_state_info &data(msg.c_msgs_state_info());
|
const auto &data(msg.c_msgs_state_info());
|
||||||
|
|
||||||
uint64 reqMsgId = data.vreq_msg_id.v;
|
uint64 reqMsgId = data.vreq_msg_id.v;
|
||||||
const string &states(data.vinfo.c_string().v);
|
const auto &states(data.vinfo.c_string().v);
|
||||||
|
|
||||||
DEBUG_LOG(("Message Info: msg state received, msgId %1, reqMsgId: %2, HEX states %3").arg(msgId).arg(reqMsgId).arg(Logs::mb(states.data(), states.length()).str()));
|
DEBUG_LOG(("Message Info: msg state received, msgId %1, reqMsgId: %2, HEX states %3").arg(msgId).arg(reqMsgId).arg(Logs::mb(states.data(), states.length()).str()));
|
||||||
mtpRequest requestBuffer;
|
mtpRequest requestBuffer;
|
||||||
|
@ -1823,9 +1823,9 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
}
|
}
|
||||||
|
|
||||||
MTPMsgsAllInfo msg(from, end);
|
MTPMsgsAllInfo msg(from, end);
|
||||||
const MTPDmsgs_all_info &data(msg.c_msgs_all_info());
|
const auto &data(msg.c_msgs_all_info());
|
||||||
const QVector<MTPlong> ids(data.vmsg_ids.c_vector().v);
|
const auto &ids(data.vmsg_ids.c_vector().v);
|
||||||
const string &states(data.vinfo.c_string().v);
|
const auto &states(data.vinfo.c_string().v);
|
||||||
|
|
||||||
QVector<MTPlong> toAck;
|
QVector<MTPlong> toAck;
|
||||||
|
|
||||||
|
@ -1837,7 +1837,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_msg_detailed_info: {
|
case mtpc_msg_detailed_info: {
|
||||||
MTPMsgDetailedInfo msg(from, end);
|
MTPMsgDetailedInfo msg(from, end);
|
||||||
const MTPDmsg_detailed_info &data(msg.c_msg_detailed_info());
|
const auto &data(msg.c_msg_detailed_info());
|
||||||
|
|
||||||
DEBUG_LOG(("Message Info: msg detailed info, sent msgId %1, answerId %2, status %3, bytes %4").arg(data.vmsg_id.v).arg(data.vanswer_msg_id.v).arg(data.vstatus.v).arg(data.vbytes.v));
|
DEBUG_LOG(("Message Info: msg detailed info, sent msgId %1, answerId %2, status %3, bytes %4").arg(data.vmsg_id.v).arg(data.vanswer_msg_id.v).arg(data.vstatus.v).arg(data.vbytes.v));
|
||||||
|
|
||||||
|
@ -1873,7 +1873,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MTPMsgDetailedInfo msg(from, end);
|
MTPMsgDetailedInfo msg(from, end);
|
||||||
const MTPDmsg_new_detailed_info &data(msg.c_msg_new_detailed_info());
|
const auto &data(msg.c_msg_new_detailed_info());
|
||||||
|
|
||||||
DEBUG_LOG(("Message Info: msg new detailed info, answerId %2, status %3, bytes %4").arg(data.vanswer_msg_id.v).arg(data.vstatus.v).arg(data.vbytes.v));
|
DEBUG_LOG(("Message Info: msg new detailed info, answerId %2, status %3, bytes %4").arg(data.vanswer_msg_id.v).arg(data.vstatus.v).arg(data.vbytes.v));
|
||||||
|
|
||||||
|
@ -1894,7 +1894,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_msg_resend_req: {
|
case mtpc_msg_resend_req: {
|
||||||
MTPMsgResendReq msg(from, end);
|
MTPMsgResendReq msg(from, end);
|
||||||
const QVector<MTPlong> &ids(msg.c_msg_resend_req().vmsg_ids.c_vector().v);
|
const auto &ids(msg.c_msg_resend_req().vmsg_ids.c_vector().v);
|
||||||
|
|
||||||
uint32 idsCount = ids.size();
|
uint32 idsCount = ids.size();
|
||||||
DEBUG_LOG(("Message Info: resend of msgs requested, ids: %1").arg(Logs::vector(ids)));
|
DEBUG_LOG(("Message Info: resend of msgs requested, ids: %1").arg(Logs::vector(ids)));
|
||||||
|
@ -1955,7 +1955,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
case mtpc_new_session_created: {
|
case mtpc_new_session_created: {
|
||||||
const mtpPrime *start = from;
|
const mtpPrime *start = from;
|
||||||
MTPNewSession msg(from, end);
|
MTPNewSession msg(from, end);
|
||||||
const MTPDnew_session_created &data(msg.c_new_session_created());
|
const auto &data(msg.c_new_session_created());
|
||||||
|
|
||||||
if (badTime) {
|
if (badTime) {
|
||||||
if (requestsFixTimeSalt(QVector<MTPlong>(1, data.vfirst_msg_id), serverTime, serverSalt)) {
|
if (requestsFixTimeSalt(QVector<MTPlong>(1, data.vfirst_msg_id), serverTime, serverSalt)) {
|
||||||
|
@ -2002,7 +2002,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
|
||||||
|
|
||||||
case mtpc_pong: {
|
case mtpc_pong: {
|
||||||
MTPPong msg(from, end);
|
MTPPong msg(from, end);
|
||||||
const MTPDpong &data(msg.c_pong());
|
const auto &data(msg.c_pong());
|
||||||
DEBUG_LOG(("Message Info: pong received, msg_id: %1, ping_id: %2").arg(data.vmsg_id.v).arg(data.vping_id.v));
|
DEBUG_LOG(("Message Info: pong received, msg_id: %1, ping_id: %2").arg(data.vmsg_id.v).arg(data.vping_id.v));
|
||||||
|
|
||||||
if (!wasSent(data.vmsg_id.v)) {
|
if (!wasSent(data.vmsg_id.v)) {
|
||||||
|
@ -2405,7 +2405,7 @@ void ConnectionPrivate::pqAnswered() {
|
||||||
return restart();
|
return restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
|
const auto &res_pq_data(res_pq.c_resPQ());
|
||||||
if (res_pq_data.vnonce != authKeyData->nonce) {
|
if (res_pq_data.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in res_pq)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in res_pq)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&res_pq_data.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&res_pq_data.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2414,9 +2414,9 @@ void ConnectionPrivate::pqAnswered() {
|
||||||
|
|
||||||
static MTP::internal::RSAPublicKeys RSAKeys = MTP::internal::InitRSAPublicKeys();
|
static MTP::internal::RSAPublicKeys RSAKeys = MTP::internal::InitRSAPublicKeys();
|
||||||
const MTP::internal::RSAPublicKey *rsaKey = nullptr;
|
const MTP::internal::RSAPublicKey *rsaKey = nullptr;
|
||||||
const QVector<MTPlong> &fingerPrints(res_pq.c_resPQ().vserver_public_key_fingerprints.c_vector().v);
|
const auto &fingerPrints(res_pq.c_resPQ().vserver_public_key_fingerprints.c_vector().v);
|
||||||
for (const MTPlong &fingerPrint : fingerPrints) {
|
for (const auto &fingerPrint : fingerPrints) {
|
||||||
auto it = RSAKeys.constFind(fingerPrint.v);
|
auto it = RSAKeys.constFind(static_cast<uint64>(fingerPrint.v));
|
||||||
if (it != RSAKeys.cend()) {
|
if (it != RSAKeys.cend()) {
|
||||||
rsaKey = &it.value();
|
rsaKey = &it.value();
|
||||||
break;
|
break;
|
||||||
|
@ -2424,7 +2424,7 @@ void ConnectionPrivate::pqAnswered() {
|
||||||
}
|
}
|
||||||
if (!rsaKey) {
|
if (!rsaKey) {
|
||||||
QStringList suggested, my;
|
QStringList suggested, my;
|
||||||
for (const MTPlong &fingerPrint : fingerPrints) {
|
for (const auto &fingerPrint : fingerPrints) {
|
||||||
suggested.push_back(QString("%1").arg(fingerPrint.v));
|
suggested.push_back(QString("%1").arg(fingerPrint.v));
|
||||||
}
|
}
|
||||||
for (auto i = RSAKeys.cbegin(), e = RSAKeys.cend(); i != e; ++i) {
|
for (auto i = RSAKeys.cbegin(), e = RSAKeys.cend(); i != e; ++i) {
|
||||||
|
@ -2505,7 +2505,7 @@ void ConnectionPrivate::dhParamsAnswered() {
|
||||||
|
|
||||||
switch (res_DH_params.type()) {
|
switch (res_DH_params.type()) {
|
||||||
case mtpc_server_DH_params_ok: {
|
case mtpc_server_DH_params_ok: {
|
||||||
const MTPDserver_DH_params_ok &encDH(res_DH_params.c_server_DH_params_ok());
|
const auto &encDH(res_DH_params.c_server_DH_params_ok());
|
||||||
if (encDH.vnonce != authKeyData->nonce) {
|
if (encDH.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_params_ok)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_params_ok)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&encDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&encDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2548,7 +2548,7 @@ void ConnectionPrivate::dhParamsAnswered() {
|
||||||
|
|
||||||
const mtpPrime *from(&decBuffer[5]), *to(from), *end(from + (encDHBufLen - 5));
|
const mtpPrime *from(&decBuffer[5]), *to(from), *end(from + (encDHBufLen - 5));
|
||||||
MTPServer_DH_inner_data dh_inner(to, end);
|
MTPServer_DH_inner_data dh_inner(to, end);
|
||||||
const MTPDserver_DH_inner_data &dh_inner_data(dh_inner.c_server_DH_inner_data());
|
const auto &dh_inner_data(dh_inner.c_server_DH_inner_data());
|
||||||
if (dh_inner_data.vnonce != authKeyData->nonce) {
|
if (dh_inner_data.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_inner_data)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_inner_data)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&dh_inner_data.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&dh_inner_data.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2590,7 +2590,7 @@ void ConnectionPrivate::dhParamsAnswered() {
|
||||||
} return dhClientParamsSend();
|
} return dhClientParamsSend();
|
||||||
|
|
||||||
case mtpc_server_DH_params_fail: {
|
case mtpc_server_DH_params_fail: {
|
||||||
const MTPDserver_DH_params_fail &encDH(res_DH_params.c_server_DH_params_fail());
|
const auto &encDH(res_DH_params.c_server_DH_params_fail());
|
||||||
if (encDH.vnonce != authKeyData->nonce) {
|
if (encDH.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_params_fail)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in server_DH_params_fail)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&encDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&encDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2691,7 +2691,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
|
||||||
|
|
||||||
switch (res_client_DH_params.type()) {
|
switch (res_client_DH_params.type()) {
|
||||||
case mtpc_dh_gen_ok: {
|
case mtpc_dh_gen_ok: {
|
||||||
const MTPDdh_gen_ok &resDH(res_client_DH_params.c_dh_gen_ok());
|
const auto &resDH(res_client_DH_params.c_dh_gen_ok());
|
||||||
if (resDH.vnonce != authKeyData->nonce) {
|
if (resDH.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_ok)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_ok)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2731,7 +2731,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
|
||||||
} return;
|
} return;
|
||||||
|
|
||||||
case mtpc_dh_gen_retry: {
|
case mtpc_dh_gen_retry: {
|
||||||
const MTPDdh_gen_retry &resDH(res_client_DH_params.c_dh_gen_retry());
|
const auto &resDH(res_client_DH_params.c_dh_gen_retry());
|
||||||
if (resDH.vnonce != authKeyData->nonce) {
|
if (resDH.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_retry)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_retry)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
@ -2759,7 +2759,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
|
||||||
} return dhClientParamsSend();
|
} return dhClientParamsSend();
|
||||||
|
|
||||||
case mtpc_dh_gen_fail: {
|
case mtpc_dh_gen_fail: {
|
||||||
const MTPDdh_gen_fail &resDH(res_client_DH_params.c_dh_gen_fail());
|
const auto &resDH(res_client_DH_params.c_dh_gen_fail());
|
||||||
if (resDH.vnonce != authKeyData->nonce) {
|
if (resDH.vnonce != authKeyData->nonce) {
|
||||||
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_fail)!"));
|
LOG(("AuthKey Error: received nonce <> sent nonce (in dh_gen_fail)!"));
|
||||||
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
DEBUG_LOG(("AuthKey Error: received nonce: %1, sent nonce: %2").arg(Logs::mb(&resDH.vnonce, 16).str()).arg(Logs::mb(&authKeyData->nonce, 16).str()));
|
||||||
|
|
|
@ -211,8 +211,8 @@ void AutoConnection::requestFinished(QNetworkReply *reply) {
|
||||||
emit receivedData();
|
emit receivedData();
|
||||||
} else if (status == WaitingBoth || status == WaitingHttp) {
|
} else if (status == WaitingBoth || status == WaitingHttp) {
|
||||||
try {
|
try {
|
||||||
MTPResPQ res_pq = readPQFakeReply(data);
|
auto res_pq = readPQFakeReply(data);
|
||||||
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
|
const auto &res_pq_data(res_pq.c_resPQ());
|
||||||
if (res_pq_data.vnonce == httpNonce) {
|
if (res_pq_data.vnonce == httpNonce) {
|
||||||
if (status == WaitingBoth) {
|
if (status == WaitingBoth) {
|
||||||
status = HttpReady;
|
status = HttpReady;
|
||||||
|
@ -277,8 +277,8 @@ void AutoConnection::socketPacket(const char *packet, uint32 length) {
|
||||||
} else if (status == WaitingBoth || status == WaitingTcp || status == HttpReady) {
|
} else if (status == WaitingBoth || status == WaitingTcp || status == HttpReady) {
|
||||||
tcpTimeoutTimer.stop();
|
tcpTimeoutTimer.stop();
|
||||||
try {
|
try {
|
||||||
MTPResPQ res_pq = readPQFakeReply(data);
|
auto res_pq = readPQFakeReply(data);
|
||||||
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
|
const auto &res_pq_data(res_pq.c_resPQ());
|
||||||
if (res_pq_data.vnonce == tcpNonce) {
|
if (res_pq_data.vnonce == tcpNonce) {
|
||||||
DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flagsTcp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flagsTcp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
||||||
status = UsingTcp;
|
status = UsingTcp;
|
||||||
|
|
|
@ -170,8 +170,8 @@ void HTTPConnection::requestFinished(QNetworkReply *reply) {
|
||||||
emit receivedData();
|
emit receivedData();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
MTPResPQ res_pq = readPQFakeReply(data);
|
auto res_pq = readPQFakeReply(data);
|
||||||
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
|
const auto &res_pq_data(res_pq.c_resPQ());
|
||||||
if (res_pq_data.vnonce == httpNonce) {
|
if (res_pq_data.vnonce == httpNonce) {
|
||||||
DEBUG_LOG(("Connection Info: HTTP/%1-transport connected by pq-response").arg((_flags & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
DEBUG_LOG(("Connection Info: HTTP/%1-transport connected by pq-response").arg((_flags & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
||||||
status = UsingHttp;
|
status = UsingHttp;
|
||||||
|
|
|
@ -361,8 +361,8 @@ void TCPConnection::socketPacket(const char *packet, uint32 length) {
|
||||||
} else if (status == WaitingTcp) {
|
} else if (status == WaitingTcp) {
|
||||||
tcpTimeoutTimer.stop();
|
tcpTimeoutTimer.stop();
|
||||||
try {
|
try {
|
||||||
MTPResPQ res_pq = readPQFakeReply(data);
|
auto res_pq = readPQFakeReply(data);
|
||||||
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
|
const auto &res_pq_data(res_pq.c_resPQ());
|
||||||
if (res_pq_data.vnonce == tcpNonce) {
|
if (res_pq_data.vnonce == tcpNonce) {
|
||||||
DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flags & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flags & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4"));
|
||||||
status = UsingTcp;
|
status = UsingTcp;
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace {
|
||||||
void configLoaded(const MTPConfig &result) {
|
void configLoaded(const MTPConfig &result) {
|
||||||
loadingConfig = false;
|
loadingConfig = false;
|
||||||
|
|
||||||
const MTPDconfig &data(result.c_config());
|
const auto &data(result.c_config());
|
||||||
|
|
||||||
DEBUG_LOG(("MTP Info: got config, chat_size_max: %1, date: %2, test_mode: %3, this_dc: %4, dc_options.length: %5").arg(data.vchat_size_max.v).arg(data.vdate.v).arg(mtpIsTrue(data.vtest_mode)).arg(data.vthis_dc.v).arg(data.vdc_options.c_vector().v.size()));
|
DEBUG_LOG(("MTP Info: got config, chat_size_max: %1, date: %2, test_mode: %3, this_dc: %4, dc_options.length: %5").arg(data.vchat_size_max.v).arg(data.vdate.v).arg(mtpIsTrue(data.vtest_mode)).arg(data.vthis_dc.v).arg(data.vdc_options.c_vector().v.size()));
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ namespace {
|
||||||
configLoader()->done();
|
configLoader()->done();
|
||||||
}
|
}
|
||||||
bool configFailed(const RPCError &error) {
|
bool configFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
loadingConfig = false;
|
loadingConfig = false;
|
||||||
LOG(("MTP Error: failed to get config!"));
|
LOG(("MTP Error: failed to get config!"));
|
||||||
|
@ -194,7 +194,7 @@ void updateDcOptions(const QVector<MTPDcOption> &options) {
|
||||||
opts = Global::DcOptions();
|
opts = Global::DcOptions();
|
||||||
}
|
}
|
||||||
for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) {
|
for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) {
|
||||||
const MTPDdcOption &optData(i->c_dcOption());
|
const auto &optData(i->c_dcOption());
|
||||||
int32 id = optData.vid.v, idWithShift = MTP::shiftDcId(id, optData.vflags.v);
|
int32 id = optData.vid.v, idWithShift = MTP::shiftDcId(id, optData.vflags.v);
|
||||||
if (already.constFind(idWithShift) == already.cend()) {
|
if (already.constFind(idWithShift) == already.cend()) {
|
||||||
already.insert(idWithShift);
|
already.insert(idWithShift);
|
||||||
|
@ -264,7 +264,7 @@ void ConfigLoader::enumDC() {
|
||||||
OrderedSet<int32> dcs;
|
OrderedSet<int32> dcs;
|
||||||
{
|
{
|
||||||
QReadLocker lock(dcOptionsMutex());
|
QReadLocker lock(dcOptionsMutex());
|
||||||
const MTP::DcOptions &options(Global::DcOptions());
|
const auto &options(Global::DcOptions());
|
||||||
for (auto i = options.cbegin(), e = options.cend(); i != e; ++i) {
|
for (auto i = options.cbegin(), e = options.cend(); i != e; ++i) {
|
||||||
dcs.insert(MTP::bareDcId(i.key()));
|
dcs.insert(MTP::bareDcId(i.key()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool importFail(const RPCError &error, mtpRequestId req) {
|
bool importFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (globalHandler.onFail && authedId()) (*globalHandler.onFail)(req, error); // auth import failed
|
if (globalHandler.onFail && authedId()) (*globalHandler.onFail)(req, error); // auth import failed
|
||||||
return true;
|
return true;
|
||||||
|
@ -140,13 +140,13 @@ namespace {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MTPDauth_exportedAuthorization &data(result.c_auth_exportedAuthorization());
|
const auto &data(result.c_auth_exportedAuthorization());
|
||||||
send(MTPauth_ImportAuthorization(data.vid, data.vbytes), rpcDone(importDone), rpcFail(importFail), i.value());
|
send(MTPauth_ImportAuthorization(data.vid, data.vbytes), rpcDone(importDone), rpcFail(importFail), i.value());
|
||||||
authExportRequests.remove(req);
|
authExportRequests.remove(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exportFail(const RPCError &error, mtpRequestId req) {
|
bool exportFail(const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
AuthExportRequests::const_iterator i = authExportRequests.constFind(req);
|
AuthExportRequests::const_iterator i = authExportRequests.constFind(req);
|
||||||
if (i != authExportRequests.cend()) {
|
if (i != authExportRequests.cend()) {
|
||||||
|
@ -159,7 +159,7 @@ namespace {
|
||||||
bool onErrorDefault(mtpRequestId requestId, const RPCError &error) {
|
bool onErrorDefault(mtpRequestId requestId, const RPCError &error) {
|
||||||
const QString &err(error.type());
|
const QString &err(error.type());
|
||||||
int32 code = error.code();
|
int32 code = error.code();
|
||||||
if (!mtpIsFlood(error) && err != qsl("AUTH_KEY_UNREGISTERED")) {
|
if (!isFloodError(error) && err != qstr("AUTH_KEY_UNREGISTERED")) {
|
||||||
int breakpoint = 0;
|
int breakpoint = 0;
|
||||||
}
|
}
|
||||||
bool badGuestDC = (code == 400) && (err == qsl("FILE_ID_INVALID"));
|
bool badGuestDC = (code == 400) && (err == qsl("FILE_ID_INVALID"));
|
||||||
|
@ -262,7 +262,7 @@ namespace {
|
||||||
waiters.push_back(requestId);
|
waiters.push_back(requestId);
|
||||||
if (badGuestDC) badGuestDCRequests.insert(requestId);
|
if (badGuestDC) badGuestDCRequests.insert(requestId);
|
||||||
return true;
|
return true;
|
||||||
} else if (err == qsl("CONNECTION_NOT_INITED") || err == qsl("CONNECTION_LAYER_INVALID")) {
|
} else if (err == qstr("CONNECTION_NOT_INITED") || err == qstr("CONNECTION_LAYER_INVALID")) {
|
||||||
mtpRequest req;
|
mtpRequest req;
|
||||||
{
|
{
|
||||||
QReadLocker locker(&requestMapLock);
|
QReadLocker locker(&requestMapLock);
|
||||||
|
@ -290,7 +290,7 @@ namespace {
|
||||||
session->sendPrepared(req);
|
session->sendPrepared(req);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (err == qsl("MSG_WAIT_FAILED")) {
|
} else if (err == qstr("MSG_WAIT_FAILED")) {
|
||||||
mtpRequest req;
|
mtpRequest req;
|
||||||
{
|
{
|
||||||
QReadLocker locker(&requestMapLock);
|
QReadLocker locker(&requestMapLock);
|
||||||
|
@ -570,7 +570,7 @@ void onSessionReset(int32 dcWithShift) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rpcErrorOccured(mtpRequestId requestId, const RPCFailHandlerPtr &onFail, const RPCError &err) { // return true if need to clean request data
|
bool rpcErrorOccured(mtpRequestId requestId, const RPCFailHandlerPtr &onFail, const RPCError &err) { // return true if need to clean request data
|
||||||
if (mtpIsFlood(err)) {
|
if (isDefaultHandledError(err)) {
|
||||||
if (onFail && (*onFail)(requestId, err)) return true;
|
if (onFail && (*onFail)(requestId, err)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -462,7 +462,7 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||||
--_queue->queries;
|
--_queue->queries;
|
||||||
_requests.erase(i);
|
_requests.erase(i);
|
||||||
|
|
||||||
const MTPDupload_file &d(result.c_upload_file());
|
const auto &d(result.c_upload_file());
|
||||||
const string &bytes(d.vbytes.c_string().v);
|
const string &bytes(d.vbytes.c_string().v);
|
||||||
|
|
||||||
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): got part with offset=%2, bytes=%3, _queue->queries=%4, _nextRequestOffset=%5, _requests=%6").arg(_id).arg(offset).arg(bytes.size()).arg(_queue->queries).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): got part with offset=%2, bytes=%3, _queue->queries=%4, _nextRequestOffset=%5, _requests=%6").arg(_id).arg(offset).arg(bytes.size()).arg(_queue->queries).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
||||||
|
@ -549,7 +549,7 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mtpFileLoader::partFailed(const RPCError &error) {
|
bool mtpFileLoader::partFailed(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
cancel(true);
|
cancel(true);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,19 +24,18 @@ class RPCError {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) {
|
RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) {
|
||||||
const string &msg(error.c_rpc_error().verror_message.c_string().v);
|
QString text = qs(error.c_rpc_error().verror_message);
|
||||||
const QString &text(QString::fromUtf8(msg.c_str(), msg.length()));
|
|
||||||
if (_code < 0 || _code >= 500) {
|
if (_code < 0 || _code >= 500) {
|
||||||
_type = "INTERNAL_SERVER_ERROR";
|
_type = qsl("INTERNAL_SERVER_ERROR");
|
||||||
_description = text;
|
_description = text;
|
||||||
} else {
|
} else {
|
||||||
QRegularExpressionMatch m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
|
auto m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
|
||||||
if (m.hasMatch()) {
|
if (m.hasMatch()) {
|
||||||
_type = m.captured(1);
|
_type = m.captured(1);
|
||||||
_description = m.captured(2).mid(2);
|
_description = m.captured(2).mid(2);
|
||||||
} else {
|
} else {
|
||||||
_type = "CLIENT_BAD_RPC_ERROR";
|
_type = qsl("CLIENT_BAD_RPC_ERROR");
|
||||||
_description = "Bad rpc error received, text = '" + text + "'";
|
_description = qsl("Bad rpc error received, text = '") + text + '\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,10 +63,22 @@ private:
|
||||||
QString _type, _description;
|
QString _type, _description;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool mtpIsFlood(const RPCError &error) {
|
namespace MTP {
|
||||||
return error.type().startsWith(qsl("FLOOD_WAIT_"));
|
|
||||||
|
inline bool isFloodError(const RPCError &error) {
|
||||||
|
return error.type().startsWith(qstr("FLOOD_WAIT_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isTemporaryError(const RPCError &error) {
|
||||||
|
return error.code() < 0 || error.code() >= 500 || isFloodError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isDefaultHandledError(const RPCError &error) {
|
||||||
|
return isTemporaryError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace MTP
|
||||||
|
|
||||||
class RPCAbstractDoneHandler { // abstract done
|
class RPCAbstractDoneHandler { // abstract done
|
||||||
public:
|
public:
|
||||||
virtual void operator()(mtpRequestId requestId, const mtpPrime *from, const mtpPrime *end) const = 0;
|
virtual void operator()(mtpRequestId requestId, const mtpPrime *from, const mtpPrime *end) const = 0;
|
||||||
|
|
|
@ -214,7 +214,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
|
||||||
const QVector<MTPMessage> *messages = 0;
|
const QVector<MTPMessage> *messages = 0;
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
case mtpc_messages_messages: {
|
case mtpc_messages_messages: {
|
||||||
const MTPDmessages_messages &d(result.c_messages_messages());
|
const auto &d(result.c_messages_messages());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
messages = &d.vmessages.c_vector().v;
|
messages = &d.vmessages.c_vector().v;
|
||||||
|
@ -222,7 +222,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
case mtpc_messages_messagesSlice: {
|
||||||
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
|
const auto &d(result.c_messages_messagesSlice());
|
||||||
App::feedUsers(d.vusers);
|
App::feedUsers(d.vusers);
|
||||||
App::feedChats(d.vchats);
|
App::feedChats(d.vchats);
|
||||||
messages = &d.vmessages.c_vector().v;
|
messages = &d.vmessages.c_vector().v;
|
||||||
|
@ -230,7 +230,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
case mtpc_messages_channelMessages: {
|
||||||
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
|
const auto &d(result.c_messages_channelMessages());
|
||||||
if (_peer && _peer->isChannel()) {
|
if (_peer && _peer->isChannel()) {
|
||||||
_peer->asChannel()->ptsReceived(d.vpts.v);
|
_peer->asChannel()->ptsReceived(d.vpts.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,7 +286,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverviewInner::searchFailed(SearchRequestType type, const RPCError &error, mtpRequestId req) {
|
bool OverviewInner::searchFailed(SearchRequestType type, const RPCError &error, mtpRequestId req) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_searchRequest == req) {
|
if (_searchRequest == req) {
|
||||||
_searchRequest = 0;
|
_searchRequest = 0;
|
||||||
|
|
|
@ -384,7 +384,7 @@ void ProfileInner::blockDone(bool blocked, const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileInner::blockFail(const RPCError &error) {
|
bool ProfileInner::blockFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_blockRequest = 0;
|
_blockRequest = 0;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1364,7 +1364,7 @@ void ProfileInner::migrateDone(const MTPUpdates &updates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileInner::migrateFail(const RPCError &error) {
|
bool ProfileInner::migrateFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -953,7 +953,7 @@ void SettingsInner::gotPassword(const MTPaccount_Password &result) {
|
||||||
|
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
case mtpc_account_noPassword: {
|
case mtpc_account_noPassword: {
|
||||||
const MTPDaccount_noPassword &d(result.c_account_noPassword());
|
const auto &d(result.c_account_noPassword());
|
||||||
_curPasswordSalt = QByteArray();
|
_curPasswordSalt = QByteArray();
|
||||||
_hasPasswordRecovery = false;
|
_hasPasswordRecovery = false;
|
||||||
_curPasswordHint = QString();
|
_curPasswordHint = QString();
|
||||||
|
@ -963,7 +963,7 @@ void SettingsInner::gotPassword(const MTPaccount_Password &result) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_account_password: {
|
case mtpc_account_password: {
|
||||||
const MTPDaccount_password &d(result.c_account_password());
|
const auto &d(result.c_account_password());
|
||||||
_curPasswordSalt = qba(d.vcurrent_salt);
|
_curPasswordSalt = qba(d.vcurrent_salt);
|
||||||
_hasPasswordRecovery = mtpIsTrue(d.vhas_recovery);
|
_hasPasswordRecovery = mtpIsTrue(d.vhas_recovery);
|
||||||
_curPasswordHint = qs(d.vhint);
|
_curPasswordHint = qs(d.vhint);
|
||||||
|
@ -986,7 +986,7 @@ void SettingsInner::offPasswordDone(const MTPBool &result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsInner::offPasswordFail(const RPCError &error) {
|
bool SettingsInner::offPasswordFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
onReloadPassword();
|
onReloadPassword();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1182,7 +1182,7 @@ void SettingsInner::supportGot(const MTPhelp_Support &support) {
|
||||||
if (!App::main()) return;
|
if (!App::main()) return;
|
||||||
|
|
||||||
if (support.type() == mtpc_help_support) {
|
if (support.type() == mtpc_help_support) {
|
||||||
const MTPDhelp_support &d(support.c_help_support());
|
const auto &d(support.c_help_support());
|
||||||
UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
|
UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
|
||||||
Ui::showPeerHistory(u, ShowAtUnreadMsgId);
|
Ui::showPeerHistory(u, ShowAtUnreadMsgId);
|
||||||
App::wnd()->hideSettings();
|
App::wnd()->hideSettings();
|
||||||
|
|
|
@ -203,7 +203,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
|
||||||
StorageImageLocation newPhotoLoc = photoLoc;
|
StorageImageLocation newPhotoLoc = photoLoc;
|
||||||
switch (p.type()) {
|
switch (p.type()) {
|
||||||
case mtpc_userProfilePhoto: {
|
case mtpc_userProfilePhoto: {
|
||||||
const MTPDuserProfilePhoto d(p.c_userProfilePhoto());
|
const auto &d(p.c_userProfilePhoto());
|
||||||
newPhotoId = d.vphoto_id.v;
|
newPhotoId = d.vphoto_id.v;
|
||||||
newPhotoLoc = App::imageLocation(160, 160, d.vphoto_small);
|
newPhotoLoc = App::imageLocation(160, 160, d.vphoto_small);
|
||||||
newPhoto = newPhotoLoc.isNull() ? userDefPhoto(colorIndex) : ImagePtr(newPhotoLoc);
|
newPhoto = newPhotoLoc.isNull() ? userDefPhoto(colorIndex) : ImagePtr(newPhotoLoc);
|
||||||
|
@ -307,7 +307,7 @@ void UserData::setBotInfoVersion(int version) {
|
||||||
void UserData::setBotInfo(const MTPBotInfo &info) {
|
void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||||
switch (info.type()) {
|
switch (info.type()) {
|
||||||
case mtpc_botInfo: {
|
case mtpc_botInfo: {
|
||||||
const MTPDbotInfo &d(info.c_botInfo());
|
const auto &d(info.c_botInfo());
|
||||||
if (peerFromUser(d.vuser_id.v) != id || !botInfo) return;
|
if (peerFromUser(d.vuser_id.v) != id || !botInfo) return;
|
||||||
|
|
||||||
QString desc = qs(d.vdescription);
|
QString desc = qs(d.vdescription);
|
||||||
|
@ -316,7 +316,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||||
botInfo->text = Text(st::msgMinWidth);
|
botInfo->text = Text(st::msgMinWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<MTPBotCommand> &v(d.vcommands.c_vector().v);
|
const auto &v(d.vcommands.c_vector().v);
|
||||||
botInfo->commands.reserve(v.size());
|
botInfo->commands.reserve(v.size());
|
||||||
bool changedCommands = false;
|
bool changedCommands = false;
|
||||||
int32 j = 0;
|
int32 j = 0;
|
||||||
|
@ -378,7 +378,7 @@ void ChatData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see Loc
|
||||||
StorageImageLocation newPhotoLoc = photoLoc;
|
StorageImageLocation newPhotoLoc = photoLoc;
|
||||||
switch (p.type()) {
|
switch (p.type()) {
|
||||||
case mtpc_chatPhoto: {
|
case mtpc_chatPhoto: {
|
||||||
const MTPDchatPhoto d(p.c_chatPhoto());
|
const auto &d(p.c_chatPhoto());
|
||||||
if (phId != UnknownPeerPhotoId) {
|
if (phId != UnknownPeerPhotoId) {
|
||||||
newPhotoId = phId;
|
newPhotoId = phId;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ void ChannelData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see
|
||||||
StorageImageLocation newPhotoLoc = photoLoc;
|
StorageImageLocation newPhotoLoc = photoLoc;
|
||||||
switch (p.type()) {
|
switch (p.type()) {
|
||||||
case mtpc_chatPhoto: {
|
case mtpc_chatPhoto: {
|
||||||
const MTPDchatPhoto d(p.c_chatPhoto());
|
const auto &d(p.c_chatPhoto());
|
||||||
if (phId != UnknownPeerPhotoId) {
|
if (phId != UnknownPeerPhotoId) {
|
||||||
newPhotoId = phId;
|
newPhotoId = phId;
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
|
||||||
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
|
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
|
||||||
switch (attributes[i].type()) {
|
switch (attributes[i].type()) {
|
||||||
case mtpc_documentAttributeImageSize: {
|
case mtpc_documentAttributeImageSize: {
|
||||||
const MTPDdocumentAttributeImageSize &d(attributes[i].c_documentAttributeImageSize());
|
const auto &d(attributes[i].c_documentAttributeImageSize());
|
||||||
dimensions = QSize(d.vw.v, d.vh.v);
|
dimensions = QSize(d.vw.v, d.vh.v);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_documentAttributeAnimated: if (type == FileDocument || type == StickerDocument || type == VideoDocument) {
|
case mtpc_documentAttributeAnimated: if (type == FileDocument || type == StickerDocument || type == VideoDocument) {
|
||||||
|
@ -1017,7 +1017,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
|
||||||
_additional = 0;
|
_additional = 0;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_documentAttributeSticker: {
|
case mtpc_documentAttributeSticker: {
|
||||||
const MTPDdocumentAttributeSticker &d(attributes[i].c_documentAttributeSticker());
|
const auto &d(attributes[i].c_documentAttributeSticker());
|
||||||
if (type == FileDocument) {
|
if (type == FileDocument) {
|
||||||
type = StickerDocument;
|
type = StickerDocument;
|
||||||
StickerData *sticker = new StickerData();
|
StickerData *sticker = new StickerData();
|
||||||
|
@ -1029,7 +1029,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_documentAttributeVideo: {
|
case mtpc_documentAttributeVideo: {
|
||||||
const MTPDdocumentAttributeVideo &d(attributes[i].c_documentAttributeVideo());
|
const auto &d(attributes[i].c_documentAttributeVideo());
|
||||||
if (type == FileDocument) {
|
if (type == FileDocument) {
|
||||||
type = VideoDocument;
|
type = VideoDocument;
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1037,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
|
||||||
dimensions = QSize(d.vw.v, d.vh.v);
|
dimensions = QSize(d.vw.v, d.vh.v);
|
||||||
} break;
|
} break;
|
||||||
case mtpc_documentAttributeAudio: {
|
case mtpc_documentAttributeAudio: {
|
||||||
const MTPDdocumentAttributeAudio &d(attributes[i].c_documentAttributeAudio());
|
const auto &d(attributes[i].c_documentAttributeAudio());
|
||||||
if (type == FileDocument) {
|
if (type == FileDocument) {
|
||||||
if (d.is_voice()) {
|
if (d.is_voice()) {
|
||||||
type = VoiceDocument;
|
type = VoiceDocument;
|
||||||
|
|
|
@ -70,18 +70,18 @@ inline EntitiesInText entitiesFromMTP(const QVector<MTPMessageEntity> &entities)
|
||||||
if (!entities.isEmpty()) {
|
if (!entities.isEmpty()) {
|
||||||
result.reserve(entities.size());
|
result.reserve(entities.size());
|
||||||
for (int32 i = 0, l = entities.size(); i != l; ++i) {
|
for (int32 i = 0, l = entities.size(); i != l; ++i) {
|
||||||
const MTPMessageEntity &e(entities.at(i));
|
const auto &e(entities.at(i));
|
||||||
switch (e.type()) {
|
switch (e.type()) {
|
||||||
case mtpc_messageEntityUrl: { const MTPDmessageEntityUrl &d(e.c_messageEntityUrl()); result.push_back(EntityInText(EntityInTextUrl, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityUrl: { const auto &d(e.c_messageEntityUrl()); result.push_back(EntityInText(EntityInTextUrl, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityTextUrl: { const MTPDmessageEntityTextUrl &d(e.c_messageEntityTextUrl()); result.push_back(EntityInText(EntityInTextCustomUrl, d.voffset.v, d.vlength.v, textClean(qs(d.vurl)))); } break;
|
case mtpc_messageEntityTextUrl: { const auto &d(e.c_messageEntityTextUrl()); result.push_back(EntityInText(EntityInTextCustomUrl, d.voffset.v, d.vlength.v, textClean(qs(d.vurl)))); } break;
|
||||||
case mtpc_messageEntityEmail: { const MTPDmessageEntityEmail &d(e.c_messageEntityEmail()); result.push_back(EntityInText(EntityInTextEmail, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityEmail: { const auto &d(e.c_messageEntityEmail()); result.push_back(EntityInText(EntityInTextEmail, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityHashtag: { const MTPDmessageEntityHashtag &d(e.c_messageEntityHashtag()); result.push_back(EntityInText(EntityInTextHashtag, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityHashtag: { const auto &d(e.c_messageEntityHashtag()); result.push_back(EntityInText(EntityInTextHashtag, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityMention: { const MTPDmessageEntityMention &d(e.c_messageEntityMention()); result.push_back(EntityInText(EntityInTextMention, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityMention: { const auto &d(e.c_messageEntityMention()); result.push_back(EntityInText(EntityInTextMention, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityBotCommand: { const MTPDmessageEntityBotCommand &d(e.c_messageEntityBotCommand()); result.push_back(EntityInText(EntityInTextBotCommand, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityBotCommand: { const auto &d(e.c_messageEntityBotCommand()); result.push_back(EntityInText(EntityInTextBotCommand, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityBold: { const MTPDmessageEntityBold &d(e.c_messageEntityBold()); result.push_back(EntityInText(EntityInTextBold, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityBold: { const auto &d(e.c_messageEntityBold()); result.push_back(EntityInText(EntityInTextBold, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityItalic: { const MTPDmessageEntityItalic &d(e.c_messageEntityItalic()); result.push_back(EntityInText(EntityInTextItalic, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityItalic: { const auto &d(e.c_messageEntityItalic()); result.push_back(EntityInText(EntityInTextItalic, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityCode: { const MTPDmessageEntityCode &d(e.c_messageEntityCode()); result.push_back(EntityInText(EntityInTextCode, d.voffset.v, d.vlength.v)); } break;
|
case mtpc_messageEntityCode: { const auto &d(e.c_messageEntityCode()); result.push_back(EntityInText(EntityInTextCode, d.voffset.v, d.vlength.v)); } break;
|
||||||
case mtpc_messageEntityPre: { const MTPDmessageEntityPre &d(e.c_messageEntityPre()); result.push_back(EntityInText(EntityInTextPre, d.voffset.v, d.vlength.v, textClean(qs(d.vlanguage)))); } break;
|
case mtpc_messageEntityPre: { const auto &d(e.c_messageEntityPre()); result.push_back(EntityInText(EntityInTextPre, d.voffset.v, d.vlength.v, textClean(qs(d.vlanguage)))); } break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue