From 1d5a1e4484bc9d408d914df583b7242e7ce99926 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 9 Nov 2014 19:59:41 -0800 Subject: [PATCH] Factor out implementation of condition_ signaling. --- Tweak.mm | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Tweak.mm b/Tweak.mm index d313bb4..1d0a930 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -276,16 +276,18 @@ static void VNCEnabled(); float (*$GSMainScreenScaleFactor)(); -static void OnUserNotification(CFUserNotificationRef notification, CFOptionFlags flags) { +static void VNCAction(rfbNewClientAction action) { [condition_ lock]; + action_ = action; + [condition_ signal]; + [condition_ unlock]; +} +static void OnUserNotification(CFUserNotificationRef notification, CFOptionFlags flags) { if ((flags & 0x3) == 1) - action_ = RFB_CLIENT_ACCEPT; + VNCAction(RFB_CLIENT_ACCEPT); else - action_ = RFB_CLIENT_REFUSE; - - [condition_ signal]; - [condition_ unlock]; + VNCAction(RFB_CLIENT_REFUSE); CFRelease(notification); } @@ -321,10 +323,7 @@ static void OnUserNotification(CFUserNotificationRef notification, CFOptionFlags } if (notification == NULL) { - [condition_ lock]; - action_ = RFB_CLIENT_REFUSE; - [condition_ signal]; - [condition_ unlock]; + VNCAction(RFB_CLIENT_REFUSE); return; } @@ -374,11 +373,9 @@ static void OnUserNotification(CFUserNotificationRef notification, CFOptionFlags @end MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) { - [condition_ lock]; - switch (button) { case 1: - action_ = RFB_CLIENT_ACCEPT; + VNCAction(RFB_CLIENT_ACCEPT); @synchronized (condition_) { [VNCBridge registerClient]; @@ -386,12 +383,10 @@ MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, break; case 2: - action_ = RFB_CLIENT_REFUSE; + VNCAction(RFB_CLIENT_REFUSE); break; } - [condition_ signal]; - [condition_ unlock]; [self dismiss]; } -- 2.47.2