-CHANGES.txt - 2.0b1 - 2013-10-18
+CHANGES.txt - 2.0b1 - 2013-11-06
--------------------------------
CHANGES IN CUPS V2.0b1
+ - Dropped "dark wake" support on OS X, which was preventing portables
+ from going to sleep when there was a stuck job. We now use a variation
+ of the CUPS 1.4 sleep support to do a cleaner sleep
+ (<rdar://problem/14323704>)
- Added support for regular expression matching in the MIME type rules
(<rdar://problem/11131245>)
- Dropped support for AIX, HP-UX, and OSF/1 (aka Digital UNIX)
if (!job_id || !waitjob || !get_job_attrs)
continue;
+ fputs("STATE: +cups-waiting-for-completed\n", stderr);
+
_cupsLangPrintFilter(stderr, "INFO", _("Waiting for job to complete."));
for (delay = _cupsNextDelay(0, &prev_delay); !job_canceled;)
/*
* "$Id$"
*
- * Line Printer Daemon backend for CUPS.
+ * Line Printer Daemon backend for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * 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"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * 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"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Send a file to the printer or server.
- * lpd_command() - Send an LPR command sequence and wait for a reply.
- * lpd_queue() - Queue a file using the Line Printer Daemon protocol.
- * lpd_write() - Write a buffer of data to an LPD server.
- * rresvport_af() - A simple implementation of rresvport_af().
- * sigterm_handler() - Handle 'terminate' signals that stop the backend.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
_("Control file sent successfully."));
}
+ fputs("STATE: +cups-waiting-for-completed\n", stderr);
+
/*
* Collect the final supply levels as needed...
*/
/*
* "$Id$"
*
- * AppSocket backend for CUPS.
+ * AppSocket backend for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * 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"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * 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"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Send a file to the printer or server.
- * wait_bc() - Wait for back-channel data...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
_cupsLangPrintFilter(stderr, "INFO", _("Print file sent."));
}
+ fputs("STATE: +cups-waiting-for-completed\n", stderr);
+
if (waiteof)
{
/*
/*
-* "$Id$"
-*
-* Copyright 2005-2013 Apple Inc. All rights reserved.
-*
-* IMPORTANT: This Apple software is supplied to you by Apple Computer,
-* Inc. ("Apple") in consideration of your agreement to the following
-* terms, and your use, installation, modification or redistribution of
-* this Apple software constitutes acceptance of these terms. If you do
-* not agree with these terms, please do not use, install, modify or
-* redistribute this Apple software.
-*
-* In consideration of your agreement to abide by the following terms, and
-* subject to these terms, Apple grants you a personal, non-exclusive
-* license, under Apple's copyrights in this original Apple software (the
-* "Apple Software"), to use, reproduce, modify and redistribute the Apple
-* Software, with or without modifications, in source and/or binary forms;
-* provided that if you redistribute the Apple Software in its entirety and
-* without modifications, you must retain this notice and the following
-* text and disclaimers in all such redistributions of the Apple Software.
-* Neither the name, trademarks, service marks or logos of Apple Computer,
-* Inc. may be used to endorse or promote products derived from the Apple
-* Software without specific prior written permission from Apple. Except
-* as expressly stated in this notice, no other rights or licenses, express
-* or implied, are granted by Apple herein, including but not limited to
-* any patent rights that may be infringed by your derivative works or by
-* other works in which the Apple Software may be incorporated.
-*
-* The Apple Software is provided by Apple on an "AS IS" basis. APPLE
-* MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
-* THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
-* FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
-* OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-*
-* IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
-* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
-* MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
-* AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
-* STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-* Contents:
-*
- * list_devices() - List all USB devices.
- * print_device() - Print a file to a USB device.
- * read_thread() - Thread to read the backchannel data on.
- * sidechannel_thread() - Handle side-channel requests.
- * iterate_printers() - Iterate over all the printers.
- * device_added() - Device added notifier.
- * list_device_cb() - list_device iterator callback.
- * find_device_cb() - print_device iterator callback.
- * status_timer_cb() - Status timer callback.
- * copy_deviceinfo() - Copy strings from the 1284 device ID.
- * release_deviceinfo() - Release deviceinfo strings.
- * load_classdriver() - Load a classdriver.
- * unload_classdriver() - Unload a classdriver.
- * load_printerdriver() - Load vendor's classdriver.
- * registry_open() - Open a connection to the printer.
- * registry_close() - Close the connection to the printer.
- * copy_deviceid() - Copy the 1284 device id string.
- * copy_devicestring() - Copy the 1284 device id string.
- * copy_value_for_key() - Copy value string associated with a key.
- * cfstr_create_trim() - Create CFString and trim whitespace characters.
- * parse_options() - Parse URI options.
- * sigterm_handler() - SIGTERM handler.
- * next_line() - Find the next line in a buffer.
- * parse_pserror() - Scan the backchannel data for postscript errors.
- * soft_reset() - Send a soft reset to the device.
- * get_device_id() - Return IEEE-1284 device ID.
-*/
+ * "$Id$"
+ *
+ * Copyright 2005-2013 Apple Inc. All rights reserved.
+ *
+ * IMPORTANT: This Apple software is supplied to you by Apple Computer,
+ * Inc. ("Apple") in consideration of your agreement to the following
+ * terms, and your use, installation, modification or redistribution of
+ * this Apple software constitutes acceptance of these terms. If you do
+ * not agree with these terms, please do not use, install, modify or
+ * redistribute this Apple software.
+ *
+ * In consideration of your agreement to abide by the following terms, and
+ * subject to these terms, Apple grants you a personal, non-exclusive
+ * license, under Apple's copyrights in this original Apple software (the
+ * "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ * Software, with or without modifications, in source and/or binary forms;
+ * provided that if you redistribute the Apple Software in its entirety and
+ * without modifications, you must retain this notice and the following
+ * text and disclaimers in all such redistributions of the Apple Software.
+ * Neither the name, trademarks, service marks or logos of Apple Computer,
+ * Inc. may be used to endorse or promote products derived from the Apple
+ * Software without specific prior written permission from Apple. Except
+ * as expressly stated in this notice, no other rights or licenses, express
+ * or implied, are granted by Apple herein, including but not limited to
+ * any patent rights that may be infringed by your derivative works or by
+ * other works in which the Apple Software may be incorporated.
+ *
+ * The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ * THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ * OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ *
+ * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ * MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ * AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ * STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/*
* Include necessary headers.
}
fprintf(stderr, "DEBUG: Sent %lld bytes...\n", (off_t)total_bytes);
+ fputs("STATE: +cups-waiting-for-completed\n", stderr);
/*
* Signal the side channel thread to exit...
CFStringRef deviceMake = NULL;
CFStringRef deviceModel = NULL;
CFStringRef deviceSerial = NULL;
-
+
*deviceID = NULL;
OSStatus err = (*classdriver)->GetDeviceID(classdriver, &devID, DEFAULT_TIMEOUT);
CFRange range = (deviceSerial != NULL ? CFStringFind(deviceSerial, CFSTR("+"), 0) : CFRangeMake(0, 0));
if (range.length == 1) {
range = CFStringFind(*deviceID, deviceSerial, 0);
-
+
CFMutableStringRef deviceIDString = CFStringCreateMutableCopy(NULL, 0, *deviceID);
CFStringFindAndReplace(deviceIDString, CFSTR("+"), CFSTR(""), range, 0);
CFRelease(*deviceID);
*deviceID = deviceIDString;
}
-
+
release_deviceinfo(&deviceMake, &deviceModel, &deviceSerial);
return err;
AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
- AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
dnl Check for dynamic store function...
AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
#undef HAVE_NOTIFY_POST
-/*
- * Do we have Darwin's IOKit private headers?
- */
-
-#undef HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H
-
-
/*
* Do we have DBUS?
*/
if (job->kill_time && job->kill_time <= curtime)
{
- cupsdLogJob(job, CUPSD_LOG_ERROR, "Stopping unresponsive job.");
+ if (!job->completed)
+ cupsdLogJob(job, CUPSD_LOG_ERROR, "Stopping unresponsive job.");
stop_job(job, CUPSD_JOB_FORCE);
continue;
if (job->cancel_time && job->cancel_time <= curtime)
{
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
- "Canceling stuck job after %d seconds.", MaxJobTime);
+ if (job->completed)
+ cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_FORCE,
+ "Marking stuck job as completed after %d seconds.", MaxJobTime);
+ else
+ cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
+ "Canceling stuck job after %d seconds.", MaxJobTime);
continue;
}
*/
if (job->state_value == IPP_JOB_PENDING && !NeedReload &&
-#ifndef kIOPMAssertionTypeDenySystemSleep
- !Sleeping &&
-#endif /* !kIOPMAssertionTypeDenySystemSleep */
- !DoingShutdown && !job->printer)
+ !Sleeping && !DoingShutdown && !job->printer)
{
printer = cupsdFindDest(job->dest);
pclass = NULL;
job;
job = (cupsd_job_t *)cupsArrayNext(PrintingJobs))
{
- if (kill_delay)
- job->kill_time = time(NULL) + kill_delay;
+ if (job->completed)
+ {
+ cupsdSetJobState(job, IPP_JOB_COMPLETED, CUPSD_JOB_FORCE, NULL);
+ }
+ else
+ {
+ if (kill_delay)
+ job->kill_time = time(NULL) + kill_delay;
- cupsdSetJobState(job, IPP_JOB_PENDING, action, NULL);
+ cupsdSetJobState(job, IPP_JOB_PENDING, action, NULL);
+ }
}
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "finalize_job(job=%p(%d))", job, job->id);
/*
- * Clear the "connecting-to-device" reason, which is only valid when a printer
- * is processing, along with any remote printing job state...
+ * Clear the "connecting-to-device" and "cups-waiting-for-completed" reasons,
+ * which are only valid when a printer is processing, along with any remote
+ * printing job state...
*/
cupsdSetPrinterReasons(job->printer, "-connecting-to-device,"
+ "cups-waiting-for-completed,"
"cups-remote-pending,"
"cups-remote-pending-held,"
"cups-remote-processing,"
* Reset cancel time after connecting to the device...
*/
- ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs,
- "job-cancel-after",
- IPP_TAG_INTEGER);
- /* job-cancel-after attribute */
-
for (i = 0; i < job->printer->num_reasons; i ++)
if (!strcmp(job->printer->reasons[i], "connecting-to-device"))
break;
if (i >= job->printer->num_reasons)
{
+ ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs,
+ "job-cancel-after",
+ IPP_TAG_INTEGER);
+ /* job-cancel-after attribute */
+
if (cancel_after)
job->cancel_time = time(NULL) + ippGetInteger(cancel_after, 0);
else
/*
* "$Id$"
*
- * Print job definitions for the CUPS scheduler.
+ * Print job definitions for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * 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/".
+ * 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/".
*/
/*
int backend; /* Backend process ID */
int status; /* Status code from filters */
int tries; /* Number of tries for this job */
+ int completed; /* cups-waiting-for-completed seen */
char *auth_env[3], /* AUTH_xxx environment variables,
* if any */
*auth_uid; /* AUTH_UID environment variable */
/*
* "$Id$"
*
- * Main loop for the CUPS scheduler.
+ * Main loop for the CUPS scheduler.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * 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"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for the CUPS scheduler.
- * cupsdAddString() - Copy and add a string to an array.
- * cupsdCheckProcess() - Tell the main loop to check for dead children.
- * cupsdClearString() - Clear a string.
- * cupsdFreeStrings() - Free an array of strings.
- * cupsdHoldSignals() - Hold child and termination signals.
- * cupsdReleaseSignals() - Release signals for delivery.
- * cupsdSetString() - Set a string value.
- * cupsdSetStringf() - Set a formatted string value.
- * launchd_checkin() - Check-in with launchd and collect the listening
- * fds.
- * launchd_checkout() - Update the launchd KeepAlive file as needed.
- * parent_handler() - Catch USR1/CHLD signals...
- * process_children() - Process all dead children...
- * select_timeout() - Calculate the select timeout value.
- * sigchld_handler() - Handle 'child' signals from old processes.
- * sighup_handler() - Handle 'hangup' signals to reconfigure the
- * scheduler.
- * sigterm_handler() - Handle 'terminate' signals that stop the scheduler.
- * usage() - Show scheduler usage.
+ * 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"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
+ if (!strcmp(reason, "cups-waiting-for-completed") && p->job)
+ p->job->completed = 0;
+
if (strcmp(reason, "connecting-to-device"))
dirty_printer(p);
+
break;
}
}
if (!strcmp(reason, "paused") && p->state != IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, 1);
+ if (!strcmp(reason, "cups-waiting-for-completed") && p->job)
+ p->job->completed = 1;
+
if (strcmp(reason, "connecting-to-device"))
dirty_printer(p);
}
/*
* "$Id$"
*
- * System management functions for the CUPS scheduler.
+ * System management functions for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 2006 by Easy Software Products.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2006 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/".
- *
- * Contents:
- *
- * cupsdCleanDirty() - Write dirty config and state files.
- * cupsdMarkDirty() - Mark config or state files as needing a
- * write.
- * cupsdSetBusyState() - Let the system know when we are busy
- * doing something.
- * cupsdAllowSleep() - Tell the OS it is now OK to sleep.
- * cupsdStartSystemMonitor() - Start monitoring for system change.
- * cupsdStopSystemMonitor() - Stop monitoring for system change.
- * sysEventThreadEntry() - A thread to receive power and computer
- * name change notifications.
- * sysEventPowerNotifier() - Handle power notification events.
- * sysEventConfigurationNotifier() - Computer name changed notification
- * callback.
- * sysEventTimerNotifier() - Handle delayed event notifications.
- * sysUpdate() - Update the current system state.
+ * 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/".
*/
#endif /* HAVE_VPROC_TRANSACTION_BEGIN */
#ifdef __APPLE__
# include <IOKit/pwr_mgt/IOPMLib.h>
-# ifdef HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H
-# include <IOKit/pwr_mgt/IOPMLibPrivate.h>
-# else
-# define kIOPMAssertionTypeDenySystemSleep CFSTR("DenySystemSleep")
-# endif /* HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */
#endif /* __APPLE__ */
* and state files to minimize the number of times the disk has to spin
* up.
*
- * Power management support is currently only implemented on MacOS X, but
+ * Power management support is currently only implemented on OS X, but
* essentially we use four functions to let the OS know when it is OK to
* put the system to sleep, typically when we are not in the middle of
* printing a job.
* to wake up in a new location/on a new wireless network.
*/
-/*
- * Local globals...
- */
-
-#if defined(kIOPMAssertionTypeDenySystemSleep) || defined(kIOPMAssertNetworkClientActive)
-static IOPMAssertionID keep_awake = 0; /* Keep the system awake while printing */
-#endif /* kIOPMAssertionTypeDenySystemSleep || kIOPMAssertNetworkClientActive */
-
-
/*
* 'cupsdCleanDirty()' - Write dirty config and state files.
*/
}
#endif /* HAVE_VPROC_TRANSACTION_BEGIN */
}
-
-#if defined(kIOPMAssertionTypeDenySystemSleep) || defined(kIOPMAssertNetworkClientActive)
- if (cupsArrayCount(PrintingJobs) > 0 && !keep_awake)
- {
-# ifdef kIOPMAssertNetworkClientActive
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Asserting NetworkClientActive.");
-
- IOPMAssertionCreateWithName(kIOPMAssertNetworkClientActive,
- kIOPMAssertionLevelOn,
- CFSTR("org.cups.cupsd"), &keep_awake);
-
-# else
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Asserting DenySystemSleep.");
-
- IOPMAssertionCreateWithName(kIOPMAssertionTypeDenySystemSleep,
- kIOPMAssertionLevelOn,
- CFSTR("org.cups.cupsd"), &keep_awake);
-
-# endif /* kIOPMAssertNetworkClientActive */
- }
- else if (cupsArrayCount(PrintingJobs) == 0 && keep_awake)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Releasing power assertion.");
- IOPMAssertionRelease(keep_awake);
- keep_awake = 0;
- }
-#endif /* kIOPMAssertionTypeDenySystemSleep || kIOPMAssertNetworkClientActive */
}
NetworkInterfaceKeyIPv6 = NULL;
/* Netowrk interface key */
static cupsd_sysevent_t LastSysEvent; /* Last system event (for delayed sleep) */
+static int NameChanged = 0;/* Did we get a 'name changed' event during sleep? */
/*
void *context);
static void sysEventTimerNotifier(CFRunLoopTimerRef timer, void *context);
static void sysUpdate(void);
+static void sysUpdateNames(void);
/*
case kIOMessageSystemWillPowerOff :
case kIOMessageSystemWillSleep :
threadData->sysevent.event |= SYSEVENT_WILLSLEEP;
+ threadData->sysevent.event &= ~SYSEVENT_WOKE;
break;
case kIOMessageSystemHasPoweredOn :
{
/*
* If there are active printers that don't have the connecting-to-device
- * printer-state-reason then cancel the sleep request (i.e. this reason
- * indicates a job that is not yet connected to the printer)...
+ * or cups-waiting-for-completed printer-state-reason then cancel the sleep
+ * request, i.e., these reasons indicate a job that is not actively doing
+ * anything...
*/
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
if (p->job)
{
for (i = 0; i < p->num_reasons; i ++)
- if (!strcmp(p->reasons[i], "connecting-to-device"))
+ if (!strcmp(p->reasons[i], "connecting-to-device") ||
+ !strcmp(p->reasons[i], "cups-waiting-for-completed"))
break;
if (!p->num_reasons || i >= p->num_reasons)
if (p)
{
cupsdLogMessage(CUPSD_LOG_INFO,
- "System sleep canceled because printer %s is active",
+ "System sleep canceled because printer %s is active.",
p->name);
IOCancelPowerChange(sysevent.powerKernelPort,
sysevent.powerNotificationID);
}
else
{
- cupsdLogMessage(CUPSD_LOG_DEBUG, "System wants to sleep");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "System wants to sleep.");
IOAllowPowerChange(sysevent.powerKernelPort,
sysevent.powerNotificationID);
}
if (sysevent.event & SYSEVENT_WILLSLEEP)
{
- cupsdLogMessage(CUPSD_LOG_DEBUG, "System going to sleep");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "System going to sleep.");
Sleeping = 1;
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Deregistering local printer \"%s\"", p->name);
- cupsdDeregisterPrinter(p, 0);
- }
-
cupsdCleanDirty();
-#ifdef kIOPMAssertionTypeDenySystemSleep
- /*
- * Remove our assertion as needed since the user wants the system to
- * sleep (different than idle sleep)...
- */
-
- if (keep_awake)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Releasing dark wake assertion.");
- IOPMAssertionRelease(keep_awake);
- keep_awake = 0;
- }
-#endif /* kIOPMAssertionTypeDenySystemSleep */
-
/*
* If we have no printing jobs, allow the power change immediately.
- * Otherwise set the SleepJobs time to 15 seconds in the future when
+ * Otherwise set the SleepJobs time to 10 seconds in the future when
* we'll take more drastic measures...
*/
{
/*
* If there are active printers that don't have the connecting-to-device
- * printer-state-reason then delay the sleep request (i.e. this reason
- * indicates a job that is not yet connected to the printer)...
+ * or cups-waiting-for-completed printer-state-reasons then delay the
+ * sleep request, i.e., these reasons indicate a job is active...
*/
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
if (p->job)
{
for (i = 0; i < p->num_reasons; i ++)
- if (!strcmp(p->reasons[i], "connecting-to-device"))
+ if (!strcmp(p->reasons[i], "connecting-to-device") ||
+ !strcmp(p->reasons[i], "cups-waiting-for-completed"))
break;
if (!p->num_reasons || i >= p->num_reasons)
if (p)
{
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "System sleep delayed because printer %s is active.",
+ p->name);
+
LastSysEvent = sysevent;
SleepJobs = time(NULL) + 10;
}
if (sysevent.event & SYSEVENT_WOKE)
{
- cupsdLogMessage(CUPSD_LOG_DEBUG, "System woke from sleep");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "System woke from sleep.");
IOAllowPowerChange(sysevent.powerKernelPort,
sysevent.powerNotificationID);
Sleeping = 0;
-#ifdef kIOPMAssertionTypeDenySystemSleep
- if (cupsArrayCount(PrintingJobs) > 0 && !keep_awake)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Asserting dark wake.");
- IOPMAssertionCreateWithName(kIOPMAssertionTypeDenySystemSleep,
- kIOPMAssertionLevelOn,
- CFSTR("org.cups.cupsd"), &keep_awake);
- }
-#endif /* kIOPMAssertionTypeDenySystemSleep */
-
/*
* Make sure jobs that were queued prior to the system going to sleep don't
* get canceled right away...
}
}
+ if (NameChanged)
+ sysUpdateNames();
+
cupsdCheckJobs();
}
if (sysevent.event & SYSEVENT_NETCHANGED)
{
- if (!Sleeping)
+ if (Sleeping)
cupsdLogMessage(CUPSD_LOG_DEBUG,
- "System network configuration changed");
+ "System network configuration changed - "
+ "ignored while sleeping.");
else
cupsdLogMessage(CUPSD_LOG_DEBUG,
- "System network configuration changed; "
- "ignored while sleeping");
+ "System network configuration changed.");
}
if (sysevent.event & SYSEVENT_NAMECHANGED)
{
- if (!Sleeping)
+ if (Sleeping)
+ {
+ NameChanged = 1;
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Computer name or BTMM domains changed - ignored while "
+ "sleeping.");
+ }
+ else
{
cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Computer name or BTMM domains changed");
+ "Computer name or BTMM domains changed.");
- /*
- * De-register the individual printers...
- */
+ sysUpdateNames();
+ }
+ }
+ }
+}
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- cupsdDeregisterPrinter(p, 1);
+
+/*
+ * 'sysUpdateNames()' - Update computer and/or BTMM domains.
+ */
+
+static void
+sysUpdateNames(void)
+{
+ cupsd_printer_t *p; /* Current printer */
+
+
+ NameChanged = 0;
+
+ /*
+ * De-register the individual printers...
+ */
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ cupsdDeregisterPrinter(p, 1);
# if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- /*
- * Update the computer name and BTMM domain list...
- */
+ /*
+ * Update the computer name and BTMM domain list...
+ */
- cupsdUpdateDNSSDName();
+ cupsdUpdateDNSSDName();
# endif /* HAVE_DNSSD || HAVE_AVAHI */
- /*
- * Now re-register them...
- */
+ /*
+ * Now re-register them...
+ */
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- cupsdRegisterPrinter(p);
- }
- else
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Computer name or BTMM domains changed; ignored while "
- "sleeping");
- }
- }
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ cupsdRegisterPrinter(p);
}
#endif /* __APPLE__ */
/* #undef HAVE_NOTIFY_POST */
-/*
- * Do we have Darwin's IOKit private headers?
- */
-
-/* #undef HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */
-
-
/*
* Do we have DBUS?
*/
#define HAVE_NOTIFY_POST 1
-/*
- * Do we have Darwin's IOKit private headers?
- */
-
-/* #undef HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */
-
-
/*
* Do we have DBUS?
*/