From d7a2e63033dd0d2d248b4cab7bf35e78f4049354 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 16 Jun 2005 22:12:26 +0000 Subject: * add support for static service definitions for the daemon using XML fragments git-svn-id: file:///home/lennart/svn/public/avahi/trunk@115 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-daemon/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'avahi-daemon/main.c') diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 7b3f209..ecc8c83 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -31,6 +31,7 @@ #include "main.h" #include "simple-protocol.h" +#include "static-services.h" #define DBUS_SERVICE_AVAHI "org.freedesktop.Avahi" @@ -119,10 +120,14 @@ signal_filter (DBusConnection *conn, DBusMessage *message, void *user_data) static void server_callback(AvahiServer *s, AvahiServerState state, gpointer userdata) { g_assert(s); - if (state == AVAHI_SERVER_RUNNING) + if (state == AVAHI_SERVER_RUNNING) { g_message("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s)); - else if (state == AVAHI_SERVER_COLLISION) { + static_service_add_to_server(); + } else if (state == AVAHI_SERVER_COLLISION) { gchar *n; + + static_service_remove_from_server(); + n = avahi_alternative_host_name(avahi_server_get_host_name(s)); g_message("Host name conflict, retrying with <%s>", n); avahi_server_set_host_name(s, n); @@ -135,7 +140,6 @@ int main(int argc, char *argv[]) { DBusConnection *bus = NULL; DBusError error; gint r = 255; - AvahiServer *server = NULL; AvahiServerConfig config; avahi_server_config_init(&config); @@ -186,12 +190,17 @@ int main(int argc, char *argv[]) { if (!(avahi_server = avahi_server_new(NULL, &config, server_callback, NULL))) goto finish; + static_service_load(); + g_main_loop_run(loop); r = 0; finish: + static_service_remove_from_server(); + static_service_free_all(); + simple_protocol_shutdown(); if (bus) { -- cgit