~ubuntu-branches/ubuntu/quantal/libdmapsharing/quantal

« back to all changes in this revision

Viewing changes to libdmapsharing/dmap-mdns-avahi.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2011-03-29 19:52:57 UTC
  • mfrom: (0.1.2 experimental) (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110329195257-0zas0lq4c03gwo46
Tags: 2.9.7-1
Initial release. (Closes: #620060)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
 
1
/* Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
4
2
 *
5
3
 * Modifications Copyright (C) 2008 W. Michael Petullo <mike@flyn.org>
6
4
 *
34
32
static gsize client_init = 0;
35
33
 
36
34
static void
37
 
client_cb (AvahiClient         *client,
38
 
           AvahiClientState     state,
39
 
           gpointer             data)
 
35
client_cb (AvahiClient * client, AvahiClientState state, gpointer data)
40
36
{
41
37
        /* FIXME
42
38
         * check to make sure we're in the _RUNNING state before we publish
55
51
 
56
52
        case AVAHI_CLIENT_S_COLLISION:
57
53
 
58
 
                 /* Let's drop our registered services. When the server is back
59
 
                  * in AVAHI_SERVER_RUNNING state we will register them
60
 
                  * again with the new host name.
61
 
                  */
62
 
                 if (entry_group) {
63
 
                         avahi_entry_group_reset (entry_group);
64
 
                 }
65
 
                 break;
 
54
                /* Let's drop our registered services. When the server is back
 
55
                 * in AVAHI_SERVER_RUNNING state we will register them
 
56
                 * again with the new host name.
 
57
                 */
 
58
                if (entry_group) {
 
59
                        avahi_entry_group_reset (entry_group);
 
60
                }
 
61
                break;
66
62
 
67
63
        case AVAHI_CLIENT_FAILURE:
68
 
                 g_warning ("Client failure: %s\n", avahi_strerror (avahi_client_errno (client)));
69
 
                 break;
 
64
                g_warning ("Client failure: %s\n",
 
65
                           avahi_strerror (avahi_client_errno (client)));
 
66
                break;
70
67
 
71
68
        case AVAHI_CLIENT_CONNECTING:
72
69
        case AVAHI_CLIENT_S_REGISTERING:
87
84
 
88
85
                apoll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
89
86
                if (apoll == NULL) {
90
 
                        g_warning ("Unable to create AvahiGlibPoll object for mDNS");
 
87
                        g_warning
 
88
                                ("Unable to create AvahiGlibPoll object for mDNS");
91
89
                }
92
90
 
93
91
                client = avahi_client_new (avahi_glib_poll_get (apoll),
94
92
                                           flags,
95
93
                                           (AvahiClientCallback) client_cb,
96
 
                                           NULL,
97
 
                                           &error);
 
94
                                           NULL, &error);
98
95
                if (error != 0) {
99
 
                        g_warning ("Unable to initialize mDNS: %s", avahi_strerror (error));
 
96
                        g_warning ("Unable to initialize mDNS: %s",
 
97
                                   avahi_strerror (error));
100
98
                }
101
99
 
102
100
                g_once_init_leave (&client_init, 1);
106
104
}
107
105
 
108
106
void
109
 
dmap_mdns_avahi_set_entry_group (AvahiEntryGroup *eg)
 
107
dmap_mdns_avahi_set_entry_group (AvahiEntryGroup * eg)
110
108
{
111
109
        /* FIXME: No longer a valid assumption with new multiple-protocol
112
110
         * per process code. Refactor?