Skip to content

Commit

Permalink
Race update
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix3200 committed Jul 6, 2010
1 parent 54ff132 commit 8810f06
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ libstatusbar_OBJCC_FILES = libstatusbar.mm Classes.mm \
StatusBarItemClient.mm StatusBarItemServer.mm \
UIStatusBarCustomItem.mm UIStatusBarCustomItemView.mm
libstatusbar_FRAMEWORKS = UIKit
libstatusbar_PRIVATE_FRAMEWORKS = AppSupport
libstatusbar_PRIVATE_FRAMEWORKS = AppSupport SpringboardServices


#SYSROOT = /Wildcat7B367.dyld_cache
Expand Down
2 changes: 1 addition & 1 deletion StatusBarItemClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- (id) init;

- (void) retrieveCurrentMessage;
- (void) processCurrentMessage;
- (bool) processCurrentMessage;
- (void) updateStatusBar;

- (void) setProperties: (id) properties forItem: (NSString*) item;
Expand Down
17 changes: 11 additions & 6 deletions StatusBarItemClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ - (void) retrieveCurrentMessage
NSDesc(_currentMessage);
}

- (void) processCurrentMessage
- (bool) processCurrentMessage
{
bool ret = NO;

NSMutableDictionary *processedMessage = [_currentMessage mutableCopy];

int keyidx = 22;
Expand All @@ -82,6 +84,8 @@ - (void) processCurrentMessage
NSString* indicatorName = [item indicatorName];
if(processedMessage==nil || [processedMessage objectForKey: indicatorName] == nil)
{
ret = YES;

NSLog(@"removing item: %@", indicatorName);
[item removeAllViews];
[customItems[i] removeObjectAtIndex: cnt];
Expand All @@ -108,27 +112,28 @@ - (void) processCurrentMessage

keyidx++;

if(processedMessage)
if(processedMessage && [processedMessage count])
{
ret = YES;
GETCLASS(UIStatusBarItem);
for(NSString* key in processedMessage)
//NSString* key = @"Pause";
{
NSLog(@"adding item: %@", key);
[[$UIStatusBarItem itemWithType: keyidx++] setIndicatorName: key];
}
}
NSLog(@"processCurrentMessage? %@", ret ? @"YES" : @"NO");
return ret;
}

- (void) updateStatusBar
{
SelLog();

[self retrieveCurrentMessage];
[self processCurrentMessage];

// need a decent guard band because we call updateStatusBar before UIApp exists
if(UIApp)
// need a decent guard band because we do call before UIApp exists
if([self processCurrentMessage] && UIApp)
{
UIStatusBarForegroundView* _foregroundView = MSHookIvar<UIStatusBarForegroundView*>([UIApp statusBar], "_foregroundView");
if(_foregroundView)
Expand Down
1 change: 1 addition & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern "C" UIApplication* UIApp;
+ (UIImage*) kitImageNamed: (NSString*) name;
@end

extern "C" int SBSSpringBoardServerPort();

#import <objc/message.h>
#import <substrate.h>
Expand Down
96 changes: 56 additions & 40 deletions libstatusbar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,67 @@ void removeBT()
}
*/

__attribute__((constructor)) void start()
HOOKDEF(void, UIApplication, _startWindowServerIfNecessary)
{
HookLog();
CALL_ORIG(UIApplication, _startWindowServerIfNecessary);

// use this only for starting client
// register as client - make sure SpringBoard is running
// UIKit should still not exist.../yet/
if($SpringBoard || SBSSpringBoardServerPort())
{
[StatusBarItemClient sharedInstance];
}
NSLine();

[[NSAutoreleasePool alloc] init];
// testing stuff...
/*
{
float delay = 4.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 8.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addPause;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 12.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) removeBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 16.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
*/
}


__attribute__((constructor)) void start()
{
NSLine();

// get classes
Classes_Fetch();

[[NSAutoreleasePool alloc] init];

// we only hook UIKit apps - used as a guard band
if($UIStatusBarItem)
{
Expand All @@ -283,52 +335,16 @@ void removeBT()
HOOKMESSAGE(UIApplication, addStatusBarImageNamed:removeOnExit:, addStatusBarImageNamed$removeOnExit$);
HOOKMESSAGE(UIApplication, addStatusBarImageNamed:, addStatusBarImageNamed$);
HOOKMESSAGE(UIApplication, removeStatusBarImageNamed:, removeStatusBarImageNamed$);
HOOKMESSAGE(UIApplication, _startWindowServerIfNecessary, _startWindowServerIfNecessary);
}

if($SpringBoard)
{
[StatusBarItemServer sharedInstance];
}
// register as client
[StatusBarItemClient sharedInstance];

// testing stuff...timers used because we are doing this before UIKit has been initialized
/*
{
float delay = 4.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 8.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addPause;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 12.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) removeBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
{
float delay = 16.0f;
CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack) addBT;
CFRunLoopTimerRef waitTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent()+delay, 0.0f, 0, 0, callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetMain(), waitTimer, kCFRunLoopCommonModes);
}
*/

NSLine();

}
}

0 comments on commit 8810f06

Please sign in to comment.