diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index a627cb3c21..2917d1ad32 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -719,8 +719,7 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers: writeRecent = true; } - MTPmessages_ClearRecentStickers::Flags flags = 0; - _stickersClearRecentRequestId = MTP::send(MTPmessages_ClearRecentStickers(MTP_flags(flags)), rpcDone(&ApiWrap::stickersClearRecentDone), rpcFail(&ApiWrap::stickersClearRecentFail)); + _stickersClearRecentRequestId = MTP::send(MTPmessages_ClearRecentStickers(MTP_flags(0)), rpcDone(&ApiWrap::stickersClearRecentDone), rpcFail(&ApiWrap::stickersClearRecentFail)); continue; } @@ -1069,7 +1068,7 @@ void ApiWrap::saveDraftsToCloud() { } cloudDraft = history->createCloudDraft(localDraft); - MTPmessages_SaveDraft::Flags flags = 0; + auto flags = MTPmessages_SaveDraft::Flags(0); auto &textWithTags = cloudDraft->textWithTags; if (cloudDraft->previewCancelled) { flags |= MTPmessages_SaveDraft::Flag::f_no_webpage; @@ -1445,8 +1444,7 @@ void ApiWrap::stickersSaveOrder() { mtpOrder.push_back(MTP_long(setId)); } - MTPmessages_ReorderStickerSets::Flags flags = 0; - _stickersReorderRequestId = MTP::send(MTPmessages_ReorderStickerSets(MTP_flags(flags), MTP_vector(mtpOrder)), rpcDone(&ApiWrap::stickersReorderDone), rpcFail(&ApiWrap::stickersReorderFail)); + _stickersReorderRequestId = MTP::send(MTPmessages_ReorderStickerSets(MTP_flags(0), MTP_vector(mtpOrder)), rpcDone(&ApiWrap::stickersReorderDone), rpcFail(&ApiWrap::stickersReorderFail)); } else { stickersReorderDone(MTP_boolTrue()); } diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index dc1a1a8e8b..122d4d4dea 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -1919,8 +1919,7 @@ namespace { photoSizes.push_back(MTP_photoSize(MTP_string("a"), uphoto.vphoto_small, MTP_int(160), MTP_int(160), MTP_int(0))); photoSizes.push_back(MTP_photoSize(MTP_string("c"), uphoto.vphoto_big, MTP_int(640), MTP_int(640), MTP_int(0))); - MTPDphoto::Flags photoFlags = 0; - return MTP_photo(MTP_flags(photoFlags), uphoto.vphoto_id, MTP_long(0), date, MTP_vector(photoSizes)); + return MTP_photo(MTP_flags(0), uphoto.vphoto_id, MTP_long(0), date, MTP_vector(photoSizes)); } return MTP_photoEmpty(MTP_long(0)); } diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 78d9c1274b..f78a3fea10 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -342,7 +342,7 @@ void GroupInfoBox::onNext() { Ui::show(Box(title, _photoImage), KeepOtherLayers); } else { bool mega = false; - MTPchannels_CreateChannel::Flags flags = mega ? MTPchannels_CreateChannel::Flag::f_megagroup : MTPchannels_CreateChannel::Flag::f_broadcast; + auto flags = mega ? MTPchannels_CreateChannel::Flag::f_megagroup : MTPchannels_CreateChannel::Flag::f_broadcast; _creationRequestId = MTP::send(MTPchannels_CreateChannel(MTP_flags(flags), MTP_string(title), MTP_string(description)), rpcDone(&GroupInfoBox::creationDone), rpcFail(&GroupInfoBox::creationFail)); } } @@ -852,7 +852,7 @@ void EditNameTitleBox::onSave() { } _sentName = first; if (_peer == App::self()) { - MTPaccount_UpdateProfile::Flags flags = MTPaccount_UpdateProfile::Flag::f_first_name | MTPaccount_UpdateProfile::Flag::f_last_name; + auto flags = MTPaccount_UpdateProfile::Flag::f_first_name | MTPaccount_UpdateProfile::Flag::f_last_name; _requestId = MTP::send(MTPaccount_UpdateProfile(MTP_flags(flags), MTP_string(first), MTP_string(last), MTPstring()), rpcDone(&EditNameTitleBox::onSaveSelfDone), rpcFail(&EditNameTitleBox::onSaveSelfFail)); } else if (_peer->isChat()) { _requestId = MTP::send(MTPmessages_EditChatTitle(_peer->asChat()->inputChat, MTP_string(first)), rpcDone(&EditNameTitleBox::onSaveChatDone), rpcFail(&EditNameTitleBox::onSaveChatFail)); diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 2d6749f461..e347380dc8 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -139,8 +139,7 @@ void ChangePhoneBox::EnterPhone::submit() { hideError(); auto phoneNumber = _phone->getLastText().trimmed(); - auto flags = MTPaccount_SendChangePhoneCode::Flags(0); - _requestId = MTP::send(MTPaccount_SendChangePhoneCode(MTP_flags(flags), MTP_string(phoneNumber), MTP_bool(false)), rpcDone(base::lambda_guarded(this, [this, phoneNumber](const MTPauth_SentCode &result) { + _requestId = MTP::send(MTPaccount_SendChangePhoneCode(MTP_flags(0), MTP_string(phoneNumber), MTP_bool(false)), rpcDone(base::lambda_guarded(this, [this, phoneNumber](const MTPauth_SentCode &result) { return sendPhoneDone(phoneNumber, result); })), rpcFail(base::lambda_guarded(this, [this, phoneNumber](const RPCError &error) { return sendPhoneFail(phoneNumber, error); diff --git a/Telegram/SourceFiles/boxes/confirmbox.cpp b/Telegram/SourceFiles/boxes/confirmbox.cpp index c602e338af..5ebcf1ed36 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.cpp +++ b/Telegram/SourceFiles/boxes/confirmbox.cpp @@ -390,7 +390,7 @@ void PinMessageBox::keyPressEvent(QKeyEvent *e) { void PinMessageBox::pinMessage() { if (_requestId) return; - MTPchannels_UpdatePinnedMessage::Flags flags = 0; + auto flags = MTPchannels_UpdatePinnedMessage::Flags(0); if (!_notify->checked()) { flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent; } diff --git a/Telegram/SourceFiles/boxes/confirmphonebox.cpp b/Telegram/SourceFiles/boxes/confirmphonebox.cpp index 492b7186f5..03f5dc9c38 100644 --- a/Telegram/SourceFiles/boxes/confirmphonebox.cpp +++ b/Telegram/SourceFiles/boxes/confirmphonebox.cpp @@ -154,8 +154,7 @@ void ConfirmPhoneBox::checkPhoneAndHash() { if (_sendCodeRequestId) { return; } - MTPaccount_SendConfirmPhoneCode::Flags flags = 0; - _sendCodeRequestId = MTP::send(MTPaccount_SendConfirmPhoneCode(MTP_flags(flags), MTP_string(_hash), MTPBool()), rpcDone(&ConfirmPhoneBox::sendCodeDone), rpcFail(&ConfirmPhoneBox::sendCodeFail)); + _sendCodeRequestId = MTP::send(MTPaccount_SendConfirmPhoneCode(MTP_flags(0), MTP_string(_hash), MTPBool()), rpcDone(&ConfirmPhoneBox::sendCodeDone), rpcFail(&ConfirmPhoneBox::sendCodeFail)); } void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) { diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index f4009e621e..24ef21c4ca 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -708,12 +708,10 @@ void ContactsBox::Inner::onPeerNameChanged(PeerData *peer, const PeerData::Names void ContactsBox::Inner::addBot() { if (auto &info = _bot->botInfo) { if (!info->shareGameShortName.isEmpty()) { - MTPmessages_SendMedia::Flags sendFlags = 0; - auto history = App::historyLoaded(_addToPeer); auto afterRequestId = history ? history->sendRequestId : 0; auto randomId = rand_value(); - auto requestId = MTP::send(MTPmessages_SendMedia(MTP_flags(sendFlags), _addToPeer->input, MTP_int(0), MTP_inputMediaGame(MTP_inputGameShortName(_bot->inputUser, MTP_string(info->shareGameShortName))), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, afterRequestId); + auto requestId = MTP::send(MTPmessages_SendMedia(MTP_flags(0), _addToPeer->input, MTP_int(0), MTP_inputMediaGame(MTP_inputGameShortName(_bot->inputUser, MTP_string(info->shareGameShortName))), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, afterRequestId); if (history) { history->sendRequestId = requestId; } diff --git a/Telegram/SourceFiles/boxes/passcodebox.cpp b/Telegram/SourceFiles/boxes/passcodebox.cpp index 0c026f3c40..afe73da6cd 100644 --- a/Telegram/SourceFiles/boxes/passcodebox.cpp +++ b/Telegram/SourceFiles/boxes/passcodebox.cpp @@ -335,7 +335,7 @@ void PasscodeBox::onSave(bool force) { if (!_oldPasscode->isHidden()) { hashSha256(oldPasswordData.constData(), oldPasswordData.size(), oldPasswordHash.data()); } - MTPDaccount_passwordInputSettings::Flags flags = MTPDaccount_passwordInputSettings::Flag::f_new_salt | MTPDaccount_passwordInputSettings::Flag::f_new_password_hash | MTPDaccount_passwordInputSettings::Flag::f_hint; + auto flags = MTPDaccount_passwordInputSettings::Flag::f_new_salt | MTPDaccount_passwordInputSettings::Flag::f_new_password_hash | MTPDaccount_passwordInputSettings::Flag::f_hint; if (_oldPasscode->isHidden() || _newPasscode->isHidden()) { flags |= MTPDaccount_passwordInputSettings::Flag::f_email; } diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 4e97537f06..9905b68f96 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -769,7 +769,7 @@ void EditCaptionBox::onSave(bool ctrlShiftEnter) { return; } - MTPmessages_EditMessage::Flags flags = MTPmessages_EditMessage::Flag::f_message; + auto flags = qFlags(MTPmessages_EditMessage::Flag::f_message); if (_previewCancelled) { flags |= MTPmessages_EditMessage::Flag::f_no_webpage; } diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index 1708ab3d94..8305fde6ff 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -895,7 +895,7 @@ void shareGameScoreFromItem(HistoryItem *item) { } }; - MTPmessages_ForwardMessages::Flags sendFlags = MTPmessages_ForwardMessages::Flag::f_with_my_score; + auto sendFlags = MTPmessages_ForwardMessages::Flag::f_with_my_score; MTPVector msgIds = MTP_vector(1, MTP_int(data->msgId.msg)); if (auto main = App::main()) { if (auto item = App::histItemById(data->msgId)) { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index cabe2b5d2d..a7856dd7cb 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -320,8 +320,7 @@ void StickersBox::loadMoreArchived() { } } } - MTPmessages_GetArchivedStickers::Flags flags = 0; - _archivedRequestId = MTP::send(MTPmessages_GetArchivedStickers(MTP_flags(flags), MTP_long(lastId), MTP_int(kArchivedLimitPerPage)), rpcDone(&StickersBox::getArchivedDone, lastId)); + _archivedRequestId = MTP::send(MTPmessages_GetArchivedStickers(MTP_flags(0), MTP_long(lastId), MTP_int(kArchivedLimitPerPage)), rpcDone(&StickersBox::getArchivedDone, lastId)); } void StickersBox::paintEvent(QPaintEvent *e) { @@ -471,8 +470,7 @@ bool StickersBox::installFail(uint64 setId, const RPCError &error) { void StickersBox::preloadArchivedSets() { if (!_archivedRequestId) { - MTPmessages_GetArchivedStickers::Flags flags = 0; - _archivedRequestId = MTP::send(MTPmessages_GetArchivedStickers(MTP_flags(flags), MTP_long(0), MTP_int(kArchivedLimitFirstRequest)), rpcDone(&StickersBox::getArchivedDone, 0ULL)); + _archivedRequestId = MTP::send(MTPmessages_GetArchivedStickers(MTP_flags(0), MTP_long(0), MTP_int(kArchivedLimitFirstRequest)), rpcDone(&StickersBox::getArchivedDone, 0ULL)); } } diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 9742c40af0..9137e9c09d 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -2643,8 +2643,7 @@ bool DialogsWidget::onSearchMessages(bool searchCache) { _searchFull = _searchFullMigrated = false; MTP::cancel(base::take(_searchRequest)); if (_searchInPeer) { - MTPmessages_Search::Flags flags = 0; - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _searchInPeer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart)); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _searchInPeer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart)); } else { _searchRequest = MTP::send(MTPmessages_SearchGlobal(MTP_string(_searchQuery), MTP_int(0), MTP_inputPeerEmpty(), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, DialogsSearchFromStart), rpcFail(&DialogsWidget::searchFailed, DialogsSearchFromStart)); } @@ -2702,12 +2701,11 @@ void DialogsWidget::searchMessages(const QString &query, PeerData *inPeer) { void DialogsWidget::onSearchMore() { if (!_searchRequest) { if (!_searchFull) { - int32 offsetDate = _inner->lastSearchDate(); - PeerData *offsetPeer = _inner->lastSearchPeer(); - MsgId offsetId = _inner->lastSearchId(); + auto offsetDate = _inner->lastSearchDate(); + auto offsetPeer = _inner->lastSearchPeer(); + auto offsetId = _inner->lastSearchId(); if (_searchInPeer) { - MTPmessages_Search::Flags flags = 0; - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _searchInPeer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(offsetId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart)); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _searchInPeer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(offsetId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart)); } else { _searchRequest = MTP::send(MTPmessages_SearchGlobal(MTP_string(_searchQuery), MTP_int(offsetDate), offsetPeer ? offsetPeer->input : MTP_inputPeerEmpty(), MTP_int(offsetId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart), rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart)); } @@ -2715,9 +2713,8 @@ void DialogsWidget::onSearchMore() { _searchQueries.insert(_searchRequest, _searchQuery); } } else if (_searchInMigrated && !_searchFullMigrated) { - MsgId offsetMigratedId = _inner->lastSearchMigratedId(); - MTPmessages_Search::Flags flags = 0; - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _searchInMigrated->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(offsetMigratedId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, offsetMigratedId ? DialogsSearchMigratedFromOffset : DialogsSearchMigratedFromStart), rpcFail(&DialogsWidget::searchFailed, offsetMigratedId ? DialogsSearchMigratedFromOffset : DialogsSearchMigratedFromStart)); + auto offsetMigratedId = _inner->lastSearchMigratedId(); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _searchInMigrated->input, MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(offsetMigratedId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, offsetMigratedId ? DialogsSearchMigratedFromOffset : DialogsSearchMigratedFromStart), rpcFail(&DialogsWidget::searchFailed, offsetMigratedId ? DialogsSearchMigratedFromOffset : DialogsSearchMigratedFromStart)); } } } @@ -2731,7 +2728,7 @@ void DialogsWidget::loadDialogs() { auto firstLoad = !_dialogsOffsetDate; auto loadCount = firstLoad ? DialogsFirstLoad : DialogsPerPage; - auto flags = qFlags(MTPmessages_GetDialogs::Flag::f_exclude_pinned); + auto flags = MTPmessages_GetDialogs::Flag::f_exclude_pinned; _dialogsRequestId = MTP::send(MTPmessages_GetDialogs(MTP_flags(flags), MTP_int(_dialogsOffsetDate), MTP_int(_dialogsOffsetId), _dialogsOffsetPeer ? _dialogsOffsetPeer->input : MTP_inputPeerEmpty(), MTP_int(loadCount)), rpcDone(&DialogsWidget::dialogsReceived), rpcFail(&DialogsWidget::dialogsFailed)); if (!_pinnedDialogsReceived) { loadPinnedDialogs(); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 4aaa024254..1f348c8ac3 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -393,8 +393,8 @@ void ChannelHistory::getRangeDifferenceNext(int32 pts) { int limit = _rangeDifferenceToId + 1 - _rangeDifferenceFromId; - auto filter = MTP_channelMessagesFilter(MTP_flags(MTPDchannelMessagesFilter::Flags(0)), MTP_vector(1, MTP_messageRange(MTP_int(_rangeDifferenceFromId), MTP_int(_rangeDifferenceToId)))); - MTPupdates_GetChannelDifference::Flags flags = MTPupdates_GetChannelDifference::Flag::f_force; + auto filter = MTP_channelMessagesFilter(MTP_flags(0), MTP_vector(1, MTP_messageRange(MTP_int(_rangeDifferenceFromId), MTP_int(_rangeDifferenceToId)))); + auto flags = MTPupdates_GetChannelDifference::Flag::f_force; _rangeDifferenceRequestId = MTP::send(MTPupdates_GetChannelDifference(MTP_flags(flags), peer->asChannel()->inputChannel, filter, MTP_int(pts), MTP_int(limit)), App::main()->rpcDone(&MainWidget::gotRangeDifference, peer->asChannel())); } @@ -728,7 +728,7 @@ void Histories::savePinnedToServer() const { peers.push_back(history->peer->input); } auto flags = MTPmessages_ReorderPinnedDialogs::Flag::f_force; - MTP::send(MTPmessages_ReorderPinnedDialogs(MTP_flags(qFlags(flags)), MTP_vector(peers))); + MTP::send(MTPmessages_ReorderPinnedDialogs(MTP_flags(flags), MTP_vector(peers))); } HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction, bool detachExistingItem) { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index b833c2ddeb..8cb33643bd 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3701,8 +3701,7 @@ void HistoryWidget::updateStickers() { } if (!Global::LastRecentStickersUpdate() || now >= Global::LastRecentStickersUpdate() + StickersUpdateTimeout) { if (!_recentStickersUpdateRequest) { - MTPmessages_GetRecentStickers::Flags flags = 0; - _recentStickersUpdateRequest = MTP::send(MTPmessages_GetRecentStickers(MTP_flags(flags), MTP_int(Local::countRecentStickersHash())), rpcDone(&HistoryWidget::recentStickersGot), rpcFail(&HistoryWidget::recentStickersFailed)); + _recentStickersUpdateRequest = MTP::send(MTPmessages_GetRecentStickers(MTP_flags(0), MTP_int(Local::countRecentStickersHash())), rpcDone(&HistoryWidget::recentStickersGot), rpcFail(&HistoryWidget::recentStickersFailed)); } } if (!Global::LastFeaturedStickersUpdate() || now >= Global::LastFeaturedStickersUpdate() + StickersUpdateTimeout) { @@ -5317,7 +5316,7 @@ void HistoryWidget::saveEditMsg() { return; } - MTPmessages_EditMessage::Flags sendFlags = MTPmessages_EditMessage::Flag::f_message; + auto sendFlags = qFlags(MTPmessages_EditMessage::Flag::f_message); if (webPageId == CancelledWebPageId) { sendFlags |= MTPmessages_EditMessage::Flag::f_no_webpage; } @@ -5524,11 +5523,11 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const fastShowAtEnd(history); PeerData *p = App::peer(peer); - MTPDmessage::Flags flags = newMessageFlags(p) | MTPDmessage::Flag::f_media; // unread, out + auto flags = newMessageFlags(p) | MTPDmessage::Flag::f_media; // unread, out bool lastKeyboardUsed = lastForceReplyReplied(FullMsgId(peerToChannel(peer), replyTo)); - MTPmessages_SendMedia::Flags sendFlags = 0; + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyTo) { flags |= MTPDmessage::Flag::f_reply_to_msg_id; sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; @@ -5890,12 +5889,12 @@ void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button using ButtonType = HistoryMessageReplyMarkup::Button::Type; BotCallbackInfo info = { bot, msg->fullId(), row, col, (button->type == ButtonType::Game) }; - MTPmessages_GetBotCallbackAnswer::Flags flags = 0; + auto flags = MTPmessages_GetBotCallbackAnswer::Flags(0); QByteArray sendData; if (info.game) { - flags = MTPmessages_GetBotCallbackAnswer::Flag::f_game; + flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_game; } else if (button->type == ButtonType::Callback) { - flags = MTPmessages_GetBotCallbackAnswer::Flag::f_data; + flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_data; sendData = button->data; } button->requestId = MTP::send(MTPmessages_GetBotCallbackAnswer(MTP_flags(flags), _peer->input, MTP_int(msg->id), MTP_bytes(sendData)), rpcDone(&HistoryWidget::botCallbackDone, info), rpcFail(&HistoryWidget::botCallbackFail, info)); @@ -6838,7 +6837,7 @@ void HistoryWidget::sendFileConfirmed(const FileLoadResultPtr &file) { fastShowAtEnd(h); - MTPDmessage::Flags flags = newMessageFlags(h->peer) | MTPDmessage::Flag::f_media; // unread, out + auto flags = newMessageFlags(h->peer) | MTPDmessage::Flag::f_media; // unread, out if (file->to.replyTo) flags |= MTPDmessage::Flag::f_reply_to_msg_id; bool channelPost = h->peer->isChannel() && !h->peer->isMegagroup(); bool showFromName = !channelPost || h->peer->asChannel()->addsSignature(); @@ -6880,7 +6879,7 @@ void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, bool silent, const M App::historyRegRandom(randomId, newId); History *hist = item->history(); MsgId replyTo = item->replyToId(); - MTPmessages_SendMedia::Flags sendFlags = 0; + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyTo) { sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; } @@ -6891,8 +6890,7 @@ void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, bool silent, const M sendFlags |= MTPmessages_SendMedia::Flag::f_silent; } auto caption = item->getMedia() ? item->getMedia()->getCaption() : TextWithEntities(); - MTPDinputMediaUploadedPhoto::Flags mediaFlags = 0; - auto media = MTP_inputMediaUploadedPhoto(MTP_flags(mediaFlags), file, MTP_string(caption.text), MTPVector()); + auto media = MTP_inputMediaUploadedPhoto(MTP_flags(0), file, MTP_string(caption.text), MTPVector()); hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_flags(sendFlags), item->history()->peer->input, MTP_int(replyTo), media, MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); } } @@ -6911,12 +6909,13 @@ namespace { if (document->type == AnimatedDocument) { attributes.push_back(MTP_documentAttributeAnimated()); } else if (document->type == StickerDocument && document->sticker()) { - MTPDdocumentAttributeSticker::Flags stickerFlags = 0; - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(document->sticker()->alt), document->sticker()->set, MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(document->sticker()->alt), document->sticker()->set, MTPMaskCoords())); } else if (document->type == SongDocument && document->song()) { - attributes.push_back(MTP_documentAttributeAudio(MTP_flags(MTPDdocumentAttributeAudio::Flag::f_title | MTPDdocumentAttributeAudio::Flag::f_performer), MTP_int(document->song()->duration), MTP_string(document->song()->title), MTP_string(document->song()->performer), MTPstring())); + auto flags = MTPDdocumentAttributeAudio::Flag::f_title | MTPDdocumentAttributeAudio::Flag::f_performer; + attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(document->song()->duration), MTP_string(document->song()->title), MTP_string(document->song()->performer), MTPstring())); } else if (document->type == VoiceDocument && document->voice()) { - attributes.push_back(MTP_documentAttributeAudio(MTP_flags(MTPDdocumentAttributeAudio::Flag::f_voice | MTPDdocumentAttributeAudio::Flag::f_waveform), MTP_int(document->voice()->duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(document->voice()->waveform)))); + auto flags = MTPDdocumentAttributeAudio::Flag::f_voice | MTPDdocumentAttributeAudio::Flag::f_waveform; + attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(document->voice()->duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(document->voice()->waveform)))); } return MTP_vector(attributes); } @@ -6926,11 +6925,11 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, bool silent, cons if (auto item = dynamic_cast(App::histItemById(newId))) { auto media = item->getMedia(); if (auto document = media ? media->getDocument() : nullptr) { - uint64 randomId = rand_value(); + auto randomId = rand_value(); App::historyRegRandom(randomId, newId); - History *hist = item->history(); - MsgId replyTo = item->replyToId(); - MTPmessages_SendMedia::Flags sendFlags = 0; + auto hist = item->history(); + auto replyTo = item->replyToId(); + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyTo) { sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; } @@ -6941,8 +6940,7 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, bool silent, cons sendFlags |= MTPmessages_SendMedia::Flag::f_silent; } auto caption = item->getMedia() ? item->getMedia()->getCaption() : TextWithEntities(); - MTPDinputMediaUploadedDocument::Flags mediaFlags = 0; - auto media = MTP_inputMediaUploadedDocument(MTP_flags(mediaFlags), file, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption.text), MTPVector()); + auto media = MTP_inputMediaUploadedDocument(MTP_flags(0), file, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption.text), MTPVector()); hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_flags(sendFlags), item->history()->peer->input, MTP_int(replyTo), media, MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); } } @@ -6952,11 +6950,11 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, bool silent, if (auto item = dynamic_cast(App::histItemById(newId))) { auto media = item->getMedia(); if (auto document = media ? media->getDocument() : nullptr) { - uint64 randomId = rand_value(); + auto randomId = rand_value(); App::historyRegRandom(randomId, newId); - History *hist = item->history(); - MsgId replyTo = item->replyToId(); - MTPmessages_SendMedia::Flags sendFlags = 0; + auto hist = item->history(); + auto replyTo = item->replyToId(); + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyTo) { sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; } @@ -6967,8 +6965,7 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, bool silent, sendFlags |= MTPmessages_SendMedia::Flag::f_silent; } auto caption = media ? media->getCaption() : TextWithEntities(); - MTPDinputMediaUploadedThumbDocument::Flags mediaFlags = 0; - auto media = MTP_inputMediaUploadedThumbDocument(MTP_flags(mediaFlags), file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption.text), MTPVector()); + auto media = MTP_inputMediaUploadedThumbDocument(MTP_flags(0), file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption.text), MTPVector()); hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_flags(sendFlags), item->history()->peer->input, MTP_int(replyTo), media, MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); } } @@ -7666,8 +7663,8 @@ void HistoryWidget::onInlineResultSend(InlineBots::Result *result, UserData *bot bool lastKeyboardUsed = lastForceReplyReplied(); bool out = !_peer->isSelf(), unread = !_peer->isSelf(); - MTPDmessage::Flags flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out - MTPmessages_SendInlineBotResult::Flags sendFlags = MTPmessages_SendInlineBotResult::Flag::f_clear_draft; + auto flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out + auto sendFlags = qFlags(MTPmessages_SendInlineBotResult::Flag::f_clear_draft); if (replyToId()) { flags |= MTPDmessage::Flag::f_reply_to_msg_id; sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_reply_to_msg_id; @@ -7846,8 +7843,8 @@ bool HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &capti bool lastKeyboardUsed = lastForceReplyReplied(); bool out = !_peer->isSelf(), unread = !_peer->isSelf(); - MTPDmessage::Flags flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out - MTPmessages_SendMedia::Flags sendFlags = 0; + auto flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyToId()) { flags |= MTPDmessage::Flag::f_reply_to_msg_id; sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; @@ -7902,8 +7899,8 @@ void HistoryWidget::sendExistingPhoto(PhotoData *photo, const QString &caption) bool lastKeyboardUsed = lastForceReplyReplied(); bool out = !_peer->isSelf(), unread = !_peer->isSelf(); - MTPDmessage::Flags flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out - MTPmessages_SendMedia::Flags sendFlags = 0; + auto flags = newMessageFlags(_peer) | MTPDmessage::Flag::f_media; // unread, out + auto sendFlags = MTPmessages_SendMedia::Flags(0); if (replyToId()) { flags |= MTPDmessage::Flag::f_reply_to_msg_id; sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id; @@ -8078,8 +8075,7 @@ void HistoryWidget::onUnpinMessage() { } Ui::hideLayer(); - MTPchannels_UpdatePinnedMessage::Flags flags = 0; - MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(flags), _peer->asChannel()->inputChannel, MTP_int(0)), rpcDone(&HistoryWidget::unpinDone)); + MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(0), _peer->asChannel()->inputChannel, MTP_int(0)), rpcDone(&HistoryWidget::unpinDone)); }))); } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp index 514e3e61b4..1522293406 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp @@ -344,7 +344,7 @@ void Result::createDocument() { } else if (_type == Type::Video) { attributes.push_back(MTP_documentAttributeVideo(MTP_int(_duration), MTP_int(_width), MTP_int(_height))); } else if (_type == Type::Audio) { - MTPDdocumentAttributeAudio::Flags flags = 0; + auto flags = MTPDdocumentAttributeAudio::Flags(0); if (mime == qstr("audio/ogg")) { flags |= MTPDdocumentAttributeAudio::Flag::f_voice; } else { diff --git a/Telegram/SourceFiles/intro/introphone.cpp b/Telegram/SourceFiles/intro/introphone.cpp index c185580b68..d0645dd584 100644 --- a/Telegram/SourceFiles/intro/introphone.cpp +++ b/Telegram/SourceFiles/intro/introphone.cpp @@ -160,8 +160,7 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) { _checkRequest->start(1000); - MTPauth_SendCode::Flags flags = 0; - _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(flags), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); + _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(0), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); } else { showSignup(); _sentRequest = 0; @@ -197,8 +196,7 @@ void PhoneWidget::toSignUp() { _checkRequest->start(1000); - MTPauth_SendCode::Flags flags = 0; - _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(flags), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); + _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(0), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); } bool PhoneWidget::phoneSubmitFail(const RPCError &error) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index df08e3aba4..349c1573a1 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -355,8 +355,8 @@ void MainWidget::finishForwarding(History *history, bool silent) { PeerData *forwardFrom = 0; App::main()->readServerHistory(history); - MTPDmessage::Flags flags = 0; - MTPmessages_ForwardMessages::Flags sendFlags = 0; + auto flags = MTPDmessage::Flags(0); + auto sendFlags = MTPmessages_ForwardMessages::Flags(0); bool channelPost = history->peer->isChannel() && !history->peer->isMegagroup(); bool showFromName = !channelPost || history->peer->asChannel()->addsSignature(); bool silentPost = channelPost && silent; @@ -818,7 +818,7 @@ void MainWidget::deleteHistoryPart(DeleteHistoryRequest request, const MTPmessag return; } - MTPmessages_DeleteHistory::Flags flags = 0; + auto flags = MTPmessages_DeleteHistory::Flags(0); if (request.justClearHistory) { flags |= MTPmessages_DeleteHistory::Flag::f_just_clear; } @@ -872,8 +872,7 @@ void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) { } if (deleteHistory) { DeleteHistoryRequest request = { peer, false }; - MTPmessages_DeleteHistory::Flags flags = 0; - MTP::send(MTPmessages_DeleteHistory(MTP_flags(flags), peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, request)); + MTP::send(MTPmessages_DeleteHistory(MTP_flags(0), peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, request)); } } @@ -927,7 +926,7 @@ void MainWidget::clearHistory(PeerData *peer) { h->clear(); h->newLoaded = h->oldLoaded = true; } - MTPmessages_DeleteHistory::Flags flags = MTPmessages_DeleteHistory::Flag::f_just_clear; + auto flags = MTPmessages_DeleteHistory::Flag::f_just_clear; DeleteHistoryRequest request = { peer, true }; MTP::send(MTPmessages_DeleteHistory(MTP_flags(flags), peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, request)); } @@ -1221,8 +1220,8 @@ void MainWidget::sendMessage(const MessageToSend &message) { App::historyRegSentData(randomId, history->peer->id, sendingText); MTPstring msgText(MTP_string(sendingText)); - MTPDmessage::Flags flags = newMessageFlags(history->peer) | MTPDmessage::Flag::f_entities; // unread, out - MTPmessages_SendMessage::Flags sendFlags = 0; + auto flags = newMessageFlags(history->peer) | MTPDmessage::Flag::f_entities; // unread, out + auto sendFlags = MTPmessages_SendMessage::Flags(0); if (replyTo) { flags |= MTPDmessage::Flag::f_reply_to_msg_id; sendFlags |= MTPmessages_SendMessage::Flag::f_reply_to_msg_id; @@ -1368,8 +1367,7 @@ bool MainWidget::preloadOverview(PeerData *peer, MediaOverviewType type) { return false; } - MTPmessages_Search::Flags flags = 0; - _overviewPreload[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(flags), peer->input, MTP_string(""), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::overviewPreloaded, peer), rpcFail(&MainWidget::overviewFailed, peer), 0, 10)); + _overviewPreload[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(0), peer->input, MTP_string(""), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::overviewPreloaded, peer), rpcFail(&MainWidget::overviewFailed, peer), 0, 10)); return true; } @@ -1478,8 +1476,7 @@ void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many MTPMessagesFilter filter = typeToMediaFilter(type); if (type == OverviewCount) return; - MTPmessages_Search::Flags flags = 0; - _overviewLoad[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(flags), peer->input, MTPstring(), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minId), MTP_int(limit)), rpcDone(&MainWidget::overviewLoaded, history))); + _overviewLoad[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(0), peer->input, MTPstring(), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minId), MTP_int(limit)), rpcDone(&MainWidget::overviewLoaded, history))); } void MainWidget::checkLastUpdate(bool afterSleep) { @@ -1807,7 +1804,7 @@ void MainWidget::dialogsCancelled() { } void MainWidget::serviceNotification(const TextWithEntities &message, const MTPMessageMedia &media, int32 date) { - MTPDmessage::Flags flags = MTPDmessage::Flag::f_entities | MTPDmessage::Flag::f_from_id | MTPDmessage_ClientFlag::f_clientside_unread; + auto flags = MTPDmessage::Flag::f_entities | MTPDmessage::Flag::f_from_id | MTPDmessage_ClientFlag::f_clientside_unread; QString sendingText, leftText = message.text; EntitiesInText sendingEntities, leftEntities = message.entities; HistoryItem *item = nullptr; @@ -3782,8 +3779,7 @@ void MainWidget::getDifference() { _ptsWaiter.setRequesting(true); - MTPupdates_GetDifference::Flags flags = 0; - MTP::send(MTPupdates_GetDifference(MTP_flags(flags), MTP_int(_ptsWaiter.current()), MTPint(), MTP_int(updDate), MTP_int(updQts)), rpcDone(&MainWidget::gotDifference), rpcFail(&MainWidget::failDifference)); + MTP::send(MTPupdates_GetDifference(MTP_flags(0), MTP_int(_ptsWaiter.current()), MTPint(), MTP_int(updDate), MTP_int(updQts)), rpcDone(&MainWidget::gotDifference), rpcFail(&MainWidget::failDifference)); } void MainWidget::getChannelDifference(ChannelData *channel, ChannelDifferenceRequest from) { @@ -3802,7 +3798,7 @@ void MainWidget::getChannelDifference(ChannelData *channel, ChannelDifferenceReq channel->ptsSetRequesting(true); auto filter = MTP_channelMessagesFilterEmpty(); - MTPupdates_GetChannelDifference::Flags flags = MTPupdates_GetChannelDifference::Flag::f_force; + auto flags = qFlags(MTPupdates_GetChannelDifference::Flag::f_force); if (from != ChannelDifferenceRequest::PtsGapOrShortPoll) { if (!channel->ptsWaitingForSkipped()) { flags = 0; // No force flag when requesting for short poll. @@ -4649,7 +4645,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { } // update before applying skipped - MTPDmessage::Flags flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; + auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; auto item = App::histories().addNewMessage(MTP_message(MTP_flags(flags), d.vid, d.is_out() ? MTP_int(AuthSession::CurrentUserId()) : d.vuser_id, MTP_peerUser(d.is_out() ? d.vuser_id : MTP_int(AuthSession::CurrentUserId())), d.vfwd_from, d.vvia_bot_id, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint(), MTPint()), NewMessageUnread); if (item) { _history->peerMessagesUpdated(item->history()->peer->id); @@ -4677,7 +4673,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { } // update before applying skipped - MTPDmessage::Flags flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; + auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; auto item = App::histories().addNewMessage(MTP_message(MTP_flags(flags), d.vid, d.vfrom_id, MTP_peerChat(d.vchat_id), d.vfwd_from, d.vvia_bot_id, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint(), MTPint()), NewMessageUnread); if (item) { _history->peerMessagesUpdated(item->history()->peer->id); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 2d8f482f3a..abd21c81e9 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -336,7 +336,7 @@ void MainWindow::sendServiceHistoryRequest() { UserData *user = App::userLoaded(ServiceUserId); if (!user) { - MTPDuser::Flags userFlags = MTPDuser::Flag::f_first_name | MTPDuser::Flag::f_phone | MTPDuser::Flag::f_status | MTPDuser::Flag::f_verified; + auto userFlags = MTPDuser::Flag::f_first_name | MTPDuser::Flag::f_phone | MTPDuser::Flag::f_status | MTPDuser::Flag::f_verified; user = App::feedUsers(MTP_vector(1, MTP_user(MTP_flags(userFlags), MTP_int(ServiceUserId), MTPlong(), MTP_string("Telegram"), MTPstring(), MTPstring(), MTP_string("42777"), MTP_userProfilePhotoEmpty(), MTP_userStatusRecently(), MTPint(), MTPstring(), MTPstring()))); } _serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), _main->rpcDone(&MainWidget::serviceHistoryDone), _main->rpcFail(&MainWidget::serviceHistoryFail)); diff --git a/Telegram/SourceFiles/messenger.cpp b/Telegram/SourceFiles/messenger.cpp index 224acfb240..62b9a4cb43 100644 --- a/Telegram/SourceFiles/messenger.cpp +++ b/Telegram/SourceFiles/messenger.cpp @@ -617,8 +617,7 @@ void Messenger::uploadProfilePhoto(const QImage &tosend, const PeerId &peerId) { PhotoId id = rand_value(); - MTPDphoto::Flags photoFlags = 0; - auto photo = MTP_photo(MTP_flags(photoFlags), MTP_long(id), MTP_long(0), MTP_int(unixtime()), MTP_vector(photoSizes)); + auto photo = MTP_photo(MTP_flags(0), MTP_long(id), MTP_long(0), MTP_int(unixtime()), MTP_vector(photoSizes)); QString file, filename; int32 filesize = 0; diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h index 5afa0c710c..da889b5281 100644 --- a/Telegram/SourceFiles/mtproto/core_types.h +++ b/Telegram/SourceFiles/mtproto/core_types.h @@ -395,6 +395,13 @@ inline MTPint MTP_int(int32 v) { } using MTPInt = MTPBoxed; +namespace internal { + +struct ZeroFlagsHelper { +}; + +} // namespace internal + template class MTPflags { public: @@ -402,6 +409,8 @@ public: static_assert(sizeof(Flags) == sizeof(int32), "MTPflags are allowed only wrapping int32 flag types!"); MTPflags() = default; + MTPflags(internal::ZeroFlagsHelper helper) { + } uint32 innerLength() const { return sizeof(Flags); @@ -423,12 +432,25 @@ private: } template - friend MTPflags MTP_flags(T v); + friend MTPflags> MTP_flags(QFlags v); + + template + friend MTPflags> MTP_flags(T v); + }; template -inline MTPflags MTP_flags(T v) { - return MTPflags(v); +inline MTPflags> MTP_flags(QFlags v) { + return MTPflags>(v); +} + +template ::value>> +inline MTPflags> MTP_flags(T v) { + return MTPflags>(v); +} + +inline internal::ZeroFlagsHelper MTP_flags(void(internal::ZeroFlagsHelper::*)()) { + return internal::ZeroFlagsHelper(); } template diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index beb2e9df21..f57bc75334 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -742,14 +742,12 @@ void OverviewInner::preloadMore() { if (!_searchRequest) { MTPmessagesFilter filter = (_type == OverviewLinks) ? MTP_inputMessagesFilterUrl() : MTP_inputMessagesFilterDocument(); if (!_searchFull) { - MTPmessages_Search::Flags flags = 0; - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _history->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(_lastSearchId), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, _lastSearchId ? SearchFromOffset : SearchFromStart), rpcFail(&OverviewInner::searchFailed, _lastSearchId ? SearchFromOffset : SearchFromStart)); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _history->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(_lastSearchId), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, _lastSearchId ? SearchFromOffset : SearchFromStart), rpcFail(&OverviewInner::searchFailed, _lastSearchId ? SearchFromOffset : SearchFromStart)); if (!_lastSearchId) { _searchQueries.insert(_searchRequest, _searchQuery); } } else if (_migrated && !_searchFullMigrated) { - MTPmessages_Search::Flags flags = 0; - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _migrated->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(_lastSearchMigratedId), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, _lastSearchMigratedId ? SearchMigratedFromOffset : SearchMigratedFromStart), rpcFail(&OverviewInner::searchFailed, _lastSearchMigratedId ? SearchMigratedFromOffset : SearchMigratedFromStart)); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _migrated->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(_lastSearchMigratedId), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, _lastSearchMigratedId ? SearchMigratedFromOffset : SearchMigratedFromStart), rpcFail(&OverviewInner::searchFailed, _lastSearchMigratedId ? SearchMigratedFromOffset : SearchMigratedFromStart)); } } } else if (App::main()) { @@ -1468,9 +1466,8 @@ bool OverviewInner::onSearchMessages(bool searchCache) { } else if (_searchQuery != q) { _searchQuery = q; _searchFull = _searchFullMigrated = false; - MTPmessages_Search::Flags flags = 0; - MTPmessagesFilter filter = (_type == OverviewLinks) ? MTP_inputMessagesFilterUrl() : MTP_inputMessagesFilterDocument(); - _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(flags), _history->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, SearchFromStart), rpcFail(&OverviewInner::searchFailed, SearchFromStart)); + auto filter = (_type == OverviewLinks) ? MTP_inputMessagesFilterUrl() : MTP_inputMessagesFilterDocument(); + _searchRequest = MTP::send(MTPmessages_Search(MTP_flags(0), _history->peer->input, MTP_string(_searchQuery), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, SearchFromStart), rpcFail(&OverviewInner::searchFailed, SearchFromStart)); _searchQueries.insert(_searchRequest, _searchQuery); } return false; diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp index 2bd1bf6ab4..b96230ce76 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp @@ -90,7 +90,7 @@ void CloudPasswordState::onTurnOff() { if (_curPasswordSalt.isEmpty()) { _turnOff->hide(); - MTPDaccount_passwordInputSettings::Flags flags = MTPDaccount_passwordInputSettings::Flag::f_email; + auto flags = MTPDaccount_passwordInputSettings::Flag::f_email; MTPaccount_PasswordInputSettings settings(MTP_account_passwordInputSettings(MTP_flags(flags), MTP_bytes(QByteArray()), MTP_bytes(QByteArray()), MTP_string(QString()), MTP_string(QString()))); MTP::send(MTPaccount_UpdatePasswordSettings(MTP_bytes(QByteArray()), settings), rpcDone(&CloudPasswordState::offPasswordDone), rpcFail(&CloudPasswordState::offPasswordFail)); } else { diff --git a/Telegram/SourceFiles/stickers/emoji_pan.cpp b/Telegram/SourceFiles/stickers/emoji_pan.cpp index eb238591cc..0a2dde30c9 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.cpp +++ b/Telegram/SourceFiles/stickers/emoji_pan.cpp @@ -3887,8 +3887,7 @@ void EmojiPan::onInlineRequest() { if (nextOffset.isEmpty()) return; } Notify::inlineBotRequesting(true); - MTPmessages_GetInlineBotResults::Flags flags = 0; - _inlineRequestId = MTP::send(MTPmessages_GetInlineBotResults(MTP_flags(flags), _inlineBot->inputUser, _inlineQueryPeer->input, MTPInputGeoPoint(), MTP_string(_inlineQuery), MTP_string(nextOffset)), rpcDone(&EmojiPan::inlineResultsDone), rpcFail(&EmojiPan::inlineResultsFail)); + _inlineRequestId = MTP::send(MTPmessages_GetInlineBotResults(MTP_flags(0), _inlineBot->inputUser, _inlineQueryPeer->input, MTPInputGeoPoint(), MTP_string(_inlineQuery), MTP_string(nextOffset)), rpcDone(&EmojiPan::inlineResultsDone), rpcFail(&EmojiPan::inlineResultsFail)); } void EmojiPan::onEmptyInlineRows() { diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index 7ee8e9639f..3f2921af6a 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -503,8 +503,7 @@ void FileLoadTask::process() { full.save(&buffer, "JPG", 87); } - MTPDphoto::Flags photoFlags = 0; - photo = MTP_photo(MTP_flags(photoFlags), MTP_long(_id), MTP_long(0), MTP_int(unixtime()), MTP_vector(photoSizes)); + photo = MTP_photo(MTP_flags(0), MTP_long(_id), MTP_long(0), MTP_int(unixtime()), MTP_vector(photoSizes)); if (filesize < 0) { filesize = _result->filesize = filedata.size(); @@ -514,8 +513,7 @@ void FileLoadTask::process() { QByteArray thumbFormat = "JPG"; int32 thumbQuality = 87; if (!isAnimation && filemime == stickerMime && w > 0 && h > 0 && w <= StickerMaxSize && h <= StickerMaxSize && filesize < StickerInMemory) { - MTPDdocumentAttributeSticker::Flags stickerFlags = 0; - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(""), MTP_inputStickerSetEmpty(), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(""), MTP_inputStickerSetEmpty(), MTPMaskCoords())); thumbFormat = "webp"; thumbname = qsl("thumb.webp"); } @@ -535,7 +533,8 @@ void FileLoadTask::process() { } if (isVoice) { - attributes[0] = MTP_documentAttributeAudio(MTP_flags(MTPDdocumentAttributeAudio::Flag::f_voice | MTPDdocumentAttributeAudio::Flag::f_waveform), MTP_int(_duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform))); + auto flags = MTPDdocumentAttributeAudio::Flag::f_voice | MTPDdocumentAttributeAudio::Flag::f_waveform; + attributes[0] = MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(_duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform))); attributes.resize(1); document = MTP_document(MTP_long(_id), MTP_long(0), MTP_int(unixtime()), MTP_string(filemime), MTP_int(filesize), thumbSize, MTP_int(MTP::maindc()), MTP_int(0), MTP_vector(attributes)); } else if (_type != SendMediaType::Photo) { diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 04f0650ec9..c7afc1f415 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -3457,8 +3457,7 @@ void importOldRecentStickers() { if (type == AnimatedDocument) { attributes.push_back(MTP_documentAttributeAnimated()); } else if (type == StickerDocument) { - MTPDdocumentAttributeSticker::Flags stickerFlags = 0; - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); } if (width > 0 && height > 0) { attributes.push_back(MTP_documentAttributeImageSize(MTP_int(width), MTP_int(height))); diff --git a/Telegram/SourceFiles/storage/serialize_document.cpp b/Telegram/SourceFiles/storage/serialize_document.cpp index 54de06d585..2ee5489c2a 100644 --- a/Telegram/SourceFiles/storage/serialize_document.cpp +++ b/Telegram/SourceFiles/storage/serialize_document.cpp @@ -89,9 +89,8 @@ DocumentData *Document::readFromStreamHelper(int streamAppVersion, QDataStream & thumb = readStorageImageLocation(stream); - MTPDdocumentAttributeSticker::Flags stickerFlags = 0; if (typeOfSet == StickerSetTypeEmpty) { - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); } else if (info) { if (info->setId == Stickers::DefaultSetId || info->setId == Stickers::CloudRecentSetId || info->setId == Stickers::CustomSetId) { typeOfSet = StickerSetTypeEmpty; @@ -99,14 +98,14 @@ DocumentData *Document::readFromStreamHelper(int streamAppVersion, QDataStream & switch (typeOfSet) { case StickerSetTypeID: { - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(alt), MTP_inputStickerSetID(MTP_long(info->setId), MTP_long(info->accessHash)), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(alt), MTP_inputStickerSetID(MTP_long(info->setId), MTP_long(info->accessHash)), MTPMaskCoords())); } break; case StickerSetTypeShortName: { - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(alt), MTP_inputStickerSetShortName(MTP_string(info->shortName)), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(alt), MTP_inputStickerSetShortName(MTP_string(info->shortName)), MTPMaskCoords())); } break; case StickerSetTypeEmpty: default: { - attributes.push_back(MTP_documentAttributeSticker(MTP_flags(stickerFlags), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); + attributes.push_back(MTP_documentAttributeSticker(MTP_flags(0), MTP_string(alt), MTP_inputStickerSetEmpty(), MTPMaskCoords())); } break; } }