"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-2.6.1/Telegram/SourceFiles/platform/linux/linux_notification_service_watcher.cpp" (24 Feb 2021, 1196 Bytes) of package /linux/misc/tdesktop-2.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "linux_notification_service_watcher.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2 This file is part of Telegram Desktop,
    3 the official desktop application for the Telegram messaging service.
    4 
    5 For license and copyright information please follow this link:
    6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
    7 */
    8 #include "platform/linux/linux_notification_service_watcher.h"
    9 
   10 #include "core/application.h"
   11 #include "main/main_domain.h"
   12 #include "window/notifications_manager.h"
   13 #include "platform/linux/specific_linux.h"
   14 
   15 #include <QtDBus/QDBusConnection>
   16 
   17 namespace Platform {
   18 namespace internal {
   19 
   20 NotificationServiceWatcher::NotificationServiceWatcher()
   21 : _dbusWatcher(
   22         qsl("org.freedesktop.Notifications"),
   23         QDBusConnection::sessionBus(),
   24         QDBusServiceWatcher::WatchForOwnerChange) {
   25     const auto signal = &QDBusServiceWatcher::serviceOwnerChanged;
   26     QObject::connect(&_dbusWatcher, signal, [=](
   27             const QString &service,
   28             const QString &oldOwner,
   29             const QString &newOwner) {
   30         crl::on_main([=] {
   31             if (!Core::App().domain().started()) {
   32                 return;
   33             } else if (IsNotificationServiceActivatable()
   34                 && newOwner.isEmpty()) {
   35                 return;
   36             }
   37 
   38             Core::App().notifications().createManager();
   39         });
   40     });
   41 }
   42 
   43 } // namespace internal
   44 } // namespace Platform