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.

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