Display the unavailable icon when updating. - Incomplete.

This commit is contained in:
Frank Denis
2012-07-31 20:16:09 -07:00
parent 9551962ca2
commit 5c9a393c49
2 changed files with 23 additions and 2 deletions
+7 -1
View File
@@ -1,5 +1,11 @@
#! /bin/sh
. ./common.inc
if [ -e "${STATES_DIR}/updating" ]; then
echo 'Updating'
exit 0
fi
name='None'
level=0
while read resolver; do
@@ -48,4 +54,4 @@ while read resolver; do
;;
esac
done
echo $name
echo "$name"
@@ -56,6 +56,8 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
} else if ([stateDescription isEqualToString: @"OpenDNS IPv6"]) {
} else if ([stateDescription isEqualToString: @"Localhost"]) {
} else if ([stateDescription isEqualToString: @"Localhost IPv6"]) {
} else if ([stateDescription isEqualToString: @"None"]) {
} else if ([stateDescription isEqualToString: @"Updating"]) {
}
}
@@ -76,6 +78,13 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
return FALSE;
}
- (void) updateLedStatusWaiting
{
NSBundle *bundle = [NSBundle mainBundle];
NSImage *led = [[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"no-network.png"]];
_statusItem.image = led;
}
- (void) updateLedStatus
{
NSBundle *bundle = [NSBundle mainBundle];
@@ -111,6 +120,10 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
currentState = kDNS_CONFIGURATION_OPENDNS;
} else if ([stateDescription isEqualToString: @"OpenDNS IPv6"]) {
currentState = kDNS_CONFIGURATION_OPENDNS;
} else if ([stateDescription isEqualToString: @"None"]) {
currentState = kDNS_CONFIGURATION_UNKNOWN;
} else if ([stateDescription isEqualToString: @"Updating"]) {
currentState = kDNS_CONFIGURATION_UNKNOWN;
} else if (stateDescription.length > 0) {
currentState = kDNS_CONFIGURATION_VANILLA;
}
@@ -126,7 +139,7 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
- (void) periodicallyUpdateStatusWithCurrentConfig {
[self updateStatusWithCurrentConfig];
[NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(periodicallyUpdateStatusWithCurrentConfig) object: nil];
[self performSelector: @selector(periodicallyUpdateStatusWithCurrentConfig) withObject:nil afterDelay: 2.5];
[self performSelector: @selector(periodicallyUpdateStatusWithCurrentConfig) withObject:nil afterDelay: 5.0];
}
- (void) awakeFromNib
@@ -164,12 +177,14 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
}
- (BOOL) setDNSCryptOn {
[self updateLedStatusWaiting];
NSString *res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./switch-to-dnscrypt.sh", nil]];
NSLog(@"%@", res);
return TRUE;
}
- (BOOL) setDNSCryptOff {
[self updateLedStatusWaiting];
NSString *res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./switch-to-dhcp.sh", nil]];
NSLog(@"%@", res);
return TRUE;