예제 #1
2
/* initialise the plug-in */
static long VLCEyeTVPluginInitialize(VLCEyeTVPluginGlobals_t** globals, long apiVersion, EyeTVPluginCallbackProc callback)
{
    printf("VLC media player Plug-In: Initialize\n");
    long result = 0;
    
    /* init our own storage */
    i_deviceCount = 0;
    i_vlcSock = -1;
    
    /* notify a potential VLC instance about our initialisation */
    CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),
                                          CFSTR("PluginInit"), 
                                          CFSTR(VLC_NOTIFICATION_OBJECT), 
                                          /*userInfo*/ NULL, 
                                          TRUE );
    
    /* init our notification support */
    CFNotificationCenterAddObserver( CFNotificationCenterGetDistributedCenter(),
                                     /* observer */ NULL, 
                                     /* callBack */ VLCEyeTVPluginGlobalNotificationReceived,
                                     /* name, NULL==all */ NULL,
                                     CFSTR(VLC_NOTIFICATION_OBJECT), 
                                     CFNotificationSuspensionBehaviorDeliverImmediately );
    
    *globals = (VLCEyeTVPluginGlobals_t *) calloc(1, sizeof( VLCEyeTVPluginGlobals_t ) );
    ( *globals )->callback = callback;
        
    return result;
}
예제 #2
0
/* we will be terminated soon, clean up */
static long VLCEyeTVPluginTerminate(VLCEyeTVPluginGlobals_t *globals)
{
    long result = 0;
    
    printf("VLC media player Plug-In: Terminate\n");
    
    /* notify a potential VLC instance about our termination */
    CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter (),
                                          CFSTR("PluginQuit"), 
                                          CFSTR(VLC_NOTIFICATION_OBJECT), 
                                          /*userInfo*/ NULL, 
                                          TRUE );
    
    /* remove us from the global notification centre */
    CFNotificationCenterRemoveEveryObserver( CFNotificationCenterGetDistributedCenter(),
                                             (void *)VLCEyeTVPluginGlobalNotificationReceived );
    
    /* close data connection */
    if( i_vlcSock != -1 )
    {
        close( i_vlcSock );
        i_vlcSock = -1;
    }
    
    free( globals );
    return result;
}
예제 #3
0
cc_int32 ccs_os_notify_ccache_changed (ccs_cache_collection_t  io_cache_collection,
                                       const char             *in_ccache_name)
{
    cc_int32 err = ccNoError;

    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_ccache_name     ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter ();
        CFStringRef name = CFStringCreateWithCString (kCFAllocatorDefault,
                                                      in_ccache_name,
                                                      kCFStringEncodingUTF8);

        if (center && name) {
            CFNotificationCenterPostNotification (center,
                                                  kCCAPICCacheChangedNotification,
                                                  name, NULL, TRUE);
        }

        if (name) { CFRelease (name); }
    }

    return cci_check_error (err);
}
예제 #4
0
/* called if a device is removed */
static long VLCEyeTVPluginDeviceRemoved(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID)
{
    printf("VLC media player Plug-In: DeviceRemoved\n");
    
    long result = 0;
        
    --i_deviceCount;
    if( 0 == i_deviceCount )
    {                
        /* notify a potential VLC instance about the removal */
        CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),
                                              CFSTR("DeviceRemoved"), 
                                              CFSTR(VLC_NOTIFICATION_OBJECT), 
                                              /*userInfo*/ NULL, 
                                              TRUE );
    }
    if( (i_vlcSock != -1) && (deviceID == globals->activeDeviceID) )
    {
        close(i_vlcSock);
        i_vlcSock = -1;
        printf( "data sending switched off\n" );
    }
    
    return result;
}
예제 #5
0
void
PA_DeviceControl::Initialize()
{
	center = CFNotificationCenterGetDistributedCenter();
	
	CFNotificationCenterAddObserver(center, this,
					staticScanDevices,
					CFSTR("scanDevices"),
					CFSTR("PAHP_Device"),
					CFNotificationSuspensionBehaviorDeliverImmediately);
	
	CFNotificationCenterAddObserver(center, this,
					staticSetConfig,
					CFSTR("setConfiguration"),
					CFSTR("PAHP_Device"),
					CFNotificationSuspensionBehaviorDeliverImmediately);
	
	CFNotificationCenterAddObserver(center, this,
					staticStreamVolumeChanged,
					CFSTR("updateStreamVolume"),
					CFSTR("PAHP_LevelControl"),
					CFNotificationSuspensionBehaviorDeliverImmediately);
	
	CFNotificationCenterAddObserver(center, this,
					staticStreamMuteChanged,
					CFSTR("updateMuteVolume"),
					CFSTR("PAHP_BooleanControl"),
					CFNotificationSuspensionBehaviorDeliverImmediately);
}
예제 #6
0
static void setupIPodSystem()
{
    if ( !Moose::iPodScrobblingEnabled() )
    {
        deleteTwiddlyDatabases();
        return;
    }

#if TARGET_OS_WIN32
    LOG( 3, "Initialising ITunesComThread" );
    gCom = new ITunesComThread();
#endif

#if TARGET_OS_MAC
    LOG( 3, "Initialising ITunesPlaysDatabase" );
    ITunesPlaysDatabase::init(); // must be done b4 notification center registration

    CFNotificationCenterAddObserver( CFNotificationCenterGetDistributedCenter(),
                                     NULL,
                                     notificationCallback,
                                     CFSTR( "com.apple.iTunes.playerInfo" ),
                                     NULL,
                                     CFNotificationSuspensionBehaviorDeliverImmediately );
#endif

    LOG( 3, "Initialising IPodDetector" );
    gIPodDetector = new IPodDetector;
}
void SendSkypeCommand(CFStringRef command)
{
	if (delegate == NULL)
	{
		printf("Can't send message, no delegate set\n");
		return;
	}
	if (command == NULL)
		return;
	if (!client_id)
	{
		printf("Can't send message, not connected\n");
		return;
	}

	CFRetain(command);

	CFNumberRef id_number = CFNumberCreate(NULL, kCFNumberIntType, &client_id);
	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
	const void *keys[] = {(void *)CFSTR("SKYPE_API_COMMAND"), (void *)CFSTR("SKYPE_API_CLIENT_ID")};
	const void *values[] = {command, id_number};
	CFDictionaryRef userInfo = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);	
	
	//send message
	CFNotificationCenterPostNotification(
		center,
		CFSTR("SKSkypeAPICommand"),
		NULL,
		userInfo,
		FALSE);
	
	CFRelease(command);
	CFRelease(id_number);
	CFRelease(userInfo);
}
예제 #8
0
void set_space_by_index(int space)
{
  
  CFNotificationCenterRef nc = CFNotificationCenterGetDistributedCenter();
  CFStringRef numstr = CFStringCreateWithFormat(NULL, nil, CFSTR("%d"), space);
  CFNotificationCenterPostNotification(nc, CFSTR("com.apple.switchSpaces"), numstr, NULL, TRUE);
}
예제 #9
0
int main (int argc, const char * argv[]) {
  CFNotificationCenterRef dc = CFNotificationCenterGetDistributedCenter();
  CFNotificationCenterPostNotificationWithOptions(
      dc, CFSTR("com.apple.remotedesktop.stopLockScreen"),
      NULL, NULL, kCFNotificationPostToAllSessions);
  return 0;
}
void
SetSkypeDelegate(SkypeDelegate *aDelegate)
{
	if (!aDelegate->clientApplicationName)
	{
		printf("Deletegate requires application name\n");
		delegate = NULL;
		return;
	}
	
	if (delegate)
	{
		RemoveSkypeDelegate();
	}
	
	delegate = aDelegate;
	
	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
	
	CFNotificationCenterAddObserver(
		center,
		delegate->clientApplicationName,
		apiNotificationCallback,
		CFSTR("SKSkypeAPINotification"),
		NULL,
		CFNotificationSuspensionBehaviorDeliverImmediately);

	CFNotificationCenterAddObserver(
		center,
		delegate->clientApplicationName,
		skypeQuitCallback,
		CFSTR("SKSkypeWillQuit"),
		NULL,
		CFNotificationSuspensionBehaviorDeliverImmediately);

	CFNotificationCenterAddObserver(
		center,
		delegate->clientApplicationName,
		skypeAvailableCallback,
		CFSTR("SKSkypeBecameAvailable"),
		NULL,
		CFNotificationSuspensionBehaviorDeliverImmediately);

	CFNotificationCenterAddObserver(
		center,
		delegate->clientApplicationName,
		availabilityUpdateCallback,
		CFSTR("SKAvailabilityUpdate"),
		NULL,
		CFNotificationSuspensionBehaviorDeliverImmediately);

	CFNotificationCenterAddObserver(
		center,
		delegate->clientApplicationName,
		attachResponseCallback,
		CFSTR("SKSkypeAttachResponse"),
		NULL,
		CFNotificationSuspensionBehaviorDeliverImmediately);
}
void	CACFDistributedNotification::RemoveObserver(const void* inObserver, CFStringRef inName)
{
#if	!TARGET_OS_IPHONE
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
#else
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
#endif
	 
	CFNotificationCenterRemoveObserver(theCenter, inObserver, inName, NULL);
}
예제 #12
0
파일: Jackdmp.cpp 프로젝트: rufferson/jack2
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);
}
void refreshManager(void)
{
    CFStringRef observedObject = CFSTR("org.pureftpd.osx");
    CFNotificationCenterRef center =
        CFNotificationCenterGetDistributedCenter();
    CFNotificationCenterPostNotification(center,
                                         CFSTR("refreshStatus"),
                                         observedObject,
                                         NULL /* no dictionary */,
                                         TRUE);
}
예제 #14
0
static void
post_notification(const osxfuse_notification_t  notification,
                  const char                   *dict[][2],
                  const int                     dict_count)
{
    CFNotificationCenterRef notification_center =
            CFNotificationCenterGetDistributedCenter();

    CFStringRef            name      = NULL;
    CFStringRef            object    = NULL;
    CFMutableDictionaryRef user_info = NULL;

    name   = CFStringCreateWithCString(kCFAllocatorDefault,
                                       osxfuse_notification_names[notification],
                                       kCFStringEncodingUTF8);
    object = CFStringCreateWithCString(kCFAllocatorDefault,
                                       osxfuse_notification_object,
                                       kCFStringEncodingUTF8);

    if (!name || !object) goto out;
    if (dict_count == 0)  goto post;

    user_info = CFDictionaryCreateMutable(kCFAllocatorDefault, dict_count,
                                          &kCFCopyStringDictionaryKeyCallBacks,
                                          &kCFTypeDictionaryValueCallBacks);

    CFStringRef key;
    CFStringRef value;
    int         i;
    for (i = 0; i < dict_count; i++) {
        key   = CFStringCreateWithCString(kCFAllocatorDefault, dict[i][0],
                                          kCFStringEncodingUTF8);
        value = CFStringCreateWithCString(kCFAllocatorDefault, dict[i][1],
                                          kCFStringEncodingUTF8);

        if (!key || !value) {
            if (key)   CFRelease(key);
            if (value) CFRelease(value);
            goto out;
        }

        CFDictionarySetValue(user_info, key, value);
        CFRelease(key); key = NULL;
        CFRelease(value); value = NULL;
    }

post:
    CFNotificationCenterPostNotification(notification_center, name, object,
                                         user_info, false);
out:
    if (name)      CFRelease(name);
    if (object)    CFRelease(object);
    if (user_info) CFRelease(user_info);
}
예제 #15
0
void unlockScreen()
{
	CFNotificationCenterRef dc =
		CFNotificationCenterGetDistributedCenter();
	CFNotificationCenterPostNotificationWithOptions(
		dc,
		CFSTR("com.apple.remotedesktop.stopLockScreen"),
		NULL,
		NULL,
		kCFNotificationPostToAllSessions
	);
}
void	CACFDistributedNotification::AddObserver(const void* inObserver, CFNotificationCallback inCallback, CFStringRef inName, CFNotificationSuspensionBehavior inSuspensionBehavior)
{
#if	!TARGET_OS_IPHONE
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
	CFNotificationSuspensionBehavior theSuspensionBehavior = inSuspensionBehavior;
#else
	#pragma unused(inSuspensionBehavior)
	CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
	CFNotificationSuspensionBehavior theSuspensionBehavior = 0;
#endif
	 
	CFNotificationCenterAddObserver(theCenter, inObserver, inCallback, inName, NULL, theSuspensionBehavior);
}
예제 #17
0
void
ITunesScript::run()
{
    setupCurrentTrack();

    CFNotificationCenterAddObserver( CFNotificationCenterGetDistributedCenter(), 
                                     this,
                                     callback, 
                                     CFSTR( "com.apple.iTunes.playerInfo" ), 
                                     NULL, 
                                     CFNotificationSuspensionBehaviorDeliverImmediately );
    
    exec();
}
void SendNotification(CFStringRef stockSymbol, double price) {
    CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
    CFNumberRef priceNum = CFNumberCreate(NULL, kCFNumberDoubleType, &price);
    CFMutableDictionaryRef stockInfoDict = CFDictionaryCreateMutable(NULL, 2,
        &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

    CFDictionaryAddValue(stockInfoDict, CFSTR("Stock Symbol"), stockSymbol);
    CFDictionaryAddValue(stockInfoDict, CFSTR("New Price"), priceNum);
    CFRelease(priceNum);

    CFNotificationCenterPostNotification(center, CFSTR("Stock Price Changed Notification"), stockSymbol, stockInfoDict, FALSE);
    
    CFRelease(stockInfoDict);
}
int main(int argc, char **argv) {
 CFStringRef _key = ((CFStringRef) __builtin___CFStringMakeConstantString ("" "Process identifier" ""));
 int pid = 42;

 CFNumberRef _value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid);
 CFDictionaryRef userInfo = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&_key, (const void **)&_value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
 CFRelease(_value); // no-warning
 CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(),
           ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlPreferencesChanged" "")),
           ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlUserDefaults" "")),
           userInfo, 0);
 CFRelease(userInfo); // no-warning

 return 0;
}
예제 #20
0
void
PA_DeviceControl::AnnounceDevice()
{
	CFMutableDictionaryRef userInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
								    &kCFCopyStringDictionaryKeyCallBacks,
								    &kCFTypeDictionaryValueCallBacks);
	CFNumberRef number;
	CFStringRef str;
	PA_DeviceBackend *be = device->GetBackend();
	
	UInt32 n = getpid();
	number = CFNumberCreate(NULL, kCFNumberIntType, &n);
	CFDictionarySetValue(userInfo, CFSTR("pid"), number);
	CFRelease(number);
	
	CFDictionarySetValue(userInfo, CFSTR("procname"), be->GetProcessName());

	str = device->CopyDeviceName();
	CFDictionarySetValue(userInfo, CFSTR("audioDevice"), str);
	CFRelease(str);
	
	n = device->GetIOBufferFrameSize();
	number = CFNumberCreate(NULL, kCFNumberIntType, &n);
	CFDictionarySetValue(userInfo, CFSTR("IOBufferFrameSize"), number);
	CFRelease(number);

	CFStringRef serverName = be->GetHostName();
	CFDictionarySetValue(userInfo, CFSTR("serverName"), serverName);
	CFRelease(serverName);
	
	n = be->GetConnectionStatus();
	number = CFNumberCreate(NULL, kCFNumberIntType, &n);
	CFDictionarySetValue(userInfo, CFSTR("connectionStatus"), number);
	CFRelease(number);
	
	DebugLog();

	CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(),
					     CFSTR("announceDevice"),
					     LOCAL_OBJECT,
					     userInfo,
					     true);
	CFRelease(userInfo);
}
예제 #21
0
KGlobalAccelImpl::KGlobalAccelImpl(GlobalShortcutsRegistry* owner)
	: m_owner(owner)
    , m_eventTarget(GetApplicationEventTarget())
    , m_eventHandler(NewEventHandlerUPP(hotKeyEventHandler))
{
    m_eventType[0].eventClass = kEventClassKeyboard;
    m_eventType[0].eventKind = kEventHotKeyPressed; 
    m_eventType[1].eventClass = kEventClassKeyboard; // only useful for testing, is not used because count passed in call to InstallEventHandler is 1
    m_eventType[1].eventKind = kEventRawKeyDown;
    refs = new QMap<int, QList<EventHotKeyRef> >();
    
    CFStringRef str = CFStringCreateWithCString(NULL, "AppleKeyboardPreferencesChangedNotification", kCFStringEncodingASCII);
    if (str) {
        CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), this, layoutChanged, str, NULL, CFNotificationSuspensionBehaviorHold);
        CFRelease(str);
    } else {
        kWarning(125) << "Couldn't create CFString to register for keyboard notifications";
    }
}
int
IsSkypeAvailable(void)
{
	//is skype available?
	isavailable = 0;
	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();

	CFNotificationCenterPostNotification(
		center,
		CFSTR("SKSkypeAPIAvailabilityRequest"),
		NULL,
		NULL,
		TRUE);
	
	//Should only take 1 second or less to reply
	RunCurrentEventLoop(1);
	int avail = isavailable;
	isavailable = 0;
	return avail;
}
예제 #23
0
void
PA_DeviceControl::SignOffDevice()
{
	CFMutableDictionaryRef userInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
								    &kCFCopyStringDictionaryKeyCallBacks,
								    &kCFTypeDictionaryValueCallBacks);
	CFNumberRef number;
	
	UInt32 pid = getpid();
	number = CFNumberCreate(NULL, kCFNumberIntType, &pid);
	CFDictionarySetValue(userInfo, CFSTR("pid"), number);
	CFRelease(number);
	
	CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(),
					     CFSTR("signOffDevice"),
					     LOCAL_OBJECT,
					     userInfo,
					     true);
	CFRelease(userInfo);
}
예제 #24
0
cc_int32 ccs_os_notify_cache_collection_changed (ccs_cache_collection_t io_cache_collection)
{
    cc_int32 err = ccNoError;

    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter ();

        if (center) {
            CFNotificationCenterPostNotification (center,
                                                  kCCAPICacheCollectionChangedNotification,
                                                  NULL, NULL, TRUE);
        }
    }



    return cci_check_error (err);
}
예제 #25
0
/* called if a device is added */
static long VLCEyeTVPluginDeviceAdded(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID, EyeTVPluginDeviceType deviceType)
{
    printf("VLC media player Plug-In: Device with type %i and ID %i added\n", (int)deviceType, (int)deviceID);
    
    long result = 0;
    
    if( globals ) 
    {
        ++i_deviceCount;
        if( 1 == i_deviceCount )
        {                
            /* notify a potential VLC instance about the addition */
            CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),
                                                  CFSTR("DeviceAdded"), 
                                                  CFSTR(VLC_NOTIFICATION_OBJECT), 
                                                  /*userInfo*/ NULL, 
                                                  TRUE );
        }
    }
    return result;
}
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);
}
void DisconnectFromSkype(void)
{
	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
		
	if (client_id)
	{
		CFNumberRef id_number = CFNumberCreate(NULL, kCFNumberIntType, &client_id);
		const void *keys[] = {(void *)CFSTR("SKYPE_API_CLIENT_ID")};
		const void *values[] = {id_number};
		CFDictionaryRef userInfo = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);	
	
		//disconnect
		CFNotificationCenterPostNotification(
			center,
			CFSTR("SKSkypeAPIDetachRequest"),
			NULL,
			userInfo,
			FALSE);
			
		client_id = 0;
	}
}
void
RemoveSkypeDelegate(void)
{
	if (delegate && delegate->clientApplicationName)
	{
		CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
			
		CFNotificationCenterRemoveObserver(
			center,
			delegate->clientApplicationName,
			CFSTR("SKSkypeAPINotification"),
			NULL);

		CFNotificationCenterRemoveObserver(
			center,
			delegate->clientApplicationName,
			CFSTR("SKSkypeWillQuit"),
			NULL);

		CFNotificationCenterRemoveObserver(
			center,
			delegate->clientApplicationName,
			CFSTR("SKSkypeBecameAvailable"),
			NULL);

		CFNotificationCenterRemoveObserver(
			center,
			delegate->clientApplicationName,
			CFSTR("SKAvailabilityUpdate"),
			NULL);

		CFNotificationCenterRemoveObserver(
			center,
			delegate->clientApplicationName,
			CFSTR("SKSkypeAttachResponse"),
			NULL);
	}
	delegate = NULL;
}
void
ConnectToSkype(void)
{
	if (!delegate || !delegate->clientApplicationName)
	{
		printf("Error: Delegate not set\n");
		return;
	}
	
	if (!IsSkypeAvailable())
	{
		printf("Error: Skype not available\n");
	}

	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
			
	//do the connect
	CFNotificationCenterPostNotification(
		center,
		CFSTR("SKSkypeAPIAttachRequest"),
		delegate->clientApplicationName,
		NULL,
		TRUE);
}
예제 #30
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);
}