diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h index 9116178..97e1507 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h +++ b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h @@ -11,11 +11,11 @@ #define kDNSCRYPT_PACKAGE_VERSION @"0.12" -#define KDNSCRYPT_CONFIG_UPDATER_LABEL @"com.opendns.osx.DNSCryptConfigUpdater" -#define KDNSCRYPT_PROXY_LABEL @"com.opendns.osx.DNSCryptProxy" - -#define kDNSCRYPT_PREFPANE_SUPPORT_DIR @"DNSCrypt Prefpane" -#define kDNSCRYPT_PREFPANE_FILE @"PrefPane.plist" +#define kDNSCRYPT_PREFPANE_APP_PATH @"/Library/PreferencePanes/DNSCrypt.prefPane" +#define kDNSCRYPT_USR_BASE_DIR kDNSCRYPT_PREFPANE_APP_PATH @"/Contents/Resources/usr" +#define kDNSCRIPT_SCRIPTS_BASE_DIR kDNSCRYPT_USR_BASE_DIR @"/scripts" +#define kDNSCRYPT_VAR_BASE_DIR @"/Library/Application Support/DNSCrypt" +#define kDNSCRYPT_CONTROL_DIR kDNSCRYPT_VAR_BASE_DIR @"/control" #define kOPENDNS_URL @"http://www.opendns.com" @@ -31,10 +31,10 @@ typedef enum { AuthorizationRef auth; } -@property (weak) IBOutlet NSButton *enableDNSCryptButton; -@property (weak) IBOutlet NSButton *enableOpenDNSButton; +@property (weak) IBOutlet NSButton *dnscryptButton; +@property (weak) IBOutlet NSButton *opendnsButton; @property (weak) IBOutlet NSButton *familyShieldButton; -@property (weak) IBOutlet NSButton *enableInsecureDNSButton; +@property (weak) IBOutlet NSButton *fallbackButton; @property (weak) IBOutlet NSTextField *currentResolverTextField; @property (weak) IBOutlet NSImageView *statusImageView; @@ -46,8 +46,11 @@ typedef enum { - (void) mainViewDidLoad; -- (IBAction)enableOpenDNSButtonPressed:(NSButton *)sender; -- (IBAction)enableDNSCryptButtonPressed:(NSButton *)sender; +- (IBAction)dnscryptButtonPressed:(NSButton *)sender; +- (IBAction)opendnsButtonPressed:(NSButton *)sender; +- (IBAction)familyShieldButtonPressed:(NSButton *)sender; +- (IBAction)fallbackButtonPressed:(NSButton *)sender; + - (IBAction)openDNSLinkPushed:(NSButton *)sender; @end diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m index 0a672fc..0b38f32 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m +++ b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m @@ -9,18 +9,18 @@ #import "DNSCrypt.h" @implementation DNSCrypt -@synthesize previewNotesWebView; -@synthesize releaseNotesWebView; -@synthesize feedbackWebView; -@synthesize aboutWebView; +@synthesize previewNotesWebView = _previewNotesWebView; +@synthesize releaseNotesWebView = _releaseNotesWebView; +@synthesize feedbackWebView = _feedbackWebView; +@synthesize aboutWebView = _aboutWebView; -@synthesize enableDNSCryptButton; -@synthesize enableOpenDNSButton; -@synthesize enableInsecureDNSButton; -@synthesize familyShieldButton; -@synthesize statusImageView; -@synthesize statusText; -@synthesize currentResolverTextField; +@synthesize dnscryptButton = _dnscryptButton; +@synthesize opendnsButton = _opendnsButton; +@synthesize fallbackButton = _fallbackButton; +@synthesize familyShieldButton = _familyShieldButton; +@synthesize statusImageView = _statusImageView; +@synthesize statusText = _statusText; +@synthesize currentResolverTextField = _currentResolverTextField; DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; @@ -44,26 +44,76 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; return result; } +- (void) initState +{ + NSString *res; + _dnscryptButton.state = 0; + _familyShieldButton.state = 0; + _opendnsButton.state = 0; + _fallbackButton.state = 0; + + res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-dnscrypt-status.sh", nil]]; + NSLog(@"%@", res); + if ([res isEqualToString: @"yes"]) { + [_dnscryptButton setState: 1]; + } + res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-familyshield-status.sh", nil]]; + NSLog(@"%@", res); + if ([res isEqualToString: @"yes"]) { + [_familyShieldButton setState: 1]; + } + res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-insecure-opendns-status.sh", nil]]; + NSLog(@"%@", res); + if ([res isEqualToString: @"yes"]) { + [_opendnsButton setState: 1]; + } + res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-fallback-status.sh", nil]]; + NSLog(@"%@", res); + if ([res isEqualToString: @"yes"]) { + [_fallbackButton setState: 1]; + } + +} + +- (IBAction)dnscryptButtonPressed:(NSButton *)sender +{ + +} + +- (IBAction)opendnsButtonPressed:(NSButton *)sender +{ + +} + +- (IBAction)familyShieldButtonPressed:(NSButton *)sender +{ + +} + +- (IBAction)fallbackButtonPressed:(NSButton *)sender +{ + +} - (void) initializeCheckBoxesWithState: (DNSConfigurationState) currentState { switch (currentState) { case kDNS_CONFIGURATION_OPENDNS: - enableOpenDNSButton.state = NSOnState; - enableDNSCryptButton.state = NSOffState; + _opendnsButton.state = NSOnState; + _dnscryptButton.state = NSOffState; break; case kDNS_CONFIGURATION_LOCALHOST: - enableOpenDNSButton.state = NSOnState; - enableDNSCryptButton.state = NSOnState; + _opendnsButton.state = NSOnState; + _dnscryptButton.state = NSOnState; break; default: - enableOpenDNSButton.state = NSOffState; - enableDNSCryptButton.state = NSOffState; + _opendnsButton.state = NSOffState; + _dnscryptButton.state = NSOffState; } - enableInsecureDNSButton.state = NSOnState; + _fallbackButton.state = NSOnState; } - (BOOL) updateStatusWithCurrentConfig @@ -87,26 +137,26 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; [resolversString appendFormat: @"%s%@", (resolversString.length > 0 ? "\n" : ""), resolver]; } currentState = kDNS_CONFIGURATION_VANILLA; - currentResolverTextField.stringValue = resolversString; + _currentResolverTextField.stringValue = resolversString; } NSBundle *bundle = [NSBundle bundleWithIdentifier: @"com.opendns.osx.DNSCrypt"]; switch (currentState) { case kDNS_CONFIGURATION_UNKNOWN: - statusText.stringValue = NSLocalizedString(@"No network", @"Status"); - statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_red.png"]] autorelease]; + _statusText.stringValue = NSLocalizedString(@"No network", @"Status"); + _statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_red.png"]] autorelease]; break; case kDNS_CONFIGURATION_VANILLA: - statusText.stringValue = NSLocalizedString(@"Unprotected", @"Status"); - statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_red.png"]] autorelease]; + _statusText.stringValue = NSLocalizedString(@"Unprotected", @"Status"); + _statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_red.png"]] autorelease]; break; case kDNS_CONFIGURATION_OPENDNS: - statusText.stringValue = NSLocalizedString(@"Unencrypted", @"Status"); - statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_yellow.png"]] autorelease]; + _statusText.stringValue = NSLocalizedString(@"Unencrypted", @"Status"); + _statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_yellow.png"]] autorelease]; break; case kDNS_CONFIGURATION_LOCALHOST: - statusText.stringValue = NSLocalizedString(@"Protected", @"Status"); - statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_green.png"]] autorelease]; + _statusText.stringValue = NSLocalizedString(@"Protected", @"Status"); + _statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"shield_green.png"]] autorelease]; break; default: return FALSE; @@ -118,9 +168,9 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; - (void) showSpinners { NSBundle *bundle = [NSBundle bundleWithIdentifier: kBUNDLE_IDENTIFIER]; - statusText.stringValue = @""; - statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"ajax-loader.gif"]] autorelease]; - currentResolverTextField.stringValue = @""; + _statusText.stringValue = @""; + _statusImageView.image = [[[NSImage alloc] initWithContentsOfFile: [bundle pathForImageResource: @"ajax-loader.gif"]] autorelease]; + _currentResolverTextField.stringValue = @""; } - (void) periodicallyUpdateStatusWithCurrentConfig { @@ -132,8 +182,10 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; - (void) mainViewDidLoad { currentState = kDNS_CONFIGURATION_UNKNOWN; + [_previewNotesWebView setDrawsBackground:false]; + + [self initState]; [self periodicallyUpdateStatusWithCurrentConfig]; - [previewNotesWebView setDrawsBackground:false]; NSString *version = kDNSCRYPT_PACKAGE_VERSION; NSString *softwareBlurbFormat = NSLocalizedString(@"This software (v: %@) encrypts DNS packets between your computer and OpenDNS. This prevents man-in-the-middle attacks and snooping of DNS traffic by ISPs or others.", @"Description of what the package does - %@ is replaced by the version number"); @@ -153,26 +205,25 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; [htmlString appendFormat: @"
  • %@
  • ", describeFallback]; [htmlString appendString: @""]; [htmlString appendString: @""]; - [[previewNotesWebView mainFrame] loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"file:///"]]; + [[_previewNotesWebView mainFrame] loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"file:///"]]; - [feedbackWebView setDrawsBackground:false]; - [feedbackWebView setShouldUpdateWhileOffscreen:true]; - [feedbackWebView setUIDelegate:self]; + [_feedbackWebView setDrawsBackground:false]; + [_feedbackWebView setShouldUpdateWhileOffscreen:true]; + [_feedbackWebView setUIDelegate:self]; NSString *feedbackURLText = @"http://dnscrypt.opendns.com/feedback.php"; - [[feedbackWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:feedbackURLText]]]; + [[_feedbackWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:feedbackURLText]]]; - [releaseNotesWebView setDrawsBackground:false]; - [releaseNotesWebView setShouldUpdateWhileOffscreen:true]; - [releaseNotesWebView setUIDelegate:self]; + [_releaseNotesWebView setDrawsBackground:false]; + [_releaseNotesWebView setShouldUpdateWhileOffscreen:true]; + [_releaseNotesWebView setUIDelegate:self]; NSString *releaseNotesURLText = @"http://dnscrypt.opendns.com/releasenotes.php"; - [[releaseNotesWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:releaseNotesURLText]]]; + [[_releaseNotesWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:releaseNotesURLText]]]; - [aboutWebView setDrawsBackground:false]; - [aboutWebView setShouldUpdateWhileOffscreen:true]; - [aboutWebView setUIDelegate:self]; + [_aboutWebView setDrawsBackground:false]; + [_aboutWebView setShouldUpdateWhileOffscreen:true]; + [_aboutWebView setUIDelegate:self]; NSString *aboutURLText = @"http://dnscrypt.opendns.com/about.php"; - [[aboutWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aboutURLText]]]; - + [[_aboutWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aboutURLText]]]; } - (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element @@ -186,8 +237,8 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; { [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(resetCheckBoxesHaveBeenInitialized) object: nil]; [self performSelector: @selector(resetCheckBoxesHaveBeenInitialized) withObject: self afterDelay:kCHECKBOXES_FREEZE_DELAY]; - if (enableDNSCryptButton.state == NSOffState) { - if (enableOpenDNSButton.state == NSOffState) { + if (_dnscryptButton.state == NSOffState) { + if (_opendnsButton.state == NSOffState) { currentState = kDNS_CONFIGURATION_VANILLA; } else { currentState = kDNS_CONFIGURATION_OPENDNS; @@ -200,24 +251,24 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN; return TRUE; } -- (IBAction)enableOpenDNSButtonPressed:(NSButton *)sender +- (IBAction)xenableOpenDNSButtonPressed:(NSButton *)sender { - if (sender.state == NSOffState && enableDNSCryptButton.state != NSOffState) { - enableDNSCryptButton.state = NSOffState; + if (sender.state == NSOffState && _dnscryptButton.state != NSOffState) { + _dnscryptButton.state = NSOffState; } [self updateConfig]; } -- (IBAction)enableDNSCryptButtonPressed:(NSButton *)sender +- (IBAction)xenableDNSCryptButtonPressed:(NSButton *)sender { - if (sender.state == NSOnState && enableOpenDNSButton.state != NSOnState) { - enableOpenDNSButton.state = NSOnState; + if (sender.state == NSOnState && _opendnsButton.state != NSOnState) { + _opendnsButton.state = NSOnState; } else if (sender.state == NSOffState) { } [self updateConfig]; } -- (IBAction)enableInsecureDNSButtonPressed:(NSButton *)sender +- (IBAction)xenableInsecureDNSButtonPressed:(NSButton *)sender { if (sender.state == NSOnState) { } else { diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib b/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib index f583d7b..24603a6 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib +++ b/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib @@ -65,7 +65,6 @@ {{13, 10}, {563, 359}} - _NS:461 @@ -74,42 +73,6 @@ 256 - - - 268 - {{15, 212}, {245, 24}} - - - - _NS:239 - YES - - 67108864 - 0 - Enable OpenDNS - - LucidaGrande-Bold - 14 - 16 - - _NS:239 - - 1211912448 - 2 - - NSImage - NSSwitch - - - NSSwitch - - - - 200 - 25 - - NO - 268 @@ -123,13 +86,22 @@ 67108864 0 Enable DNSCrypt - + + LucidaGrande-Bold + 14 + 16 + _NS:239 1211912448 2 - - + + NSImage + NSSwitch + + + NSSwitch + 200 @@ -137,29 +109,25 @@ NO - + 268 - {{15, 133}, {204, 22}} + {{15, 212}, {245, 24}} - + _NS:239 YES - + 67108864 0 - Fallback to insecure DNS - - LucidaGrande - 14 - 16 - + Enable OpenDNS + _NS:239 - + 1211912448 2 - + @@ -181,12 +149,42 @@ 67108864 0 Enable Familyshield - + + LucidaGrande + 14 + 16 + _NS:239 1211912448 2 - + + + + + 200 + 25 + + NO + + + + 268 + {{15, 133}, {204, 22}} + + + _NS:239 + YES + + 67108864 + 0 + Fallback to insecure DNS + + _NS:239 + + 1211912448 + 2 + @@ -698,38 +696,6 @@ 26 - - - enableInsecureDNSButton - - - - 301 - - - - enableInsecureDNSButtonPressed: - - - - 293 - - - - useHTTPSButton - - - - 308 - - - - enableHTTPSButtonPressed: - - - - 309 - statusText @@ -738,22 +704,6 @@ 304 - - - enableDNSCryptButton - - - - 300 - - - - enableDNSCryptButtonPressed: - - - - 292 - currentResolverTextField @@ -762,22 +712,6 @@ 296 - - - enableOpenDNSButton - - - - 294 - - - - enableOpenDNSButtonPressed: - - - - 291 - statusImageView @@ -826,6 +760,70 @@ 359 + + + dnscryptButton + + + + 363 + + + + opendnsButton + + + + 364 + + + + fallbackButton + + + + 365 + + + + familyShieldButton + + + + 366 + + + + dnscryptButtonPressed: + + + + 368 + + + + opendnsButtonPressed: + + + + 369 + + + + familyShieldButtonPressed: + + + + 371 + + + + fallbackButtonPressed: + + + + 372 + @@ -905,12 +903,12 @@ - - + + @@ -1236,7 +1234,7 @@ - 362 + 372 @@ -1244,46 +1242,61 @@ DNSCrypt NSPreferencePane - NSButton - NSButton - NSButton - NSButton + NSButton + NSButton + NSButton NSButton + NSButton + NSButton + NSButton + NSButton - - enableDNSCryptButtonPressed: + + dnscryptButtonPressed: NSButton - - enableHTTPSButtonPressed: + + fallbackButtonPressed: NSButton - - enableInsecureDNSButtonPressed: - NSButton - - - enableOpenDNSButtonPressed: + + familyShieldButtonPressed: NSButton openDNSLinkPushed: NSButton + + opendnsButtonPressed: + NSButton + + + xenableDNSCryptButtonPressed: + NSButton + + + xenableInsecureDNSButtonPressed: + NSButton + + + xenableOpenDNSButtonPressed: + NSButton + WebView NSTextField - NSButton - NSButton - NSButton + NSButton + NSButton + NSButton WebView + NSButton WebView WebView NSImageView NSTextField - NSButton @@ -1294,22 +1307,26 @@ currentResolverTextField NSTextField - - enableDNSCryptButton + + dnscryptButton NSButton - - enableInsecureDNSButton + + fallbackButton NSButton - - enableOpenDNSButton + + familyShieldButton NSButton feedbackWebView WebView + + opendnsButton + NSButton + previewNotesWebView WebView @@ -1326,10 +1343,6 @@ statusText NSTextField - - useHTTPSButton - NSButton - IBProjectSource