- if (state == AVAHI_CLIENT_S_RUNNING)
- /* The serve has startup successfully and registered its host
- * name on the network, so it's time to create our services */
- create_services(c);
-
- else if (state == AVAHI_CLIENT_S_COLLISION) {
- /* Let's drop our registered services. When the server is back
- * in AVAHI_SERVER_RUNNING state we will register them
- * again with the new host name. */
+ switch (state) {
+ case AVAHI_CLIENT_S_RUNNING:
+
+ /* The server has startup successfully and registered its host
+ * name on the network, so it's time to create our services */
+ if (!group)
+ create_services(c);
+ break;
+
+ case AVAHI_CLIENT_FAILURE:
+
+ fprintf(stderr, "Client failure: %s\n", avahi_strerror(avahi_client_errno(c)));
+ avahi_simple_poll_quit(simple_poll);
+
+ break;
+
+ case AVAHI_CLIENT_S_COLLISION:
+
+ /* Let's drop our registered services. When the server is back
+ * in AVAHI_SERVER_RUNNING state we will register them
+ * again with the new host name. */
+
+ case AVAHI_CLIENT_S_REGISTERING:
+
+ /* The server records are now being established. This
+ * might be caused by a host name change. We need to wait
+ * for our own records to register until the host name is
+ * properly esatblished. */
+
+ if (group)
+ avahi_entry_group_reset(group);
+
+ break;
+
+ case AVAHI_CLIENT_CONNECTING:
+ ;
+ }
+}
+
+static void modify_callback(AVAHI_GCC_UNUSED AvahiTimeout *e, void *userdata) {
+ AvahiClient *client = userdata;
+
+ fprintf(stderr, "Doing some weird modification\n");
+
+ avahi_free(name);
+ name = avahi_strdup("Modified MegaPrinter");
+
+ /* If the server is currently running, we need to remove our
+ * service and create it anew */
+ if (avahi_client_get_state(client) == AVAHI_CLIENT_S_RUNNING) {
+
+ /* Remove the old services */