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 {
|
|
|
|
|
2021-07-15 11:12:38 +00:00
|
|
|
class BlockedBoxController : 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;
|
|
|
|
|
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;
|
|
|
|
|
2018-09-11 19:00:23 +00:00
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class PhoneNumberPrivacyController : public EditPrivacyController {
|
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
2019-05-21 12:51:24 +00:00
|
|
|
rpl::producer<QString> warning() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2019-05-21 12:51:24 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() 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:
|
|
|
|
rpl::variable<Option> _phoneNumberOption = { Option::Contacts };
|
|
|
|
rpl::variable<Option> _addedByPhone = { Option::Everyone };
|
|
|
|
Fn<void()> _saveAdditional;
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LastSeenPrivacyController : 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);
|
|
|
|
|
2018-09-11 19:00:23 +00:00
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
2018-09-19 09:06:21 +00:00
|
|
|
rpl::producer<QString> warning() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2018-09-19 09:06:21 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() override;
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2019-06-18 12:16:43 +00:00
|
|
|
void confirmSave(
|
|
|
|
bool someAreDisallowed,
|
|
|
|
FnMut<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
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class GroupsInvitePrivacyController : public EditPrivacyController {
|
2018-09-11 19:00:23 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2018-09-11 19:00:23 +00:00
|
|
|
bool hasOption(Option option) override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2018-09-19 09:06:21 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() override;
|
2018-09-11 19:00:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class CallsPrivacyController : public EditPrivacyController {
|
2018-09-11 19:00:23 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2018-09-19 09:06:21 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() override;
|
|
|
|
|
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,
|
2019-05-21 12:51:24 +00:00
|
|
|
not_null<QWidget*> parent) override;
|
|
|
|
|
2018-10-24 09:07:54 +00:00
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class CallsPeer2PeerPrivacyController : public EditPrivacyController {
|
2018-10-24 09:07:54 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
2019-06-19 15:09:03 +00:00
|
|
|
QString optionLabel(EditPrivacyBox::Option option) override;
|
2018-10-24 09:07:54 +00:00
|
|
|
rpl::producer<QString> warning() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2018-10-24 09:07:54 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() 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
|
|
|
|
2019-03-19 10:39:19 +00:00
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
2019-03-19 10:39:19 +00:00
|
|
|
rpl::producer<QString> warning() override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2019-03-19 10:39:19 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() override;
|
|
|
|
|
2019-03-19 13:50:36 +00:00
|
|
|
object_ptr<Ui::RpWidget> setupAboveWidget(
|
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<Option> optionValue) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
using Element = HistoryView::Element;
|
|
|
|
not_null<HistoryView::ElementDelegate*> delegate();
|
|
|
|
HistoryView::Context elementContext() override;
|
|
|
|
|
|
|
|
static void PaintForwardedTooltip(
|
|
|
|
Painter &p,
|
|
|
|
not_null<HistoryView::Element*> view,
|
|
|
|
Option value);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class ProfilePhotoPrivacyController : public EditPrivacyController {
|
2019-03-19 10:39:19 +00:00
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> title() override;
|
2019-03-25 07:11:13 +00:00
|
|
|
bool hasOption(Option option) override;
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> optionsTitleKey() override;
|
|
|
|
rpl::producer<QString> exceptionButtonTextKey(
|
|
|
|
Exception exception) override;
|
2019-06-18 15:00:55 +00:00
|
|
|
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
|
2019-03-19 10:39:19 +00:00
|
|
|
rpl::producer<QString> exceptionsDescription() override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-09-11 19:00:23 +00:00
|
|
|
} // namespace Settings
|