Skip to content

Commit

Permalink
Merge pull request #45 from Dirk-/master
Browse files Browse the repository at this point in the history
Version 1.4.5: Localized strings also for preference pane
  • Loading branch information
specialunderwear authored Sep 25, 2020
2 parents 8548ab7 + c93ae2f commit 939a944
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 46 deletions.
6 changes: 3 additions & 3 deletions BuildNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ Sign the pane:
codesign -v -f -s "Developer ID Application: Your Name (ABCDEFG1234)" Hosts.prefPane

Build Package (pane in folder "build"):
pkgbuild --root build --identifier "nl.your-domain.hosts" --version "1.4.4" --install-location "/Library/PreferencePanes" --sign "Developer ID Installer: Your Name (ABCDEFG1234)" Hosts-PrefPane-1.4.4.pkg
pkgbuild --root build --identifier "nl.your-domain.hosts" --version "1.4.5" --install-location "/Library/PreferencePanes" --sign "Developer ID Installer: Your Name (ABCDEFG1234)" Hosts-PrefPane-1.4.5.pkg

To certify the installer, you need your ProviderShortname. For this, you have to give altool its app-specific password:
xcrun altool --list-providers -u "[email protected]" -p "@keychain:Developer-altool"

Certify package:
xcrun altool --notarize-app --primary-bundle-id "nl.your-domain.hosts" --username "[email protected]" --password "@keychain:Developer-altool" --asc-provider "YourName123456" --file "Hosts-PrefPane-1.4.4.pkg"
xcrun altool --notarize-app --primary-bundle-id "nl.your-domain.hosts" --username "[email protected]" --password "@keychain:Developer-altool" --asc-provider "YourName123456" --file "Hosts-PrefPane-1.4.5.pkg"

Wait, check status:
xcrun altool --notarization-info "YourRequestUUID" --username "[email protected]" --password "@keychain:Developer-altool"

Staple notarization ticket to package for offline installation:
xcrun stapler staple Hosts-PrefPane-1.4.4.pkg
xcrun stapler staple Hosts-PrefPane-1.4.5.pkg


