You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
4.7 KiB

  1. --- a/scan/sane/hpaio.c
  2. +++ b/scan/sane/hpaio.c
  3. @@ -34,7 +34,6 @@
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. -#include <cups/cups.h>
  8. #include "hpmud.h"
  9. #include "hpip.h"
  10. #include "hp_ipp.h"
  11. @@ -144,98 +143,6 @@ static int GetUriLine(char *buf, char *u
  12. return i;
  13. }
  14. -static int AddCupsList(char *uri, char ***printer)
  15. -{
  16. - int i, stat=1;
  17. -
  18. - /* Look for hp network URIs only. */
  19. - if (strncasecmp(uri, "hp:/net/", 8) !=0)
  20. - goto bugout;
  21. -
  22. - if (*printer == NULL)
  23. - {
  24. - /* Allocate array of string pointers. */
  25. - *printer = malloc(sizeof(char *) * MAX_DEVICE);
  26. - memset(*printer, 0, sizeof(char *) * MAX_DEVICE);
  27. - }
  28. -
  29. - /* Ignor duplicates (ie: printer queues using the same device). */
  30. - for (i=0; (*printer)[i] != NULL && i<MAX_DEVICE; i++)
  31. - {
  32. - if (strcmp((*printer)[i], uri) == 0)
  33. - goto bugout;
  34. - }
  35. -
  36. - /* Find empty slot in array of pointers. */
  37. - for (i=0; i<MAX_DEVICE; i++)
  38. - {
  39. - if ((*printer)[i] == NULL)
  40. - {
  41. - (*printer)[i] = strdup(uri);
  42. - break;
  43. - }
  44. - }
  45. -
  46. - stat = 0;
  47. -
  48. -bugout:
  49. -
  50. - return stat;
  51. -}
  52. -
  53. -
  54. -static int GetCupsPrinters(char ***printer)
  55. -{
  56. - http_t *http=NULL; /* HTTP object */
  57. - ipp_t *request=NULL; /* IPP request object */
  58. - ipp_t *response=NULL; /* IPP response object */
  59. - ipp_attribute_t *attr; /* Current IPP attribute */
  60. - int cnt=0;
  61. -
  62. - /* Connect to the HTTP server */
  63. - if ((http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption())) == NULL)
  64. - goto bugout;
  65. -
  66. - /* Assemble the IPP request */
  67. - request = ippNew();
  68. -
  69. - ippSetOperation( request, CUPS_GET_PRINTERS );
  70. - ippSetRequestId( request, 1 );
  71. -
  72. - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8");
  73. - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en");
  74. - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "device-uri");
  75. -
  76. - /* Send the request and get a response. */
  77. - if ((response = cupsDoRequest(http, request, "/")) == NULL)
  78. - goto bugout;
  79. -
  80. - for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response ))
  81. - {
  82. - /* Skip leading attributes until we hit a printer. */
  83. - while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER)
  84. - attr = ippNextAttribute( response );
  85. -
  86. - if (attr == NULL)
  87. - break;
  88. -
  89. - while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER)
  90. - {
  91. - if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0)
  92. - cnt++;
  93. - attr = ippNextAttribute( response );
  94. - }
  95. -
  96. - if (attr == NULL)
  97. - break;
  98. - }
  99. -
  100. - ippDelete(response);
  101. -
  102. - bugout:
  103. - return cnt;
  104. -}
  105. -
  106. static int AddDevice(char *uri)
  107. {
  108. struct hpmud_model_attributes ma;
  109. @@ -264,7 +171,6 @@ static int DevDiscovery(int localOnly)
  110. char uri[HPMUD_LINE_SIZE];
  111. char *tail = message;
  112. int i, scan_type, cnt=0, total=0, bytes_read;
  113. - char **cups_printer=NULL; /* list of printers */
  114. char* token = NULL;
  115. enum HPMUD_RESULT stat;
  116. @@ -279,34 +185,6 @@ static int DevDiscovery(int localOnly)
  117. total += AddDevice(uri);
  118. }
  119. - /* Look for Network Scan devices if localonly flag if FALSE. */
  120. - if (!localOnly)
  121. - {
  122. - /* Look for all-in-one scan devices for which print queue created */
  123. - cnt = GetCupsPrinters(&cups_printer);
  124. - for (i=0; i<cnt; i++)
  125. - {
  126. - total += AddDevice(cups_printer[i]);
  127. - free(cups_printer[i]);
  128. - }
  129. - if (cups_printer)
  130. - free(cups_printer);
  131. -#ifdef HAVE_LIBNETSNMP
  132. - /* Discover NW scanners using Bonjour*/
  133. - bytes_read = mdns_probe_nw_scanners(message, sizeof(message), &cnt);
  134. - token = strtok(message, ";");
  135. - while (token)
  136. - {
  137. - total += AddDevice(token);
  138. - token = strtok(NULL, ";");
  139. - }
  140. -#endif
  141. - if(!total)
  142. - {
  143. - SendScanEvent("hpaio:/net/HP_Scan_Devices?ip=1.1.1.1", EVENT_ERROR_NO_PROBED_DEVICES_FOUND);
  144. - }
  145. - }
  146. -
  147. bugout:
  148. return total;
  149. }
  150. --- a/Makefile.am
  151. +++ b/Makefile.am
  152. @@ -67,7 +67,7 @@ else
  153. libsane_hpaio_la_LDFLAGS = -version-info 1:0:0
  154. endif
  155. # The following is a interlibrary dependency that must be compiled first.
  156. -libsane_hpaio_la_LIBADD = libhpip.la libhpmud.la libhpipp.la $(DBUS_LIBS) -lcups -ldl
  157. +libsane_hpaio_la_LIBADD = libhpip.la libhpmud.la libhpipp.la $(DBUS_LIBS) -ldl
  158. #libsane_hpaio_la_CFLAGS = -DWITH_NONAMESPACES -DSOAP_DEBUG
  159. libsane_hpaio_la_CFLAGS = $(DBUS_CFLAGS) -Iprotocol