/*
- * "$Id$"
- *
* User-defined destination (and option) support for CUPS.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
* which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*/
*/
#ifdef __APPLE__
-# include <SystemConfiguration/SystemConfiguration.h>
+# if !TARGET_OS_IOS
+# include <SystemConfiguration/SystemConfiguration.h>
+# define _CUPS_LOCATION_DEFAULTS 1
+# endif /* !TARGET_OS_IOS */
# define kCUPSPrintingPrefs CFSTR("org.cups.PrintingPrefs")
# define kDefaultPaperIDKey CFSTR("DefaultPaperID")
# define kLastUsedPrintersKey CFSTR("LastUsedPrinters")
* Local functions...
*/
-#ifdef __APPLE__
+#if _CUPS_LOCATION_DEFAULTS
static CFArrayRef appleCopyLocations(void);
static CFStringRef appleCopyNetwork(void);
-static char *appleGetPaperSize(char *name, int namesize);
+#endif /* _CUPS_LOCATION_DEFAULTS */
+#ifdef __APPLE__
+static char *appleGetPaperSize(char *name, size_t namesize);
+#endif /* __APPLE__ */
+#if _CUPS_LOCATION_DEFAULTS
static CFStringRef appleGetPrinter(CFArrayRef locations,
CFStringRef network, CFIndex *locindex);
-#endif /* __APPLE__ */
+#endif /* _CUPS_LOCATION_DEFAULTS */
static cups_dest_t *cups_add_dest(const char *name, const char *instance,
int *num_dests, cups_dest_t **dests);
#ifdef __BLOCKS__
CFStringRef /* O - Default printer name */
_cupsAppleCopyDefaultPrinter(void)
{
+# if _CUPS_LOCATION_DEFAULTS
CFStringRef network; /* Network location */
CFArrayRef locations; /* Location array */
CFStringRef locprinter; /* Current printer */
CFRelease(locations);
return (locprinter);
+
+# else
+ return (NULL);
+# endif /* _CUPS_LOCATION_DEFAULTS */
}
{
CFPreferencesSetAppValue(kDefaultPaperIDKey, name, kCUPSPrintingPrefs);
CFPreferencesAppSynchronize(kCUPSPrintingPrefs);
+
+# ifdef HAVE_NOTIFY_POST
notify_post("com.apple.printerPrefsChange");
+# endif /* HAVE_NOTIFY_POST */
}
_cupsAppleSetDefaultPrinter(
CFStringRef name) /* I - Default printer/class name */
{
+# if _CUPS_LOCATION_DEFAULTS
CFStringRef network; /* Current network */
CFArrayRef locations; /* Old locations array */
CFIndex locindex; /* Index in locations array */
CFPreferencesSetAppValue(kLastUsedPrintersKey, newlocations,
kCUPSPrintingPrefs);
CFPreferencesAppSynchronize(kCUPSPrintingPrefs);
+
+# ifdef HAVE_NOTIFY_POST
notify_post("com.apple.printerPrefsChange");
+# endif /* HAVE_NOTIFY_POST */
}
if (newlocations)
CFRelease(locations);
CFRelease(network);
+
+# else
+ (void)name;
+# endif /* _CUPS_LOCATION_DEFAULTS */
}
uselast ? kCFBooleanTrue : kCFBooleanFalse,
kCUPSPrintingPrefs);
CFPreferencesAppSynchronize(kCUPSPrintingPrefs);
+
+# ifdef HAVE_NOTIFY_POST
notify_post("com.apple.printerPrefsChange");
+# endif /* HAVE_NOTIFY_POST */
}
#endif /* __APPLE__ */
* to by "cancel" is non-zero, or the callback function (or block) returns 0,
* The caller is responsible for calling httpClose() on the returned object.
*
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
*/
http_t * /* O - Connection to server or @code NULL@ */
http_t *http; /* Connection to server */
+ DEBUG_printf(("cupsConnectDest(dest=%p, flags=0x%x, msec=%d, cancel=%p(%d), resource=\"%s\", resourcesize=" CUPS_LLFMT ", cb=%p, user_data=%p)", (void *)dest, flags, msec, (void *)cancel, cancel ? *cancel : -1, resource, CUPS_LLCAST resourcesize, (void *)cb, user_data));
+
/*
* Range check input...
*/
* Grab the printer URI...
*/
- if ((uri = cupsGetOption("printer-uri-supported", dest->num_options,
- dest->options)) == NULL)
+ if ((uri = cupsGetOption("printer-uri-supported", dest->num_options, dest->options)) == NULL)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOENT), 0);
+ if ((uri = cupsGetOption("resolved-device-uri", dest->num_options, dest->options)) == NULL)
+ {
+ if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL)
+ {
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ if (strstr(uri, "._tcp"))
+ uri = cups_dnssd_resolve(dest, uri, msec, cancel, cb, user_data);
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ }
+ }
- if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR,
- dest);
+ if (uri)
+ uri = _cupsCreateDest(dest->name, cupsGetOption("printer-info", dest->num_options, dest->options), NULL, uri, tempresource, sizeof(tempresource));
- return (NULL);
+ if (uri)
+ {
+ dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &dest->options);
+
+ uri = cupsGetOption("printer-uri-supported", dest->num_options, dest->options);
+ }
}
-#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- if (strstr(uri, "._tcp"))
+ if (!uri)
{
- if ((uri = cups_dnssd_resolve(dest, uri, msec, cancel, cb,
- user_data)) == NULL)
- return (NULL);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOENT), 0);
+
+ if (cb)
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR, dest);
+
+ return (NULL);
}
-#endif /* HAVE_DNSSD || HAVE_AVAHI */
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme),
userpass, sizeof(userpass), hostname, sizeof(hostname),
&port, resource, (int)resourcesize) < HTTP_URI_STATUS_OK)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer URI."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer-uri."), 1);
if (cb)
(*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR,
*/
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING, dest);
snprintf(portstr, sizeof(portstr), "%d", port);
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portstr)) == NULL)
{
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR, dest);
return (NULL);
}
httpAddrFreeList(addrlist);
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CANCELED,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CANCELED, dest);
return (NULL);
}
else
encryption = HTTP_ENCRYPTION_IF_REQUESTED;
- http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, encryption, 1, 0,
- NULL);
+ http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, encryption, 1, 0, NULL);
+ httpAddrFreeList(addrlist);
/*
* Connect if requested...
else
{
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CONNECTING,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CONNECTING, dest);
if (!httpReconnect2(http, msec, cancel) && cb)
{
if (cancel && *cancel)
- (*cb)(user_data,
- CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CONNECTING, dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_CONNECTING, dest);
else
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR, dest);
}
else if (cb)
(*cb)(user_data, CUPS_DEST_FLAGS_NONE, dest);
* to by "cancel" is non-zero, or the callback function (or block) returns 0,
* The caller is responsible for calling httpClose() on the returned object.
*
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
*/
http_t * /* O - Connection to server or @code NULL@ */
* copy) - for use with the cupsEnumDests* functions. The caller is responsible
* for calling cupsFreeDests() on the returned object(s).
*
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
*/
int
}
+/*
+ * '_cupsCreateDest()' - Create a local (temporary) queue.
+ */
+
+char * /* O - Printer URI or @code NULL@ on error */
+_cupsCreateDest(const char *name, /* I - Printer name */
+ const char *info, /* I - Printer description of @code NULL@ */
+ const char *device_id, /* I - 1284 Device ID or @code NULL@ */
+ const char *device_uri, /* I - Device URI */
+ char *uri, /* I - Printer URI buffer */
+ size_t urisize) /* I - Size of URI buffer */
+{
+ http_t *http; /* Connection to server */
+ ipp_t *request, /* CUPS-Create-Local-Printer request */
+ *response; /* CUPS-Create-Local-Printer response */
+ ipp_attribute_t *attr; /* printer-uri-supported attribute */
+ ipp_pstate_t state = IPP_PSTATE_STOPPED;
+ /* printer-state value */
+
+
+ if (!name || !device_uri || !uri || urisize < 32)
+ return (NULL);
+
+ if ((http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL)) == NULL)
+ return (NULL);
+
+ request = ippNewRequest(IPP_OP_CUPS_CREATE_LOCAL_PRINTER);
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "ipp://localhost/");
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, device_uri);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, name);
+ if (info)
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", NULL, info);
+ if (device_id)
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id);
+
+ response = cupsDoRequest(http, request, "/");
+
+ if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL)
+ strlcpy(uri, ippGetString(attr, 0, NULL), urisize);
+ else
+ {
+ ippDelete(response);
+ httpClose(http);
+ return (NULL);
+ }
+
+ if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL)
+ state = (ipp_pstate_t)ippGetInteger(attr, 0);
+
+ while (state == IPP_PSTATE_STOPPED && cupsLastError() == IPP_STATUS_OK)
+ {
+ sleep(1);
+ ippDelete(response);
+
+ request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "printer-state");
+
+ response = cupsDoRequest(http, request, "/");
+
+ if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL)
+ state = (ipp_pstate_t)ippGetInteger(attr, 0);
+ }
+
+ ippDelete(response);
+
+ httpClose(http);
+
+ return (uri);
+}
+
+
/*
* 'cupsEnumDests()' - Enumerate available destinations with a callback function.
*
* Enumeration happens on the current thread and does not return until all
* destinations have been enumerated or the callback function returns 0.
*
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
*/
int /* O - 1 on success, 0 on failure */
*/
num_dests = _cupsGetDests(CUPS_HTTP_DEFAULT, IPP_OP_CUPS_GET_PRINTERS, NULL,
- &dests, type, mask);
+ &dests, type, mask | CUPS_PRINTER_3D);
if ((user_default = _cupsUserDefault(name, sizeof(name))) != NULL)
defprinter = name;
* Enumeration happens on the current thread and does not return until all
* destinations have been enumerated or the block returns 0.
*
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
*/
int /* O - 1 on success, 0 on failure */
userpass, sizeof(userpass), hostname, sizeof(hostname),
&port, resource, (int)resourcesize) < HTTP_URI_STATUS_OK)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer URI."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer-uri."), 1);
return (NULL);
}
}
+/*
+ * 'cupsGetDestWithURI()' - Get a destination associated with a URI.
+ *
+ * "name" is the desired name for the printer. If @code NULL@, a name will be
+ * created using the URI.
+ *
+ * "uri" is the "ipp" or "ipps" URI for the printer.
+ *
+ * @since CUPS 2.0/macOS 10.10@
+ */
+
+cups_dest_t * /* O - Destination or @code NULL@ */
+cupsGetDestWithURI(const char *name, /* I - Desired printer name or @code NULL@ */
+ const char *uri) /* I - URI for the printer */
+{
+ cups_dest_t *dest; /* New destination */
+ char temp[1024], /* Temporary string */
+ scheme[256], /* Scheme from URI */
+ userpass[256], /* Username:password from URI */
+ hostname[256], /* Hostname from URI */
+ resource[1024], /* Resource path from URI */
+ *ptr; /* Pointer into string */
+ int port; /* Port number from URI */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!uri)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (NULL);
+ }
+
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK ||
+ (strncmp(uri, "ipp://", 6) && strncmp(uri, "ipps://", 7)))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer-uri."), 1);
+
+ return (NULL);
+ }
+
+ if (!name)
+ {
+ /*
+ * Create the name from the URI...
+ */
+
+ if (strstr(hostname, "._tcp"))
+ {
+ /*
+ * Use the service instance name...
+ */
+
+ if ((ptr = strchr(hostname, '.')) != NULL)
+ *ptr = '\0';
+
+ name = hostname;
+ }
+ else if (!strncmp(resource, "/classes/", 9))
+ {
+ snprintf(temp, sizeof(temp), "%s @ %s", resource + 9, hostname);
+ name = temp;
+ }
+ else if (!strncmp(resource, "/printers/", 10))
+ {
+ snprintf(temp, sizeof(temp), "%s @ %s", resource + 10, hostname);
+ name = temp;
+ }
+ else
+ {
+ name = hostname;
+ }
+ }
+
+ /*
+ * Create the destination...
+ */
+
+ if ((dest = calloc(1, sizeof(cups_dest_t))) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ return (NULL);
+ }
+
+ dest->name = _cupsStrAlloc(name);
+ dest->num_options = cupsAddOption("device-uri", uri, dest->num_options, &(dest->options));
+ dest->num_options = cupsAddOption("printer-info", name, dest->num_options, &(dest->options));
+
+ return (dest);
+}
+
+
/*
* '_cupsGetDests()' - Get destinations from a server.
*
* Free the memory used by the destination array using the @link cupsFreeDests@
* function.
*
- * Note: On OS X this function also gets the default paper from the system
+ * Note: On macOS this function also gets the default paper from the system
* preferences (~/L/P/org.cups.PrintingPrefs.plist) and includes it in the
* options array for each destination that supports it.
*/
* Use the @link cupsFreeDests@ function to free the destination list and
* the @link cupsGetDest@ function to find a particular destination.
*
- * @since CUPS 1.1.21/OS X 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@
*/
int /* O - Number of destinations */
*/
*dests = (cups_dest_t *)0;
- num_dests = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, dests, 0, 0);
+ num_dests = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, dests, 0, CUPS_PRINTER_3D);
if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
* The returned destination must be freed using @link cupsFreeDests@ with a
* "num_dests" value of 1.
*
- * @since CUPS 1.4/OS X 10.6@
+ * @since CUPS 1.4/macOS 10.6@
*/
cups_dest_t * /* O - Destination or @code NULL@ */
* Get the printer's attributes...
*/
- if (!_cupsGetDests(http, op, name, &dest, 0, 0))
+ if (!_cupsGetDests(http, op, name, &dest, 0, CUPS_PRINTER_3D))
return (NULL);
if (instance)
* @link cupsSetDests@ or @link cupsSetDests2@ functions to save the new
* options for the user.
*
- * @since CUPS 1.3/OS X 10.5@
+ * @since CUPS 1.3/macOS 10.5@
*/
int /* O - New number of destinations */
/*
* 'cupsSetDefaultDest()' - Set the default destination.
*
- * @since CUPS 1.3/OS X 10.5@
+ * @since CUPS 1.3/macOS 10.5@
*/
void
* This function saves the destinations to /etc/cups/lpoptions when run
* as root and ~/.cups/lpoptions when run as a normal user.
*
- * @since CUPS 1.1.21/OS X 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@
*/
int /* O - 0 on success, -1 on error */
* Get the server destinations...
*/
- num_temps = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &temps, 0, 0);
+ num_temps = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &temps, 0, CUPS_PRINTER_3D);
if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
#ifdef HAVE_NOTIFY_POST
/*
- * Send a notification so that MacOS X applications can know about the
+ * Send a notification so that macOS applications can know about the
* change, too.
*/
}
-#ifdef __APPLE__
+#if _CUPS_LOCATION_DEFAULTS
/*
* 'appleCopyLocations()' - Copy the location history array.
*/
return (network);
}
+#endif /* _CUPS_LOCATION_DEFAULTS */
+#ifdef __APPLE__
/*
* 'appleGetPaperSize()' - Get the default paper size.
*/
static char * /* O - Default paper size */
-appleGetPaperSize(char *name, /* I - Paper size name buffer */
- int namesize) /* I - Size of buffer */
+appleGetPaperSize(char *name, /* I - Paper size name buffer */
+ size_t namesize) /* I - Size of buffer */
{
CFStringRef defaultPaperID; /* Default paper ID */
pwg_media_t *pwgmedia; /* PWG media size */
defaultPaperID = _cupsAppleCopyDefaultPaperID();
if (!defaultPaperID ||
CFGetTypeID(defaultPaperID) != CFStringGetTypeID() ||
- !CFStringGetCString(defaultPaperID, name, namesize,
- kCFStringEncodingUTF8))
+ !CFStringGetCString(defaultPaperID, name, (CFIndex)namesize, kCFStringEncodingUTF8))
name[0] = '\0';
else if ((pwgmedia = pwgMediaForLegacy(name)) != NULL)
strlcpy(name, pwgmedia->pwg, namesize);
return (name);
}
+#endif /* __APPLE__ */
+#if _CUPS_LOCATION_DEFAULTS
/*
* 'appleGetPrinter()' - Get a printer from the history array.
*/
return (NULL);
}
-#endif /* __APPLE__ */
+#endif /* _CUPS_LOCATION_DEFAULTS */
/*
/* Enumeration data */
- DEBUG_printf(("5cups_dnssd_browse_cb(sdRef=%p, flags=%x, "
- "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
- "regtype=\"%s\", replyDomain=\"%s\", context=%p)",
- sdRef, flags, interfaceIndex, errorCode, serviceName, regtype,
- replyDomain, context));
+ DEBUG_printf(("5cups_dnssd_browse_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\", context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain, context));
/*
* Don't do anything on error...
_cups_dnssd_device_t *device, /* I - Device */
_cups_dnssd_data_t *data) /* I - Enumeration data */
{
- DEBUG_printf(("5cups_dnssd_free_device(device=%p(%s), data=%p)", device,
- device->dest.name, data));
+ DEBUG_printf(("5cups_dnssd_free_device(device=%p(%s), data=%p)", (void *)device, device->dest.name, (void *)data));
# ifdef HAVE_DNSSD
if (device->ref)
/* Full name for query */
- DEBUG_printf(("5cups_dnssd_get_device(data=%p, serviceName=\"%s\", "
- "regtype=\"%s\", replyDomain=\"%s\")", data, serviceName,
- regtype, replyDomain));
+ DEBUG_printf(("5cups_dnssd_get_device(data=%p, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\")", (void *)data, serviceName, regtype, replyDomain));
/*
* See if this is an existing device...
_cups_dnssd_device_t *device; /* Device */
- DEBUG_printf(("5cups_dnssd_local_cb(sdRef=%p, flags=%x, "
- "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
- "regtype=\"%s\", replyDomain=\"%s\", context=%p)",
- sdRef, flags, interfaceIndex, errorCode, serviceName,
- regtype, replyDomain, context));
+ DEBUG_printf(("5cups_dnssd_local_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\", context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain, context));
/*
* Only process "add" data...
# ifdef HAVE_DNSSD
- DEBUG_printf(("5cups_dnssd_query_cb(sdRef=%p, flags=%x, "
- "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
- "rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, "
- "context=%p)", sdRef, flags, interfaceIndex, errorCode,
- fullName, rrtype, rrclass, rdlen, rdata, ttl, context));
+ DEBUG_printf(("5cups_dnssd_query_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, fullName=\"%s\", rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context));
/*
* Only process "add" data...
*/
const char *start, *next; /* Pointer into value */
- int have_pdf = 0; /* Have PDF? */
+ int have_pdf = 0, /* Have PDF? */
+ have_raster = 0;/* Have raster format support? */
for (start = value; start && *start; start = next)
{
- if (!_cups_strncasecmp(start, "application/pdf", 15) &&
- (!start[15] || start[15] == ','))
+ if (!_cups_strncasecmp(start, "application/pdf", 15) && (!start[15] || start[15] == ','))
{
have_pdf = 1;
break;
}
+ else if ((!_cups_strncasecmp(start, "image/pwg-raster", 16) && (!start[16] || start[16] == ',')) ||
+ (!_cups_strncasecmp(start, "image/urf", 9) && (!start[9] || start[9] == ',')))
+ {
+ have_raster = 1;
+ break;
+ }
if ((next = strchr(start, ',')) != NULL)
next ++;
}
- if (!have_pdf)
+ if (!have_pdf && !have_raster)
device->state = _CUPS_DNSSD_INCOMPATIBLE;
}
else if (!_cups_strcasecmp(key, "printer-type"))
* Save the printer-xxx values...
*/
- device->dest.num_options = cupsAddOption("printer-info", name,
- device->dest.num_options,
- &device->dest.options);
+ device->dest.num_options = cupsAddOption("printer-info", name, device->dest.num_options, &device->dest.options);
if (make_and_model[0])
{
strlcat(make_and_model, " ", sizeof(make_and_model));
strlcat(make_and_model, model, sizeof(make_and_model));
- device->dest.num_options = cupsAddOption("printer-make-and-model",
- make_and_model,
- device->dest.num_options,
- &device->dest.options);
+ device->dest.num_options = cupsAddOption("printer-make-and-model", make_and_model, device->dest.num_options, &device->dest.options);
}
else
- device->dest.num_options = cupsAddOption("printer-make-and-model",
- model,
- device->dest.num_options,
- &device->dest.options);
+ device->dest.num_options = cupsAddOption("printer-make-and-model", model, device->dest.num_options, &device->dest.options);
device->type = type;
snprintf(value, sizeof(value), "%u", type);
- device->dest.num_options = cupsAddOption("printer-type", value,
- device->dest.num_options,
- &device->dest.options);
+ device->dest.num_options = cupsAddOption("printer-type", value, device->dest.num_options, &device->dest.options);
/*
* Save the URI...
!strcmp(device->regtype, "_ipps._tcp") ? "ipps" : "ipp",
NULL, uriname, 0, saw_printer_type ? "/cups" : "/");
- DEBUG_printf(("6cups_dnssd_query: printer-uri-supported=\"%s\"", uri));
+ DEBUG_printf(("6cups_dnssd_query: device-uri=\"%s\"", uri));
- device->dest.num_options = cupsAddOption("printer-uri-supported", uri,
- device->dest.num_options,
- &device->dest.options);
+ device->dest.num_options = cupsAddOption("device-uri", uri, device->dest.num_options, &device->dest.options);
}
else
DEBUG_printf(("6cups_dnssd_query: Ignoring TXT record for '%s'.",
resolve.end_time.tv_sec += 75;
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING, dest);
- if ((uri = _httpResolveURI(uri, tempuri, sizeof(tempuri),
- _HTTP_RESOLVE_FQDN, cups_dnssd_resolve_cb,
- &resolve)) == NULL)
+ if ((uri = _httpResolveURI(uri, tempuri, sizeof(tempuri), _HTTP_RESOLVE_DEFAULT, cups_dnssd_resolve_cb, &resolve)) == NULL)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to resolve printer URI."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to resolve printer-uri."), 1);
if (cb)
- (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR,
- dest);
+ (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_ERROR, dest);
return (NULL);
}
* Save the resolved URI...
*/
- dest->num_options = cupsAddOption("printer-uri-supported", uri,
- dest->num_options, &dest->options);
+ dest->num_options = cupsAddOption("resolved-device-uri", uri, dest->num_options, &dest->options);
- return (cupsGetOption("printer-uri-supported", dest->num_options,
- dest->options));
+ return (cupsGetOption("resolved-device-uri", dest->num_options, dest->options));
}
* If the cancel variable is set, return immediately.
*/
- if (*resolve->cancel)
+ if (resolve->cancel && *(resolve->cancel))
+ {
+ DEBUG_puts("4cups_dnssd_resolve_cb: Canceled.");
return (0);
+ }
/*
* Otherwise check the end time...
gettimeofday(&curtime, NULL);
- return (curtime.tv_sec > resolve->end_time.tv_sec ||
+ DEBUG_printf(("4cups_dnssd_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, (int)curtime.tv_usec, (int)resolve->end_time.tv_sec, (int)resolve->end_time.tv_usec));
+
+ return (curtime.tv_sec < resolve->end_time.tv_sec ||
(curtime.tv_sec == resolve->end_time.tv_sec &&
- curtime.tv_usec > resolve->end_time.tv_usec));
+ curtime.tv_usec < resolve->end_time.tv_usec));
}
int linenum; /* Current line number */
- DEBUG_printf(("7cups_get_dests(filename=\"%s\", match_name=\"%s\", "
- "match_inst=\"%s\", user_default_set=%d, num_dests=%d, "
- "dests=%p)", filename, match_name, match_inst,
- user_default_set, num_dests, dests));
+ DEBUG_printf(("7cups_get_dests(filename=\"%s\", match_name=\"%s\", match_inst=\"%s\", user_default_set=%d, num_dests=%d, dests=%p)", filename, match_name, match_inst, user_default_set, num_dests, (void *)dests));
/*
* Try to open the file...
return (buffer);
}
-
-
-/*
- * End of "$Id$".
- */