Skip to content

Commit

Permalink
Merge pull request #123 from lindegroup/autoPkgTask-Class
Browse files Browse the repository at this point in the history
Merging 1.0.3 changes into master branch.
  • Loading branch information
homebysix committed Sep 9, 2014
2 parents b9ae83c + cd08afb commit a6f804e
Show file tree
Hide file tree
Showing 27 changed files with 1,274 additions and 790 deletions.
37 changes: 31 additions & 6 deletions AutoPkgr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
1A1BAD96197A0407008192A7 /* LGVersionComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A1BAD95197A0407008192A7 /* LGVersionComparator.m */; };
1A1BAD9E197A4133008192A7 /* LGGitHubJSONLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A1BAD9D197A4133008192A7 /* LGGitHubJSONLoader.m */; };
1A979FE01960BCCC00EE9881 /* LGUnzipper.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A979FDF1960BCCC00EE9881 /* LGUnzipper.m */; };
1AAAA5CC196C82DB00623804 /* LGAutoPkgRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAA5CB196C82DB00623804 /* LGAutoPkgRunner.m */; };
1AC69551195B59ED00D2BD81 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC69550195B59ED00D2BD81 /* Cocoa.framework */; };
1AC6955B195B59ED00D2BD81 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1AC69559195B59ED00D2BD81 /* InfoPlist.strings */; };
1AC6955D195B59EE00D2BD81 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6955C195B59ED00D2BD81 /* main.m */; };
Expand All @@ -38,6 +37,11 @@
6A53625D1988BE59008A949C /* LGTestPort.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A53625C1988BE59008A949C /* LGTestPort.m */; };
8B6A3199195B7AC1007A7A16 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 8B6A3198195B7AC1007A7A16 /* [email protected] */; };
8BB217F619709A2C00EF8B93 /* AutoPkgrIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8BB217F519709A2C00EF8B93 /* AutoPkgrIcon.png */; };
BE025CF619BAE93400D36345 /* LGAutoPkgTask.m in Sources */ = {isa = PBXBuildFile; fileRef = BE025CF519BAE93400D36345 /* LGAutoPkgTask.m */; };
BE025CF719BAE93400D36345 /* LGAutoPkgTask.m in Sources */ = {isa = PBXBuildFile; fileRef = BE025CF519BAE93400D36345 /* LGAutoPkgTask.m */; };
BE025CFE19BAEF8800D36345 /* LGAutoPkgSchedule.m in Sources */ = {isa = PBXBuildFile; fileRef = BE025CFD19BAEF8800D36345 /* LGAutoPkgSchedule.m */; };
BE025CFF19BAEF8800D36345 /* LGAutoPkgSchedule.m in Sources */ = {isa = PBXBuildFile; fileRef = BE025CFD19BAEF8800D36345 /* LGAutoPkgSchedule.m */; };
BE57AC2A19BA3BBC00BB17B1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BE57AC2C19BA3BBC00BB17B1 /* Localizable.strings */; };
BE87994B1995BA410082472B /* LGDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = BE87994A1995BA410082472B /* LGDefaults.m */; };
BEFC931D1995F0710074C938 /* LGError.m in Sources */ = {isa = PBXBuildFile; fileRef = BEFC931C1995F0710074C938 /* LGError.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -116,8 +120,6 @@
1A1BAD9D197A4133008192A7 /* LGGitHubJSONLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGGitHubJSONLoader.m; sourceTree = "<group>"; };
1A979FDE1960BCCC00EE9881 /* LGUnzipper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGUnzipper.h; sourceTree = "<group>"; };
1A979FDF1960BCCC00EE9881 /* LGUnzipper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGUnzipper.m; sourceTree = "<group>"; };
1AAAA5CA196C82DB00623804 /* LGAutoPkgRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGAutoPkgRunner.h; sourceTree = "<group>"; };
1AAAA5CB196C82DB00623804 /* LGAutoPkgRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGAutoPkgRunner.m; sourceTree = "<group>"; };
1AC6954D195B59ED00D2BD81 /* AutoPkgr.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutoPkgr.app; sourceTree = BUILT_PRODUCTS_DIR; };
1AC69550195B59ED00D2BD81 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
1AC69553195B59ED00D2BD81 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -158,9 +160,15 @@
6A53625C1988BE59008A949C /* LGTestPort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGTestPort.m; sourceTree = "<group>"; };
8B6A3198195B7AC1007A7A16 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
8BB217F519709A2C00EF8B93 /* AutoPkgrIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = AutoPkgrIcon.png; sourceTree = "<group>"; };
BE025CF419BAE93400D36345 /* LGAutoPkgTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGAutoPkgTask.h; sourceTree = "<group>"; };
BE025CF519BAE93400D36345 /* LGAutoPkgTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGAutoPkgTask.m; sourceTree = "<group>"; };
BE025CFC19BAEF8800D36345 /* LGAutoPkgSchedule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGAutoPkgSchedule.h; sourceTree = "<group>"; };
BE025CFD19BAEF8800D36345 /* LGAutoPkgSchedule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGAutoPkgSchedule.m; sourceTree = "<group>"; };
BE34DF2B19AA21E200DC2FAF /* LGAutoPkgr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LGAutoPkgr.h; sourceTree = "<group>"; };
BE57AC2B19BA3BBC00BB17B1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
BE8799491995BA410082472B /* LGDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGDefaults.h; sourceTree = "<group>"; };
BE87994A1995BA410082472B /* LGDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGDefaults.m; sourceTree = "<group>"; };
BE94AA7B19BB8A78001A00D0 /* LGProgressDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LGProgressDelegate.h; sourceTree = "<group>"; };
BEFC931B1995F0710074C938 /* LGError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGError.h; sourceTree = "<group>"; };
BEFC931C1995F0710074C938 /* LGError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGError.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -249,14 +257,17 @@
BE34DF2B19AA21E200DC2FAF /* LGAutoPkgr.h */,
1AC69562195B59EE00D2BD81 /* LGAppDelegate.h */,
1AC69563195B59EE00D2BD81 /* LGAppDelegate.m */,
BE94AA7B19BB8A78001A00D0 /* LGProgressDelegate.h */,
1AC98410195CE8510071CAB3 /* LGEmailer.h */,
1AC98411195CE8520071CAB3 /* LGEmailer.m */,
1AC98408195CE7D60071CAB3 /* LGConstants.h */,
1AC98409195CE7D60071CAB3 /* LGConstants.m */,
1AAAA5CA196C82DB00623804 /* LGAutoPkgRunner.h */,
1AAAA5CB196C82DB00623804 /* LGAutoPkgRunner.m */,
BE025CF419BAE93400D36345 /* LGAutoPkgTask.h */,
BE025CF519BAE93400D36345 /* LGAutoPkgTask.m */,
1AC9841C195CEC350071CAB3 /* LGConfigurationWindowController.h */,
1AC9841D195CEC350071CAB3 /* LGConfigurationWindowController.m */,
BE025CFC19BAEF8800D36345 /* LGAutoPkgSchedule.h */,
BE025CFD19BAEF8800D36345 /* LGAutoPkgSchedule.m */,
1A979FDE1960BCCC00EE9881 /* LGUnzipper.h */,
1A979FDF1960BCCC00EE9881 /* LGUnzipper.m */,
6A0BABE7196E560000A136BB /* LGPopularRepositories.h */,
Expand All @@ -281,6 +292,7 @@
children = (
1AC69558195B59ED00D2BD81 /* AutoPkgr-Info.plist */,
1AC69559195B59ED00D2BD81 /* InfoPlist.strings */,
BE57AC2C19BA3BBC00BB17B1 /* Localizable.strings */,
1AC6955C195B59ED00D2BD81 /* main.m */,
1AC6955E195B59EE00D2BD81 /* AutoPkgr-Prefix.pch */,
1AC6955F195B59EE00D2BD81 /* Credits.rtf */,
Expand Down Expand Up @@ -469,6 +481,7 @@
1AC6955B195B59ED00D2BD81 /* InfoPlist.strings in Resources */,
1AC69569195B59EE00D2BD81 /* Images.xcassets in Resources */,
1AC98420195CEC360071CAB3 /* LGConfigurationWindowController.xib in Resources */,
BE57AC2A19BA3BBC00BB17B1 /* Localizable.strings in Resources */,
8B6A3199195B7AC1007A7A16 /* [email protected] in Resources */,
1AC98427195DF6350071CAB3 /* autopkgr.png in Resources */,
1AC69561195B59EE00D2BD81 /* Credits.rtf in Resources */,
Expand All @@ -494,6 +507,7 @@
1AC86D3D195E0AC6006FDD2B /* LGHostInfo.m in Sources */,
1A1BAD96197A0407008192A7 /* LGVersionComparator.m in Sources */,
1AC98412195CE8520071CAB3 /* LGEmailer.m in Sources */,
BE025CFE19BAEF8800D36345 /* LGAutoPkgSchedule.m in Sources */,
6A0ACE34196FB349002C7FE4 /* LGApplications.m in Sources */,
1AC9841F195CEC360071CAB3 /* LGConfigurationWindowController.m in Sources */,
1A1BAD9E197A4133008192A7 /* LGGitHubJSONLoader.m in Sources */,
Expand All @@ -505,16 +519,18 @@
BEFC931D1995F0710074C938 /* LGError.m in Sources */,
1AC98416195CE99E0071CAB3 /* SSKeychain.m in Sources */,
1A979FE01960BCCC00EE9881 /* LGUnzipper.m in Sources */,
BE025CF619BAE93400D36345 /* LGAutoPkgTask.m in Sources */,
6A0BABE9196E560000A136BB /* LGPopularRepositories.m in Sources */,
1AAAA5CC196C82DB00623804 /* LGAutoPkgRunner.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1AC6956A195B59EE00D2BD81 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BE025CFF19BAEF8800D36345 /* LGAutoPkgSchedule.m in Sources */,
1AC6957B195B59EE00D2BD81 /* AutoPkgrTests.m in Sources */,
BE025CF719BAE93400D36345 /* LGAutoPkgTask.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -566,6 +582,15 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
BE57AC2C19BA3BBC00BB17B1 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
BE57AC2B19BA3BBC00BB17B1 /* en */,
);
name = Localizable.strings;
path = ..;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
4 changes: 2 additions & 2 deletions AutoPkgr/AutoPkgr-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.0.2</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion AutoPkgr/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="5vA-zg-b1N"/>
<menuItem title="Quit" id="cuo-db-FBC">
<menuItem title="Quit AutoPkgr" id="cuo-db-FBC">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="terminate:" target="-2" id="t6s-yZ-lSS"/>
Expand Down
3 changes: 2 additions & 1 deletion AutoPkgr/LGAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
//

#import <Cocoa/Cocoa.h>
#import "LGProgressDelegate.h"

@class LGConfigurationWindowController;

@interface LGAppDelegate : NSObject <NSApplicationDelegate>
@interface LGAppDelegate : NSObject <NSApplicationDelegate,LGProgressDelegate>
{
@private
LGConfigurationWindowController *configurationWindowController;
Expand Down
61 changes: 49 additions & 12 deletions AutoPkgr/LGAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#import "LGAppDelegate.h"
#import "LGAutoPkgr.h"
#import "LGAutoPkgTask.h"
#import "LGEmailer.h"
#import "LGAutoPkgSchedule.h"
#import "LGConfigurationWindowController.h"

@implementation LGAppDelegate
Expand All @@ -29,6 +32,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
LGDefaults *defaults = [LGDefaults new];

// set self as the delegate for the time so the menu item is updated
// during timed runs.
[[LGAutoPkgSchedule sharedTimer] setProgressDelegate:self];

// Setup the status item
[self setupStatusItem];

Expand All @@ -39,24 +46,19 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// Start the AutoPkg run timer if the user enabled it
[self startAutoPkgRunTimer];

// Update AutoPkg recipe repos when the application launches
// if the user has enabled automatic repo updates
if (defaults.checkForRepoUpdatesAutomaticallyEnabled) {
NSLog(@"Updating AutoPkg recipe repos.");
[self updateAutoPkgRecipeReposInBackgroundAtAppLaunch];
}
}

- (void)startAutoPkgRunTimer
{
LGAutoPkgRunner *autoPkgRunner = [[LGAutoPkgRunner alloc] init];
[autoPkgRunner startAutoPkgRunTimer];
[[LGAutoPkgSchedule sharedTimer] configure];
}


- (void)updateAutoPkgRecipeReposInBackgroundAtAppLaunch
{
LGAutoPkgRunner *autoPkgRunner = [[LGAutoPkgRunner alloc] init];
[autoPkgRunner invokeAutoPkgRepoUpdateInBackgroundThread];
[LGAutoPkgTask repoUpdate:^(NSError *error) {
NSLog(@"%@", error ? error.localizedDescription:@"AutoPkg recipe repos updated.");
}];
}

- (void)setupStatusItem
Expand All @@ -72,10 +74,20 @@ - (void)setupStatusItem

- (void)checkNowFromMenu:(id)sender
{
LGAutoPkgRunner *autoPkgRunner = [[LGAutoPkgRunner alloc] init];
[autoPkgRunner invokeAutoPkgInBackgroundThread];
[self startProgressWithMessage:@"Starting..."];
NSString *recipeList = [LGApplications recipeList];
[LGAutoPkgTask runRecipeList:recipeList
progress:^(NSString *message, double taskProgress) {
[self updateProgress:message progress:taskProgress];
}
reply:^(NSDictionary *report,NSError *error) {
[self stopProgress:error];
LGEmailer *emailer = [LGEmailer new];
[emailer sendEmailForReport:report error:error];
}];
}


- (void)showConfigurationWindow:(id)sender
{
if (!self->configurationWindowController) {
Expand Down Expand Up @@ -107,4 +119,29 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
return NSTerminateNow;
}

# pragma mark - Progress Protocol
-(void)startProgressWithMessage:(NSString *)message{
__block NSMenuItem *item = [self.statusMenu itemAtIndex:0];
[item setAction:nil];
[item setTitle:message];
}

-(void)stopProgress:(NSError *)error{
__block NSMenuItem *item = [self.statusMenu itemAtIndex:0];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[item setTitle:@"Check Now"];
[item setAction:@selector(checkNowFromMenu:)];
}];
}

-(void)updateProgress:(NSString *)message progress:(double)progress{
__block NSMenuItem *item = [self.statusMenu itemAtIndex:0];
if (message.length < 50) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[item setTitle:message];
}];
}
NSLog(@"%@",message);
}

@end
5 changes: 3 additions & 2 deletions AutoPkgr/LGApplications.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//

#import <Foundation/Foundation.h>
#import "LGAutoPkgRunner.h"
#import "LGAutoPkgTask.h"

@interface LGApplications : NSObject <NSApplicationDelegate, NSTableViewDataSource, NSTableViewDelegate> {

Expand All @@ -29,7 +29,6 @@
NSArray *apps;
NSArray *activeApps;
NSArray *searchedApps;
LGAutoPkgRunner *pkgRunner;
__weak NSSearchField *_appSearch;
}

Expand All @@ -39,4 +38,6 @@

@property (weak) IBOutlet NSSearchField *appSearch;

+ (NSString *)recipeList;

@end
17 changes: 10 additions & 7 deletions AutoPkgr/LGApplications.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@ @implementation LGApplications
- (id)init
{
self = [super init];

pkgRunner = [[LGAutoPkgRunner alloc] init];

apps = [pkgRunner getLocalAutoPkgRecipes];
activeApps = [self getActiveApps];
searchedApps = apps;

return self;
}


- (void)reload
{
apps = [pkgRunner getLocalAutoPkgRecipes];

apps = [LGAutoPkgTask listRecipes];
[self executeAppSearch:self];
}

Expand Down Expand Up @@ -221,8 +216,16 @@ - (void)executeAppSearch:(id)sender

- (void)awakeFromNib
{
[self reload];
[_appSearch setTarget:self];
[_appSearch setAction:@selector(executeAppSearch:)];
}

+ (NSString *)recipeList
{
LGApplications *apps = [[LGApplications alloc] init];
NSString *applicationSupportDirectory = [apps getAppSupportDirectory];
return [applicationSupportDirectory stringByAppendingString:@"/recipe_list.txt"];
}

@end
39 changes: 0 additions & 39 deletions AutoPkgr/LGAutoPkgRunner.h

This file was deleted.

Loading

0 comments on commit a6f804e

Please sign in to comment.