diff --git a/.gitmodules b/.gitmodules index 101674a90..bf3c35f42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -100,3 +100,6 @@ [submodule "Telegram/ThirdParty/libprisma"] path = Telegram/ThirdParty/libprisma url = https://github.com/desktop-app/libprisma.git +[submodule "Telegram/ThirdParty/xdg-desktop-portal"] + path = Telegram/ThirdParty/xdg-desktop-portal + url = https://github.com/flatpak/xdg-desktop-portal.git diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index e1766f5e6..64409ea88 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1651,9 +1651,6 @@ else() desktop-app::external_glibmm ) - include(${cmake_helpers_loc}/external/glib/generate_dbus.cmake) - generate_dbus(Telegram org.freedesktop.portal. XdpInhibit ${src_loc}/platform/linux/org.freedesktop.portal.Inhibit.xml) - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(Telegram PRIVATE diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index c94400ff1..0473edf72 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -78,24 +78,24 @@ std::unique_ptr CreateServiceWatcher() { Gio::DBus::BusType::SESSION); const auto activatable = [&] { - try { - return ranges::contains( - base::Platform::DBus::ListActivatableNames(connection), - kService, - &Glib::ustring::raw); - } catch (...) { + const auto names = base::Platform::DBus::ListActivatableNames( + connection->gobj()); + + if (!names) { // avoid service restart loop in sandboxed environments return true; } + + return ranges::contains(*names, kService); }(); return std::make_unique( - connection, + connection->gobj(), kService, [=]( - const Glib::ustring &service, - const Glib::ustring &oldOwner, - const Glib::ustring &newOwner) { + const std::string &service, + const std::string &oldOwner, + const std::string &newOwner) { Core::Sandbox::Instance().customEnterFromEventLoop([&] { if (activatable && newOwner.empty()) { Core::App().notifications().clearAll(); @@ -115,27 +115,28 @@ void StartServiceAsync(Fn callback) { const auto connection = Gio::DBus::Connection::get_sync( Gio::DBus::BusType::SESSION); - base::Platform::DBus::StartServiceByNameAsync( - connection, + namespace DBus = base::Platform::DBus; + DBus::StartServiceByNameAsync( + connection->gobj(), kService, - [=](Fn result) { + [=](Fn()> result) { Core::Sandbox::Instance().customEnterFromEventLoop([&] { Noexcept([&] { - try { - result(); // get the error if any - } catch (const Glib::Error &e) { + // get the error if any + if (const auto ret = result(); !ret) { static const auto NotSupportedErrors = { "org.freedesktop.DBus.Error.ServiceUnknown", }; - const auto errorName = - Gio::DBus::ErrorUtils::get_remote_error(e) - .raw(); - - if (!ranges::contains( + if (ranges::none_of( NotSupportedErrors, - errorName)) { - throw; + [&](const auto &error) { + return strstr( + ret.error()->what(), + error); + })) { + throw std::runtime_error( + ret.error()->what()); } } }); @@ -156,25 +157,20 @@ bool GetServiceRegistered() { const auto connection = Gio::DBus::Connection::get_sync( Gio::DBus::BusType::SESSION); - const auto hasOwner = [&] { - try { - return base::Platform::DBus::NameHasOwner( - connection, - kService); - } catch (...) { - return false; - } - }(); + const auto hasOwner = base::Platform::DBus::NameHasOwner( + connection->gobj(), + kService + ).value_or(false); static const auto activatable = [&] { - try { - return ranges::contains( - base::Platform::DBus::ListActivatableNames(connection), - kService, - &Glib::ustring::raw); - } catch (...) { + const auto names = base::Platform::DBus::ListActivatableNames( + connection->gobj()); + + if (!names) { return false; } + + return ranges::contains(*names, kService); }(); return hasOwner || activatable; diff --git a/Telegram/SourceFiles/platform/linux/org.freedesktop.portal.Inhibit.xml b/Telegram/SourceFiles/platform/linux/org.freedesktop.portal.Inhibit.xml deleted file mode 100644 index e91bd22d3..000000000 --- a/Telegram/SourceFiles/platform/linux/org.freedesktop.portal.Inhibit.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Telegram/ThirdParty/xdg-desktop-portal b/Telegram/ThirdParty/xdg-desktop-portal new file mode 160000 index 000000000..fa8d41a2f --- /dev/null +++ b/Telegram/ThirdParty/xdg-desktop-portal @@ -0,0 +1 @@ +Subproject commit fa8d41a2f9a5d30a1e41568b6fb53b046dce14dc diff --git a/Telegram/lib_base b/Telegram/lib_base index 888a19075..cee9211bd 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit 888a19075b569eda3d18a977543320823b984ae0 +Subproject commit cee9211bd58e054f24ad5e7f122037f71a44b237 diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 4fce8b197..27af88195 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 4fce8b1971721da739619acf36da0fe79d614a23 +Subproject commit 27af88195bca687e9d2a52b4fcd4e83ef5476be9 diff --git a/cmake b/cmake index a46279fcf..b699c232d 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit a46279fcfe69ebcc806bb31679ccece5f7c07508 +Subproject commit b699c232d57d50070a7b1b861809e206624f48d4