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.

162 lines
4.7 KiB

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