bool AvahiBrowser::invoke_resolver(const Glib::ustring& name) { AvahiProtocol protocol = AVAHI_PROTO_UNSPEC; AvahiIfIndex interface = AVAHI_IF_UNSPEC; Entry *e = 0; for (std::list<Entry>::iterator i = services.begin(); i != services.end(); ++i) { if (i->name != name) { continue; } if (i->protocol < protocol) { continue; } if (i->interface < interface) { continue; } e = &(*i); } if (!e) { return false; } assert(!resolver); resolver = ga_service_resolver_new( e->interface, e->protocol, e->name.c_str(), e->type.c_str(), e->domain.c_str(), e->protocol, GA_LOOKUP_NO_FLAGS); g_signal_connect(resolver, "found", G_CALLBACK(on_found), this); g_signal_connect(resolver, "failure", G_CALLBACK(on_failure), this); GError *error = 0; ga_service_resolver_attach(resolver, client, &error); return true; }
static void sib_controller_new_service_cb( GaServiceBrowser *context, gint interface, gint protocol, gchar *name, gchar *type, gchar *domain, gint flags, gpointer userdata) { whiteboard_log_debug_fb(); SIBController *self = (SIBController *)userdata; GError *err = NULL; SIBServerData *ssdata = NULL; g_return_if_fail(self!=NULL); whiteboard_log_debug("New service: %s, type %s, domain: %s\n", name, type, domain); if( g_ascii_strcasecmp(type, SIB_SERVICE_TYPE) == 0) { ssdata = g_new0(SIBServerData,1); ssdata->uri = (guchar*)g_strdup(name); if(sib_controller_add_service(self,ssdata)) { ssdata->resolver = ga_service_resolver_new(interface, protocol, name, type, domain, AVAHI_PROTO_INET, GA_LOOKUP_NO_FLAGS); if(ssdata->resolver) { if( ga_service_resolver_attach(ssdata->resolver, self->client, &err) == TRUE) { g_signal_connect( G_OBJECT(ssdata->resolver), "found", (GCallback) sib_controller_resolver_found, self); g_signal_connect( G_OBJECT(ssdata->resolver), "failure", (GCallback) sib_controller_resolver_failure, self); } else if(err != NULL) { whiteboard_log_debug("Could not attach avahi service_browser w/ client: %s\n", err->message); g_error_free(err); sib_controller_remove_service(self, ssdata->uri); } } else { whiteboard_log_debug("Could not create avahi service_browser\n"); sib_controller_remove_service(self, ssdata->uri); } } } whiteboard_log_debug_fe(); }