mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Divide data/data_peer and remove from PCH.
This commit is contained in:
parent
0ce4d66601
commit
c5a41e1f55
143 changed files with 2291 additions and 1899 deletions
|
@ -17,6 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_search_controller.h"
|
||||
#include "data/data_channel_admins.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "core/tl_help.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
|
@ -2604,7 +2607,7 @@ void ApiWrap::requestFileReference(
|
|||
|
||||
request(std::move(data)).done([=](const auto &result) {
|
||||
const auto parsed = Data::GetFileReferences(result);
|
||||
for (const auto &p : parsed) {
|
||||
for (const auto &p : parsed.data) {
|
||||
// Unpack here the parsed pair by hand to workaround a GCC bug.
|
||||
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87122
|
||||
const auto &origin = p.first;
|
||||
|
@ -2669,7 +2672,7 @@ void ApiWrap::refreshFileReference(
|
|||
const auto fail = [&] {
|
||||
handler(Data::UpdatedFileReferences());
|
||||
};
|
||||
origin.match([&](Data::FileOriginMessage data) {
|
||||
origin.data.match([&](Data::FileOriginMessage data) {
|
||||
if (const auto item = App::histItemById(data)) {
|
||||
if (const auto channel = item->history()->peer->asChannel()) {
|
||||
request(MTPchannels_GetMessages(
|
||||
|
|
|
@ -24,6 +24,10 @@ enum class SendMediaType;
|
|||
struct FileLoadTo;
|
||||
class mtpFileLoader;
|
||||
|
||||
namespace Data {
|
||||
struct UpdatedFileReferences;
|
||||
} // namespace Data
|
||||
|
||||
namespace InlineBots {
|
||||
class Result;
|
||||
} // namespace InlineBots
|
||||
|
@ -408,10 +412,6 @@ private:
|
|||
TimeMs received = 0;
|
||||
};
|
||||
|
||||
using SimpleFileLocationId = Data::SimpleFileLocationId;
|
||||
using DocumentFileLocationId = Data::DocumentFileLocationId;
|
||||
using FileLocationId = Data::FileLocationId;
|
||||
|
||||
void updatesReceived(const MTPUpdates &updates);
|
||||
void checkQuitPreventFinished();
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_boxes.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_abstract_structure.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_session.h"
|
||||
|
@ -700,6 +703,14 @@ namespace App {
|
|||
return Auth().data().historyLoaded(peer);
|
||||
}
|
||||
|
||||
not_null<History*> history(not_null<const PeerData*> peer) {
|
||||
return history(peer->id);
|
||||
}
|
||||
|
||||
History *historyLoaded(const PeerData *peer) {
|
||||
return peer ? historyLoaded(peer->id) : nullptr;
|
||||
}
|
||||
|
||||
HistoryItem *histItemById(ChannelId channelId, MsgId itemId) {
|
||||
if (!itemId) return nullptr;
|
||||
|
||||
|
@ -713,6 +724,10 @@ namespace App {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
HistoryItem *histItemById(const ChannelData *channel, MsgId itemId) {
|
||||
return histItemById(channel ? peerToChannel(channel->id) : 0, itemId);
|
||||
}
|
||||
|
||||
void historyRegItem(not_null<HistoryItem*> item) {
|
||||
const auto data = fetchMsgsData(item->channelId());
|
||||
const auto i = data->constFind(item->id);
|
||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "data/data_types.h"
|
||||
#include "data/data_peer.h"
|
||||
|
||||
enum NewMessageType : char;
|
||||
enum class ImageRoundRadius;
|
||||
|
@ -102,16 +101,11 @@ namespace App {
|
|||
[[nodiscard]] not_null<History*> history(PeerId peer);
|
||||
[[nodiscard]] History *historyLoaded(PeerId peer);
|
||||
[[nodiscard]] HistoryItem *histItemById(ChannelId channelId, MsgId itemId);
|
||||
[[nodiscard]] inline not_null<History*> history(const PeerData *peer) {
|
||||
Assert(peer != nullptr);
|
||||
return history(peer->id);
|
||||
}
|
||||
[[nodiscard]] inline History *historyLoaded(const PeerData *peer) {
|
||||
return peer ? historyLoaded(peer->id) : nullptr;
|
||||
}
|
||||
[[nodiscard]] inline HistoryItem *histItemById(const ChannelData *channel, MsgId itemId) {
|
||||
return histItemById(channel ? peerToChannel(channel->id) : 0, itemId);
|
||||
}
|
||||
[[nodiscard]] not_null<History*> history(not_null<const PeerData*> peer);
|
||||
[[nodiscard]] History *historyLoaded(const PeerData *peer);
|
||||
[[nodiscard]] HistoryItem *histItemById(
|
||||
const ChannelData *channel,
|
||||
MsgId itemId);
|
||||
[[nodiscard]] inline HistoryItem *histItemById(const FullMsgId &msgId) {
|
||||
return histItemById(msgId.channel, msgId.msg);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/storage_facade.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "platform/platform_specific.h"
|
||||
|
@ -438,6 +439,14 @@ base::Observable<void> &AuthSession::downloaderTaskFinished() {
|
|||
return downloader().taskFinished();
|
||||
}
|
||||
|
||||
UserId AuthSession::userId() const {
|
||||
return _user->bareId();
|
||||
}
|
||||
|
||||
PeerId AuthSession::userPeerId() const {
|
||||
return _user->id;
|
||||
}
|
||||
|
||||
bool AuthSession::validateSelf(const MTPUser &user) {
|
||||
if (user.type() != mtpc_user || !user.c_user().is_self()) {
|
||||
LOG(("API Error: bad self user received."));
|
||||
|
|
|
@ -282,12 +282,8 @@ public:
|
|||
|
||||
static bool Exists();
|
||||
|
||||
UserId userId() const {
|
||||
return _user->bareId();
|
||||
}
|
||||
PeerId userPeerId() const {
|
||||
return _user->id;
|
||||
}
|
||||
UserId userId() const;
|
||||
PeerId userPeerId() const;
|
||||
not_null<UserData*> user() const {
|
||||
return _user;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/toast/toast.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "apiwrap.h"
|
||||
|
|
|
@ -25,6 +25,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/click_handler_types.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "auth_session.h"
|
||||
#include "observer_peer.h"
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_media_types.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_user.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/event_filter.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
|
|
|
@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/special_buttons.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace {
|
||||
|
@ -446,6 +448,10 @@ void EditRestrictedBox::setRestrictUntil(TimeId until) {
|
|||
resizeToContent();
|
||||
}
|
||||
|
||||
bool EditRestrictedBox::isUntilForever() const {
|
||||
return ChannelData::IsRestrictedForever(_until);
|
||||
}
|
||||
|
||||
void EditRestrictedBox::clearVariants() {
|
||||
for (auto &&widget : base::take(_untilVariants)) {
|
||||
removeControl(widget.data());
|
||||
|
|
|
@ -112,9 +112,7 @@ private:
|
|||
void applyDependencies(QPointer<Ui::Checkbox> changed);
|
||||
void showRestrictUntil();
|
||||
void setRestrictUntil(TimeId until);
|
||||
bool isUntilForever() {
|
||||
return ChannelData::IsRestrictedForever(_until);
|
||||
}
|
||||
bool isUntilForever() const;
|
||||
void clearVariants();
|
||||
void createUntilGroup();
|
||||
void createUntilVariants();
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "apiwrap.h"
|
||||
#include "auth_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
|
|
|
@ -26,8 +26,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "observer_peer.h"
|
||||
#include "storage/file_download.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
|
||||
auto PaintUserpicCallback(
|
||||
not_null<PeerData*> peer,
|
||||
bool respectSavedMessagesChat)
|
||||
-> Fn<void(Painter &p, int x, int y, int outerWidth, int size)> {
|
||||
if (respectSavedMessagesChat && peer->isSelf()) {
|
||||
return [](Painter &p, int x, int y, int outerWidth, int size) {
|
||||
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
|
||||
};
|
||||
}
|
||||
return [=](Painter &p, int x, int y, int outerWidth, int size) {
|
||||
peer->paintUserpicLeft(p, x, y, outerWidth, size);
|
||||
};
|
||||
}
|
||||
|
||||
PeerListBox::PeerListBox(
|
||||
QWidget*,
|
||||
std::unique_ptr<PeerListController> controller,
|
||||
|
|
|
@ -34,19 +34,10 @@ namespace Notify {
|
|||
struct PeerUpdate;
|
||||
} // namespace Notify
|
||||
|
||||
inline auto PaintUserpicCallback(
|
||||
auto PaintUserpicCallback(
|
||||
not_null<PeerData*> peer,
|
||||
bool respectSavedMessagesChat)
|
||||
->Fn<void(Painter &p, int x, int y, int outerWidth, int size)> {
|
||||
if (respectSavedMessagesChat && peer->isSelf()) {
|
||||
return [](Painter &p, int x, int y, int outerWidth, int size) {
|
||||
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
|
||||
};
|
||||
}
|
||||
return [peer](Painter &p, int x, int y, int outerWidth, int size) {
|
||||
peer->paintUserpicLeft(p, x, y, outerWidth, size);
|
||||
};
|
||||
}
|
||||
-> Fn<void(Painter &p, int x, int y, int outerWidth, int size)>;
|
||||
|
||||
using PeerListRowId = uint64;
|
||||
class PeerListRow {
|
||||
|
|
|
@ -7,18 +7,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_profile.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "observer_peer.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "auth_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "apiwrap.h"
|
||||
#include "mainwidget.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "history/history.h"
|
||||
#include "dialogs/dialogs_indexed_list.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_profile.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/add_contact_box.h"
|
||||
#include "boxes/stickers_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/profile/info_profile_button.h"
|
||||
#include "info/profile/info_profile_icon.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
|
|
|
@ -8,14 +8,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/report_box.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_profile.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "mainwindow.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_profile.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/themes/window_theme.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "auth_session.h"
|
||||
#include "messenger.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwidget.h"
|
||||
#include "chat_helpers/stickers.h"
|
||||
|
|
|
@ -14,9 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "messenger.h"
|
||||
#include "auth_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/connection.h"
|
||||
#include "media/media_audio_track.h"
|
||||
#include "calls/calls_panel.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
#ifdef slots
|
||||
#undef slots
|
||||
|
|
|
@ -15,11 +15,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "calls/calls_call.h"
|
||||
#include "calls/calls_panel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "media/media_audio_track.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "mainwidget.h"
|
||||
|
||||
#include "boxes/rate_call_box.h"
|
||||
|
||||
namespace Calls {
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "calls/calls_emoji_fingerprint.h"
|
||||
#include "styles/style_calls.h"
|
||||
#include "styles/style_history.h"
|
||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "calls/calls_top_bar.h"
|
||||
|
||||
#include "styles/style_calls.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
|
@ -15,11 +14,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "calls/calls_call.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "calls/calls_panel.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "data/data_user.h"
|
||||
#include "observer_peer.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "base/timer.h"
|
||||
#include "layout.h"
|
||||
#include "styles/style_calls.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace Calls {
|
||||
namespace {
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "history/history.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
|
|
|
@ -8,17 +8,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/field_autocomplete.h"
|
||||
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "mainwindow.h"
|
||||
#include "apiwrap.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "auth_session.h"
|
||||
#include "chat_helpers/stickers.h"
|
||||
#include "styles/style_history.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "auth_session.h"
|
||||
#include "chat_helpers/stickers.h"
|
||||
|
||||
FieldAutocomplete::FieldAutocomplete(QWidget *parent) : TWidget(parent)
|
||||
, _scroll(this, st::mentionScroll) {
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/abstract_box.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/image/image.h"
|
||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "observer_peer.h"
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/localstorage.h"
|
||||
#include "ui/widgets/tooltip.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
474
Telegram/SourceFiles/data/data_channel.cpp
Normal file
474
Telegram/SourceFiles/data/data_channel.cpp
Normal file
|
@ -0,0 +1,474 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_channel.h"
|
||||
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_channel_admins.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "observer_peer.h"
|
||||
#include "auth_session.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
} // namespace
|
||||
|
||||
ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
|
||||
: PeerData(owner, id)
|
||||
, inputChannel(MTP_inputChannel(MTP_int(bareId()), MTP_long(0))) {
|
||||
Data::PeerFlagValue(
|
||||
this,
|
||||
MTPDchannel::Flag::f_megagroup
|
||||
) | rpl::start_with_next([this](bool megagroup) {
|
||||
if (megagroup) {
|
||||
if (!mgInfo) {
|
||||
mgInfo = std::make_unique<MegagroupInfo>();
|
||||
}
|
||||
} else if (mgInfo) {
|
||||
mgInfo = nullptr;
|
||||
}
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void ChannelData::setPhoto(const MTPChatPhoto &photo) {
|
||||
setPhoto(userpicPhotoId(), photo);
|
||||
}
|
||||
|
||||
void ChannelData::setPhoto(PhotoId photoId, const MTPChatPhoto &photo) {
|
||||
if (photo.type() == mtpc_chatPhoto) {
|
||||
const auto &data = photo.c_chatPhoto();
|
||||
updateUserpic(photoId, data.vphoto_small);
|
||||
} else {
|
||||
clearUserpic();
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setName(const QString &newName, const QString &newUsername) {
|
||||
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), newUsername);
|
||||
}
|
||||
|
||||
bool ChannelData::setAbout(const QString &newAbout) {
|
||||
if (_about == newAbout) {
|
||||
return false;
|
||||
}
|
||||
_about = newAbout;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::AboutChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChannelData::setInviteLink(const QString &newInviteLink) {
|
||||
if (newInviteLink != _inviteLink) {
|
||||
_inviteLink = newInviteLink;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
||||
}
|
||||
}
|
||||
|
||||
QString ChannelData::inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
|
||||
bool ChannelData::canHaveInviteLink() const {
|
||||
return (adminRights() & AdminRight::f_invite_users)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
void ChannelData::setMembersCount(int newMembersCount) {
|
||||
if (_membersCount != newMembersCount) {
|
||||
if (isMegagroup() && !mgInfo->lastParticipants.empty()) {
|
||||
mgInfo->lastParticipantsStatus |= MegagroupInfo::LastParticipantsCountOutdated;
|
||||
mgInfo->lastParticipantsCount = membersCount();
|
||||
}
|
||||
_membersCount = newMembersCount;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setAdminsCount(int newAdminsCount) {
|
||||
if (_adminsCount != newAdminsCount) {
|
||||
_adminsCount = newAdminsCount;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::AdminsChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setRestrictedCount(int newRestrictedCount) {
|
||||
if (_restrictedCount != newRestrictedCount) {
|
||||
_restrictedCount = newRestrictedCount;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::BannedUsersChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setKickedCount(int newKickedCount) {
|
||||
if (_kickedCount != newKickedCount) {
|
||||
_kickedCount = newKickedCount;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::BannedUsersChanged);
|
||||
}
|
||||
}
|
||||
|
||||
MTPChatBannedRights ChannelData::KickedRestrictedRights() {
|
||||
using Flag = MTPDchatBannedRights::Flag;
|
||||
auto flags = Flag::f_view_messages | Flag::f_send_messages | Flag::f_send_media | Flag::f_embed_links | Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_games | Flag::f_send_inline;
|
||||
return MTP_chatBannedRights(MTP_flags(flags), MTP_int(std::numeric_limits<int32>::max()));
|
||||
}
|
||||
|
||||
void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChatAdminRights &oldRights, const MTPChatAdminRights &newRights) {
|
||||
auto flags = Notify::PeerUpdate::Flag::AdminsChanged | Notify::PeerUpdate::Flag::None;
|
||||
if (mgInfo) {
|
||||
// If rights are empty - still add participant? TODO check
|
||||
if (!base::contains(mgInfo->lastParticipants, user)) {
|
||||
mgInfo->lastParticipants.push_front(user);
|
||||
setMembersCount(membersCount() + 1);
|
||||
if (user->botInfo && !mgInfo->bots.contains(user)) {
|
||||
mgInfo->bots.insert(user);
|
||||
if (mgInfo->botStatus != 0 && mgInfo->botStatus < 2) {
|
||||
mgInfo->botStatus = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If rights are empty - still remove restrictions? TODO check
|
||||
if (mgInfo->lastRestricted.contains(user)) {
|
||||
mgInfo->lastRestricted.remove(user);
|
||||
if (restrictedCount() > 0) {
|
||||
setRestrictedCount(restrictedCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
auto userId = peerToUser(user->id);
|
||||
auto it = mgInfo->lastAdmins.find(user);
|
||||
if (newRights.c_chatAdminRights().vflags.v != 0) {
|
||||
auto lastAdmin = MegagroupInfo::Admin { newRights };
|
||||
lastAdmin.canEdit = true;
|
||||
if (it == mgInfo->lastAdmins.cend()) {
|
||||
mgInfo->lastAdmins.emplace(user, lastAdmin);
|
||||
setAdminsCount(adminsCount() + 1);
|
||||
} else {
|
||||
it->second = lastAdmin;
|
||||
}
|
||||
Data::ChannelAdminChanges(this).feed(userId, true);
|
||||
} else {
|
||||
if (it != mgInfo->lastAdmins.cend()) {
|
||||
mgInfo->lastAdmins.erase(it);
|
||||
if (adminsCount() > 0) {
|
||||
setAdminsCount(adminsCount() - 1);
|
||||
}
|
||||
}
|
||||
Data::ChannelAdminChanges(this).feed(userId, false);
|
||||
}
|
||||
}
|
||||
if (oldRights.c_chatAdminRights().vflags.v && !newRights.c_chatAdminRights().vflags.v) {
|
||||
// We removed an admin.
|
||||
if (adminsCount() > 1) {
|
||||
setAdminsCount(adminsCount() - 1);
|
||||
}
|
||||
if (!isMegagroup() && user->botInfo && membersCount() > 1) {
|
||||
// Removing bot admin removes it from channel.
|
||||
setMembersCount(membersCount() - 1);
|
||||
}
|
||||
} else if (!oldRights.c_chatAdminRights().vflags.v && newRights.c_chatAdminRights().vflags.v) {
|
||||
// We added an admin.
|
||||
setAdminsCount(adminsCount() + 1);
|
||||
updateFullForced();
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, flags);
|
||||
}
|
||||
|
||||
void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
|
||||
auto flags = Notify::PeerUpdate::Flag::BannedUsersChanged | Notify::PeerUpdate::Flag::None;
|
||||
auto isKicked = (newRights.c_chatBannedRights().vflags.v & MTPDchatBannedRights::Flag::f_view_messages);
|
||||
auto isRestricted = !isKicked && (newRights.c_chatBannedRights().vflags.v != 0);
|
||||
if (mgInfo) {
|
||||
// If rights are empty - still remove admin? TODO check
|
||||
if (mgInfo->lastAdmins.contains(user)) {
|
||||
mgInfo->lastAdmins.remove(user);
|
||||
if (adminsCount() > 1) {
|
||||
setAdminsCount(adminsCount() - 1);
|
||||
} else {
|
||||
flags |= Notify::PeerUpdate::Flag::AdminsChanged;
|
||||
}
|
||||
}
|
||||
auto it = mgInfo->lastRestricted.find(user);
|
||||
if (isRestricted) {
|
||||
if (it == mgInfo->lastRestricted.cend()) {
|
||||
mgInfo->lastRestricted.emplace(user, MegagroupInfo::Restricted { newRights });
|
||||
setRestrictedCount(restrictedCount() + 1);
|
||||
} else {
|
||||
it->second.rights = newRights;
|
||||
}
|
||||
} else {
|
||||
if (it != mgInfo->lastRestricted.cend()) {
|
||||
mgInfo->lastRestricted.erase(it);
|
||||
if (restrictedCount() > 0) {
|
||||
setRestrictedCount(restrictedCount() - 1);
|
||||
}
|
||||
}
|
||||
if (isKicked) {
|
||||
auto i = ranges::find(mgInfo->lastParticipants, user);
|
||||
if (i != mgInfo->lastParticipants.end()) {
|
||||
mgInfo->lastParticipants.erase(i);
|
||||
}
|
||||
if (membersCount() > 1) {
|
||||
setMembersCount(membersCount() - 1);
|
||||
} else {
|
||||
mgInfo->lastParticipantsStatus |= MegagroupInfo::LastParticipantsCountOutdated;
|
||||
mgInfo->lastParticipantsCount = 0;
|
||||
}
|
||||
setKickedCount(kickedCount() + 1);
|
||||
if (mgInfo->bots.contains(user)) {
|
||||
mgInfo->bots.remove(user);
|
||||
if (mgInfo->bots.empty() && mgInfo->botStatus > 0) {
|
||||
mgInfo->botStatus = -1;
|
||||
}
|
||||
}
|
||||
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
||||
owner().removeMegagroupParticipant(this, user);
|
||||
}
|
||||
}
|
||||
Data::ChannelAdminChanges(this).feed(peerToUser(user->id), false);
|
||||
} else {
|
||||
if (isKicked) {
|
||||
if (membersCount() > 1) {
|
||||
setMembersCount(membersCount() - 1);
|
||||
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
||||
}
|
||||
setKickedCount(kickedCount() + 1);
|
||||
}
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, flags);
|
||||
}
|
||||
|
||||
bool ChannelData::isGroupAdmin(not_null<UserData*> user) const {
|
||||
if (auto info = mgInfo.get()) {
|
||||
return info->admins.contains(peerToUser(user->id));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ChannelData::unavailableReason() const {
|
||||
return _unavailableReason;
|
||||
}
|
||||
|
||||
void ChannelData::setUnavailableReason(const QString &text) {
|
||||
if (_unavailableReason != text) {
|
||||
_unavailableReason = text;
|
||||
Notify::peerUpdatedDelayed(
|
||||
this,
|
||||
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setAvailableMinId(MsgId availableMinId) {
|
||||
if (_availableMinId != availableMinId) {
|
||||
_availableMinId = availableMinId;
|
||||
if (pinnedMessageId() <= _availableMinId) {
|
||||
clearPinnedMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::setFeed(not_null<Data::Feed*> feed) {
|
||||
setFeedPointer(feed);
|
||||
}
|
||||
|
||||
void ChannelData::clearFeed() {
|
||||
setFeedPointer(nullptr);
|
||||
}
|
||||
|
||||
void ChannelData::setFeedPointer(Data::Feed *feed) {
|
||||
if (_feed != feed) {
|
||||
const auto was = _feed;
|
||||
_feed = feed;
|
||||
if (was) {
|
||||
was->unregisterOne(this);
|
||||
}
|
||||
if (_feed) {
|
||||
_feed->registerOne(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ChannelData::canBanMembers() const {
|
||||
return (adminRights() & AdminRight::f_ban_users)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditMessages() const {
|
||||
return (adminRights() & AdminRight::f_edit_messages)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canDeleteMessages() const {
|
||||
return (adminRights() & AdminRight::f_delete_messages)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::anyoneCanAddMembers() const {
|
||||
// #TODO groups
|
||||
return false;// (flags() & MTPDchannel::Flag::f_democracy);
|
||||
}
|
||||
|
||||
bool ChannelData::hiddenPreHistory() const {
|
||||
return (fullFlags() & MTPDchannelFull::Flag::f_hidden_prehistory);
|
||||
}
|
||||
|
||||
bool ChannelData::canAddMembers() const {
|
||||
return (adminRights() & AdminRight::f_invite_users)
|
||||
|| amCreator()
|
||||
|| (anyoneCanAddMembers()
|
||||
&& amIn()
|
||||
&& !hasRestrictions());
|
||||
}
|
||||
|
||||
bool ChannelData::canAddAdmins() const {
|
||||
return (adminRights() & AdminRight::f_add_admins)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canPublish() const {
|
||||
return (adminRights() & AdminRight::f_post_messages)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return amIn()
|
||||
&& (canPublish()
|
||||
|| (!isBroadcast()
|
||||
&& !restricted(Restriction::f_send_messages)));
|
||||
}
|
||||
|
||||
bool ChannelData::canViewMembers() const {
|
||||
return fullFlags()
|
||||
& MTPDchannelFull::Flag::f_can_view_participants;
|
||||
}
|
||||
|
||||
bool ChannelData::canViewAdmins() const {
|
||||
return (isMegagroup() || hasAdminRights() || amCreator());
|
||||
}
|
||||
|
||||
bool ChannelData::canViewBanned() const {
|
||||
return (hasAdminRights() || amCreator());
|
||||
}
|
||||
|
||||
bool ChannelData::canEditInformation() const {
|
||||
return (adminRights() & AdminRight::f_change_info)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditInvites() const {
|
||||
return canEditInformation();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditSignatures() const {
|
||||
return canEditInformation();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditPreHistoryHidden() const {
|
||||
return canEditInformation();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditUsername() const {
|
||||
return amCreator()
|
||||
&& (fullFlags()
|
||||
& MTPDchannelFull::Flag::f_can_set_username);
|
||||
}
|
||||
|
||||
bool ChannelData::canEditStickers() const {
|
||||
return (fullFlags()
|
||||
& MTPDchannelFull::Flag::f_can_set_stickers);
|
||||
}
|
||||
|
||||
bool ChannelData::canDelete() const {
|
||||
constexpr auto kDeleteChannelMembersLimit = 1000;
|
||||
return amCreator()
|
||||
&& (membersCount() <= kDeleteChannelMembersLimit);
|
||||
}
|
||||
|
||||
bool ChannelData::canEditLastAdmin(not_null<UserData*> user) const {
|
||||
// Duplicated in ParticipantsBoxController::canEditAdmin :(
|
||||
if (mgInfo) {
|
||||
auto i = mgInfo->lastAdmins.find(user);
|
||||
if (i != mgInfo->lastAdmins.cend()) {
|
||||
return i->second.canEdit;
|
||||
}
|
||||
return (user != mgInfo->creator);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChannelData::canEditAdmin(not_null<UserData*> user) const {
|
||||
// Duplicated in ParticipantsBoxController::canEditAdmin :(
|
||||
if (user->isSelf()) {
|
||||
return false;
|
||||
} else if (amCreator()) {
|
||||
return true;
|
||||
} else if (!canEditLastAdmin(user)) {
|
||||
return false;
|
||||
}
|
||||
return adminRights() & AdminRight::f_add_admins;
|
||||
}
|
||||
|
||||
bool ChannelData::canRestrictUser(not_null<UserData*> user) const {
|
||||
// Duplicated in ParticipantsBoxController::canRestrictUser :(
|
||||
if (user->isSelf()) {
|
||||
return false;
|
||||
} else if (amCreator()) {
|
||||
return true;
|
||||
} else if (!canEditLastAdmin(user)) {
|
||||
return false;
|
||||
}
|
||||
return adminRights() & AdminRight::f_ban_users;
|
||||
}
|
||||
|
||||
void ChannelData::setAdminRights(const MTPChatAdminRights &rights) {
|
||||
if (rights.c_chatAdminRights().vflags.v == adminRights()) {
|
||||
return;
|
||||
}
|
||||
_adminRights.set(rights.c_chatAdminRights().vflags.v);
|
||||
if (isMegagroup()) {
|
||||
const auto self = session().user();
|
||||
if (hasAdminRights()) {
|
||||
if (!amCreator()) {
|
||||
auto me = MegagroupInfo::Admin { rights };
|
||||
me.canEdit = false;
|
||||
mgInfo->lastAdmins.emplace(self, me);
|
||||
}
|
||||
mgInfo->lastRestricted.remove(self);
|
||||
} else {
|
||||
mgInfo->lastAdmins.remove(self);
|
||||
}
|
||||
|
||||
auto amAdmin = hasAdminRights() || amCreator();
|
||||
Data::ChannelAdminChanges(this).feed(session().userId(), amAdmin);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
}
|
||||
|
||||
void ChannelData::setRestrictedRights(const MTPChatBannedRights &rights) {
|
||||
if (rights.c_chatBannedRights().vflags.v == restrictions()
|
||||
&& rights.c_chatBannedRights().vuntil_date.v == _restrictedUntill) {
|
||||
return;
|
||||
}
|
||||
_restrictedUntill = rights.c_chatBannedRights().vuntil_date.v;
|
||||
_restrictions.set(rights.c_chatBannedRights().vflags.v);
|
||||
if (isMegagroup()) {
|
||||
const auto self = session().user();
|
||||
if (hasRestrictions()) {
|
||||
if (!amCreator()) {
|
||||
auto me = MegagroupInfo::Restricted { rights };
|
||||
mgInfo->lastRestricted.emplace(self, me);
|
||||
}
|
||||
mgInfo->lastAdmins.remove(self);
|
||||
Data::ChannelAdminChanges(this).feed(session().userId(), false);
|
||||
} else {
|
||||
mgInfo->lastRestricted.remove(self);
|
||||
}
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
}
|
364
Telegram/SourceFiles/data/data_channel.h
Normal file
364
Telegram/SourceFiles/data/data_channel.h
Normal file
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_pts_waiter.h"
|
||||
|
||||
struct MegagroupInfo {
|
||||
struct Admin {
|
||||
explicit Admin(MTPChatAdminRights rights)
|
||||
: rights(rights) {
|
||||
}
|
||||
Admin(MTPChatAdminRights rights, bool canEdit)
|
||||
: rights(rights)
|
||||
, canEdit(canEdit) {
|
||||
}
|
||||
MTPChatAdminRights rights;
|
||||
bool canEdit = false;
|
||||
};
|
||||
struct Restricted {
|
||||
explicit Restricted(MTPChatBannedRights rights)
|
||||
: rights(rights) {
|
||||
}
|
||||
MTPChatBannedRights rights;
|
||||
};
|
||||
std::deque<not_null<UserData*>> lastParticipants;
|
||||
base::flat_map<not_null<UserData*>, Admin> lastAdmins;
|
||||
base::flat_map<not_null<UserData*>, Restricted> lastRestricted;
|
||||
base::flat_set<not_null<PeerData*>> markupSenders;
|
||||
base::flat_set<not_null<UserData*>> bots;
|
||||
|
||||
// For admin badges, full admins list.
|
||||
base::flat_set<UserId> admins;
|
||||
|
||||
UserData *creator = nullptr; // nullptr means unknown
|
||||
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
||||
bool joinedMessageFound = false;
|
||||
MTPInputStickerSet stickerSet = MTP_inputStickerSetEmpty();
|
||||
|
||||
enum LastParticipantsStatus {
|
||||
LastParticipantsUpToDate = 0x00,
|
||||
LastParticipantsCountOutdated = 0x02,
|
||||
};
|
||||
mutable int lastParticipantsStatus = LastParticipantsUpToDate;
|
||||
int lastParticipantsCount = 0;
|
||||
|
||||
ChatData *migrateFromPtr = nullptr;
|
||||
|
||||
};
|
||||
|
||||
class ChannelData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDchannel::Flag::f_creator
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel::Flag::f_broadcast
|
||||
| MTPDchannel::Flag::f_verified
|
||||
| MTPDchannel::Flag::f_megagroup
|
||||
| MTPDchannel::Flag::f_restricted
|
||||
| MTPDchannel::Flag::f_signatures
|
||||
| MTPDchannel::Flag::f_username;
|
||||
using Flags = Data::Flags<
|
||||
MTPDchannel::Flags,
|
||||
kEssentialFlags>;
|
||||
|
||||
static constexpr auto kEssentialFullFlags = 0
|
||||
| MTPDchannelFull::Flag::f_can_view_participants
|
||||
| MTPDchannelFull::Flag::f_can_set_username
|
||||
| MTPDchannelFull::Flag::f_can_set_stickers;
|
||||
using FullFlags = Data::Flags<
|
||||
MTPDchannelFull::Flags,
|
||||
kEssentialFullFlags>;
|
||||
|
||||
ChannelData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
void setPhoto(PhotoId photoId, const MTPChatPhoto &photo);
|
||||
|
||||
void setName(const QString &name, const QString &username);
|
||||
|
||||
void setFlags(MTPDchannel::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDchannel::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDchannel::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
void setFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.set(which);
|
||||
}
|
||||
void addFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.add(which);
|
||||
}
|
||||
void removeFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.remove(which);
|
||||
}
|
||||
auto fullFlags() const {
|
||||
return _fullFlags.current();
|
||||
}
|
||||
auto fullFlagsValue() const {
|
||||
return _fullFlags.value();
|
||||
}
|
||||
|
||||
uint64 access = 0;
|
||||
|
||||
MTPinputChannel inputChannel;
|
||||
|
||||
QString username;
|
||||
|
||||
// Returns true if about text was changed.
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
return _about;
|
||||
}
|
||||
|
||||
int membersCount() const {
|
||||
return _membersCount;
|
||||
}
|
||||
void setMembersCount(int newMembersCount);
|
||||
|
||||
int adminsCount() const {
|
||||
return _adminsCount;
|
||||
}
|
||||
void setAdminsCount(int newAdminsCount);
|
||||
|
||||
int restrictedCount() const {
|
||||
return _restrictedCount;
|
||||
}
|
||||
void setRestrictedCount(int newRestrictedCount);
|
||||
|
||||
int kickedCount() const {
|
||||
return _kickedCount;
|
||||
}
|
||||
void setKickedCount(int newKickedCount);
|
||||
|
||||
bool haveLeft() const {
|
||||
return flags() & MTPDchannel::Flag::f_left;
|
||||
}
|
||||
bool amIn() const {
|
||||
return !isForbidden() && !haveLeft();
|
||||
}
|
||||
bool addsSignature() const {
|
||||
return flags() & MTPDchannel::Flag::f_signatures;
|
||||
}
|
||||
bool isForbidden() const {
|
||||
return flags() & MTPDchannel_ClientFlag::f_forbidden;
|
||||
}
|
||||
bool isVerified() const {
|
||||
return flags() & MTPDchannel::Flag::f_verified;
|
||||
}
|
||||
|
||||
static MTPChatBannedRights KickedRestrictedRights();
|
||||
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
||||
static bool IsRestrictedForever(TimeId until) {
|
||||
return !until || (until == kRestrictUntilForever);
|
||||
}
|
||||
void applyEditAdmin(
|
||||
not_null<UserData*> user,
|
||||
const MTPChatAdminRights &oldRights,
|
||||
const MTPChatAdminRights &newRights);
|
||||
void applyEditBanned(
|
||||
not_null<UserData*> user,
|
||||
const MTPChatBannedRights &oldRights,
|
||||
const MTPChatBannedRights &newRights);
|
||||
|
||||
bool isGroupAdmin(not_null<UserData*> user) const;
|
||||
|
||||
int32 date = 0;
|
||||
int version = 0;
|
||||
std::unique_ptr<MegagroupInfo> mgInfo;
|
||||
bool lastParticipantsCountOutdated() const {
|
||||
if (!mgInfo
|
||||
|| !(mgInfo->lastParticipantsStatus
|
||||
& MegagroupInfo::LastParticipantsCountOutdated)) {
|
||||
return false;
|
||||
}
|
||||
if (mgInfo->lastParticipantsCount == membersCount()) {
|
||||
mgInfo->lastParticipantsStatus
|
||||
&= ~MegagroupInfo::LastParticipantsCountOutdated;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool isMegagroup() const {
|
||||
return flags() & MTPDchannel::Flag::f_megagroup;
|
||||
}
|
||||
bool isBroadcast() const {
|
||||
return flags() & MTPDchannel::Flag::f_broadcast;
|
||||
}
|
||||
bool isPublic() const {
|
||||
return flags() & MTPDchannel::Flag::f_username;
|
||||
}
|
||||
bool amCreator() const {
|
||||
return flags() & MTPDchannel::Flag::f_creator;
|
||||
}
|
||||
|
||||
using AdminRight = ChatAdminRight;
|
||||
using Restriction = ChatRestriction;
|
||||
using AdminRights = ChatAdminRights;
|
||||
using Restrictions = ChatRestrictions;
|
||||
using AdminRightFlags = Data::Flags<AdminRights>;
|
||||
using RestrictionFlags = Data::Flags<Restrictions>;
|
||||
auto adminRights() const {
|
||||
return _adminRights.current();
|
||||
}
|
||||
auto adminRightsValue() const {
|
||||
return _adminRights.value();
|
||||
}
|
||||
void setAdminRights(const MTPChatAdminRights &rights);
|
||||
bool hasAdminRights() const {
|
||||
return (adminRights() != 0);
|
||||
}
|
||||
auto restrictions() const {
|
||||
return _restrictions.current();
|
||||
}
|
||||
auto restrictionsValue() const {
|
||||
return _restrictions.value();
|
||||
}
|
||||
bool restricted(Restriction right) const {
|
||||
return restrictions() & right;
|
||||
}
|
||||
TimeId restrictedUntil() const {
|
||||
return _restrictedUntill;
|
||||
}
|
||||
void setRestrictedRights(const MTPChatBannedRights &rights);
|
||||
bool hasRestrictions() const {
|
||||
return (restrictions() != 0);
|
||||
}
|
||||
bool hasRestrictions(TimeId now) const {
|
||||
return hasRestrictions()
|
||||
&& (restrictedUntil() > now);
|
||||
}
|
||||
bool canBanMembers() const;
|
||||
bool canEditMessages() const;
|
||||
bool canDeleteMessages() const;
|
||||
bool anyoneCanAddMembers() const;
|
||||
bool hiddenPreHistory() const;
|
||||
bool canAddMembers() const;
|
||||
bool canAddAdmins() const;
|
||||
bool canPublish() const;
|
||||
bool canWrite() const;
|
||||
bool canViewMembers() const;
|
||||
bool canViewAdmins() const;
|
||||
bool canViewBanned() const;
|
||||
bool canEditInformation() const;
|
||||
bool canEditInvites() const;
|
||||
bool canEditSignatures() const;
|
||||
bool canEditPreHistoryHidden() const;
|
||||
bool canEditUsername() const;
|
||||
bool canEditStickers() const;
|
||||
bool canDelete() const;
|
||||
bool canEditAdmin(not_null<UserData*> user) const;
|
||||
bool canRestrictUser(not_null<UserData*> user) const;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const;
|
||||
bool canHaveInviteLink() const;
|
||||
|
||||
UserId inviter = 0; // > 0 - user who invited me to channel, < 0 - not in channel
|
||||
TimeId inviteDate = 0;
|
||||
|
||||
void ptsInit(int32 pts) {
|
||||
_ptsWaiter.init(pts);
|
||||
}
|
||||
void ptsReceived(int32 pts) {
|
||||
_ptsWaiter.updateAndApply(this, pts, 0);
|
||||
}
|
||||
bool ptsUpdateAndApply(int32 pts, int32 count) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, update);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, updates);
|
||||
}
|
||||
int32 pts() const {
|
||||
return _ptsWaiter.current();
|
||||
}
|
||||
bool ptsInited() const {
|
||||
return _ptsWaiter.inited();
|
||||
}
|
||||
bool ptsRequesting() const {
|
||||
return _ptsWaiter.requesting();
|
||||
}
|
||||
void ptsSetRequesting(bool isRequesting) {
|
||||
return _ptsWaiter.setRequesting(isRequesting);
|
||||
}
|
||||
void ptsWaitingForShortPoll(int32 ms) { // < 0 - not waiting
|
||||
return _ptsWaiter.setWaitingForShortPoll(this, ms);
|
||||
}
|
||||
bool ptsWaitingForSkipped() const {
|
||||
return _ptsWaiter.waitingForSkipped();
|
||||
}
|
||||
bool ptsWaitingForShortPoll() const {
|
||||
return _ptsWaiter.waitingForShortPoll();
|
||||
}
|
||||
|
||||
QString unavailableReason() const override;
|
||||
void setUnavailableReason(const QString &reason);
|
||||
|
||||
MsgId availableMinId() const {
|
||||
return _availableMinId;
|
||||
}
|
||||
void setAvailableMinId(MsgId availableMinId);
|
||||
|
||||
void setFeed(not_null<Data::Feed*> feed);
|
||||
void clearFeed();
|
||||
|
||||
Data::Feed *feed() const {
|
||||
return _feed;
|
||||
}
|
||||
|
||||
private:
|
||||
void flagsUpdated(MTPDchannel::Flags diff);
|
||||
void fullFlagsUpdated(MTPDchannelFull::Flags diff);
|
||||
|
||||
bool canEditLastAdmin(not_null<UserData*> user) const;
|
||||
void setFeedPointer(Data::Feed *feed);
|
||||
|
||||
Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0);
|
||||
FullFlags _fullFlags;
|
||||
|
||||
PtsWaiter _ptsWaiter;
|
||||
|
||||
int _membersCount = 1;
|
||||
int _adminsCount = 1;
|
||||
int _restrictedCount = 0;
|
||||
int _kickedCount = 0;
|
||||
MsgId _availableMinId = 0;
|
||||
|
||||
AdminRightFlags _adminRights;
|
||||
RestrictionFlags _restrictions;
|
||||
TimeId _restrictedUntill;
|
||||
|
||||
QString _unavailableReason;
|
||||
QString _about;
|
||||
|
||||
QString _inviteLink;
|
||||
Data::Feed *_feed = nullptr;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_channel_admins.h"
|
||||
|
||||
#include "history/history.h"
|
||||
#include "data/data_channel.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
65
Telegram/SourceFiles/data/data_chat.cpp
Normal file
65
Telegram/SourceFiles/data/data_chat.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_chat.h"
|
||||
|
||||
#include "observer_peer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
} // namespace
|
||||
|
||||
ChatData::ChatData(not_null<Data::Session*> owner, PeerId id)
|
||||
: PeerData(owner, id)
|
||||
, inputChat(MTP_int(bareId())) {
|
||||
}
|
||||
|
||||
void ChatData::setPhoto(const MTPChatPhoto &photo) {
|
||||
setPhoto(userpicPhotoId(), photo);
|
||||
}
|
||||
|
||||
void ChatData::setPhoto(PhotoId photoId, const MTPChatPhoto &photo) {
|
||||
if (photo.type() == mtpc_chatPhoto) {
|
||||
const auto &data = photo.c_chatPhoto();
|
||||
updateUserpic(photoId, data.vphoto_small);
|
||||
} else {
|
||||
clearUserpic();
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatData::canEditInformation() const {
|
||||
// #TODO groups
|
||||
return !isDeactivated()
|
||||
/*&& ((adminRights() & AdminRight::f_change_info) || amCreator())*/;
|
||||
}
|
||||
|
||||
void ChatData::setName(const QString &newName) {
|
||||
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString());
|
||||
}
|
||||
|
||||
void ChatData::invalidateParticipants() {
|
||||
// #TODO groups
|
||||
auto wasCanEdit = canEditInformation();
|
||||
participants.clear();
|
||||
admins.clear();
|
||||
//removeFlags(MTPDchat::Flag::f_admin);
|
||||
invitedByMe.clear();
|
||||
botStatus = 0;
|
||||
if (wasCanEdit != canEditInformation()) {
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged);
|
||||
}
|
||||
|
||||
void ChatData::setInviteLink(const QString &newInviteLink) {
|
||||
if (newInviteLink != _inviteLink) {
|
||||
_inviteLink = newInviteLink;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
||||
}
|
||||
}
|
108
Telegram/SourceFiles/data/data_chat.h
Normal file
108
Telegram/SourceFiles/data/data_chat.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_peer.h"
|
||||
|
||||
class ChatData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDchat::Flag::f_creator
|
||||
| MTPDchat::Flag::f_kicked
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat::Flag::f_migrated_to
|
||||
| MTPDchat::Flag::f_admin_rights
|
||||
| MTPDchat::Flag::f_default_banned_rights;
|
||||
using Flags = Data::Flags<
|
||||
MTPDchat::Flags,
|
||||
kEssentialFlags>;
|
||||
|
||||
ChatData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
void setPhoto(PhotoId photoId, const MTPChatPhoto &photo);
|
||||
|
||||
void setName(const QString &newName);
|
||||
|
||||
void invalidateParticipants();
|
||||
bool noParticipantInfo() const {
|
||||
return (count > 0 || amIn()) && participants.empty();
|
||||
}
|
||||
|
||||
MTPint inputChat;
|
||||
|
||||
ChannelData *migrateToPtr = nullptr;
|
||||
|
||||
int count = 0;
|
||||
TimeId date = 0;
|
||||
int version = 0;
|
||||
UserId creator = 0;
|
||||
|
||||
void setFlags(MTPDchat::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDchat::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDchat::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
bool isForbidden() const {
|
||||
return flags() & MTPDchat_ClientFlag::f_forbidden;
|
||||
}
|
||||
bool amIn() const {
|
||||
return !isForbidden() && !haveLeft() && !wasKicked();
|
||||
}
|
||||
bool canEditInformation() const;
|
||||
bool canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !isDeactivated() && amIn();
|
||||
}
|
||||
bool haveLeft() const {
|
||||
return flags() & MTPDchat::Flag::f_left;
|
||||
}
|
||||
bool wasKicked() const {
|
||||
return flags() & MTPDchat::Flag::f_kicked;
|
||||
}
|
||||
bool amCreator() const {
|
||||
return flags() & MTPDchat::Flag::f_creator;
|
||||
}
|
||||
bool isDeactivated() const {
|
||||
return flags() & MTPDchat::Flag::f_deactivated;
|
||||
}
|
||||
bool isMigrated() const {
|
||||
return flags() & MTPDchat::Flag::f_migrated_to;
|
||||
}
|
||||
base::flat_map<not_null<UserData*>, int> participants;
|
||||
base::flat_set<not_null<UserData*>> invitedByMe;
|
||||
base::flat_set<not_null<UserData*>> admins;
|
||||
std::deque<not_null<UserData*>> lastAuthors;
|
||||
base::flat_set<not_null<PeerData*>> markupSenders;
|
||||
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
||||
// ImagePtr photoFull;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
|
||||
private:
|
||||
void flagsUpdated(MTPDchat::Flags diff);
|
||||
|
||||
Flags _flags;
|
||||
QString _inviteLink;
|
||||
|
||||
};
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "media/media_clip_reader.h"
|
||||
#include "auth_session.h"
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_feed.h"
|
||||
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
|
|
|
@ -19,7 +19,7 @@ struct FileReferenceAccumulator {
|
|||
}
|
||||
void push(const MTPFileLocation &data) {
|
||||
data.match([&](const MTPDfileLocation &data) {
|
||||
result.emplace(SimpleFileLocationId(
|
||||
result.data.emplace(SimpleFileLocationId(
|
||||
data.vvolume_id.v,
|
||||
data.vdc_id.v,
|
||||
data.vlocal_id.v), data.vfile_reference.v);
|
||||
|
@ -46,7 +46,7 @@ struct FileReferenceAccumulator {
|
|||
for (const auto &thumb : data.vthumbs.v) {
|
||||
push(thumb);
|
||||
}
|
||||
result.emplace(
|
||||
result.data.emplace(
|
||||
DocumentFileLocationId(data.vid.v),
|
||||
data.vfile_reference.v);
|
||||
}, [](const MTPDdocumentEmpty &data) {
|
||||
|
|
|
@ -60,12 +60,35 @@ struct FileOriginSavedGifs {
|
|||
}
|
||||
};
|
||||
|
||||
using FileOrigin = base::optional_variant<
|
||||
FileOriginMessage,
|
||||
FileOriginUserPhoto,
|
||||
FileOriginPeerPhoto,
|
||||
FileOriginStickerSet,
|
||||
FileOriginSavedGifs>;
|
||||
struct FileOrigin {
|
||||
using Variant = base::optional_variant<
|
||||
FileOriginMessage,
|
||||
FileOriginUserPhoto,
|
||||
FileOriginPeerPhoto,
|
||||
FileOriginStickerSet,
|
||||
FileOriginSavedGifs>;
|
||||
|
||||
FileOrigin() = default;
|
||||
FileOrigin(FileOriginMessage data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginUserPhoto data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginPeerPhoto data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginStickerSet data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginSavedGifs data) : data(data) {
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return data.has_value();
|
||||
}
|
||||
inline bool operator<(const FileOrigin &other) const {
|
||||
return data < other.data;
|
||||
}
|
||||
|
||||
Variant data;
|
||||
};
|
||||
|
||||
// Volume_id, dc_id, local_id.
|
||||
struct SimpleFileLocationId {
|
||||
|
@ -84,7 +107,9 @@ using DocumentFileLocationId = uint64;
|
|||
using FileLocationId = base::variant<
|
||||
SimpleFileLocationId,
|
||||
DocumentFileLocationId>;
|
||||
using UpdatedFileReferences = std::map<FileLocationId, QByteArray>;
|
||||
struct UpdatedFileReferences {
|
||||
std::map<FileLocationId, QByteArray> data;
|
||||
};
|
||||
|
||||
UpdatedFileReferences GetFileReferences(const MTPmessages_Messages &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPphotos_Photos &data);
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_game.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "data/data_poll.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "layout.h"
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_types.h"
|
||||
#include "data/data_flags.h"
|
||||
#include "data/data_notify_settings.h"
|
||||
#include "data/data_file_origin.h"
|
||||
|
||||
namespace Ui {
|
||||
class EmptyUserpic;
|
||||
|
@ -33,6 +32,11 @@ style::color PeerUserpicColor(PeerId peerId);
|
|||
|
||||
} // namespace Data
|
||||
|
||||
using ChatAdminRight = MTPDchatAdminRights::Flag;
|
||||
using ChatRestriction = MTPDchatBannedRights::Flag;
|
||||
using ChatAdminRights = MTPDchatAdminRights::Flags;
|
||||
using ChatRestrictions = MTPDchatBannedRights::Flags;
|
||||
|
||||
class PeerClickHandler : public ClickHandler {
|
||||
public:
|
||||
PeerClickHandler(not_null<PeerData*> peer);
|
||||
|
@ -188,14 +192,8 @@ public:
|
|||
PhotoId userpicPhotoId() const {
|
||||
return userpicPhotoUnknown() ? 0 : _userpicPhotoId;
|
||||
}
|
||||
Data::FileOrigin userpicOrigin() const {
|
||||
return Data::FileOrigin(Data::FileOriginPeerPhoto(id));
|
||||
}
|
||||
Data::FileOrigin userpicPhotoOrigin() const {
|
||||
return (isUser() && userpicPhotoId())
|
||||
? Data::FileOriginUserPhoto(bareId(), userpicPhotoId())
|
||||
: Data::FileOrigin();
|
||||
}
|
||||
Data::FileOrigin userpicOrigin() const;
|
||||
Data::FileOrigin userpicPhotoOrigin() const;
|
||||
|
||||
int nameVersion = 1;
|
||||
|
||||
|
@ -261,900 +259,3 @@ private:
|
|||
MsgId _pinnedMessageId = 0;
|
||||
|
||||
};
|
||||
|
||||
class BotCommand {
|
||||
public:
|
||||
BotCommand(
|
||||
const QString &command,
|
||||
const QString &description)
|
||||
: command(command)
|
||||
, _description(description) {
|
||||
}
|
||||
QString command;
|
||||
|
||||
bool setDescription(const QString &description) {
|
||||
if (_description != description) {
|
||||
_description = description;
|
||||
_descriptionText = Text();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const Text &descriptionText() const;
|
||||
|
||||
private:
|
||||
QString _description;
|
||||
mutable Text _descriptionText;
|
||||
|
||||
};
|
||||
|
||||
struct BotInfo {
|
||||
bool inited = false;
|
||||
bool readsAllHistory = false;
|
||||
bool cantJoinGroups = false;
|
||||
int version = 0;
|
||||
QString description, inlinePlaceholder;
|
||||
QList<BotCommand> commands;
|
||||
Text text = Text{ int(st::msgMinWidth) }; // description
|
||||
|
||||
QString startToken, startGroupToken, shareGameShortName;
|
||||
PeerId inlineReturnPeerId = 0;
|
||||
};
|
||||
|
||||
class UserData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDuser::Flag::f_self
|
||||
| MTPDuser::Flag::f_contact
|
||||
| MTPDuser::Flag::f_mutual_contact
|
||||
| MTPDuser::Flag::f_deleted
|
||||
| MTPDuser::Flag::f_bot
|
||||
| MTPDuser::Flag::f_bot_chat_history
|
||||
| MTPDuser::Flag::f_bot_nochats
|
||||
| MTPDuser::Flag::f_verified
|
||||
| MTPDuser::Flag::f_restricted
|
||||
| MTPDuser::Flag::f_bot_inline_geo;
|
||||
using Flags = Data::Flags<
|
||||
MTPDuser::Flags,
|
||||
kEssentialFlags.value()>;
|
||||
|
||||
static constexpr auto kEssentialFullFlags = 0
|
||||
| MTPDuserFull::Flag::f_blocked
|
||||
| MTPDuserFull::Flag::f_phone_calls_available
|
||||
| MTPDuserFull::Flag::f_phone_calls_private;
|
||||
using FullFlags = Data::Flags<
|
||||
MTPDuserFull::Flags,
|
||||
kEssentialFullFlags.value()>;
|
||||
|
||||
UserData(not_null<Data::Session*> owner, PeerId id);
|
||||
void setPhoto(const MTPUserProfilePhoto &photo);
|
||||
|
||||
void setName(
|
||||
const QString &newFirstName,
|
||||
const QString &newLastName,
|
||||
const QString &newPhoneName,
|
||||
const QString &newUsername);
|
||||
|
||||
void setPhone(const QString &newPhone);
|
||||
void setBotInfoVersion(int version);
|
||||
void setBotInfo(const MTPBotInfo &info);
|
||||
|
||||
void setNameOrPhone(const QString &newNameOrPhone);
|
||||
|
||||
void madeAction(TimeId when); // pseudo-online
|
||||
|
||||
uint64 accessHash() const {
|
||||
return _accessHash;
|
||||
}
|
||||
void setAccessHash(uint64 accessHash);
|
||||
|
||||
void setFlags(MTPDuser::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDuser::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDuser::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
void setFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.set(which);
|
||||
}
|
||||
void addFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.add(which);
|
||||
}
|
||||
void removeFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.remove(which);
|
||||
}
|
||||
auto fullFlags() const {
|
||||
return _fullFlags.current();
|
||||
}
|
||||
auto fullFlagsValue() const {
|
||||
return _fullFlags.value();
|
||||
}
|
||||
|
||||
bool isVerified() const {
|
||||
return flags() & MTPDuser::Flag::f_verified;
|
||||
}
|
||||
bool isBotInlineGeo() const {
|
||||
return flags() & MTPDuser::Flag::f_bot_inline_geo;
|
||||
}
|
||||
bool isInaccessible() const {
|
||||
constexpr auto inaccessible = 0
|
||||
| MTPDuser::Flag::f_deleted;
|
||||
// | MTPDuser_ClientFlag::f_inaccessible;
|
||||
return flags() & inaccessible;
|
||||
}
|
||||
bool canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !isInaccessible();
|
||||
}
|
||||
bool isContact() const {
|
||||
return (_contactStatus == ContactStatus::Contact);
|
||||
}
|
||||
|
||||
bool canShareThisContact() const;
|
||||
bool canAddContact() const {
|
||||
return canShareThisContact() && !isContact();
|
||||
}
|
||||
|
||||
// In feedUsers() we check only that.
|
||||
// When actually trying to share contact we perform
|
||||
// a full check by canShareThisContact() call.
|
||||
bool canShareThisContactFast() const {
|
||||
return !_phone.isEmpty();
|
||||
}
|
||||
|
||||
MTPInputUser inputUser;
|
||||
|
||||
QString firstName;
|
||||
QString lastName;
|
||||
QString username;
|
||||
const QString &phone() const {
|
||||
return _phone;
|
||||
}
|
||||
QString nameOrPhone;
|
||||
Text phoneText;
|
||||
TimeId onlineTill = 0;
|
||||
|
||||
enum class ContactStatus : char {
|
||||
PhoneUnknown,
|
||||
CanAdd,
|
||||
Contact,
|
||||
};
|
||||
ContactStatus contactStatus() const {
|
||||
return _contactStatus;
|
||||
}
|
||||
void setContactStatus(ContactStatus status);
|
||||
|
||||
enum class BlockStatus : char {
|
||||
Unknown,
|
||||
Blocked,
|
||||
NotBlocked,
|
||||
};
|
||||
BlockStatus blockStatus() const {
|
||||
return _blockStatus;
|
||||
}
|
||||
bool isBlocked() const {
|
||||
return (blockStatus() == BlockStatus::Blocked);
|
||||
}
|
||||
void setBlockStatus(BlockStatus blockStatus);
|
||||
|
||||
enum class CallsStatus : char {
|
||||
Unknown,
|
||||
Enabled,
|
||||
Disabled,
|
||||
Private,
|
||||
};
|
||||
CallsStatus callsStatus() const {
|
||||
return _callsStatus;
|
||||
}
|
||||
bool hasCalls() const;
|
||||
void setCallsStatus(CallsStatus callsStatus);
|
||||
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
return _about;
|
||||
}
|
||||
|
||||
std::unique_ptr<BotInfo> botInfo;
|
||||
|
||||
QString unavailableReason() const override;
|
||||
void setUnavailableReason(const QString &reason);
|
||||
|
||||
int commonChatsCount() const {
|
||||
return _commonChatsCount;
|
||||
}
|
||||
void setCommonChatsCount(int count);
|
||||
|
||||
private:
|
||||
Flags _flags;
|
||||
FullFlags _fullFlags;
|
||||
|
||||
QString _unavailableReason;
|
||||
QString _about;
|
||||
QString _phone;
|
||||
ContactStatus _contactStatus = ContactStatus::PhoneUnknown;
|
||||
BlockStatus _blockStatus = BlockStatus::Unknown;
|
||||
CallsStatus _callsStatus = CallsStatus::Unknown;
|
||||
int _commonChatsCount = 0;
|
||||
|
||||
uint64 _accessHash = 0;
|
||||
static constexpr auto kInaccessibleAccessHashOld
|
||||
= 0xFFFFFFFFFFFFFFFFULL;
|
||||
|
||||
};
|
||||
|
||||
using ChatAdminRight = MTPDchatAdminRights::Flag;
|
||||
using ChatRestriction = MTPDchatBannedRights::Flag;
|
||||
using ChatAdminRights = MTPDchatAdminRights::Flags;
|
||||
using ChatRestrictions = MTPDchatBannedRights::Flags;
|
||||
|
||||
class ChatData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDchat::Flag::f_creator
|
||||
| MTPDchat::Flag::f_kicked
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat::Flag::f_migrated_to
|
||||
| MTPDchat::Flag::f_admin_rights
|
||||
| MTPDchat::Flag::f_default_banned_rights;
|
||||
using Flags = Data::Flags<
|
||||
MTPDchat::Flags,
|
||||
kEssentialFlags>;
|
||||
|
||||
ChatData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
void setPhoto(PhotoId photoId, const MTPChatPhoto &photo);
|
||||
|
||||
void setName(const QString &newName);
|
||||
|
||||
void invalidateParticipants();
|
||||
bool noParticipantInfo() const {
|
||||
return (count > 0 || amIn()) && participants.empty();
|
||||
}
|
||||
|
||||
MTPint inputChat;
|
||||
|
||||
ChannelData *migrateToPtr = nullptr;
|
||||
|
||||
int count = 0;
|
||||
TimeId date = 0;
|
||||
int version = 0;
|
||||
UserId creator = 0;
|
||||
|
||||
void setFlags(MTPDchat::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDchat::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDchat::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
bool isForbidden() const {
|
||||
return flags() & MTPDchat_ClientFlag::f_forbidden;
|
||||
}
|
||||
bool amIn() const {
|
||||
return !isForbidden() && !haveLeft() && !wasKicked();
|
||||
}
|
||||
bool canEditInformation() const;
|
||||
bool canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !isDeactivated() && amIn();
|
||||
}
|
||||
bool haveLeft() const {
|
||||
return flags() & MTPDchat::Flag::f_left;
|
||||
}
|
||||
bool wasKicked() const {
|
||||
return flags() & MTPDchat::Flag::f_kicked;
|
||||
}
|
||||
bool amCreator() const {
|
||||
return flags() & MTPDchat::Flag::f_creator;
|
||||
}
|
||||
bool isDeactivated() const {
|
||||
return flags() & MTPDchat::Flag::f_deactivated;
|
||||
}
|
||||
bool isMigrated() const {
|
||||
return flags() & MTPDchat::Flag::f_migrated_to;
|
||||
}
|
||||
base::flat_map<not_null<UserData*>, int> participants;
|
||||
base::flat_set<not_null<UserData*>> invitedByMe;
|
||||
base::flat_set<not_null<UserData*>> admins;
|
||||
std::deque<not_null<UserData*>> lastAuthors;
|
||||
base::flat_set<not_null<PeerData*>> markupSenders;
|
||||
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
||||
// ImagePtr photoFull;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
|
||||
private:
|
||||
void flagsUpdated(MTPDchat::Flags diff);
|
||||
|
||||
Flags _flags;
|
||||
QString _inviteLink;
|
||||
|
||||
};
|
||||
|
||||
enum PtsSkippedQueue {
|
||||
SkippedUpdate,
|
||||
SkippedUpdates,
|
||||
};
|
||||
class PtsWaiter {
|
||||
public:
|
||||
PtsWaiter() = default;
|
||||
void init(int32 pts) {
|
||||
_good = _last = _count = pts;
|
||||
clearSkippedUpdates();
|
||||
}
|
||||
bool inited() const {
|
||||
return _good > 0;
|
||||
}
|
||||
void setRequesting(bool isRequesting) {
|
||||
_requesting = isRequesting;
|
||||
if (_requesting) {
|
||||
clearSkippedUpdates();
|
||||
}
|
||||
}
|
||||
bool requesting() const {
|
||||
return _requesting;
|
||||
}
|
||||
bool waitingForSkipped() const {
|
||||
return _waitingForSkipped;
|
||||
}
|
||||
bool waitingForShortPoll() const {
|
||||
return _waitingForShortPoll;
|
||||
}
|
||||
void setWaitingForSkipped(ChannelData *channel, int32 ms); // < 0 - not waiting
|
||||
void setWaitingForShortPoll(ChannelData *channel, int32 ms); // < 0 - not waiting
|
||||
int32 current() const{
|
||||
return _good;
|
||||
}
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates);
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update);
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count);
|
||||
void applySkippedUpdates(ChannelData *channel);
|
||||
void clearSkippedUpdates();
|
||||
|
||||
private:
|
||||
bool check(ChannelData *channel, int32 pts, int32 count); // return false if need to save that update and apply later
|
||||
uint64 ptsKey(PtsSkippedQueue queue, int32 pts);
|
||||
void checkForWaiting(ChannelData *channel);
|
||||
QMap<uint64, PtsSkippedQueue> _queue;
|
||||
QMap<uint64, MTPUpdate> _updateQueue;
|
||||
QMap<uint64, MTPUpdates> _updatesQueue;
|
||||
int32 _good = 0;
|
||||
int32 _last = 0;
|
||||
int32 _count = 0;
|
||||
int32 _applySkippedLevel = 0;
|
||||
bool _requesting = false;
|
||||
bool _waitingForSkipped = false;
|
||||
bool _waitingForShortPoll = false;
|
||||
uint32 _skippedKey = 0;
|
||||
};
|
||||
|
||||
struct MegagroupInfo {
|
||||
struct Admin {
|
||||
explicit Admin(MTPChatAdminRights rights)
|
||||
: rights(rights) {
|
||||
}
|
||||
Admin(MTPChatAdminRights rights, bool canEdit)
|
||||
: rights(rights)
|
||||
, canEdit(canEdit) {
|
||||
}
|
||||
MTPChatAdminRights rights;
|
||||
bool canEdit = false;
|
||||
};
|
||||
struct Restricted {
|
||||
explicit Restricted(MTPChatBannedRights rights)
|
||||
: rights(rights) {
|
||||
}
|
||||
MTPChatBannedRights rights;
|
||||
};
|
||||
std::deque<not_null<UserData*>> lastParticipants;
|
||||
base::flat_map<not_null<UserData*>, Admin> lastAdmins;
|
||||
base::flat_map<not_null<UserData*>, Restricted> lastRestricted;
|
||||
base::flat_set<not_null<PeerData*>> markupSenders;
|
||||
base::flat_set<not_null<UserData*>> bots;
|
||||
|
||||
// For admin badges, full admins list.
|
||||
base::flat_set<UserId> admins;
|
||||
|
||||
UserData *creator = nullptr; // nullptr means unknown
|
||||
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
||||
bool joinedMessageFound = false;
|
||||
MTPInputStickerSet stickerSet = MTP_inputStickerSetEmpty();
|
||||
|
||||
enum LastParticipantsStatus {
|
||||
LastParticipantsUpToDate = 0x00,
|
||||
LastParticipantsCountOutdated = 0x02,
|
||||
};
|
||||
mutable int lastParticipantsStatus = LastParticipantsUpToDate;
|
||||
int lastParticipantsCount = 0;
|
||||
|
||||
ChatData *migrateFromPtr = nullptr;
|
||||
|
||||
};
|
||||
|
||||
class ChannelData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDchannel::Flag::f_creator
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel::Flag::f_broadcast
|
||||
| MTPDchannel::Flag::f_verified
|
||||
| MTPDchannel::Flag::f_megagroup
|
||||
| MTPDchannel::Flag::f_restricted
|
||||
| MTPDchannel::Flag::f_signatures
|
||||
| MTPDchannel::Flag::f_username;
|
||||
using Flags = Data::Flags<
|
||||
MTPDchannel::Flags,
|
||||
kEssentialFlags>;
|
||||
|
||||
static constexpr auto kEssentialFullFlags = 0
|
||||
| MTPDchannelFull::Flag::f_can_view_participants
|
||||
| MTPDchannelFull::Flag::f_can_set_username
|
||||
| MTPDchannelFull::Flag::f_can_set_stickers;
|
||||
using FullFlags = Data::Flags<
|
||||
MTPDchannelFull::Flags,
|
||||
kEssentialFullFlags>;
|
||||
|
||||
ChannelData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
void setPhoto(PhotoId photoId, const MTPChatPhoto &photo);
|
||||
|
||||
void setName(const QString &name, const QString &username);
|
||||
|
||||
void setFlags(MTPDchannel::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDchannel::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDchannel::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
void setFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.set(which);
|
||||
}
|
||||
void addFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.add(which);
|
||||
}
|
||||
void removeFullFlags(MTPDchannelFull::Flags which) {
|
||||
_fullFlags.remove(which);
|
||||
}
|
||||
auto fullFlags() const {
|
||||
return _fullFlags.current();
|
||||
}
|
||||
auto fullFlagsValue() const {
|
||||
return _fullFlags.value();
|
||||
}
|
||||
|
||||
uint64 access = 0;
|
||||
|
||||
MTPinputChannel inputChannel;
|
||||
|
||||
QString username;
|
||||
|
||||
// Returns true if about text was changed.
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
return _about;
|
||||
}
|
||||
|
||||
int membersCount() const {
|
||||
return _membersCount;
|
||||
}
|
||||
void setMembersCount(int newMembersCount);
|
||||
|
||||
int adminsCount() const {
|
||||
return _adminsCount;
|
||||
}
|
||||
void setAdminsCount(int newAdminsCount);
|
||||
|
||||
int restrictedCount() const {
|
||||
return _restrictedCount;
|
||||
}
|
||||
void setRestrictedCount(int newRestrictedCount);
|
||||
|
||||
int kickedCount() const {
|
||||
return _kickedCount;
|
||||
}
|
||||
void setKickedCount(int newKickedCount);
|
||||
|
||||
bool haveLeft() const {
|
||||
return flags() & MTPDchannel::Flag::f_left;
|
||||
}
|
||||
bool amIn() const {
|
||||
return !isForbidden() && !haveLeft();
|
||||
}
|
||||
bool addsSignature() const {
|
||||
return flags() & MTPDchannel::Flag::f_signatures;
|
||||
}
|
||||
bool isForbidden() const {
|
||||
return flags() & MTPDchannel_ClientFlag::f_forbidden;
|
||||
}
|
||||
bool isVerified() const {
|
||||
return flags() & MTPDchannel::Flag::f_verified;
|
||||
}
|
||||
|
||||
static MTPChatBannedRights KickedRestrictedRights();
|
||||
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
||||
static bool IsRestrictedForever(TimeId until) {
|
||||
return !until || (until == kRestrictUntilForever);
|
||||
}
|
||||
void applyEditAdmin(
|
||||
not_null<UserData*> user,
|
||||
const MTPChatAdminRights &oldRights,
|
||||
const MTPChatAdminRights &newRights);
|
||||
void applyEditBanned(
|
||||
not_null<UserData*> user,
|
||||
const MTPChatBannedRights &oldRights,
|
||||
const MTPChatBannedRights &newRights);
|
||||
|
||||
bool isGroupAdmin(not_null<UserData*> user) const;
|
||||
|
||||
int32 date = 0;
|
||||
int version = 0;
|
||||
std::unique_ptr<MegagroupInfo> mgInfo;
|
||||
bool lastParticipantsCountOutdated() const {
|
||||
if (!mgInfo
|
||||
|| !(mgInfo->lastParticipantsStatus
|
||||
& MegagroupInfo::LastParticipantsCountOutdated)) {
|
||||
return false;
|
||||
}
|
||||
if (mgInfo->lastParticipantsCount == membersCount()) {
|
||||
mgInfo->lastParticipantsStatus
|
||||
&= ~MegagroupInfo::LastParticipantsCountOutdated;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool isMegagroup() const {
|
||||
return flags() & MTPDchannel::Flag::f_megagroup;
|
||||
}
|
||||
bool isBroadcast() const {
|
||||
return flags() & MTPDchannel::Flag::f_broadcast;
|
||||
}
|
||||
bool isPublic() const {
|
||||
return flags() & MTPDchannel::Flag::f_username;
|
||||
}
|
||||
bool amCreator() const {
|
||||
return flags() & MTPDchannel::Flag::f_creator;
|
||||
}
|
||||
|
||||
using AdminRight = ChatAdminRight;
|
||||
using Restriction = ChatRestriction;
|
||||
using AdminRights = ChatAdminRights;
|
||||
using Restrictions = ChatRestrictions;
|
||||
using AdminRightFlags = Data::Flags<AdminRights>;
|
||||
using RestrictionFlags = Data::Flags<Restrictions>;
|
||||
auto adminRights() const {
|
||||
return _adminRights.current();
|
||||
}
|
||||
auto adminRightsValue() const {
|
||||
return _adminRights.value();
|
||||
}
|
||||
void setAdminRights(const MTPChatAdminRights &rights);
|
||||
bool hasAdminRights() const {
|
||||
return (adminRights() != 0);
|
||||
}
|
||||
auto restrictions() const {
|
||||
return _restrictions.current();
|
||||
}
|
||||
auto restrictionsValue() const {
|
||||
return _restrictions.value();
|
||||
}
|
||||
bool restricted(Restriction right) const {
|
||||
return restrictions() & right;
|
||||
}
|
||||
TimeId restrictedUntil() const {
|
||||
return _restrictedUntill;
|
||||
}
|
||||
void setRestrictedRights(const MTPChatBannedRights &rights);
|
||||
bool hasRestrictions() const {
|
||||
return (restrictions() != 0);
|
||||
}
|
||||
bool hasRestrictions(TimeId now) const {
|
||||
return hasRestrictions()
|
||||
&& (restrictedUntil() > now);
|
||||
}
|
||||
bool canBanMembers() const;
|
||||
bool canEditMessages() const;
|
||||
bool canDeleteMessages() const;
|
||||
bool anyoneCanAddMembers() const;
|
||||
bool hiddenPreHistory() const;
|
||||
bool canAddMembers() const;
|
||||
bool canAddAdmins() const;
|
||||
bool canPublish() const;
|
||||
bool canWrite() const;
|
||||
bool canViewMembers() const;
|
||||
bool canViewAdmins() const;
|
||||
bool canViewBanned() const;
|
||||
bool canEditInformation() const;
|
||||
bool canEditInvites() const;
|
||||
bool canEditSignatures() const;
|
||||
bool canEditPreHistoryHidden() const;
|
||||
bool canEditUsername() const;
|
||||
bool canEditStickers() const;
|
||||
bool canDelete() const;
|
||||
bool canEditAdmin(not_null<UserData*> user) const;
|
||||
bool canRestrictUser(not_null<UserData*> user) const;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
bool canHaveInviteLink() const {
|
||||
return (adminRights() & AdminRight::f_invite_users)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
UserId inviter = 0; // > 0 - user who invited me to channel, < 0 - not in channel
|
||||
TimeId inviteDate = 0;
|
||||
|
||||
void ptsInit(int32 pts) {
|
||||
_ptsWaiter.init(pts);
|
||||
}
|
||||
void ptsReceived(int32 pts) {
|
||||
_ptsWaiter.updateAndApply(this, pts, 0);
|
||||
}
|
||||
bool ptsUpdateAndApply(int32 pts, int32 count) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, update);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, updates);
|
||||
}
|
||||
int32 pts() const {
|
||||
return _ptsWaiter.current();
|
||||
}
|
||||
bool ptsInited() const {
|
||||
return _ptsWaiter.inited();
|
||||
}
|
||||
bool ptsRequesting() const {
|
||||
return _ptsWaiter.requesting();
|
||||
}
|
||||
void ptsSetRequesting(bool isRequesting) {
|
||||
return _ptsWaiter.setRequesting(isRequesting);
|
||||
}
|
||||
void ptsWaitingForShortPoll(int32 ms) { // < 0 - not waiting
|
||||
return _ptsWaiter.setWaitingForShortPoll(this, ms);
|
||||
}
|
||||
bool ptsWaitingForSkipped() const {
|
||||
return _ptsWaiter.waitingForSkipped();
|
||||
}
|
||||
bool ptsWaitingForShortPoll() const {
|
||||
return _ptsWaiter.waitingForShortPoll();
|
||||
}
|
||||
|
||||
QString unavailableReason() const override;
|
||||
void setUnavailableReason(const QString &reason);
|
||||
|
||||
MsgId availableMinId() const {
|
||||
return _availableMinId;
|
||||
}
|
||||
void setAvailableMinId(MsgId availableMinId);
|
||||
|
||||
void setFeed(not_null<Data::Feed*> feed);
|
||||
void clearFeed();
|
||||
|
||||
Data::Feed *feed() const {
|
||||
return _feed;
|
||||
}
|
||||
|
||||
private:
|
||||
void flagsUpdated(MTPDchannel::Flags diff);
|
||||
void fullFlagsUpdated(MTPDchannelFull::Flags diff);
|
||||
|
||||
bool canEditLastAdmin(not_null<UserData*> user) const;
|
||||
void setFeedPointer(Data::Feed *feed);
|
||||
|
||||
Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0);
|
||||
FullFlags _fullFlags;
|
||||
|
||||
PtsWaiter _ptsWaiter;
|
||||
|
||||
int _membersCount = 1;
|
||||
int _adminsCount = 1;
|
||||
int _restrictedCount = 0;
|
||||
int _kickedCount = 0;
|
||||
MsgId _availableMinId = 0;
|
||||
|
||||
AdminRightFlags _adminRights;
|
||||
RestrictionFlags _restrictions;
|
||||
TimeId _restrictedUntill;
|
||||
|
||||
QString _unavailableReason;
|
||||
QString _about;
|
||||
|
||||
QString _inviteLink;
|
||||
Data::Feed *_feed = nullptr;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
inline bool isUser(const PeerData *peer) {
|
||||
return peer ? peer->isUser() : false;
|
||||
}
|
||||
inline UserData *PeerData::asUser() {
|
||||
return isUser() ? static_cast<UserData*>(this) : nullptr;
|
||||
}
|
||||
inline UserData *asUser(PeerData *peer) {
|
||||
return peer ? peer->asUser() : nullptr;
|
||||
}
|
||||
inline const UserData *PeerData::asUser() const {
|
||||
return isUser() ? static_cast<const UserData*>(this) : nullptr;
|
||||
}
|
||||
inline const UserData *asUser(const PeerData *peer) {
|
||||
return peer ? peer->asUser() : nullptr;
|
||||
}
|
||||
inline bool isChat(const PeerData *peer) {
|
||||
return peer ? peer->isChat() : false;
|
||||
}
|
||||
inline ChatData *PeerData::asChat() {
|
||||
return isChat() ? static_cast<ChatData*>(this) : nullptr;
|
||||
}
|
||||
inline ChatData *asChat(PeerData *peer) {
|
||||
return peer ? peer->asChat() : nullptr;
|
||||
}
|
||||
inline const ChatData *PeerData::asChat() const {
|
||||
return isChat() ? static_cast<const ChatData*>(this) : nullptr;
|
||||
}
|
||||
inline const ChatData *asChat(const PeerData *peer) {
|
||||
return peer ? peer->asChat() : nullptr;
|
||||
}
|
||||
inline bool isChannel(const PeerData *peer) {
|
||||
return peer ? peer->isChannel() : false;
|
||||
}
|
||||
inline ChannelData *PeerData::asChannel() {
|
||||
return isChannel() ? static_cast<ChannelData*>(this) : nullptr;
|
||||
}
|
||||
inline ChannelData *asChannel(PeerData *peer) {
|
||||
return peer ? peer->asChannel() : nullptr;
|
||||
}
|
||||
inline const ChannelData *PeerData::asChannel() const {
|
||||
return isChannel()
|
||||
? static_cast<const ChannelData*>(this)
|
||||
: nullptr;
|
||||
}
|
||||
inline const ChannelData *asChannel(const PeerData *peer) {
|
||||
return peer ? peer->asChannel() : nullptr;
|
||||
}
|
||||
inline ChannelData *PeerData::asMegagroup() {
|
||||
return isMegagroup() ? static_cast<ChannelData*>(this) : nullptr;
|
||||
}
|
||||
inline ChannelData *asMegagroup(PeerData *peer) {
|
||||
return peer ? peer->asMegagroup() : nullptr;
|
||||
}
|
||||
inline const ChannelData *PeerData::asMegagroup() const {
|
||||
return isMegagroup()
|
||||
? static_cast<const ChannelData*>(this)
|
||||
: nullptr;
|
||||
}
|
||||
inline const ChannelData *asMegagroup(const PeerData *peer) {
|
||||
return peer ? peer->asMegagroup() : nullptr;
|
||||
}
|
||||
inline bool isMegagroup(const PeerData *peer) {
|
||||
return peer ? peer->isMegagroup() : false;
|
||||
}
|
||||
inline ChatData *PeerData::migrateFrom() const {
|
||||
if (const auto megagroup = asMegagroup()) {
|
||||
return megagroup->amIn()
|
||||
? megagroup->mgInfo->migrateFromPtr
|
||||
: nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
inline ChannelData *PeerData::migrateTo() const {
|
||||
if (const auto chat = asChat()) {
|
||||
if (const auto migrateTo = chat->migrateToPtr) {
|
||||
return migrateTo->amIn() ? migrateTo : nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
inline Data::Feed *PeerData::feed() const {
|
||||
if (const auto channel = asChannel()) {
|
||||
return channel->feed();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
inline const Text &PeerData::dialogName() const {
|
||||
return migrateTo()
|
||||
? migrateTo()->dialogName()
|
||||
: (isUser() && !asUser()->phoneText.isEmpty())
|
||||
? asUser()->phoneText
|
||||
: nameText;
|
||||
}
|
||||
inline const QString &PeerData::shortName() const {
|
||||
return isUser() ? asUser()->firstName : name;
|
||||
}
|
||||
inline QString PeerData::userName() const {
|
||||
return isUser()
|
||||
? asUser()->username
|
||||
: isChannel()
|
||||
? asChannel()->username
|
||||
: QString();
|
||||
}
|
||||
inline bool PeerData::isVerified() const {
|
||||
return isUser()
|
||||
? asUser()->isVerified()
|
||||
: isChannel()
|
||||
? asChannel()->isVerified()
|
||||
: false;
|
||||
}
|
||||
inline bool PeerData::isMegagroup() const {
|
||||
return isChannel() ? asChannel()->isMegagroup() : false;
|
||||
}
|
||||
inline bool PeerData::canWrite() const {
|
||||
return isChannel()
|
||||
? asChannel()->canWrite()
|
||||
: isChat()
|
||||
? asChat()->canWrite()
|
||||
: isUser()
|
||||
? asUser()->canWrite()
|
||||
: false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer_values.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
namespace Data {
|
||||
namespace {
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo.h"
|
||||
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/image/image_source.h"
|
||||
#include "mainwidget.h"
|
||||
|
|
159
Telegram/SourceFiles/data/data_pts_waiter.cpp
Normal file
159
Telegram/SourceFiles/data/data_pts_waiter.cpp
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_pts_waiter.h"
|
||||
|
||||
#include "mainwidget.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
uint64 PtsWaiter::ptsKey(PtsSkippedQueue queue, int32 pts) {
|
||||
return _queue.insert(uint64(uint32(pts)) << 32 | (++_skippedKey), queue).key();
|
||||
}
|
||||
|
||||
void PtsWaiter::setWaitingForSkipped(ChannelData *channel, int32 ms) {
|
||||
if (ms >= 0) {
|
||||
if (App::main()) {
|
||||
App::main()->ptsWaiterStartTimerFor(channel, ms);
|
||||
}
|
||||
_waitingForSkipped = true;
|
||||
} else {
|
||||
_waitingForSkipped = false;
|
||||
checkForWaiting(channel);
|
||||
}
|
||||
}
|
||||
|
||||
void PtsWaiter::setWaitingForShortPoll(ChannelData *channel, int32 ms) {
|
||||
if (ms >= 0) {
|
||||
if (App::main()) {
|
||||
App::main()->ptsWaiterStartTimerFor(channel, ms);
|
||||
}
|
||||
_waitingForShortPoll = true;
|
||||
} else {
|
||||
_waitingForShortPoll = false;
|
||||
checkForWaiting(channel);
|
||||
}
|
||||
}
|
||||
|
||||
void PtsWaiter::checkForWaiting(ChannelData *channel) {
|
||||
if (!_waitingForSkipped && !_waitingForShortPoll && App::main()) {
|
||||
App::main()->ptsWaiterStartTimerFor(channel, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void PtsWaiter::applySkippedUpdates(ChannelData *channel) {
|
||||
if (!_waitingForSkipped) return;
|
||||
|
||||
setWaitingForSkipped(channel, -1);
|
||||
|
||||
if (_queue.isEmpty()) return;
|
||||
|
||||
++_applySkippedLevel;
|
||||
for (auto i = _queue.cbegin(), e = _queue.cend(); i != e; ++i) {
|
||||
switch (i.value()) {
|
||||
case SkippedUpdate: Auth().api().applyUpdateNoPtsCheck(_updateQueue.value(i.key())); break;
|
||||
case SkippedUpdates: Auth().api().applyUpdatesNoPtsCheck(_updatesQueue.value(i.key())); break;
|
||||
}
|
||||
}
|
||||
--_applySkippedLevel;
|
||||
clearSkippedUpdates();
|
||||
}
|
||||
|
||||
void PtsWaiter::clearSkippedUpdates() {
|
||||
_queue.clear();
|
||||
_updateQueue.clear();
|
||||
_updatesQueue.clear();
|
||||
_applySkippedLevel = 0;
|
||||
}
|
||||
|
||||
bool PtsWaiter::updated(ChannelData *channel, int32 pts, int32 count, const MTPUpdates &updates) {
|
||||
if (_requesting || _applySkippedLevel) {
|
||||
return true;
|
||||
} else if (pts <= _good && count > 0) {
|
||||
return false;
|
||||
} else if (check(channel, pts, count)) {
|
||||
return true;
|
||||
}
|
||||
_updatesQueue.insert(ptsKey(SkippedUpdates, pts), updates);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PtsWaiter::updated(ChannelData *channel, int32 pts, int32 count, const MTPUpdate &update) {
|
||||
if (_requesting || _applySkippedLevel) {
|
||||
return true;
|
||||
} else if (pts <= _good && count > 0) {
|
||||
return false;
|
||||
} else if (check(channel, pts, count)) {
|
||||
return true;
|
||||
}
|
||||
_updateQueue.insert(ptsKey(SkippedUpdate, pts), update);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PtsWaiter::updated(ChannelData *channel, int32 pts, int32 count) {
|
||||
if (_requesting || _applySkippedLevel) {
|
||||
return true;
|
||||
} else if (pts <= _good && count > 0) {
|
||||
return false;
|
||||
}
|
||||
return check(channel, pts, count);
|
||||
}
|
||||
|
||||
bool PtsWaiter::updateAndApply(ChannelData *channel, int32 pts, int32 count, const MTPUpdates &updates) {
|
||||
if (!updated(channel, pts, count, updates)) {
|
||||
return false;
|
||||
}
|
||||
if (!_waitingForSkipped || _queue.isEmpty()) {
|
||||
// Optimization - no need to put in queue and back.
|
||||
Auth().api().applyUpdatesNoPtsCheck(updates);
|
||||
} else {
|
||||
_updatesQueue.insert(ptsKey(SkippedUpdates, pts), updates);
|
||||
applySkippedUpdates(channel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PtsWaiter::updateAndApply(ChannelData *channel, int32 pts, int32 count, const MTPUpdate &update) {
|
||||
if (!updated(channel, pts, count, update)) {
|
||||
return false;
|
||||
}
|
||||
if (!_waitingForSkipped || _queue.isEmpty()) {
|
||||
// Optimization - no need to put in queue and back.
|
||||
Auth().api().applyUpdateNoPtsCheck(update);
|
||||
} else {
|
||||
_updateQueue.insert(ptsKey(SkippedUpdate, pts), update);
|
||||
applySkippedUpdates(channel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PtsWaiter::updateAndApply(ChannelData *channel, int32 pts, int32 count) {
|
||||
if (!updated(channel, pts, count)) {
|
||||
return false;
|
||||
}
|
||||
applySkippedUpdates(channel);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PtsWaiter::check(ChannelData *channel, int32 pts, int32 count) { // return false if need to save that update and apply later
|
||||
if (!inited()) {
|
||||
init(pts);
|
||||
return true;
|
||||
}
|
||||
|
||||
_last = qMax(_last, pts);
|
||||
_count += count;
|
||||
if (_last == _count) {
|
||||
_good = _last;
|
||||
return true;
|
||||
} else if (_last < _count) {
|
||||
setWaitingForSkipped(channel, 1);
|
||||
} else {
|
||||
setWaitingForSkipped(channel, WaitForSkippedTimeout);
|
||||
}
|
||||
return !count;
|
||||
}
|
95
Telegram/SourceFiles/data/data_pts_waiter.h
Normal file
95
Telegram/SourceFiles/data/data_pts_waiter.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
enum PtsSkippedQueue {
|
||||
SkippedUpdate,
|
||||
SkippedUpdates,
|
||||
};
|
||||
|
||||
class PtsWaiter {
|
||||
public:
|
||||
PtsWaiter() = default;
|
||||
void init(int32 pts) {
|
||||
_good = _last = _count = pts;
|
||||
clearSkippedUpdates();
|
||||
}
|
||||
bool inited() const {
|
||||
return _good > 0;
|
||||
}
|
||||
void setRequesting(bool isRequesting) {
|
||||
_requesting = isRequesting;
|
||||
if (_requesting) {
|
||||
clearSkippedUpdates();
|
||||
}
|
||||
}
|
||||
bool requesting() const {
|
||||
return _requesting;
|
||||
}
|
||||
bool waitingForSkipped() const {
|
||||
return _waitingForSkipped;
|
||||
}
|
||||
bool waitingForShortPoll() const {
|
||||
return _waitingForShortPoll;
|
||||
}
|
||||
void setWaitingForSkipped(ChannelData *channel, int32 ms); // < 0 - not waiting
|
||||
void setWaitingForShortPoll(ChannelData *channel, int32 ms); // < 0 - not waiting
|
||||
int32 current() const{
|
||||
return _good;
|
||||
}
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates);
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update);
|
||||
bool updated(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update);
|
||||
bool updateAndApply(
|
||||
ChannelData *channel,
|
||||
int32 pts,
|
||||
int32 count);
|
||||
void applySkippedUpdates(ChannelData *channel);
|
||||
void clearSkippedUpdates();
|
||||
|
||||
private:
|
||||
// Return false if need to save that update and apply later.
|
||||
bool check(ChannelData *channel, int32 pts, int32 count);
|
||||
|
||||
uint64 ptsKey(PtsSkippedQueue queue, int32 pts);
|
||||
void checkForWaiting(ChannelData *channel);
|
||||
|
||||
QMap<uint64, PtsSkippedQueue> _queue;
|
||||
QMap<uint64, MTPUpdate> _updateQueue;
|
||||
QMap<uint64, MTPUpdates> _updatesQueue;
|
||||
int32 _good = 0;
|
||||
int32 _last = 0;
|
||||
int32 _count = 0;
|
||||
int32 _applySkippedLevel = 0;
|
||||
bool _requesting = false;
|
||||
bool _waitingForSkipped = false;
|
||||
bool _waitingForShortPoll = false;
|
||||
uint32 _skippedKey = 0;
|
||||
|
||||
};
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "auth_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_messages.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h" // for lang(lng_deleted) in user name.
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_web_page.h"
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/stickers.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "data/data_groups.h"
|
||||
#include "data/data_notify_settings.h"
|
||||
#include "history/history_location_manager.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
|
|
|
@ -82,6 +82,12 @@ class PeerData;
|
|||
class UserData;
|
||||
class ChatData;
|
||||
class ChannelData;
|
||||
class BotCommand;
|
||||
struct BotInfo;
|
||||
|
||||
namespace Data {
|
||||
class Feed;
|
||||
} // namespace Data
|
||||
|
||||
using UserId = int32;
|
||||
using ChatId = int32;
|
||||
|
|
260
Telegram/SourceFiles/data/data_user.cpp
Normal file
260
Telegram/SourceFiles/data/data_user.cpp
Normal file
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_user.h"
|
||||
|
||||
#include "observer_peer.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_session.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
} // namespace
|
||||
|
||||
BotCommand::BotCommand(
|
||||
const QString &command,
|
||||
const QString &description)
|
||||
: command(command)
|
||||
, _description(description) {
|
||||
}
|
||||
|
||||
bool BotCommand::setDescription(const QString &description) {
|
||||
if (_description != description) {
|
||||
_description = description;
|
||||
_descriptionText = Text();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const Text &BotCommand::descriptionText() const {
|
||||
if (_descriptionText.isEmpty() && !_description.isEmpty()) {
|
||||
_descriptionText.setText(
|
||||
st::defaultTextStyle,
|
||||
_description,
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
return _descriptionText;
|
||||
}
|
||||
|
||||
UserData::UserData(not_null<Data::Session*> owner, PeerId id)
|
||||
: PeerData(owner, id) {
|
||||
}
|
||||
|
||||
bool UserData::canShareThisContact() const {
|
||||
return canShareThisContactFast()
|
||||
|| !owner().findContactPhone(peerToUser(id)).isEmpty();
|
||||
}
|
||||
|
||||
void UserData::setContactStatus(ContactStatus status) {
|
||||
if (_contactStatus != status) {
|
||||
const auto changed = (_contactStatus == ContactStatus::Contact)
|
||||
!= (status == ContactStatus::Contact);
|
||||
_contactStatus = status;
|
||||
if (changed) {
|
||||
Notify::peerUpdatedDelayed(
|
||||
this,
|
||||
Notify::PeerUpdate::Flag::UserIsContact);
|
||||
}
|
||||
}
|
||||
if (_contactStatus == ContactStatus::Contact
|
||||
&& cReportSpamStatuses().value(id, dbiprsHidden) != dbiprsHidden) {
|
||||
cRefReportSpamStatuses().insert(id, dbiprsHidden);
|
||||
Local::writeReportSpamStatuses();
|
||||
}
|
||||
}
|
||||
|
||||
// see Local::readPeer as well
|
||||
void UserData::setPhoto(const MTPUserProfilePhoto &photo) {
|
||||
if (photo.type() == mtpc_userProfilePhoto) {
|
||||
const auto &data = photo.c_userProfilePhoto();
|
||||
updateUserpic(data.vphoto_id.v, data.vphoto_small);
|
||||
} else {
|
||||
clearUserpic();
|
||||
}
|
||||
}
|
||||
|
||||
bool UserData::setAbout(const QString &newAbout) {
|
||||
if (_about == newAbout) {
|
||||
return false;
|
||||
}
|
||||
_about = newAbout;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::AboutChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString UserData::unavailableReason() const {
|
||||
return _unavailableReason;
|
||||
}
|
||||
|
||||
void UserData::setUnavailableReason(const QString &text) {
|
||||
if (_unavailableReason != text) {
|
||||
_unavailableReason = text;
|
||||
Notify::peerUpdatedDelayed(
|
||||
this,
|
||||
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setCommonChatsCount(int count) {
|
||||
if (_commonChatsCount != count) {
|
||||
_commonChatsCount = count;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserCommonChatsChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setName(const QString &newFirstName, const QString &newLastName, const QString &newPhoneName, const QString &newUsername) {
|
||||
bool changeName = !newFirstName.isEmpty() || !newLastName.isEmpty();
|
||||
|
||||
QString newFullName;
|
||||
if (changeName && newFirstName.trimmed().isEmpty()) {
|
||||
firstName = newLastName;
|
||||
lastName = QString();
|
||||
newFullName = firstName;
|
||||
} else {
|
||||
if (changeName) {
|
||||
firstName = newFirstName;
|
||||
lastName = newLastName;
|
||||
}
|
||||
newFullName = lastName.isEmpty() ? firstName : lng_full_name(lt_first_name, firstName, lt_last_name, lastName);
|
||||
}
|
||||
updateNameDelayed(newFullName, newPhoneName, newUsername);
|
||||
}
|
||||
|
||||
void UserData::setPhone(const QString &newPhone) {
|
||||
if (_phone != newPhone) {
|
||||
_phone = newPhone;
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setBotInfoVersion(int version) {
|
||||
if (version < 0) {
|
||||
if (botInfo) {
|
||||
if (!botInfo->commands.isEmpty()) {
|
||||
botInfo->commands.clear();
|
||||
Notify::botCommandsChanged(this);
|
||||
}
|
||||
botInfo = nullptr;
|
||||
Notify::userIsBotChanged(this);
|
||||
}
|
||||
} else if (!botInfo) {
|
||||
botInfo = std::make_unique<BotInfo>();
|
||||
botInfo->version = version;
|
||||
Notify::userIsBotChanged(this);
|
||||
} else if (botInfo->version < version) {
|
||||
if (!botInfo->commands.isEmpty()) {
|
||||
botInfo->commands.clear();
|
||||
Notify::botCommandsChanged(this);
|
||||
}
|
||||
botInfo->description.clear();
|
||||
botInfo->version = version;
|
||||
botInfo->inited = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||
switch (info.type()) {
|
||||
case mtpc_botInfo: {
|
||||
const auto &d(info.c_botInfo());
|
||||
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);
|
||||
}
|
||||
|
||||
auto &v = d.vcommands.v;
|
||||
botInfo->commands.reserve(v.size());
|
||||
auto changedCommands = false;
|
||||
int32 j = 0;
|
||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
||||
if (v.at(i).type() != mtpc_botCommand) continue;
|
||||
|
||||
QString cmd = qs(v.at(i).c_botCommand().vcommand), desc = qs(v.at(i).c_botCommand().vdescription);
|
||||
if (botInfo->commands.size() <= j) {
|
||||
botInfo->commands.push_back(BotCommand(cmd, desc));
|
||||
changedCommands = true;
|
||||
} else {
|
||||
if (botInfo->commands[j].command != cmd) {
|
||||
botInfo->commands[j].command = cmd;
|
||||
changedCommands = true;
|
||||
}
|
||||
if (botInfo->commands[j].setDescription(desc)) {
|
||||
changedCommands = true;
|
||||
}
|
||||
}
|
||||
++j;
|
||||
}
|
||||
while (j < botInfo->commands.size()) {
|
||||
botInfo->commands.pop_back();
|
||||
changedCommands = true;
|
||||
}
|
||||
|
||||
botInfo->inited = true;
|
||||
|
||||
if (changedCommands) {
|
||||
Notify::botCommandsChanged(this);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setNameOrPhone(const QString &newNameOrPhone) {
|
||||
if (nameOrPhone != newNameOrPhone) {
|
||||
nameOrPhone = newNameOrPhone;
|
||||
phoneText.setText(
|
||||
st::msgNameStyle,
|
||||
nameOrPhone,
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::madeAction(TimeId when) {
|
||||
if (botInfo || isServiceUser(id) || when <= 0) return;
|
||||
|
||||
if (onlineTill <= 0 && -onlineTill < when) {
|
||||
onlineTill = -when - SetOnlineAfterActivity;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
||||
} else if (onlineTill > 0 && onlineTill < when + 1) {
|
||||
onlineTill = when + SetOnlineAfterActivity;
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setAccessHash(uint64 accessHash) {
|
||||
if (accessHash == kInaccessibleAccessHashOld) {
|
||||
_accessHash = 0;
|
||||
// _flags.add(MTPDuser_ClientFlag::f_inaccessible | 0);
|
||||
_flags.add(MTPDuser::Flag::f_deleted);
|
||||
} else {
|
||||
_accessHash = accessHash;
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setBlockStatus(BlockStatus blockStatus) {
|
||||
if (blockStatus != _blockStatus) {
|
||||
_blockStatus = blockStatus;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserIsBlocked);
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::setCallsStatus(CallsStatus callsStatus) {
|
||||
if (callsStatus != _callsStatus) {
|
||||
_callsStatus = callsStatus;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserHasCalls);
|
||||
}
|
||||
}
|
||||
|
||||
bool UserData::hasCalls() const {
|
||||
return (callsStatus() != CallsStatus::Disabled)
|
||||
&& (callsStatus() != CallsStatus::Unknown);
|
||||
}
|
229
Telegram/SourceFiles/data/data_user.h
Normal file
229
Telegram/SourceFiles/data/data_user.h
Normal file
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_peer.h"
|
||||
|
||||
class BotCommand {
|
||||
public:
|
||||
BotCommand(const QString &command, const QString &description);
|
||||
|
||||
bool setDescription(const QString &description);
|
||||
const Text &descriptionText() const;
|
||||
|
||||
QString command;
|
||||
|
||||
private:
|
||||
QString _description;
|
||||
mutable Text _descriptionText;
|
||||
|
||||
};
|
||||
|
||||
struct BotInfo {
|
||||
bool inited = false;
|
||||
bool readsAllHistory = false;
|
||||
bool cantJoinGroups = false;
|
||||
int version = 0;
|
||||
QString description, inlinePlaceholder;
|
||||
QList<BotCommand> commands;
|
||||
Text text = Text{ int(st::msgMinWidth) }; // description
|
||||
|
||||
QString startToken, startGroupToken, shareGameShortName;
|
||||
PeerId inlineReturnPeerId = 0;
|
||||
};
|
||||
|
||||
class UserData : public PeerData {
|
||||
public:
|
||||
static constexpr auto kEssentialFlags = 0
|
||||
| MTPDuser::Flag::f_self
|
||||
| MTPDuser::Flag::f_contact
|
||||
| MTPDuser::Flag::f_mutual_contact
|
||||
| MTPDuser::Flag::f_deleted
|
||||
| MTPDuser::Flag::f_bot
|
||||
| MTPDuser::Flag::f_bot_chat_history
|
||||
| MTPDuser::Flag::f_bot_nochats
|
||||
| MTPDuser::Flag::f_verified
|
||||
| MTPDuser::Flag::f_restricted
|
||||
| MTPDuser::Flag::f_bot_inline_geo;
|
||||
using Flags = Data::Flags<
|
||||
MTPDuser::Flags,
|
||||
kEssentialFlags.value()>;
|
||||
|
||||
static constexpr auto kEssentialFullFlags = 0
|
||||
| MTPDuserFull::Flag::f_blocked
|
||||
| MTPDuserFull::Flag::f_phone_calls_available
|
||||
| MTPDuserFull::Flag::f_phone_calls_private;
|
||||
using FullFlags = Data::Flags<
|
||||
MTPDuserFull::Flags,
|
||||
kEssentialFullFlags.value()>;
|
||||
|
||||
UserData(not_null<Data::Session*> owner, PeerId id);
|
||||
void setPhoto(const MTPUserProfilePhoto &photo);
|
||||
|
||||
void setName(
|
||||
const QString &newFirstName,
|
||||
const QString &newLastName,
|
||||
const QString &newPhoneName,
|
||||
const QString &newUsername);
|
||||
|
||||
void setPhone(const QString &newPhone);
|
||||
void setBotInfoVersion(int version);
|
||||
void setBotInfo(const MTPBotInfo &info);
|
||||
|
||||
void setNameOrPhone(const QString &newNameOrPhone);
|
||||
|
||||
void madeAction(TimeId when); // pseudo-online
|
||||
|
||||
uint64 accessHash() const {
|
||||
return _accessHash;
|
||||
}
|
||||
void setAccessHash(uint64 accessHash);
|
||||
|
||||
void setFlags(MTPDuser::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
void addFlags(MTPDuser::Flags which) {
|
||||
_flags.add(which);
|
||||
}
|
||||
void removeFlags(MTPDuser::Flags which) {
|
||||
_flags.remove(which);
|
||||
}
|
||||
auto flags() const {
|
||||
return _flags.current();
|
||||
}
|
||||
auto flagsValue() const {
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
void setFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.set(which);
|
||||
}
|
||||
void addFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.add(which);
|
||||
}
|
||||
void removeFullFlags(MTPDuserFull::Flags which) {
|
||||
_fullFlags.remove(which);
|
||||
}
|
||||
auto fullFlags() const {
|
||||
return _fullFlags.current();
|
||||
}
|
||||
auto fullFlagsValue() const {
|
||||
return _fullFlags.value();
|
||||
}
|
||||
|
||||
bool isVerified() const {
|
||||
return flags() & MTPDuser::Flag::f_verified;
|
||||
}
|
||||
bool isBotInlineGeo() const {
|
||||
return flags() & MTPDuser::Flag::f_bot_inline_geo;
|
||||
}
|
||||
bool isInaccessible() const {
|
||||
constexpr auto inaccessible = 0
|
||||
| MTPDuser::Flag::f_deleted;
|
||||
// | MTPDuser_ClientFlag::f_inaccessible;
|
||||
return flags() & inaccessible;
|
||||
}
|
||||
bool canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !isInaccessible();
|
||||
}
|
||||
bool isContact() const {
|
||||
return (_contactStatus == ContactStatus::Contact);
|
||||
}
|
||||
|
||||
bool canShareThisContact() const;
|
||||
bool canAddContact() const {
|
||||
return canShareThisContact() && !isContact();
|
||||
}
|
||||
|
||||
// In feedUsers() we check only that.
|
||||
// When actually trying to share contact we perform
|
||||
// a full check by canShareThisContact() call.
|
||||
bool canShareThisContactFast() const {
|
||||
return !_phone.isEmpty();
|
||||
}
|
||||
|
||||
MTPInputUser inputUser;
|
||||
|
||||
QString firstName;
|
||||
QString lastName;
|
||||
QString username;
|
||||
const QString &phone() const {
|
||||
return _phone;
|
||||
}
|
||||
QString nameOrPhone;
|
||||
Text phoneText;
|
||||
TimeId onlineTill = 0;
|
||||
|
||||
enum class ContactStatus : char {
|
||||
PhoneUnknown,
|
||||
CanAdd,
|
||||
Contact,
|
||||
};
|
||||
ContactStatus contactStatus() const {
|
||||
return _contactStatus;
|
||||
}
|
||||
void setContactStatus(ContactStatus status);
|
||||
|
||||
enum class BlockStatus : char {
|
||||
Unknown,
|
||||
Blocked,
|
||||
NotBlocked,
|
||||
};
|
||||
BlockStatus blockStatus() const {
|
||||
return _blockStatus;
|
||||
}
|
||||
bool isBlocked() const {
|
||||
return (blockStatus() == BlockStatus::Blocked);
|
||||
}
|
||||
void setBlockStatus(BlockStatus blockStatus);
|
||||
|
||||
enum class CallsStatus : char {
|
||||
Unknown,
|
||||
Enabled,
|
||||
Disabled,
|
||||
Private,
|
||||
};
|
||||
CallsStatus callsStatus() const {
|
||||
return _callsStatus;
|
||||
}
|
||||
bool hasCalls() const;
|
||||
void setCallsStatus(CallsStatus callsStatus);
|
||||
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
return _about;
|
||||
}
|
||||
|
||||
std::unique_ptr<BotInfo> botInfo;
|
||||
|
||||
QString unavailableReason() const override;
|
||||
void setUnavailableReason(const QString &reason);
|
||||
|
||||
int commonChatsCount() const {
|
||||
return _commonChatsCount;
|
||||
}
|
||||
void setCommonChatsCount(int count);
|
||||
|
||||
private:
|
||||
Flags _flags;
|
||||
FullFlags _fullFlags;
|
||||
|
||||
QString _unavailableReason;
|
||||
QString _about;
|
||||
QString _phone;
|
||||
ContactStatus _contactStatus = ContactStatus::PhoneUnknown;
|
||||
BlockStatus _blockStatus = BlockStatus::Unknown;
|
||||
CallsStatus _callsStatus = CallsStatus::Unknown;
|
||||
int _commonChatsCount = 0;
|
||||
|
||||
uint64 _accessHash = 0;
|
||||
static constexpr auto kInaccessibleAccessHashOld
|
||||
= 0xFFFFFFFFFFFFFFFFULL;
|
||||
|
||||
};
|
|
@ -20,6 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_drafts.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
|
|
|
@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "support/support_helper.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
namespace Dialogs {
|
||||
namespace Layout {
|
||||
|
|
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "observer_peer.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
|
|
|
@ -33,6 +33,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/storage_media_prepare.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/media_clip_reader.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_user.h"
|
||||
#include "observer_peer.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
|
@ -236,6 +238,9 @@ void showPeerProfile(const PeerId &peer) {
|
|||
}
|
||||
}
|
||||
}
|
||||
void showPeerProfile(const PeerData *peer) {
|
||||
showPeerProfile(peer->id);
|
||||
}
|
||||
|
||||
void showPeerProfile(not_null<const History*> history) {
|
||||
showPeerProfile(history->peer->id);
|
||||
|
@ -261,6 +266,10 @@ void showPeerHistory(not_null<const History*> history, MsgId msgId) {
|
|||
showPeerHistory(history->peer->id, msgId);
|
||||
}
|
||||
|
||||
void showPeerHistory(const PeerData *peer, MsgId msgId) {
|
||||
showPeerHistory(peer->id, msgId);
|
||||
}
|
||||
|
||||
PeerData *getPeerForMouseAction() {
|
||||
return Messenger::Instance().ui_getPeerForMouseAction();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
class BoxContent;
|
||||
|
||||
namespace Data {
|
||||
struct FileOrigin;
|
||||
} // namespace Data
|
||||
|
||||
namespace Dialogs {
|
||||
enum class Mode;
|
||||
} // namespace Dialogs
|
||||
|
@ -113,17 +117,13 @@ void hideSettingsAndLayer(anim::type animated = anim::type::normal);
|
|||
bool isLayerShown();
|
||||
|
||||
void showPeerProfile(const PeerId &peer);
|
||||
inline void showPeerProfile(const PeerData *peer) {
|
||||
showPeerProfile(peer->id);
|
||||
}
|
||||
void showPeerProfile(const PeerData *peer);
|
||||
void showPeerProfile(not_null<const History*> history);
|
||||
|
||||
void showPeerHistory(const PeerId &peer, MsgId msgId);
|
||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
||||
|
||||
inline void showPeerHistory(const PeerData *peer, MsgId msgId) {
|
||||
showPeerHistory(peer->id, msgId);
|
||||
}
|
||||
void showPeerHistory(const PeerData *peer, MsgId msgId);
|
||||
void showPeerHistory(not_null<const History*> history, MsgId msgId);
|
||||
inline void showChatsList() {
|
||||
showPeerHistory(PeerId(0), 0);
|
||||
|
|
|
@ -7,11 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/admin_log/history_admin_log_filter.h"
|
||||
|
||||
#include "styles/style_boxes.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace AdminLog {
|
||||
namespace {
|
||||
|
|
|
@ -39,6 +39,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
namespace AdminLog {
|
||||
namespace {
|
||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_service.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/history.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/sticker_set_box.h"
|
||||
|
@ -151,12 +153,17 @@ const auto CollectChanges = [](auto &phraseMap, auto plusFlags, auto minusFlags)
|
|||
return withPrefix(plusFlags & ~minusFlags, '+') + withPrefix(minusFlags & ~plusFlags, kMinus);
|
||||
};
|
||||
|
||||
auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntities &user, const MTPChatAdminRights *newRights, const MTPChatAdminRights *prevRights) {
|
||||
TextWithEntities GenerateAdminChangeText(
|
||||
not_null<ChannelData*> channel,
|
||||
const TextWithEntities &user,
|
||||
const MTPChatAdminRights *newRights,
|
||||
const MTPChatAdminRights *prevRights) {
|
||||
Expects(!newRights || newRights->type() == mtpc_chatAdminRights);
|
||||
Expects(!prevRights || prevRights->type() == mtpc_chatAdminRights);
|
||||
|
||||
using Flag = MTPDchatAdminRights::Flag;
|
||||
using Flags = MTPDchatAdminRights::Flags;
|
||||
|
||||
Expects(!newRights || newRights->type() == mtpc_chatAdminRights);
|
||||
Expects(!prevRights || prevRights->type() == mtpc_chatAdminRights);
|
||||
auto newFlags = newRights ? newRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
|
||||
auto prevFlags = prevRights ? prevRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
|
||||
auto result = lng_admin_log_promoted__generic(lt_user, user);
|
||||
|
@ -189,12 +196,16 @@ auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntit
|
|||
return result;
|
||||
};
|
||||
|
||||
auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChatBannedRights *newRights, const MTPChatBannedRights *prevRights) {
|
||||
TextWithEntities GenerateBannedChangeText(
|
||||
const TextWithEntities &user,
|
||||
const MTPChatBannedRights *newRights,
|
||||
const MTPChatBannedRights *prevRights) {
|
||||
Expects(!newRights || newRights->type() == mtpc_chatBannedRights);
|
||||
Expects(!prevRights || prevRights->type() == mtpc_chatBannedRights);
|
||||
|
||||
using Flag = MTPDchatBannedRights::Flag;
|
||||
using Flags = MTPDchatBannedRights::Flags;
|
||||
|
||||
Expects(!newRights || newRights->type() == mtpc_chatBannedRights);
|
||||
Expects(!prevRights || prevRights->type() == mtpc_chatBannedRights);
|
||||
auto newFlags = newRights ? newRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
|
||||
auto prevFlags = prevRights ? prevRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
|
||||
auto newUntil = newRights ? newRights->c_chatBannedRights().vuntil_date.v : TimeId(0);
|
||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/window_controller.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "base/timer.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_history.h"
|
||||
#include "styles/style_window.h"
|
||||
|
|
|
@ -33,6 +33,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_channel_admins.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "core/crash_reports.h"
|
||||
|
|
|
@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_document.h"
|
||||
#include "data/data_poll.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_user.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_message.h"
|
||||
#include "history/history.h"
|
||||
#include "media/media_clip_reader.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_history.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "storage/file_upload.h"
|
||||
|
@ -37,6 +35,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_messages.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/player/media_player_instance.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_media_types.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "data/data_groups.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/text_options.h"
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwidget.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "platform/platform_specific.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -30,6 +30,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "data/data_game.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_history.h"
|
||||
|
|
|
@ -21,6 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_game.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
|
@ -524,6 +526,14 @@ std::unique_ptr<HistoryView::Element> HistoryService::createView(
|
|||
return delegate->elementCreate(this);
|
||||
}
|
||||
|
||||
QString HistoryService::fromLinkText() const {
|
||||
return textcmdLink(1, _from->name);
|
||||
}
|
||||
|
||||
ClickHandlerPtr HistoryService::fromLink() const {
|
||||
return _from->createOpenLink();
|
||||
}
|
||||
|
||||
void HistoryService::setServiceText(const PreparedText &prepared) {
|
||||
_text.setText(
|
||||
st::serviceTextStyle,
|
||||
|
|
|
@ -111,12 +111,8 @@ protected:
|
|||
|
||||
void setServiceText(const PreparedText &prepared);
|
||||
|
||||
QString fromLinkText() const {
|
||||
return textcmdLink(1, _from->name);
|
||||
};
|
||||
ClickHandlerPtr fromLink() const {
|
||||
return _from->createOpenLink();
|
||||
};
|
||||
QString fromLinkText() const;
|
||||
ClickHandlerPtr fromLink() const;
|
||||
|
||||
void removeMedia();
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_document.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_message.h"
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/empty_userpic.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "history/media/history_media.h"
|
||||
|
||||
namespace Ui {
|
||||
class EmptyUserpic;
|
||||
} // namespace Ui
|
||||
|
||||
class HistoryContact : public HistoryMedia {
|
||||
public:
|
||||
HistoryContact(
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/grouped_layout.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/grouped_layout.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_media_types.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_media_types.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_groups.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_feed.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace HistoryView {
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/media/history_media_web_page.h"
|
||||
#include "history/history.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
|
|
|
@ -31,6 +31,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer_values.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "support/support_helper.h"
|
||||
#include "observer_peer.h"
|
||||
#include "apiwrap.h"
|
||||
|
|
|
@ -10,13 +10,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/common_groups/info_common_groups_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/search_field_controller.h"
|
||||
#include "data/data_user.h"
|
||||
#include "apiwrap.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Info {
|
||||
namespace CommonGroups {
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/info_controller.h"
|
||||
#include "ui/search_field_controller.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "history/history.h"
|
||||
|
|
|
@ -15,6 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/info_memento.h"
|
||||
#include "info/media/info_media_widget.h"
|
||||
#include "observer_peer.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace Info {
|
||||
|
@ -24,7 +27,7 @@ not_null<PeerData*> CorrectPeer(PeerId peerId) {
|
|||
Expects(peerId != 0);
|
||||
|
||||
auto result = App::peer(peerId);
|
||||
if (auto to = result->migrateTo()) {
|
||||
if (const auto to = result->migrateTo()) {
|
||||
return to;
|
||||
}
|
||||
return result;
|
||||
|
@ -81,6 +84,20 @@ rpl::producer<QString> AbstractController::mediaSourceQueryValue() const {
|
|||
return rpl::single(QString());
|
||||
}
|
||||
|
||||
PeerId AbstractController::peerId() const {
|
||||
if (const auto peer = key().peer()) {
|
||||
return peer->id;
|
||||
}
|
||||
return PeerId(0);
|
||||
}
|
||||
|
||||
PeerId AbstractController::migratedPeerId() const {
|
||||
if (const auto peer = migrated()) {
|
||||
return peer->id;
|
||||
}
|
||||
return PeerId(0);
|
||||
}
|
||||
|
||||
void AbstractController::showSection(
|
||||
Window::SectionMemento &&memento,
|
||||
const Window::SectionShow ¶ms) {
|
||||
|
|
|
@ -107,18 +107,8 @@ public:
|
|||
virtual PeerData *migrated() const = 0;
|
||||
virtual Section section() const = 0;
|
||||
|
||||
PeerId peerId() const {
|
||||
if (const auto peer = key().peer()) {
|
||||
return peer->id;
|
||||
}
|
||||
return PeerId(0);
|
||||
}
|
||||
PeerId migratedPeerId() const {
|
||||
if (auto peer = migrated()) {
|
||||
return peer->id;
|
||||
}
|
||||
return PeerId(0);
|
||||
}
|
||||
PeerId peerId() const;
|
||||
PeerId migratedPeerId() const;
|
||||
Data::Feed *feed() const {
|
||||
return key().feed();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/info_layer_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
|
||||
namespace Info {
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <rpl/never.h>
|
||||
#include <rpl/merge.h>
|
||||
#include "styles/style_info.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "info/info_wrap_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
|
@ -26,6 +25,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/search_field_controller.h"
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "auth_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "mainwidget.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_info.h"
|
||||
|
|
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer_values.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
|
|
|
@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <rpl/combine.h>
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "info/info_memento.h"
|
||||
|
|
|
@ -24,12 +24,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/search_field_controller.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Profile {
|
||||
|
|
|
@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "auth_session.h"
|
||||
#include "mainwidget.h"
|
||||
#include "observer_peer.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "styles/style_info.h"
|
||||
|
@ -351,6 +353,10 @@ int MemberListRow::nameIconWidth() const {
|
|||
: 0;
|
||||
}
|
||||
|
||||
not_null<UserData*> MemberListRow::user() const {
|
||||
return peer()->asUser();
|
||||
}
|
||||
|
||||
void MemberListRow::paintNameIcon(
|
||||
Painter &p,
|
||||
int x,
|
||||
|
|
|
@ -48,9 +48,7 @@ public:
|
|||
int outerWidth,
|
||||
bool selected) override;
|
||||
|
||||
not_null<UserData*> user() const {
|
||||
return peer()->asUser();
|
||||
}
|
||||
not_null<UserData*> user() const;
|
||||
bool canRemove() const {
|
||||
return _type.canRemove;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer_values.h"
|
||||
#include "data/data_shared_media.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
|
||||
namespace Info {
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "inline_bots/inline_bot_result.h"
|
||||
#include "inline_bots/inline_bot_layout_internal.h"
|
||||
|
@ -19,6 +20,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace InlineBots {
|
||||
namespace Layout {
|
||||
namespace {
|
||||
|
||||
NeverFreedPointer<DocumentItems> documentItemsMap;
|
||||
|
||||
} // namespace
|
||||
|
||||
void ItemBase::setPosition(int32 position) {
|
||||
_position = position;
|
||||
|
@ -211,11 +217,9 @@ QString ItemBase::getResultThumbLetter() const {
|
|||
return QString();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
NeverFreedPointer<DocumentItems> documentItemsMap;
|
||||
|
||||
} // namespace
|
||||
Data::FileOrigin ItemBase::fileOrigin() const {
|
||||
return _context->inlineItemFileOrigin();
|
||||
}
|
||||
|
||||
const DocumentItems *documentItems() {
|
||||
return documentItemsMap.data();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue