Skip to content

Commit

Permalink
updates for upcoming version
Browse files Browse the repository at this point in the history
Much improves update notification, code optimisation
  • Loading branch information
fabulouspanda committed Feb 8, 2014
1 parent 220c383 commit 6aa5373
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 38 deletions.
2 changes: 1 addition & 1 deletion MacMiner/AppDelegate.h
Expand Up @@ -10,7 +10,7 @@
#import "TaskWrapper.h"


@interface AppDelegate : NSObject <NSApplicationDelegate, NSURLAuthenticationChallengeSender, NSURLConnectionDelegate, NSURLConnectionDataDelegate, NSURLConnectionDownloadDelegate>
@interface AppDelegate : NSObject <NSApplicationDelegate, NSURLAuthenticationChallengeSender, NSURLConnectionDelegate, NSURLConnectionDataDelegate, NSURLConnectionDownloadDelegate, NSUserNotificationCenterDelegate>


//@property (assign) IBOutlet NSWindow *window;
Expand Down
49 changes: 49 additions & 0 deletions MacMiner/AppDelegate.m
Expand Up @@ -24,6 +24,38 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// Insert code here to initialize your application


[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];

BOOL notificationCenterIsAvailable = (NSClassFromString(@"NSUserNotificationCenter")!=nil);

if (notificationCenterIsAvailable) {
NSString *stringVersion = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://downloads.fabulouspanda.co.uk/version.html"]encoding:NSUTF8StringEncoding error:nil];


NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
// NSString *appVersion = [infoDict objectForKey:@"CFBundleShortVersionString"]; // example: 1.0.0
NSNumber *buildNumber = [infoDict objectForKey:@"CFBundleVersion"];
NSString *checkString = [NSString stringWithFormat:@"%@", buildNumber];

if ([checkString rangeOfString:stringVersion].location == NSNotFound) {



NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Update Available"];
NSString *messageText = [NSString stringWithFormat:@"You have version %@, %@ is available", checkString, stringVersion];
[notification setInformativeText:messageText];
[notification setSoundName:NSUserNotificationDefaultSoundName];


NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification: notification];

}

}


[[NSApp dockTile] setContentView:self.dockView];

[[NSApp dockTile] display];
Expand All @@ -46,6 +78,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
}


- (void) userNotificationCenter: (NSUserNotificationCenter *) center didActivateNotification: (NSUserNotification *) notification
{

if ([notification activationType] == NSUserNotificationActivationTypeContentsClicked)
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://fabulouspanda.co.uk/macminer/"]];
}
}

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

// Returns the directory the application uses to store the Core Data store file. This code uses a directory named "fabulouspanda.MacMiner" in the user's Application Support directory.
- (NSURL *)applicationFilesDirectory
Expand Down Expand Up @@ -292,9 +336,11 @@ -(void)mobileCommandsThread {
NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request2 returningResponse:&responseCode error:&error];

if([responseCode statusCode] != 200){
if([responseCode statusCode] != 0){
NSLog(@"Error getting %@, HTTP status code %li", getString, (long)[responseCode statusCode]);
// return nil;
}
}

NSString *responseString = [[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding];

Expand Down Expand Up @@ -329,8 +375,10 @@ -(void)mobileCommandsThread {
NSData *oResponseData3 = [NSURLConnection sendSynchronousRequest:request3 returningResponse:&responseCode3 error:&error3];

if([responseCode3 statusCode] != 200){
if([responseCode3 statusCode] != 0){
NSLog(@"Error getting %@, HTTP status code %li", getString, (long)[responseCode statusCode]);
// return nil;
}
}
else {
// NSLog(@"DELETE SUCCESS");
Expand Down Expand Up @@ -599,4 +647,5 @@ - (NSString *)getDataBetweenFromString:(NSString *)data leftString:(NSString *)l
else return nil;
}


@end
4 changes: 2 additions & 2 deletions MacMiner/MacMiner-Info.plist
Expand Up @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.12</string>
<string>1.5.13</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1512</string>
<string>1513</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
37 changes: 8 additions & 29 deletions MacMiner/asicMiner.m
Expand Up @@ -45,33 +45,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
// self.minerAddressesArray = [self.prefs objectForKey:@"ipAddress"];


BOOL notificationCenterIsAvailable = (NSClassFromString(@"NSUserNotificationCenter")!=nil);

if (notificationCenterIsAvailable) {
NSString *stringVersion = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://downloads.fabulouspanda.co.uk/version.html"]encoding:NSUTF8StringEncoding error:nil];


NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
// NSString *appVersion = [infoDict objectForKey:@"CFBundleShortVersionString"]; // example: 1.0.0
NSNumber *buildNumber = [infoDict objectForKey:@"CFBundleVersion"];
NSString *checkString = [NSString stringWithFormat:@"%@", buildNumber];

if ([checkString rangeOfString:stringVersion].location == NSNotFound) {



NSUserNotification *note = [[NSUserNotification alloc] init];
[note setTitle:@"Update Available"];
[note setInformativeText:@"Please upgrade at http://macminer.net/"];


NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification: note];

}

}


}


Expand Down Expand Up @@ -804,10 +778,15 @@ - (void)toggleTimerFired:(NSTimer*)timer
if (findTwoRunning == YES) {
[apiTask stopTask];
apiTask = nil;
findRunning = NO;
}

if (findTwoRunning == NO) {
else {

// If the task is still sitting around from the last run, release it
if (apiTask!=nil) {
apiTask = nil;
}

if (self.acceptLabel.tag == 0) {
self.acceptLabel.tag = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions MacMiner/bfgminer.conf
Expand Up @@ -15,7 +15,7 @@
"user" : "user2",
"pass" : "pass2"
}
],
]


"kernel-path" : "/Applications/MacMiner.app/Contents/Resources/bfgminer/bin"
}
3 changes: 1 addition & 2 deletions MacMiner/litecoin.conf
Expand Up @@ -15,7 +15,6 @@
"user" : "user2",
"pass" : "pass2"
}
],
]

"kernel-path" : "/Applications/MacMiner.app/Contents/Resources/bfgminer/bin"
}
3 changes: 1 addition & 2 deletions MacMiner/nobackup.conf
Expand Up @@ -5,7 +5,6 @@
"user" : "user1",
"pass" : "pass1"
}
],
]

"kernel-path" : "/Applications/MacMiner.app/Contents/Resources/bfgminer/bin"
}

0 comments on commit 6aa5373

Please sign in to comment.