Skip to content

Commit 45c0b23

Browse files
committed
Merge branch 'release/1.3.2'
2 parents f393adc + b2dd565 commit 45c0b23

File tree

22 files changed

+105
-44
lines changed

22 files changed

+105
-44
lines changed

src/HITDevKit/HITDevKit/HITBasicPlugin.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
- (instancetype)initWithSettings:(NSDictionary*)settings;
1818

19+
- (NSString*)localizedString:(id)dictionaryOrArray;
20+
1921
@end
2022

2123
@interface HITBasicPlugin (MustBeDefinedInSubclass)
2224
- (NSMenuItem*)prepareNewMenuItem;
23-
@end
25+
@end

src/HITDevKit/HITDevKit/HITBasicPlugin.m

+19
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,23 @@ - (void)stopAndPrepareForRelease {
4545
self.allowedToRun = NO;
4646
}
4747

48+
- (NSString*)localizedString:(id)dictionaryOrArray {
49+
if ([dictionaryOrArray isKindOfClass:[NSDictionary class]]) {
50+
NSString *selectedValue = nil;
51+
52+
for (NSString *localIdentifier in @[
53+
[[NSLocale currentLocale] localeIdentifier],
54+
[[NSLocale currentLocale] languageCode],
55+
@"en"]) {
56+
selectedValue = [dictionaryOrArray objectForKey:localIdentifier];
57+
if (selectedValue) {
58+
break;
59+
}
60+
}
61+
62+
return selectedValue;
63+
} else {
64+
return dictionaryOrArray;
65+
}
66+
}
4867
@end

src/HITDevKit/HITDevKit/HITSimplePlugin.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@implementation HITSimplePlugin
1414

