]> git.meshlink.io Git - catta/blobdiff - avahi-client/client.c
systemd: pull in avahi from dbus activation indirectly to make it possible to deactiv...
[catta] / avahi-client / client.c
index 389a3d11ce0bedcc17b2dfdd79cb1a41ba90b963..be675ad2bf81305d0786313a59dcad3e16347001 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of avahi.
 
@@ -35,6 +33,7 @@
 #include <avahi-common/dbus.h>
 #include <avahi-common/malloc.h>
 #include <avahi-common/dbus-watch-glue.h>
+#include <avahi-common/i18n.h>
 
 #include "client.h"
 #include "internal.h"
@@ -56,7 +55,7 @@ int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error) {
     return avahi_client_set_errno(client, avahi_error_dbus_to_number(error->name));
 }
 
-static void client_set_state (AvahiClient *client, AvahiServerState state) {
+static void client_set_state(AvahiClient *client, AvahiClientState state) {
     assert(client);
 
     if (client->state == state)
@@ -142,9 +141,10 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
 
         if (strcmp(name, AVAHI_DBUS_NAME) == 0) {
 
-            if (avahi_client_is_connected(client)) {
+            if (old[0] &&
+                avahi_client_is_connected(client)) {
 
-                /* Regardless if the server lost or acquired its name or
+                /* Regardless if the server lost its name or
                  * if the name was transfered: our services are no longer
                  * available, so we disconnect ourselves */
                 avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);
@@ -324,7 +324,7 @@ static int get_server_state(AvahiClient *client, int *ret_error) {
         dbus_error_is_set (&error))
         goto fail;
 
-    client_set_state(client, (AvahiServerState) state);
+    client_set_state(client, (AvahiClientState) state);
 
     dbus_message_unref(message);
     dbus_message_unref(reply);
@@ -523,7 +523,7 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
         goto fail;
     }
 
-    if (!dbus_connection_add_filter (client->bus, filter_func, client, NULL)) {
+    if (!dbus_connection_add_filter(client->bus, filter_func, client, NULL)) {
         if (ret_error)
             *ret_error = AVAHI_ERR_NO_MEMORY;
         goto fail;
@@ -560,9 +560,7 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
     if (dbus_error_is_set(&error))
         goto fail;
 
-
-    if (!(dbus_bus_name_has_owner(client->bus, AVAHI_DBUS_NAME, &error)) ||
-        dbus_error_is_set(&error)) {
+    if (!dbus_bus_start_service_by_name(client->bus, AVAHI_DBUS_NAME, 0, NULL, &error)) {
 
         /* We free the error so its not set, that way the fail target
          * will return the NO_DAEMON error rather than a DBUS error */