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"
|
2019-03-19 13:50:36 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
2021-08-01 22:57:36 +00:00
|
|
|
#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
|
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
namespace Ui {
|
|
|
|
class ChatStyle;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2018-09-11 19:00:23 +00:00
|
|
|
namespace Settings {
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
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;
|
2021-10-13 12:37:38 +00:00
|
|
|
void rowRightActionClicked(not_null<PeerListRow*> row) override;
|
2018-09-11 19:00:23 +00:00
|
|
|
void loadMoreRows() override;
|
|
|
|
|
2022-05-01 18:08:16 +00:00
|
|
|
[[nodiscard]] rpl::producer<int> rowsCountChanges() const;
|
|
|
|
|
2020-09-01 06:44:18 +00:00
|
|
|
static void BlockNewPeer(not_null<Window::SessionController*> window);
|
2018-09-11 19:00:23 +00:00
|
|
|
|
|
|
|
private:
|
2021-08-01 22:57:36 +00:00
|
|
|
void applySlice(const Api::BlockedPeers::Slice &slice);
|
2020-09-01 06:44:18 +00:00
|
|
|
void handleBlockedEvent(not_null<PeerData*> peer);
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2020-09-01 06:44:18 +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;
|
|
|
|
|
2021-08-01 22:57:36 +00:00
|
|
|
base::has_weak_ptr _guard;
|
|
|
|
|
2022-05-01 18:08:16 +00:00
|
|
|
rpl::event_stream<int> _rowsCountChanges;
|
|
|
|
|
2018-09-11 19:00:23 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class PhoneNumberPrivacyController final : public EditPrivacyController {
|
2019-05-21 12:51:24 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
2022-03-01 12:30:55 +00:00
|
|
|
explicit PhoneNumberPrivacyController(
|
|
|
|
not_null<Window::SessionController*> controller);
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2019-05-21 12:51:24 +00:00
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
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(
|
2022-07-14 20:10:50 +00:00
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionBoxTitle(
|
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionsDescription() const override;
|
2019-05-21 12:51:24 +00:00
|
|
|
|
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:
|
2022-03-01 12:30:55 +00:00
|
|
|
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;
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
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);
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2022-07-14 20:10:50 +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(
|
2022-07-14 20:10:50 +00:00
|
|
|
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,
|
2022-02-27 10:41:18 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class GroupsInvitePrivacyController final : public EditPrivacyController {
|
2018-09-11 19:00:23 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2022-07-14 20:10:50 +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(
|
2022-07-14 20:10:50 +00:00
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class CallsPrivacyController final : public EditPrivacyController {
|
2018-09-11 19:00:23 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2022-07-14 20:10:50 +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(
|
2022-07-14 20:10:50 +00:00
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionBoxTitle(
|
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionsDescription() const override;
|
2018-09-19 09:06:21 +00:00
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
object_ptr<Ui::RpWidget> setupBelowWidget(
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2022-12-19 14:36:02 +00:00
|
|
|
not_null<QWidget*> parent) override;
|
2019-05-21 12:51:24 +00:00
|
|
|
|
2018-10-24 09:07:54 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class CallsPeer2PeerPrivacyController final : public EditPrivacyController {
|
2018-10-24 09:07:54 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2018-10-24 09:07:54 +00:00
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
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(
|
2022-07-14 20:10:50 +00:00
|
|
|
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-03-19 13:50:36 +00:00
|
|
|
class ForwardsPrivacyController
|
2019-05-21 12:51:24 +00:00
|
|
|
: public EditPrivacyController
|
2019-05-14 09:50:44 +00:00
|
|
|
, private HistoryView::SimpleElementDelegate {
|
2019-03-19 10:39:19 +00:00
|
|
|
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
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2019-03-19 10:39:19 +00:00
|
|
|
|
2022-07-14 20:10:50 +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(
|
2022-07-14 20:10:50 +00:00
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionBoxTitle(
|
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionsDescription() const override;
|
2019-03-19 10:39:19 +00:00
|
|
|
|
2019-03-19 13:50:36 +00:00
|
|
|
object_ptr<Ui::RpWidget> setupAboveWidget(
|
|
|
|
not_null<QWidget*> parent,
|
2022-02-13 13:30:43 +00:00
|
|
|
rpl::producer<Option> optionValue,
|
|
|
|
not_null<QWidget*> outerContainer) override;
|
2019-03-19 13:50:36 +00:00
|
|
|
|
|
|
|
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;
|
2021-08-27 20:44:47 +00:00
|
|
|
const std::unique_ptr<Ui::ChatStyle> _chatStyle;
|
2019-07-24 14:00:30 +00:00
|
|
|
|
2019-03-19 10:39:19 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class ProfilePhotoPrivacyController final : public EditPrivacyController {
|
2019-03-19 10:39:19 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2019-03-19 10:39:19 +00:00
|
|
|
|
2022-07-14 20:10:50 +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(
|
2022-07-14 20:10:50 +00:00
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionBoxTitle(
|
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionsDescription() const override;
|
2019-03-19 10:39:19 +00:00
|
|
|
|
2022-12-19 14:36:02 +00:00
|
|
|
void handleExceptionsChange(
|
|
|
|
Exception exception,
|
|
|
|
rpl::producer<int> value) override;
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> setupAboveWidget(
|
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<Option> optionValue,
|
|
|
|
not_null<QWidget*> outerContainer) override;
|
|
|
|
|
2023-08-14 12:04:33 +00:00
|
|
|
object_ptr<Ui::RpWidget> setupMiddleWidget(
|
2022-12-19 14:36:02 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2023-08-14 12:04:33 +00:00
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<Option> optionValue) override;
|
2022-12-19 14:36:02 +00:00
|
|
|
|
|
|
|
void saveAdditional() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Fn<void()> _saveAdditional;
|
|
|
|
rpl::variable<Option> _option;
|
|
|
|
rpl::variable<int> _exceptionsNever;
|
|
|
|
|
2019-03-19 10:39:19 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
class VoicesPrivacyController final : public EditPrivacyController {
|
2022-07-14 19:25:04 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
explicit VoicesPrivacyController(not_null<::Main::Session*> session);
|
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
Key key() const override;
|
2022-07-14 19:25:04 +00:00
|
|
|
|
2022-07-14 20:10:50 +00:00
|
|
|
rpl::producer<QString> title() const override;
|
|
|
|
rpl::producer<QString> optionsTitleKey() const override;
|
2022-07-14 19:25:04 +00:00
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
2022-07-14 20:10:50 +00:00
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionBoxTitle(
|
|
|
|
Exception exception) const override;
|
|
|
|
rpl::producer<QString> exceptionsDescription() const override;
|
2022-07-14 19:25:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-05-30 14:41:02 +00:00
|
|
|
class AboutPrivacyController 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;
|
|
|
|
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
|
|
|
} // namespace Settings
|