1515
-(NSMenuItem *)prepareNewMenuItem {
16-
NSString *title = [self.settings objectForKey:kHITSimplePluginTitleKey];
16+
NSString *title = [self localizedString:[self.settings objectForKey:kHITSimplePluginTitleKey]];
1717
if (!title) {
1818
title = @"";
1919
}

src/HITDevKit/HITDevKit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>NSHumanReadableCopyright</key>
2424
<string>Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved.</string>
2525
<key>NSPrincipalClass</key>

src/Hello IT.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
F8340B8B1C96CF9000C820D7 /* statusbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "statusbar@2x.png"; sourceTree = "<group>"; };
282282
F89B59391DA7DC350028D75F /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
283283
F89B593A1DA7DC350028D75F /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
284+
F8B315891FA6BB1400839784 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/MainMenu.strings; sourceTree = "<group>"; };
284285
/* End PBXFileReference section */
285286

286287
/* Begin PBXFrameworksBuildPhase section */
@@ -841,6 +842,7 @@
841842
isa = PBXVariantGroup;
842843
children = (
843844
E1D068071B51D08E00567172 /* Base */,
845+
F8B315891FA6BB1400839784 /* fr */,
844846
);
845847
name = MainMenu.xib;
846848
sourceTree = "<group>";
@@ -852,6 +854,7 @@
852854
isa = XCBuildConfiguration;
853855
buildSettings = {
854856
ALWAYS_SEARCH_USER_PATHS = NO;
857+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
855858
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
856859
CLANG_CXX_LIBRARY = "libc++";
857860
CLANG_ENABLE_MODULES = YES;
@@ -904,6 +907,7 @@
904907
isa = XCBuildConfiguration;
905908
buildSettings = {
906909
ALWAYS_SEARCH_USER_PATHS = NO;
910+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
907911
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
908912
CLANG_CXX_LIBRARY = "libc++";
909913
CLANG_ENABLE_MODULES = YES;

src/Hello IT/Info.plist

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.3.1</string>
20+
<string>1.3.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>225</string>
24+
<string>235</string>
2525
<key>LSApplicationCategoryType</key>
2626
<string>public.app-category.utilities</string>
2727
<key>LSMinimumSystemVersion</key>
@@ -39,5 +39,7 @@
3939
<string>MainMenu</string>
4040
<key>NSPrincipalClass</key>
4141
<string>NSApplication</string>
42+
<key>NSUserNotificationAlertStyle</key>
43+
<string>alert</string>
4244
</dict>
4345
</plist>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/Plugins/ADPass/ADPass/HITPADPass.m

+28-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#define kHITPADPassNotifTitle @"notificationTitle"
2222
#define kHITPADPassNotifMessageFormat @"notificationMessageFormat"
2323
#define kHITPADPassNotifOfflineMessageFormat @"notificationOfflineMessageFormat"
24+
#define kHITPADPassNotifChangePasswordTitle @"notificationChangePasswordTitle"
25+
#define kHITPADPassNotifLaterTitle @"notificationLaterTitle"
2426

2527
#define kHITPADPassAlertXDaysBefore @"alertXDaysBefore"
2628

@@ -38,6 +40,8 @@ @interface HITPADPass () <NSUserNotificationCenterDelegate>
3840
@property NSString *notificationTitle;
3941
@property NSString *notificationMessageFormat;
4042
@property NSString *notificationOfflineMessageFormat;
43+
@property NSString *notificationChangePasswordTitle;
44+
@property NSString *notificationLaterTitle;
4145

4246
@property NSInteger alertXDaysBefore;
4347

@@ -82,10 +86,14 @@ - (instancetype)initWithSettings:(NSDictionary*)settings
8286
NSString *defaultNotificationTitle = @"🔐 📆 ⚠️";
8387
NSString *defaultNotificationMessageFormat = @"Your password will expire on %@. Change it before!";
8488
NSString *defaultNotificationOfflineMessageFormat = @"Your password will expire on %@. Come back on your corporate network and change it before!";
89+
NSString *defaultNotificationChangePasswordTitle = @"🔑";
90+
NSString *defaultNotificationLaterTitle = @"";
8591

8692
_notificationTitle = [settings objectForKey:kHITPADPassNotifTitle];
8793
_notificationMessageFormat = [settings objectForKey:kHITPADPassNotifMessageFormat];
8894
_notificationOfflineMessageFormat = [settings objectForKey:kHITPADPassNotifOfflineMessageFormat];
95+
_notificationChangePasswordTitle = [settings objectForKey:kHITPADPassNotifChangePasswordTitle];
96+
_notificationLaterTitle = [settings objectForKey:kHITPADPassNotifLaterTitle];
8997

9098
if ([_notificationTitle length] == 0) {
9199
_notificationTitle = [[NSBundle bundleForClass:[self class]] localizedStringForKey:kHITPADPassNotifTitle value:defaultNotificationTitle table:nil];
@@ -98,8 +106,15 @@ - (instancetype)initWithSettings:(NSDictionary*)settings
98106
if ([_notificationOfflineMessageFormat length] == 0) {
99107
_notificationOfflineMessageFormat = [[NSBundle bundleForClass:[self class]] localizedStringForKey:kHITPADPassNotifOfflineMessageFormat value:defaultNotificationOfflineMessageFormat table:nil];
100108
}
101-
102-
109+
110+
if ([_notificationChangePasswordTitle length] == 0) {
111+
_notificationChangePasswordTitle = [[NSBundle bundleForClass:[self class]] localizedStringForKey:kHITPADPassNotifChangePasswordTitle value:defaultNotificationChangePasswordTitle table:nil];
112+
}
113+
114+
if ([_notificationLaterTitle length] == 0) {
115+
_notificationLaterTitle = [[NSBundle bundleForClass:[self class]] localizedStringForKey:kHITPADPassNotifLaterTitle value:defaultNotificationLaterTitle table:nil];
116+
}
117+
103118
}
104119
return self;
105120
}
@@ -149,7 +164,6 @@ - (void)updateTitle {
149164

150165
if (components.hour >= 10 && notifNeeded) {
151166
[self sendUserNotification];
152-
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:kHITPADPassLastNotifKey];
153167
}
154168
}
155169
}
@@ -213,11 +227,13 @@ - (void)sendUserNotification {
213227
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Notification to change AD password is requested.");
214228
NSUserNotification *notification = [NSUserNotification new];
215229

216-
notification.identifier = [[NSBundle bundleForClass:[self class]] bundleIdentifier];
217-
218230
notification.title = self.notificationTitle;
219231
NSString *infoTextFormat = self.lastADRequestSucceded ? self.notificationMessageFormat : self.notificationOfflineMessageFormat;
220232

233+
notification.hasActionButton = YES;
234+
notification.actionButtonTitle = self.notificationChangePasswordTitle;
235+
notification.otherButtonTitle = self.notificationLaterTitle;
236+
221237
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
222238
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
223239
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
@@ -226,13 +242,16 @@ - (void)sendUserNotification {
226242
notification.informativeText = [NSString stringWithFormat:infoTextFormat, stringDate];
227243

228244
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
245+
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:kHITPADPassLastNotifKey];
229246
}
230247

