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=702455
This commit is contained in:
@@ -1479,7 +1479,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)
|
||||
|
||||
@@ -89,6 +89,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
|
||||
@@ -659,6 +673,14 @@ 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)
|
||||
{
|
||||
|
||||
@@ -182,6 +182,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
@@ -82,6 +82,17 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
|
||||
printer->get_remote_ppd_attempts = 0;
|
||||
printer->remote_cups_connection_test = NULL;
|
||||
printer->auth_info_required = NULL;
|
||||
#ifdef HAVE_CUPS_API_1_6
|
||||
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
|
||||
@@ -101,6 +112,12 @@ gtk_printer_cups_finalize (GObject *object)
|
||||
g_free (printer->default_cover_after);
|
||||
g_strfreev (printer->auth_info_required);
|
||||
|
||||
#ifdef HAVE_CUPS_API_1_6
|
||||
g_free (printer->avahi_name);
|
||||
g_free (printer->avahi_type);
|
||||
g_free (printer->avahi_domain);
|
||||
#endif
|
||||
|
||||
if (printer->ppd_file)
|
||||
ppdClose (printer->ppd_file);
|
||||
|
||||
@@ -128,6 +145,7 @@ gtk_printer_cups_new (const char *name,
|
||||
{
|
||||
GObject *result;
|
||||
gboolean accepts_pdf;
|
||||
GtkPrinterCups *printer;
|
||||
|
||||
#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1
|
||||
accepts_pdf = TRUE;
|
||||
@@ -142,7 +160,16 @@ gtk_printer_cups_new (const char *name,
|
||||
"accepts-pdf", accepts_pdf,
|
||||
NULL);
|
||||
|
||||
return (GtkPrinterCups *) result;
|
||||
printer = GTK_PRINTER_CUPS (result);
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
ppd_file_t *
|
||||
|
||||
@@ -62,6 +62,17 @@ struct _GtkPrinterCups
|
||||
guint get_remote_ppd_poll;
|
||||
gint get_remote_ppd_attempts;
|
||||
GtkCupsConnectionTest *remote_cups_connection_test;
|
||||
#ifdef HAVE_CUPS_API_1_6
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user