1 /* xscreensaver, Copyright (c) 2013 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
11 * XScreenSaverUpdater.app -- downloads and installs XScreenSaver updates
12 * via Sparkle.framework.
16 * NOTE: This does not work with Sparkle 1.5b6 -- it requires the "HEAD"
17 * version 4-Dec-2013 or later.
21 #import "Sparkle/SUUpdater.h"
23 @implementation XScreenSaverUpdater : NSObject
25 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
27 SUUpdater *updater = [SUUpdater updaterForBundle:
28 [NSBundle bundleForClass:[self class]]];
29 NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
30 [defs registerDefaults:UPDATER_DEFAULTS];
32 // Launch the updater thread.
33 [updater checkForUpdatesInBackground];
35 // Now we need to wait for the Sparkle thread to finish before we can
36 // exit, so just poll waiting for it.
37 [NSTimer scheduledTimerWithTimeInterval:1
39 selector:@selector(exitWhenDone:)
44 - (void) exitWhenDone:(NSTimer *)timer
46 SUUpdater *updater = [timer userInfo];
47 if (![updater updateInProgress])
48 [[NSApplication sharedApplication] terminate:self];
51 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app