forked from AuroraMiddleware/gtk
printing: List Avahi printers
Show printers advertised by avahi on local network. CUPS backend now looks for _ipps._tcp and _ipp._tcp services offered by avahi. If it finds such a service (printer) it requests its attributes through IPP_GET_PRINTER_ATTRIBUTES ipp request and adds it to the list of printers. Such printer behaves like a remote printer then. If an avahi printer is a default printer then it is considered default by the backend only if there is no local or remote default printer. This functionality is enabled when building Gtk+ with CUPS 1.6 or later because it replaces browsing protocol removed in CUPS 1.6. https://bugzilla.gnome.org/show_bug.cgi?id=688956
This commit is contained in:
parent
bfb327deda
commit
eed9e72e83
42
configure.ac
42
configure.ac
@ -1421,7 +1421,7 @@ else
|
||||
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6; then
|
||||
AC_DEFINE(HAVE_CUPS_API_1_6, 1,
|
||||
[Define to 1 if CUPS 1.6 API is available])
|
||||
|
||||
have_cups_api_1_6=yes
|
||||
fi
|
||||
|
||||
AC_SUBST(CUPS_API_MAJOR)
|
||||
@ -1452,6 +1452,45 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for Avahi flags
|
||||
AC_ARG_ENABLE(avahi-browsing,
|
||||
[AS_HELP_STRING([--disable-avahi-browsing],
|
||||
[disable avahi browsing of printers])],,
|
||||
[enable_avahi_browsing=auto])
|
||||
|
||||
have_avahi_browsing=no
|
||||
if test "x$enable_avahi_browsing" != "xno" -a \
|
||||
"x$have_cups_api_1_6" = "xyes"; then
|
||||
AC_MSG_CHECKING([avahi-gobject])
|
||||
|
||||
if $PKG_CONFIG --exists avahi-gobject ; then
|
||||
AVAHI_CFLAGS=`$PKG_CONFIG --cflags avahi-gobject`
|
||||
AC_SUBST(AVAHI_CFLAGS)
|
||||
AVAHI_LIBS=`$PKG_CONFIG --libs avahi-gobject`
|
||||
AC_SUBST(AVAHI_LIBS)
|
||||
have_avahi_gobject=yes
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
if test "x$have_avahi_gobject" = "xyes" ; then
|
||||
AC_DEFINE([HAVE_AVAHI_BROWSING], [1], [Define to 1 if avahi-gobject available])
|
||||
have_avahi_browsing=yes
|
||||
else
|
||||
AC_MSG_ERROR([
|
||||
*** avahi-gobject not found. avahi-gobject is required to build GTK+ with support
|
||||
*** for avahi browsed printers when using CUPS 1.6.
|
||||
])
|
||||
fi
|
||||
else
|
||||
if test "x$enable_avahi_browsing" = "xyes"; then
|
||||
AC_MSG_ERROR([
|
||||
*** Avahi browsing support requested but CUPS 1.6 not found.
|
||||
])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checks to see if we should compile with PAPI backend for GTK+
|
||||
#
|
||||
|
||||
@ -1828,6 +1867,7 @@ echo " Dynamic modules: $build_dynamic_modules"
|
||||
echo " Included immodules: $included_immodules"
|
||||
echo " PackageKit support: $build_packagekit"
|
||||
echo " colord support: $have_colord"
|
||||
echo " Avahi browsing: $have_avahi_browsing"
|
||||
echo " Introspection: $found_introspection"
|
||||
echo " Debugging: $enable_debug"
|
||||
echo " Documentation: $enable_gtk_doc"
|
||||
|
@ -12,6 +12,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/gdk \
|
||||
$(CUPS_CFLAGS) \
|
||||
$(COLORD_CFLAGS) \
|
||||
$(AVAHI_CFLAGS) \
|
||||
-DGTK_COMPILATION \
|
||||
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
|
||||
$(GTK_DEP_CFLAGS) \
|
||||
@ -37,6 +38,6 @@ noinst_HEADERS = \
|
||||
gtkcupsutils.h
|
||||
|
||||
libprintbackend_cups_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
||||
libprintbackend_cups_la_LIBADD = $(LDADDS) $(CUPS_LIBS)
|
||||
libprintbackend_cups_la_LIBADD = $(LDADDS) $(CUPS_LIBS) $(AVAHI_LIBS)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
@ -87,6 +87,20 @@ static GtkCupsRequestStateFunc get_states[] = {
|
||||
#define ippSetState(ipp_request, ipp_state) ipp_request->state = ipp_state
|
||||
#define ippGetString(attr, index, foo) attr->values[index].string.text
|
||||
#define ippGetCount(attr) attr->num_values
|
||||
|
||||
int
|
||||
ippSetVersion (ipp_t *ipp,
|
||||
int major,
|
||||
int minor)
|
||||
{
|
||||
if (!ipp || major < 0 || minor < 0)
|
||||
return 0;
|
||||
|
||||
ipp->request.any.version[0] = major;
|
||||
ipp->request.any.version[1] = minor;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
@ -656,6 +670,13 @@ gtk_cups_request_encode_option (GtkCupsRequest *request,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_cups_request_set_ipp_version (GtkCupsRequest *request,
|
||||
gint major,
|
||||
gint minor)
|
||||
{
|
||||
ippSetVersion (request->ipp_request, major, minor);
|
||||
}
|
||||
|
||||
static void
|
||||
_connect (GtkCupsRequest *request)
|
||||
|
@ -178,6 +178,9 @@ gboolean gtk_cups_request_is_done (GtkCupsRequest *
|
||||
void gtk_cups_request_encode_option (GtkCupsRequest *request,
|
||||
const gchar *option,
|
||||
const gchar *value);
|
||||
void gtk_cups_request_set_ipp_version (GtkCupsRequest *request,
|
||||
gint major,
|
||||
gint minor);
|
||||
gboolean gtk_cups_result_is_error (GtkCupsResult *result);
|
||||
ipp_t * gtk_cups_result_get_response (GtkCupsResult *result);
|
||||
GtkCupsErrorType gtk_cups_result_get_error_type (GtkCupsResult *result);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -114,6 +114,17 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
|
||||
printer->remote_cups_connection_test = NULL;
|
||||
printer->auth_info_required = NULL;
|
||||
printer->default_number_up = 1;
|
||||
#ifdef HAVE_AVAHI_BROWSING
|
||||
printer->avahi_browsed = FALSE;
|
||||
printer->avahi_name = NULL;
|
||||
printer->avahi_type = NULL;
|
||||
printer->avahi_domain = NULL;
|
||||
#endif
|
||||
printer->ipp_version_major = 1;
|
||||
printer->ipp_version_minor = 1;
|
||||
printer->supports_copies = FALSE;
|
||||
printer->supports_collate = FALSE;
|
||||
printer->supports_number_up = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -134,8 +145,11 @@ gtk_printer_cups_finalize (GObject *object)
|
||||
g_strfreev (printer->auth_info_required);
|
||||
|
||||
#ifdef HAVE_COLORD
|
||||
if (printer->colord_cancellable)
|
||||
{
|
||||
g_cancellable_cancel (printer->colord_cancellable);
|
||||
g_object_unref (printer->colord_cancellable);
|
||||
}
|
||||
g_free (printer->colord_title);
|
||||
g_free (printer->colord_qualifier);
|
||||
if (printer->colord_client)
|
||||
@ -146,6 +160,12 @@ gtk_printer_cups_finalize (GObject *object)
|
||||
g_object_unref (printer->colord_profile);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVAHI_BROWSING
|
||||
g_free (printer->avahi_name);
|
||||
g_free (printer->avahi_type);
|
||||
g_free (printer->avahi_domain);
|
||||
#endif
|
||||
|
||||
if (printer->ppd_file)
|
||||
ppdClose (printer->ppd_file);
|
||||
|
||||
@ -512,6 +532,7 @@ colord_printer_details_aquired_cb (GtkPrinterCups *printer,
|
||||
gpointer user_data)
|
||||
{
|
||||
/* refresh the device */
|
||||
if (printer->colord_client)
|
||||
colord_update_device (printer);
|
||||
}
|
||||
#endif
|
||||
@ -565,6 +586,14 @@ gtk_printer_cups_new (const char *name,
|
||||
G_CALLBACK (colord_printer_details_aquired_cb),
|
||||
printer);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* IPP version 1.1 has to be supported
|
||||
* by all implementations according to rfc 2911
|
||||
*/
|
||||
printer->ipp_version_major = 1;
|
||||
printer->ipp_version_minor = 1;
|
||||
|
||||
return printer;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,17 @@ struct _GtkPrinterCups
|
||||
gchar *colord_title;
|
||||
gchar *colord_qualifier;
|
||||
#endif
|
||||
#ifdef HAVE_AVAHI_BROWSING
|
||||
gboolean avahi_browsed;
|
||||
gchar *avahi_name;
|
||||
gchar *avahi_type;
|
||||
gchar *avahi_domain;
|
||||
#endif
|
||||
guchar ipp_version_major;
|
||||
guchar ipp_version_minor;
|
||||
gboolean supports_copies;
|
||||
gboolean supports_collate;
|
||||
gboolean supports_number_up;
|
||||
};
|
||||
|
||||
struct _GtkPrinterCupsClass
|
||||
|
Loading…
Reference in New Issue
Block a user