Skip to content

Commit

Permalink
Merge branch 'release/1.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ygini committed Jun 14, 2019
2 parents bc9b8e8 + 2dcb125 commit 023c1db
Show file tree
Hide file tree
Showing 36 changed files with 211 additions and 64 deletions.
7 changes: 5 additions & 2 deletions package/BuildAndPackage.command
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ echo "####### Build project"

echo "### Start building Hello IT"

xcodebuild -quiet -project "${PROJECT_DIR}/Hello IT.xcodeproj" -configuration ${CONFIGURATION} -target "Hello IT" CONFIGURATION_TEMP_DIR="${BUILT_PRODUCTS_DIR}/Intermediates" CONFIGURATION_BUILD_DIR="${BUILT_PRODUCTS_DIR}/Products" DWARF_DSYM_FOLDER_PATH="${BUILT_PRODUCTS_DIR}/dSYM"
xcodebuild -UseModernBuildSystem=NO -quiet -project "${PROJECT_DIR}/Hello IT.xcodeproj" -configuration ${CONFIGURATION} -target "Hello IT" CONFIGURATION_TEMP_DIR="${BUILT_PRODUCTS_DIR}/Intermediates" CONFIGURATION_BUILD_DIR="${BUILT_PRODUCTS_DIR}/Products" DWARF_DSYM_FOLDER_PATH="${BUILT_PRODUCTS_DIR}/dSYM"

cp -r "${BUILT_PRODUCTS_DIR}/Products/Hello IT.app" "${RELEASE_PRODUCT_LOCATION}"

Expand Down Expand Up @@ -104,9 +104,12 @@ PBK_BUILD_COMPONENT="${BUILT_PRODUCTS_DIR}/components.plist"
pkgbuild --analyze --root "${PKG_ROOT}" "${PBK_BUILD_COMPONENT}"

/usr/libexec/PlistBuddy -c "Set 0:BundleIsRelocatable bool false" "${PBK_BUILD_COMPONENT}"
/usr/libexec/PlistBuddy -c "Print" "${PBK_BUILD_COMPONENT}"
#/usr/libexec/PlistBuddy -c "Print" "${PBK_BUILD_COMPONENT}"
pkgbuild --component-plist "${PBK_BUILD_COMPONENT}" --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg"

productbuild --product "${GIT_ROOT_DIR}/package/requirements.plist" --sign "${DEVELOPER_ID_INSTALLER}" --version "${PKG_VERSION}" --package "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}-Distribution.pkg"


rm -rf "${PKG_ROOT}"

