Ticket #9464: epdfview-0.1.8-cupsgetdests.patch

File epdfview-0.1.8-cupsgetdests.patch, 1.7 KB (added by Tim Tassonis, 7 years ago)

Patch to appy after applying the fixes-2 patch

  • src/PrintPter.cxx

    diff -ruN epdfview-0.1.8/src/PrintPter.cxx epdfview-0.1.8-cupsgetdests/src/PrintPter.cxx
    old new  
    474474    return attributes;
    475475}
    476476
     477typedef struct
     478{
     479  int num_dests;
     480  cups_dest_t *dests;
     481} all_dests_t;
     482
     483int dest_cb(all_dests_t *user_data, unsigned flags,
     484           cups_dest_t *dest)
     485{
     486  if (flags & CUPS_DEST_FLAGS_REMOVED) {
     487   /* * Remove destination from array...  */
     488    user_data->num_dests =
     489        cupsRemoveDest(dest->name, dest->instance,
     490                       user_data->num_dests,
     491                       &(user_data->dests));
     492  } else {
     493   /*
     494    * Add destination to array...
     495    */
     496
     497    user_data->num_dests =
     498        cupsCopyDest(dest, user_data->num_dests,
     499                     &(user_data->dests));
     500  }
     501
     502  return (1);
     503}
     504
     505
    477506void
    478507PrintPter::listPrinters (void)
    479508{
    480509    IPrintView &view = getView ();
    481510
    482511    cups_dest_t *destinations;
    483     int numDestinations = cupsGetDests (&destinations);
     512    int numDestinations;
     513        all_dests_t user_data = { 0, NULL };
     514        if (!cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, CUPS_PRINTER_LOCAL, CUPS_PRINTER_DISCOVERED, (cups_dest_cb_t)dest_cb, &user_data)) {
     515                cupsFreeDests(user_data.num_dests, user_data.dests);
     516                fprintf(stderr,"cupsEnumDests: Error\n");
     517                numDestinations = 0;
     518                destinations = NULL;
     519        } else {
     520                numDestinations = user_data.num_dests;
     521                destinations = user_data.dests;
     522        }
     523        fprintf(stderr,"No printers: %d\n",numDestinations);
    484524    // For now we don't have any printer selected.
    485525    int printerToSelect = -1;
    486526