Distinguish DBus connection and name acquired error

Distinguish between a failure to connect to DBus and a failure to
connect to the actual FDN DBus path.

This is possible, because `on_name_acquired` gets its DBus connection
passed as a parameter. If this parameter is NULL, there is no connection
established and the DBus name is not lost, because another notification
daemon is running.
This commit is contained in:
Benedikt Heine 2017-12-06 17:06:15 +01:00
parent 75fddab7bd
commit 16aefbabe3

View File

@ -418,7 +418,11 @@ static void on_name_lost(GDBusConnection *connection,
const gchar *name, const gchar *name,
gpointer user_data) gpointer user_data)
{ {
fprintf(stderr, "Name Lost. Is Another notification daemon running?\n"); if (connection)
fprintf(stderr, "Cannot acquire 'org.freedesktop.Notifications'."
"Is Another notification daemon running?\n");
else
fprintf(stderr, "Cannot connect to DBus.\n");
exit(1); exit(1);
} }