Function: zeroconf-init

zeroconf-init is a byte-compiled function defined in zeroconf.el.gz.

Signature

(zeroconf-init &optional DOMAIN)

Documentation

Instantiate an Avahi service type browser for domain DOMAIN.

DOMAIN is a string, like "dns-sd.org" or "local". When DOMAIN is nil, the local domain is used.

Source Code

;; Defined in /usr/src/emacs/lisp/net/zeroconf.el.gz
;;; Services signaling.

;; Register for the service type browser.  Service registrations will
;; happen in `zeroconf-service-type-browser-handler', when there is an
;; "ItemNew" signal from the service type browser.
(defun zeroconf-init (&optional domain)
  "Instantiate an Avahi service type browser for domain DOMAIN.
DOMAIN is a string, like \"dns-sd.org\" or \"local\".  When
DOMAIN is nil, the local domain is used."
  (when (and (or (null domain) (stringp domain))
	     (dbus-ping :system zeroconf-service-avahi)
	     (dbus-call-method
	      :system zeroconf-service-avahi zeroconf-path-avahi
	      zeroconf-interface-avahi-server "GetVersionString"))

    ;; Reset all stored values.
    (setq zeroconf-path-avahi-service-type-browser nil
	  zeroconf-avahi-current-domain (or domain
					    zeroconf-avahi-domain-unspec))
    (clrhash zeroconf-path-avahi-service-browser-hash)
    (clrhash zeroconf-path-avahi-service-resolver-hash)
    (clrhash zeroconf-services-hash)
    (clrhash zeroconf-resolved-services-hash)
    (clrhash zeroconf-service-added-hooks-hash)
    (clrhash zeroconf-service-removed-hooks-hash)

    ;; Register a service type browser.
    (let ((object-path (zeroconf-register-service-type-browser)))
      ;; Register the signals.
      (dolist (member '("ItemNew" "ItemRemove" "Failure"))
	(dbus-register-signal
	 :system zeroconf-service-avahi object-path
	 zeroconf-interface-avahi-service-type-browser member
	 'zeroconf-service-type-browser-handler)))

    ;; Register state changed signal.
    (dbus-register-signal
     :system zeroconf-service-avahi zeroconf-path-avahi
     zeroconf-interface-avahi-service-type-browser "StateChanged"
     'zeroconf-service-type-browser-handler)))