EpcServiceMonitor

EpcServiceMonitor — find DNS-SD services

Stability Level

Unstable, unless otherwise indicated

Synopsis


#include <libepc/service-monitor.h>

                    EpcServiceMonitorClass;
                    EpcServiceMonitorPrivate;
                    EpcServiceMonitor;
EpcServiceMonitor*  epc_service_monitor_new             (const gchar *application,
                                                         const gchar *domain,
                                                         EpcProtocol first_protocol,
                                                         ...);
EpcServiceMonitor*  epc_service_monitor_new_for_types   (const gchar *domain,
                                                         ...);
EpcServiceMonitor*  epc_service_monitor_new_for_types_strv
                                                        (const gchar *domain,
                                                         gchar **types);
void                epc_service_monitor_set_skip_our_own
                                                        (EpcServiceMonitor *monitor,
                                                         gboolean setting);
gboolean            epc_service_monitor_get_skip_our_own
                                                        (EpcServiceMonitor *monitor);

Object Hierarchy

  GObject
   +----EpcServiceMonitor

Properties

  "application"              gchar*                : Read / Write / Construct Only
  "domain"                   gchar*                : Read / Write / Construct Only
  "service-types"            GStrv*                : Read / Write / Construct Only
  "skip-our-own"             gboolean              : Read / Write / Construct

Signals

  "scanning-done"                                  : Run First
  "service-found"                                  : Run First
  "service-removed"                                : Run First

Description

The EpcServiceMonitor object provides an easy method for finding DNS-SD services. It hides all the boring state and callback handling Avahi requires, and just exposes three simple GObject signals: "service-found", "service-removed" and "scanning-done".

Example 8. Find an Easy-Publish service

  monitor = epc_service_monitor_new ("glom", NULL, EPC_PROTOCOL_UNKNOWN);

  g_signal_connect (monitor, "service-found", service_found_cb, self);
  g_signal_connect (monitor, "service-removed", service_removed_cb, self);

  g_main_loop_run (loop);
 


Details

EpcServiceMonitorClass

typedef struct {
  void (*service_found)   (EpcServiceMonitor  *monitor,
                           const gchar        *name,
                           EpcServiceInfo     *info);
  void (*service_removed) (EpcServiceMonitor  *monitor,
                           const gchar        *name,
                           const gchar        *type);
  void (*scanning_done)   (EpcServiceMonitor  *monitor,
                           const gchar        *type);
} EpcServiceMonitorClass;

Virtual methods of the EpcServiceMonitor class.

service_found ()

virtual method of the "service-found" signal

service_removed ()

virtual method of the "service-removed" signal

scanning_done ()

virtual method of the "scanning-done" signal

EpcServiceMonitorPrivate

typedef struct _EpcServiceMonitorPrivate EpcServiceMonitorPrivate;

Private fields of the EpcServiceMonitor class.


EpcServiceMonitor

typedef struct _EpcServiceMonitor EpcServiceMonitor;

Public fields of the EpcServiceMonitor class.


epc_service_monitor_new ()

EpcServiceMonitor*  epc_service_monitor_new             (const gchar *application,
                                                         const gchar *domain,
                                                         EpcProtocol first_protocol,
                                                         ...);

Creates a new service monitor watching the specified domain for a certain application using one of the protocols listed. Passing NULL for application lists all libepc based applications. Passing NULL for domain monitors the local network. Passing an empty protocol list requests monitoring of all service-types supported by the library (see epc_service_type_list_supported()).

application :

name of the application to monitor, or NULL

domain :

the DNS domain to monitor, or NULL

first_protocol :

the first protocol to monitor

... :

a list of additional protocols, terminated by EPC_PROTOCOL_UNKNOWN

Returns :

The newly created service monitor.

epc_service_monitor_new_for_types ()

EpcServiceMonitor*  epc_service_monitor_new_for_types   (const gchar *domain,
                                                         ...);

Creates a new service monitor watching the specified domain for the service-types listed. Passing NULL for domain monitors the local network. Passing an empty service list requests monitoring of all service-types supported by the library (see epc_service_type_list_supported()).

See also: epc_service_monitor_new_for_types_strv()

domain :

the DNS domain to monitor, or NULL

... :

a NULL terminated list of service types to monitor

Returns :

The newly created service monitor.

Since 0.3.1


epc_service_monitor_new_for_types_strv ()

EpcServiceMonitor*  epc_service_monitor_new_for_types_strv
                                                        (const gchar *domain,
                                                         gchar **types);

Creates a new service monitor watching the specified domain for the service-types listed. Passing NULL for domain monitors the local network. Passing an empty service list requests monitoring of all service-types supported by the library (see epc_service_type_list_supported()).

See also: epc_service_monitor_new_for_types()

domain :

the DNS domain to monitor, or NULL

types :

a NULL terminated list of service types to monitor

Returns :

The newly created service monitor.

epc_service_monitor_set_skip_our_own ()

void                epc_service_monitor_set_skip_our_own
                                                        (EpcServiceMonitor *monitor,
                                                         gboolean setting);

Updates the "skip-our-own" property.

monitor :

a EpcServiceMonitor

setting :

the new setting

epc_service_monitor_get_skip_our_own ()

gboolean            epc_service_monitor_get_skip_our_own
                                                        (EpcServiceMonitor *monitor);

Queries the current value of the "skip-our-own" property.

monitor :

a EpcServiceMonitor

Returns :

The current value of the "skip-our-own" property

Property Details

The "application" property

  "application"              gchar*                : Read / Write / Construct Only

The application to monitor.

Default value: NULL


The "domain" property

  "domain"                   gchar*                : Read / Write / Construct Only

The DNS domain to monitor.

Default value: NULL


The "service-types" property

  "service-types"            GStrv*                : Read / Write / Construct Only

The DNS-SD services types to watch.


The "skip-our-own" property

  "skip-our-own"             gboolean              : Read / Write / Construct

Skip services of the current application.

Default value: FALSE

Signal Details

The "scanning-done" signal

void                user_function                      (EpcServiceMonitor *monitor,
                                                        gchar             *type,
                                                        gpointer           user_data)      : Run First

This signal is emitted when active scanning as finished and most certainly no new services will be detected for some time. Can be used for instance to hide an progress indicator.

monitor :

a EpcServiceMonitor

type :

the service type watched

user_data :

user data set when the signal handler was connected.

The "service-found" signal

void                user_function                      (EpcServiceMonitor *monitor,
                                                        gchar             *name,
                                                        EpcServiceInfo    *info,
                                                        gpointer           user_data)      : Run First

This signal is emitted when a new service was found.

monitor :

a EpcServiceMonitor

name :

name of the service removed

info :

a description of the service found

user_data :

user data set when the signal handler was connected.

The "service-removed" signal

void                user_function                      (EpcServiceMonitor *monitor,
                                                        gchar             *name,
                                                        gchar             *type,
                                                        gpointer           user_data)      : Run First

This signal is emitted when a previously known service disappears.

monitor :

a EpcServiceMonitor

name :

name of the service removed

type :

the service type watched

user_data :

user data set when the signal handler was connected.