Changeset View
Changeset View
Standalone View
Standalone View
src/knotificationmanager.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | |||||
62 | 62 | | |||
63 | struct Q_DECL_HIDDEN KNotificationManager::Private { | 63 | struct Q_DECL_HIDDEN KNotificationManager::Private { | ||
64 | QHash<int, KNotification *> notifications; | 64 | QHash<int, KNotification *> notifications; | ||
65 | QHash<QString, KNotificationPlugin *> notifyPlugins; | 65 | QHash<QString, KNotificationPlugin *> notifyPlugins; | ||
66 | 66 | | |||
67 | // incremental ids for notifications | 67 | // incremental ids for notifications | ||
68 | int notifyIdCounter; | 68 | int notifyIdCounter; | ||
69 | QStringList dirtyConfigCache; | 69 | QStringList dirtyConfigCache; | ||
70 | bool inSandbox = false; | | |||
71 | bool portalDBusServiceExists = false; | 70 | bool portalDBusServiceExists = false; | ||
72 | }; | 71 | }; | ||
73 | 72 | | |||
74 | class KNotificationManagerSingleton | 73 | class KNotificationManagerSingleton | ||
75 | { | 74 | { | ||
76 | public: | 75 | public: | ||
77 | KNotificationManager instance; | 76 | KNotificationManager instance; | ||
78 | }; | 77 | }; | ||
79 | 78 | | |||
80 | Q_GLOBAL_STATIC(KNotificationManagerSingleton, s_self) | 79 | Q_GLOBAL_STATIC(KNotificationManagerSingleton, s_self) | ||
81 | 80 | | |||
82 | KNotificationManager *KNotificationManager::self() | 81 | KNotificationManager *KNotificationManager::self() | ||
83 | { | 82 | { | ||
84 | return &s_self()->instance; | 83 | return &s_self()->instance; | ||
85 | } | 84 | } | ||
86 | 85 | | |||
87 | KNotificationManager::KNotificationManager() | 86 | KNotificationManager::KNotificationManager() | ||
88 | : d(new Private) | 87 | : d(new Private) | ||
89 | { | 88 | { | ||
90 | d->notifyIdCounter = 0; | 89 | d->notifyIdCounter = 0; | ||
91 | qDeleteAll(d->notifyPlugins); | 90 | qDeleteAll(d->notifyPlugins); | ||
92 | d->notifyPlugins.clear(); | 91 | d->notifyPlugins.clear(); | ||
93 | 92 | | |||
94 | if (!qEnvironmentVariableIsEmpty("XDG_RUNTIME_DIR")) { | | |||
95 | const QByteArray runtimeDir = qgetenv("XDG_RUNTIME_DIR"); | | |||
96 | if (!runtimeDir.isEmpty()) { | | |||
97 | d->inSandbox = QFileInfo::exists(QFile::decodeName(runtimeDir) + QLatin1String("/flatpak-info")); | | |||
98 | } | | |||
99 | } else if (qEnvironmentVariableIsSet("SNAP")) { | | |||
100 | d->inSandbox = true; | | |||
101 | } | | |||
102 | | ||||
103 | #ifdef QT_DBUS_LIB | 93 | #ifdef QT_DBUS_LIB | ||
broulik: Do you need this check now, even, since you're not using it anymore? | |||||
I think Kai is right, since there is /.flatpak-info (which I didn't know about until now), you don't need to check $XDG_RUNTIME_DIR. jgrulich: I think Kai is right, since there is /.flatpak-info (which I didn't know about until now), you… | |||||
104 | if (d->inSandbox) { | 94 | const bool inSandbox = QFileInfo::exists(QLatin1String("/.flatpak-info")) || qEnvironmentVariableIsSet("SNAP"); | ||
95 | | ||||
96 | if (inSandbox) { | ||||
105 | QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface(); | 97 | QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface(); | ||
106 | d->portalDBusServiceExists = interface->isServiceRegistered(QStringLiteral("org.freedesktop.portal.Desktop")); | 98 | d->portalDBusServiceExists = interface->isServiceRegistered(QStringLiteral("org.freedesktop.portal.Desktop")); | ||
107 | } | 99 | } | ||
108 | 100 | | |||
109 | QDBusConnection::sessionBus().connect(QString(), | 101 | QDBusConnection::sessionBus().connect(QString(), | ||
110 | QStringLiteral("/Config"), | 102 | QStringLiteral("/Config"), | ||
111 | QStringLiteral("org.kde.knotification"), | 103 | QStringLiteral("org.kde.knotification"), | ||
112 | QStringLiteral("reparseConfiguration"), | 104 | QStringLiteral("reparseConfiguration"), | ||
Show All 24 Lines | 128 | connect(plugin, &KNotificationPlugin::actionInvoked, | |||
137 | this, &KNotificationManager::notificationActivated); | 129 | this, &KNotificationManager::notificationActivated); | ||
138 | }; | 130 | }; | ||
139 | 131 | | |||
140 | // Load plugin. | 132 | // Load plugin. | ||
141 | // We have a series of built-ins up first, and fall back to trying | 133 | // We have a series of built-ins up first, and fall back to trying | ||
142 | // to instantiate an externally supplied plugin. | 134 | // to instantiate an externally supplied plugin. | ||
143 | if (action == QLatin1String("Popup")) { | 135 | if (action == QLatin1String("Popup")) { | ||
144 | #ifndef Q_OS_ANDROID | 136 | #ifndef Q_OS_ANDROID | ||
145 | if (d->inSandbox && d->portalDBusServiceExists) { | 137 | if (d->portalDBusServiceExists) { | ||
146 | plugin = new NotifyByPortal(this); | 138 | plugin = new NotifyByPortal(this); | ||
147 | } else { | 139 | } else { | ||
148 | plugin = new NotifyByPopup(this); | 140 | plugin = new NotifyByPopup(this); | ||
149 | } | 141 | } | ||
150 | #else | 142 | #else | ||
151 | plugin = new NotifyByAndroid(this); | 143 | plugin = new NotifyByAndroid(this); | ||
152 | #endif | 144 | #endif | ||
153 | 145 | | |||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
Do you need this check now, even, since you're not using it anymore?