On 07/08/2017 11:30 PM, Ken Moffat wrote:
On Sat, Jul 08, 2017 at 11:06:47PM +0200, Tim Tassonis wrote:
On 07/08/2017 10:28 PM, Tim Tassonis wrote:
Hi all

It seems that some recent update in blfs (maybe cups) broke printing in
epdfview. Obviously, epdfview is largely unmaintained and therefore it
will be difficult to find any information about it.

I just wonder if anybody else is still using epdfview and has the same
issue, that it stopped listing any printers?

I had a look at the source and it is now clear that the old cups api to list
printers, cupsGetDests() seems to have stopped working. I will investigate
further and provide a patch if the problem can be solved easily.

Cheers
Tim

Hi Tim,

  I don't normally print PDFs, but on my current system (LFS from
12th May, BLFS from 13th, with some updates: yes, I know, it's
getting old!) I can see my print queue if I open a PDF in
epdfview and then use file->Print.

This is with cups-2.2.3.

As always, I build cups very early, so that the gtk toolkits can use
the print queue.  Not sure how recent your build is, nor if you
perhaps changed the order you build things.


Hi Ken

I now fixed the problem: in 2.2.4, cupsGetDests seems to have stopped working and you have to use cupsEnumDests.

I replaced the corresponding code in src/PrintPter.cxx, and now my printers appear again and also print my pdf's.

I attach to this mail a patch that applies _after_ your epdfview-0.1.8-fixes-2.patch, so I did:

patch -Np1 -i /lfs-src/epdfview-0.1.8-fixes-2.patch || exit
patch -Np1 -i /lfs-src/epdfview-0.1.8-cupsgetdests.patch || exit


If you want, I can also generate a merged patch against the original 0.1.8 sources of your fixes-2 and my cups changes, but maybe you want to do this yourself.


Cheers
Tim


--
decentral.ch - IT Stuff
Tim Tassonis
Badenerstrasse 219
8003 Zürich

[email protected]
+41 79 229 36 17
diff -ruN epdfview-0.1.8/src/PrintPter.cxx epdfview-0.1.8-cupsgetdests/src/PrintPter.cxx
--- epdfview-0.1.8/src/PrintPter.cxx	2017-07-08 23:55:43.003752173 +0200
+++ epdfview-0.1.8-cupsgetdests/src/PrintPter.cxx	2017-07-08 23:57:24.655676651 +0200
@@ -474,13 +474,53 @@
     return attributes;
 }
 
+typedef struct
+{
+  int num_dests;
+  cups_dest_t *dests;
+} all_dests_t;
+
+int dest_cb(all_dests_t *user_data, unsigned flags,
+           cups_dest_t *dest)
+{
+  if (flags & CUPS_DEST_FLAGS_REMOVED) {
+   /* * Remove destination from array...  */
+    user_data->num_dests =
+        cupsRemoveDest(dest->name, dest->instance,
+                       user_data->num_dests,
+                       &(user_data->dests));
+  } else {
+   /*
+    * Add destination to array...
+    */
+
+    user_data->num_dests =
+        cupsCopyDest(dest, user_data->num_dests,
+                     &(user_data->dests));
+  }
+
+  return (1);
+}
+
+
 void
 PrintPter::listPrinters (void)
 {
     IPrintView &view = getView ();
 
     cups_dest_t *destinations;
-    int numDestinations = cupsGetDests (&destinations);
+    int numDestinations;
+	all_dests_t user_data = { 0, NULL };
+	if (!cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, CUPS_PRINTER_LOCAL, CUPS_PRINTER_DISCOVERED, (cups_dest_cb_t)dest_cb, &user_data)) {
+		cupsFreeDests(user_data.num_dests, user_data.dests);
+		fprintf(stderr,"cupsEnumDests: Error\n");
+		numDestinations = 0;
+		destinations = NULL;
+	} else {
+		numDestinations = user_data.num_dests;
+		destinations = user_data.dests;
+	}
+	fprintf(stderr,"No printers: %d\n",numDestinations);
     // For now we don't have any printer selected.
     int printerToSelect = -1;
 
-- 
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to