echo "####### Cleaning temporary files"
Expand Down
10 changes: 10 additions & 0 deletions package/requirements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>os</key>
<array>
<string>10.10</string>
</array>
</dict>
</plist>
7 changes: 5 additions & 2 deletions src/HITDevKit/HITDevKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
E1B2C8C81B59351B005A9936 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0940;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Yoann Gini (Open Source Project)";
TargetAttributes = {
E1B2C8D01B59351B005A9936 = {
Expand All @@ -218,10 +218,11 @@
};
buildConfigurationList = E1B2C8CB1B59351B005A9936 /* Build configuration list for PBXProject "HITDevKit" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = E1B2C8C71B59351B005A9936;
productRefGroup = E1B2C8D21B59351B005A9936 /* Products */;
Expand Down Expand Up @@ -307,6 +308,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -363,6 +365,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down
10 changes: 10 additions & 0 deletions src/HITDevKit/HITDevKit/HITAdvancedPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@

@interface HITAdvancedPlugin : HITSimplePlugin

#define kHITAdvancedPluginSkipForGlobalStateKey @"skipForGlobalState"

#define kHITNotificationMessageForOKKey @"notificationWhenStateTurnOK"
#define kHITNotificationMessageForNoneKey @"notificationWhenStateTurnNone"
#define kHITNotificationMessageForWarningKey @"notificationWhenStateTurnWarning"
#define kHITNotificationMessageForErrorKey @"notificationWhenStateTurnError"
#define kHITNotificationMessageForUnavailableKey @"notificationWhenStateTurnUnavailable"

@property (nonatomic) HITPluginTestState testState;
@property (nonatomic) BOOL skipForGlobalState;

-(void)sendNotificationWithMessage:(NSString*)message;

@end
23 changes: 20 additions & 3 deletions src/HITDevKit/HITDevKit/HITAdvancedPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//

#import "HITAdvancedPlugin.h"
#import <asl.h>

@interface HITAdvancedPlugin () {
HITPluginTestState _testState;
}
@property id<HITPluginsManagerProtocol> pluginsManager;

@end

Expand All @@ -20,45 +22,60 @@ @implementation HITAdvancedPlugin

- (void)updateMenuItemState {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *notificationMessage = nil;
switch (self.testState) {
case HITPluginTestStateError:
self.menuItem.image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.github.ygini.HITDevKit"] pathForResource:@"Error"
ofType:@"tiff"]];
notificationMessage = [self localizedString:[self.settings objectForKey:kHITNotificationMessageForErrorKey]];
break;
case HITPluginTestStateOK:
self.menuItem.image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.github.ygini.HITDevKit"] pathForResource:@"OK"
ofType:@"tiff"]];
notificationMessage = [self localizedString:[self.settings objectForKey:kHITNotificationMessageForOKKey]];
break;
case HITPluginTestStateWarning:
self.menuItem.image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.github.ygini.HITDevKit"] pathForResource:@"Warning"
ofType:@"tiff"]];
notificationMessage = [self localizedString:[self.settings objectForKey:kHITNotificationMessageForWarningKey]];
break;
case HITPluginTestStateUnavailable:
self.menuItem.image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.github.ygini.HITDevKit"] pathForResource:@"Unavailable"
ofType:@"tiff"]];
notificationMessage = [self localizedString:[self.settings objectForKey:kHITNotificationMessageForUnavailableKey]];
break;
case HITPluginTestStateNone:
default:
self.menuItem.image = nil;
notificationMessage = [self localizedString:[self.settings objectForKey:kHITNotificationMessageForNoneKey]];
break;
}
if (notificationMessage) {
[self sendNotificationWithMessage:notificationMessage];
}
});
}

-(void)sendNotificationWithMessage:(NSString*)message {
[self.pluginsManager sendNotificationWithTitle:self.menuItem.title andMessage:message from:self];
}

-(HITPluginTestState)testState {
return _testState;
}

-(void)setTestState:(HITPluginTestState)testState {
_testState = testState;
[self updateMenuItemState];
if (_testState != testState) {
_testState = testState;
[self updateMenuItemState];
}
}

- (instancetype)initWithSettings:(NSDictionary*)settings
{
self = [super initWithSettings:settings];
if (self) {
_skipForGlobalState = [[settings objectForKey:@"skipForGlobalState"] boolValue];
_skipForGlobalState = [[settings objectForKey:kHITAdvancedPluginSkipForGlobalStateKey] boolValue];
}
return self;
}
Expand Down
5 changes: 5 additions & 0 deletions src/HITDevKit/HITDevKit/HITPluginProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ typedef NS_ENUM(NSUInteger, HITPluginTestState) {
@protocol HITPluginsManagerProtocol <NSObject>
- (Class<HITPluginProtocol>)mainClassForPluginWithFunctionIdentifier:(NSString*)functionIdentifier;
- (void)registerPluginInstanceAsNetworkRelated:(id<HITPluginProtocol>)plugin;
- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id<HITPluginProtocol>)sender;
- (void)sendNotification:(NSUserNotification*)notification from:(id<HITPluginProtocol>)sender;

@end

@protocol HITPluginProtocol <NSObject>
Expand All @@ -41,4 +44,6 @@ typedef NS_ENUM(NSUInteger, HITPluginTestState) {
- (BOOL)isNetworkRelated;
- (void)generalNetworkStateUpdate:(BOOL)state;

- (void)actionFromNotification:(NSUserNotification*)notification;

@end
2 changes: 1 addition & 1 deletion src/HITDevKit/HITDevKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>304</string>
<string>319</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
3 changes: 2 additions & 1 deletion src/Hello IT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,12 @@
};
buildConfigurationList = E1D067F51B51D08E00567172 /* Build configuration list for PBXProject "Hello IT" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
fr,
);
mainGroup = E1D067F11B51D08E00567172;
productRefGroup = E1D067FB1B51D08E00567172 /* Products */;
Expand Down
6 changes: 3 additions & 3 deletions src/Hello IT/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#define kMenuItemSettings @"settings"
#define kMenuItemAllowSubdomains @"allowSubdomains"

