/*
- * "$Id: sysman.c 5241 2006-03-07 22:07:44Z mike $"
+ * "$Id: sysman.c 6649 2007-07-11 21:46:42Z mike $"
*
* System management definitions for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * 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:
*
* common to wake up in a new location.
*/
-#ifndef __APPLE__
-/*
- * 'cupsdStartSystemMonitor()' - Start monitoring for system change.
- */
-
-void
-cupsdStartSystemMonitor(void)
-{
-}
-
-
-/*
- * 'cupsdStopSystemMonitor()' - Stop monitoring for system change.
- */
-
-void
-cupsdStopSystemMonitor(void)
-{
-}
-
-
-/*
- * 'cupsdUpdateSystemMonitor()' - Update the current system state.
- */
-
-void
-cupsdUpdateSystemMonitor(void)
-{
-}
-#endif /* !__APPLE__ */
-
-
#ifdef __APPLE__
/*
* This is the Apple-specific system event code. It works by creating
/* The runloop. Access must be protected! */
static CFStringRef ComputerNameKey = NULL,
/* Computer name key */
- NetworkGlobalKey = NULL,
- /* Network global key */
+ NetworkGlobalKeyIPv4 = NULL,
+ /* Network global IPv4 key */
+ NetworkGlobalKeyIPv6 = NULL,
+ /* Network global IPv6 key */
+ NetworkGlobalKeyDNS = NULL,
+ /* Network global DNS key */
HostNamesKey = NULL,
/* Host name key */
- NetworkInterfaceKey = NULL;
+ NetworkInterfaceKeyIPv4 = NULL,
+ /* Netowrk interface key */
+ NetworkInterfaceKeyIPv6 = NULL;
/* Netowrk interface key */
return;
}
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdStartSystemMonitor: Adding fd %d to InputSet...",
- SysEventPipes[0]);
- FD_SET(SysEventPipes[0], InputSet);
+ cupsdAddSelect(SysEventPipes[0], (cupsd_selfunc_t)cupsdUpdateSystemMonitor,
+ NULL, NULL);
/*
* Set non-blocking mode on the descriptor we will be receiving notification
if (SysEventPipes[0] >= 0)
{
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdStopSystemMonitor: Removing fd %d from InputSet...",
- SysEventPipes[0]);
-
- FD_CLR(SysEventPipes[0], InputSet);
-
+ cupsdRemoveSelect(SysEventPipes[0]);
cupsdClosePipe(SysEventPipes);
}
}
Sleeping = 1;
- cupsdStopAllJobs();
+ cupsdStopAllJobs(0);
cupsdSaveAllJobs();
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
}
else
{
- /* TODO: Possibly update when MDNS support is added? */
cupsdLogMessage(CUPSD_LOG_DEBUG,
"Deregistering local printer \"%s\"", p->name);
- cupsdSendBrowseDelete(p);
+ cupsdDeregisterPrinter(p, 0);
}
}
cupsdLogMessage(CUPSD_LOG_DEBUG,
"System network configuration changed");
- /*
- * Force an update of the list of network interfaces in 2 seconds.
- */
-
- NetIFTime = time(NULL) - 58;
-
/*
* Resetting browse_time before calling cupsdSendBrowseList causes
* browse packets to be sent for local shared printers.
p->browse_time = 0;
cupsdSendBrowseList();
+ cupsdRestartPolling();
}
else
cupsdLogMessage(CUPSD_LOG_DEBUG,
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
- cupsdSendBrowseDelete(p);
+ cupsdDeregisterPrinter(p, 1);
/*
* Now re-register them...
- *
- * TODO: This might need updating for MDNS.
*/
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ {
p->browse_time = 0;
+ cupsdRegisterPrinter(p);
+ }
}
else
cupsdLogMessage(CUPSD_LOG_DEBUG,
SCDynamicStoreRef store = NULL;/* System Config dynamic store */
CFRunLoopSourceRef powerRLS = NULL,/* Power runloop source */
storeRLS = NULL;/* System Config runloop source */
- CFStringRef key[3], /* System Config keys */
- pattern[1]; /* System Config patterns */
+ CFStringRef key[5], /* System Config keys */
+ pattern[2]; /* System Config patterns */
CFArrayRef keys = NULL, /* System Config key array*/
patterns = NULL;/* System Config pattern array */
SCDynamicStoreContext storeContext; /* Dynamic store context */
if (!ComputerNameKey)
ComputerNameKey = SCDynamicStoreKeyCreateComputerName(NULL);
- if (!NetworkGlobalKey)
- NetworkGlobalKey =
+ if (!NetworkGlobalKeyIPv4)
+ NetworkGlobalKeyIPv4 =
SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
kSCDynamicStoreDomainState,
kSCEntNetIPv4);
+ if (!NetworkGlobalKeyIPv6)
+ NetworkGlobalKeyIPv6 =
+ SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
+ kSCDynamicStoreDomainState,
+ kSCEntNetIPv6);
+
+ if (!NetworkGlobalKeyDNS)
+ NetworkGlobalKeyDNS =
+ SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
+ kSCDynamicStoreDomainState,
+ kSCEntNetDNS);
+
if (!HostNamesKey)
HostNamesKey = SCDynamicStoreKeyCreateHostNames(NULL);
- if (!NetworkInterfaceKey)
- NetworkInterfaceKey =
+ if (!NetworkInterfaceKeyIPv4)
+ NetworkInterfaceKeyIPv4 =
SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
kSCDynamicStoreDomainState,
kSCCompAnyRegex,
kSCEntNetIPv4);
- if (store && ComputerNameKey && NetworkGlobalKey && HostNamesKey &&
- NetworkInterfaceKey)
+ if (!NetworkInterfaceKeyIPv6)
+ NetworkInterfaceKeyIPv6 =
+ SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
+ kSCDynamicStoreDomainState,
+ kSCCompAnyRegex,
+ kSCEntNetIPv6);
+
+ if (store && ComputerNameKey && HostNamesKey &&
+ NetworkGlobalKeyIPv4 && NetworkGlobalKeyIPv6 && NetworkGlobalKeyDNS &&
+ NetworkInterfaceKeyIPv4 && NetworkInterfaceKeyIPv6)
{
key[0] = ComputerNameKey;
- key[1] = NetworkGlobalKey;
- key[2] = HostNamesKey;
- pattern[0] = NetworkInterfaceKey;
+ key[1] = NetworkGlobalKeyIPv4;
+ key[2] = NetworkGlobalKeyIPv6;
+ key[3] = NetworkGlobalKeyDNS;
+ key[4] = HostNamesKey;
+
+ pattern[0] = NetworkInterfaceKeyIPv4;
+ pattern[1] = NetworkInterfaceKeyIPv6;
keys = CFArrayCreate(NULL, (const void **)key,
sizeof(key) / sizeof(key[0]),
&kCFTypeArrayCallBacks);
+
patterns = CFArrayCreate(NULL, (const void **)pattern,
sizeof(pattern) / sizeof(pattern[0]),
&kCFTypeArrayCallBacks);
if (CFArrayContainsValue(changedKeys, range, ComputerNameKey))
threadData->sysevent.event |= SYSEVENT_NAMECHANGED;
-
- if (CFArrayContainsValue(changedKeys, range, NetworkGlobalKey) ||
- CFArrayContainsValue(changedKeys, range, HostNamesKey) ||
- CFArrayContainsValue(changedKeys, range, NetworkInterfaceKey))
+ else
+ {
threadData->sysevent.event |= SYSEVENT_NETCHANGED;
+ /*
+ * Indicate the network interface list needs updating...
+ */
+
+ NetIFUpdate = 1;
+ }
+
/*
* Because we registered for several different kinds of change notifications
* this callback usually gets called several times in a row. We use a timer to
*/
CFRunLoopTimerSetNextFireDate(threadData->timerRef,
- CFAbsoluteTimeGetCurrent() + 2);
+ CFAbsoluteTimeGetCurrent() + 5);
}
/*
- * End of "$Id: sysman.c 5241 2006-03-07 22:07:44Z mike $".
+ * End of "$Id: sysman.c 6649 2007-07-11 21:46:42Z mike $".
*/