7 This file is part of avahi.
9 avahi is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
14 avahi is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17 Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with avahi; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtkdialog.h>
28 #include <avahi-client/client.h>
30 /** \file avahi-ui.h A Gtk dialog for browsing for services */
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 #define AUI_TYPE_SERVICE_DIALOG (aui_service_dialog_get_type())
37 #define AUI_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialog))
38 #define AUI_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass))
39 #define AUI_IS_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AUI_TYPE_SERVICE_DIALOG))
40 #define AUI_IS_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), AUI_TYPE_SERVICE_DIALOG))
41 #define AUI_SERVICE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass))
43 typedef struct _AuiServiceDialogPrivate AuiServiceDialogPrivate;
44 typedef struct _AuiServiceDialogClass AuiServiceDialogClass;
46 struct _AuiServiceDialogClass {
47 GtkDialogClass parent_class;
49 /* Padding for future expansion */
50 void (*_aui_reserved1)(void);
51 void (*_aui_reserved2)(void);
52 void (*_aui_reserved3)(void);
53 void (*_aui_reserved4)(void);
56 struct _AuiServiceDialog {
57 GtkDialog parent_instance;
58 AuiServiceDialogPrivate *priv;
62 GType aui_service_dialog_get_type(void) G_GNUC_CONST;
66 /** The GTK service dialog structure */
67 typedef struct _AuiServiceDialog AuiServiceDialog;
69 /** Create a new service browser dialog with the specific title,
70 * parent window and the speicified buttons. The buttons are specified
71 * in a similar way to GtkFileChooserDialog. Please note that at least
72 * one button has to respond GTK_RESPONSE_ACCEPT. */
73 GtkWidget* aui_service_dialog_new(
76 const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED;
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 GtkWidget *aui_service_dialog_new_valist(
82 const gchar *first_button_text,
86 /** Select the service types to browse for. Takes a NULL terminated list of DNS-SD service types. i.e. _http._tcp */
87 void aui_service_dialog_set_browse_service_types(AuiServiceDialog *d, const gchar *type, ...) G_GNUC_NULL_TERMINATED;
88 /** Same as aui_service_dialog_set_browse_service_types() but take a NULL terminated array */
89 void aui_service_dialog_set_browse_service_typesv(AuiServiceDialog *d, const gchar *const*type);
90 /** Return the service types currently browsed for. i.e. what was previously set with aui_service_dialog_set_browse_service_types() */
91 const gchar*const* aui_service_dialog_get_browse_service_types(AuiServiceDialog *d);
93 /** Set the domain to browse in */
94 void aui_service_dialog_set_domain(AuiServiceDialog *d, const gchar *domain);
95 /** Query the domain that is browsed in */
96 const gchar* aui_service_dialog_get_domain(AuiServiceDialog *d);
98 /** Set the service type for the service to select */
99 void aui_service_dialog_set_service_type(AuiServiceDialog *d, const gchar *name);
101 /** Query the service type of the currently selected service */
102 const gchar* aui_service_dialog_get_service_type(AuiServiceDialog *d);
104 /** Set the service name for the service to select */
105 void aui_service_dialog_set_service_name(AuiServiceDialog *d, const gchar *name);
107 /** Query the service name of the currently select service */
108 const gchar* aui_service_dialog_get_service_name(AuiServiceDialog *d);
110 /** Return the IP address of the selected service. (Only valid if host name resolving has not been disabled via aui_service_dialog_set_resolve_host_name()) */
111 const AvahiAddress* aui_service_dialog_get_address(AuiServiceDialog *d);
113 /** Return the IP port number of the selected service */
114 guint16 aui_service_dialog_get_port(AuiServiceDialog *d);
116 /** Return the host name of the selected service */
117 const gchar* aui_service_dialog_get_host_name(AuiServiceDialog *d);
119 /** Return the TXT metadata of the selected service */
120 const AvahiStringList *aui_service_dialog_get_txt_data(AuiServiceDialog *d);
122 /** Disable/Enable automatic service resolving. Disabling this feature
123 * will require you to resolve the selected service on our own. I.e. the port
124 * number, the TXT data and the host name/IP address will not be
125 * available after a service has been selected. This functionality
126 * offers a certain optimization in the traffic imposed on the
127 * network. Most people will not want to touch this. */
128 void aui_service_dialog_set_resolve_service(AuiServiceDialog *d, gboolean resolve);
130 /** Query the last status of aui_service_dialog_set_resolve_service() */
131 gboolean aui_service_dialog_get_resolve_service(AuiServiceDialog *d);
133 /** Disable/Enable automatic host name resolving. Disabling this
134 * feature will cause aui_service_dialog_get_address() return NULL in
135 * all case because avahi-ui will not resolve the host name of the
136 * selected service to an address. This is a slight optimization
137 * regarding the traffic imposed by this query to the network. By
138 * default, avahi-ui will resolve the host names of selected services. */
139 void aui_service_dialog_set_resolve_host_name(AuiServiceDialog *d, gboolean resolve);
141 /** Query the last status of aui_service_dialog_set_resolve_host_name() */
142 gboolean aui_service_dialog_get_resolve_host_name(AuiServiceDialog *d);
144 /** Select the address family to look for services of. This can be
145 used to look only for IPv6 services or only for IPv4 services. By
146 default avahi-ui will browse for both IPv4 and IPv6 services.*/
147 void aui_service_dialog_set_address_family(AuiServiceDialog *d, AvahiProtocol proto);
149 /** Query the address family we're looking for. */
150 AvahiProtocol aui_service_dialog_get_address_family(AuiServiceDialog *d);