epdfview-0.1.8-modern-cups.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. diff -Naur epdfview-0.1.8.orig/src/PrintPter.cxx epdfview-0.1.8/src/PrintPter.cxx
  2. --- epdfview-0.1.8.orig/src/PrintPter.cxx 2011-05-28 11:25:01.000000000 +0100
  3. +++ epdfview-0.1.8/src/PrintPter.cxx 2012-08-22 20:11:46.362436859 +0100
  4. @@ -22,6 +22,40 @@
  5. #include <locale.h>
  6. #include "epdfview.h"
  7. +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
  8. +#define HAVE_CUPS_1_6 1
  9. +#endif
  10. +
  11. +#ifndef HAVE_CUPS_1_6
  12. +inline int ippGetInteger (ipp_attribute_t *attr, int element)
  13. +{
  14. + return (attr->values[element].integer);
  15. +}
  16. +
  17. +inline const char * ippGetString (ipp_attribute_t *attr,
  18. + int element,
  19. + const char **language /*UNUSED*/)
  20. +{
  21. + return (attr->values[element].string.text);
  22. +}
  23. +
  24. +inline int ippSetOperation (ipp_t *ipp, ipp_op_t op)
  25. +{
  26. + if (!ipp)
  27. + return (0);
  28. + ipp->request.op.operation_id = op;
  29. + return (1);
  30. +}
  31. +
  32. +inline int ippSetRequestId (ipp_t *ipp, int request_id)
  33. +{
  34. + if (!ipp)
  35. + return (0);
  36. + ipp->request.any.request_id = request_id;
  37. + return (1);
  38. +}
  39. +#endif
  40. +
  41. using namespace ePDFView;
  42. // Structures
  43. @@ -380,8 +414,8 @@
  44. ipp_t *request = ippNew ();
  45. - request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
  46. - request->request.op.request_id = 1;
  47. + ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES);
  48. + ippSetRequestId(request, 1);
  49. ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
  50. "attributes-charset", NULL, "utf-8");
  51. @@ -403,7 +437,7 @@
  52. ippFindAttribute (answer, "printer-state", IPP_TAG_ZERO);
  53. if ( NULL != state )
  54. {
  55. - switch (state->values[0].integer)
  56. + switch (ippGetInteger (state, 0))
  57. {
  58. case IPP_PRINTER_IDLE:
  59. attributes->state = g_strdup (_("Idle"));
  60. @@ -425,7 +459,7 @@
  61. ippFindAttribute (answer, "printer-location", IPP_TAG_ZERO);
  62. if ( NULL != location )
  63. {
  64. - attributes->location = g_strdup (location->values[0].string.text);
  65. + attributes->location = g_strdup (ippGetString (location, 0, NULL));
  66. }
  67. ippDelete (answer);