Merge remote-tracking branch 'private/alpha' into cmake

This commit is contained in:
John Preston 2019-12-06 10:11:30 +03:00
commit e3fa17dd4f
291 changed files with 12837 additions and 10571 deletions

9
.gitmodules vendored
View File

@ -55,3 +55,12 @@
[submodule "cmake"]
path = cmake
url = https://github.com/desktop-app/cmake_helpers.git
[submodule "Telegram/ThirdParty/expected"]
path = Telegram/ThirdParty/expected
url = https://github.com/TartanLlama/expected
[submodule "Telegram/ThirdParty/QR"]
path = Telegram/ThirdParty/QR
url = https://github.com/nayuki/QR-Code-generator
[submodule "Telegram/lib_qr"]
path = Telegram/lib_qr
url = https://github.com/desktop-app/lib_qr.git

View File

@ -49,6 +49,7 @@ addons:
- libvdpau-dev
- libxcb-xkb-dev
- libxkbcommon-dev
- libatspi2.0-dev
- lintian
- quilt
- valac

View File

@ -17,7 +17,7 @@ XKB_PATH="$BUILD/libxkbcommon"
XKB_CACHE_VERSION="3"
QT_PATH="$BUILD/qt"
QT_CACHE_VERSION="4"
QT_CACHE_VERSION="5"
QT_PATCH="$EXTERNAL/patches/qtbase_${QT_VERSION//\./_}.diff"
BREAKPAD_PATH="$BUILD/breakpad"
@ -694,7 +694,6 @@ buildTelegram() {
-Dlinux_path_qt=$QT_PATH \
-Dlinux_path_breakpad=$BREAKPAD_PATH \
-Dlinux_path_libexif_lib=/usr/local/lib \
-Dlinux_path_opus_include=/usr/include/opus \
-Dlinux_lib_ssl=-lssl \
-Dlinux_lib_crypto=-lcrypto \
-Dlinux_lib_icu=-licuuc\ -licutu\ -licui18n \

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -178,8 +178,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_photo_caption" = "Caption";
"lng_photos_comment" = "Comment";
"lng_intro_qr_title" = "Scan From Mobile Telegram";
"lng_intro_qr_step1" = "**1.** Open Telegram on your phone";
"lng_intro_qr_step2" = "**2.** Go to Settings > Devices > Scan QR Code";
"lng_intro_qr_step3" = "**3.** Scan this image to Log In";
"lng_intro_qr_skip" = "Or log in using your phone number";
"lng_phone_title" = "Your Phone Number";
"lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number.";
"lng_phone_to_qr" = "Quick log in using QR code";
"lng_country_code" = "Country Code";
"lng_bad_country_code" = "Invalid Country Code";
"lng_country_ph" = "Search";
@ -2231,6 +2238,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_mac_menu_new_group" = "New Group";
"lng_mac_menu_new_channel" = "New Channel";
"lng_mac_menu_show" = "Show Telegram";
"lng_mac_menu_emoji_and_symbols" = "Emoji & Symbols";
"lng_mac_touchbar_favorite_stickers" = "Favorite stickers";

View File

@ -89,6 +89,7 @@ inputDocumentFileLocation#bad07584 id:long access_hash:long file_reference:bytes
inputSecureFileLocation#cbc7ee28 id:long access_hash:long = InputFileLocation;
inputTakeoutFileLocation#29be5899 = InputFileLocation;
inputPhotoFileLocation#40181ffe id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;
inputPhotoLegacyFileLocation#d83466f3 id:long access_hash:long file_reference:bytes volume_id:long local_id:int secret:long = InputFileLocation;
inputPeerPhotoFileLocation#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation;
inputStickerSetThumb#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation;
@ -347,6 +348,8 @@ updatePeerLocated#b4afcfb0 peers:Vector<PeerLocated> = Update;
updateNewScheduledMessage#39a51dfb message:Message = Update;
updateDeleteScheduledMessages#90866cee peer:Peer messages:Vector<int> = Update;
updateTheme#8216fba3 theme:Theme = Update;
updateGeoLiveViewed#871fb939 peer:Peer msg_id:int = Update;
updateLoginToken#564fe691 = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@ -1082,6 +1085,12 @@ wallet.liteResponse#764386d7 response:bytes = wallet.LiteResponse;
wallet.secretSalt#dd484d64 salt:bytes = wallet.KeySecretSalt;
auth.loginToken#629f1980 expires:int token:bytes = auth.LoginToken;
auth.loginTokenMigrateTo#68e9916 dc_id:int token:bytes = auth.LoginToken;
auth.loginTokenSuccess#390d5c5e authorization:auth.Authorization = auth.LoginToken;
auth.loginTokenInfo#5203303a dc_id:int auth_key_id:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string ip:string region:string = auth.LoginTokenInfo;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -1107,6 +1116,10 @@ auth.recoverPassword#4ea56e92 code:string = auth.Authorization;
auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode;
auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool;
auth.dropTempAuthKeys#8e48a188 except_auth_keys:Vector<long> = Bool;
auth.exportLoginToken#b1b41517 api_id:int api_hash:string except_ids:Vector<int> = auth.LoginToken;
auth.importLoginToken#95ac5ce4 token:bytes = auth.LoginToken;
auth.acceptLoginToken#42e731b9 token:bytes = Updates;
auth.checkLoginToken#7d4fd4b0 token:bytes = auth.LoginTokenInfo;
account.registerDevice#68976c6f flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<int> = Bool;
account.unregisterDevice#3076c4bf token_type:int token:string other_uids:Vector<int> = Bool;
@ -1422,4 +1435,4 @@ folders.deleteFolder#1c295881 folder_id:int = Updates;
wallet.sendLiteRequest#e2c9d33e body:bytes = wallet.LiteResponse;
wallet.getKeySecretSalt#b57f346 revoke:Bool = wallet.KeySecretSalt;
// LAYER 106
// LAYER 107

View File

@ -21,6 +21,8 @@ p_q_inner_data_dc#a9f55f95 pq:string p:string q:string nonce:int128 server_nonce
p_q_inner_data_temp#3c6a84d4 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data;
p_q_inner_data_temp_dc#56fddf88 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data;
bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner;
server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params;
server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params;

View File

@ -9,7 +9,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="1.9.1.0" />
Version="1.9.1.7" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram FZ-LLC</PublisherDisplayName>

View File

@ -33,8 +33,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,1,0
PRODUCTVERSION 1,9,1,0
FILEVERSION 1,9,1,7
PRODUCTVERSION 1,9,1,7
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop"
VALUE "FileVersion", "1.9.1.0"
VALUE "FileVersion", "1.9.1.7"
VALUE "LegalCopyright", "Copyright (C) 2014-2019"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.9.1.0"
VALUE "ProductVersion", "1.9.1.7"
END
END
BLOCK "VarFileInfo"

View File

@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,1,0
PRODUCTVERSION 1,9,1,0
FILEVERSION 1,9,1,7
PRODUCTVERSION 1,9,1,7
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -42,10 +42,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop Updater"
VALUE "FileVersion", "1.9.1.0"
VALUE "FileVersion", "1.9.1.7"
VALUE "LegalCopyright", "Copyright (C) 2014-2019"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.9.1.0"
VALUE "ProductVersion", "1.9.1.7"
END
END
BLOCK "VarFileInfo"

View File

@ -40,6 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
//#include "history/feed/history_feed_section.h" // #feed
#include "storage/localstorage.h"
#include "main/main_session.h"
#include "main/main_account.h"
#include "boxes/confirm_box.h"
#include "boxes/stickers_box.h"
#include "boxes/sticker_set_box.h"
@ -54,7 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/emoji_config.h"
#include "support/support_helper.h"
#include "storage/localimageloader.h"
#include "storage/file_download.h"
#include "storage/download_manager_mtproto.h"
#include "storage/file_upload.h"
#include "storage/storage_facade.h"
#include "storage/storage_shared_media.h"
@ -222,7 +223,8 @@ bool ApiWrap::BlockedUsersSlice::operator!=(const BlockedUsersSlice &other) cons
}
ApiWrap::ApiWrap(not_null<Main::Session*> session)
: _session(session)
: MTP::Sender(session->account().mtp())
, _session(session)
, _messageDataResolveDelayed([=] { resolveMessageDatas(); })
, _webPagesTimer([=] { resolveWebPages(); })
, _draftsSaveTimer([=] { saveDraftsToCloud(); })
@ -280,11 +282,11 @@ void ApiWrap::refreshProxyPromotion() {
return;
}
const auto key = [&]() -> std::pair<QString, uint32> {
if (Global::ProxySettings() != ProxyData::Settings::Enabled) {
if (Global::ProxySettings() != MTP::ProxyData::Settings::Enabled) {
return {};
}
const auto &proxy = Global::SelectedProxy();
if (proxy.type != ProxyData::Type::Mtproto) {
if (proxy.type != MTP::ProxyData::Type::Mtproto) {
return {};
}
return { proxy.host, proxy.port };
@ -2971,12 +2973,12 @@ void ApiWrap::requestFileReference(
void ApiWrap::refreshFileReference(
Data::FileOrigin origin,
not_null<mtpFileLoader*> loader,
not_null<Storage::DownloadMtprotoTask*> task,
int requestId,
const QByteArray &current) {
return refreshFileReference(origin, crl::guard(loader, [=](
return refreshFileReference(origin, crl::guard(task, [=](
const UpdatedFileReferences &data) {
loader->refreshFileReferenceFrom(data, requestId, current);
task->refreshFileReferenceFrom(data, requestId, current);
}));
}

View File

@ -20,7 +20,6 @@ struct MessageGroupId;
struct SendingAlbum;
enum class SendMediaType;
struct FileLoadTo;
class mtpFileLoader;
namespace Main {
class Session;
@ -38,6 +37,7 @@ class Result;
namespace Storage {
enum class SharedMediaType : signed char;
struct PreparedList;
class DownloadMtprotoTask;
} // namespace Storage
namespace Dialogs {
@ -201,7 +201,7 @@ public:
FileReferencesHandler &&handler);
void refreshFileReference(
Data::FileOrigin origin,
not_null<mtpFileLoader*> loader,
not_null<Storage::DownloadMtprotoTask*> task,
int requestId,
const QByteArray &current);

View File

@ -203,7 +203,7 @@ void ShowAddParticipantsError(
Ui::show(Box<InformBox>(text), Ui::LayerOption::KeepOther);
}
class RevokePublicLinkBox::Inner : public TWidget, private MTP::Sender {
class RevokePublicLinkBox::Inner : public TWidget {
public:
Inner(
QWidget *parent,
@ -228,6 +228,7 @@ private:
void updateSelected();
const not_null<Main::Session*> _session;
MTP::Sender _api;
PeerData *_selected = nullptr;
PeerData *_pressed = nullptr;
@ -450,6 +451,7 @@ GroupInfoBox::GroupInfoBox(
const QString &title,
Fn<void(not_null<ChannelData*>)> channelDone)
: _navigation(navigation)
, _api(_navigation->session().api().instance())
, _type(type)
, _initialTitle(title)
, _channelDone(std::move(channelDone)) {
@ -569,7 +571,7 @@ void GroupInfoBox::createGroup(
if (inputs.empty()) {
return;
}
_creationRequestId = request(MTPmessages_CreateChat(
_creationRequestId = _api.request(MTPmessages_CreateChat(
MTP_vector<MTPInputUser>(inputs),
MTP_string(title)
)).done([=](const MTPUpdates &result) {
@ -645,7 +647,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
const auto flags = (_type == Type::Megagroup)
? MTPchannels_CreateChannel::Flag::f_megagroup
: MTPchannels_CreateChannel::Flag::f_broadcast;
_creationRequestId = request(MTPchannels_CreateChannel(
_creationRequestId = _api.request(MTPchannels_CreateChannel(
MTP_flags(flags),
MTP_string(title),
MTP_string(description),
@ -682,7 +684,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
std::move(image));
}
_createdChannel = channel;
_creationRequestId = request(MTPmessages_ExportChatInvite(
_creationRequestId = _api.request(MTPmessages_ExportChatInvite(
_createdChannel->input
)).done([=](const MTPExportedChatInvite &result) {
_creationRequestId = 0;
@ -1287,6 +1289,7 @@ RevokePublicLinkBox::Inner::Inner(
Fn<void()> revokeCallback)
: TWidget(parent)
, _session(session)
, _api(_session->api().instance())
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _revokeWidth(st::normalFont->width(tr::lng_channels_too_much_public_revoke(tr::now)))
, _revokeCallback(std::move(revokeCallback)) {
@ -1294,7 +1297,7 @@ RevokePublicLinkBox::Inner::Inner(
resize(width(), 5 * _rowHeight);
request(MTPchannels_GetAdminedPublicChannels(
_api.request(MTPchannels_GetAdminedPublicChannels(
MTP_flags(0)
)).done([=](const MTPmessages_Chats &result) {
const auto &chats = result.match([](const auto &data) {
@ -1401,7 +1404,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now);
_weakRevokeConfirmBox = Ui::show(Box<ConfirmBox>(text, confirmText, crl::guard(this, [this, pressed]() {
if (_revokeRequestId) return;
_revokeRequestId = request(MTPchannels_UpdateUsername(
_revokeRequestId = _api.request(MTPchannels_UpdateUsername(
pressed->asChannel()->inputChannel,
MTP_string()
)).done([=](const MTPBool &result) {

View File

@ -94,7 +94,7 @@ private:
};
class GroupInfoBox : public Ui::BoxContent, private MTP::Sender {
class GroupInfoBox : public Ui::BoxContent {
public:
enum class Type {
Group,
@ -124,6 +124,7 @@ private:
void updateMaxHeight();
const not_null<Window::SessionNavigation*> _navigation;
MTP::Sender _api;
Type _type = Type::Group;
QString _initialTitle;

View File

@ -53,10 +53,7 @@ QImage TakeMiddleSample(QImage original, QSize size) {
} // namespace
class BackgroundBox::Inner
: public Ui::RpWidget
, private MTP::Sender
, private base::Subscriber {
class BackgroundBox::Inner : public Ui::RpWidget, private base::Subscriber {
public:
Inner(
QWidget *parent,
@ -114,6 +111,7 @@ private:
void validatePaperThumbnail(const Paper &paper) const;
const not_null<Main::Session*> _session;
MTP::Sender _api;
std::vector<Paper> _papers;
@ -185,6 +183,7 @@ BackgroundBox::Inner::Inner(
not_null<Main::Session*> session)
: RpWidget(parent)
, _session(session)
, _api(_session->api().instance())
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
if (_session->data().wallpapers().empty()) {
@ -209,7 +208,7 @@ BackgroundBox::Inner::Inner(
}
void BackgroundBox::Inner::requestPapers() {
request(MTPaccount_GetWallPapers(
_api.request(MTPaccount_GetWallPapers(
MTP_int(_session->data().wallpapersHash())
)).done([=](const MTPaccount_WallPapers &result) {
if (_session->data().updateWallpapers(result)) {

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/calendar_box.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "ui/widgets/buttons.h"
#include "lang/lang_keys.h"
#include "ui/effects/ripple_animation.h"

View File

@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_user.h"
#include "data/data_file_origin.h"
#include "base/unixtime.h"
#include "main/main_session.h"
#include "observer_peer.h"

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "boxes/abstract_box.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Main {
class Session;

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "numbers.h"
#include "app.h"
#include "lang/lang_keys.h"
#include "mtproto/facade.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "base/timer.h"
#include "ui/widgets/input_fields.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Ui {
class InputField;

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/call_delayed.h"
#include "core/application.h"
#include "main/main_account.h"
#include "mtproto/facade.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
@ -38,6 +39,8 @@ namespace {
constexpr auto kSaveSettingsDelayedTimeout = crl::time(1000);
using ProxyData = MTP::ProxyData;
class Base64UrlInput : public Ui::MaskedInputField {
public:
Base64UrlInput(
@ -1057,7 +1060,7 @@ void ProxiesBoxController::refreshChecker(Item &item) {
item.state = ItemState::Checking;
const auto setup = [&](Checker &checker, const bytes::vector &secret) {
checker = MTP::internal::AbstractConnection::Create(
checker = MTP::details::AbstractConnection::Create(
mtproto,
type,
QThread::currentThread(),
@ -1105,7 +1108,7 @@ void ProxiesBoxController::refreshChecker(Item &item) {
}
void ProxiesBoxController::setupChecker(int id, const Checker &checker) {
using Connection = MTP::internal::AbstractConnection;
using Connection = MTP::details::AbstractConnection;
const auto pointer = checker.get();
pointer->connect(pointer, &Connection::connected, [=] {
const auto item = findById(id);
@ -1148,7 +1151,7 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::create() {
for (const auto &item : _list) {
updateView(item);
}
return std::move(result);
return result;
}
auto ProxiesBoxController::findById(int id) -> std::vector<Item>::iterator {

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer.h"
#include "base/object_ptr.h"
#include "mtproto/connection_abstract.h"
#include "mtproto/mtproto_proxy_data.h"
namespace Ui {
class BoxContent;
@ -25,6 +26,7 @@ class Radioenum;
class ProxiesBoxController : public base::Subscriber {
public:
using ProxyData = MTP::ProxyData;
using Type = ProxyData::Type;
ProxiesBoxController();
@ -73,7 +75,7 @@ public:
~ProxiesBoxController();
private:
using Checker = MTP::internal::ConnectionPointer;
using Checker = MTP::details::ConnectionPointer;
struct Item {
int id = 0;
ProxyData data;

View File

@ -768,7 +768,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
FocusAtEnd(question);
}, lifetime());
return std::move(result);
return result;
}
void CreatePollBox::prepare() {

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_media_prepare.h"
#include "ui/wrap/slide_wrap.h"
#include "media/clip/media_clip_reader.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace ChatHelpers {
class TabbedPanel;

View File

@ -100,7 +100,7 @@ private:
};
class EditPrivacyBox : public Ui::BoxContent, private MTP::Sender {
class EditPrivacyBox : public Ui::BoxContent {
public:
using Value = ApiWrap::Privacy;
using Option = Value::Option;

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h"
#include "boxes/confirm_phone_box.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "main/main_session.h"
#include "storage/localstorage.h"
#include "ui/widgets/buttons.h"
@ -47,6 +48,7 @@ PasscodeBox::PasscodeBox(
not_null<Main::Session*> session,
bool turningOff)
: _session(session)
, _api(_session->api().instance())
, _turningOff(turningOff)
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
@ -62,6 +64,7 @@ PasscodeBox::PasscodeBox(
not_null<Main::Session*> session,
const CloudFields &fields)
: _session(session)
, _api(_session->api().instance())
, _turningOff(fields.turningOff)
, _cloudPwd(true)
, _cloudFields(fields)
@ -357,7 +360,7 @@ void PasscodeBox::validateEmail(
if (_setRequest) {
return;
}
_setRequest = request(MTPaccount_ConfirmPasswordEmail(
_setRequest = _api.request(MTPaccount_ConfirmPasswordEmail(
MTP_string(code)
)).done([=](const MTPBool &result) {
*set = true;
@ -387,7 +390,7 @@ void PasscodeBox::validateEmail(
if (_setRequest) {
return;
}
_setRequest = request(MTPaccount_ResendPasswordEmail(
_setRequest = _api.request(MTPaccount_ResendPasswordEmail(
)).done([=](const MTPBool &result) {
_setRequest = 0;
resent->fire(tr::lng_cloud_password_resent(tr::now));
@ -597,8 +600,8 @@ void PasscodeBox::requestPasswordData() {
return serverError();
}
request(base::take(_setRequest)).cancel();
_setRequest = request(
_api.request(base::take(_setRequest)).cancel();
_setRequest = _api.request(
MTPaccount_GetPassword()
).done([=](const MTPaccount_Password &result) {
_setRequest = 0;
@ -636,7 +639,7 @@ void PasscodeBox::sendClearCloudPassword(
| MTPDaccount_passwordInputSettings::Flag::f_new_password_hash
| MTPDaccount_passwordInputSettings::Flag::f_hint
| MTPDaccount_passwordInputSettings::Flag::f_email;
_setRequest = request(MTPaccount_UpdatePasswordSettings(
_setRequest = _api.request(MTPaccount_UpdatePasswordSettings(
check.result,
MTP_account_passwordInputSettings(
MTP_flags(flags),
@ -667,7 +670,7 @@ void PasscodeBox::setNewCloudPassword(const QString &newPassword) {
| MTPDaccount_passwordInputSettings::Flag::f_hint
| MTPDaccount_passwordInputSettings::Flag::f_email;
_checkPasswordCallback = nullptr;
_setRequest = request(MTPaccount_UpdatePasswordSettings(
_setRequest = _api.request(MTPaccount_UpdatePasswordSettings(
MTP_inputCheckPasswordEmpty(),
MTP_account_passwordInputSettings(
MTP_flags(flags),
@ -695,7 +698,7 @@ void PasscodeBox::changeCloudPassword(
const QString &oldPassword,
const Core::CloudPasswordResult &check,
const QString &newPassword) {
_setRequest = request(MTPaccount_GetPasswordSettings(
_setRequest = _api.request(MTPaccount_GetPasswordSettings(
check.result
)).done([=](const MTPaccount_PasswordSettings &result) {
_setRequest = 0;
@ -760,7 +763,7 @@ void PasscodeBox::resetSecret(
const QString &newPassword,
Fn<void()> callback) {
using Flag = MTPDaccount_passwordInputSettings::Flag;
_setRequest = request(MTPaccount_UpdatePasswordSettings(
_setRequest = _api.request(MTPaccount_UpdatePasswordSettings(
check.result,
MTP_account_passwordInputSettings(
MTP_flags(Flag::f_new_secure_settings),
@ -814,7 +817,7 @@ void PasscodeBox::sendChangeCloudPassword(
_cloudFields.newSecureSecretAlgo,
bytes::make_span(newPasswordBytes)));
}
_setRequest = request(MTPaccount_UpdatePasswordSettings(
_setRequest = _api.request(MTPaccount_UpdatePasswordSettings(
check.result,
MTP_account_passwordInputSettings(
MTP_flags(flags),
@ -873,7 +876,7 @@ void PasscodeBox::emailChanged() {
void PasscodeBox::recoverByEmail() {
if (_pattern.isEmpty()) {
_pattern = "-";
request(MTPauth_RequestPasswordRecovery(
_api.request(MTPauth_RequestPasswordRecovery(
)).done([=](const MTPauth_PasswordRecovery &result) {
recoverStarted(result);
}).fail([=](const RPCError &error) {

View File

@ -25,7 +25,7 @@ namespace Core {
struct CloudPasswordState;
} // namespace Core
class PasscodeBox : public Ui::BoxContent, private MTP::Sender {
class PasscodeBox : public Ui::BoxContent {
public:
PasscodeBox(QWidget*, not_null<Main::Session*> session, bool turningOff);
@ -130,6 +130,7 @@ private:
void serverError();
const not_null<Main::Session*> _session;
MTP::Sender _api;
QString _pattern;

View File

@ -1287,7 +1287,6 @@ void PeerListContent::loadProfilePhotos() {
auto yFrom = _visibleTop;
auto yTo = _visibleBottom + (_visibleBottom - _visibleTop) * PreloadHeightsCount;
_controller->session().downloader().clearPriorities();
if (yTo < 0) return;
if (yFrom < 0) yFrom = 0;

View File

@ -142,7 +142,8 @@ void PeerListRowWithLink::paintAction(
PeerListGlobalSearchController::PeerListGlobalSearchController(
not_null<Window::SessionNavigation*> navigation)
: _navigation(navigation) {
: _navigation(navigation)
, _api(_navigation->session().api().instance()) {
_timer.setCallback([this] { searchOnServer(); });
}
@ -169,7 +170,7 @@ bool PeerListGlobalSearchController::searchInCache() {
}
void PeerListGlobalSearchController::searchOnServer() {
_requestId = request(MTPcontacts_Search(
_requestId = _api.request(MTPcontacts_Search(
MTP_string(_query),
MTP_int(SearchPeopleLimit)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {

View File

@ -59,9 +59,7 @@ private:
};
class PeerListGlobalSearchController
: public PeerListSearchController
, private MTP::Sender {
class PeerListGlobalSearchController : public PeerListSearchController {
public:
PeerListGlobalSearchController(
not_null<Window::SessionNavigation*> navigation);
@ -78,6 +76,7 @@ private:
void searchDone(const MTPcontacts_Found &result, mtpRequestId requestId);
const not_null<Window::SessionNavigation*> _navigation;
MTP::Sender _api;
base::Timer _timer;
QString _query;
mtpRequestId _requestId = 0;

View File

@ -276,6 +276,7 @@ AddSpecialBoxController::AddSpecialBoxController(
peer,
&_additional))
, _peer(peer)
, _api(_peer->session().api().instance())
, _role(role)
, _additional(peer, Role::Members)
, _adminDoneCallback(std::move(adminDoneCallback))
@ -408,7 +409,7 @@ void AddSpecialBoxController::loadMoreRows() {
const auto participantsHash = 0;
const auto channel = _peer->asChannel();
_loadRequestId = request(MTPchannels_GetParticipants(
_loadRequestId = _api.request(MTPchannels_GetParticipants(
channel->inputChannel,
MTP_channelParticipantsRecent(),
MTP_int(_offset),
@ -464,7 +465,7 @@ bool AddSpecialBoxController::checkInfoLoaded(
// We don't know what this user status is in the group.
const auto channel = _peer->asChannel();
request(MTPchannels_GetParticipant(
_api.request(MTPchannels_GetParticipant(
channel->inputChannel,
user->inputUser
)).done([=](const MTPchannels_ChannelParticipant &result) {
@ -829,6 +830,7 @@ AddSpecialBoxSearchController::AddSpecialBoxSearchController(
not_null<ParticipantsAdditionalData*> additional)
: _peer(peer)
, _additional(additional)
, _api(_peer->session().api().instance())
, _timer([=] { searchOnServer(); }) {
subscribeToMigration();
}
@ -924,7 +926,7 @@ void AddSpecialBoxSearchController::requestParticipants() {
const auto participantsHash = 0;
const auto channel = _peer->asChannel();
_requestId = request(MTPchannels_GetParticipants(
_requestId = _api.request(MTPchannels_GetParticipants(
channel->inputChannel,
MTP_channelParticipantsSearch(MTP_string(_query)),
MTP_int(_offset),
@ -1012,7 +1014,7 @@ void AddSpecialBoxSearchController::requestGlobal() {
}
auto perPage = SearchPeopleLimit;
_requestId = request(MTPcontacts_Search(
_requestId = _api.request(MTPcontacts_Search(
MTP_string(_query),
MTP_int(perPage)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {

View File

@ -69,7 +69,6 @@ private:
class AddSpecialBoxController
: public PeerListController
, private base::Subscriber
, private MTP::Sender
, public base::has_weak_ptr {
public:
using Role = ParticipantsBoxController::Role;
@ -87,12 +86,12 @@ public:
AdminDoneCallback adminDoneCallback,
BannedDoneCallback bannedDoneCallback);
Main::Session &session() const override;
[[nodiscard]] Main::Session &session() const override;
void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override;
void loadMoreRows() override;
std::unique_ptr<PeerListRow> createSearchRow(
[[nodiscard]] std::unique_ptr<PeerListRow> createSearchRow(
not_null<PeerData*> peer) override;
private:
@ -120,6 +119,7 @@ private:
void migrate(not_null<ChannelData*> channel);
not_null<PeerData*> _peer;
MTP::Sender _api;
Role _role = Role::Admins;
int _offset = 0;
mtpRequestId _loadRequestId = 0;
@ -139,7 +139,6 @@ protected:
// Finds chat/channel members, then contacts, then global search results.
class AddSpecialBoxSearchController
: public PeerListSearchController
, private MTP::Sender
, private base::Subscriber {
public:
using Role = ParticipantsBoxController::Role;
@ -181,6 +180,7 @@ private:
not_null<PeerData*> _peer;
not_null<ParticipantsAdditionalData*> _additional;
MTP::Sender _api;
base::Timer _timer;
QString _query;

View File

@ -223,7 +223,7 @@ object_ptr<Ui::RpWidget> SetupAbout(
tr::now,
Ui::Text::WithEntities);
}());
return std::move(about);
return about;
}
object_ptr<Ui::RpWidget> SetupFooter(

View File

@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "base/unique_qptr.h"
class RPCError;
namespace Ui {
class FlatLabel;
class LinkButton;

View File

@ -745,6 +745,7 @@ ParticipantsBoxController::ParticipantsBoxController(
: PeerListController(CreateSearchController(peer, role, &_additional))
, _navigation(navigation)
, _peer(peer)
, _api(_peer->session().api().instance())
, _role(role)
, _additional(peer, _role) {
subscribeToMigration();
@ -1022,7 +1023,7 @@ void ParticipantsBoxController::restoreState(
: nullptr;
if (const auto my = dynamic_cast<SavedState*>(typeErasedState)) {
if (const auto requestId = base::take(_loadRequestId)) {
request(requestId).cancel();
_api.request(requestId).cancel();
}
_additional = std::move(my->additional);
@ -1251,7 +1252,7 @@ void ParticipantsBoxController::loadMoreRows() {
: kParticipantsFirstPageCount;
const auto participantsHash = 0;
_loadRequestId = request(MTPchannels_GetParticipants(
_loadRequestId = _api.request(MTPchannels_GetParticipants(
channel->inputChannel,
filter,
MTP_int(_offset),
@ -1786,7 +1787,7 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
row->setActionLink(tr::lng_profile_kick(tr::now));
}
}
return std::move(row);
return row;
}
auto ParticipantsBoxController::computeType(
@ -1906,7 +1907,8 @@ ParticipantsBoxSearchController::ParticipantsBoxSearchController(
not_null<ParticipantsAdditionalData*> additional)
: _channel(channel)
, _role(role)
, _additional(additional) {
, _additional(additional)
, _api(_channel->session().api().instance()) {
_timer.setCallback([=] { searchOnServer(); });
}
@ -1931,14 +1933,14 @@ auto ParticipantsBoxSearchController::saveState() const
result->offset = _offset;
result->allLoaded = _allLoaded;
result->wasLoading = (_requestId != 0);
return std::move(result);
return result;
}
void ParticipantsBoxSearchController::restoreState(
std::unique_ptr<SavedStateBase> state) {
if (auto my = dynamic_cast<SavedState*>(state.get())) {
if (auto requestId = base::take(_requestId)) {
request(requestId).cancel();
_api.request(requestId).cancel();
}
_cache.clear();
_queries.clear();
@ -2002,7 +2004,7 @@ bool ParticipantsBoxSearchController::loadMoreRows() {
auto perPage = kParticipantsPerPage;
auto participantsHash = 0;
_requestId = request(MTPchannels_GetParticipants(
_requestId = _api.request(MTPchannels_GetParticipants(
_channel->inputChannel,
filter,
MTP_int(_offset),

View File

@ -134,7 +134,6 @@ private:
class ParticipantsBoxController
: public PeerListController
, private base::Subscriber
, private MTP::Sender
, public base::has_weak_ptr {
public:
using Role = ParticipantsRole;
@ -238,6 +237,7 @@ private:
not_null<Window::SessionNavigation*> _navigation;
not_null<PeerData*> _peer;
MTP::Sender _api;
Role _role = Role::Admins;
int _offset = 0;
mtpRequestId _loadRequestId = 0;
@ -251,9 +251,7 @@ private:
};
// Members, banned and restricted users server side search.
class ParticipantsBoxSearchController
: public PeerListSearchController
, private MTP::Sender {
class ParticipantsBoxSearchController : public PeerListSearchController {
public:
using Role = ParticipantsBoxController::Role;
@ -295,6 +293,7 @@ private:
not_null<ChannelData*> _channel;
Role _role = Role::Restricted;
not_null<ParticipantsAdditionalData*> _additional;
MTP::Sender _api;
base::Timer _timer;
QString _query;

View File

@ -240,9 +240,7 @@ namespace {
constexpr auto kMaxGroupChannelTitle = 128; // See also add_contact_box.
constexpr auto kMaxChannelDescription = 255; // See also add_contact_box.
class Controller
: public base::has_weak_ptr
, private MTP::Sender {
class Controller : public base::has_weak_ptr {
public:
Controller(
not_null<Window::SessionNavigation*> navigation,
@ -334,6 +332,7 @@ private:
const not_null<Window::SessionNavigation*> _navigation;
const not_null<Ui::BoxContent*> _box;
not_null<PeerData*> _peer;
MTP::Sender _api;
const bool _isGroup = false;
base::unique_qptr<Ui::VerticalLayout> _wrap;
@ -344,7 +343,6 @@ private:
const rpl::event_stream<Privacy> _privacyTypeUpdates;
const rpl::event_stream<ChannelData*> _linkedChatUpdates;
MTP::Sender _linkedChatsRequester;
mtpRequestId _linkedChatsRequestId = 0;
rpl::lifetime _lifetime;
@ -358,6 +356,7 @@ Controller::Controller(
: _navigation(navigation)
, _box(box)
, _peer(peer)
, _api(_peer->session().api().instance())
, _isGroup(_peer->isChat() || _peer->isMegagroup()) {
_box->setTitle(_isGroup
? tr::lng_edit_group()
@ -478,7 +477,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
[=] { submitTitle(); });
_controls.title = result->entity();
return std::move(result);
return result;
}
object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
@ -512,7 +511,7 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
[=] { submitDescription(); });
_controls.description = result->entity();
return std::move(result);
return result;
}
object_ptr<Ui::RpWidget> Controller::createManageGroupButtons() {
@ -526,7 +525,7 @@ object_ptr<Ui::RpWidget> Controller::createManageGroupButtons() {
fillManageSection();
return std::move(result);
return result;
}
object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
@ -564,7 +563,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
Ui::show(Box<StickersBox>(channel), Ui::LayerOption::KeepOther);
});
return std::move(result);
return result;
}
bool Controller::canEditInformation() const {
@ -644,7 +643,7 @@ void Controller::showEditLinkedChatBox() {
callback(_linkedChatOriginalValue);
return;
}
_linkedChatsRequestId = _linkedChatsRequester.request(
_linkedChatsRequestId = _api.request(
MTPchannels_GetGroupsForDiscussion()
).done([=](const MTPmessages_Chats &result) {
_linkedChatsRequestId = 0;
@ -1187,7 +1186,7 @@ void Controller::saveUsername() {
return;
}
request(MTPchannels_UpdateUsername(
_api.request(MTPchannels_UpdateUsername(
channel->inputChannel,
MTP_string(*_savingData.username)
)).done([=](const MTPBool &result) {
@ -1242,7 +1241,7 @@ void Controller::saveLinkedChat() {
const auto input = *_savingData.linkedChat
? (*_savingData.linkedChat)->inputChannel
: MTP_inputChannelEmpty();
request(MTPchannels_SetDiscussionGroup(
_api.request(MTPchannels_SetDiscussionGroup(
(channel->isBroadcast() ? channel->inputChannel : input),
(channel->isBroadcast() ? input : channel->inputChannel)
)).done([=](const MTPBool &result) {
@ -1283,14 +1282,14 @@ void Controller::saveTitle() {
};
if (const auto channel = _peer->asChannel()) {
request(MTPchannels_EditTitle(
_api.request(MTPchannels_EditTitle(
channel->inputChannel,
MTP_string(*_savingData.title)
)).done(std::move(onDone)
).fail(std::move(onFail)
).send();
} else if (const auto chat = _peer->asChat()) {
request(MTPmessages_EditChatTitle(
_api.request(MTPmessages_EditChatTitle(
chat->inputChat,
MTP_string(*_savingData.title)
)).done(std::move(onDone)
@ -1311,7 +1310,7 @@ void Controller::saveDescription() {
_peer->setAbout(*_savingData.description);
continueSave();
};
request(MTPmessages_EditChatAbout(
_api.request(MTPmessages_EditChatAbout(
_peer->input,
MTP_string(*_savingData.description)
)).done([=](const MTPBool &result) {
@ -1368,7 +1367,7 @@ void Controller::togglePreHistoryHidden(
done();
};
request(MTPchannels_TogglePreHistoryHidden(
_api.request(MTPchannels_TogglePreHistoryHidden(
channel->inputChannel,
MTP_bool(hidden)
)).done([=](const MTPUpdates &result) {
@ -1390,7 +1389,7 @@ void Controller::saveSignatures() {
|| *_savingData.signatures == channel->addsSignature()) {
return continueSave();
}
request(MTPchannels_ToggleSignatures(
_api.request(MTPchannels_ToggleSignatures(
channel->inputChannel,
MTP_bool(*_savingData.signatures)
)).done([=](const MTPUpdates &result) {

View File

@ -51,9 +51,7 @@ namespace {
constexpr auto kUsernameCheckTimeout = crl::time(200);
constexpr auto kMinUsernameLength = 5;
class Controller
: public base::has_weak_ptr
, private MTP::Sender {
class Controller : public base::has_weak_ptr {
public:
Controller(
not_null<Ui::VerticalLayout*> container,
@ -144,6 +142,7 @@ private:
QString inviteLinkText();
not_null<PeerData*> _peer;
MTP::Sender _api;
std::optional<Privacy> _privacySavedValue;
std::optional<QString> _usernameSavedValue;
@ -169,6 +168,7 @@ Controller::Controller(
std::optional<Privacy> privacySavedValue,
std::optional<QString> usernameSavedValue)
: _peer(peer)
, _api(_peer->session().api().instance())
, _privacySavedValue(privacySavedValue)
, _usernameSavedValue(usernameSavedValue)
, _useLocationPhrases(useLocationPhrases)
@ -364,7 +364,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
const auto shown = (_controls.privacy->value() == Privacy::HasUsername);
result->toggle(shown, anim::type::instant);
return std::move(result);
return result;
}
void Controller::privacyChanged(Privacy value) {
@ -401,7 +401,7 @@ void Controller::privacyChanged(Privacy value) {
refreshVisibilities();
_controls.usernameInput->setDisplayFocused(true);
} else {
request(base::take(_checkUsernameRequestId)).cancel();
_api.request(base::take(_checkUsernameRequestId)).cancel();
_checkUsernameTimer.cancel();
refreshVisibilities();
}
@ -420,11 +420,11 @@ void Controller::checkUsernameAvailability() {
return;
}
if (_checkUsernameRequestId) {
request(_checkUsernameRequestId).cancel();
_api.request(_checkUsernameRequestId).cancel();
}
const auto channel = _peer->migrateToOrMe()->asChannel();
const auto username = channel ? channel->username : QString();
_checkUsernameRequestId = request(MTPchannels_CheckUsername(
_checkUsernameRequestId = _api.request(MTPchannels_CheckUsername(
channel ? channel->inputChannel : MTP_inputChannelEmpty(),
MTP_string(checking)
)).done([=](const MTPBool &result) {
@ -630,7 +630,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkEdit() {
observeInviteLink();
return std::move(result);
return result;
}
void Controller::refreshEditInviteLink() {
@ -692,7 +692,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkCreate() {
observeInviteLink();
return std::move(result);
return result;
}
void Controller::refreshCreateInviteLink() {

View File

@ -31,6 +31,7 @@ RateCallBox::RateCallBox(
uint64 callId,
uint64 callAccessHash)
: _session(session)
, _api(_session->api().instance())
, _callId(callId)
, _callAccessHash(callAccessHash) {
}
@ -120,7 +121,7 @@ void RateCallBox::send() {
return;
}
auto comment = _comment ? _comment->getLastText().trimmed() : QString();
_requestId = request(MTPphone_SetCallRating(
_requestId = _api.request(MTPphone_SetCallRating(
MTP_flags(0),
MTP_inputPhoneCall(MTP_long(_callId), MTP_long(_callAccessHash)),
MTP_int(_rating),

View File

@ -20,7 +20,7 @@ namespace Main {
class Session;
} // namespace Main
class RateCallBox : public Ui::BoxContent, private MTP::Sender {
class RateCallBox : public Ui::BoxContent {
public:
RateCallBox(
QWidget*,
@ -41,6 +41,7 @@ private:
void commentResized();
const not_null<Main::Session*> _session;
MTP::Sender _api;
uint64 _callId = 0;
uint64 _callAccessHash = 0;

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/toast/toast.h"
#include "mtproto/facade.h"
#include "mainwindow.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "boxes/abstract_box.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Ui {
template <typename Enum>

View File

@ -20,7 +20,7 @@ namespace Main {
class Session;
} // namespace Main
class SelfDestructionBox : public Ui::BoxContent, private MTP::Sender {
class SelfDestructionBox : public Ui::BoxContent {
public:
SelfDestructionBox(
QWidget*,

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "base/unixtime.h"
@ -77,6 +78,7 @@ private:
SessionsBox::SessionsBox(QWidget*, not_null<Main::Session*> session)
: _session(session)
, _api(_session->api().instance())
, _shortPollTimer([=] { shortPollSessions(); }) {
}
@ -280,7 +282,7 @@ void SessionsBox::shortPollSessions() {
if (_shortPollRequest) {
return;
}
_shortPollRequest = request(MTPaccount_GetAuthorizations(
_shortPollRequest = _api.request(MTPaccount_GetAuthorizations(
)).done([=](const MTPaccount_Authorizations &result) {
got(result);
}).send();
@ -294,7 +296,7 @@ void SessionsBox::terminateOne(uint64 hash) {
_terminateBox->closeBox();
_terminateBox = nullptr;
}
request(MTPaccount_ResetAuthorization(
_api.request(MTPaccount_ResetAuthorization(
MTP_long(hash)
)).done([=](const MTPBool &result) {
_inner->terminatingOne(hash, false);
@ -330,12 +332,12 @@ void SessionsBox::terminateAll() {
_terminateBox->closeBox();
_terminateBox = nullptr;
}
request(MTPauth_ResetAuthorizations(
_api.request(MTPauth_ResetAuthorizations(
)).done([=](const MTPBool &result) {
request(base::take(_shortPollRequest)).cancel();
_api.request(base::take(_shortPollRequest)).cancel();
shortPollSessions();
}).fail([=](const RPCError &result) {
request(base::take(_shortPollRequest)).cancel();
_api.request(base::take(_shortPollRequest)).cancel();
shortPollSessions();
}).send();
setLoading(true);

View File

@ -22,7 +22,7 @@ namespace Main {
class Session;
} // namespace Main
class SessionsBox : public Ui::BoxContent, private MTP::Sender {
class SessionsBox : public Ui::BoxContent {
public:
SessionsBox(QWidget*, not_null<Main::Session*> session);
@ -60,6 +60,7 @@ private:
void terminateAll();
const not_null<Main::Session*> _session;
MTP::Sender _api;
bool _loading = false;
Full _data;

View File

@ -722,7 +722,6 @@ void ShareBox::Inner::loadProfilePhotos(int yFrom) {
yFrom *= _columnCount;
yTo *= _columnCount;
_navigation->session().downloader().clearPriorities();
if (_filter.isEmpty()) {
if (!_chatsIndexed->empty()) {
auto i = _chatsIndexed->cfind(yFrom, _rowHeight);

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer.h"
#include "ui/effects/animations.h"
#include "ui/effects/round_checkbox.h"
#include "mtproto/mtproto_rpc_sender.h"
enum class SendMenuType;

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_file_origin.h"
#include "lang/lang_keys.h"
#include "chat_helpers/stickers.h"
#include "boxes/confirm_box.h"
@ -99,7 +100,7 @@ private:
void showPreview();
not_null<Window::SessionController*> _controller;
MTP::Sender _mtp;
MTP::Sender _api;
std::vector<Element> _elements;
std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
Stickers::Pack _pack;
@ -220,6 +221,7 @@ StickerSetBox::Inner::Inner(
const MTPInputStickerSet &set)
: RpWidget(parent)
, _controller(controller)
, _api(_controller->session().api().instance())
, _input(set)
, _previewTimer([=] { showPreview(); }) {
set.match([&](const MTPDinputStickerSetID &data) {
@ -231,7 +233,7 @@ StickerSetBox::Inner::Inner(
}, [&](const MTPDinputStickerSetAnimatedEmoji &) {
});
_mtp.request(MTPmessages_GetStickerSet(
_api.request(MTPmessages_GetStickerSet(
_input
)).done([=](const MTPmessages_StickerSet &result) {
gotSet(result);
@ -700,7 +702,7 @@ void StickerSetBox::Inner::install() {
} else if (_installRequest) {
return;
}
_installRequest = _mtp.request(MTPmessages_InstallStickerSet(
_installRequest = _api.request(MTPmessages_InstallStickerSet(
_input,
MTP_bool(false)
)).done([=](const MTPmessages_StickerSetInstallResult &result) {

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_channel.h"
#include "data/data_file_origin.h"
#include "core/application.h"
#include "lang/lang_keys.h"
#include "mainwidget.h"
@ -661,6 +662,7 @@ StickersBox::Inner::Inner(
StickersBox::Section section)
: RpWidget(parent)
, _session(session)
, _api(_session->api().instance())
, _section(section)
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _shiftingAnimation([=](crl::time now) {
@ -677,6 +679,7 @@ StickersBox::Inner::Inner(
StickersBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> megagroup)
: RpWidget(parent)
, _session(&megagroup->session())
, _api(_session->api().instance())
, _section(StickersBox::Section::Installed)
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _shiftingAnimation([=](crl::time now) {
@ -1469,11 +1472,13 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
}
}
} else if (!_megagroupSetRequestId) {
_megagroupSetRequestId = request(MTPmessages_GetStickerSet(MTP_inputStickerSetShortName(MTP_string(text)))).done([this](const MTPmessages_StickerSet &result) {
_megagroupSetRequestId = _api.request(MTPmessages_GetStickerSet(
MTP_inputStickerSetShortName(MTP_string(text))
)).done([=](const MTPmessages_StickerSet &result) {
_megagroupSetRequestId = 0;
auto set = Stickers::FeedSetFull(result);
setMegagroupSelectedSet(MTP_inputStickerSetID(MTP_long(set->id), MTP_long(set->access)));
}).fail([this](const RPCError &error) {
}).fail([=](const RPCError &error) {
_megagroupSetRequestId = 0;
setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
}).send();

View File

@ -153,8 +153,7 @@ private:
// This class is hold in header because it requires Qt preprocessing.
class StickersBox::Inner
: public Ui::RpWidget
, private base::Subscriber
, private MTP::Sender {
, private base::Subscriber {
Q_OBJECT
public:
@ -320,6 +319,7 @@ private:
int countMaxNameWidth() const;
const not_null<Main::Session*> _session;
MTP::Sender _api;
Section _section;

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "boxes/abstract_box.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Ui {
class UsernameInput;

View File

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/data_media_types.h"
#include "data/data_user.h"
#include "apiwrap.h"
#include "facades.h"
#include "app.h"
@ -216,7 +217,8 @@ void BoxController::Row::stopLastActionRipple() {
}
BoxController::BoxController(not_null<Window::SessionController*> window)
: _window(window) {
: _window(window)
, _api(_window->session().api().instance()) {
}
Main::Session &BoxController::session() const {
@ -256,7 +258,7 @@ void BoxController::loadMoreRows() {
return;
}
_loadRequestId = request(MTPmessages_Search(
_loadRequestId = _api.request(MTPmessages_Search(
MTP_flags(0),
MTP_inputPeerEmpty(),
MTP_string(),
@ -404,8 +406,7 @@ BoxController::Row *BoxController::rowForItem(not_null<const HistoryItem*> item)
std::unique_ptr<PeerListRow> BoxController::createRow(
not_null<HistoryItem*> item) const {
auto row = std::make_unique<Row>(item);
return std::move(row);
return std::make_unique<Row>(item);
}
} // namespace Calls

View File

@ -15,10 +15,7 @@ class SessionController;
namespace Calls {
class BoxController
: public PeerListController
, private base::Subscriber
, private MTP::Sender {
class BoxController : public PeerListController, private base::Subscriber {
public:
explicit BoxController(not_null<Window::SessionController*> window);
@ -44,6 +41,7 @@ private:
not_null<HistoryItem*> item) const;
const not_null<Window::SessionController*> _window;
MTP::Sender _api;
MsgId _offsetId = 0;
mtpRequestId _loadRequestId = 0;

View File

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/rate_call_box.h"
#include "calls/calls_instance.h"
#include "base/openssl_help.h"
#include "mtproto/connection.h"
#include "mtproto/mtproto_dh_utils.h"
#include "media/audio/media_audio_track.h"
#include "base/platform/base_platform_info.h"
#include "calls/calls_panel.h"
@ -130,6 +130,7 @@ Call::Call(
Type type)
: _delegate(delegate)
, _user(user)
, _api(_user->session().api().instance())
, _type(type) {
_discardByTimeoutTimer.setCallback([this] { hangup(); });
@ -189,7 +190,7 @@ void Call::startOutgoing() {
Expects(_state == State::Requesting);
Expects(_gaHash.size() == kSha256Size);
request(MTPphone_RequestCall(
_api.request(MTPphone_RequestCall(
MTP_flags(0),
_user->inputUser,
MTP_int(rand_value<int32>()),
@ -236,11 +237,13 @@ void Call::startIncoming() {
Expects(_type == Type::Incoming);
Expects(_state == State::Starting);
request(MTPphone_ReceivedCall(MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)))).done([this](const MTPBool &result) {
_api.request(MTPphone_ReceivedCall(
MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash))
)).done([=](const MTPBool &result) {
if (_state == State::Starting) {
setState(State::WaitingIncoming);
}
}).fail([this](const RPCError &error) {
}).fail([=](const RPCError &error) {
handleRequestError(error);
}).send();
}
@ -267,7 +270,7 @@ void Call::actuallyAnswer() {
} else {
_answerAfterDhConfigReceived = false;
}
request(MTPphone_AcceptCall(
_api.request(MTPphone_AcceptCall(
MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)),
MTP_bytes(_gb),
MTP_phoneCallProtocol(
@ -504,7 +507,7 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) {
_keyFingerprint = ComputeFingerprint(_authKey);
setState(State::ExchangingKeys);
request(MTPphone_ConfirmCall(
_api.request(MTPphone_ConfirmCall(
MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)),
MTP_bytes(_ga),
MTP_long(_keyFingerprint),
@ -623,10 +626,10 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
_controller->SetEncryptionKey(reinterpret_cast<char*>(_authKey.data()), (_type == Type::Outgoing));
_controller->SetCallbacks(callbacks);
if (Global::UseProxyForCalls()
&& (Global::ProxySettings() == ProxyData::Settings::Enabled)) {
&& (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled)) {
const auto &proxy = Global::SelectedProxy();
if (proxy.supportsCalls()) {
Assert(proxy.type == ProxyData::Type::Socks5);
Assert(proxy.type == MTP::ProxyData::Type::Socks5);
_controller->SetProxy(
tgvoip::PROXY_SOCKS5,
proxy.host.toStdString(),
@ -840,7 +843,7 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) {
auto duration = getDurationMs() / 1000;
auto connectionId = _controller ? _controller->GetPreferredRelayID() : 0;
_finishByTimeoutTimer.call(kHangupTimeoutMs, [this, finalState] { setState(finalState); });
request(MTPphone_DiscardCall(
_api.request(MTPphone_DiscardCall(
MTP_flags(0),
MTP_inputPhoneCall(
MTP_long(_id),

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer.h"
#include "base/bytes.h"
#include "mtproto/sender.h"
#include "mtproto/auth_key.h"
#include "mtproto/mtproto_auth_key.h"
namespace Media {
namespace Audio {
@ -31,7 +31,7 @@ struct DhConfig {
bytes::vector p;
};
class Call : public base::has_weak_ptr, private MTP::Sender {
class Call : public base::has_weak_ptr {
public:
class Delegate {
public:
@ -183,6 +183,7 @@ private:
not_null<Delegate*> _delegate;
not_null<UserData*> _user;
MTP::Sender _api;
Type _type = Type::Outgoing;
State _state = State::Starting;
FinishType _finishAfterRequestingCall = FinishType::None;

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "calls/calls_instance.h"
#include "mtproto/connection.h"
#include "mtproto/mtproto_dh_utils.h"
#include "core/application.h"
#include "main/main_session.h"
#include "apiwrap.h"
@ -32,7 +32,9 @@ constexpr auto kServerConfigUpdateTimeoutMs = 24 * 3600 * crl::time(1000);
} // namespace
Instance::Instance(not_null<Main::Session*> session) : _session(session) {
Instance::Instance(not_null<Main::Session*> session)
: _session(session)
, _api(_session->api().instance()) {
}
void Instance::startOutgoingCall(not_null<UserData*> user) {
@ -139,7 +141,7 @@ void Instance::refreshDhConfig() {
Expects(_currentCall != nullptr);
const auto weak = base::make_weak(_currentCall);
request(MTPmessages_GetDhConfig(
_api.request(MTPmessages_GetDhConfig(
MTP_int(_dhConfig.version),
MTP_int(MTP::ModExpFirst::kRandomPowerSize)
)).done([=](const MTPmessages_DhConfig &result) {
@ -203,13 +205,14 @@ void Instance::refreshServerConfig() {
if (_lastServerConfigUpdateTime && (crl::now() - _lastServerConfigUpdateTime) < kServerConfigUpdateTimeoutMs) {
return;
}
_serverConfigRequestId = request(MTPphone_GetCallConfig()).done([this](const MTPDataJSON &result) {
_serverConfigRequestId = _api.request(MTPphone_GetCallConfig(
)).done([=](const MTPDataJSON &result) {
_serverConfigRequestId = 0;
_lastServerConfigUpdateTime = crl::now();
const auto &json = result.c_dataJSON().vdata().v;
UpdateConfig(std::string(json.data(), json.size()));
}).fail([this](const RPCError &error) {
}).fail([=](const RPCError &error) {
_serverConfigRequestId = 0;
}).send();
}
@ -246,7 +249,7 @@ void Instance::handleCallUpdate(const MTPPhoneCall &call) {
LOG(("API Error: Self found in phoneCallRequested."));
}
if (alreadyInCall() || !user || user->isSelf()) {
request(MTPphone_DiscardCall(
_api.request(MTPphone_DiscardCall(
MTP_flags(0),
MTP_inputPhoneCall(phoneCall.vid(), phoneCall.vaccess_hash()),
MTP_int(0),

View File

@ -25,8 +25,7 @@ namespace Calls {
class Panel;
class Instance
: private MTP::Sender
, private Call::Delegate
: private Call::Delegate
, private base::Subscriber
, public base::has_weak_ptr {
public:
@ -74,6 +73,7 @@ private:
void handleCallUpdate(const MTPPhoneCall &call);
const not_null<Main::Session*> _session;
MTP::Sender _api;
DhConfig _dhConfig;

View File

@ -427,7 +427,7 @@ object_ptr<TabbedSelector::InnerFooter> EmojiListWidget::createFooter() {
Expects(_footer == nullptr);
auto result = object_ptr<Footer>(this);
_footer = result;
return std::move(result);
return result;
}
template <typename Callback>

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h"
#include "data/data_user.h"
#include "data/data_peer_values.h"
#include "data/data_file_origin.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "storage/localstorage.h"

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "styles/style_chat_helpers.h"
#include "data/data_file_origin.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/effects/ripple_animation.h"
@ -22,10 +22,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "window/window_session_controller.h"
#include "history/view/history_view_cursor_state.h"
#include "facades.h"
#include "app.h"
#include "styles/style_chat_helpers.h"
#include <QtWidgets/QApplication>
@ -130,6 +132,7 @@ GifsListWidget::GifsListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller)
: Inner(parent, controller)
, _api(controller->session().api().instance())
, _section(Section::Gifs)
, _updateInlineItems([=] { updateInlineItems(); })
, _previewTimer([=] { showPreview(); }) {
@ -178,7 +181,7 @@ object_ptr<TabbedSelector::InnerFooter> GifsListWidget::createFooter() {
auto result = object_ptr<Footer>(this);
_footer = result;
return std::move(result);
return result;
}
void GifsListWidget::visibleTopBottomUpdated(
@ -217,7 +220,7 @@ GifsListWidget::~GifsListWidget() {
void GifsListWidget::cancelGifsSearch() {
_footer->setLoading(false);
if (_inlineRequestId) {
request(_inlineRequestId).cancel();
_api.request(_inlineRequestId).cancel();
_inlineRequestId = 0;
}
_inlineRequestTimer.stop();
@ -840,7 +843,7 @@ void GifsListWidget::searchForGifs(const QString &query) {
if (_inlineQuery != query) {
_footer->setLoading(false);
if (_inlineRequestId) {
request(_inlineRequestId).cancel();
_api.request(_inlineRequestId).cancel();
_inlineRequestId = 0;
}
if (_inlineCache.find(query) != _inlineCache.cend()) {
@ -855,7 +858,7 @@ void GifsListWidget::searchForGifs(const QString &query) {
if (!_searchBot && !_searchBotRequestId) {
auto username = str_const_toString(kSearchBotUsername);
_searchBotRequestId = request(MTPcontacts_ResolveUsername(
_searchBotRequestId = _api.request(MTPcontacts_ResolveUsername(
MTP_string(username)
)).done([=](const MTPcontacts_ResolvedPeer &result) {
Expects(result.type() == mtpc_contacts_resolvedPeer);
@ -905,7 +908,7 @@ void GifsListWidget::sendInlineRequest() {
}
_footer->setLoading(true);
_inlineRequestId = request(MTPmessages_GetInlineBotResults(
_inlineRequestId = _api.request(MTPmessages_GetInlineBotResults(
MTP_flags(0),
_searchBot->inputUser,
_inlineQueryPeer->input,

View File

@ -34,8 +34,7 @@ namespace ChatHelpers {
class GifsListWidget
: public TabbedSelector::Inner
, public InlineBots::Layout::Context
, private base::Subscriber
, private MTP::Sender {
, private base::Subscriber {
public:
using InlineChosen = TabbedSelector::InlineChosen;
@ -119,6 +118,8 @@ private:
void updateInlineItems();
void showPreview();
MTP::Sender _api;
Section _section = Section::Gifs;
crl::time _lastScrolled = 0;
base::Timer _updateInlineItems;

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_file_origin.h"
#include "boxes/stickers_box.h"
#include "boxes/confirm_box.h"
#include "lang/lang_keys.h"
@ -891,7 +892,7 @@ std::optional<std::vector<not_null<EmojiPtr>>> GetEmojiListFromSet(
if (result.empty()) {
return std::nullopt;
}
return std::move(result);
return result;
}
return std::nullopt;
}

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_channel.h"
#include "data/data_file_origin.h"
#include "ui/widgets/buttons.h"
#include "ui/effects/animations.h"
#include "ui/effects/ripple_animation.h"
@ -828,6 +829,7 @@ StickersListWidget::StickersListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller)
: Inner(parent, controller)
, _api(controller->session().api().instance())
, _section(Section::Stickers)
, _megagroupSetAbout(st::columnMinimalWidthThird - st::emojiScroll.width - st::emojiPanHeaderLeft)
, _addText(tr::lng_stickers_featured_add(tr::now).toUpper())
@ -878,7 +880,7 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
auto result = object_ptr<Footer>(this);
_footer = result;
return std::move(result);
return result;
}
void StickersListWidget::visibleTopBottomUpdated(
@ -1069,7 +1071,7 @@ void StickersListWidget::sendSearchRequest() {
_footer->setLoading(true);
const auto hash = int32(0);
_searchRequestId = request(MTPmessages_SearchStickerSets(
_searchRequestId = _api.request(MTPmessages_SearchStickerSets(
MTP_flags(0),
MTP_string(_searchQuery),
MTP_int(hash)
@ -1092,7 +1094,7 @@ void StickersListWidget::searchForSets(const QString &query) {
if (_searchQuery != cleaned) {
_footer->setLoading(false);
if (const auto requestId = base::take(_searchRequestId)) {
request(requestId).cancel();
_api.request(requestId).cancel();
}
if (_searchCache.find(cleaned) != _searchCache.cend()) {
_searchRequestTimer.cancel();
@ -1108,7 +1110,7 @@ void StickersListWidget::searchForSets(const QString &query) {
void StickersListWidget::cancelSetsSearch() {
_footer->setLoading(false);
if (const auto requestId = base::take(_searchRequestId)) {
request(requestId).cancel();
_api.request(requestId).cancel();
}
_searchRequestTimer.cancel();
_searchQuery = _searchNextQuery = QString();
@ -2468,7 +2470,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
return;
}
_megagroupSetIdRequested = set.vid().v;
request(MTPmessages_GetStickerSet(
_api.request(MTPmessages_GetStickerSet(
_megagroupSet->mgInfo->stickerSet
)).done([=](const MTPmessages_StickerSet &result) {
if (const auto set = Stickers::FeedSetFull(result)) {
@ -2810,7 +2812,7 @@ void StickersListWidget::installSet(uint64 setId) {
const auto input = Stickers::inputSetId(*it);
if ((it->flags & MTPDstickerSet_ClientFlag::f_not_loaded)
|| it->stickers.empty()) {
request(MTPmessages_GetStickerSet(
_api.request(MTPmessages_GetStickerSet(
input
)).done([=](const MTPmessages_StickerSet &result) {
Stickers::FeedSetFull(result);
@ -2825,7 +2827,7 @@ void StickersListWidget::installSet(uint64 setId) {
void StickersListWidget::sendInstallRequest(
uint64 setId,
const MTPInputStickerSet &input) {
request(MTPmessages_InstallStickerSet(
_api.request(MTPmessages_InstallStickerSet(
input,
MTP_bool(false)
)).done([=](const MTPmessages_StickerSetInstallResult &result) {
@ -2876,9 +2878,9 @@ void StickersListWidget::removeSet(uint64 setId) {
auto it = sets.find(_removingSetId);
if (it != sets.cend()) {
if (it->id && it->access) {
request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)))).send();
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)))).send();
} else if (!it->shortName.isEmpty()) {
request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(it->shortName)))).send();
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(it->shortName)))).send();
}
auto writeRecent = false;
auto &recent = Stickers::GetRecentPack();

View File

@ -38,8 +38,7 @@ struct StickerIcon;
class StickersListWidget
: public TabbedSelector::Inner
, private base::Subscriber
, private MTP::Sender {
, private base::Subscriber {
public:
StickersListWidget(
QWidget *parent,
@ -300,6 +299,7 @@ private:
void showPreview();
MTP::Sender _api;
ChannelData *_megagroupSet = nullptr;
uint64 _megagroupSetIdRequested = 0;
std::vector<Set> _mySets;

View File

@ -20,7 +20,7 @@ object_ptr<Window::SectionWidget> TabbedMemento::createWidget(
const QRect &geometry) {
auto result = object_ptr<TabbedSection>(parent, controller);
result->setGeometry(geometry);
return std::move(result);
return result;
}
TabbedSection::TabbedSection(

View File

@ -14,7 +14,7 @@ from generate_tl import generate
generate({
'namespaces': {
'creator': 'MTP::internal',
'creator': 'MTP::details',
},
'prefixes': {
'type': 'MTP',
@ -28,7 +28,6 @@ generate({
'buffer': 'mtpBuffer',
},
'sections': [
'serialization',
'read-write',
],
@ -91,4 +90,8 @@ generate({
},
'builtinInclude': 'mtproto/core_types.h',
'dumpToText': {
'include': 'mtproto/details/mtproto_dump_to_text.h',
},
})

View File

@ -93,6 +93,7 @@ Application::Application(not_null<Launcher*> launcher)
, _dcOptions(std::make_unique<MTP::DcOptions>())
, _account(std::make_unique<Main::Account>(cDataFile()))
, _langpack(std::make_unique<Lang::Instance>())
, _langCloudManager(std::make_unique<Lang::CloudManager>(langpack()))
, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
, _audio(std::make_unique<Media::Audio::Instance>())
, _logo(Window::LoadLogo())
@ -114,9 +115,6 @@ Application::Application(not_null<Launcher*> launcher)
) | rpl::filter([=](MTP::Instance *instance) {
return instance != nullptr;
}) | rpl::start_with_next([=](not_null<MTP::Instance*> mtp) {
_langCloudManager = std::make_unique<Lang::CloudManager>(
langpack(),
mtp);
if (!UpdaterDisabled()) {
UpdateChecker().setMtproto(mtp.get());
}
@ -134,11 +132,6 @@ Application::~Application() {
// Some MTP requests can be cancelled from data clearing.
unlockTerms();
activeAccount().destroySession();
// The langpack manager should be destroyed before MTProto instance,
// because it is MTP::Sender and it may have pending requests.
_langCloudManager.reset();
activeAccount().clearMtp();
Shortcuts::Finish();
@ -146,7 +139,6 @@ Application::~Application() {
Ui::Emoji::Clear();
Media::Clip::Finish();
stopWebLoadManager();
App::deinitMedia();
Window::Theme::Uninitialize();
@ -191,9 +183,9 @@ void Application::run() {
style::ShortAnimationPlaying(
) | rpl::start_with_next([=](bool playing) {
if (playing) {
MTP::internal::pause();
MTP::details::pause();
} else {
MTP::internal::unpause();
MTP::details::unpause();
}
}, _lifetime);
@ -370,12 +362,12 @@ void Application::saveSettingsDelayed(crl::time delay) {
}
void Application::setCurrentProxy(
const ProxyData &proxy,
ProxyData::Settings settings) {
const MTP::ProxyData &proxy,
MTP::ProxyData::Settings settings) {
const auto current = [&] {
return (Global::ProxySettings() == ProxyData::Settings::Enabled)
return (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled)
? Global::SelectedProxy()
: ProxyData();
: MTP::ProxyData();
};
const auto was = current();
Global::SetSelectedProxy(proxy);
@ -391,12 +383,12 @@ auto Application::proxyChanges() const -> rpl::producer<ProxyChange> {
}
void Application::badMtprotoConfigurationError() {
if (Global::ProxySettings() == ProxyData::Settings::Enabled
if (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled
&& !_badProxyDisableBox) {
const auto disableCallback = [=] {
setCurrentProxy(
Global::SelectedProxy(),
ProxyData::Settings::System);
MTP::ProxyData::Settings::System);
};
_badProxyDisableBox = Ui::show(Box<InformBox>(
Lang::Hard::ProxyConfigError(),
@ -406,14 +398,18 @@ void Application::badMtprotoConfigurationError() {
void Application::startLocalStorage() {
Local::start();
subscribe(_dcOptions->changed(), [this](const MTP::DcOptions::Ids &ids) {
Local::writeSettings();
if (const auto instance = activeAccount().mtp()) {
for (const auto id : ids) {
instance->restart(id);
}
}
});
const auto writing = _lifetime.make_state<bool>(false);
_dcOptions->changed(
) | rpl::filter([=] {
return !*writing;
}) | rpl::start_with_next([=] {
*writing = true;
Ui::PostponeCall(this, [=] {
Local::writeSettings();
});
}, _lifetime);
_saveSettingsTimer.setCallback([=] { Local::writeSettings(); });
}

View File

@ -8,7 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "core/core_settings.h"
#include "mtproto/auth_key.h"
#include "mtproto/mtproto_auth_key.h"
#include "mtproto/mtproto_proxy_data.h"
#include "base/observer.h"
#include "base/timer.h"
@ -131,12 +132,12 @@ public:
return _dcOptions.get();
}
struct ProxyChange {
ProxyData was;
ProxyData now;
MTP::ProxyData was;
MTP::ProxyData now;
};
void setCurrentProxy(
const ProxyData &proxy,
ProxyData::Settings settings);
const MTP::ProxyData &proxy,
MTP::ProxyData::Settings settings);
[[nodiscard]] rpl::producer<ProxyChange> proxyChanges() const;
void badMtprotoConfigurationError();
@ -265,7 +266,7 @@ private:
std::unique_ptr<Window::Controller> _window;
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
const std::unique_ptr<Lang::Instance> _langpack;
std::unique_ptr<Lang::CloudManager> _langCloudManager;
const std::unique_ptr<Lang::CloudManager> _langCloudManager;
const std::unique_ptr<ChatHelpers::EmojiKeywords> _emojiKeywords;
std::unique_ptr<Lang::Translator> _translator;
base::Observable<void> _passcodedChanged;

View File

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_cloud_password.h"
#include "base/openssl_help.h"
#include "mtproto/connection.h"
#include "mtproto/mtproto_dh_utils.h"
namespace Core {
namespace {

View File

@ -814,10 +814,10 @@ void LastCrashedWindow::onNetworkSettingsSaved(
QString password) {
Expects(host.isEmpty() || port != 0);
auto proxy = ProxyData();
auto proxy = MTP::ProxyData();
proxy.type = host.isEmpty()
? ProxyData::Type::None
: ProxyData::Type::Http;
? MTP::ProxyData::Type::None
: MTP::ProxyData::Type::Http;
proxy.host = host;
proxy.port = port;
proxy.user = username;
@ -843,7 +843,7 @@ void LastCrashedWindow::proxyUpdated() {
activate();
}
rpl::producer<ProxyData> LastCrashedWindow::proxyChanges() const {
rpl::producer<MTP::ProxyData> LastCrashedWindow::proxyChanges() const {
return _proxyChanges.events();
}

View File

@ -16,6 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtNetwork/QHttpMultiPart>
#include <QtNetwork/QNetworkAccessManager>
namespace MTP {
struct ProxyData;
} // namespace MTP
namespace Core {
class Launcher;
} // namespace Core
@ -96,7 +100,7 @@ public:
const QByteArray &crashdump,
Fn<void()> launch);
rpl::producer<ProxyData> proxyChanges() const;
rpl::producer<MTP::ProxyData> proxyChanges() const;
rpl::lifetime &lifetime() {
return _lifetime;
@ -199,7 +203,7 @@ private:
void setDownloadProgress(qint64 ready, qint64 total);
Fn<void()> _launch;
rpl::event_stream<ProxyData> _proxyChanges;
rpl::event_stream<MTP::ProxyData> _proxyChanges;
rpl::lifetime _lifetime;
};

View File

@ -341,6 +341,7 @@ QString PlatformString() {
}
void StartCatching(not_null<Core::Launcher*> launcher) {
return; AssertIsDebug();
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(ApiId).toUtf8().constData();

View File

@ -163,7 +163,9 @@ bool ApplySocksProxy(
auto params = url_parse_params(
match->captured(1),
qthelp::UrlParamNameTransform::ToLower);
ProxiesBoxController::ShowApplyConfirmation(ProxyData::Type::Socks5, params);
ProxiesBoxController::ShowApplyConfirmation(
MTP::ProxyData::Type::Socks5,
params);
return true;
}
@ -174,7 +176,9 @@ bool ApplyMtprotoProxy(
auto params = url_parse_params(
match->captured(1),
qthelp::UrlParamNameTransform::ToLower);
ProxiesBoxController::ShowApplyConfirmation(ProxyData::Type::Mtproto, params);
ProxiesBoxController::ShowApplyConfirmation(
MTP::ProxyData::Type::Mtproto,
params);
return true;
}

View File

@ -329,7 +329,7 @@ void Sandbox::singleInstanceChecked() {
_lastCrashDump,
[=] { launchApplication(); });
window->proxyChanges(
) | rpl::start_with_next([=](ProxyData &&proxy) {
) | rpl::start_with_next([=](MTP::ProxyData &&proxy) {
_sandboxProxy = std::move(proxy);
refreshGlobalProxy();
}, window->lifetime());
@ -443,15 +443,15 @@ void Sandbox::refreshGlobalProxy() {
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
const auto proxy = !Global::started()
? _sandboxProxy
: (Global::ProxySettings() == ProxyData::Settings::Enabled)
: (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled)
? Global::SelectedProxy()
: ProxyData();
if (proxy.type == ProxyData::Type::Socks5
|| proxy.type == ProxyData::Type::Http) {
: MTP::ProxyData();
if (proxy.type == MTP::ProxyData::Type::Socks5
|| proxy.type == MTP::ProxyData::Type::Http) {
QNetworkProxy::setApplicationProxy(
ToNetworkProxy(ToDirectIpProxy(proxy)));
MTP::ToNetworkProxy(MTP::ToDirectIpProxy(proxy)));
} else if (!Global::started()
|| Global::ProxySettings() == ProxyData::Settings::System) {
|| Global::ProxySettings() == MTP::ProxyData::Settings::System) {
QNetworkProxyFactory::setUseSystemConfiguration(true);
} else {
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
@ -555,7 +555,7 @@ rpl::producer<> Sandbox::widgetUpdateRequests() const {
return _widgetUpdateRequests.events();
}
ProxyData Sandbox::sandboxProxy() const {
MTP::ProxyData Sandbox::sandboxProxy() const {
return _sandboxProxy;
}

View File

@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "mtproto/mtproto_proxy_data.h"
#include <QtWidgets/QApplication>
#include <QtNetwork/QLocalServer>
#include <QtNetwork/QLocalSocket>
@ -50,7 +52,7 @@ public:
rpl::producer<> widgetUpdateRequests() const;
ProxyData sandboxProxy() const;
MTP::ProxyData sandboxProxy() const;
static Sandbox &Instance() {
Expects(QCoreApplication::instance() != nullptr);
@ -119,7 +121,7 @@ private:
std::unique_ptr<UpdateChecker> _updateChecker;
QByteArray _lastCrashDump;
ProxyData _sandboxProxy;
MTP::ProxyData _sandboxProxy;
rpl::event_stream<> _widgetUpdateRequests;

View File

@ -58,134 +58,6 @@ static_assert(sizeof(MTPdouble) == 8, "Basic types size check failed");
static_assert(sizeof(int) >= 4, "Basic types size check failed");
namespace {
std::atomic<int> GlobalAtomicRequestId = 0;
[[nodiscard]] bool IsHexMtprotoPassword(const QString &password) {
const auto size = password.size();
if (size < 32 || size % 2 == 1) {
return false;
}
const auto bad = [](QChar ch) {
const auto code = ch.unicode();
return (code < 'a' || code > 'f')
&& (code < 'A' || code > 'F')
&& (code < '0' || code > '9');
};
const auto i = std::find_if(password.begin(), password.end(), bad);
return (i == password.end());
}
[[nodiscard]] ProxyData::Status HexMtprotoPasswordStatus(
const QString &password) {
const auto size = password.size() / 2;
const auto valid = (size == 16)
|| (size == 17 && (password[0] == 'd') && (password[1] == 'd'))
|| (size >= 21 && (password[0] == 'e') && (password[1] == 'e'));
if (valid) {
return ProxyData::Status::Valid;
} else if (size < 16) {
return ProxyData::Status::Invalid;
}
return ProxyData::Status::Unsupported;
}
[[nodiscard]] bytes::vector SecretFromHexMtprotoPassword(
const QString &password) {
Expects(password.size() % 2 == 0);
const auto size = password.size() / 2;
const auto fromHex = [](QChar ch) -> int {
const auto code = int(ch.unicode());
if (code >= '0' && code <= '9') {
return (code - '0');
} else if (code >= 'A' && code <= 'F') {
return 10 + (code - 'A');
} else if (ch >= 'a' && ch <= 'f') {
return 10 + (code - 'a');
}
Unexpected("Code in ProxyData fromHex.");
};
auto result = bytes::vector(size);
for (auto i = 0; i != size; ++i) {
const auto high = fromHex(password[2 * i]);
const auto low = fromHex(password[2 * i + 1]);
if (high < 0 || low < 0) {
return {};
}
result[i] = static_cast<bytes::type>(high * 16 + low);
}
return result;
}
[[nodiscard]] QStringRef Base64UrlInner(const QString &password) {
Expects(password.size() > 2);
// Skip one or two '=' at the end of the string.
return password.midRef(0, [&] {
auto result = password.size();
for (auto i = 0; i != 2; ++i) {
const auto prev = result - 1;
if (password[prev] != '=') {
break;
}
result = prev;
}
return result;
}());
}
[[nodiscard]] bool IsBase64UrlMtprotoPassword(const QString &password) {
const auto size = password.size();
if (size < 22 || size % 4 == 1) {
return false;
}
const auto bad = [](QChar ch) {
const auto code = ch.unicode();
return (code < 'a' || code > 'z')
&& (code < 'A' || code > 'Z')
&& (code < '0' || code > '9')
&& (code != '_')
&& (code != '-');
};
const auto inner = Base64UrlInner(password);
const auto begin = inner.data();
const auto end = begin + inner.size();
return (std::find_if(begin, end, bad) == end);
}
[[nodiscard]] ProxyData::Status Base64UrlMtprotoPasswordStatus(
const QString &password) {
const auto inner = Base64UrlInner(password);
const auto size = (inner.size() * 3) / 4;
const auto valid = (size == 16)
|| (size == 17
&& (password[0] == '3')
&& ((password[1] >= 'Q' && password[1] <= 'Z')
|| (password[1] >= 'a' && password[1] <= 'f')))
|| (size >= 21
&& (password[0] == '7')
&& (password[1] >= 'g')
&& (password[1] <= 'v'));
if (size < 16) {
return ProxyData::Status::Invalid;
} else if (valid) {
return ProxyData::Status::Valid;
}
return ProxyData::Status::Unsupported;
}
[[nodiscard]] bytes::vector SecretFromBase64UrlMtprotoPassword(
const QString &password) {
const auto result = QByteArray::fromBase64(
password.toLatin1(),
QByteArray::Base64UrlEncoding);
return bytes::make_vector(bytes::make_span(result));
}
} // namespace
// Precise timing functions / rand init
struct CRYPTO_dynlock_value {
@ -248,105 +120,6 @@ namespace {
}
}
bool ProxyData::valid() const {
return status() == Status::Valid;
}
ProxyData::Status ProxyData::status() const {
if (type == Type::None || host.isEmpty() || !port) {
return Status::Invalid;
} else if (type == Type::Mtproto) {
return MtprotoPasswordStatus(password);
}
return Status::Valid;
}
bool ProxyData::supportsCalls() const {
return (type == Type::Socks5);
}
bool ProxyData::tryCustomResolve() const {
return (type == Type::Socks5 || type == Type::Mtproto)
&& !qthelp::is_ipv6(host)
&& !QRegularExpression(
qsl("^\\d+\\.\\d+\\.\\d+\\.\\d+$")
).match(host).hasMatch();
}
bytes::vector ProxyData::secretFromMtprotoPassword() const {
Expects(type == Type::Mtproto);
if (IsHexMtprotoPassword(password)) {
return SecretFromHexMtprotoPassword(password);
} else if (IsBase64UrlMtprotoPassword(password)) {
return SecretFromBase64UrlMtprotoPassword(password);
}
return {};
}
ProxyData::operator bool() const {
return valid();
}
bool ProxyData::operator==(const ProxyData &other) const {
if (!valid()) {
return !other.valid();
}
return (type == other.type)
&& (host == other.host)
&& (port == other.port)
&& (user == other.user)
&& (password == other.password);
}
bool ProxyData::operator!=(const ProxyData &other) const {
return !(*this == other);
}
bool ProxyData::ValidMtprotoPassword(const QString &password) {
return MtprotoPasswordStatus(password) == Status::Valid;
}
ProxyData::Status ProxyData::MtprotoPasswordStatus(const QString &password) {
if (IsHexMtprotoPassword(password)) {
return HexMtprotoPasswordStatus(password);
} else if (IsBase64UrlMtprotoPassword(password)) {
return Base64UrlMtprotoPasswordStatus(password);
}
return Status::Invalid;
}
ProxyData ToDirectIpProxy(const ProxyData &proxy, int ipIndex) {
if (!proxy.tryCustomResolve()
|| ipIndex < 0
|| ipIndex >= proxy.resolvedIPs.size()) {
return proxy;
}
return {
proxy.type,
proxy.resolvedIPs[ipIndex],
proxy.port,
proxy.user,
proxy.password
};
}
QNetworkProxy ToNetworkProxy(const ProxyData &proxy) {
if (proxy.type == ProxyData::Type::None) {
return QNetworkProxy::DefaultProxy;
} else if (proxy.type == ProxyData::Type::Mtproto) {
return QNetworkProxy::NoProxy;
}
return QNetworkProxy(
(proxy.type == ProxyData::Type::Socks5
? QNetworkProxy::Socks5Proxy
: QNetworkProxy::HttpProxy),
proxy.host,
proxy.port,
proxy.user,
proxy.password);
}
namespace ThirdParty {
void start() {
@ -427,14 +200,6 @@ namespace ThirdParty {
}
}
int GetNextRequestId() {
const auto result = ++GlobalAtomicRequestId;
if (result == std::numeric_limits<int>::max() / 2) {
GlobalAtomicRequestId = 0;
}
return result;
}
int32 *hashSha1(const void *data, uint32 len, void *dest) {
return (int32*)SHA1((const uchar*)data, (size_t)len, (uchar*)dest);
}

View File

@ -25,12 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace base {
template <typename T>
using set_of_unique_ptr = std::set<std::unique_ptr<T>, base::pointer_comparator<T>>;
template <typename T>
using set_of_shared_ptr = std::set<std::shared_ptr<T>, base::pointer_comparator<T>>;
template <typename Value, typename From, typename Till>
inline bool in_range(Value &&value, From &&from, Till &&till) {
return (value >= from) && (value < till);
@ -88,8 +82,6 @@ inline QByteArray str_const_toByteArray(const str_const &str) {
return QByteArray::fromRawData(str.c_str(), str.size());
}
int GetNextRequestId();
inline void mylocaltime(struct tm * _Tm, const time_t * _Time) {
#ifdef Q_OS_WIN
localtime_s(_Tm, _Time);
@ -167,37 +159,6 @@ T rand_value() {
return result;
}
class ReadLockerAttempt {
public:
ReadLockerAttempt(not_null<QReadWriteLock*> lock) : _lock(lock), _locked(_lock->tryLockForRead()) {
}
ReadLockerAttempt(const ReadLockerAttempt &other) = delete;
ReadLockerAttempt &operator=(const ReadLockerAttempt &other) = delete;
ReadLockerAttempt(ReadLockerAttempt &&other) : _lock(other._lock), _locked(base::take(other._locked)) {
}
ReadLockerAttempt &operator=(ReadLockerAttempt &&other) {
_lock = other._lock;
_locked = base::take(other._locked);
return *this;
}
~ReadLockerAttempt() {
if (_locked) {
_lock->unlock();
}
}
operator bool() const {
return _locked;
}
private:
not_null<QReadWriteLock*> _lock;
bool _locked = false;
};
static const QRegularExpression::PatternOptions reMultiline(QRegularExpression::DotMatchesEverythingOption | QRegularExpression::MultilineOption);
template <typename T>
inline T snap(const T &v, const T &_min, const T &_max) {
return (v < _min) ? _min : ((v > _max) ? _max : v);
@ -218,50 +179,6 @@ enum DBIWorkMode {
dbiwmWindowOnly = 2,
};
struct ProxyData {
enum class Settings {
System,
Enabled,
Disabled,
};
enum class Type {
None,
Socks5,
Http,
Mtproto,
};
enum class Status {
Valid,
Unsupported,
Invalid,
};
Type type = Type::None;
QString host;
uint32 port = 0;
QString user, password;
std::vector<QString> resolvedIPs;
crl::time resolvedExpireAt = 0;
[[nodiscard]] bool valid() const;
[[nodiscard]] Status status() const;
[[nodiscard]] bool supportsCalls() const;
[[nodiscard]] bool tryCustomResolve() const;
[[nodiscard]] bytes::vector secretFromMtprotoPassword() const;
[[nodiscard]] explicit operator bool() const;
[[nodiscard]] bool operator==(const ProxyData &other) const;
[[nodiscard]] bool operator!=(const ProxyData &other) const;
[[nodiscard]] static bool ValidMtprotoPassword(const QString &password);
[[nodiscard]] static Status MtprotoPasswordStatus(
const QString &password);
};
ProxyData ToDirectIpProxy(const ProxyData &proxy, int ipIndex = 0);
QNetworkProxy ToNetworkProxy(const ProxyData &proxy);
static const int MatrixRowShift = 40000;
inline int rowscount(int fullCount, int countPerRow) {

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#define TDESKTOP_REQUESTED_ALPHA_VERSION (0ULL)
#define TDESKTOP_REQUESTED_ALPHA_VERSION (1009001007ULL)
#ifdef TDESKTOP_OFFICIAL_TARGET
#define TDESKTOP_ALPHA_VERSION TDESKTOP_REQUESTED_ALPHA_VERSION
@ -17,5 +17,5 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
constexpr auto AppVersion = 1009001;
constexpr auto AppVersionStr = "1.9.1";
constexpr auto AppBetaVersion = true;
constexpr auto AppBetaVersion = false;
constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION;

View File

@ -21,6 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/streaming/media_streaming_loader_local.h"
#include "storage/localstorage.h"
#include "storage/streamed_file_downloader.h"
#include "storage/file_download_mtproto.h"
#include "storage/file_download_web.h"
#include "platform/platform_specific.h"
#include "history/history.h"
#include "history/history_item.h"
@ -815,7 +817,6 @@ void DocumentData::destroyLoader() const {
if (cancelled()) {
loader->cancel();
}
loader->stop();
}
bool DocumentData::loading() const {

View File

@ -33,6 +33,12 @@ struct FileReferenceAccumulator {
}, [](const MTPDdocumentEmpty &data) {
});
}
void push(const MTPPage &data) {
data.match([&](const auto &data) {
push(data.vphotos());
push(data.vdocuments());
});
}
void push(const MTPWallPaper &data) {
data.match([&](const MTPDwallPaper &data) {
push(data.vdocument());
@ -57,6 +63,9 @@ struct FileReferenceAccumulator {
if (const auto photo = data.vphoto()) {
push(*photo);
}
if (const auto page = data.vcached_page()) {
push(*page);
}
}, [](const auto &data) {
});
}

View File

@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_web_page.h"
#include "data/data_poll.h"
#include "data/data_channel.h"
#include "data/data_file_origin.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "storage/file_upload.h"

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_channel.h"
#include "history/history.h"
#include "history/history_item.h"
#include "apiwrap.h"
namespace Api {
namespace {
@ -191,6 +192,10 @@ SearchController::CacheEntry::CacheEntry(const Query &query)
: std::nullopt) {
}
SearchController::SearchController(not_null<Main::Session*> session)
: _api(session->api().instance()) {
}
bool SearchController::hasInCache(const Query &query) const {
return query.query.isEmpty() || _cache.contains(query);
}
@ -361,7 +366,7 @@ void SearchController::requestMore(
if (!prepared) {
return;
}
auto requestId = request(
auto requestId = _api.request(
std::move(*prepared)
).done([=](const MTPmessages_Messages &result) {
listData->requests.remove(key);
@ -377,11 +382,13 @@ void SearchController::requestMore(
parsed.fullCount);
}).send();
listData->requests.emplace(key, [=] {
request(requestId).cancel();
_api.request(requestId).cancel();
});
}
DelayedSearchController::DelayedSearchController() {
DelayedSearchController::DelayedSearchController(
not_null<Main::Session*> session)
: _controller(session) {
_timer.setCallback([this] { setQueryFast(_nextQuery); });
}

View File

@ -14,6 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/value_ordering.h"
#include "base/timer.h"
namespace Main {
class Session;
} // namespace Main
namespace Data {
enum class LoadDirection : char;
} // namespace Data
@ -40,7 +44,7 @@ SearchResult ParseSearchResult(
Data::LoadDirection direction,
const MTPmessages_Messages &data);
class SearchController : private MTP::Sender {
class SearchController final {
public:
using IdsList = Storage::SparseIdsList;
struct Query {
@ -67,6 +71,7 @@ public:
std::optional<IdsList> migratedList;
};
explicit SearchController(not_null<Main::Session*> session);
void setQuery(const Query &query);
bool hasInCache(const Query &query) const;
@ -124,6 +129,7 @@ private:
const Query &query,
Data *listData);
MTP::Sender _api;
Cache _cache;
Cache::iterator _current = _cache.end();
@ -131,7 +137,7 @@ private:
class DelayedSearchController {
public:
DelayedSearchController();
explicit DelayedSearchController(not_null<Main::Session*> session);
using Query = SearchController::Query;
using SavedState = SearchController::SavedState;

View File

@ -2464,7 +2464,6 @@ void InnerWidget::loadPeerPhotos() {
auto yFrom = _visibleTop;
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
session().downloader().clearPriorities();
if (_state == WidgetState::Default) {
auto otherStart = shownDialogs()->size() * st::dialogsRowHeight;
if (yFrom < otherStart) {

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "base/flags.h"
#include "base/object_ptr.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Main {
class Session;

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/scroll_area.h"
#include "ui/special_buttons.h"
#include "api/api_single_message_search.h"
#include "mtproto/mtproto_rpc_sender.h"
namespace Main {
class Session;

View File

@ -209,6 +209,32 @@ Utf8String FillLeft(const Utf8String &data, int length, char filler) {
return result;
}
bool RefreshFileReference(FileLocation &to, const FileLocation &from) {
if (to.dcId != from.dcId || to.data.type() != from.data.type()) {
return false;
}
if (to.data.type() == mtpc_inputPhotoFileLocation) {
const auto &toData = to.data.c_inputPhotoFileLocation();
const auto &fromData = from.data.c_inputPhotoFileLocation();
if (toData.vid().v != fromData.vid().v
|| toData.vthumb_size().v != fromData.vthumb_size().v) {
return false;
}
to = from;
return true;
} else if (to.data.type() == mtpc_inputDocumentFileLocation) {
const auto &toData = to.data.c_inputDocumentFileLocation();
const auto &fromData = from.data.c_inputDocumentFileLocation();
if (toData.vid().v != fromData.vid().v
|| toData.vthumb_size().v != fromData.vthumb_size().v) {
return false;
}
to = from;
return true;
}
return false;
}
Image ParseMaxImage(
const MTPDphoto &photo,
const QString &suggestedPath) {

View File

@ -60,6 +60,8 @@ struct FileLocation {
}
};
bool RefreshFileReference(FileLocation &to, const FileLocation &from);
struct File {
enum class SkipReason {
None,
@ -526,6 +528,12 @@ struct Message {
const Image &thumb() const;
};
struct FileOrigin {
int split = 0;
MTPInputPeer peer;
int32 messageId = 0;
};
Message ParseMessage(
ParseMediaContext &context,
const MTPMessage &data,

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/data/export_data_types.h"
#include "export/output/export_output_result.h"
#include "export/output/export_output_file.h"
#include "mtproto/rpc_sender.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "base/value_ordering.h"
#include "base/bytes.h"
#include <set>
@ -84,6 +84,10 @@ LocationKey ComputeLocationKey(const Data::FileLocation &value) {
result.type |= (8ULL << 24);
result.type |= (uint64(uint32(data.vlocal_id().v)) << 32);
result.id = data.vvolume_id().v;
}, [&](const MTPDinputPhotoLegacyFileLocation &data) {
result.type |= (9ULL << 24);
result.type |= (uint64(uint32(data.vlocal_id().v)) << 32);
result.id = data.vvolume_id().v;
});
return result;
}
@ -177,6 +181,7 @@ struct ApiWrap::FileProcess {
FnMut<void(const QString &relativePath)> done;
Data::FileLocation location;
Data::FileOrigin origin;
int offset = 0;
int size = 0;
@ -396,6 +401,9 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) {
} else if (result.type() == qstr("LOCATION_INVALID")
|| result.type() == qstr("VERSION_INVALID")) {
filePartUnavailable();
} else if (result.code() == 400
&& result.type().startsWith(qstr("FILE_REFERENCE_"))) {
filePartRefreshReference(offset);
} else {
error(std::move(result));
}
@ -692,6 +700,7 @@ void ApiWrap::requestOtherData(
_otherDataProcess->file.suggestedPath = suggestedPath;
loadFile(
_otherDataProcess->file,
Data::FileOrigin(),
[](FileProgress progress) { return true; },
[=](const QString &result) { otherDataDone(result); });
}
@ -776,6 +785,7 @@ void ApiWrap::loadNextUserpic() {
; ++_userpicsProcess->fileIndex) {
const auto ready = processFileLoad(
list[_userpicsProcess->fileIndex].image.file,
Data::FileOrigin(),
[=](FileProgress value) { return loadUserpicProgress(value); },
[=](const QString &path) { loadUserpicDone(path); });
if (!ready) {
@ -1378,6 +1388,24 @@ void ApiWrap::loadMessagesFiles(Data::MessagesSlice &&slice) {
loadNextMessageFile();
}
Data::Message *ApiWrap::currentFileMessage() const {
Expects(_chatProcess != nullptr);
Expects(_chatProcess->slice.has_value());
return &_chatProcess->slice->list[_chatProcess->fileIndex];
}
Data::FileOrigin ApiWrap::currentFileMessageOrigin() const {
Expects(_chatProcess != nullptr);
Expects(_chatProcess->slice.has_value());
auto result = Data::FileOrigin();
result.messageId = currentFileMessage()->id;
result.peer = _chatProcess->info.input;
result.split = _chatProcess->info.splits[_chatProcess->localSplitIndex];
return result;
}
void ApiWrap::loadNextMessageFile() {
Expects(_chatProcess != nullptr);
Expects(_chatProcess->slice.has_value());
@ -1394,9 +1422,10 @@ void ApiWrap::loadNextMessageFile() {
};
const auto ready = processFileLoad(
list[_chatProcess->fileIndex].file(),
currentFileMessageOrigin(),
fileProgress,
[=](const QString &path) { loadMessageFileDone(path); },
&list[_chatProcess->fileIndex]);
currentFileMessage());
if (!ready) {
return;
}
@ -1405,9 +1434,10 @@ void ApiWrap::loadNextMessageFile() {
};
const auto thumbReady = processFileLoad(
list[_chatProcess->fileIndex].thumb().file,
currentFileMessageOrigin(),
thumbProgress,
[=](const QString &path) { loadMessageThumbDone(path); },
&list[_chatProcess->fileIndex]);
currentFileMessage());
if (!thumbReady) {
return;
}
@ -1497,6 +1527,7 @@ void ApiWrap::finishMessages() {
bool ApiWrap::processFileLoad(
Data::File &file,
const Data::FileOrigin &origin,
Fn<bool(FileProgress)> progress,
FnMut<void(QString)> done,
Data::Message *message) {
@ -1508,7 +1539,7 @@ bool ApiWrap::processFileLoad(
} else if (!file.location && file.content.isEmpty()) {
file.skipReason = SkipReason::Unavailable;
return true;
} else if (writePreloadedFile(file)) {
} else if (writePreloadedFile(file, origin)) {
return !file.relativePath.isEmpty();
}
@ -1544,11 +1575,13 @@ bool ApiWrap::processFileLoad(
file.skipReason = SkipReason::FileSize;
return true;
}
loadFile(file, std::move(progress), std::move(done));
loadFile(file, origin, std::move(progress), std::move(done));
return false;
}
bool ApiWrap::writePreloadedFile(Data::File &file) {
bool ApiWrap::writePreloadedFile(
Data::File &file,
const Data::FileOrigin &origin) {
Expects(_settings != nullptr);
using namespace Output;
@ -1557,7 +1590,7 @@ bool ApiWrap::writePreloadedFile(Data::File &file) {
file.relativePath = *path;
return true;
} else if (!file.content.isEmpty()) {
const auto process = prepareFileProcess(file);
const auto process = prepareFileProcess(file, origin);
if (const auto result = process->file.writeBlock(file.content)) {
file.relativePath = process->relativePath;
_fileCache->save(file.location, file.relativePath);
@ -1571,13 +1604,14 @@ bool ApiWrap::writePreloadedFile(Data::File &file) {
void ApiWrap::loadFile(
const Data::File &file,
const Data::FileOrigin &origin,
Fn<bool(FileProgress)> progress,
FnMut<void(QString)> done) {
Expects(_fileProcess == nullptr);
Expects(file.location.dcId != 0
|| file.location.data.type() == mtpc_inputTakeoutFileLocation);
_fileProcess = prepareFileProcess(file);
_fileProcess = prepareFileProcess(file, origin);
_fileProcess->progress = std::move(progress);
_fileProcess->done = std::move(done);
@ -1594,7 +1628,9 @@ void ApiWrap::loadFile(
loadFilePart();
}
auto ApiWrap::prepareFileProcess(const Data::File &file) const
auto ApiWrap::prepareFileProcess(
const Data::File &file,
const Data::FileOrigin &origin) const
-> std::unique_ptr<FileProcess> {
Expects(_settings != nullptr);
@ -1607,6 +1643,7 @@ auto ApiWrap::prepareFileProcess(const Data::File &file) const
result->relativePath = relativePath;
result->location = file.location;
result->size = file.size;
result->origin = origin;
return result;
}
@ -1701,6 +1738,87 @@ void ApiWrap::filePartDone(int offset, const MTPupload_File &result) {
process->done(process->relativePath);
}
void ApiWrap::filePartRefreshReference(int offset) {
Expects(_fileProcess != nullptr);
const auto &origin = _fileProcess->origin;
if (!origin.messageId) {
error("FILE_REFERENCE error for non-message file.");
return;
}
if (origin.peer.type() == mtpc_inputPeerChannel
|| origin.peer.type() == mtpc_inputPeerChannelFromMessage) {
const auto channel = (origin.peer.type() == mtpc_inputPeerChannel)
? MTP_inputChannel(
origin.peer.c_inputPeerChannel().vchannel_id(),
origin.peer.c_inputPeerChannel().vaccess_hash())
: MTP_inputChannelFromMessage(
origin.peer.c_inputPeerChannelFromMessage().vpeer(),
origin.peer.c_inputPeerChannelFromMessage().vmsg_id(),
origin.peer.c_inputPeerChannelFromMessage().vchannel_id());
mainRequest(MTPchannels_GetMessages(
channel,
MTP_vector<MTPInputMessage>(
1,
MTP_inputMessageID(MTP_int(origin.messageId)))
)).fail([=](const RPCError &error) {
filePartUnavailable();
return true;
}).done([=](const MTPmessages_Messages &result) {
filePartExtractReference(offset, result);
}).send();
} else {
splitRequest(origin.split, MTPmessages_GetMessages(
MTP_vector<MTPInputMessage>(
1,
MTP_inputMessageID(MTP_int(origin.messageId)))
)).fail([=](const RPCError &error) {
filePartUnavailable();
return true;
}).done([=](const MTPmessages_Messages &result) {
filePartExtractReference(offset, result);
}).send();
}
}
void ApiWrap::filePartExtractReference(
int offset,
const MTPmessages_Messages &result) {
Expects(_fileProcess != nullptr);
result.match([&](const MTPDmessages_messagesNotModified &data) {
error("Unexpected messagesNotModified received.");
}, [&](const auto &data) {
auto context = Data::ParseMediaContext();
const auto messages = Data::ParseMessagesSlice(
context,
data.vmessages(),
data.vusers(),
data.vchats(),
_chatProcess->info.relativePath);
for (const auto &message : messages.list) {
if (message.id == _fileProcess->origin.messageId) {
const auto refresh1 = Data::RefreshFileReference(
_fileProcess->location,
message.file().location);
const auto refresh2 = Data::RefreshFileReference(
_fileProcess->location,
message.thumb().file.location);
if (refresh1 || refresh2) {
fileRequest(
_fileProcess->location,
offset
).done([=](const MTPupload_File &result) {
filePartDone(offset, result);
}).send();
return;
}
}
}
filePartUnavailable();
});
}
void ApiWrap::filePartUnavailable() {
Expects(_fileProcess != nullptr);
Expects(!_fileProcess->requests.empty());

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "mtproto/concurrent_sender.h"
#include "mtproto/mtproto_concurrent_sender.h"
namespace Export {
namespace Data {
@ -23,6 +23,7 @@ struct DialogsInfo;
struct DialogInfo;
struct MessagesSlice;
struct Message;
struct FileOrigin;
} // namespace Data
namespace Output {
@ -159,21 +160,33 @@ private:
void finishMessagesSlice();
void finishMessages();
[[nodiscard]] Data::Message *currentFileMessage() const;
[[nodiscard]] Data::FileOrigin currentFileMessageOrigin() const;
bool processFileLoad(
Data::File &file,
const Data::FileOrigin &origin,
Fn<bool(FileProgress)> progress,
FnMut<void(QString)> done,
Data::Message *message = nullptr);
std::unique_ptr<FileProcess> prepareFileProcess(
const Data::File &file) const;
bool writePreloadedFile(Data::File &file);
const Data::File &file,
const Data::FileOrigin &origin) const;
bool writePreloadedFile(
Data::File &file,
const Data::FileOrigin &origin);
void loadFile(
const Data::File &file,
const Data::FileOrigin &origin,
Fn<bool(FileProgress)> progress,
FnMut<void(QString)> done);
void loadFilePart();
void filePartDone(int offset, const MTPupload_File &result);
void filePartUnavailable();
void filePartRefreshReference(int offset);
void filePartExtractReference(
int offset,
const MTPmessages_Messages &result);
template <typename Request>
class RequestBuilder;

View File

@ -7,9 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <crl/crl_object_on_queue.h>
#include "base/variant.h"
#include "mtproto/rpc_sender.h"
#include "mtproto/mtproto_rpc_sender.h"
#include <crl/crl_object_on_queue.h>
namespace Export {

View File

@ -373,9 +373,9 @@ struct Data {
bool NotificationsDemoIsShown = false;
bool TryIPv6 = !Platform::IsWindows();
std::vector<ProxyData> ProxiesList;
ProxyData SelectedProxy;
ProxyData::Settings ProxySettings = ProxyData::Settings::System;
std::vector<MTP::ProxyData> ProxiesList;
MTP::ProxyData SelectedProxy;
MTP::ProxyData::Settings ProxySettings = MTP::ProxyData::Settings::System;
bool UseProxyForCalls = false;
base::Observable<void> ConnectionTypeChanged;
@ -501,9 +501,9 @@ DefineVar(Global, Notify::ScreenCorner, NotificationsCorner);
DefineVar(Global, bool, NotificationsDemoIsShown);
DefineVar(Global, bool, TryIPv6);
DefineVar(Global, std::vector<ProxyData>, ProxiesList);
DefineVar(Global, ProxyData, SelectedProxy);
DefineVar(Global, ProxyData::Settings, ProxySettings);
DefineVar(Global, std::vector<MTP::ProxyData>, ProxiesList);
DefineVar(Global, MTP::ProxyData, SelectedProxy);
DefineVar(Global, MTP::ProxyData::Settings, ProxySettings);
DefineVar(Global, bool, UseProxyForCalls);
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);

View File

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/type_traits.h"
#include "base/observer.h"
#include "base/call_delayed.h"
#include "ui/effects/animation_value.h"
#include "mtproto/mtproto_proxy_data.h"
class History;
@ -224,9 +224,9 @@ DeclareVar(Notify::ScreenCorner, NotificationsCorner);
DeclareVar(bool, NotificationsDemoIsShown);
DeclareVar(bool, TryIPv6);
DeclareVar(std::vector<ProxyData>, ProxiesList);
DeclareVar(ProxyData, SelectedProxy);
DeclareVar(ProxyData::Settings, ProxySettings);
DeclareVar(std::vector<MTP::ProxyData>, ProxiesList);
DeclareVar(MTP::ProxyData, SelectedProxy);
DeclareVar(MTP::ProxyData::Settings, ProxySettings);
DeclareVar(bool, UseProxyForCalls);
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);

View File

@ -70,7 +70,7 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
#ifndef TDESKTOP_OFFICIAL_TARGET
for (auto i = 0; i != intsCount; ++i) {
dst[i] = qPremultiply(src[i]);
udst[i] = qPremultiply(usrc[i]);
}
#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];

View File

@ -226,6 +226,7 @@ InnerWidget::InnerWidget(
, _controller(controller)
, _channel(channel)
, _history(channel->owner().history(channel))
, _api(_channel->session().api().instance())
, _scrollDateCheck([=] { scrollDateCheck(); })
, _emptyText(
st::historyAdminLogEmptyWidth
@ -407,7 +408,7 @@ void InnerWidget::applySearch(const QString &query) {
void InnerWidget::requestAdmins() {
auto participantsHash = 0;
request(MTPchannels_GetParticipants(
_api.request(MTPchannels_GetParticipants(
_channel->inputChannel,
MTP_channelParticipantsAdmins(),
MTP_int(0),
@ -463,8 +464,8 @@ void InnerWidget::showFilter(Fn<void(FilterValue &&filter)> callback) {
}
void InnerWidget::clearAndRequestLog() {
request(base::take(_preloadUpRequestId)).cancel();
request(base::take(_preloadDownRequestId)).cancel();
_api.request(base::take(_preloadUpRequestId)).cancel();
_api.request(base::take(_preloadDownRequestId)).cancel();
_filterChanged = true;
_upLoaded = false;
_downLoaded = true;
@ -635,7 +636,7 @@ void InnerWidget::preloadMore(Direction direction) {
auto maxId = (direction == Direction::Up) ? _minId : 0;
auto minId = (direction == Direction::Up) ? 0 : _maxId;
auto perPage = _items.empty() ? kEventsFirstPage : kEventsPerPage;
requestId = request(MTPchannels_GetAdminLog(
requestId = _api.request(MTPchannels_GetAdminLog(
MTP_flags(flags),
_channel->inputChannel,
MTP_string(_searchQuery),
@ -1217,7 +1218,7 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
if (base::contains(_admins, user)) {
editRestrictions(true, MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
} else {
request(MTPchannels_GetParticipant(
_api.request(MTPchannels_GetParticipant(
_channel->inputChannel,
user->inputUser
)).done([=](const MTPchannels_ChannelParticipant &result) {

View File

@ -44,7 +44,6 @@ class InnerWidget final
: public Ui::RpWidget
, public Ui::AbstractTooltipShower
, public HistoryView::ElementDelegate
, private MTP::Sender
, private base::Subscriber {
public:
InnerWidget(
@ -216,9 +215,11 @@ private:
template <typename Method>
void enumerateDates(Method method);
not_null<Window::SessionController*> _controller;
not_null<ChannelData*> _channel;
not_null<History*> _history;
const not_null<Window::SessionController*> _controller;
const not_null<ChannelData*> _channel;
const not_null<History*> _history;
MTP::Sender _api;
std::vector<OwnedItem> _items;
std::set<uint64> _eventIds;
std::map<not_null<const HistoryItem*>, not_null<Element*>> _itemsByData;

View File

@ -97,7 +97,7 @@ object_ptr<Window::SectionWidget> SectionMemento::createWidget(
}
auto result = object_ptr<Widget>(parent, controller, _channel);
result->setInternalState(geometry, this);
return std::move(result);
return result;
}
FixedBar::FixedBar(
@ -365,7 +365,7 @@ void Widget::setupShortcuts() {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(channel());
saveState(result.get());
return std::move(result);
return result;
}
void Widget::saveState(not_null<SectionMemento*> memento) {

View File

@ -59,7 +59,7 @@ object_ptr<Window::SectionWidget> Memento::createWidget(
}
auto result = object_ptr<Widget>(parent, controller, _feed);
result->setInternalState(geometry, this);
return std::move(result);
return result;
}
Widget::Widget(
@ -456,7 +456,7 @@ ClickHandlerPtr Widget::listDateLink(not_null<Element*> view) {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<Memento>(_feed);
saveState(result.get());
return std::move(result);
return result;
}
void Widget::saveState(not_null<Memento*> memento) {

Some files were not shown because too many files have changed in this diff Show More