tdesktop/Telegram/SourceFiles/settings/settings_privacy_controllers.h

256 lines
7.7 KiB
C
Raw Normal View History

2018-09-11 19:00:23 +00:00
/*
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 "boxes/peer_list_box.h"
#include "boxes/edit_privacy_box.h"
#include "history/view/history_view_element.h"
#include "api/api_blocked_peers.h"
2018-09-11 19:00:23 +00:00
2020-06-10 18:08:17 +00:00
namespace Window {
class SessionController;
} // namespace Window
namespace Ui {
class ChatStyle;
} // namespace Ui
2018-09-11 19:00:23 +00:00
namespace Settings {
class BlockedBoxController final : public PeerListController {
2018-09-11 19:00:23 +00:00
public:
2019-07-24 14:00:30 +00:00
explicit BlockedBoxController(
not_null<Window::SessionController*> window);
2019-07-25 18:55:11 +00:00
Main::Session &session() const override;
2018-09-11 19:00:23 +00:00
void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override;
void rowRightActionClicked(not_null<PeerListRow*> row) override;
2018-09-11 19:00:23 +00:00
void loadMoreRows() override;
[[nodiscard]] rpl::producer<int> rowsCountChanges() const;
static void BlockNewPeer(not_null<Window::SessionController*> window);
2018-09-11 19:00:23 +00:00
private:
void applySlice(const Api::BlockedPeers::Slice &slice);
void handleBlockedEvent(not_null<PeerData*> peer);
2018-09-11 19:00:23 +00:00
bool appendRow(not_null<PeerData*> peer);
bool prependRow(not_null<PeerData*> peer);
std::unique_ptr<PeerListRow> createRow(not_null<PeerData*> peer) const;
2018-09-11 19:00:23 +00:00
2019-07-24 14:00:30 +00:00
const not_null<Window::SessionController*> _window;
2018-09-11 19:00:23 +00:00
int _offset = 0;
bool _allLoaded = false;
base::has_weak_ptr _guard;
rpl::event_stream<int> _rowsCountChanges;
2018-09-11 19:00:23 +00:00
};
class PhoneNumberPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
explicit PhoneNumberPrivacyController(
not_null<Window::SessionController*> controller);
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
void prepareWarningLabel(not_null<Ui::FlatLabel*> warning) const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2019-08-29 08:44:03 +00:00
object_ptr<Ui::RpWidget> setupMiddleWidget(
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent,
rpl::producer<Option> optionValue) override;
void saveAdditional() override;
private:
const not_null<Window::SessionController*> _controller;
2019-08-29 08:44:03 +00:00
rpl::variable<Option> _phoneNumberOption = { Option::Contacts };
rpl::variable<Option> _addedByPhone = { Option::Everyone };
Fn<void()> _saveAdditional;
};
class LastSeenPrivacyController final : public EditPrivacyController {
2018-09-11 19:00:23 +00:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
2019-07-24 14:00:30 +00:00
explicit LastSeenPrivacyController(not_null<::Main::Session*> session);
Key key() const override;
2018-09-11 19:00:23 +00:00
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 19:00:23 +00:00
2019-06-18 12:16:43 +00:00
void confirmSave(
bool someAreDisallowed,
Fn<void()> saveCallback) override;
2018-09-11 19:00:23 +00:00
2019-07-24 14:00:30 +00:00
private:
const not_null<::Main::Session*> _session;
2018-09-11 19:00:23 +00:00
};
class GroupsInvitePrivacyController final : public EditPrivacyController {
2018-09-11 19:00:23 +00:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
2018-09-11 19:00:23 +00:00
rpl::producer<QString> title() const override;
bool hasOption(Option option) const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 19:00:23 +00:00
};
class CallsPrivacyController final : public EditPrivacyController {
2018-09-11 19:00:23 +00:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
2018-09-11 19:00:23 +00:00
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
object_ptr<Ui::RpWidget> setupBelowWidget(
2019-07-24 14:00:30 +00:00
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) const override;
};
class CallsPeer2PeerPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
QString optionLabel(EditPrivacyBox::Option option) const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 19:00:23 +00:00
};
class ForwardsPrivacyController
: public EditPrivacyController
2019-05-14 09:50:44 +00:00
, private HistoryView::SimpleElementDelegate {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
2020-06-10 18:08:17 +00:00
explicit ForwardsPrivacyController(
not_null<Window::SessionController*> controller);
2019-07-24 14:00:30 +00:00
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
object_ptr<Ui::RpWidget> setupAboveWidget(
not_null<QWidget*> parent,
rpl::producer<Option> optionValue,
not_null<QWidget*> outerContainer) override;
private:
using Element = HistoryView::Element;
not_null<HistoryView::ElementDelegate*> delegate();
HistoryView::Context elementContext() override;
2020-06-10 18:08:17 +00:00
const not_null<Window::SessionController*> _controller;
const std::unique_ptr<Ui::ChatStyle> _chatStyle;
2019-07-24 14:00:30 +00:00
};
class ProfilePhotoPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
rpl::producer<QString> title() const override;
bool hasOption(Option option) const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
};
class VoicesPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
explicit VoicesPrivacyController(not_null<::Main::Session*> session);
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
private:
rpl::lifetime _lifetime;
};
2018-09-11 19:00:23 +00:00
} // namespace Settings