diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index dce378f..3cac9d9 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -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}" @@ -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" diff --git a/package/requirements.plist b/package/requirements.plist new file mode 100644 index 0000000..d5d92e8 --- /dev/null +++ b/package/requirements.plist @@ -0,0 +1,10 @@ + + + + + os + + 10.10 + + + diff --git a/src/HITDevKit/HITDevKit.xcodeproj/project.pbxproj b/src/HITDevKit/HITDevKit.xcodeproj/project.pbxproj index 280f617..3f849f0 100644 --- a/src/HITDevKit/HITDevKit.xcodeproj/project.pbxproj +++ b/src/HITDevKit/HITDevKit.xcodeproj/project.pbxproj @@ -203,7 +203,7 @@ E1B2C8C81B59351B005A9936 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E1B2C8D01B59351B005A9936 = { @@ -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 */; @@ -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; @@ -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; diff --git a/src/HITDevKit/HITDevKit/HITAdvancedPlugin.h b/src/HITDevKit/HITDevKit/HITAdvancedPlugin.h index 261dd83..5e6d259 100644 --- a/src/HITDevKit/HITDevKit/HITAdvancedPlugin.h +++ b/src/HITDevKit/HITDevKit/HITAdvancedPlugin.h @@ -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 diff --git a/src/HITDevKit/HITDevKit/HITAdvancedPlugin.m b/src/HITDevKit/HITDevKit/HITAdvancedPlugin.m index 516a98c..fa1dd75 100644 --- a/src/HITDevKit/HITDevKit/HITAdvancedPlugin.m +++ b/src/HITDevKit/HITDevKit/HITAdvancedPlugin.m @@ -7,10 +7,12 @@ // #import "HITAdvancedPlugin.h" +#import @interface HITAdvancedPlugin () { HITPluginTestState _testState; } +@property id pluginsManager; @end @@ -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; } diff --git a/src/HITDevKit/HITDevKit/HITPluginProtocol.h b/src/HITDevKit/HITDevKit/HITPluginProtocol.h index f51a763..9b0166a 100644 --- a/src/HITDevKit/HITDevKit/HITPluginProtocol.h +++ b/src/HITDevKit/HITDevKit/HITPluginProtocol.h @@ -21,6 +21,9 @@ typedef NS_ENUM(NSUInteger, HITPluginTestState) { @protocol HITPluginsManagerProtocol - (Class)mainClassForPluginWithFunctionIdentifier:(NSString*)functionIdentifier; - (void)registerPluginInstanceAsNetworkRelated:(id)plugin; +- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id)sender; +- (void)sendNotification:(NSUserNotification*)notification from:(id)sender; + @end @protocol HITPluginProtocol @@ -41,4 +44,6 @@ typedef NS_ENUM(NSUInteger, HITPluginTestState) { - (BOOL)isNetworkRelated; - (void)generalNetworkStateUpdate:(BOOL)state; +- (void)actionFromNotification:(NSUserNotification*)notification; + @end diff --git a/src/HITDevKit/HITDevKit/Info.plist b/src/HITDevKit/HITDevKit/Info.plist index 5237667..c0b981a 100644 --- a/src/HITDevKit/HITDevKit/Info.plist +++ b/src/HITDevKit/HITDevKit/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 NSHumanReadableCopyright Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved. NSPrincipalClass diff --git a/src/Hello IT.xcodeproj/project.pbxproj b/src/Hello IT.xcodeproj/project.pbxproj index de8703e..4808051 100644 --- a/src/Hello IT.xcodeproj/project.pbxproj +++ b/src/Hello IT.xcodeproj/project.pbxproj @@ -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 */; diff --git a/src/Hello IT/AppDelegate.m b/src/Hello IT/AppDelegate.m index 90a4fec..e06e852 100644 --- a/src/Hello IT/AppDelegate.m +++ b/src/Hello IT/AppDelegate.m @@ -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 statusMenuManager; -@property NSMutableArray *pluginInstances; @property Reachability *reachability; @property id notificationObjectForInterfaceTheme; @@ -41,7 +40,6 @@ @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.menuOK = NO; - self.pluginInstances = [NSMutableArray new]; asl_add_log_file(NULL, STDERR_FILENO); @@ -328,4 +326,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } } + + @end diff --git a/src/Hello IT/HITPluginsManager.h b/src/Hello IT/HITPluginsManager.h index b32a206..20578bc 100644 --- a/src/Hello IT/HITPluginsManager.h +++ b/src/Hello IT/HITPluginsManager.h @@ -15,4 +15,7 @@ - (void)loadPluginsWithCompletionHandler:(void(^)(HITPluginsManager *pluginsManager))handler; - (Class)mainClassForPluginWithFunctionIdentifier:(NSString*)functionIdentifier; +- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id)sender; +- (void)sendNotification:(NSUserNotification*)notification from:(id)sender; + @end diff --git a/src/Hello IT/HITPluginsManager.m b/src/Hello IT/HITPluginsManager.m index 7ed0c80..15115f4 100644 --- a/src/Hello IT/HITPluginsManager.m +++ b/src/Hello IT/HITPluginsManager.m @@ -16,10 +16,11 @@ #import "Reachability.h" #import -@interface HITPluginsManager () +@interface HITPluginsManager () @property NSDictionary *pluginURLPerFunctionIdentifier; @property NSMutableDictionary *loadedPluginsPerFunctionIdentifier; @property NSMutableArray *networkRelatedPluginInstances; +@property NSMutableDictionary *pluginsAwaitingForNotifications; @end @implementation HITPluginsManager @@ -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; @@ -217,5 +220,58 @@ - (BOOL)directoryUsableAtURL:(NSURL*)URL { return pathExist && isFolder; } +#pragma mark - Notifications Management + +- (void)sendNotificationWithTitle:(NSString*)title andMessage:(NSString*)message from:(id)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)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 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 diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 69d5b2b..aece64e 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.2 + 1.4.3 CFBundleSignature ???? CFBundleVersion - 304 + 319 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/src/Plugins/ADPass/ADPass.xcodeproj/project.pbxproj b/src/Plugins/ADPass/ADPass.xcodeproj/project.pbxproj index 1da8e37..14db863 100644 --- a/src/Plugins/ADPass/ADPass.xcodeproj/project.pbxproj +++ b/src/Plugins/ADPass/ADPass.xcodeproj/project.pbxproj @@ -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 */; diff --git a/src/Plugins/ADPass/ADPass/HITPADPass.m b/src/Plugins/ADPass/ADPass/HITPADPass.m index 0a60c83..df67a36 100644 --- a/src/Plugins/ADPass/ADPass/HITPADPass.m +++ b/src/Plugins/ADPass/ADPass/HITPADPass.m @@ -27,7 +27,7 @@ #define kHITPADPassAlertXDaysBefore @"alertXDaysBefore" -@interface HITPADPass () +@interface HITPADPass () @property NSDate *passwordExpiryDate; @property BOOL lastADRequestSucceded; @@ -47,6 +47,8 @@ @interface HITPADPass () @property NSInteger alertXDaysBefore; +@property id pluginsManager; + @end @implementation HITPADPass @@ -55,8 +57,6 @@ - (instancetype)initWithSettings:(NSDictionary*)settings { self = [super initWithSettings:settings]; if (self) { - [NSUserNotificationCenter defaultUserNotificationCenter].delegate = self; - if ([settings.allKeys containsObject:kHITPADPassAlertXDaysBefore]) { _alertXDaysBefore = [[settings objectForKey:kHITPADPassAlertXDaysBefore] integerValue]; } else { @@ -145,6 +145,7 @@ - (void)periodicAction:(NSTimer *)timer { - (void)updateTitle { NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:[NSDate date] toDate:self.passwordExpiryDate options:0]; long daysBeforeExpiry = (long)[components day]; + if (daysBeforeExpiry < 0) daysBeforeExpiry = 0; self.menuItem.title = [NSString stringWithFormat:self.willExpireFormat, daysBeforeExpiry]; @@ -265,15 +266,12 @@ - (void)sendUserNotification { [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:kHITPADPassLastNotifKey]; + + [self.pluginsManager sendNotification:notification from:self]; } -- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification { +- (void)actionFromNotification:(NSUserNotification*)notification { [self mainAction:notification]; - [center removeDeliveredNotification:notification]; -} - --(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(nonnull NSUserNotification *)notification { - return YES; } @end diff --git a/src/Plugins/CachetHQ/CachetHQ.xcodeproj/project.pbxproj b/src/Plugins/CachetHQ/CachetHQ.xcodeproj/project.pbxproj index c04e747..a8ecfb4 100644 --- a/src/Plugins/CachetHQ/CachetHQ.xcodeproj/project.pbxproj +++ b/src/Plugins/CachetHQ/CachetHQ.xcodeproj/project.pbxproj @@ -152,6 +152,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = F8B6573120C727D7009F31B6; productRefGroup = F8B6573B20C727D7009F31B6 /* Products */; diff --git a/src/Plugins/OpenApplication/OpenApplication.xcodeproj/project.pbxproj b/src/Plugins/OpenApplication/OpenApplication.xcodeproj/project.pbxproj index 77dfca4..0862a79 100644 --- a/src/Plugins/OpenApplication/OpenApplication.xcodeproj/project.pbxproj +++ b/src/Plugins/OpenApplication/OpenApplication.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E14B67951B57855F00941A27 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E14B679C1B57855F00941A27 = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E14B67981B57855F00941A27 /* Build configuration list for PBXProject "OpenApplication" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E14B67941B57855F00941A27; productRefGroup = E14B679E1B57855F00941A27 /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/OpenApplication/OpenApplication/Info.plist b/src/Plugins/OpenApplication/OpenApplication/Info.plist index aefa7bb..3b0ba15 100644 --- a/src/Plugins/OpenApplication/OpenApplication/Info.plist +++ b/src/Plugins/OpenApplication/OpenApplication/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.open.application NSHumanReadableCopyright diff --git a/src/Plugins/OpenResource/OpenResource.xcodeproj/project.pbxproj b/src/Plugins/OpenResource/OpenResource.xcodeproj/project.pbxproj index 2ae46f7..d93ca70 100644 --- a/src/Plugins/OpenResource/OpenResource.xcodeproj/project.pbxproj +++ b/src/Plugins/OpenResource/OpenResource.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E1D068211B51E54E00567172 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E1D068281B51E54E00567172 = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E1D068241B51E54E00567172 /* Build configuration list for PBXProject "OpenResource" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E1D068201B51E54E00567172; productRefGroup = E1D0682A1B51E54E00567172 /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/OpenResource/OpenResource/Info.plist b/src/Plugins/OpenResource/OpenResource/Info.plist index b1edb85..761b49b 100644 --- a/src/Plugins/OpenResource/OpenResource/Info.plist +++ b/src/Plugins/OpenResource/OpenResource/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.open.resource NSHumanReadableCopyright diff --git a/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj b/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj index 74984dc..54b707c 100644 --- a/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj +++ b/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj @@ -122,11 +122,12 @@ }; buildConfigurationList = E1AF403C1B529AA10017B4DD /* Build configuration list for PBXProject "Quit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, fr, + Base, ); mainGroup = E1AF40381B529AA10017B4DD; productRefGroup = E1AF40421B529AA10017B4DD /* Products */; diff --git a/src/Plugins/Quit/Quit/Info.plist b/src/Plugins/Quit/Quit/Info.plist index b93fc8f..9ccc148 100644 --- a/src/Plugins/Quit/Quit/Info.plist +++ b/src/Plugins/Quit/Quit/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.quit NSHumanReadableCopyright diff --git a/src/Plugins/Quit/Quit/en.lproj/Localizable.strings b/src/Plugins/Quit/Quit/en.lproj/Localizable.strings index cc8eb4f..c17e03d 100644 --- a/src/Plugins/Quit/Quit/en.lproj/Localizable.strings +++ b/src/Plugins/Quit/Quit/en.lproj/Localizable.strings @@ -1,2 +1,2 @@ -/* Status bar menu item allowing user to quit the application */ -"QUIT_SERVICE" = "Quit"; +/* Status bar menu item allowing user to quit the application */ +"QUIT_SERVICE" = "Reload"; diff --git a/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings b/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings index 1b2c5d4..ec0dd31 100644 --- a/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings +++ b/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings @@ -1,3 +1,3 @@ -/* Status bar menu item allowing user to quit the application */ -"QUIT_SERVICE" = "Quitter"; +/* Status bar menu item allowing user to quit the application */ +"QUIT_SERVICE" = "Recharger"; diff --git a/src/Plugins/ScriptedItem/ScriptedItem.xcodeproj/project.pbxproj b/src/Plugins/ScriptedItem/ScriptedItem.xcodeproj/project.pbxproj index f3a0ef4..d7f8fa0 100644 --- a/src/Plugins/ScriptedItem/ScriptedItem.xcodeproj/project.pbxproj +++ b/src/Plugins/ScriptedItem/ScriptedItem.xcodeproj/project.pbxproj @@ -96,7 +96,7 @@ E14B67BD1B59059000941A27 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E14B67C41B59059000941A27 = { @@ -108,10 +108,11 @@ }; buildConfigurationList = E14B67C01B59059000941A27 /* Build configuration list for PBXProject "ScriptedItem" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E14B67BC1B59059000941A27; productRefGroup = E14B67C61B59059000941A27 /* Products */; @@ -167,6 +168,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; @@ -220,6 +222,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; diff --git a/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m b/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m index 57d7ff0..604a0de 100644 --- a/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m +++ b/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m @@ -42,7 +42,7 @@ - (instancetype)initWithSettings:(NSDictionary*)settings if (self) { _network = [[settings objectForKey:kHITPSubCommandNetworkRelated] boolValue]; _script = [[settings objectForKey:kHITPSubCommandScriptPath] stringByExpandingTildeInPath]; - + if ([_script length] == 0) { _script = [[NSString stringWithFormat:kHITPCustomScriptsPath] stringByAppendingPathComponent:[settings objectForKey:kHITPSubCommandScriptName]]; } @@ -122,7 +122,8 @@ -(void)generalNetworkStateUpdate:(BOOL)state { - (void)runScriptWithCommand:(NSString*)command { if (self.scriptChecked && self.allowedToRun) { asl_log(NULL, NULL, ASL_LEVEL_INFO, "Start script with command %s", [command cStringUsingEncoding:NSUTF8StringEncoding]); - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:self.script]; @@ -134,9 +135,6 @@ - (void)runScriptWithCommand:(NSString*)command { [environment setObject:[[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"scriptLibraries/bash"] forKey:@"HELLO_IT_SCRIPT_SH_LIBRARY"]; - [environment setObject:[[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"scriptLibraries/python"] - forKey:@"HELLO_IT_SCRIPT_PYTHON_LIBRARY"]; - NSMutableArray *finalArgs = [NSMutableArray new]; [finalArgs addObject:command]; @@ -200,8 +198,7 @@ - (void)runScriptWithCommand:(NSString*)command { } @catch (NSException *exception) { asl_log(NULL, NULL, ASL_LEVEL_ERR, "Script failed to run: %s", [[exception reason] UTF8String]); } - - }); + }]; } } @@ -213,7 +210,7 @@ - (void)handleScriptRequest:(NSString*)request { NSString *key = [[[request substringToIndex:limiterRange.location] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] lowercaseString]; NSString *value = [[request substringFromIndex:limiterRange.location+1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; value = [value stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"]; - + if ([key isEqualToString:@"hitp-title"]) { self.menuItem.title = value; @@ -261,6 +258,9 @@ - (void)handleScriptRequest:(NSString*)request { self.menuItem.hidden = NO; } + } else if ([key isEqualToString:@"hitp-notification"]) { + [self sendNotificationWithMessage:value]; + } else if ([key isEqualToString:@"hitp-tooltip"]) { self.menuItem.toolTip = value; @@ -291,4 +291,8 @@ - (void)handleScriptRequest:(NSString*)request { }); } +- (void)actionFromNotification:(NSUserNotification *)notification { + [self runScriptWithCommand:@"notification"]; +} + @end diff --git a/src/Plugins/ScriptedItem/ScriptedItem/Info.plist b/src/Plugins/ScriptedItem/ScriptedItem/Info.plist index 79395a3..df6d4ef 100644 --- a/src/Plugins/ScriptedItem/ScriptedItem/Info.plist +++ b/src/Plugins/ScriptedItem/ScriptedItem/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.script.item NSHumanReadableCopyright diff --git a/src/Plugins/ScriptedItem/scriptLibraries/bash/com.github.ygini.hello-it.scriptlib.sh b/src/Plugins/ScriptedItem/scriptLibraries/bash/com.github.ygini.hello-it.scriptlib.sh index 50fbcab..f2158af 100644 --- a/src/Plugins/ScriptedItem/scriptLibraries/bash/com.github.ygini.hello-it.scriptlib.sh +++ b/src/Plugins/ScriptedItem/scriptLibraries/bash/com.github.ygini.hello-it.scriptlib.sh @@ -22,6 +22,11 @@ function fromCronAction { : } +# override this function to specify what to do when the script is on a periodic run +function fromNotificationAction { +: +} + # override this function to specify the item title when UI is loaded (optional, use it # when your title is always dynamic and can't have a default value). For default value # use the title key in Hello IT's settings. @@ -68,6 +73,12 @@ function updateTooltip { echo "hitp-tooltip: $1" } +# usage: sendNotification "This aren't the droids you're looking for" +# first arg only will be used as new title, don't forget quotes +function sendNotification { + echo "hitp-notification: $1" +} + # usage: emergencyLog "This aren't the droids you're looking for" # first arg only will be used as new title, don't forget quotes function emergencyLog { @@ -144,8 +155,11 @@ function main { network) onNetworkAction $options ;; + notification) + fromNotificationAction $options + ;; *) - echo "Usage: $0 {run|periodic-run|network|title}" + echo "Usage: $0 {run|periodic-run|network|notification|title}" echo "$run_option not recognized" exit 1 ;; diff --git a/src/Plugins/Separator/Separator.xcodeproj/project.pbxproj b/src/Plugins/Separator/Separator.xcodeproj/project.pbxproj index cd3ce7f..6659063 100644 --- a/src/Plugins/Separator/Separator.xcodeproj/project.pbxproj +++ b/src/Plugins/Separator/Separator.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E17743631B51F19B00A5B406 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E177436A1B51F19B00A5B406 = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E17743661B51F19B00A5B406 /* Build configuration list for PBXProject "Separator" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E17743621B51F19B00A5B406; productRefGroup = E177436C1B51F19B00A5B406 /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/Separator/Separator/Info.plist b/src/Plugins/Separator/Separator/Info.plist index ae6ce1f..201d7fb 100644 --- a/src/Plugins/Separator/Separator/Info.plist +++ b/src/Plugins/Separator/Separator/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.separator NSHumanReadableCopyright diff --git a/src/Plugins/SubMenu/SubMenu.xcodeproj/project.pbxproj b/src/Plugins/SubMenu/SubMenu.xcodeproj/project.pbxproj index 6f5bcaa..a0fbbfa 100644 --- a/src/Plugins/SubMenu/SubMenu.xcodeproj/project.pbxproj +++ b/src/Plugins/SubMenu/SubMenu.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E1AF405E1B529F460017B4DD /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E1AF40651B529F460017B4DD = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E1AF40611B529F460017B4DD /* Build configuration list for PBXProject "SubMenu" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E1AF405D1B529F460017B4DD; productRefGroup = E1AF40671B529F460017B4DD /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/SubMenu/SubMenu/Info.plist b/src/Plugins/SubMenu/SubMenu/Info.plist index 46433bf..190c02a 100644 --- a/src/Plugins/SubMenu/SubMenu/Info.plist +++ b/src/Plugins/SubMenu/SubMenu/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.submenu NSHumanReadableCopyright diff --git a/src/Plugins/TestHTTP/TestHTTP.xcodeproj/project.pbxproj b/src/Plugins/TestHTTP/TestHTTP.xcodeproj/project.pbxproj index b7f2728..edb45c8 100644 --- a/src/Plugins/TestHTTP/TestHTTP.xcodeproj/project.pbxproj +++ b/src/Plugins/TestHTTP/TestHTTP.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E12F1E381B52355B005A4418 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E12F1E3F1B52355B005A4418 = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E12F1E3B1B52355B005A4418 /* Build configuration list for PBXProject "TestHTTP" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E12F1E371B52355B005A4418; productRefGroup = E12F1E411B52355B005A4418 /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/TestHTTP/TestHTTP/HITPTestHTTP.m b/src/Plugins/TestHTTP/TestHTTP/HITPTestHTTP.m index 768cf6b..050f32b 100644 --- a/src/Plugins/TestHTTP/TestHTTP/HITPTestHTTP.m +++ b/src/Plugins/TestHTTP/TestHTTP/HITPTestHTTP.m @@ -66,7 +66,7 @@ - (instancetype)initWithSettings:(NSDictionary*)settings } } - + NSNumber *timeout = [settings objectForKey:kHITPTestHTTPTimeout]; if (timeout) { _timeout = [timeout integerValue]; @@ -154,7 +154,6 @@ -(void)mainAction:(id)sender { } } }]; - }); } else { diff --git a/src/Plugins/TestHTTP/TestHTTP/Info.plist b/src/Plugins/TestHTTP/TestHTTP/Info.plist index 98ac321..f1bec94 100644 --- a/src/Plugins/TestHTTP/TestHTTP/Info.plist +++ b/src/Plugins/TestHTTP/TestHTTP/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.test.http NSHumanReadableCopyright diff --git a/src/Plugins/Title/Title.xcodeproj/project.pbxproj b/src/Plugins/Title/Title.xcodeproj/project.pbxproj index a15d8af..dc4ef7c 100644 --- a/src/Plugins/Title/Title.xcodeproj/project.pbxproj +++ b/src/Plugins/Title/Title.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ E17743821B51F2C900A5B406 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yoann Gini (Open Source Project)"; TargetAttributes = { E17743891B51F2C900A5B406 = { @@ -105,10 +105,11 @@ }; buildConfigurationList = E17743851B51F2C900A5B406 /* Build configuration list for PBXProject "Title" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E17743811B51F2C900A5B406; productRefGroup = E177438B1B51F2C900A5B406 /* Products */; @@ -163,6 +164,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; @@ -216,6 +218,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; diff --git a/src/Plugins/Title/Title/Info.plist b/src/Plugins/Title/Title/Info.plist index b4e1dbf..0b396ed 100644 --- a/src/Plugins/Title/Title/Info.plist +++ b/src/Plugins/Title/Title/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 319 HITPFunctionIdentifier public.title NSHumanReadableCopyright