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.

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