231248
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
232-
if ([notification.identifier isEqualToString:[[NSBundle bundleForClass:[self class]] bundleIdentifier]] && notification.activationType != NSUserNotificationActivationTypeNone) {
233-
[self mainAction:notification];
234-
[center removeDeliveredNotification:notification];
235-
}
249+
[self mainAction:notification];
250+
[center removeDeliveredNotification:notification];
251+
}
252+
253+
-(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(nonnull NSUserNotification *)notification {
254+
return YES;
236255
}
237256

238257
@end

src/Plugins/ADPass/ADPass/en.lproj/Localizable.strings

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
"notificationTitle" = "Password is about to expire!";
1818
"notificationMessageFormat" = "Your password will expire on %@. Change it before!";
1919
"notificationOfflineMessageFormat" = "Your password will expire on %@. Come back on your corporate network and change it before!";
20+
"notificationChangePasswordTitle" = "Let's do it";
21+
"notificationLaterTitle" = "Later";

src/Plugins/ADPass/ADPass/fr.lproj/Localizable.strings

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
// `%ld` is the format used to display the number of days before password expire.
1111
// To show `Your password will expire in 42d` use format `Your password will expire in %ldd`
1212

13-
"willExpireFormat" = "MDP expire dans %ldj";
13+
"willExpireFormat" = "Votre mot de passe expire dans %ldj";
1414
"tooltip" = "Nombre de jours avant que votre mot de passe ne change, pensez à le changer avant !";
1515
"disabledTooltip" = "Votre système d'information est injoignable. L'information actuelle est basée sur la dernière valeur enregistrée et vous ne pouvez pas changer votre mot de passe.";
1616

1717
"notificationTitle" = "Votre mot de passe va expirer !";
1818
"notificationMessageFormat" = "Votre mot de passe expire le %@. Changez-le avant !";
1919
"notificationOfflineMessageFormat" = "Votre mot de passe expire le %@. Retournez sur votre réseau d'entreprise et changez-le avant la date butoire !";
20+
"notificationChangePasswordTitle" = "Maintenant";
21+
"notificationLaterTitle" = "Plus tard";

src/Plugins/OpenApplication/OpenApplication/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.open.application</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/OpenResource/OpenResource/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.open.resource</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/Quit/Quit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.quit</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.ip.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
mode=0
1818
mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}')
1919

20-
while getopts "m:i:" o; do
21-
case "${o}" in
22-
m)
23-
mode=${OPTARG}
24-
;;
25-
i)
26-
mainBSDInterface=${OPTARG}
27-
;;
28-
esac
29-
done
20+
function handleOptions {
21+
while getopts "m:i:" o; do
22+
case "${o}" in
23+
m)
24+
mode=${OPTARG}
25+
;;
26+
i)
27+
mainBSDInterface=${OPTARG}
28+
;;
29+
esac
30+
done
31+
}
3032

3133
function handleStateUpdate {
3234
mode=$1

src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.public-ip.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
mode=0
1818
public_ip_url="https://ip.abelionni.com/script/"
1919

20-
while getopts "m:u:" o; do
21-
case "${o}" in
22-
m)
23-
mode=${OPTARG}
24-
;;
25-
u)
26-
public_ip_url=${OPTARG}
27-
;;
28-
esac
29-
done
20+
function handleOptions {
21+
while getopts "m:u:" o; do
22+
case "${o}" in
23+
m)
24+
mode=${OPTARG}
25+
;;
26+
u)
27+
public_ip_url=${OPTARG}
28+
;;
29+
esac
30+
done
31+
}
3032

3133
function handleStateUpdate {
3234
mode=$1

src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.scriptlib.sh

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ function debugLog {
9292
echo "hitp-log-debug: $1"
9393
}
9494

95+
# override this function if you need to parse your options array before everything else
96+
function handleOptions {
97+
:
98+
}
99+
95100
# override this function to specify what to do when the user clic on your menu item
96101
function onClickAction {
97102
:
@@ -135,6 +140,7 @@ function main {
135140
if [ "$HELLO_IT_ARGS_AVAILABLE" == "yes" ]
136141
then
137142
options=("$HELLO_IT_ARGS")
143+
handleOptions $options
138144
fi
139145

140146
case "$run_option" in

src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ - (instancetype)initWithSettings:(NSDictionary*)settings
9191
}
9292

9393
-(NSMenuItem *)prepareNewMenuItem {
94-
NSString *title = [self.settings objectForKey:kHITSimplePluginTitleKey];
94+
NSString *title = [self localizedString:[self.settings objectForKey:kHITSimplePluginTitleKey]];
9595
if (!title) {
9696
title = @"";
9797
}

src/Plugins/ScriptedItem/ScriptedItem/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.script.item</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/Separator/Separator/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.separator</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/SubMenu/SubMenu/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.submenu</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/TestHTTP/TestHTTP/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.test.http</string>
2525
<key>NSHumanReadableCopyright</key>

src/Plugins/Title/Title/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>225</string>
22+
<string>235</string>
2323
<key>HITPFunctionIdentifier</key>
2424
<string>public.title</string>
2525
<key>NSHumanReadableCopyright</key>

0 commit comments

Comments
 (0)