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"
|
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;
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
static void BlockNewUser(not_null<Window::SessionController*> window);
|
2018-09-11 19:00:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void receivedUsers(const QVector<MTPContactBlocked> &result);
|
2018-12-04 11:46:07 +00:00
|
|
|
void handleBlockedEvent(not_null<UserData*> user);
|
2018-09-11 19:00:23 +00:00
|
|
|
|
2018-12-04 11:46:07 +00:00
|
|
|
bool appendRow(not_null<UserData*> user);
|
|
|
|
bool prependRow(not_null<UserData*> user);
|
|
|
|
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) 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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class PhoneNumberPrivacyController : public EditPrivacyController {
|
|
|
|
public:
|
|
|
|
using Option = EditPrivacyBox::Option;
|
|
|
|
using Exception = EditPrivacyBox::Exception;
|
|
|
|
|
|
|
|
Key key() override;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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;
|
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;
|
|
|
|
MTPInputPrivacyKey apiKey() 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
|