From e4ca0842d9f50f89e78395d2fdd9a313ebadde78 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 30 Aug 2009 05:47:02 +0000 Subject: [PATCH] Stupid/silly statusbar bug. --- Tweak.mm | 60 +++++++++++++++++++++++++++++++------------------------- control | 2 +- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Tweak.mm b/Tweak.mm index 9c84689..f969bf6 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -88,18 +88,39 @@ static NSLock *lock_; static rfbClientPtr client_; -static void VNCAccept() { - action_ = RFB_CLIENT_ACCEPT; +@interface VNCBridge : NSObject { +} + ++ (void) askForConnection; ++ (void) removeStatusBarItem; ++ (void) registerClient; + +@end + +@implementation VNCBridge + ++ (void) askForConnection { + [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]]; +} + ++ (void) removeStatusBarItem { + [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"]; +} + ++ (void) registerClient { ++clients_; [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"]; } +@end + MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) { [condition_ lock]; switch (button) { case 1: - VNCAccept(); + action_ = RFB_CLIENT_ACCEPT; + [VNCBridge registerClient]; break; case 2: @@ -125,26 +146,6 @@ MSInstanceMessage0(void, VNCAlertItem, performUnlockAction) { [[$SBAlertItemsController sharedInstance] activateAlertItem:self]; } -@interface VNCBridge : NSObject { -} - -+ (void) askForConnection; -+ (void) removeStatusBarItem; - -@end - -@implementation VNCBridge - -+ (void) askForConnection { - [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]]; -} - -+ (void) removeStatusBarItem { - [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"]; -} - -@end - static mach_port_t (*GSTakePurpleSystemEventPort)(void); static bool PurpleAllocated; static bool Two_; @@ -170,9 +171,10 @@ static void VNCSettings() { [reinterpret_cast(screen_->authPasswdData) release]; screen_->authPasswdData = NULL; - if (NSString *password = [settings objectForKey:@"Password"]) - if ([password length] != 0) - screen_->authPasswdData = [password retain]; + if (settings != nil) + if (NSString *password = [settings objectForKey:@"Password"]) + if ([password length] != 0) + screen_->authPasswdData = [password retain]; } } @@ -356,8 +358,11 @@ static void VNCDisconnect(rfbClientPtr client) { static rfbNewClientAction VNCClient(rfbClientPtr client) { @synchronized (condition_) { - if (screen_->authPasswdData != NULL) + if (screen_->authPasswdData != NULL) { + [VNCBridge performSelectorOnMainThread:@selector(registerClient) withObject:nil waitUntilDone:YES]; + client->clientGoneHook = &VNCDisconnect; return RFB_CLIENT_ACCEPT; + } } [condition_ lock]; @@ -368,6 +373,7 @@ static rfbNewClientAction VNCClient(rfbClientPtr client) { rfbNewClientAction action(action_); action_ = RFB_CLIENT_ON_HOLD; [condition_ unlock]; + if (action == RFB_CLIENT_ACCEPT) client->clientGoneHook = &VNCDisconnect; return action; diff --git a/control b/control index ed16c3a..7298082 100644 --- a/control +++ b/control @@ -5,7 +5,7 @@ Priority: optional Section: Networking Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3022-1 +Version: 0.9.3023-1 Description: a VNC /server/ for the iPhone Name: Veency Depends: mobilesubstrate (>= 0.9.2966-1), libvncserver, com.saurik.iphone.ske, preferenceloader -- 2.47.2