Beispiel #1
0
static int sleepImmediately (void)
{
	mach_port_t	masterPort;
	io_connect_t	rootPort;
	IOReturn	err;

	if (IOPMSleepEnabled()) {
		if ((err = IOMasterPort(MACH_PORT_NULL, &masterPort))) {
			fprintf (stderr, "%s: can't get mach master port: %ld\n", args.progname, (long) err);
			return (1);
		}
		rootPort = IOPMFindPowerManagement(masterPort);
		if (rootPort) {
			err = IOPMSleepSystem(rootPort);
			if (err) {
				fprintf (stderr, "%s: IOPMSleepSystem failed: %ld\n", args.progname, (long) err);
				return (1);
			}
		} else {
			fprintf (stderr, "%s: IOPMFindPowerManagement failed\n", args.progname);
			return (1);
		}
	} else {
		fprintf (stderr, "%s: sleep mode is disabled\n", args.progname);
		return (1);
	}
	return (0);
}
Beispiel #2
0
bool CCocoaPowerSyscall::CanSuspend(void)
{
  bool result;
#if defined(TARGET_DARWIN_IOS)
  result = false;
#else
  result =IOPMSleepEnabled();
#endif
  return(result);
}
bool CCocoaPowerSyscall::CanSuspend(void)
{
  bool result;
#if defined(TARGET_DARWIN_IOS)
  result = false;
#else
  // Only OSX boxes can suspend, the AppleTV cannot
  if (g_sysinfo.IsAppleTV())
    result = false;
  else
    result =IOPMSleepEnabled();
#endif
  return(result);
}