add listener for ch.ringwald.btstack.preferences

This commit is contained in:
matthias.ringwald 2012-02-07 20:50:03 +00:00
parent 4764045067
commit a4516c1567
2 changed files with 21 additions and 0 deletions

View File

@ -43,3 +43,4 @@
void platform_iphone_status_handler(BLUETOOTH_STATE state);
void platform_iphone_register_window_manager_restart(void (*callback)());
void platform_iphone_register_preferences_changed(void (*callback)());

View File

@ -86,6 +86,7 @@ static void springBoardDidLaunch(){
(*window_manager_restart_callback)();
}
}
void platform_iphone_register_window_manager_restart(void (*callback)() ){
static int registered = 0;
if (!registered) {
@ -97,4 +98,23 @@ void platform_iphone_register_window_manager_restart(void (*callback)() ){
window_manager_restart_callback = callback;
}
static void (*preferences_changed_callback)() = NULL;
static void preferencesDidChange(){
NSLog(@"ch.ringwald.btstack.preferences!\n");
if (preferences_changed_callback) {
(*preferences_changed_callback)();
}
}
void platform_iphone_register_preferences_changed(void (*callback)() ){
static int registered = 0;
if (!registered) {
// register for launch notification
CFNotificationCenterRef darwin = CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterAddObserver(darwin, NULL, (CFNotificationCallback) preferencesDidChange,
(CFStringRef) @"ch.ringwald.btstack.preferences", NULL, 0);
}
preferences_changed_callback = callback;
}
#endif