replace BluetoothManager calls with SpringBoardAccess

This commit is contained in:
matthias.ringwald 2010-05-26 20:24:06 +00:00
parent 28f654622f
commit c07efcf512

View File

@ -74,59 +74,13 @@ kern_return_t IOObjectRelease(mach_port_t object);
#endif
#endif
// minimal BluetoothManager swiped from BigBoss SBSettings Toggle
#import <Foundation/Foundation.h>
@class UIDevice;
@interface BluetoothManager : NSObject
+ (BluetoothManager *) sharedInstance;
- (void) setPowered:(BOOL)powered;
- (void) setEnabled:(BOOL)enabled;
- (BOOL) enabled;
@end
#define kAppBTServer CFSTR("com.apple.BTServer")
#define kKeyBTPowered CFSTR("defaultPoweredState")
#define kAppNetwork CFSTR("com.apple.preferences.network")
#define kKeyBTNetwork CFSTR("bluetooth-network")
int iphone_system_bt_enabled(){
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if ([[BluetoothManager sharedInstance] enabled]) {
return 1;
} else {
return 0;
}
[pool release];
return SBA_getBluetoothEnabled();
}
void iphone_system_bt_set_enabled(int enabled)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
/* Get a copy of the global bluetooth server */
BluetoothManager *bm = [BluetoothManager sharedInstance];
if ( [bm enabled] && enabled) return;
if (![bm enabled] && !enabled) return;
if (enabled) {
/* Store into preferences that bluetooth should start on system boot */
CFPreferencesSetAppValue(kKeyBTNetwork, kCFBooleanTrue, kAppNetwork);
/* Turn bluetooth on */
[bm setPowered:YES];
} else {
/* Store into preferences taht bluetooth should not start on system boot */
CFPreferencesSetAppValue(kKeyBTNetwork, kCFBooleanFalse, kAppNetwork);
/* Turn bluetooth off */
[bm setEnabled:NO];
}
/* Synchronize to preferences, e.g. write to disk, bluetooth settings */
CFPreferencesAppSynchronize(kAppNetwork);
[pool release];
SBA_setBluetoothEnabled(enabled);
}
#endif