Skip to content

Commit

Permalink
Merge pull request #80 from TheNewNormal/v1.4.2
Browse files Browse the repository at this point in the history
v1.4.2
  • Loading branch information
rimusz authored Jul 12, 2016
2 parents 3c1771c + fee6b31 commit 13815c5
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 3 deletions.
Binary file modified coreos-osx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/CoreOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
01D3685918E5C184006510B5 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 01D3685818E5C184006510B5 /* icon.icns */; };
01E2853E18A6C4E300BC630D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01E2853D18A6C4E300BC630D /* Cocoa.framework */; };
01E285B818A6D7F400BC630D /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 01E285B718A6D7F400BC630D /* icon.png */; };
1309B1F61D34ED590054C730 /* check_app_version_github.command in Resources */ = {isa = PBXBuildFile; fileRef = 1309B1F51D34ED590054C730 /* check_app_version_github.command */; };
13164EBA1D2D2E8400642B0A /* run_corectl_app.command in Resources */ = {isa = PBXBuildFile; fileRef = 13164EB91D2D2E8400642B0A /* run_corectl_app.command */; };
133DD11C1CE49AB900059FCC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 133DD10E1CE49AB900059FCC /* AppDelegate.m */; };
133DD11D1CE49AB900059FCC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 133DD10F1CE49AB900059FCC /* MainMenu.xib */; };
Expand Down Expand Up @@ -67,6 +68,7 @@
01E2854218A6C4E300BC630D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
01E2855C18A6C4E300BC630D /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
01E285B718A6D7F400BC630D /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
1309B1F51D34ED590054C730 /* check_app_version_github.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_app_version_github.command; sourceTree = "<group>"; };
13164EB91D2D2E8400642B0A /* run_corectl_app.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = run_corectl_app.command; sourceTree = "<group>"; };
133DD10D1CE49AB900059FCC /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
133DD10E1CE49AB900059FCC /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -155,11 +157,12 @@
01E285B918A6E23C00BC630D /* Scripts */ = {
isa = PBXGroup;
children = (
1309B1F51D34ED590054C730 /* check_app_version_github.command */,
01B675D51B602FC2004349CC /* check_vm_status.command */,
13164EB91D2D2E8400642B0A /* run_corectl_app.command */,
137018B31C11F1FD0002B2B9 /* docker_registry.sh */,
01741B64190DB81400BB1F91 /* up.command */,
0106B3491B65277F001709E0 /* functions.sh */,
01B675D51B602FC2004349CC /* check_vm_status.command */,
01CFC2DB1A2AA48300F251C2 /* change_release_channel.command */,
134182F51D2A9DD7001021BD /* enable_disable_nfs.command */,
01CFC2DC1A2AA48300F251C2 /* destroy.command */,
Expand Down Expand Up @@ -263,6 +266,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1309B1F61D34ED590054C730 /* check_app_version_github.command in Resources */,
019662121B04C562005FA955 /* bin in Resources */,
01D3685918E5C184006510B5 /* icon.icns in Resources */,
01E285B818A6D7F400BC630D /* icon.png in Resources */,
Expand Down
Binary file not shown.
74 changes: 74 additions & 0 deletions src/CoreOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[self.statusItem setImage: [NSImage imageNamed:@"icon"]];
[self.statusItem setHighlightMode:YES];

//check for latest app version and notify user if there is such one
NSString *popup = [[NSString alloc] init];
[self checkAppVersionGithub:popup = @"no"];

// get the App's main bundle path
_resoucesPathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@""];
NSLog(@"applicationDirectory: '%@'", _resoucesPathFromApp);
Expand Down Expand Up @@ -256,6 +260,14 @@ - (IBAction)Restart:(id)sender {


// Updates menu

- (IBAction)checkForAppUpdates:(id)sender {

NSString *popup = [[NSString alloc] init];
[self checkAppVersionGithub:popup = @"yes"];
}


- (IBAction)updates:(id)sender {
int vm_status=[self checkVMStatus];
//NSLog (@"VM status:\n%d", vm_status);
Expand Down Expand Up @@ -569,6 +581,41 @@ - (IBAction)quit:(id)sender {


// helping functions

// check and notify about App's new version
- (void)checkAppVersionGithub:(NSString*)popup
{
// get App's current version'
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *app_version = [NSString stringWithFormat:@"%@%@", @"v", version];
NSLog (@"Installed App version:\n%@", app_version);

// get lates github version
NSString *githubVersion = [self getAppVersionGithub];

if (app_version == githubVersion) {
if ([popup isEqual: @"yes"]) {
NSString *mText = [NSString stringWithFormat:@"%@ %@", @"CoreOS for macOS", app_version];
NSString *infoText = @"You are-up-to-date !!!";
[self displayWithMessage:mText infoText:infoText];
}
else {
NSLog (@"App is up-to-date!!!");
}
}
else {
// show alert message
NSString *mText = [NSString stringWithFormat:@"%@", @"There is a new CoreOS App version available !!!"];
NSString *infoText = @"The download link will be opened in your browser ...";
[self displayWithMessage:mText infoText:infoText];

// open coreos.app releases URL
NSString *url = [@[@"https://github.com/TheNewNormal/coreos-osx/releases"] componentsJoinedByString:@""];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
}
//

- (void)runScript:(NSString*)scriptName arguments:(NSString*)arguments
{
NSTask *task = [[NSTask alloc] init];
Expand All @@ -586,6 +633,33 @@ - (void)runApp:(NSString*)appName arguments:(NSString*)arguments
}


- (NSString*)getAppVersionGithub {
// get App github version and return the shell script output
NSTask *task = [[NSTask alloc] init];
task.launchPath = [NSString stringWithFormat:@"%@", [[NSBundle mainBundle] pathForResource:@"check_app_version_github" ofType:@"command"]];
// task.arguments = @[@"status"];

NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];

NSFileHandle *file;
file = [pipe fileHandleForReading];

[task launch];
[task waitUntilExit];

NSData *data;
data = [file readDataToEndOfFile];

NSString *string;
string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog (@"App latest github version:\n%@", string);

return string;
}


- (int)checkVMStatus {
// check VM status and return the shell script output
NSTask *task = [[NSTask alloc] init];
Expand Down
6 changes: 6 additions & 0 deletions src/CoreOS/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="Gmy-Y5-bmI"/>
<menuItem title="Check for App updates" id="VaK-HQ-cRL">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForAppUpdates:" target="494" id="Ril-Fv-4AP"/>
</connections>
</menuItem>
<menuItem title="Updates" id="VT6-tu-oxP" userLabel="Menu Item - Updates">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Updates" id="DFA-8C-ne3">
Expand Down
4 changes: 2 additions & 2 deletions src/CoreOS/CoreOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>CFBundleVersion</key>
<string>519</string>
<string>521</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
6 changes: 6 additions & 0 deletions src/check_app_version_github.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# get remote version
CORECTL_VERSION=$(curl -Ss https://api.github.com/repos/TheNewNormal/coreos-osx/releases | grep "tag_name" | awk '{print $2}' | sed -e 's/"\(.*\)"./\1/' | head -1)

echo -n "${CORECTL_VERSION}"

0 comments on commit 13815c5

Please sign in to comment.