tdesktop/Telegram/SourceFiles/settings/settings_privacy_controllers.h

226 lines
6.6 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"
2018-09-11 19:00:23 +00:00
#include "mtproto/sender.h"
2020-06-10 18:08:17 +00:00
namespace Window {
class SessionController;
} // namespace Window
2018-09-11 19:00:23 +00:00
namespace Settings {
2019-07-25 18:55:11 +00:00
class BlockedBoxController
: public PeerListController
2019-11-27 08:02:56 +00:00
, private base::Subscriber {
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 rowActionClicked(not_null<PeerListRow*> row) override;
void loadMoreRows() override;
static void BlockNewPeer(not_null<Window::SessionController*> window);
2018-09-11 19:00:23 +00:00
private:
void receivedPeers(const QVector<MTPPeerBlocked> &result);
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;
2019-11-27 08:02:56 +00:00
MTP::Sender _api;
2019-07-24 14:00:30 +00:00
2018-09-11 19:00:23 +00:00
int _offset = 0;
mtpRequestId _loadRequestId = 0;
bool _allLoaded = false;
};
class PhoneNumberPrivacyController : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() override;
MTPInputPrivacyKey apiKey() override;
rpl::producer<QString> title() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
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;
};
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;
MTPInputPrivacyKey apiKey() override;
rpl::producer<QString> title() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
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
};
class GroupsInvitePrivacyController : public EditPrivacyController {
2018-09-11 19:00:23 +00:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() override;
MTPInputPrivacyKey apiKey() override;
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;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
2018-09-11 19:00:23 +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;
MTPInputPrivacyKey apiKey() override;
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;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
object_ptr<Ui::RpWidget> setupBelowWidget(
2019-07-24 14:00:30 +00:00
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) override;
};
class CallsPeer2PeerPrivacyController : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() override;
MTPInputPrivacyKey apiKey() override;
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;
rpl::producer<QString> warning() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() 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() override;
MTPInputPrivacyKey apiKey() override;
rpl::producer<QString> title() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
2019-06-18 12:16:43 +00:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
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;
2019-07-24 14:00:30 +00:00
};
class ProfilePhotoPrivacyController : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() override;
MTPInputPrivacyKey apiKey() override;
rpl::producer<QString> title() override;
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;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
};
2018-09-11 19:00:23 +00:00
} // namespace Settings