Beispiel #1
0
int main (int argc, const char * argv[]) {
  CFNotificationCenterRef dc = CFNotificationCenterGetDistributedCenter();
  CFNotificationCenterPostNotificationWithOptions(
      dc, CFSTR("com.apple.remotedesktop.stopLockScreen"),
      NULL, NULL, kCFNotificationPostToAllSessions);
  return 0;
}
Beispiel #2
0
static void notify_server_stop(const char* server_name)
{
    // Send notification to be used in the JackRouter plugin
    CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
    CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
            CFSTR("com.grame.jackserver.stop"),
            ref1,
            NULL,
            kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
    CFRelease(ref1);
}
Beispiel #3
0
void unlockScreen()
{
	CFNotificationCenterRef dc =
		CFNotificationCenterGetDistributedCenter();
	CFNotificationCenterPostNotificationWithOptions(
		dc,
		CFSTR("com.apple.remotedesktop.stopLockScreen"),
		NULL,
		NULL,
		kCFNotificationPostToAllSessions
	);
}
void	CACFDistributedNotification::PostNotification(CFStringRef inName, CFDictionaryRef inUserInfo, bool inPostToAllSessions)
{
#if	!TARGET_OS_IPHONE
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
	CFDictionaryRef theUserInfo = inUserInfo;
	CFOptionFlags theFlags = kCFNotificationDeliverImmediately;
	if(inPostToAllSessions)
	{
		theFlags += kCFNotificationPostToAllSessions;
	}
#else
	//	flag unsupported features
	Assert(inUserInfo == NULL, "CACFDistributedNotification::PostNotification: distributed notifications do not support a payload");
	Assert(inPostToAllSessions, "CACFDistributedNotification::PostNotification: distributed notifications do not support per-session delivery");
	
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
	CFDictionaryRef theUserInfo = NULL;
	CFOptionFlags theFlags = 0;
#endif
	 
	 CFNotificationCenterPostNotificationWithOptions(theCenter, inName, NULL, theUserInfo, theFlags);
}
Beispiel #5
0
int 
main(int argc, char *argv[])
{
	struct kevent	kev;
	Action          anAction = kActionStart;
	int             ch, r, kq = kqueue();

	assert(kq  != -1);

	EV_SET(&kev, SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
	r = kevent(kq, &kev, 1, NULL, 0, NULL);
	assert(r != -1);
	signal(SIGTERM, dummy_sig);

	while ((ch = getopt(argc, argv, "gvxirdDqn?")) != -1) {
		switch (ch) {
		case 'v':
			gVerboseFlag = true;
			break;
		case 'x':
		case 'g':
		case 'r':
		case 'q':
			break;
		case 'd':
		case 'D':
			gDebugFlag = true;
			break;
		case 'n':
			gNoRunFlag = true;
			break;
		case '?':
		default:
			usage();
			break;
		}
	}
	argc -= optind;
	argv += optind;

	if (argc > 2) {
		usage();
	}

	openlog(getprogname(), LOG_PID|LOG_CONS|(gDebugFlag ? LOG_PERROR : 0), LOG_DAEMON);
	if (gDebugFlag) {
		setlogmask(LOG_UPTO(LOG_DEBUG));
	} else if (gVerboseFlag) {
		setlogmask(LOG_UPTO(LOG_INFO));
	} else {
		setlogmask(LOG_UPTO(LOG_NOTICE));
	}

	if (!gNoRunFlag && (getuid() != 0)) {
		syslog(LOG_ERR, "must be root to run");
		exit(EXIT_FAILURE);
	}

	if (argc > 0) {
		if (strcmp(argv[0], "start") == 0) {
			anAction = kActionStart;
		} else if (strcmp(argv[0], "stop") == 0) {
			anAction = kActionStop;
		} else if (strcmp(argv[0], "restart") == 0) {
			anAction = kActionRestart;
		} else {
			usage();
		}
	}

	if (argc == 2) {
		exit(system_starter(anAction, argv[1]));
	}

	unlink(kFixerPath);

	mach_timespec_t w = { 600, 0 };
	kern_return_t kr;

	/*
	 * Too many old StartupItems had implicit dependancies on "Network" via
	 * other StartupItems that are now no-ops.
	 *
	 * SystemStarter is not on the critical path for boot up, so we'll
	 * stall here to deal with this legacy dependancy problem.
	 */

	if ((kr = IOKitWaitQuiet(kIOMasterPortDefault, &w)) != kIOReturnSuccess) {
		syslog(LOG_NOTICE, "IOKitWaitQuiet: %d\n", kr);
	}

	fwexec("/usr/sbin/ipconfig", "waitall", NULL);
	autodiskmount(); /* wait for Disk Arbitration to report idle */

	system_starter(kActionStart, NULL);

	if (StartupItemSecurityCheck("/etc/rc.local")) {
		fwexec(_PATH_BSHELL, "/etc/rc.local", NULL);
	}

	CFNotificationCenterPostNotificationWithOptions(
			CFNotificationCenterGetDistributedCenter(),
			CFSTR("com.apple.startupitems.completed"),
			NULL, NULL,
			kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);

	r = kevent(kq, NULL, 0, &kev, 1, NULL);
	assert(r != -1);
	assert(kev.filter == EVFILT_SIGNAL && kev.ident == SIGTERM);

	if (StartupItemSecurityCheck("/etc/rc.shutdown.local")) {
		fwexec(_PATH_BSHELL, "/etc/rc.shutdown.local", NULL);
	}

	system_starter(kActionStop, NULL);

	exit(EXIT_SUCCESS);
}
CF_EXPORT void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately) {
    CFNotificationCenterPostNotificationWithOptions(center, name, object, userInfo, kCFNotificationDeliverImmediately);
}