~unity-api-team/unity-notifications/trunk

« back to all changes in this revision

Viewing changes to src/NotificationServer.cpp

  • Committer: Bileto Bot
  • Author(s): Lukáš Tinkl
  • Date: 2016-10-24 11:31:40 UTC
  • mfrom: (241.1.3 unity-notifications)
  • Revision ID: ci-train-bot@canonical.com-20161024113140-ofcbha8g7c1z2lju
Simplify the check for cmd line (notify-send) to make it work also inside a container (LP: #1623142)

Approved by: Christopher Townsend, Michael Zanetti, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
    return sender;
168
168
}
169
169
 
170
 
bool NotificationServer::isCmdLine() const {
171
 
    if (!calledFromDBus()) {
172
 
        return false;
173
 
    }
174
 
    QString sender = message().service();
175
 
    uint pid = connection().interface()->servicePid(sender);
176
 
    QString path = QDir(QString("/proc/%1/exe").arg(pid)).canonicalPath();
177
 
    return (path == "/usr/bin/notify-send");
178
 
}
179
 
 
180
170
void NotificationServer::serviceUnregistered(const QString &clientId) {
181
171
    m_watcher.removeWatchedService(clientId);
182
172
    const auto notifications = model.removeAllNotificationsForClient(clientId);
288
278
 
289
279
    if (newNotification) {
290
280
        // Don't clean up after the command line client closes
291
 
        if (!isCmdLine()) {
 
281
        if (app_name != QStringLiteral("notify-send")) {
292
282
            m_watcher.addWatchedService(clientId);
293
283
        }
294
284
        model.insertNotification(notification);