EpcShell

EpcShell — library management functions

Stability Level

Private, unless otherwise indicated

Synopsis


#include <libepc/shell.h>


#define             EPC_AVAHI_ERROR
AvahiClient*        epc_shell_create_avahi_client       (AvahiClientFlags flags,
                                                         AvahiClientCallback callback,
                                                         gpointer user_data,
                                                         GError **error);
void                epc_shell_enter                     (void);
const AvahiPoll*    epc_shell_get_avahi_poll_api        (void);
void                epc_shell_leave                     (void);
void                epc_shell_ref                       (void);
void                epc_shell_unref                     (void);

Description

The methods of the EpcShell singleton are used to manage library resources.

Details

EPC_AVAHI_ERROR

#define EPC_AVAHI_ERROR (epc_avahi_error_quark ())

Error domain for Avahi operations. Errors in this domain will be Avahi error codes. See GError for information on error domains.


epc_shell_create_avahi_client ()

AvahiClient*        epc_shell_create_avahi_client       (AvahiClientFlags flags,
                                                         AvahiClientCallback callback,
                                                         gpointer user_data,
                                                         GError **error);

Creates a new Avahi client with the behavior described by flags. Whenever the state of the client changes callback is called. This callback may be NULL. If the call was not successful, it returns FALSE. The error domain is EPC_AVAHI_ERROR. Possible error codes are those of the Avahi library.

You have to call epc_shell_ref before using this function.

Note

Please note that this function is called for the first time from within the epc_shell_create_avahi_client context! Thus, in the callback you should not make use of global variables that are initialized only after your call to epc_shell_create_avahi_client. A common mistake is to store the AvahiClient pointer returned by epc_shell_create_avahi_client in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer.

flags : options for creating the client
callback : the function to call on status changes, or NULL
user_data : data to passed to callback
error : return location for a GError, or NULL
Returns : The newly created Avahi client instance, or NULL on error.

epc_shell_enter ()

void                epc_shell_enter                     (void);

Acquires the big GDK lock when running unter GDK/GTK+. It has to be called after leaving GLib main loops to avoid race conditions. See gdk_threads_enter for details.


epc_shell_get_avahi_poll_api ()

const AvahiPoll*    epc_shell_get_avahi_poll_api        (void);

Returns the Avahi polling API object used for integrating the Avahi library with the GLib main loop.

You have to call epc_shell_ref before using this function.

Returns : The Avahi polling API used.

epc_shell_leave ()

void                epc_shell_leave                     (void);

Releases the big GDK lock when running unter GDK/GTK+. It has to be called before entering GLib main loops to avoid race conditions. See gdk_threads_leave for details.


epc_shell_ref ()

void                epc_shell_ref                       (void);

Increases the reference count for this library. When called for the first time essential resources are allocated. Each call to this function has to be paired with a call to epc_shell_unref.


epc_shell_unref ()

void                epc_shell_unref                     (void);

Decreases the reference count for this library. When the reference count reaches zero, global resources allocated by the library are released.