SCDynamicStore ConsoleUser change callback not working on Tiger?
SCDynamicStore ConsoleUser change callback not working on Tiger?
- Subject: SCDynamicStore ConsoleUser change callback not working on Tiger?
- From: Daniel Becker <email@hidden>
- Date: Fri, 6 May 2005 10:05:23 +0200
Hi all,
I have a daemon which registers a callback with SCDynamicStore to get
notified of console user changes. This seems to work just fine on
Panther, but it appears the callback never gets triggered on Tiger.
Were there any relevant changes in Tiger's SCDynamicStore that I should
be aware of? Any other suggestions? (The relevant code is given below.)
Daniel
void ConsoleUserChangedCallBackFunction(SCDynamicStoreRef store,
CFArrayRef changedKeys, void * context)
{
[...]
}
int main (int argc, const char * argv[])
{
SCDynamicStoreContext context = {0, NULL, NULL, NULL, NULL};
SCDynamicStoreRef session = NULL;
CFStringRef consoleUserNameChangeKey = NULL;
CFArrayRef notificationKeys;
CFRunLoopSourceRef rls = NULL;
FILE * pid_file;
daemon(0,0);
syslog(1, "Daemon starting up with PID %d.\n", getpid());
session = SCDynamicStoreCreate(NULL, CFSTR(kProgramName),
ConsoleUserChangedCallBackFunction, &context);
if (session == NULL)
{
syslog(1, "Couldn't create DynamicStore session!\n");
return 1;
}
consoleUserNameChangeKey = SCDynamicStoreKeyCreateConsoleUser(NULL);
if (consoleUserNameChangeKey == NULL)
{
CFRelease(session);
syslog(1, "Couldn't create ConsoleUser key!\n");
return 1;
}
notificationKeys = CFArrayCreate(NULL,
(void*)&consoleUserNameChangeKey,
(CFIndex)1, &kCFTypeArrayCallBacks);
CFRelease(consoleUserNameChangeKey);
if (notificationKeys == NULL)
{
CFRelease(session);
syslog(1, "Couldn't create notification key array!\n");
return 1;
}
if (SCDynamicStoreSetNotificationKeys(session, notificationKeys, NULL)
== FALSE)
{
CFRelease(notificationKeys);
CFRelease(session);
syslog(1, "Couldn't set up dynamic store notification!\n");
return 1;
}
CFRelease(notificationKeys);
rls = SCDynamicStoreCreateRunLoopSource(NULL, session, (CFIndex)0);
pid_file = fopen(kPIDFile, "w");
fprintf(pid_file, "%d\n", getpid());
fclose(pid_file);
CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
CFRelease(rls);
CFRunLoopRun();
unlink(kPIDFile);
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden