Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/server_p.cpp
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | 110 | { | |||
---|---|---|---|---|---|
133 | // might override some of the things we set above (like application name) | 133 | // might override some of the things we set above (like application name) | ||
134 | notification.d->processHints(hints); | 134 | notification.d->processHints(hints); | ||
135 | 135 | | |||
136 | // If we didn't get a pixmap, load the app_icon instead | 136 | // If we didn't get a pixmap, load the app_icon instead | ||
137 | if (notification.d->image.isNull()) { | 137 | if (notification.d->image.isNull()) { | ||
138 | notification.setIcon(app_icon); | 138 | notification.setIcon(app_icon); | ||
139 | } | 139 | } | ||
140 | 140 | | |||
141 | // No application name? Try to figure out the process name using the sender's PID | 141 | uint pid = 0; | ||
142 | if (notification.applicationName().isEmpty()) { | 142 | if (notification.desktopEntry().isEmpty() || notification.applicationName().isEmpty()) { | ||
143 | qCInfo(NOTIFICATIONMANAGER) << "Notification from service" << message().service() << "didn't contain any identification information, this is an application bug!"; | 143 | qCInfo(NOTIFICATIONMANAGER) << "Notification from service" << message().service() << "didn't contain any identification information, this is an application bug!"; | ||
144 | 144 | | |||
145 | const QString processName = Utils::processNameFromDBusService(connection(), message().service()); | 145 | QDBusReply<uint> pidReply = connection().interface()->servicePid(message().service()); | ||
146 | if (pidReply.isValid()) { | ||||
147 | pid = pidReply.value(); | ||||
148 | } | ||||
149 | } | ||||
150 | | ||||
151 | // No desktop entry? Try to read the BAMF_DESKTOP_FILE_HINT in the environment of snaps | ||||
152 | if (notification.desktopEntry().isEmpty() && pid > 0) { | ||||
153 | const QString desktopEntry = Utils::desktopEntryFromPid(pid); | ||||
154 | if (!desktopEntry.isEmpty()) { | ||||
155 | qCDebug(NOTIFICATIONMANAGER) << "Resolved notification to be from desktop entry" << desktopEntry; | ||||
156 | notification.setDesktopEntry(desktopEntry); | ||||
157 | } | ||||
158 | } | ||||
159 | | ||||
160 | // No application name? Try to figure out the process name using the sender's PID | ||||
161 | if (notification.applicationName().isEmpty() && pid > 0) { | ||||
162 | const QString processName = Utils::processNameFromPid(pid); | ||||
146 | if (!processName.isEmpty()) { | 163 | if (!processName.isEmpty()) { | ||
147 | qCDebug(NOTIFICATIONMANAGER) << "Resolved notification to be from" << processName; | 164 | qCDebug(NOTIFICATIONMANAGER) << "Resolved notification to be from process name" << processName; | ||
148 | notification.setApplicationName(processName); | 165 | notification.setApplicationName(processName); | ||
149 | } | 166 | } | ||
150 | } | 167 | } | ||
151 | 168 | | |||
152 | if (wasReplaced) { | 169 | if (wasReplaced) { | ||
153 | notification.resetUpdated(); | 170 | notification.resetUpdated(); | ||
154 | emit static_cast<Server*>(parent())->notificationReplaced(replaces_id, notification); | 171 | emit static_cast<Server*>(parent())->notificationReplaced(replaces_id, notification); | ||
155 | } else { | 172 | } else { | ||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |