Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 346722 Details for
Bug 467528
=x11-libs/gtk+-3.2.4-r1 with =sys-devel/binutils-2.23.2 - undefined reference to symbol 'g_module_symbol'
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
gtk+-3.2.4-cups-1.6.patch
gtk+-3.2.4-cups-1.6.patch (text/plain), 35.36 KB, created by
Ted Tanberry
on 2013-04-27 17:55:27 UTC
(
hide
)
Description:
gtk+-3.2.4-cups-1.6.patch
Filename:
MIME Type:
Creator:
Ted Tanberry
Created:
2013-04-27 17:55:27 UTC
Size:
35.36 KB
patch
obsolete
>--- configure.ac 2013-04-27 16:51:25.022996055 +0200 >+++ configure.ac 2013-04-27 16:51:53.712962958 +0200 >@@ -1425,6 +1425,12 @@ > AC_DEFINE(HAVE_CUPS_API_1_2, 1, > [Define to 1 if CUPS 1.2 API is available]) > fi >+ if test $CUPS_API_MAJOR -gt 1 -o \ >+ $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]) >+ >+ fi > > AC_SUBST(CUPS_API_MAJOR) > AC_SUBST(CUPS_API_MINOR) >Only in gtk+-3.2.4/: configure.ac.orig >--- modules/printbackends/cups/gtkcupsutils.c 2013-04-27 16:51:26.273994613 +0200 >+++ modules/printbackends/cups/gtkcupsutils.c 2013-04-27 16:51:54.123962483 +0200 >@@ -83,6 +83,14 @@ > _get_read_data > }; > >+#ifndef HAVE_CUPS_API_1_6 >+#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id >+#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id >+#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 >+#endif >+ > static void > gtk_cups_result_set_error (GtkCupsResult *result, > GtkCupsErrorType error_type, >@@ -165,8 +173,8 @@ > request->data_io = data_io; > > request->ipp_request = ippNew (); >- request->ipp_request->request.op.operation_id = operation_id; >- request->ipp_request->request.op.request_id = 1; >+ ippSetOperation (request->ipp_request, operation_id); >+ ippSetRequestId (request->ipp_request, 1); > > language = cupsLangDefault (); > >@@ -355,8 +363,8 @@ > name, > tag); > >- if (attribute != NULL && attribute->values != NULL) >- return attribute->values[0].string.text; >+ if (attribute != NULL && ippGetCount (attribute) > 0) >+ return ippGetString (attribute, 0, NULL); > else > return NULL; > } >@@ -734,7 +742,7 @@ > request->attempts = 0; > > request->state = GTK_CUPS_POST_WRITE_REQUEST; >- request->ipp_request->state = IPP_IDLE; >+ ippSetState (request->ipp_request, IPP_IDLE); > } > > static void >@@ -1227,7 +1235,7 @@ > request->state = GTK_CUPS_GET_CHECK; > request->poll_state = GTK_CUPS_HTTP_READ; > >- request->ipp_request->state = IPP_IDLE; >+ ippSetState (request->ipp_request, IPP_IDLE); > } > > static void >diff -ur old/modules/printbackends/cups/gtkprintbackendcups.c gtk+-3.2.4/modules/printbackends/cups/gtkprintbackendcups.c >--- modules/printbackends/cups/gtkprintbackendcups.c 2013-04-27 16:51:26.273994613 +0200 >+++ modules/printbackends/cups/gtkprintbackendcups.c 2013-04-27 16:51:54.119962488 +0200 >@@ -30,6 +30,13 @@ > #include <sys/stat.h> > #include <stdlib.h> > #include <time.h> >+/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(), >+ * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This >+ * turns off the warning so that it will compile. >+ */ >+#ifdef HAVE_CUPS_API_1_6 >+# define _PPD_DEPRECATED >+#endif > > #include <cups/cups.h> > #include <cups/language.h> >@@ -241,7 +248,22 @@ > { > return gtk_print_backend_cups_new (); > } >- >+/* CUPS 1.6 Getter/Setter Functions CUPS 1.6 makes private most of the >+ * IPP structures and enforces access via new getter functions, which >+ * are unfortunately not available in earlier versions. We define >+ * below those getter functions as macros for use when building >+ * against earlier CUPS versions. >+ */ >+#ifndef HAVE_CUPS_API_1_6 >+#define ippGetOperation(ipp_request) ipp_request->request.op.operation_id >+#define ippGetInteger(attr, index) attr->values[index].integer >+#define ippGetBoolean(attr, index) attr->values[index].boolean >+#define ippGetString(attr, index, foo) attr->values[index].string.text >+#define ippGetValueTag(attr) attr->value_tag >+#define ippGetName(attr) attr->name >+#define ippGetCount(attr) attr->num_values >+#define ippGetGroupTag(attr) attr->group_tag >+#endif > /* > * GtkPrintBackendCups > */ >@@ -469,7 +491,7 @@ > ipp_t *response = gtk_cups_result_get_response (result); > > if ((attr = ippFindAttribute (response, "job-id", IPP_TAG_INTEGER)) != NULL) >- job_id = attr->values[0].integer; >+ job_id = ippGetInteger (attr, 0); > > if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0) > gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED); >@@ -862,7 +884,7 @@ > > dispatch->backend->authentication_lock = TRUE; > >- switch (dispatch->request->ipp_request->request.op.operation_id) >+ switch (ippGetOperation (dispatch->request->ipp_request)) > { > case IPP_PRINT_JOB: > if (job_title != NULL && printer_name != NULL) >@@ -890,7 +912,7 @@ > break; > default: > /* work around gcc warning about 0 not being a value for this enum */ >- if (dispatch->request->ipp_request->request.op.operation_id == 0) >+ if (ippGetOperation (dispatch->request->ipp_request) == 0) > prompt = g_strdup_printf ( _("Authentication is required to get a file from %s"), hostname); > else > prompt = g_strdup_printf ( _("Authentication is required on %s"), hostname); >@@ -1478,10 +1500,15 @@ > } > > data->counter++; >- >+ > response = gtk_cups_result_get_response (result); > > state = 0; >+ >+#ifdef HAVE_CUPS_API_1_6 >+ attr = ippFindAttribute (response, "job-state", IPP_TAG_INTEGER); >+ state = ippGetInteger (attr, 0); >+#else > for (attr = response->attrs; attr != NULL; attr = attr->next) > { > if (!attr->name) >@@ -1489,7 +1516,8 @@ > > _CUPS_MAP_ATTR_INT (attr, state, "job-state"); > } >- >+#endif >+ > done = FALSE; > switch (state) > { >@@ -1613,6 +1641,302 @@ > printer_name = gtk_printer_get_name (printer); > return g_ascii_strcasecmp (printer_name, find_name); > } >+/* Printer messages we're interested in */ >+static const char * const printer_messages[] = >+ { >+ "toner-low", >+ "toner-empty", >+ "developer-low", >+ "developer-empty", >+ "marker-supply-low", >+ "marker-supply-empty", >+ "cover-open", >+ "door-open", >+ "media-low", >+ "media-empty", >+ "offline", >+ "other" >+ }; >+/* Our translatable versions of the printer messages */ >+static const char * printer_strings[] = >+ { >+ N_("Printer '%s' is low on toner."), >+ N_("Printer '%s' has no toner left."), >+ /* Translators: "Developer" like on photo development context */ >+ N_("Printer '%s' is low on developer."), >+ /* Translators: "Developer" like on photo development context */ >+ N_("Printer '%s' is out of developer."), >+ /* Translators: "marker" is one color bin of the printer */ >+ N_("Printer '%s' is low on at least one marker supply."), >+ /* Translators: "marker" is one color bin of the printer */ >+ N_("Printer '%s' is out of at least one marker supply."), >+ N_("The cover is open on printer '%s'."), >+ N_("The door is open on printer '%s'."), >+ N_("Printer '%s' is low on paper."), >+ N_("Printer '%s' is out of paper."), >+ N_("Printer '%s' is currently offline."), >+ N_("There is a problem on printer '%s'.") >+ }; >+ >+typedef enum >+ { >+ GTK_PRINTER_STATE_LEVEL_NONE = 0, >+ GTK_PRINTER_STATE_LEVEL_INFO = 1, >+ GTK_PRINTER_STATE_LEVEL_WARNING = 2, >+ GTK_PRINTER_STATE_LEVEL_ERROR = 3 >+ } PrinterStateLevel; >+ >+typedef struct >+{ >+ const gchar *printer_name; >+ const gchar *printer_uri; >+ const gchar *member_uris; >+ const gchar *location; >+ const gchar *description; >+ const gchar *state_msg; >+ const gchar *reason_msg; >+ PrinterStateLevel reason_level; >+ gint state; >+ gint job_count; >+ gboolean is_paused; >+ gboolean is_accepting_jobs; >+ const gchar *default_cover_before; >+ const gchar *default_cover_after; >+ gboolean default_printer; >+ gboolean got_printer_type; >+ gboolean remote_printer; >+ gchar **auth_info_required; >+} PrinterSetupInfo; >+ >+static void >+cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend, >+ ipp_attribute_t *attr, >+ PrinterSetupInfo *info) >+{ >+ gint i,j; >+ >+ if (strcmp (ippGetName (attr), "printer-name") == 0 && >+ ippGetValueTag (attr) == IPP_TAG_NAME) >+ info->printer_name = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 && >+ ippGetValueTag (attr) == IPP_TAG_URI) >+ info->printer_uri = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "member-uris") == 0 && >+ ippGetValueTag (attr) == IPP_TAG_URI) >+ info->member_uris = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "printer-location") == 0) >+ info->location = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "printer-info") == 0) >+ info->description = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "printer-state-message") == 0) >+ info->state_msg = ippGetString (attr, 0, NULL); >+ else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0) >+ /* Store most important reason to reason_msg and set >+ its importance at printer_state_reason_level */ >+ { >+ for (i = 0; i < ippGetCount (attr); i++) >+ { >+ gboolean interested_in = FALSE; >+ if (strcmp (ippGetString (attr, i, NULL), "none") == 0) >+ continue; >+ /* Sets is_paused flag for paused printer. */ >+ if (strcmp (ippGetString (attr, i, NULL), "paused") == 0) >+ { >+ info->is_paused = TRUE; >+ } >+ >+ for (j = 0; j < G_N_ELEMENTS (printer_messages); j++) >+ if (strncmp (ippGetString (attr, i, NULL), printer_messages[j], strlen (printer_messages[j])) == 0) >+ { >+ interested_in = TRUE; >+ break; >+ } >+ >+ if (!interested_in) >+ continue; >+ if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report")) >+ { >+ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_INFO) >+ { >+ info->reason_msg = ippGetString (attr, i, NULL); >+ info->reason_level = GTK_PRINTER_STATE_LEVEL_INFO; >+ } >+ } >+ else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning")) >+ { >+ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_WARNING) >+ { >+ info->reason_msg = ippGetString (attr, i, NULL); >+ info->reason_level = GTK_PRINTER_STATE_LEVEL_WARNING; >+ } >+ } >+ else /* It is error in the case of no suffix. */ >+ { >+ info->reason_msg = ippGetString (attr, i, NULL); >+ info->reason_level = GTK_PRINTER_STATE_LEVEL_ERROR; >+ } >+ } >+ } >+ else if (strcmp (ippGetName (attr), "printer-state") == 0) >+ info->state = ippGetInteger (attr, 0); >+ else if (strcmp (ippGetName (attr), "queued-job-count") == 0) >+ info->job_count = ippGetInteger (attr, 0); >+ else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0) >+ { >+ if (ippGetBoolean (attr, 0) == 1) >+ info->is_accepting_jobs = TRUE; >+ else >+ info->is_accepting_jobs = FALSE; >+ } >+ else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0) >+ { >+ if (cups_backend->covers == NULL) >+ { >+ cups_backend->number_of_covers = ippGetCount (attr); >+ cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1); >+ for (i = 0; i < cups_backend->number_of_covers; i++) >+ cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL)); >+ cups_backend->covers[cups_backend->number_of_covers] = NULL; >+ } >+ } >+ else if (strcmp (ippGetName (attr), "job-sheets-default") == 0) >+ { >+ if (ippGetCount (attr) == 2) >+ { >+ info->default_cover_before = ippGetString (attr, 0, NULL); >+ info->default_cover_after = ippGetString (attr, 1, NULL); >+ } >+ } >+ else if (strcmp (ippGetName (attr), "printer-type") == 0) >+ { >+ info->got_printer_type = TRUE; >+ if (ippGetInteger (attr, 0) & 0x00020000) >+ info->default_printer = TRUE; >+ else >+ info->default_printer = FALSE; >+ >+ if (ippGetInteger (attr, 0) & 0x00000002) >+ info->remote_printer = TRUE; >+ else >+ info->remote_printer = FALSE; >+ } >+ else if (strcmp (ippGetName (attr), "auth-info-required") == 0) >+ { >+ if (strcmp (ippGetString (attr, 0, NULL), "none") != 0) >+ { >+ info->auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1); >+ for (i = 0; i < ippGetCount (attr); i++) >+ info->auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL)); >+ } >+ } >+ else >+ { >+ GTK_NOTE (PRINTING, >+ g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr))); >+ } >+ >+} >+ >+static GtkPrinter* >+cups_create_printer (GtkPrintBackendCups *cups_backend, >+ PrinterSetupInfo *info) >+{ >+ GtkPrinterCups *cups_printer; >+ GtkPrinter *printer; >+ char uri[HTTP_MAX_URI]; /* Printer URI */ >+ char method[HTTP_MAX_URI]; /* Method/scheme name */ >+ char username[HTTP_MAX_URI]; /* Username:password */ >+ char hostname[HTTP_MAX_URI]; /* Hostname */ >+ char resource[HTTP_MAX_URI]; /* Resource name */ >+ int port; /* Port number */ >+ char *cups_server; /* CUPS server */ >+ GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend); >+ >+#ifdef HAVE_COLORD >+ cups_printer = gtk_printer_cups_new (info->printer_name, >+ backend, >+ cups_backend->colord_client); >+#else >+ cups_printer = gtk_printer_cups_new (info->printer_name, backend, NULL); >+#endif >+ >+ cups_printer->device_uri = g_strdup_printf ("/printers/%s", >+ info->printer_name); >+ >+ /* Check to see if we are looking at a class */ >+ if (info->member_uris) >+ { >+ cups_printer->printer_uri = g_strdup (info->member_uris); >+ /* TODO if member_uris is a class we need to recursivly find a printer */ >+ GTK_NOTE (PRINTING, >+ g_print ("CUPS Backend: Found class with printer %s\n", >+ info->member_uris)); >+ } >+ else >+ { >+ cups_printer->printer_uri = g_strdup (info->printer_uri); >+ GTK_NOTE (PRINTING, >+ g_print ("CUPS Backend: Found printer %s\n", info->printer_uri)); >+ } >+ >+#ifdef HAVE_CUPS_API_1_2 >+ httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri, >+ method, sizeof (method), >+ username, sizeof (username), >+ hostname, sizeof (hostname), >+ &port, >+ resource, sizeof (resource)); >+ >+#else >+ httpSeparate (cups_printer->printer_uri, >+ method, >+ username, >+ hostname, >+ &port, >+ resource); >+#endif >+ >+ if (strncmp (resource, "/printers/", 10) == 0) >+ { >+ cups_printer->ppd_name = g_strdup (resource + 10); >+ GTK_NOTE (PRINTING, >+ g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, info->printer_name)); >+ } >+ >+ gethostname (uri, sizeof (uri)); >+ cups_server = g_strdup (cupsServer()); >+ >+ if (strcasecmp (uri, hostname) == 0) >+ strcpy (hostname, "localhost"); >+ >+ /* if the cups server is local and listening at a unix domain socket >+ * then use the socket connection >+ */ >+ if ((strstr (hostname, "localhost") != NULL) && >+ (cups_server[0] == '/')) >+ strcpy (hostname, cups_server); >+ >+ g_free (cups_server); >+ >+ cups_printer->default_cover_before = g_strdup (info->default_cover_before); >+ cups_printer->default_cover_after = g_strdup (info->default_cover_after); >+ >+ cups_printer->hostname = g_strdup (hostname); >+ cups_printer->port = port; >+ >+ cups_printer->auth_info_required = g_strdupv (info->auth_info_required); >+ g_strfreev (info->auth_info_required); >+ >+ printer = GTK_PRINTER (cups_printer); >+ >+ if (cups_backend->default_printer != NULL && >+ strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0) >+ gtk_printer_set_is_default (printer, TRUE); >+ >+ >+ gtk_print_backend_add_printer (backend, printer); >+ return printer; >+} > > static void > cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend, >@@ -1662,208 +1986,53 @@ > removed_printer_checklist = gtk_print_backend_get_printer_list (backend); > > response = gtk_cups_result_get_response (result); >+#ifdef HAVE_CUPS_API_1_6 >+ for (attr = ippFirstAttribute (response); attr != NULL; >+ attr = ippNextAttribute (response)) >+ { >+ GtkPrinter *printer; >+ gboolean status_changed = FALSE; >+ GList *node; >+ gint i; >+ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo); > >+ /* Skip leading attributes until we hit a printer... >+ */ >+ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER) >+ attr = ippNextAttribute (response); >+ >+ if (attr == NULL) >+ break; >+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER) >+ { >+ cups_printer_handle_attribute (cups_backend, attr, info); >+ attr = ippNextAttribute (response); >+ } >+#else > for (attr = response->attrs; attr != NULL; attr = attr->next) > { > GtkPrinter *printer; >- const gchar *printer_name = NULL; >- const gchar *printer_uri = NULL; >- const gchar *member_uris = NULL; >- const gchar *location = NULL; >- const gchar *description = NULL; >- const gchar *state_msg = NULL; >- gint state = 0; >- gint job_count = 0; > gboolean status_changed = FALSE; > GList *node; >- gint i,j; >- const gchar *reason_msg = NULL; >- gchar *reason_msg_desc = NULL; >- gchar *tmp_msg = NULL; >- gchar *tmp_msg2 = NULL; >- gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */ >- gboolean interested_in = FALSE; >- gboolean found = FALSE; >- static const char * const reasons[] = /* Reasons we're interested in */ >- { >- "toner-low", >- "toner-empty", >- "developer-low", >- "developer-empty", >- "marker-supply-low", >- "marker-supply-empty", >- "cover-open", >- "door-open", >- "media-low", >- "media-empty", >- "offline", >- "other" >- }; >- static const char * reasons_descs[] = >- { >- N_("Printer '%s' is low on toner."), >- N_("Printer '%s' has no toner left."), >- /* Translators: "Developer" like on photo development context */ >- N_("Printer '%s' is low on developer."), >- /* Translators: "Developer" like on photo development context */ >- N_("Printer '%s' is out of developer."), >- /* Translators: "marker" is one color bin of the printer */ >- N_("Printer '%s' is low on at least one marker supply."), >- /* Translators: "marker" is one color bin of the printer */ >- N_("Printer '%s' is out of at least one marker supply."), >- N_("The cover is open on printer '%s'."), >- N_("The door is open on printer '%s'."), >- N_("Printer '%s' is low on paper."), >- N_("Printer '%s' is out of paper."), >- N_("Printer '%s' is currently offline."), >- N_("There is a problem on printer '%s'.") >- }; >- gboolean is_paused = FALSE; >- gboolean is_accepting_jobs = TRUE; >- gboolean default_printer = FALSE; >- gboolean got_printer_type = FALSE; >- gchar *default_cover_before = NULL; >- gchar *default_cover_after = NULL; >- gboolean remote_printer = FALSE; >- gchar **auth_info_required = NULL; >- >+ gint i; >+ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo); >+ > /* Skip leading attributes until we hit a printer... > */ >- while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER) >+ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER) > attr = attr->next; > > if (attr == NULL) > break; >- >- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) >+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER) > { >- if (strcmp (attr->name, "printer-name") == 0 && >- attr->value_tag == IPP_TAG_NAME) >- printer_name = attr->values[0].string.text; >- else if (strcmp (attr->name, "printer-uri-supported") == 0 && >- attr->value_tag == IPP_TAG_URI) >- printer_uri = attr->values[0].string.text; >- else if (strcmp (attr->name, "member-uris") == 0 && >- attr->value_tag == IPP_TAG_URI) >- member_uris = attr->values[0].string.text; >- else if (strcmp (attr->name, "printer-location") == 0) >- location = attr->values[0].string.text; >- else if (strcmp (attr->name, "printer-info") == 0) >- description = attr->values[0].string.text; >- else if (strcmp (attr->name, "printer-state-message") == 0) >- state_msg = attr->values[0].string.text; >- else if (strcmp (attr->name, "printer-state-reasons") == 0) >- /* Store most important reason to reason_msg and set >- its importance at printer_state_reason_level */ >- { >- for (i = 0; i < attr->num_values; i++) >- { >- if (strcmp (attr->values[i].string.text, "none") != 0) >- { >- /* Sets is_paused flag for paused printer. */ >- if (strcmp (attr->values[i].string.text, "paused") == 0) >- { >- is_paused = TRUE; >- } >- >- interested_in = FALSE; >- for (j = 0; j < G_N_ELEMENTS (reasons); j++) >- if (strncmp (attr->values[i].string.text, reasons[j], strlen (reasons[j])) == 0) >- { >- interested_in = TRUE; >- break; >- } >- >- if (interested_in) >- { >- if (g_str_has_suffix (attr->values[i].string.text, "-report")) >- { >- if (printer_state_reason_level <= 1) >- { >- reason_msg = attr->values[i].string.text; >- printer_state_reason_level = 1; >- } >- } >- else if (g_str_has_suffix (attr->values[i].string.text, "-warning")) >- { >- if (printer_state_reason_level <= 2) >- { >- reason_msg = attr->values[i].string.text; >- printer_state_reason_level = 2; >- } >- } >- else /* It is error in the case of no suffix. */ >- { >- reason_msg = attr->values[i].string.text; >- printer_state_reason_level = 3; >- } >- } >- } >- } >- } >- else if (strcmp (attr->name, "printer-state") == 0) >- state = attr->values[0].integer; >- else if (strcmp (attr->name, "queued-job-count") == 0) >- job_count = attr->values[0].integer; >- else if (strcmp (attr->name, "printer-is-accepting-jobs") == 0) >- { >- if (attr->values[0].boolean == 1) >- is_accepting_jobs = TRUE; >- else >- is_accepting_jobs = FALSE; >- } >- else if (strcmp (attr->name, "job-sheets-supported") == 0) >- { >- if (cups_backend->covers == NULL) >- { >- cups_backend->number_of_covers = attr->num_values; >- cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1); >- for (i = 0; i < cups_backend->number_of_covers; i++) >- cups_backend->covers[i] = g_strdup (attr->values[i].string.text); >- cups_backend->covers[cups_backend->number_of_covers] = NULL; >- } >- } >- else if (strcmp (attr->name, "job-sheets-default") == 0) >- { >- if (attr->num_values == 2) >- { >- default_cover_before = attr->values[0].string.text; >- default_cover_after = attr->values[1].string.text; >- } >- } >- else if (strcmp (attr->name, "printer-type") == 0) >- { >- got_printer_type = TRUE; >- if (attr->values[0].integer & 0x00020000) >- default_printer = TRUE; >- else >- default_printer = FALSE; >- >- if (attr->values[0].integer & 0x00000002) >- remote_printer = TRUE; >- else >- remote_printer = FALSE; >- } >- else if (strcmp (attr->name, "auth-info-required") == 0) >- { >- if (strcmp (attr->values[0].string.text, "none") != 0) >- { >- auth_info_required = g_new0 (gchar *, attr->num_values + 1); >- for (i = 0; i < attr->num_values; i++) >- auth_info_required[i] = g_strdup (attr->values[i].string.text); >- } >- } >- else >- { >- GTK_NOTE (PRINTING, >- g_print ("CUPS Backend: Attribute %s ignored", attr->name)); >- } >- >+ cups_printer_handle_attribute (cups_backend, attr, info); > attr = attr->next; > } >+#endif > >- if (printer_name == NULL || >- (printer_uri == NULL && member_uris == NULL)) >+ if (info->printer_name == NULL || >+ (info->printer_uri == NULL && info->member_uris == NULL)) > { > if (attr == NULL) > break; >@@ -1871,19 +2040,19 @@ > continue; > } > >- if (got_printer_type) >+ if (info->got_printer_type) > { >- if (default_printer && !cups_backend->got_default_printer) >+ if (info->default_printer && !cups_backend->got_default_printer) > { >- if (!remote_printer) >+ if (!info->remote_printer) > { > cups_backend->got_default_printer = TRUE; >- cups_backend->default_printer = g_strdup (printer_name); >+ cups_backend->default_printer = g_strdup (info->printer_name); > } > else > { > if (remote_default_printer == NULL) >- remote_default_printer = g_strdup (printer_name); >+ remote_default_printer = g_strdup (info->printer_name); > } > } > } >@@ -1894,111 +2063,25 @@ > } > > /* remove name from checklist if it was found */ >- node = g_list_find_custom (removed_printer_checklist, printer_name, (GCompareFunc) find_printer); >- removed_printer_checklist = g_list_delete_link (removed_printer_checklist, node); >+ node = g_list_find_custom (removed_printer_checklist, >+ info->printer_name, >+ (GCompareFunc) find_printer); >+ removed_printer_checklist = g_list_delete_link (removed_printer_checklist, >+ node); > >- printer = gtk_print_backend_find_printer (backend, printer_name); >+ printer = gtk_print_backend_find_printer (backend, info->printer_name); > if (!printer) >- { >- GtkPrinterCups *cups_printer; >- char uri[HTTP_MAX_URI]; /* Printer URI */ >- char method[HTTP_MAX_URI]; /* Method/scheme name */ >- char username[HTTP_MAX_URI]; /* Username:password */ >- char hostname[HTTP_MAX_URI]; /* Hostname */ >- char resource[HTTP_MAX_URI]; /* Resource name */ >- int port; /* Port number */ >- char *cups_server; /* CUPS server */ >- >- list_has_changed = TRUE; >-#ifdef HAVE_COLORD >- cups_printer = gtk_printer_cups_new (printer_name, >- backend, >- cups_backend->colord_client); >-#else >- cups_printer = gtk_printer_cups_new (printer_name, backend, NULL); >-#endif >- >- cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name); >- >- /* Check to see if we are looking at a class */ >- if (member_uris) >- { >- cups_printer->printer_uri = g_strdup (member_uris); >- /* TODO if member_uris is a class we need to recursivly find a printer */ >- GTK_NOTE (PRINTING, >- g_print ("CUPS Backend: Found class with printer %s\n", member_uris)); >- } >- else >- { >- cups_printer->printer_uri = g_strdup (printer_uri); >- GTK_NOTE (PRINTING, >- g_print ("CUPS Backend: Found printer %s\n", printer_uri)); >- } >- >-#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1 >- httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri, >- method, sizeof (method), >- username, sizeof (username), >- hostname, sizeof (hostname), >- &port, >- resource, sizeof (resource)); >- >-#else >- httpSeparate (cups_printer->printer_uri, >- method, >- username, >- hostname, >- &port, >- resource); >-#endif >- >- if (strncmp (resource, "/printers/", 10) == 0) >- { >- cups_printer->ppd_name = g_strdup (resource + 10); >- GTK_NOTE (PRINTING, >- g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, printer_name)); >- } >- >- gethostname (uri, sizeof (uri)); >- cups_server = g_strdup (cupsServer()); >- >- if (strcasecmp (uri, hostname) == 0) >- strcpy (hostname, "localhost"); >- >- /* if the cups server is local and listening at a unix domain socket >- * then use the socket connection >- */ >- if ((strstr (hostname, "localhost") != NULL) && >- (cups_server[0] == '/')) >- strcpy (hostname, cups_server); >- >- g_free (cups_server); >- >- cups_printer->default_cover_before = g_strdup (default_cover_before); >- cups_printer->default_cover_after = g_strdup (default_cover_after); >- >- cups_printer->hostname = g_strdup (hostname); >- cups_printer->port = port; >- >- cups_printer->auth_info_required = g_strdupv (auth_info_required); >- g_strfreev (auth_info_required); >- >- printer = GTK_PRINTER (cups_printer); >- >- if (cups_backend->default_printer != NULL && >- strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0) >- gtk_printer_set_is_default (printer, TRUE); >- >- >- gtk_print_backend_add_printer (backend, printer); >- } >+ { >+ printer = cups_create_printer (cups_backend, info); >+ list_has_changed = TRUE; >+ } > else > g_object_ref (printer); > >- GTK_PRINTER_CUPS (printer)->remote = remote_printer; >+ GTK_PRINTER_CUPS (printer)->remote = info->remote_printer; > >- gtk_printer_set_is_paused (printer, is_paused); >- gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs); >+ gtk_printer_set_is_paused (printer, info->is_paused); >+ gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs); > > if (!gtk_printer_is_active (printer)) > { >@@ -2021,72 +2104,80 @@ > cups_request_printer_info (cups_backend, gtk_printer_get_name (printer)); > #endif > >- GTK_PRINTER_CUPS (printer)->state = state; >- status_changed = gtk_printer_set_job_count (printer, job_count); >- status_changed |= gtk_printer_set_location (printer, location); >- status_changed |= gtk_printer_set_description (printer, description); >- >- if (state_msg != NULL && strlen (state_msg) == 0) >- { >- if (is_paused && !is_accepting_jobs) >- /* Translators: this is a printer status. */ >+ GTK_PRINTER_CUPS (printer)->state = info->state; >+ status_changed = gtk_printer_set_job_count (printer, info->job_count); >+ status_changed |= gtk_printer_set_location (printer, info->location); >+ status_changed |= gtk_printer_set_description (printer, >+ info->description); >+ >+ if (info->state_msg != NULL && strlen (info->state_msg) == 0) >+ { >+ gchar *tmp_msg2 = NULL; >+ if (info->is_paused && !info->is_accepting_jobs) >+ /* Translators: this is a printer status. */ > tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs")); >- if (is_paused && is_accepting_jobs) >- /* Translators: this is a printer status. */ >+ if (info->is_paused && info->is_accepting_jobs) >+ /* Translators: this is a printer status. */ > tmp_msg2 = g_strdup ( N_("Paused")); >- if (!is_paused && !is_accepting_jobs) >- /* Translators: this is a printer status. */ >+ if (!info->is_paused && !info->is_accepting_jobs) >+ /* Translators: this is a printer status. */ > tmp_msg2 = g_strdup ( N_("Rejecting Jobs")); > > if (tmp_msg2 != NULL) >- state_msg = tmp_msg2; >- } >+ { >+ info->state_msg = tmp_msg2; >+ g_free (tmp_msg2); >+ } >+ } > > /* Set description of the reason and combine it with printer-state-message. */ >- if ( (reason_msg != NULL)) >+ if ( (info->reason_msg != NULL)) > { >- for (i = 0; i < G_N_ELEMENTS (reasons); i++) >+ gchar *reason_msg_desc = NULL; >+ gboolean found = FALSE; >+ >+ for (i = 0; i < G_N_ELEMENTS (printer_messages); i++) > { >- if (strncmp (reason_msg, reasons[i], strlen (reasons[i])) == 0) >+ if (strncmp (info->reason_msg, printer_messages[i], >+ strlen (printer_messages[i])) == 0) > { >- reason_msg_desc = g_strdup_printf (reasons_descs[i], printer_name); >+ reason_msg_desc = g_strdup_printf (printer_strings[i], >+ info->printer_name); > found = TRUE; > break; > } > } > > if (!found) >- printer_state_reason_level = 0; >+ info->reason_level = GTK_PRINTER_STATE_LEVEL_NONE; > >- if (printer_state_reason_level >= 2) >+ if (info->reason_level >= GTK_PRINTER_STATE_LEVEL_WARNING) > { >- if (strlen (state_msg) == 0) >- state_msg = reason_msg_desc; >+ if (strlen (info->state_msg) == 0) >+ info->state_msg = reason_msg_desc; > else > { >- tmp_msg = g_strjoin (" ; ", state_msg, reason_msg_desc, NULL); >- state_msg = tmp_msg; >+ gchar *tmp_msg = NULL; >+ tmp_msg = g_strjoin (" ; ", info->state_msg, >+ reason_msg_desc, NULL); >+ info->state_msg = tmp_msg; >+ g_free (tmp_msg); > } > } >+ if (reason_msg_desc != NULL) >+ g_free (reason_msg_desc); > } > >- status_changed |= gtk_printer_set_state_message (printer, state_msg); >- status_changed |= gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs); >- >- if (tmp_msg != NULL) >- g_free (tmp_msg); >+ status_changed |= gtk_printer_set_state_message (printer, info->state_msg); >+ status_changed |= gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs); > >- if (tmp_msg2 != NULL) >- g_free (tmp_msg2); > >- if (reason_msg_desc != NULL) >- g_free (reason_msg_desc); > > /* Set printer icon according to importance > (none, report, warning, error - report is omitted). */ >- if (printer_state_reason_level == 3) >+ if (info->reason_level == GTK_PRINTER_STATE_LEVEL_ERROR) > gtk_printer_set_icon_name (printer, "printer-error"); >- else if (printer_state_reason_level == 2) >+ else if (info->reason_level == GTK_PRINTER_STATE_LEVEL_WARNING) > gtk_printer_set_icon_name (printer, "printer-warning"); > else if (gtk_printer_is_paused (printer)) > gtk_printer_set_icon_name (printer, "printer-paused"); >@@ -2099,7 +2190,8 @@ > > /* The ref is held by GtkPrintBackend, in add_printer() */ > g_object_unref (printer); >- >+ g_slice_free (PrinterSetupInfo, info); >+ > if (attr == NULL) > break; > } >@@ -2672,7 +2764,7 @@ > response = gtk_cups_result_get_response (result); > > if ((attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME)) != NULL) >- print_backend->default_printer = g_strdup (attr->values[0].string.text); >+ print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL)); > > print_backend->got_default_printer = TRUE; > >Only in gtk+-3.2.4/modules/printbackends/cups: gtkprintbackendcups.c.orig
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 467528
: 346722