Add API to control bundle auto-updating

This commit is contained in:
Allan Odgaard
2013-03-25 13:04:40 +01:00
parent 75234faaa1
commit d1a6c854a1
3 changed files with 21 additions and 3 deletions

View File

@@ -231,6 +231,7 @@ BOOL HasDocumentWindow (NSArray* windows)
[TerminalPreferences updateMateIfRequired];
[AboutWindowController showChangesIfUpdated];
[[BundlesManager sharedInstance] setAutoUpdateBundles:YES];
[[CrashReporter sharedInstance] applicationDidFinishLaunching:aNotification];
[[CrashReporter sharedInstance] postNewCrashReportsToURLString:REST_API @"/crashes"];

View File

@@ -5,6 +5,8 @@ PUBLIC extern NSString* const kUserDefaultsLastBundleUpdateCheckKey;
PUBLIC extern NSString* const BundlesManagerBundlesDidChangeNotification;
PUBLIC @interface BundlesManager : NSObject
@property (nonatomic) BOOL autoUpdateBundles;
@property (nonatomic, readonly) BOOL isBusy;
@property (nonatomic, readonly) NSString* activityText;
@property (nonatomic, readonly) double progress;

View File

@@ -18,6 +18,7 @@ static std::string const kInstallDirectory = NULL_STR;
NSUInteger scheduledTasks;
std::set<oak::uuid_t> installing;
}
@property (nonatomic) NSTimer* updateTimer;
@property (nonatomic) BOOL isBusy;
@property (nonatomic) NSString* activityText;
@property (nonatomic) double progress;
@@ -135,13 +136,27 @@ namespace
bundlesIndex = bundles_db::index(kInstallDirectory);
load_bundles(path::join(path::home(), "Library/Application Support/TextMate/Cache"));
[self updateSources:nil];
[NSTimer scheduledTimerWithTimeInterval:4*60*60 target:self selector:@selector(updateSources:) userInfo:nil repeats:YES];
}
return self;
}
- (void)setAutoUpdateBundles:(BOOL)flag
{
if(_autoUpdateBundles == flag)
return;
if(_autoUpdateBundles = flag)
{
[self updateSources:nil];
self.updateTimer = [NSTimer scheduledTimerWithTimeInterval:4*60*60 target:self selector:@selector(updateSources:) userInfo:nil repeats:YES];
}
else
{
[self.updateTimer invalidate];
self.updateTimer = nil;
}
}
- (void)updateProgress:(NSTimer*)aTimer
{
self.progress = self.threadProgress;