Issue with Check Box disabling:
Expand Down
24 changes: 13 additions & 11 deletions Hosts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1130;
LastUpgradeCheck = 1200;
TargetAttributes = {
8D1107260486CEB800E47090 = {
DevelopmentTeam = PZV4XW8XL7;
Expand Down Expand Up @@ -652,7 +652,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_TEAM = PZV4XW8XL7;
Expand All @@ -668,7 +668,7 @@
HEADER_SEARCH_PATHS = $SRCROOT;
INFOPLIST_FILE = "Hosts-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 1.4.4;
MARKETING_VERSION = 1.4.5;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "de.dirk-froehling.hosts";
PRODUCT_NAME = Hosts;
Expand All @@ -683,7 +683,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_TEAM = PZV4XW8XL7;
Expand All @@ -693,7 +693,7 @@
HEADER_SEARCH_PATHS = $SRCROOT;
INFOPLIST_FILE = "Hosts-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 1.4.4;
MARKETING_VERSION = 1.4.5;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "de.dirk-froehling.hosts";
Expand All @@ -707,7 +707,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
Expand All @@ -721,6 +721,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -755,7 +756,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
Expand All @@ -769,6 +770,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -827,7 +829,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = PZV4XW8XL7;
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -845,7 +847,7 @@
INFOPLIST_FILE = "HostsPrefpane/HostsPrefpane-Info.plist";
INSTALL_PATH = "$(HOME)/Library/PreferencePanes";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 1.4.4;
MARKETING_VERSION = 1.4.5;
PRODUCT_BUNDLE_IDENTIFIER = "de.dirk-froehling.hosts";
PRODUCT_NAME = Hosts;
PROVISIONING_PROFILE = "";
Expand All @@ -861,7 +863,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = PZV4XW8XL7;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
Expand All @@ -873,7 +875,7 @@
INFOPLIST_FILE = "HostsPrefpane/HostsPrefpane-Info.plist";
INSTALL_PATH = "$(HOME)/Library/PreferencePanes";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 1.4.4;
MARKETING_VERSION = 1.4.5;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "de.dirk-froehling.hosts";
PRODUCT_NAME = Hosts;
Expand Down
2 changes: 1 addition & 1 deletion Hosts.xcodeproj/xcshareddata/xcschemes/HostsApp.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:Hosts.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
6 changes: 1 addition & 5 deletions Hosts.xcodeproj/xcshareddata/xcschemes/parser.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:Hosts.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for helping getting the latest release done!
![](https://github.com/specialunderwear/Hosts.prefpane/raw/master/screenshots/edit.png)

## Download
For now you'll find the latest pre-built preference pane and the app on [Dirk-'s website](https://www.dirk-froehling.de/downloads/downloads.html). ``Hosts App 1.4.4.zip`` includes the app which can be used from any location on your disk. ``Hosts PrefPane 1.4.4.pkg`` is an installer for the preference pane. It will get installed into ``/Library/PreferencePanes``, so you have to enter your admin credentials during installation. The installer is neccessary for macOS Catalina, since all executables have to be notarized, and you cannot notarize a preference pane.
For now you'll find the latest pre-built preference pane and the app on [Dirk-'s website](https://www.dirk-froehling.de/downloads/downloads.html). ``Hosts App 1.4.5.zip`` includes the app which can be used from any location on your disk. ``Hosts PrefPane 1.4.5.pkg`` is an installer for the preference pane. It will get installed into ``/Library/PreferencePanes``, so you have to enter your admin credentials during installation. The installer is neccessary for macOS Catalina, since all executables have to be notarized, and you cannot notarize a preference pane.

## Development hints
### Compiling the parser
Expand Down
6 changes: 3 additions & 3 deletions c/parser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ ifneq ($(BISON_VERSION_GT_2_5), 1)
endif

all: .PHONY libs
gcc -o hosts -g main.c hostsparser.o
gcc -Wno-implicit-function-declaration -o hosts -g main.c hostsparser.o

libs: .PHONY
$(BISON_PATH) -d hostsparser.y
flex --header-file=hostsscanner.h hostsparser.yy
$(BISON_PATH) --report=state hostsparser.y
cc -c -g hosts.c lex.NLPERMANENTMARKERSHOSTS.c hostsparser.tab.c
cc -Wno-implicit-function-declaration -c -g hosts.c lex.NLPERMANENTMARKERSHOSTS.c hostsparser.tab.c
ld -r hosts.o lex.NLPERMANENTMARKERSHOSTS.o hostsparser.tab.o -o hostsparser.o
release: clean libs
gcc -O3 -o hosts main.c hostsparser.o
gcc -Wno-implicit-function-declaration -O3 -o hosts main.c hostsparser.o
strip hosts

clean:
Expand Down
11 changes: 7 additions & 4 deletions pm/controllers/NLPERMANENTMARKERSHOSTSListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ - (IBAction) confirmDeleteItem:(id)sender {
NSUInteger at_index = [self selectionIndex];
NLPERMANENTMARKERSHOSTSHostEntry *entry = [[self arrangedObjects] objectAtIndex:at_index];

NSString *title = NSLocalizedString(@"Confirm deletion", @"deletion: title");
NSString *description = NSLocalizedString(
@"Are you sure you want to permanently remove:\n%@ from /etc/hosts?", @"deletion: message format string");
NSString *title = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Confirm deletion" value:@"" table:nil];
NSString *description = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Are you sure you want to permanently remove:\n%@ from /etc/hosts?" value:@"" table:nil];
description = [NSString stringWithFormat:description, [entry toString]];
NSAlert *alert = [NSAlert alertWithMessageText:title defaultButton:NSLocalizedString(@"Yes", nil) alternateButton:NSLocalizedString(@"No", nil) otherButton:nil informativeTextWithFormat:@"%@", description];
NSAlert *alert = [NSAlert alertWithMessageText:title
defaultButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Yes" value:@"" table:nil]
alternateButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"No" value:@"" table:nil]
otherButton:nil
informativeTextWithFormat:@"%@", description];
[alert beginSheetModalForWindow:[[NSApplication sharedApplication] mainWindow] modalDelegate:self didEndSelector:@selector(alertEnded:code:context:) contextInfo:NULL];
}

Expand Down
8 changes: 4 additions & 4 deletions pm/models/NLPERMANENTMARKERSHOSTSFileModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ - (void) insertObject:(id)object inHostsAtIndex:(NSUInteger) index {
if (undoManager != nil) {
[[undoManager prepareWithInvocationTarget:self] removeObjectFromHostsAtIndex:index];
if ([undoManager isUndoing]) {
NSString * undoActionName = NSLocalizedString(@"Delete host entry", @"undo: redo insert");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
} else {
NSString * undoActionName = NSLocalizedString(@"Insert host entry", @"undo: undo delete");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
}
}
Expand All @@ -83,10 +83,10 @@ - (void) removeObjectFromHostsAtIndex:(NSUInteger) index {
[undoManager removeAllActionsWithTarget:deletedObject];
[[undoManager prepareWithInvocationTarget:self] insertObject:deletedObject inHostsAtIndex:index];
if ([undoManager isUndoing]) {
NSString * undoActionName = NSLocalizedString(@"Insert host entry", @"undo: redo delete");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
} else {
NSString * undoActionName = NSLocalizedString(@"Delete host entry", @"undo: undo insert");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
}
}
Expand Down
7 changes: 3 additions & 4 deletions pm/models/NLPERMANENTMARKERSHOSTSHostEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (void) pushUndoState:(NSDictionary *)change withManager:(NSUndoManager *)undoM
}
NSLog(@"old value %@", oldValue);
[[undoManager prepareWithInvocationTarget:self] setValue:oldValue forKeyPath:keyPath];
NSString * undoActionName = NSLocalizedString(@"Edit", @"undo: undo edit");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Edit" value:@"" table:nil];
[undoManager setActionName:undoActionName];

}
Expand All @@ -101,7 +101,7 @@ - (BOOL) validateAddress:(id *)ioValue error:(NSError **)outError {
} else {
NSLog(@"is not an ip");
if (outError != NULL) {
NSString * errorStr = NSLocalizedString(@"Please enter a valid ip address", @"validation: valid ip address");
NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid ip address" value:@"" table:nil];
NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr
forKey:NSLocalizedDescriptionKey];
NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN
Expand Down Expand Up @@ -130,8 +130,7 @@ - (BOOL) validateHostnames:(id *)ioValue error:(NSError **) outError {
return YES;
} else {
if (outError != NULL) {
NSString * errorStr = NSLocalizedString(@"Please enter a valid hostname",
@"validation: valid hostname");
NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid hostname" value:@"" table:nil];
NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr
forKey:NSLocalizedDescriptionKey];
NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN
Expand Down
32 changes: 27 additions & 5 deletions pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
#import "pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.h"
#import "pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h"


// We need a class here to find the NSBundle for string localization.
// In case we run this as a Pref Pane, NSLocalizedString does not help, and since the
// strings are needed outside a class, we just declare one here.
@interface LocalizationSupportClass: NSObject
@end

@implementation LocalizationSupportClass
@end


// defined in NLPERMANENTMARKERSHOSTSFileModel.m
extern NSMutableArray * NLPERMANENTMARKERSHOSTShostsEntries;

Expand All @@ -33,13 +44,24 @@ void NLPERMANENTMARKERSHOSTSonHostEntryFound(NLPERMANENTMARKERSHOSTS_CHostEntry

// error handler for the hosts file parser
void NLPERMANENTMARKERSHOSTSonHostsParseError(NLPERMANENTMARKERSHOSTS_CHostEntryError * error) {
NSString *windowTitle = NSLocalizedString(@"Parse error", @"error: title");
NSString *errorFormatString = NSLocalizedString(@"In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error.",
@"error: description");
LocalizationSupportClass *foo = [[LocalizationSupportClass alloc] init];
NSBundle *myBundle = [NSBundle bundleForClass:[foo class]];

NSString *windowTitle = [myBundle localizedStringForKey:@"Parse error" value:@"" table:nil];
NSString *errorFormatString = [myBundle localizedStringForKey:@"In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error."
value:@""
table:nil];

NSString *errorString = [NSString stringWithFormat:errorFormatString, error->linenumber, error->token, error->error];

NSInteger choice = NSRunAlertPanel(windowTitle, @"%@", errorString, NSLocalizedString(@"No", nil), nil, NSLocalizedString(@"Yes", nil));
if (choice == NSAlertDefaultReturn) {
NSAlert *alert = [NSAlert
alertWithMessageText:windowTitle
defaultButton:[myBundle localizedStringForKey:@"Yes" value:@"" table:nil]
alternateButton:[myBundle localizedStringForKey:@"No" value:@"" table:nil]
otherButton:nil
informativeTextWithFormat:@"%@", errorString];

if ([alert runModal] == NSModalResponseCancel) {
[[NSApplication sharedApplication] terminate:nil];
}
}

0 comments on commit 939a944

Please sign in to comment.