EpcServiceMonitor

EpcServiceMonitor — find DNS-SD services

Stability Level

Unstable, unless otherwise indicated

Properties

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

Signals

void scanning-done Run First
void service-found Run First
void service-removed Run First

Object Hierarchy

    GObject
    ╰── EpcServiceMonitor

Includes

#include <libepc/service-monitor.h>

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

1
2
3
4
5
6
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);


Functions

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()).

Parameters

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()

Parameters

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()

Parameters

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.

Parameters

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.

Parameters

monitor

a EpcServiceMonitor

 

Returns

The current value of the “skip-our-own” property

Types and Values

struct EpcServiceMonitorClass

struct EpcServiceMonitorClass {
  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);
};

Virtual methods of the EpcServiceMonitor class.

Members

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.


struct EpcServiceMonitor

struct EpcServiceMonitor;

Public fields of the EpcServiceMonitor class.

Property Details

The “application” property

  “application”              gchar *

The application to monitor.

Flags: Read / Write / Construct Only

Default value: NULL


The “domain” property

  “domain”                   gchar *

The DNS domain to monitor.

Flags: Read / Write / Construct Only

Default value: NULL


The “service-types” property

  “service-types”            GStrv

The DNS-SD services types to watch.

Flags: Read / Write / Construct Only


The “skip-our-own” property

  “skip-our-own”             gboolean

Skip services of the current application.

Flags: Read / Write / Construct

Default value: FALSE

Signal Details

The “scanning-done” signal

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

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.

Parameters

monitor

a EpcServiceMonitor

 

type

the service type watched

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “service-found” signal

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

This signal is emitted when a new service was found.

Parameters

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.

 

Flags: Run First


The “service-removed” signal

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

This signal is emitted when a previously known service disappears.

Parameters

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.

 

Flags: Run First