@interface AppDelegate ()
@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@property (strong) NSStatusItem *statusItem;
@property id<HITPluginProtocol> statusMenuManager;
@property NSMutableArray *pluginInstances;
@property Reachability *reachability;

@property id notificationObjectForInterfaceTheme;
Expand All @@ -41,7 +40,6 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.menuOK = NO;
self.pluginInstances = [NSMutableArray new];

asl_add_log_file(NULL, STDERR_FILENO);

Expand Down Expand Up @@ -328,4 +326,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
}
}



@end
3 changes: 3 additions & 0 deletions src/Hello IT/HITPluginsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
- (void)loadPluginsWithCompletionHandler:(void(^)(HITPluginsManager *pluginsManager))handler;
- (Class<HITPluginProtocol>)mainClassForPluginWithFunctionIdentifier:(NSString*)functionIdentifier;

- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id<HITPluginProtocol>)sender;
- (void)sendNotification:(NSUserNotification*)notification from:(id<HITPluginProtocol>)sender;

@end
60 changes: 58 additions & 2 deletions src/Hello IT/HITPluginsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#import "Reachability.h"
#import <asl.h>

@interface HITPluginsManager ()
@interface HITPluginsManager () <NSUserNotificationCenterDelegate>
@property NSDictionary *pluginURLPerFunctionIdentifier;
@property NSMutableDictionary *loadedPluginsPerFunctionIdentifier;
@property NSMutableArray *networkRelatedPluginInstances;
@property NSMutableDictionary *pluginsAwaitingForNotifications;
@end

@implementation HITPluginsManager
Expand All @@ -40,8 +41,10 @@ - (instancetype)init
self = [super init];
if (self) {
_loadedPluginsPerFunctionIdentifier = [NSMutableDictionary new];
_pluginsAwaitingForNotifications = [NSMutableDictionary new];
_networkRelatedPluginInstances = [NSMutableArray new];


[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChangedNotification:) name:kReachabilityChangedNotification object:nil];
}
return self;
Expand Down Expand Up @@ -217,5 +220,58 @@ - (BOOL)directoryUsableAtURL:(NSURL*)URL {
return pathExist && isFolder;
}

#pragma mark - Notifications Management

- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id<HITPluginProtocol>)sender {
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Simple notification requested");
NSUserNotification *notification = [NSUserNotification new];

notification.title = title;
notification.hasActionButton = NO;
notification.informativeText = message;

[self sendNotification:notification from:sender];
}

- (void)sendNotification:(NSUserNotification*)notification from:(id<HITPluginProtocol>)sender {
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Notification sent");
NSString *senderID = [[self.pluginsAwaitingForNotifications keysOfEntriesPassingTest:^BOOL(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
if (obj == sender) {
*stop = YES;
return YES;
}
return NO;
}] anyObject];

if (!senderID) {
senderID = [[NSUUID UUID] UUIDString];
[self.pluginsAwaitingForNotifications setObject:sender forKey:senderID];
}

NSMutableDictionary* userInfo = [NSMutableDictionary new];
if (notification.userInfo) {
[userInfo setDictionary:notification.userInfo];
}
[userInfo setObject:senderID forKey:@"senderID"];

notification.userInfo = userInfo;

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
NSString* senderID = [notification.userInfo objectForKey:@"senderID"];
if ([senderID length] > 0) {
id<HITPluginProtocol> sender = [self.pluginsAwaitingForNotifications objectForKey:senderID];
if ([sender respondsToSelector:@selector(actionFromNotification:)]) {
[sender actionFromNotification:notification];
}
}
[center removeDeliveredNotification:notification];
}

-(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(nonnull NSUserNotification *)notification {
return YES;
}

@end
4 changes: 2 additions & 2 deletions src/Hello IT/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.2</string>
<string>1.4.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>304</string>
<string>319</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
3 changes: 2 additions & 1 deletion src/Plugins/ADPass/ADPass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@
};
buildConfigurationList = F83294A01F773076009DA574 /* Build configuration list for PBXProject "ADPass" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
fr,
Base,
);
mainGroup = F832949C1F773076009DA574;
productRefGroup = F83294A61F773076009DA574 /* Products */;
Expand Down
Loading

0 comments on commit 023c1db

Please sign in to comment.