mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Sparkle now warns the delegate before and after it brings up a modal panel. One can e.g. use this to unfloat floating windows that would otherwise cover the alerts.
This commit is contained in:
1 parent
990dee6a8d
commit
f6710e2379
3 files changed
+38
-2
No files matched your search
@@ -48,6 +48,7 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [host name], [host displayVersion]];
|
||||
[self showModalAlert:alert];
|
||||
[self abortUpdate];
|
||||
@@ -206,12 +207,18 @@
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)])
|
||||
[[updater delegate] updaterWillShowModalAlert: updater];
|
||||
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
[alert setIcon:[host icon]];
|
||||
[alert runModal];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
|
||||
[[updater delegate] updaterDidShowModalAlert: updater];
|
||||
}
|
||||
|
||||
@end
|
||||
+7
-2
@@ -148,6 +148,11 @@
|
||||
// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
|
||||
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
|
||||
|
||||
// Called before resp. after an updater shows a modal alert window, to give the host
|
||||
// the opportunity to hide attached windows etc. that may get in the way:
|
||||
-(void) updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
-(void) updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -156,13 +161,13 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
|
||||
#ifdef DEBUG && 0
|
||||
#if DEBUG && 0
|
||||
#define SU_MIN_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_MIN_CHECK_INTERVAL 60*60
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG && 0
|
||||
#if DEBUG && 0
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60*60*24
|
||||
|
||||
+24
@@ -30,6 +30,10 @@
|
||||
- (void)unregisterAsObserver;
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note;
|
||||
- (NSURL *)parameterizedFeedURL;
|
||||
|
||||
-(void) notifyWillShowAlert;
|
||||
-(void) notifyDidShowAlert;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdater
|
||||
@@ -76,7 +80,11 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
|
||||
// Saving-the-developer-from-a-stupid-mistake-check:
|
||||
if (![[[self feedURL] scheme] isEqualToString:@"https"] && ![host publicDSAKey])
|
||||
{
|
||||
[self notifyWillShowModalAlert];
|
||||
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to distribute your appcast over SSL or sign your updates. See Sparkle's documentation for more information.", @"OK", nil, nil);
|
||||
[self notifyDidShowModalAlert];
|
||||
}
|
||||
#endif
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that
|
||||
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:0];
|
||||
@@ -84,6 +92,7 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
// This will be used when the updater is instantiated in a nib such as MainMenu
|
||||
- (id)init
|
||||
{
|
||||
@@ -92,6 +101,21 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
|
||||
-(void) notifyWillShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterWillShowModalAlert:)] )
|
||||
[delegate updaterWillShowModalAlert: self];
|
||||
}
|
||||
|
||||
|
||||
-(void) notifyDidShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterDidShowModalAlert:)] )
|
||||
[delegate updaterDidShowModalAlert: self];
|
||||
}
|
||||
|
||||
|
||||
- (void)startUpdateCycle
|
||||
{
|
||||
BOOL shouldPrompt = NO;
|
||||
|
||||
Reference in new issue
Block a user