diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 78b74c727..1d006822c 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -317,6 +317,13 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt h->asChannelHistory()->unreadCountAll = f.vunread_count.v; } } + if (channel->isMegagroup()) { + if (f.has_pinned_msg_id()) { + channel->mgInfo->pinnedMsgId = f.vpinned_msg_id.v; + } else { + channel->mgInfo->pinnedMsgId = 0; + } + } channel->fullUpdated(); App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), f.vnotify_settings); @@ -344,14 +351,21 @@ 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()); App::feedUsers(MTP_vector(1, d.vuser), false); - App::feedPhoto(d.vprofile_photo); + if (d.has_profile_photo()) { + App::feedPhoto(d.vprofile_photo); + } App::feedUserLink(MTP_int(peerToUser(peer->id)), d.vlink.c_contacts_link().vmy_link, d.vlink.c_contacts_link().vforeign_link, false); if (App::main()) { App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), d.vnotify_settings); } - peer->asUser()->setBotInfo(d.vbot_info); - peer->asUser()->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked; + if (d.has_bot_info()) { + peer->asUser()->setBotInfo(d.vbot_info); + } else { + peer->asUser()->setBotInfoVersion(-1); + } + peer->asUser()->blocked = d.is_blocked() ? UserIsBlocked : UserIsNotBlocked; + peer->asUser()->about = d.has_about() ? qs(d.vabout) : QString(); if (req) { QMap::iterator i = _fullPeerRequests.find(peer); diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 86accc4bc..c695c1949 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -1094,7 +1094,8 @@ void EditNameTitleBox::onSave() { } _sentName = first; if (_peer == App::self()) { - _requestId = MTP::send(MTPaccount_UpdateProfile(MTP_string(first), MTP_string(last)), rpcDone(&EditNameTitleBox::onSaveSelfDone), rpcFail(&EditNameTitleBox::onSaveSelfFail)); + int32 flags = MTPaccount_UpdateProfile::flag_first_name | MTPaccount_UpdateProfile::flag_last_name; + _requestId = MTP::send(MTPaccount_UpdateProfile(MTP_int(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/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 91b027d79..6ab5eef10 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -5587,7 +5587,26 @@ void HistoryWidget::updateOnlineDisplay(int32 x, int32 w) { } } } else if (_peer->isChannel()) { - text = _peer->asChannel()->count ? lng_chat_status_members(lt_count, _peer->asChannel()->count) : lang(_peer->isMegagroup() ? lng_group_status : lng_channel_status); + if (_peer->isMegagroup() && _peer->asChannel()->count > 0 && _peer->asChannel()->count <= Global::ChatSizeMax()) { + if (_peer->asChannel()->mgInfo->lastParticipants.size() < _peer->asChannel()->count || _peer->asChannel()->lastParticipantsCountOutdated()) { + if (App::api()) App::api()->requestLastParticipants(_peer->asChannel()); + } + int32 onlineCount = 0; + bool onlyMe = true; + for (MentionRows::const_iterator i = _peer->asChannel()->mgInfo->lastParticipants.cbegin(), e = _peer->asChannel()->mgInfo->lastParticipants.cend(); i != e; ++i) { + if ((*i)->onlineTill > t) { + ++onlineCount; + if (onlyMe && (*i) != App::self()) onlyMe = false; + } + } + if (onlineCount && !onlyMe) { + text = lng_chat_status_members_online(lt_count, _peer->asChannel()->count, lt_count_online, onlineCount); + } else { + text = lng_chat_status_members(lt_count, _peer->asChannel()->count); + } + } else { + text = _peer->asChannel()->count ? lng_chat_status_members(lt_count, _peer->asChannel()->count) : lang(_peer->isMegagroup() ? lng_group_status : lng_channel_status); + } } if (_titlePeerText != text) { _titlePeerText = text; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 1cd34b51d..6e49f6758 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -4542,6 +4542,19 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { } } break; + case mtpc_updateChannelPinnedMessage: { + const MTPDupdateChannelPinnedMessage &d(update.c_updateChannelPinnedMessage()); + + if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) { + if (channel->isMegagroup()) { + channel->mgInfo->pinnedMsgId = d.vid.v; + if (App::api()) { + emit App::api()->fullPeerUpdated(channel); + } + } + } + } break; + case mtpc_updateReadChannelInbox: { const MTPDupdateReadChannelInbox &d(update.c_updateReadChannelInbox()); ChannelData *channel = App::channelLoaded(d.vchannel_id.v); diff --git a/Telegram/SourceFiles/mtproto/mtpCoreTypes.h b/Telegram/SourceFiles/mtproto/mtpCoreTypes.h index dc16848d7..53965606c 100644 --- a/Telegram/SourceFiles/mtproto/mtpCoreTypes.h +++ b/Telegram/SourceFiles/mtproto/mtpCoreTypes.h @@ -368,7 +368,7 @@ static const mtpTypeId mtpLayers[] = { mtpTypeId(mtpc_invokeWithLayer18), }; static const uint32 mtpLayerMaxSingle = sizeof(mtpLayers) / sizeof(mtpLayers[0]); -static const mtpPrime mtpCurrentLayer = 48; +static const mtpPrime mtpCurrentLayer = 49; template class MTPBoxed : public bareT { diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.cpp b/Telegram/SourceFiles/mtproto/mtpScheme.cpp index 57bc8ec59..40ec2b60e 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.cpp +++ b/Telegram/SourceFiles/mtproto/mtpScheme.cpp @@ -1226,6 +1226,7 @@ void _serialize_channelFull(MTPStringLogger &to, int32 stage, int32 lev, Types & case 13: to.add(" bot_info: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 14: to.add(" migrated_from_chat_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_chat_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; case 15: to.add(" migrated_from_max_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_max_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; + case 16: to.add(" pinned_msg_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_pinned_msg_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -1959,12 +1960,14 @@ void _serialize_userFull(MTPStringLogger &to, int32 stage, int32 lev, Types &typ to.add("\n").addSpaces(lev); } switch (stage) { - case 0: to.add(" user: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 1: to.add(" link: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 2: to.add(" profile_photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 3: to.add(" notify_settings: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 4: to.add(" blocked: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 5: to.add(" bot_info: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" blocked: "); ++stages.back(); if (flag & MTPDuserFull::flag_blocked) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" user: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" about: "); ++stages.back(); if (flag & MTPDuserFull::flag_about) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break; + case 4: to.add(" link: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 5: to.add(" profile_photo: "); ++stages.back(); if (flag & MTPDuserFull::flag_profile_photo) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break; + case 6: to.add(" notify_settings: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 7: to.add(" bot_info: "); ++stages.back(); if (flag & MTPDuserFull::flag_bot_info) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 3 IN FIELD flags ]"); } break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -2891,6 +2894,20 @@ void _serialize_updateEditChannelMessage(MTPStringLogger &to, int32 stage, int32 } } +void _serialize_updateChannelPinnedMessage(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ updateChannelPinnedMessage"); + to.add("\n").addSpaces(lev); + } + switch (stage) { + case 0: to.add(" channel_id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; + } +} + void _serialize_updates_state(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -4304,10 +4321,6 @@ void _serialize_botCommand(MTPStringLogger &to, int32 stage, int32 lev, Types &t } } -void _serialize_botInfoEmpty(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { - to.add("{ botInfoEmpty }"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); -} - void _serialize_botInfo(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -4317,10 +4330,8 @@ void _serialize_botInfo(MTPStringLogger &to, int32 stage, int32 lev, Types &type } switch (stage) { case 0: to.add(" user_id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 1: to.add(" version: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 2: to.add(" share_text: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 3: to.add(" description: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 4: to.add(" commands: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" description: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 2: to.add(" commands: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -6031,8 +6042,10 @@ void _serialize_account_updateProfile(MTPStringLogger &to, int32 stage, int32 le to.add("\n").addSpaces(lev); } switch (stage) { - case 0: to.add(" first_name: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 1: to.add(" last_name: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" first_name: "); ++stages.back(); if (flag & MTPaccount_updateProfile::flag_first_name) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" last_name: "); ++stages.back(); if (flag & MTPaccount_updateProfile::flag_last_name) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break; + case 3: to.add(" about: "); ++stages.back(); if (flag & MTPaccount_updateProfile::flag_about) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -6937,6 +6950,20 @@ void _serialize_channels_editMessage(MTPStringLogger &to, int32 stage, int32 lev } } +void _serialize_channels_updatePinnedMessage(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ channels_updatePinnedMessage"); + to.add("\n").addSpaces(lev); + } + switch (stage) { + case 0: to.add(" channel: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; + } +} + void _serialize_messages_getChats(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -7760,6 +7787,7 @@ namespace { _serializers.insert(mtpc_updateBotInlineQuery, _serialize_updateBotInlineQuery); _serializers.insert(mtpc_updateBotInlineSend, _serialize_updateBotInlineSend); _serializers.insert(mtpc_updateEditChannelMessage, _serialize_updateEditChannelMessage); + _serializers.insert(mtpc_updateChannelPinnedMessage, _serialize_updateChannelPinnedMessage); _serializers.insert(mtpc_updates_state, _serialize_updates_state); _serializers.insert(mtpc_updates_differenceEmpty, _serialize_updates_differenceEmpty); _serializers.insert(mtpc_updates_difference, _serialize_updates_difference); @@ -7876,7 +7904,6 @@ namespace { _serializers.insert(mtpc_stickerSet, _serialize_stickerSet); _serializers.insert(mtpc_messages_stickerSet, _serialize_messages_stickerSet); _serializers.insert(mtpc_botCommand, _serialize_botCommand); - _serializers.insert(mtpc_botInfoEmpty, _serialize_botInfoEmpty); _serializers.insert(mtpc_botInfo, _serialize_botInfo); _serializers.insert(mtpc_keyboardButton, _serialize_keyboardButton); _serializers.insert(mtpc_keyboardButtonRow, _serialize_keyboardButtonRow); @@ -8072,6 +8099,7 @@ namespace { _serializers.insert(mtpc_channels_toggleInvites, _serialize_channels_toggleInvites); _serializers.insert(mtpc_channels_toggleSignatures, _serialize_channels_toggleSignatures); _serializers.insert(mtpc_channels_editMessage, _serialize_channels_editMessage); + _serializers.insert(mtpc_channels_updatePinnedMessage, _serialize_channels_updatePinnedMessage); _serializers.insert(mtpc_messages_getChats, _serialize_messages_getChats); _serializers.insert(mtpc_channels_getChannels, _serialize_channels_getChannels); _serializers.insert(mtpc_messages_getFullChat, _serialize_messages_getFullChat); diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.h b/Telegram/SourceFiles/mtproto/mtpScheme.h index 94cd2994a..8ffca9b89 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.h +++ b/Telegram/SourceFiles/mtproto/mtpScheme.h @@ -136,7 +136,7 @@ enum { mtpc_channel = 0x4b1b7506, mtpc_channelForbidden = 0x2d85832c, mtpc_chatFull = 0x2e02a614, - mtpc_channelFull = 0x9e341ddf, + mtpc_channelFull = 0x97bee562, mtpc_chatParticipant = 0xc8d7493e, mtpc_chatParticipantCreator = 0xda13538a, mtpc_chatParticipantAdmin = 0xe2d6e436, @@ -197,7 +197,7 @@ enum { mtpc_inputReportReasonViolence = 0x1e22c78d, mtpc_inputReportReasonPornography = 0x2e59d922, mtpc_inputReportReasonOther = 0xe1746d0a, - mtpc_userFull = 0x5a89ac5b, + mtpc_userFull = 0x5932fc03, mtpc_contact = 0xf911c994, mtpc_importedContact = 0xd0028438, mtpc_contactBlocked = 0x561bc879, @@ -270,6 +270,7 @@ enum { mtpc_updateBotInlineQuery = 0xc01eea08, mtpc_updateBotInlineSend = 0xf69e113, mtpc_updateEditChannelMessage = 0x1b3f4df7, + mtpc_updateChannelPinnedMessage = 0x98592475, mtpc_updates_state = 0xa56c2a3e, mtpc_updates_differenceEmpty = 0x5d75a138, mtpc_updates_difference = 0xf49ca0, @@ -386,8 +387,7 @@ enum { mtpc_stickerSet = 0xcd303b41, mtpc_messages_stickerSet = 0xb60a24a6, mtpc_botCommand = 0xc27ac8c7, - mtpc_botInfoEmpty = 0xbb2e37ce, - mtpc_botInfo = 0x9cf585d, + mtpc_botInfo = 0x98e81d3a, mtpc_keyboardButton = 0xa2fa4880, mtpc_keyboardButtonRow = 0x77608b83, mtpc_replyKeyboardHide = 0xa03e5b85, @@ -476,7 +476,7 @@ enum { mtpc_account_updateNotifySettings = 0x84be5b93, mtpc_account_getNotifySettings = 0x12b3ad31, mtpc_account_resetNotifySettings = 0xdb7e1747, - mtpc_account_updateProfile = 0xf0888d68, + mtpc_account_updateProfile = 0x78515775, mtpc_account_updateStatus = 0x6628562c, mtpc_account_getWallPapers = 0xc04cfac2, mtpc_account_reportPeer = 0xae189d5f, @@ -612,7 +612,8 @@ enum { mtpc_channels_exportMessageLink = 0xc846d22d, mtpc_channels_toggleSignatures = 0x1f69b606, mtpc_channels_getMessageEditData = 0x27ea3a28, - mtpc_channels_editMessage = 0xdcda80ed + mtpc_channels_editMessage = 0xdcda80ed, + mtpc_channels_updatePinnedMessage = 0x84a41867 }; // Type forward declarations @@ -950,6 +951,7 @@ class MTPDupdateStickerSetsOrder; class MTPDupdateBotInlineQuery; class MTPDupdateBotInlineSend; class MTPDupdateEditChannelMessage; +class MTPDupdateChannelPinnedMessage; class MTPupdates_state; class MTPDupdates_state; @@ -3314,7 +3316,7 @@ private: explicit MTPchatFull(MTPDchannelFull *_data); friend MTPchatFull MTP_chatFull(MTPint _id, const MTPChatParticipants &_participants, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info); - friend MTPchatFull MTP_channelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id); + friend MTPchatFull MTP_channelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id, MTPint _pinned_msg_id); mtpTypeId _type; }; @@ -4425,7 +4427,7 @@ public: private: explicit MTPuserFull(MTPDuserFull *_data); - friend MTPuserFull MTP_userFull(const MTPUser &_user, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, MTPBool _blocked, const MTPBotInfo &_bot_info); + friend MTPuserFull MTP_userFull(MTPint _flags, const MTPUser &_user, const MTPstring &_about, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, const MTPBotInfo &_bot_info); }; typedef MTPBoxed MTPUserFull; @@ -5458,6 +5460,18 @@ public: return *(const MTPDupdateEditChannelMessage*)data; } + MTPDupdateChannelPinnedMessage &_updateChannelPinnedMessage() { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_updateChannelPinnedMessage) throw mtpErrorWrongTypeId(_type, mtpc_updateChannelPinnedMessage); + split(); + return *(MTPDupdateChannelPinnedMessage*)data; + } + const MTPDupdateChannelPinnedMessage &c_updateChannelPinnedMessage() const { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_updateChannelPinnedMessage) throw mtpErrorWrongTypeId(_type, mtpc_updateChannelPinnedMessage); + return *(const MTPDupdateChannelPinnedMessage*)data; + } + uint32 innerLength() const; mtpTypeId type() const; void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons); @@ -5509,6 +5523,7 @@ private: explicit MTPupdate(MTPDupdateBotInlineQuery *_data); explicit MTPupdate(MTPDupdateBotInlineSend *_data); explicit MTPupdate(MTPDupdateEditChannelMessage *_data); + explicit MTPupdate(MTPDupdateChannelPinnedMessage *_data); friend MTPupdate MTP_updateNewMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count); friend MTPupdate MTP_updateMessageID(MTPint _id, const MTPlong &_random_id); @@ -5554,6 +5569,7 @@ private: friend MTPupdate MTP_updateBotInlineQuery(const MTPlong &_query_id, MTPint _user_id, const MTPstring &_query, const MTPstring &_offset); friend MTPupdate MTP_updateBotInlineSend(MTPint _user_id, const MTPstring &_query, const MTPstring &_id); friend MTPupdate MTP_updateEditChannelMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count); + friend MTPupdate MTP_updateChannelPinnedMessage(MTPint _channel_id, MTPint _id); mtpTypeId _type; }; @@ -7776,39 +7792,32 @@ typedef MTPBoxed MTPBotCommand; class MTPbotInfo : private mtpDataOwner { public: - MTPbotInfo() : mtpDataOwner(0), _type(0) { - } - MTPbotInfo(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) : mtpDataOwner(0), _type(0) { + MTPbotInfo(); + MTPbotInfo(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_botInfo) : mtpDataOwner(0) { read(from, end, cons); } MTPDbotInfo &_botInfo() { if (!data) throw mtpErrorUninitialized(); - if (_type != mtpc_botInfo) throw mtpErrorWrongTypeId(_type, mtpc_botInfo); split(); return *(MTPDbotInfo*)data; } const MTPDbotInfo &c_botInfo() const { if (!data) throw mtpErrorUninitialized(); - if (_type != mtpc_botInfo) throw mtpErrorWrongTypeId(_type, mtpc_botInfo); return *(const MTPDbotInfo*)data; } uint32 innerLength() const; mtpTypeId type() const; - void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons); + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_botInfo); void write(mtpBuffer &to) const; typedef void ResponseType; private: - explicit MTPbotInfo(mtpTypeId type); explicit MTPbotInfo(MTPDbotInfo *_data); - friend MTPbotInfo MTP_botInfoEmpty(); - friend MTPbotInfo MTP_botInfo(MTPint _user_id, MTPint _version, const MTPstring &_share_text, const MTPstring &_description, const MTPVector &_commands); - - mtpTypeId _type; + friend MTPbotInfo MTP_botInfo(MTPint _user_id, const MTPstring &_description, const MTPVector &_commands); }; typedef MTPBoxed MTPBotInfo; @@ -10005,7 +10014,7 @@ class MTPDchannelFull : public mtpDataImpl { public: MTPDchannelFull() { } - MTPDchannelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id) : vflags(_flags), vid(_id), vabout(_about), vparticipants_count(_participants_count), vadmins_count(_admins_count), vkicked_count(_kicked_count), vread_inbox_max_id(_read_inbox_max_id), vunread_count(_unread_count), vunread_important_count(_unread_important_count), vchat_photo(_chat_photo), vnotify_settings(_notify_settings), vexported_invite(_exported_invite), vbot_info(_bot_info), vmigrated_from_chat_id(_migrated_from_chat_id), vmigrated_from_max_id(_migrated_from_max_id) { + MTPDchannelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id, MTPint _pinned_msg_id) : vflags(_flags), vid(_id), vabout(_about), vparticipants_count(_participants_count), vadmins_count(_admins_count), vkicked_count(_kicked_count), vread_inbox_max_id(_read_inbox_max_id), vunread_count(_unread_count), vunread_important_count(_unread_important_count), vchat_photo(_chat_photo), vnotify_settings(_notify_settings), vexported_invite(_exported_invite), vbot_info(_bot_info), vmigrated_from_chat_id(_migrated_from_chat_id), vmigrated_from_max_id(_migrated_from_max_id), vpinned_msg_id(_pinned_msg_id) { } MTPint vflags; @@ -10023,6 +10032,7 @@ public: MTPVector vbot_info; MTPint vmigrated_from_chat_id; MTPint vmigrated_from_max_id; + MTPint vpinned_msg_id; enum { flag_can_view_participants = (1 << 3), @@ -10031,6 +10041,7 @@ public: flag_kicked_count = (1 << 2), flag_migrated_from_chat_id = (1 << 4), flag_migrated_from_max_id = (1 << 4), + flag_pinned_msg_id = (1 << 5), }; bool is_can_view_participants() const { return vflags.v & flag_can_view_participants; } @@ -10039,6 +10050,7 @@ public: bool has_kicked_count() const { return vflags.v & flag_kicked_count; } bool has_migrated_from_chat_id() const { return vflags.v & flag_migrated_from_chat_id; } bool has_migrated_from_max_id() const { return vflags.v & flag_migrated_from_max_id; } + bool has_pinned_msg_id() const { return vflags.v & flag_pinned_msg_id; } }; class MTPDchatParticipant : public mtpDataImpl { @@ -10627,15 +10639,28 @@ class MTPDuserFull : public mtpDataImpl { public: MTPDuserFull() { } - MTPDuserFull(const MTPUser &_user, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, MTPBool _blocked, const MTPBotInfo &_bot_info) : vuser(_user), vlink(_link), vprofile_photo(_profile_photo), vnotify_settings(_notify_settings), vblocked(_blocked), vbot_info(_bot_info) { + MTPDuserFull(MTPint _flags, const MTPUser &_user, const MTPstring &_about, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, const MTPBotInfo &_bot_info) : vflags(_flags), vuser(_user), vabout(_about), vlink(_link), vprofile_photo(_profile_photo), vnotify_settings(_notify_settings), vbot_info(_bot_info) { } + MTPint vflags; MTPUser vuser; + MTPstring vabout; MTPcontacts_Link vlink; MTPPhoto vprofile_photo; MTPPeerNotifySettings vnotify_settings; - MTPBool vblocked; MTPBotInfo vbot_info; + + enum { + flag_blocked = (1 << 0), + flag_about = (1 << 1), + flag_profile_photo = (1 << 2), + flag_bot_info = (1 << 3), + }; + + bool is_blocked() const { return vflags.v & flag_blocked; } + bool has_about() const { return vflags.v & flag_about; } + bool has_profile_photo() const { return vflags.v & flag_profile_photo; } + bool has_bot_info() const { return vflags.v & flag_bot_info; } }; class MTPDcontact : public mtpDataImpl { @@ -11337,6 +11362,17 @@ public: MTPint vpts_count; }; +class MTPDupdateChannelPinnedMessage : public mtpDataImpl { +public: + MTPDupdateChannelPinnedMessage() { + } + MTPDupdateChannelPinnedMessage(MTPint _channel_id, MTPint _id) : vchannel_id(_channel_id), vid(_id) { + } + + MTPint vchannel_id; + MTPint vid; +}; + class MTPDupdates_state : public mtpDataImpl { public: MTPDupdates_state() { @@ -12488,12 +12524,10 @@ class MTPDbotInfo : public mtpDataImpl { public: MTPDbotInfo() { } - MTPDbotInfo(MTPint _user_id, MTPint _version, const MTPstring &_share_text, const MTPstring &_description, const MTPVector &_commands) : vuser_id(_user_id), vversion(_version), vshare_text(_share_text), vdescription(_description), vcommands(_commands) { + MTPDbotInfo(MTPint _user_id, const MTPstring &_description, const MTPVector &_commands) : vuser_id(_user_id), vdescription(_description), vcommands(_commands) { } MTPint vuser_id; - MTPint vversion; - MTPstring vshare_text; MTPstring vdescription; MTPVector vcommands; }; @@ -14721,30 +14755,46 @@ public: class MTPaccount_updateProfile { // RPC method 'account.updateProfile' public: + MTPint vflags; MTPstring vfirst_name; MTPstring vlast_name; + MTPstring vabout; MTPaccount_updateProfile() { } MTPaccount_updateProfile(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_account_updateProfile) { read(from, end, cons); } - MTPaccount_updateProfile(const MTPstring &_first_name, const MTPstring &_last_name) : vfirst_name(_first_name), vlast_name(_last_name) { + MTPaccount_updateProfile(MTPint _flags, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_about) : vflags(_flags), vfirst_name(_first_name), vlast_name(_last_name), vabout(_about) { } + enum { + flag_first_name = (1 << 0), + flag_last_name = (1 << 1), + flag_about = (1 << 2), + }; + + bool has_first_name() const { return vflags.v & flag_first_name; } + bool has_last_name() const { return vflags.v & flag_last_name; } + bool has_about() const { return vflags.v & flag_about; } + uint32 innerLength() const { - return vfirst_name.innerLength() + vlast_name.innerLength(); + return vflags.innerLength() + (has_first_name() ? vfirst_name.innerLength() : 0) + (has_last_name() ? vlast_name.innerLength() : 0) + (has_about() ? vabout.innerLength() : 0); } mtpTypeId type() const { return mtpc_account_updateProfile; } void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_account_updateProfile) { - vfirst_name.read(from, end); - vlast_name.read(from, end); + vflags.read(from, end); + if (has_first_name()) { vfirst_name.read(from, end); } else { vfirst_name = MTPstring(); } + if (has_last_name()) { vlast_name.read(from, end); } else { vlast_name = MTPstring(); } + if (has_about()) { vabout.read(from, end); } else { vabout = MTPstring(); } } void write(mtpBuffer &to) const { - vfirst_name.write(to); - vlast_name.write(to); + vflags.write(to); + if (has_first_name()) vfirst_name.write(to); + if (has_last_name()) vlast_name.write(to); + if (has_about()) vabout.write(to); } typedef MTPUser ResponseType; @@ -14757,7 +14807,7 @@ public: } MTPaccount_UpdateProfile(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed(from, end, cons) { } - MTPaccount_UpdateProfile(const MTPstring &_first_name, const MTPstring &_last_name) : MTPBoxed(MTPaccount_updateProfile(_first_name, _last_name)) { + MTPaccount_UpdateProfile(MTPint _flags, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_about) : MTPBoxed(MTPaccount_updateProfile(_flags, _first_name, _last_name, _about)) { } }; @@ -20551,6 +20601,48 @@ public: } }; +class MTPchannels_updatePinnedMessage { // RPC method 'channels.updatePinnedMessage' +public: + MTPInputChannel vchannel; + MTPint vid; + + MTPchannels_updatePinnedMessage() { + } + MTPchannels_updatePinnedMessage(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_channels_updatePinnedMessage) { + read(from, end, cons); + } + MTPchannels_updatePinnedMessage(const MTPInputChannel &_channel, MTPint _id) : vchannel(_channel), vid(_id) { + } + + uint32 innerLength() const { + return vchannel.innerLength() + vid.innerLength(); + } + mtpTypeId type() const { + return mtpc_channels_updatePinnedMessage; + } + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_channels_updatePinnedMessage) { + vchannel.read(from, end); + vid.read(from, end); + } + void write(mtpBuffer &to) const { + vchannel.write(to); + vid.write(to); + } + + typedef MTPUpdates ResponseType; +}; +class MTPchannels_UpdatePinnedMessage : public MTPBoxed { +public: + MTPchannels_UpdatePinnedMessage() { + } + MTPchannels_UpdatePinnedMessage(const MTPchannels_updatePinnedMessage &v) : MTPBoxed(v) { + } + MTPchannels_UpdatePinnedMessage(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed(from, end, cons) { + } + MTPchannels_UpdatePinnedMessage(const MTPInputChannel &_channel, MTPint _id) : MTPBoxed(MTPchannels_updatePinnedMessage(_channel, _id)) { + } +}; + // Inline methods definition inline MTPresPQ::MTPresPQ() : mtpDataOwner(new MTPDresPQ()) { @@ -22990,7 +23082,7 @@ inline uint32 MTPchatFull::innerLength() const { } case mtpc_channelFull: { const MTPDchannelFull &v(c_channelFull()); - return v.vflags.innerLength() + v.vid.innerLength() + v.vabout.innerLength() + (v.has_participants_count() ? v.vparticipants_count.innerLength() : 0) + (v.has_admins_count() ? v.vadmins_count.innerLength() : 0) + (v.has_kicked_count() ? v.vkicked_count.innerLength() : 0) + v.vread_inbox_max_id.innerLength() + v.vunread_count.innerLength() + v.vunread_important_count.innerLength() + v.vchat_photo.innerLength() + v.vnotify_settings.innerLength() + v.vexported_invite.innerLength() + v.vbot_info.innerLength() + (v.has_migrated_from_chat_id() ? v.vmigrated_from_chat_id.innerLength() : 0) + (v.has_migrated_from_max_id() ? v.vmigrated_from_max_id.innerLength() : 0); + return v.vflags.innerLength() + v.vid.innerLength() + v.vabout.innerLength() + (v.has_participants_count() ? v.vparticipants_count.innerLength() : 0) + (v.has_admins_count() ? v.vadmins_count.innerLength() : 0) + (v.has_kicked_count() ? v.vkicked_count.innerLength() : 0) + v.vread_inbox_max_id.innerLength() + v.vunread_count.innerLength() + v.vunread_important_count.innerLength() + v.vchat_photo.innerLength() + v.vnotify_settings.innerLength() + v.vexported_invite.innerLength() + v.vbot_info.innerLength() + (v.has_migrated_from_chat_id() ? v.vmigrated_from_chat_id.innerLength() : 0) + (v.has_migrated_from_max_id() ? v.vmigrated_from_max_id.innerLength() : 0) + (v.has_pinned_msg_id() ? v.vpinned_msg_id.innerLength() : 0); } } return 0; @@ -23030,6 +23122,7 @@ inline void MTPchatFull::read(const mtpPrime *&from, const mtpPrime *end, mtpTyp v.vbot_info.read(from, end); if (v.has_migrated_from_chat_id()) { v.vmigrated_from_chat_id.read(from, end); } else { v.vmigrated_from_chat_id = MTPint(); } if (v.has_migrated_from_max_id()) { v.vmigrated_from_max_id.read(from, end); } else { v.vmigrated_from_max_id = MTPint(); } + if (v.has_pinned_msg_id()) { v.vpinned_msg_id.read(from, end); } else { v.vpinned_msg_id = MTPint(); } } break; default: throw mtpErrorUnexpected(cons, "MTPchatFull"); } @@ -23062,6 +23155,7 @@ inline void MTPchatFull::write(mtpBuffer &to) const { v.vbot_info.write(to); if (v.has_migrated_from_chat_id()) v.vmigrated_from_chat_id.write(to); if (v.has_migrated_from_max_id()) v.vmigrated_from_max_id.write(to); + if (v.has_pinned_msg_id()) v.vpinned_msg_id.write(to); } break; } } @@ -23079,8 +23173,8 @@ inline MTPchatFull::MTPchatFull(MTPDchannelFull *_data) : mtpDataOwner(_data), _ inline MTPchatFull MTP_chatFull(MTPint _id, const MTPChatParticipants &_participants, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info) { return MTPchatFull(new MTPDchatFull(_id, _participants, _chat_photo, _notify_settings, _exported_invite, _bot_info)); } -inline MTPchatFull MTP_channelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id) { - return MTPchatFull(new MTPDchannelFull(_flags, _id, _about, _participants_count, _admins_count, _kicked_count, _read_inbox_max_id, _unread_count, _unread_important_count, _chat_photo, _notify_settings, _exported_invite, _bot_info, _migrated_from_chat_id, _migrated_from_max_id)); +inline MTPchatFull MTP_channelFull(MTPint _flags, MTPint _id, const MTPstring &_about, MTPint _participants_count, MTPint _admins_count, MTPint _kicked_count, MTPint _read_inbox_max_id, MTPint _unread_count, MTPint _unread_important_count, const MTPPhoto &_chat_photo, const MTPPeerNotifySettings &_notify_settings, const MTPExportedChatInvite &_exported_invite, const MTPVector &_bot_info, MTPint _migrated_from_chat_id, MTPint _migrated_from_max_id, MTPint _pinned_msg_id) { + return MTPchatFull(new MTPDchannelFull(_flags, _id, _about, _participants_count, _admins_count, _kicked_count, _read_inbox_max_id, _unread_count, _unread_important_count, _chat_photo, _notify_settings, _exported_invite, _bot_info, _migrated_from_chat_id, _migrated_from_max_id, _pinned_msg_id)); } inline uint32 MTPchatParticipant::innerLength() const { @@ -24597,7 +24691,7 @@ inline MTPuserFull::MTPuserFull() : mtpDataOwner(new MTPDuserFull()) { inline uint32 MTPuserFull::innerLength() const { const MTPDuserFull &v(c_userFull()); - return v.vuser.innerLength() + v.vlink.innerLength() + v.vprofile_photo.innerLength() + v.vnotify_settings.innerLength() + v.vblocked.innerLength() + v.vbot_info.innerLength(); + return v.vflags.innerLength() + v.vuser.innerLength() + (v.has_about() ? v.vabout.innerLength() : 0) + v.vlink.innerLength() + (v.has_profile_photo() ? v.vprofile_photo.innerLength() : 0) + v.vnotify_settings.innerLength() + (v.has_bot_info() ? v.vbot_info.innerLength() : 0); } inline mtpTypeId MTPuserFull::type() const { return mtpc_userFull; @@ -24607,26 +24701,28 @@ inline void MTPuserFull::read(const mtpPrime *&from, const mtpPrime *end, mtpTyp if (!data) setData(new MTPDuserFull()); MTPDuserFull &v(_userFull()); + v.vflags.read(from, end); v.vuser.read(from, end); + if (v.has_about()) { v.vabout.read(from, end); } else { v.vabout = MTPstring(); } v.vlink.read(from, end); - v.vprofile_photo.read(from, end); + if (v.has_profile_photo()) { v.vprofile_photo.read(from, end); } else { v.vprofile_photo = MTPPhoto(); } v.vnotify_settings.read(from, end); - v.vblocked.read(from, end); - v.vbot_info.read(from, end); + if (v.has_bot_info()) { v.vbot_info.read(from, end); } else { v.vbot_info = MTPBotInfo(); } } inline void MTPuserFull::write(mtpBuffer &to) const { const MTPDuserFull &v(c_userFull()); + v.vflags.write(to); v.vuser.write(to); + if (v.has_about()) v.vabout.write(to); v.vlink.write(to); - v.vprofile_photo.write(to); + if (v.has_profile_photo()) v.vprofile_photo.write(to); v.vnotify_settings.write(to); - v.vblocked.write(to); - v.vbot_info.write(to); + if (v.has_bot_info()) v.vbot_info.write(to); } inline MTPuserFull::MTPuserFull(MTPDuserFull *_data) : mtpDataOwner(_data) { } -inline MTPuserFull MTP_userFull(const MTPUser &_user, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, MTPBool _blocked, const MTPBotInfo &_bot_info) { - return MTPuserFull(new MTPDuserFull(_user, _link, _profile_photo, _notify_settings, _blocked, _bot_info)); +inline MTPuserFull MTP_userFull(MTPint _flags, const MTPUser &_user, const MTPstring &_about, const MTPcontacts_Link &_link, const MTPPhoto &_profile_photo, const MTPPeerNotifySettings &_notify_settings, const MTPBotInfo &_bot_info) { + return MTPuserFull(new MTPDuserFull(_flags, _user, _about, _link, _profile_photo, _notify_settings, _bot_info)); } inline MTPcontact::MTPcontact() : mtpDataOwner(new MTPDcontact()) { @@ -25439,6 +25535,10 @@ inline uint32 MTPupdate::innerLength() const { const MTPDupdateEditChannelMessage &v(c_updateEditChannelMessage()); return v.vmessage.innerLength() + v.vpts.innerLength() + v.vpts_count.innerLength(); } + case mtpc_updateChannelPinnedMessage: { + const MTPDupdateChannelPinnedMessage &v(c_updateChannelPinnedMessage()); + return v.vchannel_id.innerLength() + v.vid.innerLength(); + } } return 0; } @@ -25730,6 +25830,12 @@ inline void MTPupdate::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeI v.vpts.read(from, end); v.vpts_count.read(from, end); } break; + case mtpc_updateChannelPinnedMessage: _type = cons; { + if (!data) setData(new MTPDupdateChannelPinnedMessage()); + MTPDupdateChannelPinnedMessage &v(_updateChannelPinnedMessage()); + v.vchannel_id.read(from, end); + v.vid.read(from, end); + } break; default: throw mtpErrorUnexpected(cons, "MTPupdate"); } } @@ -25972,6 +26078,11 @@ inline void MTPupdate::write(mtpBuffer &to) const { v.vpts.write(to); v.vpts_count.write(to); } break; + case mtpc_updateChannelPinnedMessage: { + const MTPDupdateChannelPinnedMessage &v(c_updateChannelPinnedMessage()); + v.vchannel_id.write(to); + v.vid.write(to); + } break; } } inline MTPupdate::MTPupdate(mtpTypeId type) : mtpDataOwner(0), _type(type) { @@ -26020,6 +26131,7 @@ inline MTPupdate::MTPupdate(mtpTypeId type) : mtpDataOwner(0), _type(type) { case mtpc_updateBotInlineQuery: setData(new MTPDupdateBotInlineQuery()); break; case mtpc_updateBotInlineSend: setData(new MTPDupdateBotInlineSend()); break; case mtpc_updateEditChannelMessage: setData(new MTPDupdateEditChannelMessage()); break; + case mtpc_updateChannelPinnedMessage: setData(new MTPDupdateChannelPinnedMessage()); break; default: throw mtpErrorBadTypeId(type, "MTPupdate"); } } @@ -26107,6 +26219,8 @@ inline MTPupdate::MTPupdate(MTPDupdateBotInlineSend *_data) : mtpDataOwner(_data } inline MTPupdate::MTPupdate(MTPDupdateEditChannelMessage *_data) : mtpDataOwner(_data), _type(mtpc_updateEditChannelMessage) { } +inline MTPupdate::MTPupdate(MTPDupdateChannelPinnedMessage *_data) : mtpDataOwner(_data), _type(mtpc_updateChannelPinnedMessage) { +} inline MTPupdate MTP_updateNewMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count) { return MTPupdate(new MTPDupdateNewMessage(_message, _pts, _pts_count)); } @@ -26239,6 +26353,9 @@ inline MTPupdate MTP_updateBotInlineSend(MTPint _user_id, const MTPstring &_quer inline MTPupdate MTP_updateEditChannelMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count) { return MTPupdate(new MTPDupdateEditChannelMessage(_message, _pts, _pts_count)); } +inline MTPupdate MTP_updateChannelPinnedMessage(MTPint _channel_id, MTPint _id) { + return MTPupdate(new MTPDupdateChannelPinnedMessage(_channel_id, _id)); +} inline MTPupdates_state::MTPupdates_state() : mtpDataOwner(new MTPDupdates_state()) { } @@ -29214,61 +29331,35 @@ inline MTPbotCommand MTP_botCommand(const MTPstring &_command, const MTPstring & return MTPbotCommand(new MTPDbotCommand(_command, _description)); } +inline MTPbotInfo::MTPbotInfo() : mtpDataOwner(new MTPDbotInfo()) { +} + inline uint32 MTPbotInfo::innerLength() const { - switch (_type) { - case mtpc_botInfo: { - const MTPDbotInfo &v(c_botInfo()); - return v.vuser_id.innerLength() + v.vversion.innerLength() + v.vshare_text.innerLength() + v.vdescription.innerLength() + v.vcommands.innerLength(); - } - } - return 0; + const MTPDbotInfo &v(c_botInfo()); + return v.vuser_id.innerLength() + v.vdescription.innerLength() + v.vcommands.innerLength(); } inline mtpTypeId MTPbotInfo::type() const { - if (!_type) throw mtpErrorUninitialized(); - return _type; + return mtpc_botInfo; } inline void MTPbotInfo::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) { - if (cons != _type) setData(0); - switch (cons) { - case mtpc_botInfoEmpty: _type = cons; break; - case mtpc_botInfo: _type = cons; { - if (!data) setData(new MTPDbotInfo()); - MTPDbotInfo &v(_botInfo()); - v.vuser_id.read(from, end); - v.vversion.read(from, end); - v.vshare_text.read(from, end); - v.vdescription.read(from, end); - v.vcommands.read(from, end); - } break; - default: throw mtpErrorUnexpected(cons, "MTPbotInfo"); - } + if (cons != mtpc_botInfo) throw mtpErrorUnexpected(cons, "MTPbotInfo"); + + if (!data) setData(new MTPDbotInfo()); + MTPDbotInfo &v(_botInfo()); + v.vuser_id.read(from, end); + v.vdescription.read(from, end); + v.vcommands.read(from, end); } inline void MTPbotInfo::write(mtpBuffer &to) const { - switch (_type) { - case mtpc_botInfo: { - const MTPDbotInfo &v(c_botInfo()); - v.vuser_id.write(to); - v.vversion.write(to); - v.vshare_text.write(to); - v.vdescription.write(to); - v.vcommands.write(to); - } break; - } + const MTPDbotInfo &v(c_botInfo()); + v.vuser_id.write(to); + v.vdescription.write(to); + v.vcommands.write(to); } -inline MTPbotInfo::MTPbotInfo(mtpTypeId type) : mtpDataOwner(0), _type(type) { - switch (type) { - case mtpc_botInfoEmpty: break; - case mtpc_botInfo: setData(new MTPDbotInfo()); break; - default: throw mtpErrorBadTypeId(type, "MTPbotInfo"); - } +inline MTPbotInfo::MTPbotInfo(MTPDbotInfo *_data) : mtpDataOwner(_data) { } -inline MTPbotInfo::MTPbotInfo(MTPDbotInfo *_data) : mtpDataOwner(_data), _type(mtpc_botInfo) { -} -inline MTPbotInfo MTP_botInfoEmpty() { - return MTPbotInfo(mtpc_botInfoEmpty); -} -inline MTPbotInfo MTP_botInfo(MTPint _user_id, MTPint _version, const MTPstring &_share_text, const MTPstring &_description, const MTPVector &_commands) { - return MTPbotInfo(new MTPDbotInfo(_user_id, _version, _share_text, _description, _commands)); +inline MTPbotInfo MTP_botInfo(MTPint _user_id, const MTPstring &_description, const MTPVector &_commands) { + return MTPbotInfo(new MTPDbotInfo(_user_id, _description, _commands)); } inline MTPkeyboardButton::MTPkeyboardButton() : mtpDataOwner(new MTPDkeyboardButton()) { diff --git a/Telegram/SourceFiles/mtproto/scheme.tl b/Telegram/SourceFiles/mtproto/scheme.tl index 8e4b7bf2f..876080a4b 100644 --- a/Telegram/SourceFiles/mtproto/scheme.tl +++ b/Telegram/SourceFiles/mtproto/scheme.tl @@ -213,7 +213,7 @@ channel#4b1b7506 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?t channelForbidden#2d85832c id:int access_hash:long title:string = Chat; chatFull#2e02a614 id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector = ChatFull; -channelFull#9e341ddf flags:# can_view_participants:flags.3?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int read_inbox_max_id:int unread_count:int unread_important_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int = ChatFull; +channelFull#97bee562 flags:# can_view_participants:flags.3?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int read_inbox_max_id:int unread_count:int unread_important_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -296,7 +296,7 @@ inputReportReasonViolence#1e22c78d = ReportReason; inputReportReasonPornography#2e59d922 = ReportReason; inputReportReasonOther#e1746d0a text:string = ReportReason; -userFull#5a89ac5b user:User link:contacts.Link profile_photo:Photo notify_settings:PeerNotifySettings blocked:Bool bot_info:BotInfo = UserFull; +userFull#5932fc03 flags:# blocked:flags.0?true user:User about:flags.1?string link:contacts.Link profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo = UserFull; contact#f911c994 user_id:int mutual:Bool = Contact; @@ -384,6 +384,7 @@ updateSavedGifs#9375341e = Update; updateBotInlineQuery#c01eea08 query_id:long user_id:int query:string offset:string = Update; updateBotInlineSend#f69e113 user_id:int query:string id:string = Update; updateEditChannelMessage#1b3f4df7 message:Message pts:int pts_count:int = Update; +updateChannelPinnedMessage#98592475 channel_id:int id:int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -553,8 +554,7 @@ messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents: botCommand#c27ac8c7 command:string description:string = BotCommand; -botInfoEmpty#bb2e37ce = BotInfo; -botInfo#9cf585d user_id:int version:int share_text:string description:string commands:Vector = BotInfo; +botInfo#98e81d3a user_id:int description:string commands:Vector = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -676,7 +676,7 @@ account.unregisterDevice#65c55b40 token_type:int token:string = Bool; account.updateNotifySettings#84be5b93 peer:InputNotifyPeer settings:InputPeerNotifySettings = Bool; account.getNotifySettings#12b3ad31 peer:InputNotifyPeer = PeerNotifySettings; account.resetNotifySettings#db7e1747 = Bool; -account.updateProfile#f0888d68 first_name:string last_name:string = User; +account.updateProfile#78515775 flags:# first_name:flags.0?string last_name:flags.1?string about:flags.2?string = User; account.updateStatus#6628562c offline:Bool = Bool; account.getWallPapers#c04cfac2 = Vector; account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool; @@ -821,3 +821,4 @@ channels.exportMessageLink#c846d22d channel:InputChannel id:int = ExportedMessag channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; channels.getMessageEditData#27ea3a28 channel:InputChannel id:int = channels.MessageEditData; channels.editMessage#dcda80ed flags:# no_webpage:flags.1?true channel:InputChannel id:int message:string entities:flags.3?Vector = Updates; +channels.updatePinnedMessage#84a41867 channel:InputChannel id:int = Updates; diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index 1f36133c1..ccc1f4a52 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -102,7 +102,8 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, PeerData , _kickDown(0) , _kickConfirm(0) -, _menu(0) { +, _menu(0) +, _updateDelayed(false) { connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update())); connect(App::api(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*))); @@ -187,9 +188,9 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, PeerData connect(App::main(), SIGNAL(peerNameChanged(PeerData *, const PeerData::Names &, const PeerData::NameFirstChars &)), this, SLOT(peerUpdated(PeerData *))); // about - if (_peerUser && _peerUser->botInfo) { - if (!_peerUser->botInfo->shareText.isEmpty()) { - _about.setText(st::linkFont, _peerUser->botInfo->shareText, _historyBotNoMonoOptions); + if (_peerUser) { + if (!_peerUser->about.isEmpty()) { + _about.setText(st::linkFont, _peerUser->about, _peerUser->botInfo ? _historyBotNoMonoOptions : _historyTextNoMonoOptions); } updateBotLinksVisibility(); } else { @@ -526,11 +527,11 @@ void ProfileInner::onFullPeerUpdated(PeerData *peer) { } else { _photoLink = TextLinkPtr(); } - if (_peerUser->botInfo) { - if (_peerUser->botInfo->shareText.isEmpty()) { + if (_peerUser) { + if (_peerUser->about.isEmpty()) { _about = Text(st::wndMinWidth - st::profilePadding.left() - st::profilePadding.right()); } else { - _about.setText(st::linkFont, _peerUser->botInfo->shareText, _historyBotNoMonoOptions); + _about.setText(st::linkFont, _peerUser->about, _peerUser->botInfo ? _historyBotNoMonoOptions : _historyTextNoMonoOptions); } updateBotLinksVisibility(); resizeEvent(0); @@ -613,11 +614,17 @@ void ProfileInner::peerUpdated(PeerData *data) { _nameCache = _peer->name; _nameText.setText(st::profileNameFont, _nameCache, _textNameOptions); } - showAll(); - resizeEvent(0); - } else { - showAll(); } + if (!_updateDelayed) { + _updateDelayed = true; + QMetaObject::invokeMethod(this, "onUpdateDelayed", Qt::QueuedConnection); + } +} + +void ProfileInner::onUpdateDelayed() { + _updateDelayed = false; + showAll(); + resizeEvent(0); update(); } @@ -688,34 +695,76 @@ void ProfileInner::reorderParticipants() { } loadProfilePhotos(_lastPreload); } else if (_peerChannel && _peerChannel->isMegagroup() && _peerChannel->amIn() && !_peerChannel->mgInfo->lastParticipants.isEmpty()) { - bool needAdmins = _peerChannel->amEditor(), adminsOutdated = (_peerChannel->mgInfo->lastParticipantsStatus & MegagroupInfo::LastParticipantsAdminsOutdated); + bool needAdmins = true, adminsOutdated = (_peerChannel->mgInfo->lastParticipantsStatus & MegagroupInfo::LastParticipantsAdminsOutdated); + bool orderByOnline = true;// (_peerChannel->count > 0) && (_peerChannel->count <= Global::ChatSizeMax()); + + _onlineText.clear(); if (_peerChannel->mgInfo->lastParticipants.isEmpty() || (needAdmins && adminsOutdated) || _peerChannel->lastParticipantsCountOutdated()) { if (App::api()) App::api()->requestLastParticipants(_peerChannel); } else if (!_peerChannel->mgInfo->lastParticipants.isEmpty()) { const MegagroupInfo::LastParticipants &list(_peerChannel->mgInfo->lastParticipants); int32 s = list.size(); - for (int32 i = 0, l = _participants.size(); i < l; ++i) { - if (i >= s || _participants.at(i) != list.at(i)) { - if (_participantsData.at(i)) { - delete _participantsData.at(i); - _participantsData[i] = 0; - } - if (i < s) { - _participants[i] = list.at(i); + if (orderByOnline) { + _participants.clear(); + for (ParticipantsData::iterator i = _participantsData.begin(), e = _participantsData.end(); i != e; ++i) { + if (*i) { + delete *i; + *i = 0; } } - } - if (_participants.size() > s) { - _participants.resize(s); - } else { _participants.reserve(s); - for (int32 i = _participants.size(); i < s; ++i) { - _participants.push_back(list.at(i)); + + UserData *self = App::self(); + bool onlyMe = true; + for (int32 i = 0; i < s; ++i) { + UserData *user = list.at(i); + int32 until = App::onlineForSort(user, t); + Participants::iterator before = _participants.begin(); + if (user != self) { + if (before != _participants.end() && (*before) == self) { + ++before; + } + while (before != _participants.end() && App::onlineForSort(*before, t) >= until) { + ++before; + } + if (until > t && onlyMe) onlyMe = false; + } + _participants.insert(before, user); + if (until > t) { + ++onlineCount; + } + } + if (onlineCount && !onlyMe) { + _onlineText = lng_chat_status_members_online(lt_count, _peerChannel->count, lt_count_online, onlineCount); + } else { + _onlineText = lng_chat_status_members(lt_count, _peerChannel->count); + } + } else { + for (int32 i = 0, l = _participants.size(); i < l; ++i) { + if (i >= s || _participants.at(i) != list.at(i)) { + if (_participantsData.at(i)) { + delete _participantsData.at(i); + _participantsData[i] = 0; + } + if (i < s) { + _participants[i] = list.at(i); + } + } + } + if (_participants.size() > s) { + _participants.resize(s); + } else { + _participants.reserve(s); + for (int32 i = _participants.size(); i < s; ++i) { + _participants.push_back(list.at(i)); + } } } _participantsData.resize(s); } - _onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(_peerChannel->isMegagroup() ? lng_group_status : lng_channel_status); + if (_onlineText.isEmpty()) { + _onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(_peerChannel->isMegagroup() ? lng_group_status : lng_channel_status); + } loadProfilePhotos(_lastPreload); } else { _participants.clear(); diff --git a/Telegram/SourceFiles/profilewidget.h b/Telegram/SourceFiles/profilewidget.h index 46d741a7f..f512b442a 100644 --- a/Telegram/SourceFiles/profilewidget.h +++ b/Telegram/SourceFiles/profilewidget.h @@ -124,6 +124,8 @@ public slots: void onBotSettings(); void onBotHelp(); + void onUpdateDelayed(); + private: void showAll(); @@ -210,6 +212,8 @@ private: QString _secretText; + bool _updateDelayed; + void blockDone(bool blocked, const MTPBool &result); bool blockFail(const RPCError &error); diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 214622fcc..c2f991885 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -263,7 +263,6 @@ void UserData::setBotInfoVersion(int32 version) { Notify::botCommandsChanged(this); } botInfo->description.clear(); - botInfo->shareText.clear(); botInfo->version = version; botInfo->inited = false; } @@ -271,33 +270,15 @@ void UserData::setBotInfoVersion(int32 version) { void UserData::setBotInfo(const MTPBotInfo &info) { switch (info.type()) { - case mtpc_botInfoEmpty: - if (botInfo) { - if (!botInfo->commands.isEmpty()) { - botInfo->commands.clear(); - Notify::botCommandsChanged(this); - } - delete botInfo; - botInfo = 0; - Notify::userIsBotChanged(this); - } - break; case mtpc_botInfo: { const MTPDbotInfo &d(info.c_botInfo()); - if (peerFromUser(d.vuser_id.v) != id) return; - - if (botInfo) { - botInfo->version = d.vversion.v; - } else { - setBotInfoVersion(d.vversion.v); - } + if (peerFromUser(d.vuser_id.v) != id || !botInfo) return; QString desc = qs(d.vdescription); if (botInfo->description != desc) { botInfo->description = desc; botInfo->text = Text(st::msgMinWidth); } - botInfo->shareText = qs(d.vshare_text); const QVector &v(d.vcommands.c_vector().v); botInfo->commands.reserve(v.size()); diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index 86dd227bd..7d73b7c60 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -334,7 +334,7 @@ struct BotInfo { bool inited; bool readsAllHistory, cantJoinGroups; int32 version; - QString shareText, description, inlinePlaceholder; + QString description, inlinePlaceholder; QList commands; Text text; // description @@ -390,6 +390,8 @@ public: Photos photos; int32 photosCount; // -1 not loaded, 0 all loaded + QString about; + BotInfo *botInfo; }; static UserData * const InlineBotLookingUpData = SharedMemoryLocation(); @@ -530,11 +532,13 @@ private: }; struct MegagroupInfo { - MegagroupInfo() : botStatus(0) - , joinedMessageFound(false) - , lastParticipantsStatus(LastParticipantsUpToDate) - , lastParticipantsCount(0) - , migrateFromPtr(0) { + MegagroupInfo() + : botStatus(0) + , pinnedMsgId(0) + , joinedMessageFound(false) + , lastParticipantsStatus(LastParticipantsUpToDate) + , lastParticipantsCount(0) + , migrateFromPtr(0) { } typedef QList LastParticipants; LastParticipants lastParticipants; @@ -546,6 +550,7 @@ struct MegagroupInfo { Bots bots; int32 botStatus; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other + MsgId pinnedMsgId; bool joinedMessageFound; enum LastParticipantsStatus {