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:
John Preston 2016-04-08 14:44:35 +04:00
parent 35d5089f48
commit 8e89486fbc
41 changed files with 587 additions and 535 deletions

View File

@ -432,7 +432,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\
QMap<QByteArray, QVector<QString> > &countedTags(keysCounted[keysOrder[i]]);
if (!countedTags.isEmpty()) {
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) {
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]]);
if (!countedTags.isEmpty()) {
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) {
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]]);
if (!countedTags.isEmpty()) {
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) {
writeCppKey(tcpp, keysOrder[i] + "__" + j.key() + QString::number(k).toUtf8(), counted[k]);
}

View File

@ -99,21 +99,21 @@ void ApiWrap::resolveMessageDatas() {
void ApiWrap::gotMessageDatas(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) {
switch (msgs.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(msgs.c_messages_messages());
const auto &d(msgs.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
App::feedMsgs(d.vmessages, NewMessageExisting);
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
const auto &d(msgs.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
App::feedMsgs(d.vmessages, NewMessageExisting);
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
const auto &d(msgs.c_messages_channelMessages());
if (channel) {
channel->ptsReceived(d.vpts.v);
} else {
@ -169,8 +169,8 @@ void ApiWrap::processFullPeer(PeerData *peer, const MTPUserFull &result) {
}
void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mtpRequestId req) {
const MTPDmessages_chatFull &d(result.c_messages_chatFull());
const QVector<MTPChat> &vc(d.vchats.c_vector().v);
const auto &d(result.c_messages_chatFull());
const auto &vc(d.vchats.c_vector().v);
bool badVersion = false;
if (peer->isChat()) {
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()));
return;
}
const MTPDchatFull &f(d.vfull_chat.c_chatFull());
const auto &f(d.vfull_chat.c_chatFull());
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) {
switch (i->type()) {
case mtpc_botInfo: {
const MTPDbotInfo &b(i->c_botInfo());
const auto &b(i->c_botInfo());
UserData *user = App::userLoaded(b.vuser_id.v);
if (user) {
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()));
return;
}
const MTPDchannelFull &f(d.vfull_chat.c_channelFull());
const auto &f(d.vfull_chat.c_channelFull());
PhotoData *photo = App::feedPhoto(f.vchat_photo);
ChannelData *channel = peer->asChannel();
channel->flagsFull = f.vflags.v;
@ -257,11 +257,11 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
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) {
switch (i->type()) {
case mtpc_botInfo: {
const MTPDbotInfo &b(i->c_botInfo());
const auto &b(i->c_botInfo());
UserData *user = App::userLoaded(b.vuser_id.v);
if (user) {
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) {
const MTPDuserFull &d(result.c_userFull());
const auto &d(result.c_userFull());
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
if (d.has_profile_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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_fullPeerRequests.remove(peer);
return true;
@ -420,7 +420,7 @@ void ApiWrap::gotChat(PeerData *peer, const MTPmessages_Chats &result) {
_peerRequests.remove(peer);
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;
if (peer->isChat()) {
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_peerRequests.remove(peer);
return true;
@ -491,8 +491,8 @@ void ApiWrap::lastParticipantsDone(ChannelData *peer, const MTPchannels_ChannelP
peer->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate;
}
const MTPDchannels_channelParticipants &d(result.c_channels_channelParticipants());
const QVector<MTPChannelParticipant> &v(d.vparticipants.c_vector().v);
const auto &d(result.c_channels_channelParticipants());
const auto &v(d.vparticipants.c_vector().v);
App::feedUsers(d.vusers);
bool added = false, needBotsInfos = false;
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_participantsRequests.value(peer) == req || _participantsRequests.value(peer) == -req) {
_participantsRequests.remove(peer);
} else if (_botsRequests.value(peer) == req) {
@ -578,27 +578,27 @@ void ApiWrap::gotSelfParticipant(ChannelData *channel, const MTPchannels_Channel
return;
}
const MTPDchannels_channelParticipant &p(result.c_channels_channelParticipant());
const auto &p(result.c_channels_channelParticipant());
App::feedUsers(p.vusers);
switch (p.vparticipant.type()) {
case mtpc_channelParticipantSelf: {
const MTPDchannelParticipantSelf &d(p.vparticipant.c_channelParticipantSelf());
const auto &d(p.vparticipant.c_channelParticipantSelf());
channel->inviter = d.vinviter_id.v;
channel->inviteDate = date(d.vdate);
} break;
case mtpc_channelParticipantCreator: {
const MTPDchannelParticipantCreator &d(p.vparticipant.c_channelParticipantCreator());
const auto &d(p.vparticipant.c_channelParticipantCreator());
channel->inviter = MTP::authedId();
channel->inviteDate = date(MTP_int(channel->date));
} break;
case mtpc_channelParticipantModerator: {
const MTPDchannelParticipantModerator &d(p.vparticipant.c_channelParticipantModerator());
const auto &d(p.vparticipant.c_channelParticipantModerator());
channel->inviter = d.vinviter_id.v;
channel->inviteDate = date(d.vdate);
} break;
case mtpc_channelParticipantEditor: {
const MTPDchannelParticipantEditor &d(p.vparticipant.c_channelParticipantEditor());
const auto &d(p.vparticipant.c_channelParticipantEditor());
channel->inviter = d.vinviter_id.v;
channel->inviteDate = date(d.vdate);
} break;
@ -609,7 +609,7 @@ void ApiWrap::gotSelfParticipant(ChannelData *channel, const MTPchannels_Channel
}
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")) {
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_kickRequests.remove(kick);
return true;
}
@ -680,10 +680,10 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
_stickerSetRequests.remove(setId);
if (result.type() != mtpc_messages_stickerSet) return;
const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
const auto &d(result.c_messages_stickerSet());
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());
auto it = sets.find(setId);
@ -695,7 +695,7 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
it->title = stickerSetTitle(s);
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);
StickerPack pack;
@ -735,13 +735,13 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
} else {
it->stickers = pack;
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) {
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)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
const auto &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_stickerSetRequests.remove(setId);
return true;
@ -861,21 +861,21 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs
const QVector<MTPMessage> *v = 0;
switch (msgs.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(msgs.c_messages_messages());
const auto &d(msgs.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
const auto &d(msgs.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
const auto &d(msgs.c_messages_channelMessages());
if (channel) {
channel->ptsReceived(d.vpts.v);
} else {
@ -894,7 +894,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs
if (!v) return;
QMap<uint64, int32> msgsIds; // copied from feedMsgs
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()) {
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;

View File

@ -356,16 +356,16 @@ namespace {
UserData *feedUsers(const MTPVector<MTPUser> &users, bool emitPeerUpdated) {
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) {
const MTPuser &user(*i);
const auto &user(*i);
data = 0;
bool wasContact = false, minimal = false;
const MTPUserStatus *status = 0, emptyStatus = MTP_userStatusEmpty();
switch (user.type()) {
case mtpc_userEmpty: {
const MTPDuserEmpty &d(user.c_userEmpty());
const auto &d(user.c_userEmpty());
PeerId peer(peerFromUser(d.vid.v));
data = App::user(peer);
@ -381,7 +381,7 @@ namespace {
data->contact = -1;
} break;
case mtpc_user: {
const MTPDuser &d(user.c_user());
const auto &d(user.c_user());
minimal = d.is_min();
PeerId peer(peerFromUser(d.vid.v));
@ -514,14 +514,14 @@ namespace {
PeerData *feedChats(const MTPVector<MTPChat> &chats, bool emitPeerUpdated) {
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) {
const MTPchat &chat(*i);
const auto &chat(*i);
data = 0;
bool minimal = false;
switch (chat.type()) {
case mtpc_chat: {
const MTPDchat &d(chat.c_chat());
const auto &d(chat.c_chat());
data = App::chat(peerFromChat(d.vid.v));
data->input = MTP_inputPeerChat(d.vid);
@ -533,7 +533,7 @@ namespace {
cdata->date = d.vdate.v;
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));
if (!channel->mgInfo) {
channel->flags |= MTPDchannel::Flag::f_megagroup;
@ -580,7 +580,7 @@ namespace {
}
} break;
case mtpc_chatForbidden: {
const MTPDchatForbidden &d(chat.c_chatForbidden());
const auto &d(chat.c_chatForbidden());
data = App::chat(peerFromChat(d.vid.v));
data->input = MTP_inputPeerChat(d.vid);
@ -596,7 +596,7 @@ namespace {
cdata->isForbidden = true;
} break;
case mtpc_channel: {
const MTPDchannel &d(chat.c_channel());
const auto &d(chat.c_channel());
PeerId peer(peerFromChannel(d.vid.v));
minimal = d.is_min();
@ -636,7 +636,7 @@ namespace {
cdata->setPhoto(d.vphoto);
} break;
case mtpc_channelForbidden: {
const MTPDchannelForbidden &d(chat.c_channelForbidden());
const auto &d(chat.c_channelForbidden());
PeerId peer(peerFromChannel(d.vid.v));
data = App::channel(peer);
@ -678,18 +678,18 @@ namespace {
ChatData *chat = 0;
switch (p.type()) {
case mtpc_chatParticipantsForbidden: {
const MTPDchatParticipantsForbidden &d(p.c_chatParticipantsForbidden());
const auto &d(p.c_chatParticipantsForbidden());
chat = App::chat(d.vchat_id.v);
chat->count = -1;
chat->invalidateParticipants();
} break;
case mtpc_chatParticipants: {
const MTPDchatParticipants &d(p.c_chatParticipants());
const auto &d(p.c_chatParticipants());
chat = App::chat(d.vchat_id.v);
if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result
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();
int32 pversion = chat->participants.isEmpty() ? 1 : (chat->participants.begin().value() + 1);
chat->invitedByMe = ChatData::InvitedByMe();
@ -699,17 +699,17 @@ namespace {
int32 uid = 0, inviter = 0;
switch (i->type()) {
case mtpc_chatParticipantCreator: {
const MTPDchatParticipantCreator &p(i->c_chatParticipantCreator());
const auto &p(i->c_chatParticipantCreator());
uid = p.vuser_id.v;
chat->creator = uid;
} break;
case mtpc_chatParticipantAdmin: {
const MTPDchatParticipantAdmin &p(i->c_chatParticipantAdmin());
const auto &p(i->c_chatParticipantAdmin());
uid = p.vuser_id.v;
inviter = p.vinviter_id.v;
} break;
case mtpc_chatParticipant: {
const MTPDchatParticipant &p(i->c_chatParticipant());
const auto &p(i->c_chatParticipant());
uid = p.vuser_id.v;
inviter = p.vinviter_id.v;
} break;
@ -1013,10 +1013,10 @@ namespace {
void feedMsgs(const QVector<MTPMessage> &msgs, NewMessageType type) {
QMap<uint64, int32> msgsIds;
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()) {
case mtpc_message: {
const MTPDmessage &d(msg.c_message());
const auto &d(msg.c_message());
bool needToAdd = true;
if (type == NewMessageUnread) { // new message, index my forwarded messages to links overview
if (checkEntitiesAndViewsUpdate(d)) { // already in blocks
@ -1044,17 +1044,17 @@ namespace {
ImagePtr image(const MTPPhotoSize &size) {
switch (size.type()) {
case mtpc_photoSize: {
const MTPDphotoSize &d(size.c_photoSize());
const auto &d(size.c_photoSize());
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);
}
} break;
case mtpc_photoCachedSize: {
const MTPDphotoCachedSize &d(size.c_photoCachedSize());
const auto &d(size.c_photoCachedSize());
if (d.vlocation.type() == mtpc_fileLocation) {
const MTPDfileLocation &l(d.vlocation.c_fileLocation());
const string &s(d.vbytes.c_string().v);
const auto &l(d.vlocation.c_fileLocation());
const auto &s(d.vbytes.c_string().v);
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);
} else if (d.vlocation.type() == mtpc_fileLocationUnavailable) {
@ -1069,7 +1069,7 @@ namespace {
StorageImageLocation imageLocation(int32 w, int32 h, const MTPFileLocation &loc) {
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, 0, 0, 0, 0);
@ -1078,11 +1078,11 @@ namespace {
StorageImageLocation imageLocation(const MTPPhotoSize &size) {
switch (size.type()) {
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);
} break;
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);
} break;
}
@ -1149,9 +1149,9 @@ namespace {
}
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) {
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);
MTPint userId(MTP_int(0));
switch (dv.vuser.type()) {
@ -1284,7 +1284,7 @@ namespace {
}
switch (photo.type()) {
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"));
} break;
case mtpc_photoEmpty: return App::photo(photo.c_photoEmpty().vid.v);
@ -1293,7 +1293,7 @@ namespace {
}
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;
int32 thumbLevel = -1, mediumLevel = -1, fullLevel = -1;
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) {
switch (document.type()) {
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());
} break;
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) {
if (photo.type() == mtpc_userProfilePhoto) {
const MTPDuserProfilePhoto &uphoto(photo.c_userProfilePhoto());
const auto &uphoto(photo.c_userProfilePhoto());
QVector<MTPPhotoSize> photoSizes;
photoSizes.push_back(MTP_photoSize(MTP_string("a"), uphoto.vphoto_small, MTP_int(160), MTP_int(160), MTP_int(0)));

View File

@ -835,7 +835,7 @@ void AppClass::chatPhotoCleared(PeerId peer, const MTPUpdates &updates) {
void AppClass::selfPhotoDone(const MTPphotos_Photo &result) {
if (!App::self()) return;
const MTPDphotos_photo &photo(result.c_photos_photo());
const auto &photo(result.c_photos_photo());
App::feedPhoto(photo.vphoto);
App::feedUsers(photo.vusers);
cancelPhotoUpdate(App::self()->id);
@ -851,7 +851,7 @@ void AppClass::chatPhotoDone(PeerId peer, const MTPUpdates &updates) {
}
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()));
cancelPhotoUpdate(peer);

View File

@ -199,7 +199,7 @@ void AddContactBox::onSave() {
}
bool AddContactBox::onSaveUserFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_addRequest = 0;
QString err(error.type());
@ -220,13 +220,13 @@ bool AddContactBox::onSaveUserFail(const RPCError &error) {
void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
if (isHidden() || !App::main()) return;
const MTPDcontacts_importedContacts &d(res.c_contacts_importedContacts());
const auto &d(res.c_contacts_importedContacts());
App::feedUsers(d.vusers);
const QVector<MTPImportedContact> &v(d.vimported.c_vector().v);
const auto &v(d.vimported.c_vector().v);
UserData *user = nullptr;
if (!v.isEmpty()) {
const MTPDimportedContact &c(v.front().c_importedContact());
const auto &c(v.front().c_importedContact());
if (c.vclient_id.v != _contactId) return;
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) {
const MTPDcontacts_importedContacts &d(res.c_contacts_importedContacts());
const auto &d(res.c_contacts_importedContacts());
App::feedUsers(d.vusers);
emit closed();
}
@ -530,7 +530,7 @@ void GroupInfoBox::creationDone(const MTPUpdates &updates) {
}
bool GroupInfoBox::creationFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_creationRequestId = 0;
if (error.type() == "NO_CHAT_TITLE") {
@ -903,7 +903,7 @@ void SetupChannelBox::onUpdateDone(const MTPBool &result) {
}
bool SetupChannelBox::onUpdateFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
QString err(error.type());
@ -940,7 +940,7 @@ void SetupChannelBox::onCheckDone(const MTPBool &result) {
}
bool SetupChannelBox::onCheckFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_checkRequestId = 0;
QString err(error.type());
@ -971,7 +971,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
}
bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_checkRequestId = 0;
QString err(error.type());
@ -1128,7 +1128,7 @@ void EditNameTitleBox::onSaveSelfDone(const MTPUser &user) {
}
bool EditNameTitleBox::onSaveSelfFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
QString err(error.type());
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_requestId = 0;
QString err(error.type());
@ -1334,7 +1334,7 @@ void EditChannelBox::saveSign() {
}
bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
QString err(error.type());
if (req == _saveTitleRequestId) {

View File

@ -42,13 +42,13 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
App::WallPapers wallpapers;
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) {
const MTPWallPaper w(v.at(i));
const auto &w(v.at(i));
switch (w.type()) {
case mtpc_wallPaper: {
const MTPDwallPaper &d(w.c_wallPaper());
const QVector<MTPPhotoSize> &sizes(d.vsizes.c_vector().v);
const auto &d(w.c_wallPaper());
const auto &sizes(d.vsizes.c_vector().v);
const MTPPhotoSize *thumb = 0, *full = 0;
int32 thumbLevel = -1, fullLevel = -1;
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;
switch (j->type()) {
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];
w = j->c_photoSize().vw.v;
h = j->c_photoSize().vh.v;
} break;
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];
w = j->c_photoCachedSize().vw.v;
h = j->c_photoCachedSize().vh.v;
@ -87,7 +87,7 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
} break;
case mtpc_wallPaperSolid: {
const MTPDwallPaperSolid &d(w.c_wallPaperSolid());
const auto &d(w.c_wallPaperSolid());
} break;
}
}

View File

@ -335,7 +335,7 @@ void ConvertToSupergroupBox::convertDone(const MTPUpdates &updates) {
}
bool ConvertToSupergroupBox::convertFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
Ui::hideLayer();
return true;
}
@ -431,7 +431,7 @@ void PinMessageBox::pinDone(const MTPUpdates &updates) {
}
bool PinMessageBox::pinFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
Ui::hideLayer();
return true;
}

View File

@ -278,7 +278,7 @@ void ContactsInner::addAdminDone(const MTPUpdates &result, 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;
@ -1478,7 +1478,7 @@ void ContactsBox::peopleReceived(const MTPcontacts_Found &result, mtpRequestId r
}
bool ContactsBox::peopleFailed(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_peopleRequest == req) {
_peopleRequest = 0;
@ -1623,7 +1623,7 @@ void ContactsBox::onCreate() {
if (_saveRequestId) return;
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)) {
_filter.setFocus();
_filter.showError();
@ -1716,7 +1716,7 @@ void ContactsBox::removeAdminDone(UserData *user, const MTPBool &result) {
}
bool ContactsBox::saveAdminsFail(const RPCError &error) {
if (mtpIsFlood(error)) return true;
if (MTP::isDefaultHandledError(error)) return true;
_saveRequestId = 0;
_inner.saving(false);
if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
@ -1726,7 +1726,7 @@ bool ContactsBox::saveAdminsFail(const RPCError &error) {
}
bool ContactsBox::editAdminFail(const RPCError &error) {
if (mtpIsFlood(error)) return true;
if (MTP::isDefaultHandledError(error)) return true;
--_saveRequestId;
_inner.chat()->invalidateParticipants();
if (!_saveRequestId) {
@ -1769,7 +1769,7 @@ void ContactsBox::creationDone(const MTPUpdates &updates) {
}
bool ContactsBox::creationFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
if (error.type() == "NO_CHAT_TITLE") {
@ -2161,8 +2161,8 @@ void MembersInner::membersReceived(const MTPchannels_ChannelParticipants &result
_loadingRequestId = 0;
if (result.type() == mtpc_channels_channelParticipants) {
const MTPDchannels_channelParticipants &d(result.c_channels_channelParticipants());
const QVector<MTPChannelParticipant> &v(d.vparticipants.c_vector().v);
const auto &d(result.c_channels_channelParticipants());
const auto &v(d.vparticipants.c_vector().v);
_rows.reserve(v.size());
_datas.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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
Ui::hideLayer();
return true;
}
@ -2263,7 +2264,7 @@ void MembersInner::kickAdminDone(const MTPUpdates &result, 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();
load();

View File

@ -284,35 +284,12 @@ void PasscodeBox::setPasswordDone(const MTPBool &result) {
}
bool PasscodeBox::setPasswordFail(const RPCError &error) {
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
_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 (MTP::isFloodError(error)) {
if (_oldPasscode.isHidden()) return false;
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
_setRequest = 0;
_oldPasscode.selectAll();
_oldPasscode.setFocus();
_oldPasscode.showError();
@ -321,6 +298,36 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
_recover.hide();
}
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;
}
@ -490,7 +497,7 @@ void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) {
}
bool PasscodeBox::recoverStartFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_pattern = QString();
onClose();
@ -587,32 +594,36 @@ void RecoverBox::codeSubmitDone(bool recover, const MTPauth_Authorization &resul
}
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;
const QString &err = error.type();
if (err == "PASSWORD_EMPTY") {
if (err == qstr("PASSWORD_EMPTY")) {
emit reloadPassword();
Ui::showLayer(new InformBox(lang(lng_cloud_password_removed)));
return true;
} else if (err == "PASSWORD_RECOVERY_NA") {
} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
onClose();
return true;
} else if (err == "PASSWORD_RECOVERY_EXPIRED") {
} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
emit recoveryExpired();
onClose();
return true;
} else if (err == "CODE_INVALID") {
} else if (err == qstr("CODE_INVALID")) {
_error = lang(lng_signin_wrong_code);
update();
_recoverCode.selectAll();
_recoverCode.setFocus();
_recoverCode.showError();
return true;
} else if (mtpIsFlood(error)) {
_error = lang(lng_flood_error);
update();
_recoverCode.showError();
return true;
}
if (cDebug()) { // internal server error
_error = err + ": " + error.description();

View File

@ -51,8 +51,8 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW
if (_file->photo.type() != mtpc_photoEmpty) {
_file->type = PreparePhoto;
} else if (_file->document.type() == mtpc_document) {
const MTPDdocument &document(_file->document.c_document());
const QVector<MTPDocumentAttribute> &attributes(document.vattributes.c_vector().v);
const auto &document(_file->document.c_document());
const auto &attributes(document.vattributes.c_vector().v);
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
if (attributes.at(i).type() == mtpc_documentAttributeAnimated) {
_animated = true;
@ -668,7 +668,7 @@ void EditCaptionBox::saveDone(const MTPUpdates &updates) {
}
bool EditCaptionBox::saveFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
QString err = error.type();

View File

@ -166,7 +166,7 @@ void SessionsInner::terminateDone(uint64 hash, const MTPBool &result) {
}
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);
if (i != _terminateButtons.end()) {
@ -181,7 +181,7 @@ void SessionsInner::terminateAllDone(const MTPBool &result) {
}
bool SessionsInner::terminateAllFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
emit allTerminated();
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;
_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();
if (l > 1) _list.reserve(l - 1);
const CountriesByISO2 &countries(countriesByISO2());
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;
data.hash = d.vhash.v;

View File

@ -56,8 +56,8 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.clear();
_emoji.clear();
if (set.type() == mtpc_messages_stickerSet) {
const MTPDmessages_stickerSet &d(set.c_messages_stickerSet());
const QVector<MTPDocument> &v(d.vdocuments.c_vector().v);
const auto &d(set.c_messages_stickerSet());
const auto &v(d.vdocuments.c_vector().v);
_pack.reserve(v.size());
for (int32 i = 0, l = v.size(); i < l; ++i) {
DocumentData *doc = App::feedDocument(v.at(i));
@ -65,12 +65,12 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_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) {
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)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
const auto &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
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) {
const MTPDstickerSet &s(d.vset.c_stickerSet());
const auto &s(d.vset.c_stickerSet());
_setTitle = stickerSetTitle(s);
_title = st::boxTitleFont->elided(_setTitle, width() - st::boxTitlePosition.x() - st::boxTitleHeight);
_setShortName = qs(s.vshort_name);
@ -107,7 +107,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
}
bool StickerSetInner::failedSet(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_loaded = true;
@ -152,7 +152,7 @@ void StickerSetInner::installDone(const MTPBool &result) {
}
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)));
@ -803,7 +803,7 @@ void StickersBox::disenableDone(const MTPBool & result, mtpRequestId req) {
}
bool StickersBox::disenableFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_disenableRequests.remove(req);
if (_disenableRequests.isEmpty()) {
saveOrder();
@ -831,7 +831,7 @@ void StickersBox::reorderDone(const MTPBool &result) {
}
bool StickersBox::reorderFail(const RPCError &result) {
if (mtpIsFlood(result)) return false;
if (MTP::isDefaultHandledError(result)) return false;
_reorderRequest = 0;
Global::SetLastStickersUpdate(0);
App::main()->updateStickers();

View File

@ -202,22 +202,22 @@ void UsernameBox::onUpdateDone(const MTPUser &user) {
}
bool UsernameBox::onUpdateFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
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));
emit closed();
return true;
} else if (err == "USERNAME_INVALID") {
} else if (err == qstr("USERNAME_INVALID")) {
_username.setFocus();
_username.showError();
_copiedTextLink = QString();
_errorText = lang(lng_username_invalid);
update();
return true;
} else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") {
} else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) {
_username.setFocus();
_username.showError();
_copiedTextLink = QString();
@ -242,15 +242,15 @@ void UsernameBox::onCheckDone(const MTPBool &result) {
}
bool UsernameBox::onCheckFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_checkRequestId = 0;
QString err(error.type());
if (err == "USERNAME_INVALID") {
if (err == qstr("USERNAME_INVALID")) {
_errorText = lang(lng_username_invalid);
update();
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);
update();
return true;

View File

@ -953,7 +953,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
History *history = 0;
switch (i->type()) {
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);
if (App::main()) {
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, history);
@ -961,7 +961,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
} break;
case mtpc_dialogChannel: {
const MTPDdialogChannel &d(i->c_dialogChannel());
const auto &d(i->c_dialogChannel());
PeerData *peer = App::peerLoaded(peerFromMTP(d.vpeer));
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);
@ -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) {
switch (i->type()) {
case mtpc_dialog: {
const MTPDdialog &d(i->c_dialog());
const auto &d(i->c_dialog());
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, h);
if (d.vunread_count.v >= h->unreadCount) {
@ -1903,7 +1903,7 @@ void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
}
} break;
case mtpc_dialogChannel: {
const MTPDdialogChannel &d(i->c_dialogChannel());
const auto &d(i->c_dialogChannel());
if (History *h = App::historyLoaded(peerFromMTP(d.vpeer))) {
if (h->peer->isChannel()) {
h->peer->asChannel()->ptsReceived(d.vpts.v);
@ -1932,7 +1932,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
const QVector<MTPMessage> *m = 0;
switch (dialogs.type()) {
case mtpc_messages_dialogs: {
const MTPDmessages_dialogs &data(dialogs.c_messages_dialogs());
const auto &data(dialogs.c_messages_dialogs());
App::feedUsers(data.vusers);
App::feedChats(data.vchats);
m = &data.vmessages.c_vector().v;
@ -1940,7 +1940,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
_dialogsFull = true;
} break;
case mtpc_messages_dialogsSlice: {
const MTPDmessages_dialogsSlice &data(dialogs.c_messages_dialogsSlice());
const auto &data(dialogs.c_messages_dialogsSlice());
App::feedUsers(data.vusers);
App::feedChats(data.vchats);
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;) {
PeerId peer = 0;
MsgId msgId = 0;
const MTPDialog &d(v->at(--i));
const auto &d(v->at(--i));
switch (d.type()) {
case mtpc_dialog:
msgId = d.c_dialog().vtop_message.v;
@ -1984,7 +1984,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
if (msgId) {
if (!lastMsgId) lastMsgId = msgId;
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) {
int32 date = dateFromMessage(d);
if (date) lastDate = date;
@ -2011,7 +2011,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
}
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()));
if (_dialogsRequest == req) {
@ -2153,7 +2153,7 @@ void DialogsWidget::loadDialogs() {
void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &contacts) {
cSetContactsReceived(true);
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);
_inner.contactsReceived(d.vcontacts.c_vector().v);
}
@ -2161,7 +2161,7 @@ void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &contacts) {
}
bool DialogsWidget::contactsFailed(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
return true;
}
@ -2180,10 +2180,10 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
if (_searchRequest == req) {
switch (result.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(result.c_messages_messages());
const auto &d(result.c_messages_messages());
App::feedUsers(d.vusers);
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 (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
_searchFullMigrated = true;
@ -2194,10 +2194,10 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
const auto &d(result.c_messages_messagesSlice());
App::feedUsers(d.vusers);
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 (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
_searchFullMigrated = true;
@ -2208,7 +2208,7 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
const auto &d(result.c_messages_channelMessages());
if (_searchInPeer && _searchInPeer->isChannel()) {
_searchInPeer->asChannel()->ptsReceived(d.vpts.v);
} else {
@ -2220,7 +2220,7 @@ void DialogsWidget::searchReceived(DialogsSearchRequestType type, const MTPmessa
App::feedUsers(d.vusers);
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 (type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset) {
_searchFullMigrated = true;
@ -2262,7 +2262,7 @@ void DialogsWidget::peopleReceived(const MTPcontacts_Found &result, mtpRequestId
}
bool DialogsWidget::searchFailed(DialogsSearchRequestType type, const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_searchRequest == req) {
_searchRequest = 0;
@ -2276,7 +2276,7 @@ bool DialogsWidget::searchFailed(DialogsSearchRequestType type, const RPCError &
}
bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_peopleRequest == req) {
_peopleRequest = 0;

View File

@ -3639,7 +3639,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
bool adding = (it != _inlineCache.cend());
if (result.type() == mtpc_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);
if (!adding) {
@ -3656,7 +3656,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
it.value()->results.reserve(it.value()->results.size() + count);
}
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)) {
++added;
it.value()->results.push_back(result.release());
@ -3677,8 +3677,7 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
}
bool EmojiPan::inlineResultsFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
// show error?
Notify::inlineBotRequesting(false);
_inlineRequestId = 0;
return true;
@ -4439,7 +4438,7 @@ void MentionsDropdown::updateFiltered(bool resetScroll) {
if (_channel->mgInfo->bots.isEmpty()) {
if (!_channel->mgInfo->botStatus && App::api()) App::api()->requestBots(_channel);
} else {
for_const (auto *user, _channel->mgInfo->bots) {
for_const (auto user, _channel->mgInfo->bots) {
if (!user->botInfo) continue;
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (user->botInfo->commands.isEmpty()) continue;

View File

@ -45,9 +45,9 @@ namespace App {
void activateBotCommand(const HistoryItem *msg, int row, int col) {
const HistoryMessageReplyMarkup::Button *button = nullptr;
if (auto *markup = msg->Get<HistoryMessageReplyMarkup>()) {
if (auto markup = msg->Get<HistoryMessageReplyMarkup>()) {
if (row < markup->rows.size()) {
const HistoryMessageReplyMarkup::ButtonRow &buttonRow(markup->rows.at(row));
const auto &buttonRow(markup->rows.at(row));
if (col < buttonRow.size()) {
button = &buttonRow.at(col);
}

View File

@ -307,7 +307,7 @@ void FileUploader::partLoaded(const MTPBool &result, 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
currentFailed();

View File

@ -563,7 +563,7 @@ void ChannelHistory::getRangeDifferenceNext(int32 pts) {
void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
if (group.type() != mtpc_messageGroup) return;
const MTPDmessageGroup &d(group.c_messageGroup());
const auto &d(group.c_messageGroup());
if (onlyImportant()) {
_otherNewLoaded = false;
@ -1227,7 +1227,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
break;
case mtpc_message: {
const MTPDmessage m(msg.c_message());
const auto &m(msg.c_message());
int badMedia = 0; // 1 - unsupported, 2 - empty
if (m.has_media()) switch (m.vmedia.type()) {
case mtpc_messageMediaEmpty:
@ -1284,16 +1284,16 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
} break;
case mtpc_messageService: {
const MTPDmessageService &d(msg.c_messageService());
const auto &d(msg.c_messageService());
result = HistoryService::create(this, d);
if (applyServiceAction) {
const MTPmessageAction &action(d.vaction);
const auto &action(d.vaction);
switch (d.vaction.type()) {
case mtpc_messageActionChatAddUser: {
const MTPDmessageActionChatAddUser &d(action.c_messageActionChatAddUser());
const auto &d(action.c_messageActionChatAddUser());
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) {
if (UserData *user = App::userLoaded(peerFromUser(v.at(i)))) {
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(user) < 0) {
@ -1312,7 +1312,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
} break;
case mtpc_messageActionChatJoinedByLink: {
const MTPDmessageActionChatJoinedByLink &d(action.c_messageActionChatJoinedByLink());
const auto &d(action.c_messageActionChatJoinedByLink());
if (peer->isMegagroup()) {
if (result->from()->isUser()) {
if (peer->asChannel()->mgInfo->lastParticipants.indexOf(result->from()->asUser()) < 0) {
@ -1334,7 +1334,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
} break;
case mtpc_messageActionChatDeleteUser: {
const MTPDmessageActionChatDeleteUser &d(action.c_messageActionChatDeleteUser());
const auto &d(action.c_messageActionChatDeleteUser());
PeerId uid = peerFromUser(d.vuser_id);
if (lastKeyboardFrom == uid) {
clearLastKeyboard();
@ -1367,13 +1367,13 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
} break;
case mtpc_messageActionChatEditPhoto: {
const MTPDmessageActionChatEditPhoto &d(action.c_messageActionChatEditPhoto());
const auto &d(action.c_messageActionChatEditPhoto());
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()) {
PhotoData *photo = App::feedPhoto(d.vphoto.c_photo());
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;
switch (smallSize.type()) {
case mtpc_photoSize: smallLoc = &smallSize.c_photoSize().vlocation; break;
@ -1396,7 +1396,7 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
} break;
case mtpc_messageActionChatEditTitle: {
const MTPDmessageActionChatEditTitle &d(action.c_messageActionChatEditTitle());
const auto &d(action.c_messageActionChatEditTitle());
ChatData *chat = peer->asChat();
if (chat) chat->updateName(qs(d.vtitle), QString(), QString());
} break;
@ -1404,12 +1404,12 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction,
case mtpc_messageActionChatMigrateTo: {
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);
} break;
case mtpc_messageActionChannelMigrateFrom: {
//const MTPDmessageActionChannelMigrateFrom &d(action.c_messageActionChannelMigrateFrom());
//const auto &d(action.c_messageActionChannelMigrateFrom());
//PeerData *chat = App::chatLoaded(d.vchat_id.v);
} break;
@ -1718,7 +1718,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
for (; groupsIt != groupsEnd; ++groupsIt) {
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;
addMessageGroup(group);
@ -1728,7 +1728,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
}
for (; groupsIt != groupsEnd; ++groupsIt) {
if (groupsIt->type() != mtpc_messageGroup) continue;
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
const auto &group(groupsIt->c_messageGroup());
addMessageGroup(group);
}
@ -1840,7 +1840,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
for (; groupsIt != groupsEnd; ++groupsIt) {
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;
addMessageGroup(group);
@ -1851,7 +1851,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
}
for (; groupsIt != groupsEnd; ++groupsIt) {
if (groupsIt->type() != mtpc_messageGroup) continue;
const MTPDmessageGroup &group(groupsIt->c_messageGroup());
const auto &group(groupsIt->c_messageGroup());
addMessageGroup(group);
}
@ -2519,7 +2519,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
const QVector<MTPMessage> *v = 0;
switch (result.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(result.c_messages_messages());
const auto &d(result.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
@ -2527,7 +2527,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
const auto &d(result.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
overviewCountData[overviewIndex] = d.vcount.v;
@ -2535,7 +2535,7 @@ void History::overviewSliceDone(int32 overviewIndex, const MTPmessages_Messages
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
const auto &d(result.c_messages_channelMessages());
if (peer->isChannel()) {
peer->asChannel()->ptsReceived(d.vpts.v);
} else {
@ -3017,15 +3017,15 @@ void HistoryMessageReplyMarkup::createFromButtonRows(const QVector<MTPKeyboardBu
}
rows.reserve(v.size());
for_const(const MTPKeyboardButtonRow &row, v) {
for_const (const auto &row, v) {
switch (row.type()) {
case mtpc_keyboardButtonRow: {
const MTPDkeyboardButtonRow &r(row.c_keyboardButtonRow());
const QVector<MTPKeyboardButton> &b(r.vbuttons.c_vector().v);
const auto &r(row.c_keyboardButtonRow());
const auto &b(r.vbuttons.c_vector().v);
if (!b.isEmpty()) {
ButtonRow buttonRow;
buttonRow.reserve(b.size());
for_const(const MTPKeyboardButton &button, b) {
for_const (const auto &button, b) {
switch (button.type()) {
case mtpc_keyboardButton: {
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()) {
case mtpc_replyKeyboardMarkup: {
const MTPDreplyKeyboardMarkup &d(markup.c_replyKeyboardMarkup());
const auto &d(markup.c_replyKeyboardMarkup());
flags = d.vflags.v;
createFromButtonRows(d.vrows.c_vector().v);
} break;
case mtpc_replyInlineMarkup: {
const MTPDreplyInlineMarkup &d(markup.c_replyInlineMarkup());
const auto &d(markup.c_replyInlineMarkup());
flags = MTPDreplyKeyboardMarkup::Flags(0) | MTPDreplyKeyboardMarkup_ClientFlag::f_inline;
createFromButtonRows(d.vrows.c_vector().v);
} break;
case mtpc_replyKeyboardHide: {
const MTPDreplyKeyboardHide &d(markup.c_replyKeyboardHide());
const auto &d(markup.c_replyKeyboardHide());
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_zero;
} break;
case mtpc_replyKeyboardForceReply: {
const MTPDreplyKeyboardForceReply &d(markup.c_replyKeyboardForceReply());
const auto &d(markup.c_replyKeyboardForceReply());
flags = mtpCastFlags(d.vflags) | MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
} break;
}
@ -3834,11 +3834,11 @@ void HistoryPhoto::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, int
void HistoryPhoto::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaPhoto) {
const MTPPhoto &photo(media.c_messageMediaPhoto().vphoto);
const auto &photo(media.c_messageMediaPhoto().vphoto);
App::feedPhoto(photo, _data);
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;
const MTPDfileLocation *maxLocation = 0;
for (int32 i = 0, l = sizes.size(); i < l; ++i) {
@ -6734,7 +6734,7 @@ HistoryMessage::HistoryMessage(History *history, const MTPDmessage &msg)
CreateConfig config;
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()) {
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);
@ -6894,35 +6894,35 @@ void HistoryMessage::initTime() {
void HistoryMessage::initMedia(const MTPMessageMedia *media, QString &currentText) {
switch (media ? media->type() : mtpc_messageMediaEmpty) {
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)));
} break;
case mtpc_messageMediaGeo: {
const MTPGeoPoint &point(media->c_messageMediaGeo().vgeo);
const auto &point(media->c_messageMediaGeo().vgeo);
if (point.type() == mtpc_geoPoint) {
_media.reset(this, new HistoryLocation(LocationCoords(point.c_geoPoint())));
}
} break;
case mtpc_messageMediaVenue: {
const MTPDmessageMediaVenue &d(media->c_messageMediaVenue());
const auto &d(media->c_messageMediaVenue());
if (d.vgeo.type() == mtpc_geoPoint) {
_media.reset(this, new HistoryLocation(LocationCoords(d.vgeo.c_geoPoint()), qs(d.vtitle), qs(d.vaddress)));
}
} break;
case mtpc_messageMediaPhoto: {
const MTPDmessageMediaPhoto &photo(media->c_messageMediaPhoto());
const auto &photo(media->c_messageMediaPhoto());
if (photo.vphoto.type() == mtpc_photo) {
_media.reset(this, new HistoryPhoto(App::feedPhoto(photo.vphoto.c_photo()), qs(photo.vcaption), this));
}
} break;
case mtpc_messageMediaDocument: {
const MTPDocument &document(media->c_messageMediaDocument().vdocument);
const auto &document(media->c_messageMediaDocument().vdocument);
if (document.type() == mtpc_document) {
return initMediaFromDocument(App::feedDocument(document), qs(media->c_messageMediaDocument().vcaption));
}
} break;
case mtpc_messageMediaWebPage: {
const MTPWebPage &d(media->c_messageMediaWebPage().vwebpage);
const auto &d(media->c_messageMediaWebPage().vwebpage);
switch (d.type()) {
case mtpc_webPageEmpty: break;
case mtpc_webPagePending: {
@ -7884,8 +7884,8 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
switch (action.type()) {
case mtpc_messageActionChatAddUser: {
const MTPDmessageActionChatAddUser &d(action.c_messageActionChatAddUser());
const QVector<MTPint> &v(d.vusers.c_vector().v);
const auto &d(action.c_messageActionChatAddUser());
const auto &v(d.vusers.c_vector().v);
bool foundSelf = false;
for (int32 i = 0, l = v.size(); i < l; ++i) {
if (v.at(i).v == MTP::authedId()) {
@ -7926,7 +7926,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} break;
case mtpc_messageActionChatJoinedByLink: {
const MTPDmessageActionChatJoinedByLink &d(action.c_messageActionChatJoinedByLink());
const auto &d(action.c_messageActionChatJoinedByLink());
//if (true || peerFromUser(d.vinviter_id) == _from->id) {
text = lng_action_user_joined_by_link(lt_from, from);
//} else {
@ -7940,12 +7940,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} break;
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)));
} break;
case mtpc_messageActionChannelCreate: {
const MTPDmessageActionChannelCreate &d(action.c_messageActionChannelCreate());
const auto &d(action.c_messageActionChannelCreate());
if (isPost()) {
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
} else {
@ -7958,7 +7958,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} break;
case mtpc_messageActionChatDeleteUser: {
const MTPDmessageActionChatDeleteUser &d(action.c_messageActionChatDeleteUser());
const auto &d(action.c_messageActionChatDeleteUser());
if (peerFromUser(d.vuser_id) == _from->id) {
text = lng_action_user_left(lt_from, from);
} else {
@ -7969,7 +7969,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} break;
case mtpc_messageActionChatEditPhoto: {
const MTPDmessageActionChatEditPhoto &d(action.c_messageActionChatEditPhoto());
const auto &d(action.c_messageActionChatEditPhoto());
if (d.vphoto.type() == mtpc_photo) {
_media.reset(this, new HistoryPhoto(history()->peer, d.vphoto.c_photo(), st::msgServicePhotoWidth));
}
@ -7977,13 +7977,13 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} break;
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)));
} break;
case mtpc_messageActionChatMigrateTo: {
_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)*/) {
text = lang(lng_action_group_migrate);
} else {
@ -7993,7 +7993,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
case mtpc_messageActionChannelMigrateFrom: {
_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)*/) {
text = lang(lng_action_group_migrate);
} else {

View File

@ -1404,7 +1404,7 @@ public:
_flags &= ~MTPDmessage::Flag::f_media_unread;
}
bool definesReplyKeyboard() const {
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
return false;
}
@ -1417,7 +1417,7 @@ public:
}
MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const {
t_assert(definesReplyKeyboard());
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
return markup->flags;
}
@ -1603,7 +1603,7 @@ public:
return nullptr;
}
MsgId replyToId() const {
if (auto *reply = Get<HistoryMessageReply>()) {
if (auto reply = Get<HistoryMessageReply>()) {
return reply->replyToId();
}
return 0;
@ -1658,7 +1658,7 @@ public:
}
int displayedDateHeight() const {
if (auto *date = Get<HistoryMessageDate>()) {
if (auto date = Get<HistoryMessageDate>()) {
return date->height();
}
return 0;
@ -1671,7 +1671,7 @@ public:
result += st::msgMargin.top();
}
result += displayedDateHeight();
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) {
if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
result += unreadbar->height();
}
return result;
@ -1737,7 +1737,7 @@ protected:
void recountAttachToPrevious();
const HistoryMessageReplyMarkup *inlineReplyMarkup() const {
if (auto *markup = Get<HistoryMessageReplyMarkup>()) {
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_inline) {
return markup;
}
@ -1745,7 +1745,7 @@ protected:
return nullptr;
}
const ReplyKeyboard *inlineReplyKeyboard() const {
if (auto *markup = inlineReplyMarkup()) {
if (auto markup = inlineReplyMarkup()) {
return markup->inlineKeyboard.data();
}
return nullptr;
@ -2852,7 +2852,7 @@ public:
}
bool updateDependencyItem() override {
if (auto *reply = Get<HistoryMessageReply>()) {
if (auto reply = Get<HistoryMessageReply>()) {
return reply->updateData(this, true);
}
return true;

View File

@ -2262,7 +2262,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
_wasForMsgId = FullMsgId(to->channelId(), to->id);
clearSelection();
const auto *markup = to->Get<HistoryMessageReplyMarkup>();
auto markup = to->Get<HistoryMessageReplyMarkup>();
_forceReply = markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
_maximizeSize = !(markup->flags & MTPDreplyKeyboardMarkup::Flag::f_resize);
_singleUse = _forceReply || (markup->flags & MTPDreplyKeyboardMarkup::Flag::f_single_use);
@ -3260,9 +3260,9 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
_stickersUpdateRequest = 0;
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());
setsOrder.clear();
@ -3274,7 +3274,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
}
for (int i = 0, l = d_sets.size(); i != l; ++i) {
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);
QString title = stickerSetTitle(set);
if (it == sets.cend()) {
@ -3334,7 +3334,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
}
bool HistoryWidget::stickersFailed(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
LOG(("App Fail: Failed to get stickers!"));
@ -3348,9 +3348,9 @@ void HistoryWidget::savedGifsGot(const MTPmessages_SavedGifs &gifs) {
_savedGifsUpdateRequest = 0;
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());
saved.clear();
@ -3387,7 +3387,7 @@ void HistoryWidget::saveGifDone(DocumentData *doc, const MTPBool &result) {
}
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!"));
@ -3851,7 +3851,7 @@ void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequ
_reportSpamSettingRequestId = 0;
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;
if (status != _reportSpamStatus) {
_reportSpamStatus = status;
@ -3866,7 +3866,7 @@ void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequ
}
bool HistoryWidget::reportSpamSettingFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (req == _reportSpamSettingRequestId) {
req = 0;
@ -4166,7 +4166,7 @@ void HistoryWidget::historyCleared(History *history) {
}
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")) {
PeerData *was = _peer;
@ -4206,21 +4206,21 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
const QVector<MTPMessageGroup> *histCollapsed = 0;
switch (messages.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(messages.c_messages_messages());
const auto &d(messages.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
histList = &d.vmessages.c_vector().v;
count = histList->size();
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(messages.c_messages_messagesSlice());
const auto &d(messages.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
histList = &d.vmessages.c_vector().v;
count = d.vcount.v;
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(messages.c_messages_channelMessages());
const auto &d(messages.c_messages_channelMessages());
if (peer && peer->isChannel()) {
peer->asChannel()->ptsReceived(d.vpts.v);
} else {
@ -4643,7 +4643,7 @@ void HistoryWidget::saveEditMsgDone(History *history, const MTPUpdates &updates,
}
bool HistoryWidget::saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (req == _saveEditMsgRequestId) {
_saveEditMsgRequestId = 0;
}
@ -4714,7 +4714,7 @@ void HistoryWidget::unblockDone(PeerData *peer, const MTPBool &result, mtpReques
}
bool HistoryWidget::unblockFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_unblockRequest == req) _unblockRequest = 0;
return false;
@ -4768,7 +4768,7 @@ void HistoryWidget::joinDone(const MTPUpdates &result, 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 (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) {
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 (markup->rows.at(info.row).at(info.col).requestId == req) {
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) {
if (mtpIsFlood(error)) return false;
// show error?
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 (markup->rows.at(info.row).at(info.col).requestId == req) {
markup->rows.at(info.row).at(info.col).requestId = 0;
@ -5254,7 +5253,6 @@ bool HistoryWidget::botCallbackFail(BotCallbackInfo info, const RPCError &error,
}
}
}
return true;
}
@ -5404,7 +5402,7 @@ void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result)
// Notify::inlineBotRequesting(false);
_inlineBotUsername = QString();
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::feedChats(d.vchats);
}
@ -5412,7 +5410,7 @@ void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result)
}
bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_inlineBotResolveRequestId = 0;
// Notify::inlineBotRequesting(false);
@ -6141,7 +6139,7 @@ void HistoryWidget::reportSpamDone(PeerData *peer, const MTPBool &result, mtpReq
}
bool HistoryWidget::reportSpamFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (req == _reportSpamRequest) {
_reportSpamRequest = 0;

View File

@ -92,7 +92,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
const MTPBotInlineMessage *message = nullptr;
switch (mtpData.type()) {
case mtpc_botInlineResult: {
const MTPDbotInlineResult &r(mtpData.c_botInlineResult());
const auto &r(mtpData.c_botInlineResult());
result->_id = qs(r.vid);
if (r.has_title()) result->_title = qs(r.vtitle);
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;
} break;
case mtpc_botInlineMediaResult: {
const MTPDbotInlineMediaResult &r(mtpData.c_botInlineMediaResult());
const auto &r(mtpData.c_botInlineMediaResult());
result->_id = qs(r.vid);
if (r.has_title()) result->_title = qs(r.vtitle);
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()) {
case mtpc_botInlineMessageMediaAuto: {
const MTPDbotInlineMessageMediaAuto &r(message->c_botInlineMessageMediaAuto());
const auto &r(message->c_botInlineMessageMediaAuto());
if (result->_type == Type::Photo) {
result->sendData.reset(new internal::SendPhoto(result->_photo, result->_content_url, qs(r.vcaption)));
} else {
@ -144,7 +144,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
} break;
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();
result->sendData.reset(new internal::SendText(qs(r.vmessage), entities, r.is_no_webpage()));
if (r.has_reply_markup()) {
@ -153,7 +153,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
} break;
case mtpc_botInlineMessageMediaGeo: {
const MTPDbotInlineMessageMediaGeo &r(message->c_botInlineMessageMediaGeo());
const auto &r(message->c_botInlineMessageMediaGeo());
if (r.vgeo.type() == mtpc_geoPoint) {
result->sendData.reset(new internal::SendGeo(r.vgeo.c_geoPoint()));
} else {
@ -165,7 +165,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
} break;
case mtpc_botInlineMessageMediaVenue: {
const MTPDbotInlineMessageMediaVenue &r(message->c_botInlineMessageMediaVenue());
const auto &r(message->c_botInlineMessageMediaVenue());
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)));
} else {
@ -177,7 +177,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
} break;
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)));
if (r.has_reply_markup()) {
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);

View File

@ -253,7 +253,7 @@ void IntroCode::codeSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
sentRequest = 0;
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?
showError(lang(lng_server_error));
return;
@ -263,31 +263,37 @@ void IntroCode::codeSubmitDone(const MTPauth_Authorization &result) {
}
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();
sentRequest = 0;
code.setDisabled(false);
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();
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));
code.notaBene();
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()->replaceStep(new IntroSignup(intro()));
return true;
} else if (err == "SESSION_PASSWORD_NEEDED") {
} else if (err == qstr("SESSION_PASSWORD_NEEDED")) {
intro()->setCode(sentCode);
code.setDisabled(false);
checkRequest.start(1000);
sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&IntroCode::gotPassword), rpcFail(&IntroCode::codeSubmitFail));
return true;
} else if (mtpIsFlood(error)) {
showError(lang(lng_flood_error));
code.setFocus();
return true;
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());
@ -334,7 +340,7 @@ void IntroCode::gotPassword(const MTPaccount_Password &result) {
break;
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()->setHasRecovery(mtpIsTrue(d.vhas_recovery));
intro()->setPwdHint(qs(d.vhint));
@ -371,7 +377,7 @@ void IntroCode::noTelegramCodeDone(const MTPauth_SentCode &result) {
return;
}
const MTPDauth_sentCode &d(result.c_auth_sentCode());
const auto &d(result.c_auth_sentCode());
switch (d.vtype.type()) {
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true);
case mtpc_auth_sentCodeTypeSms:
@ -388,11 +394,13 @@ void IntroCode::noTelegramCodeDone(const MTPauth_SentCode &result) {
}
bool IntroCode::noTelegramCodeFail(const RPCError &error) {
if (mtpIsFlood(error)) {
if (MTP::isFloodError(error)) {
showError(lang(lng_flood_error));
code.setFocus();
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
if (cDebug()) { // internal server error
showError(error.type() + ": " + error.description());
} else {

View File

@ -222,7 +222,7 @@ void IntroPhone::onCheckRequest() {
void IntroPhone::phoneCheckDone(const MTPauth_CheckedPhone &result) {
stopCheck();
const MTPDauth_checkedPhone &d(result.c_auth_checkedPhone());
const auto &d(result.c_auth_checkedPhone());
if (mtpIsTrue(d.vphone_registered)) {
disableAll();
showError(QString());
@ -248,7 +248,7 @@ void IntroPhone::phoneSubmitDone(const MTPauth_SentCode &result) {
return;
}
const MTPDauth_sentCode &d(result.c_auth_sentCode());
const auto &d(result.c_auth_sentCode());
switch (d.vtype.type()) {
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true); break;
case mtpc_auth_sentCodeTypeSms:
@ -275,17 +275,22 @@ void IntroPhone::toSignUp() {
}
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();
sentRequest = 0;
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));
enableAll(true);
return true;
} else if (mtpIsFlood(error)) {
showError(lang(lng_flood_error));
enableAll(true);
return true;
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());

View File

@ -185,7 +185,7 @@ void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &res
}
_pwdField.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?
showError(lang(lng_server_error));
return;
@ -194,22 +194,29 @@ void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &res
}
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;
stopCheck();
_pwdField.setDisabled(false);
_codeField.setDisabled(false);
const QString &err = error.type();
if (err == "PASSWORD_HASH_INVALID") {
if (err == qstr("PASSWORD_HASH_INVALID")) {
showError(lang(lng_signin_bad_password));
_pwdField.selectAll();
_pwdField.notaBene();
return true;
} else if (err == "PASSWORD_EMPTY") {
} else if (err == qstr("PASSWORD_EMPTY")) {
intro()->onBack();
} else if (mtpIsFlood(error)) {
showError(lang(lng_flood_error));
_pwdField.notaBene();
return true;
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());
@ -221,30 +228,33 @@ bool IntroPwdCheck::pwdSubmitFail(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;
stopCheck();
_pwdField.setDisabled(false);
_codeField.setDisabled(false);
const QString &err = error.type();
if (err == "PASSWORD_EMPTY") {
if (err == qstr("PASSWORD_EMPTY")) {
intro()->onBack();
return true;
} else if (err == "PASSWORD_RECOVERY_NA") {
} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
recoverStartFail(error);
return true;
} else if (err == "PASSWORD_RECOVERY_EXPIRED") {
} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
_emailPattern = QString();
onToPassword();
return true;
} else if (err == "CODE_INVALID") {
} else if (err == qstr("CODE_INVALID")) {
showError(lang(lng_signin_wrong_code));
_codeField.selectAll();
_codeField.notaBene();
return true;
} else if (mtpIsFlood(error)) {
showError(lang(lng_flood_error));
_codeField.notaBene();
return true;
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());
@ -330,7 +340,8 @@ void IntroPwdCheck::onResetSure() {
}
bool IntroPwdCheck::deleteFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
sentRequest = 0;
showError(lang(lng_server_error));
return true;

View File

@ -252,7 +252,7 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
first.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?
showError(lang(lng_server_error));
return;
@ -261,11 +261,27 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
}
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();
first.setDisabled(false);
last.setDisabled(false);
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();
return true;
} else if (err == "FIRSTNAME_INVALID") {
@ -276,14 +292,6 @@ bool IntroSignup::nameSubmitFail(const RPCError &error) {
showError(lang(lng_bad_name));
last.setFocus();
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
showError(err + ": " + error.description());

View File

@ -39,7 +39,7 @@ namespace {
IntroWidget *signalEmitOn = 0;
QString countryForReg;
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));
MTP::setdc(result.c_nearestDc().vnearest_dc.v, true);
if (countryForReg != nearest.vcountry.c_string().v.c_str()) {

View File

@ -965,7 +965,7 @@ DragState MainWidget::getDragState(const QMimeData *mime) {
}
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
deleteConversation(peer);
@ -980,7 +980,7 @@ void MainWidget::deleteHistoryAfterLeave(PeerData *peer, const MTPUpdates &updat
}
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->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
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) {
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::feedUserLink(MTP_int(peerToUser(user->id)), d.vmy_link, d.vforeign_link, false);
App::emitPeerUpdated();
@ -1075,7 +1075,7 @@ void MainWidget::deleteAllFromUser(ChannelData *channel, UserData *from) {
}
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)) {
params.channel->ptsApplySkippedUpdates();
App::emitPeerUpdated();
@ -1126,19 +1126,19 @@ void MainWidget::addParticipants(PeerData *chatOrChannel, const QVector<UserData
}
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);
if (error.type() == "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
if (error.type() == qstr("USER_LEFT_CHAT")) { // trying to return a user who has left
} else if (error.type() == qstr("USER_KICKED")) { // trying to return a user who was kicked by admin
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);
} 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);
} 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);
} else if (error.type() == "PEER_FLOOD") {
} else if (error.type() == qstr("PEER_FLOOD")) {
text = cantInviteError();
}
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
QString text = lang(lng_failed_add_participant);
if (error.type() == "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
if (error.type() == qstr("USER_LEFT_CHAT")) { // trying to return banned user to his group
} else if (error.type() == qstr("USER_KICKED")) { // trying to return a user who was kicked by admin
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);
} 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);
} else if (error.type() == "PEER_FLOOD") {
} else if (error.type() == qstr("PEER_FLOOD")) {
text = cantInviteError();
}
Ui::showLayer(new InformBox(text));
@ -1170,7 +1170,7 @@ void MainWidget::kickParticipant(ChatData *chat, UserData *user) {
}
bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
error.type();
return false;
@ -1189,21 +1189,21 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
const QVector<MTPMessageGroup> *collapsed = 0;
switch (result.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(result.c_messages_messages());
const auto &d(result.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
const auto &d(result.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
const auto &d(result.c_messages_channelMessages());
if (peer && peer->isChannel()) {
peer->asChannel()->ptsReceived(d.vpts.v);
} else {
@ -1261,9 +1261,9 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
}
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()));
return true;
}
@ -1639,7 +1639,7 @@ void MainWidget::itemEdited(HistoryItem *item) {
}
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
MediaOverviewType type = OverviewCount;
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
readRequestDone(peer);
return false;
@ -1748,7 +1748,7 @@ void MainWidget::readRequestDone(PeerData *peer) {
}
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->asChannel()->ptsUpdated(d.vpts.v, d.vpts_count.v)) {
peer->asChannel()->ptsApplySkippedUpdates();
@ -2012,21 +2012,21 @@ void MainWidget::serviceNotification(const QString &msg, const MTPMessageMedia &
void MainWidget::serviceHistoryDone(const MTPmessages_Messages &msgs) {
switch (msgs.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(msgs.c_messages_messages());
const auto &d(msgs.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
App::feedMsgs(d.vmessages, NewMessageLast);
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
const auto &d(msgs.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
App::feedMsgs(d.vmessages, NewMessageLast);
} break;
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)"));
if (d.has_collapsed()) { // should not be returned
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
App::wnd()->showDelayedServiceMsgs();
return false;
@ -2205,7 +2205,7 @@ void MainWidget::onViewsIncrement() {
}
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()) {
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
for (ViewsIncrementRequests::iterator i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) {
if (i.value() == req) {
@ -2641,7 +2641,7 @@ void MainWidget::sentUpdatesReceived(uint64 randomId, const MTPUpdates &result)
}
bool MainWidget::deleteChannelFailed(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
//if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// 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) {
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) {
if (skipMessageIds && i->type() == mtpc_updateMessageID) continue;
feedUpdate(*i);
@ -2990,7 +2990,7 @@ void MainWidget::feedUpdateVector(const MTPVector<MTPUpdate> &updates, bool skip
}
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) {
if (i->type() == mtpc_updateMessageID) {
feedUpdate(*i);
@ -3039,14 +3039,14 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
bool isFinal = true;
switch (diff.type()) {
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;
isFinal = d.is_final();
channel->ptsInit(d.vpts.v);
} break;
case mtpc_updates_channelDifferenceTooLong: {
const MTPDupdates_channelDifferenceTooLong &d(diff.c_updates_channelDifferenceTooLong());
const auto &d(diff.c_updates_channelDifferenceTooLong());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
@ -3083,7 +3083,7 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
} break;
case mtpc_updates_channelDifference: {
const MTPDupdates_channelDifference &d(diff.c_updates_channelDifference());
const auto &d(diff.c_updates_channelDifference());
App::feedUsers(d.vusers);
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
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;
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()) {
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
LOG(("Skipping message, because it is already in blocks!"));
} 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;
}
}
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) {
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) {
const MTPDmessageGroup &group(updateGroup.vgroup.c_messageGroup());
const auto &group(updateGroup.vgroup.c_messageGroup());
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));
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) {
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)) {
LOG(("API Error: message with invalid peer returned in channelDifference, channelId: %1, peer: %2").arg(peerToChannel(channel->id)).arg(peerFromMessage(msg)));
continue; // wtf
}
h->addNewMessage(msg, NewMessageUnread);
} 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);
}
}
@ -3164,13 +3164,13 @@ void MainWidget::gotRangeDifference(ChannelData *channel, const MTPupdates_Chann
bool isFinal = true;
switch (diff.type()) {
case mtpc_updates_channelDifferenceEmpty: {
const MTPDupdates_channelDifferenceEmpty &d(diff.c_updates_channelDifferenceEmpty());
const auto &d(diff.c_updates_channelDifferenceEmpty());
nextRequestPts = d.vpts.v;
isFinal = d.is_final();
} break;
case mtpc_updates_channelDifferenceTooLong: {
const MTPDupdates_channelDifferenceTooLong &d(diff.c_updates_channelDifferenceTooLong());
const auto &d(diff.c_updates_channelDifferenceTooLong());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
@ -3180,7 +3180,7 @@ void MainWidget::gotRangeDifference(ChannelData *channel, const MTPupdates_Chann
} break;
case mtpc_updates_channelDifference: {
const MTPDupdates_channelDifference &d(diff.c_updates_channelDifference());
const auto &d(diff.c_updates_channelDifference());
App::feedUsers(d.vusers);
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) {
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()));
failDifferenceStartTimerFor(channel);
@ -3215,7 +3215,7 @@ bool MainWidget::failChannelDifference(ChannelData *channel, const RPCError &err
}
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);
_lastUpdateTime = getms(true);
@ -3233,7 +3233,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
switch (diff.type()) {
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);
_lastUpdateTime = getms(true);
@ -3244,10 +3244,10 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
App::emitPeerUpdated();
} break;
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);
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);
_ptsWaiter.setRequesting(false);
@ -3258,7 +3258,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) {
App::emitPeerUpdated();
} break;
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);
gotState(d.vstate);
@ -3362,7 +3362,7 @@ void MainWidget::feedDifference(const MTPVector<MTPUser> &users, const MTPVector
}
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()));
failDifferenceStartTimerFor(0);
@ -3641,7 +3641,7 @@ void MainWidget::usernameResolveDone(QPair<MsgId, QString> msgIdAndStartToken, c
Ui::hideLayer();
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::feedChats(d.vchats);
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (error.code() == 400) {
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) {
switch (invite.type()) {
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));
_inviteHash = hash;
connect(box, SIGNAL(confirmed()), this, SLOT(onInviteImport()));
@ -3692,7 +3692,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
} break;
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));
if (chat) {
Ui::showPeerHistory(chat->id, ShowAtUnreadMsgId);
@ -3702,7 +3702,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
}
bool MainWidget::inviteCheckFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (error.code() == 400) {
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
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;
}
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?..
return App::logOutDelayed();
}
@ -3774,7 +3774,7 @@ void MainWidget::applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNoti
}
break;
case mtpc_peerNotifySettings: {
const MTPDpeerNotifySettings &d(settings.c_peerNotifySettings());
const auto &d(settings.c_peerNotifySettings());
NotifySettingsPtr setTo = UnknownNotifySettings;
switch (peer.type()) {
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
gotNotifySetting(peer, MTP_peerNotifySettingsEmpty());
return true;
@ -4095,7 +4095,7 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) {
void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
switch (updates.type()) {
case mtpc_updates: {
const MTPDupdates &d(updates.c_updates());
const auto &d(updates.c_updates());
if (d.vseq.v) {
if (d.vseq.v <= updSeq) return;
if (d.vseq.v > updSeq + 1) {
@ -4112,7 +4112,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
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 <= updSeq) return;
if (d.vseq_start.v > updSeq + 1) {
@ -4129,7 +4129,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShort: {
const MTPDupdateShort &d(updates.c_updateShort());
const auto &d(updates.c_updateShort());
feedUpdate(d.vupdate);
@ -4137,13 +4137,13 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
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))) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
return getDifference();
}
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)) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
return getDifference();
@ -4170,7 +4170,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShortChatMessage: {
const MTPDupdateShortChatMessage &d(updates.c_updateShortChatMessage());
const auto &d(updates.c_updateShortChatMessage());
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))) {
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();
}
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)) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
return getDifference();
@ -4205,7 +4205,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShortSentMessage: {
const MTPDupdateShortSentMessage &d(updates.c_updateShortSentMessage());
const auto &d(updates.c_updateShortSentMessage());
if (randomId) {
PeerId peerId = 0;
QString text;
@ -4242,7 +4242,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
switch (update.type()) {
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)) {
return;
@ -4266,7 +4266,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateMessageID: {
const MTPDupdateMessageID &d(update.c_updateMessageID());
const auto &d(update.c_updateMessageID());
FullMsgId msg = App::histItemByRandom(d.vrandom_id.v);
if (msg.msg) {
HistoryItem *msgRow = App::histItemById(msg);
@ -4296,14 +4296,14 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
}
// 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) {
if (HistoryItem *item = App::histItemById(NoChannel, v.at(i).v)) {
if (item->isMediaUnread()) {
@ -4320,7 +4320,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
@ -4333,7 +4333,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
@ -4356,7 +4356,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
@ -4371,7 +4371,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
@ -4385,7 +4385,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateUserTyping: {
const MTPDupdateUserTyping &d(update.c_updateUserTyping());
const auto &d(update.c_updateUserTyping());
History *history = App::historyLoaded(peerFromUser(d.vuser_id));
UserData *user = App::userLoaded(d.vuser_id.v);
if (history && user) {
@ -4394,7 +4394,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateChatUserTyping: {
const MTPDupdateChatUserTyping &d(update.c_updateChatUserTyping());
const auto &d(update.c_updateChatUserTyping());
History *history = 0;
if (PeerData *chat = App::chatLoaded(d.vchat_id.v)) {
history = App::historyLoaded(chat->id);
@ -4428,7 +4428,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateUserStatus: {
const MTPDupdateUserStatus &d(update.c_updateUserStatus());
const auto &d(update.c_updateUserStatus());
UserData *user = App::userLoaded(d.vuser_id.v);
if (user) {
switch (d.vstatus.type()) {
@ -4458,7 +4458,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateUserName: {
const MTPDupdateUserName &d(update.c_updateUserName());
const auto &d(update.c_updateUserName());
UserData *user = App::userLoaded(d.vuser_id.v);
if (user) {
if (user->contact <= 0) {
@ -4471,7 +4471,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateUserPhoto: {
const MTPDupdateUserPhoto &d(update.c_updateUserPhoto());
const auto &d(update.c_updateUserPhoto());
UserData *user = App::userLoaded(d.vuser_id.v);
if (user) {
user->setPhoto(d.vphoto);
@ -4494,7 +4494,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateContactRegistered: {
const MTPDupdateContactRegistered &d(update.c_updateContactRegistered());
const auto &d(update.c_updateContactRegistered());
UserData *user = App::userLoaded(d.vuser_id.v);
if (user) {
if (App::history(user->id)->loadedAtBottom()) {
@ -4504,22 +4504,22 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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);
} break;
case mtpc_updateNotifySettings: {
const MTPDupdateNotifySettings &d(update.c_updateNotifySettings());
const auto &d(update.c_updateNotifySettings());
applyNotifySetting(d.vpeer, d.vnotify_settings);
} break;
case mtpc_updateDcOptions: {
const MTPDupdateDcOptions &d(update.c_updateDcOptions());
const auto &d(update.c_updateDcOptions());
MTP::updateDcOptions(d.vdc_options.c_vector().v);
} break;
case mtpc_updateUserPhone: {
const MTPDupdateUserPhone &d(update.c_updateUserPhone());
const auto &d(update.c_updateUserPhone());
UserData *user = App::userLoaded(d.vuser_id.v);
if (user) {
user->setPhone(qs(d.vphone));
@ -4529,23 +4529,23 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateNewEncryptedMessage: {
const MTPDupdateNewEncryptedMessage &d(update.c_updateNewEncryptedMessage());
const auto &d(update.c_updateNewEncryptedMessage());
} break;
case mtpc_updateEncryptedChatTyping: {
const MTPDupdateEncryptedChatTyping &d(update.c_updateEncryptedChatTyping());
const auto &d(update.c_updateEncryptedChatTyping());
} break;
case mtpc_updateEncryption: {
const MTPDupdateEncryption &d(update.c_updateEncryption());
const auto &d(update.c_updateEncryption());
} break;
case mtpc_updateEncryptedMessagesRead: {
const MTPDupdateEncryptedMessagesRead &d(update.c_updateEncryptedMessagesRead());
const auto &d(update.c_updateEncryptedMessagesRead());
} break;
case mtpc_updateUserBlocked: {
const MTPDupdateUserBlocked &d(update.c_updateUserBlocked());
const auto &d(update.c_updateUserBlocked());
if (UserData *user = App::userLoaded(d.vuser_id.v)) {
user->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked;
App::markPeerUpdated(user);
@ -4553,7 +4553,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateNewAuthorization: {
const MTPDupdateNewAuthorization &d(update.c_updateNewAuthorization());
const auto &d(update.c_updateNewAuthorization());
QDateTime datetime = date(d.vdate);
QString name = App::self()->firstName;
@ -4566,7 +4566,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateServiceNotification: {
const MTPDupdateServiceNotification &d(update.c_updateServiceNotification());
const auto &d(update.c_updateServiceNotification());
if (mtpIsTrue(d.vpopup)) {
Ui::showLayer(new InformBox(qs(d.vmessage)));
} else {
@ -4575,12 +4575,12 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updatePrivacy: {
const MTPDupdatePrivacy &d(update.c_updatePrivacy());
const auto &d(update.c_updatePrivacy());
} break;
/////// Channel updates
case mtpc_updateChannel: {
const MTPDupdateChannel &d(update.c_updateChannel());
const auto &d(update.c_updateChannel());
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
App::markPeerUpdated(channel);
channel->inviter = 0;
@ -4594,7 +4594,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateNewChannelMessage: {
const MTPDupdateNewChannelMessage &d(update.c_updateNewChannelMessage());
const auto &d(update.c_updateNewChannelMessage());
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
if (!channel && !_ptsWaiter.requesting()) {
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;
case mtpc_updateEditChannelMessage: {
const MTPDupdateEditChannelMessage &d(update.c_updateEditChannelMessage());
const auto &d(update.c_updateEditChannelMessage());
ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage)));
if (channel && !_handlingChannelDifference) {
@ -4652,7 +4652,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
return;
@ -4666,7 +4666,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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 (channel->isMegagroup()) {
@ -4679,13 +4679,13 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateReadChannelInbox: {
const MTPDupdateReadChannelInbox &d(update.c_updateReadChannelInbox());
const auto &d(update.c_updateReadChannelInbox());
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
App::feedInboxRead(peerFromChannel(d.vchannel_id.v), d.vmax_id.v);
} break;
case mtpc_updateDeleteChannelMessages: {
const MTPDupdateDeleteChannelMessages &d(update.c_updateDeleteChannelMessages());
const auto &d(update.c_updateDeleteChannelMessages());
ChannelData *channel = App::channelLoaded(d.vchannel_id.v);
if (channel && !_handlingChannelDifference) {
@ -4712,7 +4712,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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 (!d.has_pts() || channel->pts() < d.vpts.v) {
getChannelDifference(channel);
@ -4721,7 +4721,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
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)) {
item->setViewsCount(d.vviews.v);
}
@ -4729,11 +4729,11 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
////// Cloud sticker sets
case mtpc_updateNewStickerSet: {
const MTPDupdateNewStickerSet &d(update.c_updateNewStickerSet());
const auto &d(update.c_updateNewStickerSet());
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) {
const MTPDstickerSet &s(set.vset.c_stickerSet());
const auto &s(set.vset.c_stickerSet());
Stickers::Sets &sets(Global::RefStickerSets());
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));
}
const QVector<MTPDocument> &v(set.vdocuments.c_vector().v);
const auto &v(set.vdocuments.c_vector().v);
it->stickers.clear();
it->stickers.reserve(v.size());
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->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) {
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)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
const auto &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
@ -4795,9 +4795,9 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateStickerSetsOrder: {
const MTPDupdateStickerSetsOrder &d(update.c_updateStickerSetsOrder());
const QVector<MTPlong> &order(d.vorder.c_vector().v);
const Stickers::Sets &sets(Global::StickerSets());
const auto &d(update.c_updateStickerSetsOrder());
const auto &order(d.vorder.c_vector().v);
const auto &sets(Global::StickerSets());
Stickers::Order result;
for (int32 i = 0, l = order.size(); i < l; ++i) {
if (sets.constFind(order.at(i).v) == sets.cend()) {

View File

@ -2079,14 +2079,14 @@ void MediaView::userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mt
const QVector<MTPPhoto> *v = 0;
switch (photos.type()) {
case mtpc_photos_photos: {
const MTPDphotos_photos &d(photos.c_photos_photos());
const auto &d(photos.c_photos_photos());
App::feedUsers(d.vusers);
v = &d.vphotos.c_vector().v;
u->photosCount = 0;
} break;
case mtpc_photos_photosSlice: {
const MTPDphotos_photosSlice &d(photos.c_photos_photosSlice());
const auto &d(photos.c_photos_photosSlice());
App::feedUsers(d.vusers);
u->photosCount = d.vcount.v;
v = &d.vphotos.c_vector().v;
@ -2111,7 +2111,7 @@ void MediaView::deletePhotosDone(const MTPVector<MTPlong> &result) {
}
bool MediaView::deletePhotosFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
return true;
}

View File

@ -440,7 +440,7 @@ ConnectionPrivate::ConnectionPrivate(QThread *thread, Connection *owner, Session
if (!dc) {
QReadLocker lock(dcOptionsMutex());
const MTP::DcOptions &options(Global::DcOptions());
const auto &options(Global::DcOptions());
if (options.isEmpty()) {
LOG(("MTP Error: connect failed, no DCs"));
dc = 0;
@ -1085,7 +1085,7 @@ void ConnectionPrivate::socketStart(bool afterConfig) {
uint32 port[2][2] = { { 0 } };
{
QReadLocker lock(dcOptionsMutex());
const MTP::DcOptions &options(Global::DcOptions());
const auto &options(Global::DcOptions());
int32 shifts[2][2][4] = {
{ // IPv4
{ // TCP IPv4
@ -1592,7 +1592,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
case mtpc_msgs_ack: {
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();
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: {
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));
mtpMsgId resendId = data.vbad_msg_id.v;
@ -1686,7 +1686,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
case mtpc_bad_server_salt: {
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));
mtpMsgId resendId = data.vbad_msg_id.v;
@ -1720,7 +1720,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
return 0;
}
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();
DEBUG_LOG(("Message Info: msgs_state_req received, ids: %1").arg(Logs::vector(ids)));
if (!idsCount) return 1;
@ -1767,10 +1767,10 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
case mtpc_msgs_state_info: {
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;
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()));
mtpRequest requestBuffer;
@ -1823,9 +1823,9 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
}
MTPMsgsAllInfo msg(from, end);
const MTPDmsgs_all_info &data(msg.c_msgs_all_info());
const QVector<MTPlong> ids(data.vmsg_ids.c_vector().v);
const string &states(data.vinfo.c_string().v);
const auto &data(msg.c_msgs_all_info());
const auto &ids(data.vmsg_ids.c_vector().v);
const auto &states(data.vinfo.c_string().v);
QVector<MTPlong> toAck;
@ -1837,7 +1837,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
case mtpc_msg_detailed_info: {
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));
@ -1873,7 +1873,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
return 0;
}
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));
@ -1894,7 +1894,7 @@ int32 ConnectionPrivate::handleOneReceived(const mtpPrime *from, const mtpPrime
case mtpc_msg_resend_req: {
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();
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: {
const mtpPrime *start = from;
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 (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: {
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));
if (!wasSent(data.vmsg_id.v)) {
@ -2405,7 +2405,7 @@ void ConnectionPrivate::pqAnswered() {
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) {
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()));
@ -2414,9 +2414,9 @@ void ConnectionPrivate::pqAnswered() {
static MTP::internal::RSAPublicKeys RSAKeys = MTP::internal::InitRSAPublicKeys();
const MTP::internal::RSAPublicKey *rsaKey = nullptr;
const QVector<MTPlong> &fingerPrints(res_pq.c_resPQ().vserver_public_key_fingerprints.c_vector().v);
for (const MTPlong &fingerPrint : fingerPrints) {
auto it = RSAKeys.constFind(fingerPrint.v);
const auto &fingerPrints(res_pq.c_resPQ().vserver_public_key_fingerprints.c_vector().v);
for (const auto &fingerPrint : fingerPrints) {
auto it = RSAKeys.constFind(static_cast<uint64>(fingerPrint.v));
if (it != RSAKeys.cend()) {
rsaKey = &it.value();
break;
@ -2424,7 +2424,7 @@ void ConnectionPrivate::pqAnswered() {
}
if (!rsaKey) {
QStringList suggested, my;
for (const MTPlong &fingerPrint : fingerPrints) {
for (const auto &fingerPrint : fingerPrints) {
suggested.push_back(QString("%1").arg(fingerPrint.v));
}
for (auto i = RSAKeys.cbegin(), e = RSAKeys.cend(); i != e; ++i) {
@ -2505,7 +2505,7 @@ void ConnectionPrivate::dhParamsAnswered() {
switch (res_DH_params.type()) {
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) {
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()));
@ -2548,7 +2548,7 @@ void ConnectionPrivate::dhParamsAnswered() {
const mtpPrime *from(&decBuffer[5]), *to(from), *end(from + (encDHBufLen - 5));
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) {
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()));
@ -2590,7 +2590,7 @@ void ConnectionPrivate::dhParamsAnswered() {
} return dhClientParamsSend();
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) {
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()));
@ -2691,7 +2691,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
switch (res_client_DH_params.type()) {
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) {
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()));
@ -2731,7 +2731,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
} return;
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) {
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()));
@ -2759,7 +2759,7 @@ void ConnectionPrivate::dhClientParamsAnswered() {
} return dhClientParamsSend();
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) {
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()));

View File

@ -211,8 +211,8 @@ void AutoConnection::requestFinished(QNetworkReply *reply) {
emit receivedData();
} else if (status == WaitingBoth || status == WaitingHttp) {
try {
MTPResPQ res_pq = readPQFakeReply(data);
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
auto res_pq = readPQFakeReply(data);
const auto &res_pq_data(res_pq.c_resPQ());
if (res_pq_data.vnonce == httpNonce) {
if (status == WaitingBoth) {
status = HttpReady;
@ -277,8 +277,8 @@ void AutoConnection::socketPacket(const char *packet, uint32 length) {
} else if (status == WaitingBoth || status == WaitingTcp || status == HttpReady) {
tcpTimeoutTimer.stop();
try {
MTPResPQ res_pq = readPQFakeReply(data);
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
auto res_pq = readPQFakeReply(data);
const auto &res_pq_data(res_pq.c_resPQ());
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"));
status = UsingTcp;

View File

@ -170,8 +170,8 @@ void HTTPConnection::requestFinished(QNetworkReply *reply) {
emit receivedData();
} else {
try {
MTPResPQ res_pq = readPQFakeReply(data);
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
auto res_pq = readPQFakeReply(data);
const auto &res_pq_data(res_pq.c_resPQ());
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"));
status = UsingHttp;

View File

@ -361,8 +361,8 @@ void TCPConnection::socketPacket(const char *packet, uint32 length) {
} else if (status == WaitingTcp) {
tcpTimeoutTimer.stop();
try {
MTPResPQ res_pq = readPQFakeReply(data);
const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
auto res_pq = readPQFakeReply(data);
const auto &res_pq_data(res_pq.c_resPQ());
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"));
status = UsingTcp;

View File

@ -150,7 +150,7 @@ namespace {
void configLoaded(const MTPConfig &result) {
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()));
@ -177,7 +177,7 @@ namespace {
configLoader()->done();
}
bool configFailed(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
loadingConfig = false;
LOG(("MTP Error: failed to get config!"));
@ -194,7 +194,7 @@ void updateDcOptions(const QVector<MTPDcOption> &options) {
opts = Global::DcOptions();
}
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);
if (already.constFind(idWithShift) == already.cend()) {
already.insert(idWithShift);
@ -264,7 +264,7 @@ void ConfigLoader::enumDC() {
OrderedSet<int32> dcs;
{
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) {
dcs.insert(MTP::bareDcId(i.key()));
}

View File

@ -125,7 +125,7 @@ namespace {
}
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
return true;
@ -140,13 +140,13 @@ namespace {
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());
authExportRequests.remove(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);
if (i != authExportRequests.cend()) {
@ -159,7 +159,7 @@ namespace {
bool onErrorDefault(mtpRequestId requestId, const RPCError &error) {
const QString &err(error.type());
int32 code = error.code();
if (!mtpIsFlood(error) && err != qsl("AUTH_KEY_UNREGISTERED")) {
if (!isFloodError(error) && err != qstr("AUTH_KEY_UNREGISTERED")) {
int breakpoint = 0;
}
bool badGuestDC = (code == 400) && (err == qsl("FILE_ID_INVALID"));
@ -262,7 +262,7 @@ namespace {
waiters.push_back(requestId);
if (badGuestDC) badGuestDCRequests.insert(requestId);
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;
{
QReadLocker locker(&requestMapLock);
@ -290,7 +290,7 @@ namespace {
session->sendPrepared(req);
}
return true;
} else if (err == qsl("MSG_WAIT_FAILED")) {
} else if (err == qstr("MSG_WAIT_FAILED")) {
mtpRequest req;
{
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
if (mtpIsFlood(err)) {
if (isDefaultHandledError(err)) {
if (onFail && (*onFail)(requestId, err)) return true;
}

View File

@ -462,7 +462,7 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
--_queue->queries;
_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);
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) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
cancel(true);
return true;

View File

@ -24,19 +24,18 @@ class RPCError {
public:
RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) {
const string &msg(error.c_rpc_error().verror_message.c_string().v);
const QString &text(QString::fromUtf8(msg.c_str(), msg.length()));
QString text = qs(error.c_rpc_error().verror_message);
if (_code < 0 || _code >= 500) {
_type = "INTERNAL_SERVER_ERROR";
_type = qsl("INTERNAL_SERVER_ERROR");
_description = text;
} else {
QRegularExpressionMatch m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
auto m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
if (m.hasMatch()) {
_type = m.captured(1);
_description = m.captured(2).mid(2);
} else {
_type = "CLIENT_BAD_RPC_ERROR";
_description = "Bad rpc error received, text = '" + text + "'";
_type = qsl("CLIENT_BAD_RPC_ERROR");
_description = qsl("Bad rpc error received, text = '") + text + '\'';
}
}
}
@ -64,10 +63,22 @@ private:
QString _type, _description;
};
inline bool mtpIsFlood(const RPCError &error) {
return error.type().startsWith(qsl("FLOOD_WAIT_"));
namespace MTP {
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
public:
virtual void operator()(mtpRequestId requestId, const mtpPrime *from, const mtpPrime *end) const = 0;

View File

@ -214,7 +214,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
const QVector<MTPMessage> *messages = 0;
switch (result.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(result.c_messages_messages());
const auto &d(result.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
messages = &d.vmessages.c_vector().v;
@ -222,7 +222,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(result.c_messages_messagesSlice());
const auto &d(result.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
messages = &d.vmessages.c_vector().v;
@ -230,7 +230,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(result.c_messages_channelMessages());
const auto &d(result.c_messages_channelMessages());
if (_peer && _peer->isChannel()) {
_peer->asChannel()->ptsReceived(d.vpts.v);
} else {
@ -286,7 +286,7 @@ void OverviewInner::searchReceived(SearchRequestType type, const MTPmessages_Mes
}
bool OverviewInner::searchFailed(SearchRequestType type, const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
if (_searchRequest == req) {
_searchRequest = 0;

View File

@ -384,7 +384,7 @@ void ProfileInner::blockDone(bool blocked, const MTPBool &result) {
}
bool ProfileInner::blockFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
_blockRequest = 0;
return false;
@ -1364,7 +1364,7 @@ void ProfileInner::migrateDone(const MTPUpdates &updates) {
}
bool ProfileInner::migrateFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
Ui::hideLayer();
return true;
}

View File

@ -953,7 +953,7 @@ void SettingsInner::gotPassword(const MTPaccount_Password &result) {
switch (result.type()) {
case mtpc_account_noPassword: {
const MTPDaccount_noPassword &d(result.c_account_noPassword());
const auto &d(result.c_account_noPassword());
_curPasswordSalt = QByteArray();
_hasPasswordRecovery = false;
_curPasswordHint = QString();
@ -963,7 +963,7 @@ void SettingsInner::gotPassword(const MTPaccount_Password &result) {
} break;
case mtpc_account_password: {
const MTPDaccount_password &d(result.c_account_password());
const auto &d(result.c_account_password());
_curPasswordSalt = qba(d.vcurrent_salt);
_hasPasswordRecovery = mtpIsTrue(d.vhas_recovery);
_curPasswordHint = qs(d.vhint);
@ -986,7 +986,7 @@ void SettingsInner::offPasswordDone(const MTPBool &result) {
}
bool SettingsInner::offPasswordFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (MTP::isDefaultHandledError(error)) return false;
onReloadPassword();
return true;
@ -1182,7 +1182,7 @@ void SettingsInner::supportGot(const MTPhelp_Support &support) {
if (!App::main()) return;
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));
Ui::showPeerHistory(u, ShowAtUnreadMsgId);
App::wnd()->hideSettings();

View File

@ -203,7 +203,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
StorageImageLocation newPhotoLoc = photoLoc;
switch (p.type()) {
case mtpc_userProfilePhoto: {
const MTPDuserProfilePhoto d(p.c_userProfilePhoto());
const auto &d(p.c_userProfilePhoto());
newPhotoId = d.vphoto_id.v;
newPhotoLoc = App::imageLocation(160, 160, d.vphoto_small);
newPhoto = newPhotoLoc.isNull() ? userDefPhoto(colorIndex) : ImagePtr(newPhotoLoc);
@ -307,7 +307,7 @@ void UserData::setBotInfoVersion(int version) {
void UserData::setBotInfo(const MTPBotInfo &info) {
switch (info.type()) {
case mtpc_botInfo: {
const MTPDbotInfo &d(info.c_botInfo());
const auto &d(info.c_botInfo());
if (peerFromUser(d.vuser_id.v) != id || !botInfo) return;
QString desc = qs(d.vdescription);
@ -316,7 +316,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
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());
bool changedCommands = false;
int32 j = 0;
@ -378,7 +378,7 @@ void ChatData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see Loc
StorageImageLocation newPhotoLoc = photoLoc;
switch (p.type()) {
case mtpc_chatPhoto: {
const MTPDchatPhoto d(p.c_chatPhoto());
const auto &d(p.c_chatPhoto());
if (phId != UnknownPeerPhotoId) {
newPhotoId = phId;
}
@ -407,7 +407,7 @@ void ChannelData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see
StorageImageLocation newPhotoLoc = photoLoc;
switch (p.type()) {
case mtpc_chatPhoto: {
const MTPDchatPhoto d(p.c_chatPhoto());
const auto &d(p.c_chatPhoto());
if (phId != UnknownPeerPhotoId) {
newPhotoId = phId;
}
@ -1008,7 +1008,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
for (int32 i = 0, l = attributes.size(); i < l; ++i) {
switch (attributes[i].type()) {
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);
} break;
case mtpc_documentAttributeAnimated: if (type == FileDocument || type == StickerDocument || type == VideoDocument) {
@ -1017,7 +1017,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
_additional = 0;
} break;
case mtpc_documentAttributeSticker: {
const MTPDdocumentAttributeSticker &d(attributes[i].c_documentAttributeSticker());
const auto &d(attributes[i].c_documentAttributeSticker());
if (type == FileDocument) {
type = StickerDocument;
StickerData *sticker = new StickerData();
@ -1029,7 +1029,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
}
} break;
case mtpc_documentAttributeVideo: {
const MTPDdocumentAttributeVideo &d(attributes[i].c_documentAttributeVideo());
const auto &d(attributes[i].c_documentAttributeVideo());
if (type == FileDocument) {
type = VideoDocument;
}
@ -1037,7 +1037,7 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
dimensions = QSize(d.vw.v, d.vh.v);
} break;
case mtpc_documentAttributeAudio: {
const MTPDdocumentAttributeAudio &d(attributes[i].c_documentAttributeAudio());
const auto &d(attributes[i].c_documentAttributeAudio());
if (type == FileDocument) {
if (d.is_voice()) {
type = VoiceDocument;

View File

@ -70,18 +70,18 @@ inline EntitiesInText entitiesFromMTP(const QVector<MTPMessageEntity> &entities)
if (!entities.isEmpty()) {
result.reserve(entities.size());
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()) {
case mtpc_messageEntityUrl: { const MTPDmessageEntityUrl &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_messageEntityEmail: { const MTPDmessageEntityEmail &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_messageEntityMention: { const MTPDmessageEntityMention &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_messageEntityBold: { const MTPDmessageEntityBold &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_messageEntityCode: { const MTPDmessageEntityCode &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_messageEntityUrl: { const auto &d(e.c_messageEntityUrl()); result.push_back(EntityInText(EntityInTextUrl, d.voffset.v, d.vlength.v)); } 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 auto &d(e.c_messageEntityEmail()); result.push_back(EntityInText(EntityInTextEmail, 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 auto &d(e.c_messageEntityMention()); result.push_back(EntityInText(EntityInTextMention, 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 auto &d(e.c_messageEntityBold()); result.push_back(EntityInText(EntityInTextBold, 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 auto &d(e.c_messageEntityCode()); result.push_back(EntityInText(EntityInTextCode, d.voffset.v, d.vlength.v)); } 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;
}
}
}