From df9e9a9d75c8be7d872e2fb62dad7d5cefd64841 Mon Sep 17 00:00:00 2001 From: Mahdi Jafari Date: Mon, 19 Jul 2021 18:05:42 +0430 Subject: [PATCH 01/15] Fix applying of patches in Dockerfile. --- Telegram/build/docker/centos_env/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 4865cdc8d..9cbba9cac 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -33,6 +33,7 @@ RUN git clone $GIT/desktop-app/patches.git WORKDIR patches RUN git checkout 87a2e9ee07 +WORKDIR .. FROM builder AS extra-cmake-modules From 3d1a0494050acc1a4040632ce4225f7a45835226 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jul 2021 16:18:46 +0200 Subject: [PATCH 02/15] window title for call window Having an empty window title brings different issues, for example: * invisible on task bar * invisible in task switcher * apply properties by match * ... So let's use the contact user name for window title. Fixes #10243 --- Telegram/SourceFiles/calls/calls_panel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 698a894bd..01a35814c 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -118,7 +118,7 @@ void Panel::initWindow() { window()->setAttribute(Qt::WA_NoSystemBackground); window()->setWindowIcon( QIcon(QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly))); - window()->setTitle(u" "_q); + window()->setTitle(_user->name); window()->setTitleStyle(st::callTitle); window()->events( From ba9b72e038ed9bb48b825d372090b369f81bd3f2 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 14 Jul 2021 02:16:03 +0400 Subject: [PATCH 03/15] Fix -Wunused-variable warnings with gcc --- Telegram/SourceFiles/boxes/language_box.cpp | 4 +- .../boxes/peers/edit_peer_type_box.cpp | 17 --------- .../SourceFiles/boxes/sticker_set_box.cpp | 1 - .../calls/group/calls_choose_join_as.cpp | 1 - .../calls/group/calls_group_members.cpp | 15 -------- .../chat_helpers/gifs_list_widget.cpp | 2 - .../chat_helpers/stickers_list_widget.cpp | 1 - Telegram/SourceFiles/core/shortcuts.h | 2 +- .../data/data_document_resolver.cpp | 38 ++++++++++--------- .../dialogs/dialogs_inner_widget.cpp | 2 - .../admin_log/history_admin_log_filter.cpp | 11 ------ .../admin_log/history_admin_log_inner.cpp | 2 +- .../history/history_inner_widget.cpp | 2 +- .../history/view/media/history_view_call.cpp | 3 +- .../info/media/info_media_inner_widget.cpp | 4 +- .../info/profile/info_profile_actions.cpp | 1 - .../inline_bots/inline_bot_layout_item.cpp | 2 +- .../inline_bots/inline_results_inner.cpp | 2 - .../media/player/media_player_widget.cpp | 5 +-- .../media/view/media_view_overlay_widget.cpp | 7 ++-- .../mtproto/details/mtproto_dc_key_binder.cpp | 1 - .../mtproto/mtproto_concurrent_sender.h | 8 ++-- .../mtproto/mtproto_dc_options.cpp | 4 +- .../platform/linux/linux_xdp_file_dialog.cpp | 29 +------------- .../SourceFiles/settings/settings_intro.cpp | 7 ---- .../SourceFiles/ui/boxes/choose_date_time.cpp | 9 ----- Telegram/SourceFiles/ui/empty_userpic.cpp | 2 +- Telegram/SourceFiles/window/main_window.cpp | 4 -- .../themes/window_theme_editor_block.cpp | 2 +- .../window/themes/window_theme_preview.cpp | 6 +-- .../window/window_outdated_bar.cpp | 2 +- 31 files changed, 46 insertions(+), 150 deletions(-) diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index a14dbeb5f..baf3ac1a0 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -115,12 +115,12 @@ private: const Rows::Row &rowBySelection(Selection selected) const; std::unique_ptr &rippleBySelection( Selection selected); - const std::unique_ptr &rippleBySelection( + [[maybe_unused]] const std::unique_ptr &rippleBySelection( Selection selected) const; std::unique_ptr &rippleBySelection( not_null row, Selection selected); - const std::unique_ptr &rippleBySelection( + [[maybe_unused]] const std::unique_ptr &rippleBySelection( not_null row, Selection selected) const; void addRipple(Selection selected, QPoint position); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index d18977597..ff7a754aa 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -129,9 +129,6 @@ private: const QString &text, rpl::producer about); - bool inviteLinkShown(); - QString inviteLinkText(); - not_null _peer; bool _linkOnly = false; @@ -308,15 +305,6 @@ QString Controller::getUsernameInput() { return _controls.usernameInput->getLastText().trimmed(); } -QString Controller::inviteLinkText() { - if (const auto channel = _peer->asChannel()) { - return channel->inviteLink(); - } else if (const auto chat = _peer->asChat()) { - return chat->inviteLink(); - } - return QString(); -} - object_ptr Controller::createUsernameEdit() { Expects(_wrap != nullptr); @@ -583,11 +571,6 @@ object_ptr Controller::createInviteLinkBlock() { return result; } -bool Controller::inviteLinkShown() { - return !_controls.privacy - || (_controls.privacy->value() == Privacy::NoUsername); -} - } // namespace EditPeerTypeBox::EditPeerTypeBox( diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 74c3a84dd..74f37c61d 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -761,7 +761,6 @@ void StickerSetBox::Inner::visibleTopBottomUpdated( void StickerSetBox::Inner::setupLottie(int index) { auto &element = _elements[index]; - const auto document = element.document; element.animated = ChatHelpers::LottieAnimationFromDocument( getLottiePlayer(), diff --git a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp index db1e6a3bb..cefaca113 100644 --- a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp @@ -335,7 +335,6 @@ void ChooseJoinAsProcess::start( }, _request->lifetime); const auto finish = [=](JoinInfo info) { - const auto peer = _request->peer; const auto done = std::move(_request->done); const auto box = _request->box; _request = nullptr; diff --git a/Telegram/SourceFiles/calls/group/calls_group_members.cpp b/Telegram/SourceFiles/calls/group/calls_group_members.cpp index f7e9fd3fd..c82fbb403 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_members.cpp @@ -1171,21 +1171,6 @@ int Members::Controller::rowPaintStatusIcon( : state.raisedHand ? st::groupCallMemberInactiveStatus->c : iconColor; - const auto color = (state.speaking == 1. && !state.mutedByMe) - ? st::groupCallMemberActiveStatus->c - : (state.speaking == 0. - ? (state.active == 1. - ? st::groupCallMemberNotJoinedStatus->c - : (state.active == 0. - ? (state.muted == 1. - ? (state.raisedHand - ? st::groupCallMemberInactiveStatus->c - : st::groupCallMemberNotJoinedStatus->c) - : (state.muted == 0. - ? st::groupCallMemberNotJoinedStatus->c - : other)) - : other)) - : other); if (camera) { st::groupCallNarrowCameraIcon.paint(p, x, y, outerWidth, other); x += st::groupCallNarrowCameraIcon.width(); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index fa8c42294..35fe93f55 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -1033,7 +1033,6 @@ void GifsListWidget::updateSelected() { int row = -1, col = -1, sel = -1; ClickHandlerPtr lnk; ClickHandlerHost *lnkhost = nullptr; - HistoryView::CursorState cursor = HistoryView::CursorState::None; if (sy >= 0) { row = 0; for (int rows = _rows.size(); row < rows; ++row) { @@ -1062,7 +1061,6 @@ void GifsListWidget::updateSelected() { QPoint(sx, sy), HistoryView::StateRequest()); lnk = result.link; - cursor = result.cursor; lnkhost = inlineItems[col]; } else { row = col = -1; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index a9eb774b5..f2dcd6f42 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1880,7 +1880,6 @@ void StickersListWidget::ensureLottiePlayer(Set &set) { void StickersListWidget::setupLottie(Set &set, int section, int index) { auto &sticker = set.stickers[index]; - const auto document = sticker.document; ensureLottiePlayer(set); // Document should be loaded already for the animation to be set up. diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index c6a8b596a..ef1d16486 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -63,7 +63,7 @@ enum class Command { SupportHistoryForward, }; -constexpr auto kShowFolder = { +[[maybe_unused]] constexpr auto kShowFolder = { Command::ShowAllChats, Command::ShowFolder1, Command::ShowFolder2, diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 9588cea4b..8452af7fd 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -98,25 +98,27 @@ QString FileExtension(const QString &filepath) { return QString(last.base(), last - reversed.begin()); } -// bool IsValidMediaFile(const QString &filepath) { -// static const auto kExtensions = [] { -// const auto list = qsl("\ -// 16svx 2sf 3g2 3gp 8svx aac aaf aif aifc aiff amr amv ape asf ast au aup \ -// avchd avi brstm bwf cam cdda cust dat divx drc dsh dsf dts dtshd dtsma \ -// dvr-ms dwd evo f4a f4b f4p f4v fla flac flr flv gif gifv gsf gsm gym iff \ -// ifo it jam la ly m1v m2p m2ts m2v m4a m4p m4v mcf mid mk3d mka mks mkv mng \ -// mov mp1 mp2 mp3 mp4 minipsf mod mpc mpe mpeg mpg mpv mscz mt2 mus mxf mxl \ -// niff nsf nsv off ofr ofs ogg ogv opus ots pac ps psf psf2 psflib ptb qsf \ -// qt ra raw rka rm rmj rmvb roq s3m shn sib sid smi smp sol spc spx ssf svi \ -// swa swf tak ts tta txm usf vgm vob voc vox vqf wav webm wma wmv wrap wtv \ -// wv xm xml ym yuv").split(' '); -// return base::flat_set(list.begin(), list.end()); -// }(); +#if 0 +bool IsValidMediaFile(const QString &filepath) { + static const auto kExtensions = [] { + const auto list = qsl("\ +16svx 2sf 3g2 3gp 8svx aac aaf aif aifc aiff amr amv ape asf ast au aup \ +avchd avi brstm bwf cam cdda cust dat divx drc dsh dsf dts dtshd dtsma \ +dvr-ms dwd evo f4a f4b f4p f4v fla flac flr flv gif gifv gsf gsm gym iff \ +ifo it jam la ly m1v m2p m2ts m2v m4a m4p m4v mcf mid mk3d mka mks mkv mng \ +mov mp1 mp2 mp3 mp4 minipsf mod mpc mpe mpeg mpg mpv mscz mt2 mus mxf mxl \ +niff nsf nsv off ofr ofs ogg ogv opus ots pac ps psf psf2 psflib ptb qsf \ +qt ra raw rka rm rmj rmvb roq s3m shn sib sid smi smp sol spc spx ssf svi \ +swa swf tak ts tta txm usf vgm vob voc vox vqf wav webm wma wmv wrap wtv \ +wv xm xml ym yuv").split(' '); + return base::flat_set(list.begin(), list.end()); + }(); -// return ranges::binary_search( -// kExtensions, -// FileExtension(filepath).toLower()); -// } + return ranges::binary_search( + kExtensions, + FileExtension(filepath).toLower()); +} +#endif bool IsExecutableName(const QString &filepath) { static const auto kExtensions = [] { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 2e8128349..fe4f58229 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -1248,14 +1248,12 @@ bool InnerWidget::pinnedShiftAnimationCallback(crl::time now) { now += st::stickersRowDuration; } - auto wasAnimating = false; auto animating = false; auto updateMin = -1; auto updateMax = 0; for (auto i = 0, l = static_cast(_pinnedRows.size()); i != l; ++i) { auto start = _pinnedRows[i].animStartTime; if (start) { - wasAnimating = true; if (updateMin < 0) updateMin = i; updateMax = i; if (start + st::stickersRowDuration > now && now >= start) { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index 7f1c688b9..579b888c4 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -32,7 +32,6 @@ public: return _check->checked(); } rpl::producer checkedChanges() const; - rpl::producer checkedValue() const; enum class NotifyAboutChange { Notify, @@ -42,8 +41,6 @@ public: bool checked, NotifyAboutChange notify = NotifyAboutChange::Notify); - void finishAnimating(); - QMargins getMargins() const override { return _st.margin; } @@ -90,10 +87,6 @@ rpl::producer UserCheckbox::checkedChanges() const { return _checkedChanges.events(); } -rpl::producer UserCheckbox::checkedValue() const { - return _checkedChanges.events_starting_with(checked()); -} - void UserCheckbox::setChecked(bool checked, NotifyAboutChange notify) { if (_check->checked() != checked) { _check->setChecked(checked, anim::type::normal); @@ -133,10 +126,6 @@ void UserCheckbox::paintEvent(QPaintEvent *e) { p.drawTextLeft(statusLeft, statusTop, width(), _statusText); } -void UserCheckbox::finishAnimating() { - _check->finishAnimating(); -} - int UserCheckbox::resizeGetHeight(int newWidth) { return st::contactsPhotoSize; } diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 40a454332..387ce6f46 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1637,7 +1637,7 @@ void InnerWidget::updateSelected() { dragState = view->textState(itemPoint, request); lnkhost = view; if (!dragState.link && itemPoint.x() >= st::historyPhotoLeft && itemPoint.x() < st::historyPhotoLeft + st::msgPhotoSize) { - if (auto message = item->toHistoryMessage()) { + if (item->toHistoryMessage()) { if (view->hasFromPhoto()) { enumerateUserpics([&](not_null view, int userpicTop) { // stop enumeration if the userpic is below our point diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 11eae477d..a351ec98b 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2823,7 +2823,7 @@ void HistoryInner::mouseActionUpdate() { _dragStateItem = session().data().message(dragState.itemId); lnkhost = view; if (!dragState.link && m.x() >= st::historyPhotoLeft && m.x() < st::historyPhotoLeft + st::msgPhotoSize) { - if (auto msg = item->toHistoryMessage()) { + if (item->toHistoryMessage()) { if (view->hasFromPhoto()) { enumerateUserpics([&](not_null view, int userpicTop) -> bool { // stop enumeration if the userpic is below our point diff --git a/Telegram/SourceFiles/history/view/media/history_view_call.cpp b/Telegram/SourceFiles/history/view/media/history_view_call.cpp index 3722a015d..6ce9be5f6 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_call.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_call.cpp @@ -81,12 +81,11 @@ void Call::draw(Painter &p, const QRect &r, TextSelection selection, crl::time m accumulate_min(paintw, maxWidth()); - auto nameleft = 0, nametop = 0, nameright = 0, statustop = 0; + auto nameleft = 0, nametop = 0, statustop = 0; auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus; nameleft = st::historyCallLeft; nametop = st::historyCallTop - topMinus; - nameright = st::msgFileLayout.padding.left(); statustop = st::historyCallStatusTop - topMinus; p.setFont(st::semiboldFont); diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp index d76a43575..3ea25dddd 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp @@ -125,9 +125,9 @@ void InnerWidget::createTypeButtons() { addMediaButton(Type::MusicFile, st::infoIconMediaAudio); addMediaButton(Type::Link, st::infoIconMediaLink); addMediaButton(Type::RoundVoiceFile, st::infoIconMediaVoice); - if (auto user = _controller->key().peer()->asUser()) { +// if (auto user = _controller->key().peer()->asUser()) { // addCommonGroupsButton(user, st::infoIconMediaGroup); - } +// } content->add(object_ptr( content, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 20964ce55..516146bb9 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -458,7 +458,6 @@ ActionsFiller::ActionsFiller( void ActionsFiller::addInviteToGroupAction( not_null user) { - const auto controller = _controller; AddActionButton( _wrap, tr::lng_profile_invite_to_group(), diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index 84593fa81..a8b9b2a57 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -198,7 +198,7 @@ ClickHandlerPtr ItemBase::getResultPreviewHandler() const { _result->_content_url, false); } else if (const auto document = _result->_document - && _result->_document->createMediaView()->canBePlayed()) { + ; document->createMediaView()->canBePlayed()) { return std::make_shared(); } else if (_result->_photo) { return std::make_shared(); diff --git a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp index cb8b225ee..2b76bd072 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp @@ -677,7 +677,6 @@ void Inner::updateSelected() { int row = -1, col = -1, sel = -1; ClickHandlerPtr lnk; ClickHandlerHost *lnkhost = nullptr; - HistoryView::CursorState cursor = HistoryView::CursorState::None; if (sy >= 0) { row = 0; for (int rows = _rows.size(); row < rows; ++row) { @@ -706,7 +705,6 @@ void Inner::updateSelected() { QPoint(sx, sy), HistoryView::StateRequest()); lnk = result.link; - cursor = result.cursor; lnkhost = inlineItems[col]; } else { row = col = -1; diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index a0204515f..d3518fa39 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -478,12 +478,11 @@ void Widget::handleSongUpdate(const TrackState &state) { } void Widget::updateTimeText(const TrackState &state) { - qint64 position = 0, length = 0, display = 0; + qint64 display = 0; const auto frequency = state.frequency; const auto document = state.id.audio(); if (!IsStoppedOrStopping(state.state)) { - display = position = state.position; - length = state.length; + display = state.position; } else if (state.length) { display = state.length; } else if (const auto song = document->song()) { diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index b10e583ea..f288e9c22 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2439,7 +2439,7 @@ void OverlayWidget::displayDocument( _docIconRect = QRect((width() - st::mediaviewFileIconSize) / 2, (height() - st::mediaviewFileIconSize) / 2, st::mediaviewFileIconSize, st::mediaviewFileIconSize); int32 colorIndex = documentColorIndex(_document, _docExt); _docIconColor = documentColor(colorIndex); - const style::icon *(thumbs[]) = { &st::mediaviewFileBlue, &st::mediaviewFileGreen, &st::mediaviewFileRed, &st::mediaviewFileYellow }; + const style::icon *thumbs[] = { &st::mediaviewFileBlue, &st::mediaviewFileGreen, &st::mediaviewFileRed, &st::mediaviewFileYellow }; _docIcon = thumbs[colorIndex]; int32 extmaxw = (st::mediaviewFileIconSize - st::mediaviewFileExtPadding * 2); @@ -3429,7 +3429,7 @@ void OverlayWidget::paintThemePreviewContent( width(), st::themePreviewMargin.top()); } - if (const auto fillTitleRect = (titleRect.y() < 0)) { + if (titleRect.y() < 0) { titleRect.moveTop(0); fillOverlay(titleRect); } @@ -3457,8 +3457,7 @@ void OverlayWidget::paintThemePreviewContent( outer.y() + outer.height() - st::themePreviewMargin.bottom(), outer.width(), st::themePreviewMargin.bottom()); - if (const auto fillButtonsRect - = (buttonsRect.y() + buttonsRect.height() > height())) { + if (buttonsRect.y() + buttonsRect.height() > height()) { buttonsRect.moveTop(height() - buttonsRect.height()); fillOverlay(buttonsRect); } diff --git a/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp b/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp index db7a06ce8..2ade496b9 100644 --- a/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp +++ b/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp @@ -109,7 +109,6 @@ DcKeyBindState DcKeyBinder::handleResponse(const mtpBuffer &response) { auto from = response.begin(); const auto end = from + response.size(); auto error = MTPRpcError(); - auto result = MTPBool(); if (response[0] == mtpc_boolTrue) { return DcKeyBindState::Success; } else if (response[0] == mtpc_rpc_error && error.read(from, end)) { diff --git a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h index d82f588eb..47daaf7a6 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h +++ b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h @@ -314,10 +314,10 @@ auto ConcurrentSender::SpecificRequestBuilder::done( Handler, mtpRequestId, Result>; - constexpr auto takesResponse = rpl::details::is_callable_plain_v< + [[maybe_unused]] constexpr auto takesResponse = rpl::details::is_callable_plain_v< Handler, Result>; - constexpr auto takesNone = rpl::details::is_callable_plain_v; + [[maybe_unused]] constexpr auto takesNone = rpl::details::is_callable_plain_v; if constexpr (takesFull) { setDoneHandler(std::forward(handler)); @@ -348,10 +348,10 @@ auto ConcurrentSender::SpecificRequestBuilder::fail( Handler, mtpRequestId, Error>; - constexpr auto takesError = rpl::details::is_callable_plain_v< + [[maybe_unused]] constexpr auto takesError = rpl::details::is_callable_plain_v< Handler, Error>; - constexpr auto takesNone = rpl::details::is_callable_plain_v; + [[maybe_unused]] constexpr auto takesNone = rpl::details::is_callable_plain_v; if constexpr (takesFull) { setFailHandler(std::forward(handler)); diff --git a/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp b/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp index 7458a7ba3..26862b6df 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp @@ -58,7 +58,7 @@ const BuiltInDc kBuiltInDcsIPv6Test[] = { { 3, "2001:0b28:f23d:f003:0000:0000:0000:000e", 443 } }; -const char *(kTestPublicRSAKeys[]) = { "\ +const char *kTestPublicRSAKeys[] = { "\ -----BEGIN RSA PUBLIC KEY-----\n\ MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIR\n\ yy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwv\n\ @@ -68,7 +68,7 @@ aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCO\n\ j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB\n\ -----END RSA PUBLIC KEY-----" }; -const char *(kPublicRSAKeys[]) = { "\ +const char *kPublicRSAKeys[] = { "\ -----BEGIN RSA PUBLIC KEY-----\n\ MIIBCgKCAQEA6LszBcC1LGzyr992NzE0ieY+BSaOW622Aa9Bd4ZHLl+TuFQ4lo4g\n\ 5nKaMBwK/BIb9xUfg0Q29/2mgIR6Zr9krM7HjuIcCzFvDtr+L0GQjae9H0pRB2OO\n\ diff --git a/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp b/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp index c015e889e..fa34ba91c 100644 --- a/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp @@ -176,20 +176,14 @@ public: } } - bool defaultNameFilterDisables() const; QUrl directory() const; void setDirectory(const QUrl &directory); void selectFile(const QUrl &filename); QList selectedFiles() const; - void setFilter(); - void selectNameFilter(const QString &filter); - QString selectedNameFilter() const; - void selectMimeTypeFilter(const QString &filter); - QString selectedMimeTypeFilter() const; int exec() override; - bool failedToOpen() { + bool failedToOpen() const { return _failedToOpen; } @@ -517,10 +511,6 @@ void XDPFileDialog::openPortal() { } } -bool XDPFileDialog::defaultNameFilterDisables() const { - return false; -} - void XDPFileDialog::setDirectory(const QUrl &directory) { _directory = directory.path().toStdString(); } @@ -544,23 +534,6 @@ QList XDPFileDialog::selectedFiles() const { return files; } -void XDPFileDialog::setFilter() { -} - -void XDPFileDialog::selectMimeTypeFilter(const QString &filter) { -} - -QString XDPFileDialog::selectedMimeTypeFilter() const { - return QString::fromStdString(_selectedMimeTypeFilter); -} - -void XDPFileDialog::selectNameFilter(const QString &filter) { -} - -QString XDPFileDialog::selectedNameFilter() const { - return QString::fromStdString(_selectedNameFilter); -} - int XDPFileDialog::exec() { setAttribute(Qt::WA_DeleteOnClose, false); diff --git a/Telegram/SourceFiles/settings/settings_intro.cpp b/Telegram/SourceFiles/settings/settings_intro.cpp index bf0053b48..e214b5c3e 100644 --- a/Telegram/SourceFiles/settings/settings_intro.cpp +++ b/Telegram/SourceFiles/settings/settings_intro.cpp @@ -49,7 +49,6 @@ protected: private: void updateControlsGeometry(int newWidth); Ui::RpWidget *pushButton(base::unique_qptr button); - void removeButton(not_null button); const style::InfoTopBar &_st; std::vector> _buttons; @@ -136,12 +135,6 @@ Ui::RpWidget *TopBar::pushButton(base::unique_qptr button) { return weak; } -void TopBar::removeButton(not_null button) { - _buttons.erase( - std::remove(_buttons.begin(), _buttons.end(), button), - _buttons.end()); -} - int TopBar::resizeGetHeight(int newWidth) { updateControlsGeometry(newWidth); return _st.height; diff --git a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp index 58af031ab..482826e55 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp @@ -126,7 +126,6 @@ private: void setInnerFocus(); void putNext(const object_ptr &field, QChar ch); void erasePrevious(const object_ptr &field); - void finishInnerAnimating(); void setErrorShown(bool error); void setFocused(bool focused); void startBorderAnimation(); @@ -538,14 +537,6 @@ void TimeInput::setFocused(bool focused) { } } -void TimeInput::finishInnerAnimating() { - _hour->finishAnimating(); - _minute->finishAnimating(); - _a_borderOpacity.stop(); - _a_borderShown.stop(); - _a_error.stop(); -} - void TimeInput::startBorderAnimation() { auto borderVisible = (_error || _focused); if (_borderVisible != borderVisible) { diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index ed3190136..b24995036 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -412,7 +412,7 @@ void EmptyUserpic::fillString(const QString &name) { auto ch = name.constData(), end = ch + name.size(); while (ch != end) { auto emojiLength = 0; - if (auto emoji = Ui::Emoji::Find(ch, end, &emojiLength)) { + if (Ui::Emoji::Find(ch, end, &emojiLength)) { ch += emojiLength; } else if (ch->isHighSurrogate()) { ++ch; diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 4ac93f8f1..4c3eeca0d 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -491,11 +491,9 @@ void MainWindow::initSize() { } const auto primaryScreen = QGuiApplication::primaryScreen(); - auto geometryScreen = primaryScreen; const auto available = primaryScreen ? primaryScreen->availableGeometry() : QRect(0, 0, st::windowDefaultWidth, st::windowDefaultHeight); - bool maximized = false; const auto initialWidth = Core::Settings::ThirdColumnByDefault() ? st::windowBigDefaultWidth : st::windowDefaultWidth; @@ -561,13 +559,11 @@ void MainWindow::initSize() { position.y + st::windowMinHeight <= screenGeometry.y() + screenGeometry.height()) { DEBUG_LOG(("Window Pos: Resulting geometry is %1, %2, %3, %4").arg(position.x).arg(position.y).arg(position.w).arg(position.h)); geometry = QRect(position.x, position.y, position.w, position.h); - geometryScreen = screen; } } break; } } - maximized = position.maximized; } geometry += _padding; DEBUG_LOG(("Window Pos: Setting first %1, %2, %3, %4").arg(geometry.x()).arg(geometry.y()).arg(geometry.width()).arg(geometry.height())); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index 67fba5b31..9212e21e6 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -320,7 +320,7 @@ bool EditorBlock::selectSkip(int direction) { if (newSelected < -1 || newSelected > maxSelected) { newSelected = maxSelected; } - if (auto changed = (newSelected != _selected)) { + if (newSelected != _selected) { setSelected(newSelected); scrollToSelected(); return (newSelected >= 0); diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index 484dff0bf..82c3a7a7f 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -31,7 +31,7 @@ QString fillLetters(const QString &name) { auto ch = name.constData(), end = ch + name.size(); while (ch != end) { auto emojiLength = 0; - if (auto emoji = Ui::Emoji::Find(ch, end, &emojiLength)) { + if (Ui::Emoji::Find(ch, end, &emojiLength)) { ch += emojiLength; } else if (ch->isHighSurrogate()) { ++ch; @@ -243,10 +243,8 @@ void Generator::addAudioBubble(QVector waveform, int waveactive, QString wa auto skipBlock = computeSkipBlock(status, date); auto width = st::msgFileMinWidth; - auto tleft = 0, tright = 0; const auto &st = st::msgFileLayout; - tleft = st.padding.left() + st.thumbSize + st.padding.right(); - tright = st.padding.left(); + auto tleft = st.padding.left() + st.thumbSize + st.padding.right(); accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right()); accumulate_min(width, st::msgMaxWidth); diff --git a/Telegram/SourceFiles/window/window_outdated_bar.cpp b/Telegram/SourceFiles/window/window_outdated_bar.cpp index ab1a6e9f3..df1b10b2d 100644 --- a/Telegram/SourceFiles/window/window_outdated_bar.cpp +++ b/Telegram/SourceFiles/window/window_outdated_bar.cpp @@ -22,6 +22,7 @@ constexpr auto kMinimalSkip = 7; constexpr auto kSoonSkip = 30; constexpr auto kNowSkip = 90; +#ifdef DESKTOP_APP_SPECIAL_TARGET class Bar : public Ui::RpWidget { public: Bar(not_null parent, QDate date); @@ -96,7 +97,6 @@ void Bar::paintEvent(QPaintEvent *e) { _soon ? st::outdateSoonBg : st::outdatedBg); } -#ifdef DESKTOP_APP_SPECIAL_TARGET QString LastHiddenPath() { return cWorkingDir() + qsl("tdata/outdated_hidden"); } From d9ea4f31caf1e25b1ac45158aa35d0f13f50c161 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 14 Jul 2021 02:16:16 +0400 Subject: [PATCH 04/15] Add SYSTEM flag to target_include_directories where appropriate --- Telegram/CMakeLists.txt | 2 +- Telegram/cmake/lib_tgvoip.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 1613253ad..7dad8ebb2 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -126,7 +126,7 @@ if (LINUX) endif() else() pkg_check_modules(GTK REQUIRED gtk+-3.0) - target_include_directories(Telegram PRIVATE ${GTK_INCLUDE_DIRS}) + target_include_directories(Telegram SYSTEM PRIVATE ${GTK_INCLUDE_DIRS}) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(Telegram PRIVATE X11) diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake index 6c97e3c7f..f7007c4e4 100644 --- a/Telegram/cmake/lib_tgvoip.cmake +++ b/Telegram/cmake/lib_tgvoip.cmake @@ -191,7 +191,7 @@ if (NOT TGVOIP_FOUND) if (LINUX) if (NOT LIBTGVOIP_DISABLE_ALSA) find_package(ALSA REQUIRED) - target_include_directories(lib_tgvoip_bundled PRIVATE ${ALSA_INCLUDE_DIRS}) + target_include_directories(lib_tgvoip_bundled SYSTEM PRIVATE ${ALSA_INCLUDE_DIRS}) else() remove_target_sources(lib_tgvoip_bundled ${tgvoip_loc} os/linux/AudioInputALSA.cpp @@ -206,7 +206,7 @@ if (NOT TGVOIP_FOUND) if (NOT LIBTGVOIP_DISABLE_PULSEAUDIO) find_package(PkgConfig REQUIRED) pkg_check_modules(PULSE REQUIRED libpulse) - target_include_directories(lib_tgvoip_bundled PRIVATE ${PULSE_INCLUDE_DIRS}) + target_include_directories(lib_tgvoip_bundled SYSTEM PRIVATE ${PULSE_INCLUDE_DIRS}) else() remove_target_sources(lib_tgvoip_bundled ${tgvoip_loc} os/linux/AudioOutputPulse.cpp From ae70dfb1f415cdedef070131f70954a552eb5fa8 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 19 Jul 2021 21:49:49 +0400 Subject: [PATCH 05/15] Return after throwing access denied error --- Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp index 77906be6e..bb57ebbfb 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp @@ -173,6 +173,7 @@ void GtkIntegration::Private::handleMethodCall( "Access denied."); invocation->return_error(error); + return; } try { From 6f151f20e93998847fa4c70b060fd1da1a2e46fc Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 19 Jul 2021 21:53:11 +0400 Subject: [PATCH 06/15] Add support for DESKTOP_APP_DISABLE_WEBKITGTK Co-authored-by: mid-kid --- .github/workflows/linux.yml | 5 ++++- .../SourceFiles/platform/linux/linux_gtk_integration.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bd232a871..7a3e721cf 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -94,7 +94,10 @@ jobs: if [ -n "${{ matrix.defines }}" ]; then DEFINE="-D ${{ matrix.defines }}=ON" if [ "${{ matrix.defines }}" == "DESKTOP_APP_DISABLE_DBUS_INTEGRATION" ]; then - DEFINE="$DEFINE -D DESKTOP_APP_DISABLE_GTK_INTEGRATION=ON" + DEFINE="$DEFINE -D DESKTOP_APP_DISABLE_GTK_INTEGRATION=ON -D DESKTOP_APP_DISABLE_WEBKITGTK=ON" + fi + if [ "${{ matrix.defines }}" == "DESKTOP_APP_DISABLE_GTK_INTEGRATION" ]; then + DEFINE="$DEFINE -D DESKTOP_APP_DISABLE_WEBKITGTK=ON" fi echo Define from matrix: $DEFINE echo "ARTIFACT_NAME=Telegram_${{ matrix.defines }}" >> $GITHUB_ENV diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp index bb57ebbfb..60f109c9d 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp @@ -16,7 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/linux/base_linux_glibmm_helper.h" #include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/base_platform_info.h" -#include "webview/platform/linux/webview_linux_webkit2gtk.h" #include "platform/linux/linux_gtk_integration_p.h" #include "platform/linux/linux_gdk_helper.h" #include "platform/linux/linux_gtk_open_with_dialog.h" @@ -24,6 +23,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_controller.h" #include "core/application.h" +#ifndef DESKTOP_APP_DISABLE_WEBKITGTK +#include "webview/platform/linux/webview_linux_webkit2gtk.h" +#endif // !DESKTOP_APP_DISABLE_WEBKITGTK + #include #include @@ -588,9 +591,11 @@ int GtkIntegration::Exec( if (const auto integration = BaseGtkIntegration::Instance()) { return integration->exec(parentDBusName); } +#ifndef DESKTOP_APP_DISABLE_WEBKITGTK } else if (type == Type::Webview) { Webview::WebKit2Gtk::SetServiceName(serviceName.toStdString()); return Webview::WebKit2Gtk::Exec(parentDBusName.toStdString()); +#endif // !DESKTOP_APP_DISABLE_WEBKITGTK } else if (type == Type::TDesktop) { ServiceName = serviceName.toStdString(); if (const auto integration = Instance()) { @@ -615,8 +620,10 @@ void GtkIntegration::Start(Type type) { if (type == Type::Base) { BaseGtkIntegration::SetServiceName(kBaseService.utf16().arg(h)); } else if (type == Type::Webview) { +#ifndef DESKTOP_APP_DISABLE_WEBKITGTK Webview::WebKit2Gtk::SetServiceName( kWebviewService.utf16().arg(h).arg("%1").toStdString()); +#endif // !DESKTOP_APP_DISABLE_WEBKITGTK return; } else { From a094fa42a0a93739f507f452189ceba730a2a439 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 19 Jul 2021 20:52:04 +0400 Subject: [PATCH 07/15] Update submodules --- Telegram/codegen | 2 +- Telegram/lib_base | 2 +- Telegram/lib_crl | 2 +- Telegram/lib_lottie | 2 +- Telegram/lib_spellcheck | 2 +- Telegram/lib_ui | 2 +- Telegram/lib_webrtc | 2 +- Telegram/lib_webview | 2 +- cmake | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Telegram/codegen b/Telegram/codegen index 18b6e547c..248614b49 160000 --- a/Telegram/codegen +++ b/Telegram/codegen @@ -1 +1 @@ -Subproject commit 18b6e547c970e8ba2e5f817df18f0d613a7b2d8f +Subproject commit 248614b49cd7d5aff69d75a737f2e35b79fbb119 diff --git a/Telegram/lib_base b/Telegram/lib_base index f9ca7dc7f..65712d182 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit f9ca7dc7f357ecafb9ae9b5ffd467f364b6b124e +Subproject commit 65712d18253905d72db28d10d319e3c53616c915 diff --git a/Telegram/lib_crl b/Telegram/lib_crl index 16150bf71..3ccf2ed50 160000 --- a/Telegram/lib_crl +++ b/Telegram/lib_crl @@ -1 +1 @@ -Subproject commit 16150bf71d79382738114b913f137ec1a1a7630c +Subproject commit 3ccf2ed5095442e5874bba8852cb7dc4efeae29f diff --git a/Telegram/lib_lottie b/Telegram/lib_lottie index 71fecd909..0770df009 160000 --- a/Telegram/lib_lottie +++ b/Telegram/lib_lottie @@ -1 +1 @@ -Subproject commit 71fecd909b0d5553153ecb6803f03a91158aeefb +Subproject commit 0770df009db7928df1d0cad0900dc5110106d229 diff --git a/Telegram/lib_spellcheck b/Telegram/lib_spellcheck index 0a0097b9c..68c9b7889 160000 --- a/Telegram/lib_spellcheck +++ b/Telegram/lib_spellcheck @@ -1 +1 @@ -Subproject commit 0a0097b9c8b89257b9c78d962f780078f961c88b +Subproject commit 68c9b788958904aea7de79f986a0f82ec8c5b094 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 0ad1d2c96..51cfd0ba3 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 0ad1d2c9652e185dc8f5b07f90419babbd2416ab +Subproject commit 51cfd0ba35b749db5d85c902aa442fd93c82eeea diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index 1ea86a387..4a722c1f2 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit 1ea86a387b1bc4fb1374c53a098a749bf024f7e6 +Subproject commit 4a722c1f267b2491f8e9ef6200ae4ec61b46f397 diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 1a3206777..bf2149e81 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 1a3206777c0bca6d9fb5b643131e6d2b028a336f +Subproject commit bf2149e815fc26a71ba9871065365d0612b9b6b7 diff --git a/cmake b/cmake index a79798285..b3f3876c5 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit a79798285dfc49f63022d4f3aaa1a0da7b49bafa +Subproject commit b3f3876c5fe1aade09b96b60540b4e2e0adaed5a From 4ea065fdf13067c009714e5a2a2f8c534523bbbc Mon Sep 17 00:00:00 2001 From: Pavel Moiseenko <19418601+rakleed@users.noreply.github.com> Date: Thu, 15 Jul 2021 00:28:23 +0300 Subject: [PATCH 08/15] Specify name of app in list of installed apps --- Telegram/build/setup.iss | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/build/setup.iss b/Telegram/build/setup.iss index 952af4ecc..c18dd374c 100644 --- a/Telegram/build/setup.iss +++ b/Telegram/build/setup.iss @@ -21,6 +21,7 @@ DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputDir={#ReleasePath} SetupIconFile={#SourcePath}..\Resources\art\icon256.ico +UninstallDisplayName={#MyAppName} UninstallDisplayIcon={app}\Telegram.exe Compression=lzma SolidCompression=yes From 9b1d9679672fac1cf85fe2fdd3aa705d5de4b1ed Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 18 Jul 2021 07:26:42 +0400 Subject: [PATCH 09/15] Move NotificationServiceWatcher to notifications manager --- Telegram/CMakeLists.txt | 4 - .../linux_notification_service_watcher.cpp | 84 ------------------- .../linux_notification_service_watcher.h | 24 ------ .../linux/notifications_manager_linux.cpp | 39 +++++++++ .../platform/linux/specific_linux.cpp | 7 -- 5 files changed, 39 insertions(+), 119 deletions(-) delete mode 100644 Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.cpp delete mode 100644 Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 7dad8ebb2..b79769ec7 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -902,8 +902,6 @@ PRIVATE platform/linux/linux_gtk_integration.h platform/linux/linux_gtk_open_with_dialog.cpp platform/linux/linux_gtk_open_with_dialog.h - platform/linux/linux_notification_service_watcher.cpp - platform/linux/linux_notification_service_watcher.h platform/linux/linux_wayland_integration_dummy.cpp platform/linux/linux_wayland_integration.cpp platform/linux/linux_wayland_integration.h @@ -1203,8 +1201,6 @@ if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) platform/linux/linux_gsd_media_keys.h platform/linux/linux_mpris_support.cpp platform/linux/linux_mpris_support.h - platform/linux/linux_notification_service_watcher.cpp - platform/linux/linux_notification_service_watcher.h platform/linux/linux_xdp_file_dialog.cpp platform/linux/linux_xdp_file_dialog.h platform/linux/linux_xdp_open_with_dialog.cpp diff --git a/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.cpp b/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.cpp deleted file mode 100644 index f0dc477bd..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "platform/linux/linux_notification_service_watcher.h" - -#include "core/application.h" -#include "main/main_domain.h" -#include "window/notifications_manager.h" -#include "base/platform/linux/base_linux_glibmm_helper.h" -#include "base/platform/linux/base_linux_dbus_utilities.h" - -#include -#include - -namespace Platform { -namespace internal { -namespace { - -constexpr auto kService = "org.freedesktop.Notifications"_cs; - -auto Activatable() { - static const auto Result = []() -> std::optional { - try { - const auto connection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - - return ranges::contains( - base::Platform::DBus::ListActivatableNames(connection), - Glib::ustring(std::string(kService))); - } catch (...) { - } - - return std::nullopt; - }(); - - return Result; -} - -} // namespace - -class NotificationServiceWatcher::Private { -public: - Glib::RefPtr dbusConnection; - uint signalId = 0; -}; - -NotificationServiceWatcher::NotificationServiceWatcher() -: _private(std::make_unique()) { - try { - _private->dbusConnection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - - _private->signalId = base::Platform::DBus::RegisterServiceWatcher( - _private->dbusConnection, - std::string(kService), - []( - const Glib::ustring &service, - const Glib::ustring &oldOwner, - const Glib::ustring &newOwner) { - if (!Core::App().domain().started() - || (Activatable().value_or(true) && newOwner.empty())) { - return; - } - - crl::on_main([] { - Core::App().notifications().createManager(); - }); - }); - } catch (...) { - } -} - -NotificationServiceWatcher::~NotificationServiceWatcher() { - if (_private->dbusConnection && _private->signalId != 0) { - _private->dbusConnection->signal_unsubscribe(_private->signalId); - } -} - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.h b/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.h deleted file mode 100644 index 034b49c7b..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -namespace Platform { -namespace internal { - -class NotificationServiceWatcher { -public: - NotificationServiceWatcher(); - ~NotificationServiceWatcher(); - -private: - class Private; - const std::unique_ptr _private; -}; - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 82955b01c..4ecb073d9 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -49,6 +49,43 @@ bool InhibitionSupported = false; std::optional CurrentServerInformation; QStringList CurrentCapabilities; +std::unique_ptr CreateServiceWatcher() { + try { + const auto connection = Gio::DBus::Connection::get_sync( + Gio::DBus::BusType::BUS_TYPE_SESSION); + + const auto activatable = [&] { + try { + return ranges::contains( + base::Platform::DBus::ListActivatableNames(connection), + Glib::ustring(std::string(kService))); + } catch (...) { + // avoid service restart loop in sandboxed environments + return true; + } + }(); + + return std::make_unique( + connection, + std::string(kService), + [=]( + const Glib::ustring &service, + const Glib::ustring &oldOwner, + const Glib::ustring &newOwner) { + if (activatable && newOwner.empty()) { + return; + } + + crl::on_main([] { + Core::App().notifications().createManager(); + }); + }); + } catch (...) { + } + + return nullptr; +} + void StartServiceAsync(Fn callback) { try { const auto connection = Gio::DBus::Connection::get_sync( @@ -712,6 +749,8 @@ bool ByDefault() { } void Create(Window::Notifications::System *system) { + static const auto ServiceWatcher = CreateServiceWatcher(); + const auto managerSetter = [=] { using ManagerType = Window::Notifications::ManagerType; if ((Core::App().settings().nativeNotifications() && Supported()) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 2fa0be985..6040295fb 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/linux/base_linux_xdp_utilities.h" -#include "platform/linux/linux_notification_service_watcher.h" #include "platform/linux/linux_xdp_file_dialog.h" #include "platform/linux/linux_gsd_media_keys.h" #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION @@ -84,8 +83,6 @@ constexpr auto kSnapcraftSettingsObjectPath = "/io/snapcraft/Settings"_cs; constexpr auto kSnapcraftSettingsInterface = kSnapcraftSettingsService; #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -std::unique_ptr NSWInstance; - void PortalAutostart(bool start, bool silent) { if (cExeName().isEmpty()) { return; @@ -964,15 +961,11 @@ void start() { crl::async(SetDarkMode); #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - NSWInstance = std::make_unique(); FileDialog::XDP::Start(); #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } void finish() { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - NSWInstance = nullptr; -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } } // namespace ThirdParty From 49fed41dfa26fb2787953ea5c2f59ef39dce6a6c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 18 Jul 2021 07:25:01 +0400 Subject: [PATCH 10/15] Use RegisterUrlScheme from lib_base --- Telegram/SourceFiles/core/application.cpp | 15 ++ Telegram/SourceFiles/core/application.h | 2 + .../platform/linux/specific_linux.cpp | 139 ------------------ .../SourceFiles/platform/mac/specific_mac.mm | 6 - .../SourceFiles/platform/platform_specific.h | 1 - .../SourceFiles/platform/win/specific_win.cpp | 44 ------ .../SourceFiles/settings/settings_codes.cpp | 2 +- 7 files changed, 18 insertions(+), 191 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 04b2ec5ee..b21d839a9 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/ui_integration.h" #include "chat_helpers/emoji_keywords.h" #include "chat_helpers/stickers_emoji_image_loader.h" +#include "base/platform/base_platform_url_scheme.h" #include "base/platform/base_platform_last_input.h" #include "base/platform/base_platform_info.h" #include "platform/platform_specific.h" @@ -197,6 +198,7 @@ void Application::run() { ValidateScale(); if (Local::oldSettingsVersion() < AppVersion) { + RegisterUrlScheme(); psNewVersion(); } @@ -1130,6 +1132,19 @@ void Application::startShortcuts() { }, _lifetime); } +void Application::RegisterUrlScheme() { + base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{ + .executable = cExeDir() + cExeName(), + .arguments = qsl("-workdir \"%1\"").arg(cWorkingDir()), + .protocol = qsl("tg"), + .protocolName = qsl("Telegram Link"), + .shortAppName = qsl("tdesktop"), + .longAppName = QCoreApplication::applicationName(), + .displayAppName = AppName.utf16(), + .displayAppDescription = AppName.utf16(), + }); +} + bool IsAppLaunched() { return (Application::Instance != nullptr); } diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index e14b9b42a..c1ae38481 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -277,6 +277,8 @@ public: void setScreenIsLocked(bool locked); bool screenIsLocked() const; + static void RegisterUrlScheme(); + protected: bool eventFilter(QObject *object, QEvent *event) override; diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 6040295fb..b59bcefb2 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -43,8 +43,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#include -#include #include #include #include @@ -71,17 +69,12 @@ namespace { constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs; constexpr auto kIconName = "telegram"_cs; -constexpr auto kHandlerTypeName = "x-scheme-handler/tg"_cs; constexpr auto kDarkColorLimit = 192; constexpr auto kXDGDesktopPortalService = "org.freedesktop.portal.Desktop"_cs; constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs; constexpr auto kIBusPortalService = "org.freedesktop.portal.IBus"_cs; -constexpr auto kSnapcraftSettingsService = "io.snapcraft.Settings"_cs; -constexpr auto kSnapcraftSettingsObjectPath = "/io/snapcraft/Settings"_cs; -constexpr auto kSnapcraftSettingsInterface = kSnapcraftSettingsService; - #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION void PortalAutostart(bool start, bool silent) { if (cExeName().isEmpty()) { @@ -210,67 +203,6 @@ void PortalAutostart(bool start, bool silent) { } } -void SnapDefaultHandler(const QString &protocol) { - try { - const auto connection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - - auto reply = connection->call_sync( - std::string(kSnapcraftSettingsObjectPath), - std::string(kSnapcraftSettingsInterface), - "GetSub", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring("default-url-scheme-handler"), - Glib::ustring(protocol.toStdString()), - }), - std::string(kSnapcraftSettingsService)); - - const auto currentHandler = base::Platform::GlibVariantCast< - Glib::ustring>(reply.get_child(0)); - - const auto expectedHandler = qEnvironmentVariable("SNAP_NAME") - + qsl(".desktop"); - - if (currentHandler == expectedHandler.toStdString()) { - return; - } - - const auto context = Glib::MainContext::create(); - const auto loop = Glib::MainLoop::create(context); - g_main_context_push_thread_default(context->gobj()); - - connection->call( - std::string(kSnapcraftSettingsObjectPath), - std::string(kSnapcraftSettingsInterface), - "SetSub", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring("default-url-scheme-handler"), - Glib::ustring(protocol.toStdString()), - Glib::ustring(expectedHandler.toStdString()), - }), - [&](const Glib::RefPtr &result) { - try { - connection->call_finish(result); - } catch (const Glib::Error &e) { - LOG(("Snap Default Handler Error: %1").arg( - QString::fromStdString(e.what()))); - } - - loop->quit(); - }, - std::string(kSnapcraftSettingsService)); - - QWindow window; - QGuiApplicationPrivate::showModalWindow(&window); - loop->run(); - g_main_context_pop_thread_default(context->gobj()); - QGuiApplicationPrivate::hideModalWindow(&window); - } catch (const Glib::Error &e) { - LOG(("Snap Default Handler Error: %1").arg( - QString::fromStdString(e.what()))); - } -} - bool IsIBusPortalPresent() { static const auto Result = [&] { try { @@ -816,76 +748,6 @@ void InstallLauncher(bool force) { }); } -void RegisterCustomScheme(bool force) { - try { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - if (InSnap()) { - SnapDefaultHandler(qsl("tg")); - return; - } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION - - if (cExeName().isEmpty()) { - return; - } - - const auto neededCommandlineBuilder = qsl("%1 -workdir %2 --").arg( - QString(EscapeShell(QFile::encodeName(cExeDir() + cExeName()))), - QString(EscapeShell(QFile::encodeName(cWorkingDir())))); - - const auto neededCommandline = qsl("%1 %u") - .arg(neededCommandlineBuilder); - - const auto currentAppInfo = Gio::AppInfo::get_default_for_type( - std::string(kHandlerTypeName), - true); - - if (currentAppInfo) { - const auto currentCommandline = QString::fromStdString( - currentAppInfo->get_commandline()); - - if (currentCommandline == neededCommandline) { - return; - } - } - - auto registeredAppInfoList = g_app_info_get_recommended_for_type( - kHandlerTypeName.utf8().constData()); - - for (auto l = registeredAppInfoList; l != nullptr; l = l->next) { - const auto currentRegisteredAppInfo = reinterpret_cast( - l->data); - - const auto currentAppInfoId = QString( - g_app_info_get_id(currentRegisteredAppInfo)); - - const auto currentCommandline = QString( - g_app_info_get_commandline(currentRegisteredAppInfo)); - - if (currentCommandline == neededCommandline - && currentAppInfoId.startsWith(qsl("userapp-"))) { - g_app_info_delete(currentRegisteredAppInfo); - } - } - - if (registeredAppInfoList) { - g_list_free_full(registeredAppInfoList, g_object_unref); - } - - const auto newAppInfo = Gio::AppInfo::create_from_commandline( - neededCommandlineBuilder.toStdString(), - std::string(AppName), - Gio::AppInfoCreateFlags::APP_INFO_CREATE_SUPPORTS_URIS); - - if (newAppInfo) { - newAppInfo->set_as_default_for_type( - std::string(kHandlerTypeName)); - } - } catch (const Glib::Error &e) { - LOG(("App Error: %1").arg(QString::fromStdString(e.what()))); - } -} - PermissionStatus GetPermissionStatus(PermissionType type) { return PermissionStatus::Granted; } @@ -976,7 +838,6 @@ void psNewVersion() { #ifndef __HAIKU__ Platform::InstallLauncher(); #endif // __HAIKU__ - Platform::RegisterCustomScheme(); } void psAutoStart(bool start, bool silent) { diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.mm b/Telegram/SourceFiles/platform/mac/specific_mac.mm index 6b283d461..f07ba21cd 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac.mm @@ -112,11 +112,6 @@ void WriteCrashDumpDetails() { #endif // DESKTOP_APP_DISABLE_CRASH_REPORTS } -void RegisterCustomScheme(bool force) { - OSStatus result = LSSetDefaultHandlerForURLScheme(CFSTR("tg"), (CFStringRef)[[NSBundle mainBundle] bundleIdentifier]); - DEBUG_LOG(("App Info: set default handler for 'tg' scheme result: %1").arg(result)); -} - // I do check for availability, just not in the exact way clang is content with #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability" @@ -196,7 +191,6 @@ void IgnoreApplicationActivationRightNow() { } // namespace Platform void psNewVersion() { - Platform::RegisterCustomScheme(); } void psAutoStart(bool start, bool silent) { diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index f7112b214..709ea0058 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -30,7 +30,6 @@ enum class SystemSettingsType { void SetWatchingMediaKeys(bool watching); void SetApplicationIcon(const QIcon &icon); QString SingleInstanceLocalServerName(const QString &hash); -void RegisterCustomScheme(bool force = false); PermissionStatus GetPermissionStatus(PermissionType type); void RequestPermission(PermissionType type, Fn resultCallback); void OpenSystemSettingsForPermission(PermissionType type); diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 8d9417827..b94a114c9 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -372,49 +372,6 @@ namespace { namespace Platform { -void RegisterCustomScheme(bool force) { - if (cExeName().isEmpty()) { - return; - } - DEBUG_LOG(("App Info: Checking custom scheme 'tg'...")); - - HKEY rkey; - QString exe = QDir::toNativeSeparators(cExeDir() + cExeName()); - - // Legacy URI scheme registration - if (!_psOpenRegKey(L"Software\\Classes\\tg", &rkey)) return; - if (!_psSetKeyValue(rkey, L"URL Protocol", QString())) return; - if (!_psSetKeyValue(rkey, 0, qsl("URL:Telegram Link"))) return; - - if (!_psOpenRegKey(L"Software\\Classes\\tg\\DefaultIcon", &rkey)) return; - if (!_psSetKeyValue(rkey, 0, '"' + exe + qsl(",1\""))) return; - - if (!_psOpenRegKey(L"Software\\Classes\\tg\\shell", &rkey)) return; - if (!_psOpenRegKey(L"Software\\Classes\\tg\\shell\\open", &rkey)) return; - if (!_psOpenRegKey(L"Software\\Classes\\tg\\shell\\open\\command", &rkey)) return; - if (!_psSetKeyValue(rkey, 0, '"' + exe + qsl("\" -workdir \"") + cWorkingDir() + qsl("\" -- \"%1\""))) return; - - // URI scheme registration as Default Program - Windows Vista and above - if (!_psOpenRegKey(L"Software\\Classes\\tdesktop.tg", &rkey)) return; - if (!_psOpenRegKey(L"Software\\Classes\\tdesktop.tg\\DefaultIcon", &rkey)) return; - if (!_psSetKeyValue(rkey, 0, '"' + exe + qsl(",1\""))) return; - - if (!_psOpenRegKey(L"Software\\Classes\\tdesktop.tg\\shell", &rkey)) return; - if (!_psOpenRegKey(L"Software\\Classes\\tdesktop.tg\\shell\\open", &rkey)) return; - if (!_psOpenRegKey(L"Software\\Classes\\tdesktop.tg\\shell\\open\\command", &rkey)) return; - if (!_psSetKeyValue(rkey, 0, '"' + exe + qsl("\" -workdir \"") + cWorkingDir() + qsl("\" -- \"%1\""))) return; - - if (!_psOpenRegKey(L"Software\\TelegramDesktop", &rkey)) return; - if (!_psOpenRegKey(L"Software\\TelegramDesktop\\Capabilities", &rkey)) return; - if (!_psSetKeyValue(rkey, L"ApplicationName", qsl("Telegram Desktop"))) return; - if (!_psSetKeyValue(rkey, L"ApplicationDescription", qsl("Telegram Desktop"))) return; - if (!_psOpenRegKey(L"Software\\TelegramDesktop\\Capabilities\\UrlAssociations", &rkey)) return; - if (!_psSetKeyValue(rkey, L"tg", qsl("tdesktop.tg"))) return; - - if (!_psOpenRegKey(L"Software\\RegisteredApplications", &rkey)) return; - if (!_psSetKeyValue(rkey, L"Telegram Desktop", qsl("SOFTWARE\\TelegramDesktop\\Capabilities"))) return; -} - PermissionStatus GetPermissionStatus(PermissionType type) { if (type==PermissionType::Microphone) { PermissionStatus result=PermissionStatus::Granted; @@ -467,7 +424,6 @@ bool OpenSystemSettings(SystemSettingsType type) { } // namespace Platform void psNewVersion() { - Platform::RegisterCustomScheme(); if (Local::oldSettingsVersion() < 8051) { AppUserModelId::checkPinned(); } diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp index ef99f5c1f..cb8ed8ac0 100644 --- a/Telegram/SourceFiles/settings/settings_codes.cpp +++ b/Telegram/SourceFiles/settings/settings_codes.cpp @@ -137,7 +137,7 @@ auto GenerateCodes() { } }); codes.emplace(qsl("registertg"), [](SessionController *window) { - Platform::RegisterCustomScheme(true); + Core::Application::RegisterUrlScheme(); Ui::Toast::Show("Forced custom scheme register."); }); From dc81f9eeafec1d5161932aa2939693bf6d5bcb25 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 18 Jul 2021 07:29:06 +0400 Subject: [PATCH 11/15] Remove SetWatchingMediaKeys Since SPMediaKeyTap has been removed on Mac, Linux is the only platform where this function is implemented, but that's not really needed due to MPRIS support, so SetWatchingMediaKeys can be dropped entirely --- Telegram/CMakeLists.txt | 4 - Telegram/SourceFiles/core/shortcuts.cpp | 1 - .../platform/linux/linux_gsd_media_keys.cpp | 157 ------------------ .../platform/linux/linux_gsd_media_keys.h | 30 ---- .../platform/linux/specific_linux.cpp | 17 -- .../platform/mac/specific_mac_p.mm | 3 - .../SourceFiles/platform/platform_specific.h | 1 - .../SourceFiles/platform/win/specific_win.h | 3 - 8 files changed, 216 deletions(-) delete mode 100644 Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp delete mode 100644 Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index b79769ec7..f44b85137 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -894,8 +894,6 @@ PRIVATE platform/linux/linux_desktop_environment.h platform/linux/linux_gdk_helper.cpp platform/linux/linux_gdk_helper.h - platform/linux/linux_gsd_media_keys.cpp - platform/linux/linux_gsd_media_keys.h platform/linux/linux_gtk_integration_dummy.cpp platform/linux/linux_gtk_integration_p.h platform/linux/linux_gtk_integration.cpp @@ -1197,8 +1195,6 @@ endif() if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) remove_target_sources(Telegram ${src_loc} - platform/linux/linux_gsd_media_keys.cpp - platform/linux/linux_gsd_media_keys.h platform/linux/linux_mpris_support.cpp platform/linux/linux_mpris_support.h platform/linux/linux_xdp_file_dialog.cpp diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index 654890071..93d350d91 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -565,7 +565,6 @@ bool HandleEvent(not_null event) { void ToggleMediaShortcuts(bool toggled) { Data.toggleMedia(toggled); - Platform::SetWatchingMediaKeys(toggled); } void ToggleSupportShortcuts(bool toggled) { diff --git a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp b/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp deleted file mode 100644 index c5f19e03f..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "platform/linux/linux_gsd_media_keys.h" - -#include "core/sandbox.h" -#include "media/player/media_player_instance.h" -#include "base/platform/linux/base_linux_glibmm_helper.h" -#include "base/platform/linux/base_linux_dbus_utilities.h" - -#include -#include - -namespace Platform { -namespace internal { -namespace { - -constexpr auto kService = "org.gnome.SettingsDaemon.MediaKeys"_cs; -constexpr auto kOldService = "org.gnome.SettingsDaemon"_cs; -constexpr auto kMATEService = "org.mate.SettingsDaemon"_cs; -constexpr auto kObjectPath = "/org/gnome/SettingsDaemon/MediaKeys"_cs; -constexpr auto kMATEObjectPath = "/org/mate/SettingsDaemon/MediaKeys"_cs; -constexpr auto kInterface = kService; -constexpr auto kMATEInterface = "org.mate.SettingsDaemon.MediaKeys"_cs; - -void KeyPressed( - const Glib::RefPtr &connection, - const Glib::ustring &sender_name, - const Glib::ustring &object_path, - const Glib::ustring &interface_name, - const Glib::ustring &signal_name, - const Glib::VariantContainerBase ¶meters) { - try { - auto parametersCopy = parameters; - - const auto app = base::Platform::GlibVariantCast( - parametersCopy.get_child(0)); - - const auto key = base::Platform::GlibVariantCast( - parametersCopy.get_child(1)); - - if (app != QCoreApplication::applicationName().toStdString()) { - return; - } - - Core::Sandbox::Instance().customEnterFromEventLoop([&] { - if (key == "Play") { - Media::Player::instance()->playPause(); - } else if (key == "Stop") { - Media::Player::instance()->stop(); - } else if (key == "Next") { - Media::Player::instance()->next(); - } else if (key == "Previous") { - Media::Player::instance()->previous(); - } - }); - } catch (...) { - } -} - -} // namespace - -class GSDMediaKeys::Private { -public: - Glib::RefPtr dbusConnection; - - Glib::ustring service; - Glib::ustring objectPath; - Glib::ustring interface; - uint signalId = 0; - bool grabbed = false; -}; - -GSDMediaKeys::GSDMediaKeys() -: _private(std::make_unique()) { - try { - _private->dbusConnection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - - if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kService))) { - _private->service = std::string(kService); - _private->objectPath = std::string(kObjectPath); - _private->interface = std::string(kInterface); - } else if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kOldService))) { - _private->service = std::string(kOldService); - _private->objectPath = std::string(kObjectPath); - _private->interface = std::string(kInterface); - } else if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kMATEService))) { - _private->service = std::string(kMATEService); - _private->objectPath = std::string(kMATEObjectPath); - _private->interface = std::string(kMATEInterface); - } else { - return; - } - - _private->dbusConnection->call_sync( - _private->objectPath, - _private->interface, - "GrabMediaPlayerKeys", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring( - QCoreApplication::applicationName() - .toStdString()), - uint(0), - }), - _private->service); - - _private->grabbed = true; - - _private->signalId = _private->dbusConnection->signal_subscribe( - sigc::ptr_fun(KeyPressed), - _private->service, - _private->interface, - "MediaPlayerKeyPressed", - _private->objectPath); - } catch (...) { - } -} - -GSDMediaKeys::~GSDMediaKeys() { - if (_private->dbusConnection) { - if (_private->signalId != 0) { - _private->dbusConnection->signal_unsubscribe(_private->signalId); - } - - if (_private->grabbed) { - try { - _private->dbusConnection->call_sync( - _private->objectPath, - _private->interface, - "ReleaseMediaPlayerKeys", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring( - QCoreApplication::applicationName() - .toStdString()) - }), - _private->service); - - _private->grabbed = false; - } catch (...) { - } - } - } -} - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h b/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h deleted file mode 100644 index 10b854d6e..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -namespace Platform { -namespace internal { - -class GSDMediaKeys { -public: - GSDMediaKeys(); - - GSDMediaKeys(const GSDMediaKeys &other) = delete; - GSDMediaKeys &operator=(const GSDMediaKeys &other) = delete; - GSDMediaKeys(GSDMediaKeys &&other) = delete; - GSDMediaKeys &operator=(GSDMediaKeys &&other) = delete; - - ~GSDMediaKeys(); - -private: - class Private; - const std::unique_ptr _private; -}; - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index b59bcefb2..f9c0fa1db 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -28,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/linux/base_linux_xdp_utilities.h" #include "platform/linux/linux_xdp_file_dialog.h" -#include "platform/linux/linux_gsd_media_keys.h" #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION @@ -455,22 +454,6 @@ void SetDarkMode() { } // namespace -void SetWatchingMediaKeys(bool watching) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - static std::unique_ptr GSDInstance; - - if (watching) { - if (!GSDInstance) { - GSDInstance = std::make_unique(); - } - } else { - if (GSDInstance) { - GSDInstance = nullptr; - } - } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION -} - void SetApplicationIcon(const QIcon &icon) { QApplication::setWindowIcon(icon); } diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index edd85a666..eee9c89d6 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -243,9 +243,6 @@ ApplicationDelegate *_sharedDelegate = nil; namespace Platform { -void SetWatchingMediaKeys(bool watching) { -} - void SetApplicationIcon(const QIcon &icon) { NSImage *image = nil; if (!icon.isNull()) { diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index 709ea0058..0dec322f7 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -27,7 +27,6 @@ enum class SystemSettingsType { Audio, }; -void SetWatchingMediaKeys(bool watching); void SetApplicationIcon(const QIcon &icon); QString SingleInstanceLocalServerName(const QString &hash); PermissionStatus GetPermissionStatus(PermissionType type); diff --git a/Telegram/SourceFiles/platform/win/specific_win.h b/Telegram/SourceFiles/platform/win/specific_win.h index d35c3fcf3..84a8c8250 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.h +++ b/Telegram/SourceFiles/platform/win/specific_win.h @@ -16,9 +16,6 @@ class LocationPoint; namespace Platform { -inline void SetWatchingMediaKeys(bool watching) { -} - inline void IgnoreApplicationActivationRightNow() { } From 3e8912a53f9a9d4313577a4bccdfbf77ff5c5d59 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 18 Jul 2021 07:31:07 +0400 Subject: [PATCH 12/15] Remove reference to non-existing linux_mpris_support from CMakeFiles.txt --- Telegram/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index f44b85137..02ae2f87d 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1195,8 +1195,6 @@ endif() if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) remove_target_sources(Telegram ${src_loc} - platform/linux/linux_mpris_support.cpp - platform/linux/linux_mpris_support.h platform/linux/linux_xdp_file_dialog.cpp platform/linux/linux_xdp_file_dialog.h platform/linux/linux_xdp_open_with_dialog.cpp From 087fbe89ce32bd420974843360b119ba03e50a9c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 18 Jul 2021 23:07:11 +0400 Subject: [PATCH 13/15] Add additional checks to NotificationData::setImage --- .../platform/linux/notifications_manager_linux.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 4ecb073d9..0c5cbd18f 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -669,13 +669,17 @@ void NotificationData::close() { } void NotificationData::setImage(const QString &imagePath) { - if (_imageKey.empty()) { + if (imagePath.isEmpty() || _imageKey.empty()) { return; } const auto image = QImage(imagePath) .convertToFormat(QImage::Format_RGBA8888); + if (image.isNull()) { + return; + } + _hints[_imageKey] = MakeGlibVariant(std::tuple{ image.width(), image.height(), From 0a4b8fc7f66b9f80490cea844c249d47901f94cf Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 19 Jul 2021 02:20:39 +0400 Subject: [PATCH 14/15] Always use QLibrary for gtk to avoid confusing dynamic linker --- Telegram/CMakeLists.txt | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 02ae2f87d..55dda89e3 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -113,25 +113,16 @@ if (LINUX) endif() if (NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION) - target_link_libraries(Telegram PRIVATE rt) find_package(PkgConfig REQUIRED) - if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) - pkg_check_modules(GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0) - target_link_libraries(Telegram PRIVATE PkgConfig::GTK3) + pkg_check_modules(GTK REQUIRED gtk+-3.0) + target_include_directories(Telegram SYSTEM PRIVATE ${GTK_INCLUDE_DIRS}) - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) - pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11) - target_link_libraries(Telegram PRIVATE PkgConfig::X11) - endif() - else() - pkg_check_modules(GTK REQUIRED gtk+-3.0) - target_include_directories(Telegram SYSTEM PRIVATE ${GTK_INCLUDE_DIRS}) - - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) - target_link_libraries(Telegram PRIVATE X11) - endif() + if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) + target_link_libraries(Telegram PRIVATE X11) endif() + + target_link_libraries(Telegram PRIVATE rt) endif() endif() From b2c762e974033fc74012b81a362405a8777fa92e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jul 2021 22:15:04 +0200 Subject: [PATCH 15/15] Set (group) call window icon. --- Telegram/SourceFiles/calls/calls_panel.cpp | 2 -- Telegram/SourceFiles/calls/group/calls_group_panel.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 01a35814c..71e875584 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -116,8 +116,6 @@ void Panel::replaceCall(not_null call) { void Panel::initWindow() { window()->setAttribute(Qt::WA_OpaquePaintEvent); window()->setAttribute(Qt::WA_NoSystemBackground); - window()->setWindowIcon( - QIcon(QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly))); window()->setTitle(_user->name); window()->setTitleStyle(st::callTitle); diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index eef148ca2..33ca08c28 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -289,8 +289,6 @@ void Panel::chooseSourceStop() { void Panel::initWindow() { window()->setAttribute(Qt::WA_OpaquePaintEvent); window()->setAttribute(Qt::WA_NoSystemBackground); - window()->setWindowIcon( - QIcon(QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly))); window()->setTitleStyle(st::groupCallTitle); subscribeToPeerChanges();