]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/static-services.c
Rename some server side objects/symbols so that they do not conflict with the same...
[catta] / avahi-daemon / static-services.c
index 59ef7aa9826275a1d7401b5a15dbcdf52a1af44c..ff2602f91a698ec555ba7d8b747f801772253ce0 100644 (file)
 #include <glib.h>
 #include <expat.h>
 
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
 #include <avahi-core/log.h>
 
 #include "main.h"
+#include "static-services.h"
 
 typedef struct StaticService StaticService;
 typedef struct StaticServiceGroup StaticServiceGroup;
@@ -62,7 +63,7 @@ struct StaticServiceGroup {
     gchar *name, *chosen_name;
     gboolean replace_wildcards;
 
-    AvahiEntryGroup *entry_group;
+    AvahiSEntryGroup *entry_group;
     AVAHI_LLIST_HEAD(StaticService, services);
     AVAHI_LLIST_FIELDS(StaticServiceGroup, groups);
 };
@@ -151,7 +152,8 @@ static void static_service_free(StaticService *s) {
 static void static_service_group_free(StaticServiceGroup *g) {
     g_assert(g);
 
-    remove_static_service_group_from_server(g);
+    if (g->entry_group)
+        avahi_s_entry_group_free(g->entry_group);
 
     while (g->services)
         static_service_free(g->services);
@@ -164,7 +166,7 @@ static void static_service_group_free(StaticServiceGroup *g) {
     g_free(g);
 }
 
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) {
     StaticServiceGroup *g = userdata;
     
     g_assert(s);
@@ -191,9 +193,6 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
 
     g_assert(g);
     
-    if (g->entry_group)
-        return;
-    
     if (g->chosen_name)
         g_free(g->chosen_name);
     
@@ -201,8 +200,11 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
         g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
     else
         g->chosen_name = g_strdup(g->name);
-    
-    g->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, g);
+
+    if (!g->entry_group)
+        g->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, g);
+
+    g_assert(avahi_s_entry_group_is_empty(g->entry_group));
     
     for (s = g->services; s; s = s->services_next) {
 
@@ -212,23 +214,23 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
                 -1, AF_UNSPEC,
                 g->chosen_name, s->type, 
                 s->domain_name, s->host_name, s->port,
-                avahi_string_list_copy(s->txt_records)) < 0) {
-            avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s)", g->chosen_name, s->type, g->filename);
+                s->txt_records) < 0) {
+            avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s): %s",
+                            g->chosen_name, s->type, g->filename,
+                            avahi_strerror(avahi_server_errno(avahi_server)));
             remove_static_service_group_from_server(g);
             return;
         }
     }
 
-    avahi_entry_group_commit(g->entry_group);
+    avahi_s_entry_group_commit(g->entry_group);
 }
 
 static void remove_static_service_group_from_server(StaticServiceGroup *g) {
     g_assert(g);
 
-    if (g->entry_group) {
-        avahi_entry_group_free(g->entry_group);
-        g->entry_group = NULL;
-    }
+    if (g->entry_group)
+        avahi_s_entry_group_reset(g->entry_group);
 }
 
 typedef enum {
@@ -590,7 +592,7 @@ void static_service_load(void) {
     }
 
     memset(&globbuf, 0, sizeof(globbuf));
-    if (glob(AVAHI_SERVICE_DIRECTORY "/*.service", GLOB_ERR, NULL, &globbuf) != 0)
+    if (glob(AVAHI_SERVICE_DIR "/*.service", GLOB_ERR, NULL, &globbuf) != 0)
         avahi_log_error("Failed to read service directory.");
     else {
         for (p = globbuf.gl_pathv; *p; p++)