--- /dev/null
+#include <unistd.h>
+#include <fcntl.h>
+
+#import <Foundation/Foundation.h>
+#import <BluetoothManager/BluetoothManager.h>
+#import <SpringBoard/SBBluetoothController.h>
+
+static unsigned connectedDevices_;
+
+@interface SBBluetoothController (_WinterBoard)
+- (void) wb_noteDevicesChanged;
+@end
+
+@implementation SBBluetoothController (WinterBoard)
+
+- (void) noteDevicesChanged {
+ if (NSArray *devices = [[BluetoothManager sharedInstance] pairedDevices]) {
+ connectedDevices_ = 0;
+ for (int i = 0, e = [devices count]; i != e; ++i)
+ if ([[devices objectAtIndex:i] connected])
+ ++connectedDevices_;
+ if (connectedDevices_ == 0)
+ unlink("/tmp/neuter");
+ else
+ close(open("/tmp/neuter", O_CREAT | O_TRUNC | O_WRONLY, 644));
+ }
+
+ [self wb_noteDevicesChanged];
+}
+
+@end
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+
+ <key>CFBundleExecutable</key>
+ <string>WinterBoard</string>
+
+ <key>CFBundleIdentifier</key>
+ <string>com.saurik.WinterBoard</string>
+
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+
+ <key>CFBundleName</key>
+ <string>WinterBoard</string>
+
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+
+ <key>CFBundleSignature</key>
+ <string>????</string>
+
+ <key>CFBundleVersion</key>
+ <string>0.9</string>
+
+ <key>NSPrincipalClass</key>
+ <string>WinterBoard</string>
+</dict>
+
+</plist>
--- /dev/null
+#import <Foundation/Foundation.h>
+#include <objc/runtime.h>
+
+#define WBPrefix "wb_"
+
+void WBRename(const char *classname, const char *oldname) {
+ Class class = objc_getClass(classname);
+ size_t namelen = strlen(oldname);
+ char newname[sizeof(WBPrefix) + namelen];
+ memcpy(newname, WBPrefix, sizeof(WBPrefix) - 1);
+ memcpy(newname + sizeof(WBPrefix) - 1, oldname, namelen + 1);
+ Method method = class_getInstanceMethod(class, sel_getUid(oldname));
+ if (!class_addMethod(class, sel_registerName(newname), method->method_imp, method->method_types))
+ NSLog(@"WB: failed to rename %s::%s", classname, oldname);
+}
+
+void WBInitialize() {
+ if (NSClassFromString(@"SpringBoard") == nil)
+ return;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSLog(@"WB: changing season");
+
+ WBRename("SBBluetoothController", "noteDevicesChanged");
+
+ NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/WinterBoard.framework"];
+ if (bundle == nil)
+ NSLog(@"WB: there is no Santa :(");
+ else if (![bundle load])
+ NSLog(@"WB: sleigh was too heavy");
+
+ [pool release];
+}
--- /dev/null
+#!/bin/bash
+PATH=/apl/n42/pre/bin:$PATH exec /apl/tel/exec.sh com.saurik.winterboard make "$@"
--- /dev/null
+ifndef PKG_TARG
+target :=
+else
+target := $(PKG_TARG)-
+endif
+
+all: WinterBoard WinterBoard.dylib
+
+clean:
+ rm -f WinterBoard.dylib
+
+WinterBoard: *.mm makefile
+ $(target)gcc -fobjc-call-cxx-cdtors -bundle -g3 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -framework UIKit -lobjc -fobjc-exceptions -flat_namespace -undefined suppress -I../uicaboodle.m
+
+WinterBoard.dylib: Initialization.m makefile
+ $(target)gcc -dynamiclib -g3 -O2 -Wall -Werror -o $@ $(filter %.m,$^) -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize
+
+.PHONY: all clean