Refactor update drivers

This removes subclassing usage making the code harder to follow.
Todo: handle resuming an update already waiting to be installed,
adding impatience timer for automatic update scheduling
This commit is contained in:
Zorg committed 2016-03-19 12:09:11 -04:00
1 parent 1e645e8bd7
commit 87275b23c8
26 files changed
+1687 -1186

No files matched your search

+96 -60
View File
@@ -86,10 +86,6 @@
5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; };
5D1AF59A0FD767E50065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
5D1AF82B0FD768180065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
610134730DD250470049ACDF /* SUUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134710DD250470049ACDF /* SUUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 610134720DD250470049ACDF /* SUUpdateDriver.m */; };
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */; };
6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; };
@@ -114,8 +110,6 @@
61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */; };
61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */; settings = {ATTRIBUTES = (); }; };
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */; };
61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A354530DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A354540DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m */; };
61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; };
61B078CE15A5FB6100600039 /* SUCodeSigningVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B078CC15A5FB6100600039 /* SUCodeSigningVerifier.h */; };
61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -132,17 +126,9 @@
61B5FC7009C51F4A00B25A18 /* SUAppcastItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5FC5309C5182000B25A18 /* SUAppcastItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FCA109C5228F00B25A18 /* SUUpdateAlert.m */; };
61B5FCDF09C52A9F00B25A18 /* SUUpdateAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5FCA009C5228F00B25A18 /* SUUpdateAlert.h */; settings = {ATTRIBUTES = (); }; };
61B93A3C0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B93A390DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B93A3A0DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.m */; };
61B93B270DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B93B250DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61B93B280DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B93B260DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m */; };
61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B93C070DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B93C080DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m */; };
61CFB3290E385186007A1735 /* Sparkle.pch in Headers */ = {isa = PBXBuildFile; fileRef = 61CFB3280E385186007A1735 /* Sparkle.pch */; };
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; };
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 61EF67580E25C5B400F754E0 /* SUHost.h */; };
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
@@ -154,6 +140,11 @@
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; };
7229E1B61C97C91100CB50D0 /* SUUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7229E1B51C97C91100CB50D0 /* SUUpdateDriver.h */; };
7229E1B91C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7229E1B71C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h */; };
7229E1BA1C97CC4D00CB50D0 /* SUScheduledUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7229E1B81C97CC4D00CB50D0 /* SUScheduledUpdateDriver.m */; };
7229E1BD1C98EFF200CB50D0 /* SUDownloadDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7229E1BB1C98EFF200CB50D0 /* SUDownloadDriver.h */; };
7229E1BE1C98EFF200CB50D0 /* SUDownloadDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7229E1BC1C98EFF200CB50D0 /* SUDownloadDriver.m */; };
7246E0A31C83B685003B4E75 /* SUStandardUpdaterController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7246E0A11C83B685003B4E75 /* SUStandardUpdaterController.h */; settings = {ATTRIBUTES = (Public, ); }; };
7246E0A41C83B685003B4E75 /* SUStandardUpdaterController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7246E0A21C83B685003B4E75 /* SUStandardUpdaterController.m */; };
725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 725602D31C83551C00DAA70E /* SUApplicationInfo.h */; };
@@ -226,6 +217,22 @@
72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; };
72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */; };
72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */; };
72B767CA1C9B707000A07552 /* SUAppcastDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767C81C9B707000A07552 /* SUAppcastDriver.h */; };
72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767C91C9B707000A07552 /* SUAppcastDriver.m */; };
72B767CE1C9B924900A07552 /* SUInstallerDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767CC1C9B924900A07552 /* SUInstallerDriver.h */; };
72B767CF1C9B924900A07552 /* SUInstallerDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767CD1C9B924900A07552 /* SUInstallerDriver.m */; };
72B767D21C9C7B9300A07552 /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767D01C9C7B9300A07552 /* SUProbingUpdateDriver.h */; };
72B767D31C9C7B9300A07552 /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767D11C9C7B9300A07552 /* SUProbingUpdateDriver.m */; };
72B767D61C9C8B5C00A07552 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767D41C9C8B5C00A07552 /* SUBasicUpdateDriver.h */; };
72B767D71C9C8B5C00A07552 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767D51C9C8B5C00A07552 /* SUBasicUpdateDriver.m */; };
72B767DA1C9CD2E400A07552 /* SUUIBasedUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767D81C9CD2E400A07552 /* SUUIBasedUpdateDriver.h */; };
72B767DB1C9CD2E400A07552 /* SUUIBasedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767D91C9CD2E400A07552 /* SUUIBasedUpdateDriver.m */; };
72B767DE1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767DC1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h */; };
72B767DF1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767DD1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m */; };
72B767E21C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767E01C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h */; };
72B767E31C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767E11C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m */; };
72B767E61C9CFD7200A07552 /* SUAutomaticUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767E41C9CFD7200A07552 /* SUAutomaticUpdateDriver.h */; };
72B767E71C9CFD7200A07552 /* SUAutomaticUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767E51C9CFD7200A07552 /* SUAutomaticUpdateDriver.m */; };
72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; };
72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */; };
72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */; };
@@ -561,10 +568,6 @@
5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxar.1.dylib; path = usr/lib/libxar.1.dylib; sourceTree = SDKROOT; };
5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
5D1AF5990FD767E50065DB48 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
610134710DD250470049ACDF /* SUUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateDriver.h; sourceTree = "<group>"; };
610134720DD250470049ACDF /* SUUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateDriver.m; sourceTree = "<group>"; };
610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = "<group>"; };
6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProbingUpdateDriver.m; sourceTree = "<group>"; };
6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPipedUnarchiver.h; sourceTree = "<group>"; };
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = "<group>"; };
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = "<group>"; };
@@ -621,8 +624,6 @@
61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUStandardVersionComparator.m; sourceTree = "<group>"; };
61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSystemProfiler.h; sourceTree = "<group>"; };
61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUSystemProfiler.m; sourceTree = "<group>"; };
61A354530DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUserInitiatedUpdateDriver.h; sourceTree = "<group>"; };
61A354540DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUserInitiatedUpdateDriver.m; sourceTree = "<group>"; };
61AAE8230A321A7F00D8810D /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Sparkle.strings; sourceTree = "<group>"; };
61AAE84F0A321AF700D8810D /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Sparkle.strings; sourceTree = "<group>"; };
61AAE8590A321B0400D8810D /* fr */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Sparkle.strings; sourceTree = "<group>"; };
@@ -644,12 +645,6 @@
61B5FC5409C5182000B25A18 /* SUAppcastItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAppcastItem.m; sourceTree = "<group>"; };
61B5FCA009C5228F00B25A18 /* SUUpdateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateAlert.h; sourceTree = "<group>"; };
61B5FCA109C5228F00B25A18 /* SUUpdateAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateAlert.m; sourceTree = "<group>"; };
61B93A390DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUIBasedUpdateDriver.h; sourceTree = "<group>"; };
61B93A3A0DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUIBasedUpdateDriver.m; sourceTree = "<group>"; };
61B93B250DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateDriver.h; sourceTree = "<group>"; };
61B93B260DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateDriver.m; sourceTree = "<group>"; };
61B93C070DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUScheduledUpdateDriver.h; sourceTree = "<group>"; };
61B93C080DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUScheduledUpdateDriver.m; sourceTree = "<group>"; };
61BA66CC14BDFA0400D02D86 /* sl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/Sparkle.strings; sourceTree = "<group>"; };
61BA66DA14BDFC5500D02D86 /* sl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = sl; path = sl.lproj/SUAutomaticUpdateAlert.xib; sourceTree = "<group>"; };
61BA66DB14BDFC5500D02D86 /* sl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = sl; path = sl.lproj/SUUpdateAlert.xib; sourceTree = "<group>"; };
@@ -664,8 +659,6 @@
61F3AC1615C22D5900260CA2 /* th */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = th; path = th.lproj/SUUpdateAlert.xib; sourceTree = "<group>"; };
61F3AC1715C22D5900260CA2 /* th */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = th; path = th.lproj/SUUpdatePermissionPrompt.xib; sourceTree = "<group>"; };
61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = "<group>"; };
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
720B16421C66433D006985FB /* UITests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "UITests-Info.plist"; path = "UITests/UITests-Info.plist"; sourceTree = SOURCE_ROOT; };
720B16431C66433D006985FB /* SUTestApplicationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SUTestApplicationTest.swift; path = UITests/SUTestApplicationTest.swift; sourceTree = SOURCE_ROOT; };
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
@@ -673,6 +666,11 @@
72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = "<group>"; };
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
7229E1B51C97C91100CB50D0 /* SUUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateDriver.h; sourceTree = "<group>"; };
7229E1B71C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUScheduledUpdateDriver.h; sourceTree = "<group>"; };
7229E1B81C97CC4D00CB50D0 /* SUScheduledUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUScheduledUpdateDriver.m; sourceTree = "<group>"; };
7229E1BB1C98EFF200CB50D0 /* SUDownloadDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDownloadDriver.h; sourceTree = "<group>"; };
7229E1BC1C98EFF200CB50D0 /* SUDownloadDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDownloadDriver.m; sourceTree = "<group>"; };
7246E0A11C83B685003B4E75 /* SUStandardUpdaterController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUStandardUpdaterController.h; sourceTree = "<group>"; };
7246E0A21C83B685003B4E75 /* SUStandardUpdaterController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUStandardUpdaterController.m; sourceTree = "<group>"; };
725602D31C83551C00DAA70E /* SUApplicationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUApplicationInfo.h; sourceTree = "<group>"; };
@@ -739,6 +737,22 @@
72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.xz; sourceTree = "<group>"; };
72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.dmg; sourceTree = "<group>"; };
72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Sparkle Unit Tests-Bridging-Header.h"; sourceTree = "<group>"; };
72B767C81C9B707000A07552 /* SUAppcastDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAppcastDriver.h; sourceTree = "<group>"; };
72B767C91C9B707000A07552 /* SUAppcastDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAppcastDriver.m; sourceTree = "<group>"; };
72B767CC1C9B924900A07552 /* SUInstallerDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUInstallerDriver.h; sourceTree = "<group>"; };
72B767CD1C9B924900A07552 /* SUInstallerDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerDriver.m; sourceTree = "<group>"; };
72B767D01C9C7B9300A07552 /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = "<group>"; };
72B767D11C9C7B9300A07552 /* SUProbingUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProbingUpdateDriver.m; sourceTree = "<group>"; };
72B767D41C9C8B5C00A07552 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
72B767D51C9C8B5C00A07552 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
72B767D81C9CD2E400A07552 /* SUUIBasedUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUIBasedUpdateDriver.h; sourceTree = "<group>"; };
72B767D91C9CD2E400A07552 /* SUUIBasedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUIBasedUpdateDriver.m; sourceTree = "<group>"; };
72B767DC1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUserInitiatedUpdateDriver.h; sourceTree = "<group>"; };
72B767DD1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUserInitiatedUpdateDriver.m; sourceTree = "<group>"; };
72B767E01C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUCoreBasedUpdateDriver.h; sourceTree = "<group>"; };
72B767E11C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCoreBasedUpdateDriver.m; sourceTree = "<group>"; };
72B767E41C9CFD7200A07552 /* SUAutomaticUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateDriver.h; sourceTree = "<group>"; };
72B767E51C9CFD7200A07552 /* SUAutomaticUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateDriver.m; sourceTree = "<group>"; };
72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestApplicationDelegate.h; sourceTree = "<group>"; };
72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestApplicationDelegate.m; sourceTree = "<group>"; };
72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateSettingsWindowController.h; sourceTree = "<group>"; };
@@ -1201,24 +1215,19 @@
61CFB2C20E38496B007A1735 /* Drivers */ = {
isa = PBXGroup;
children = (
725CB9561C7120410064365A /* SUUserDriver.h */,
725F97791C8A896F00265BE4 /* SUUserDriverCoreComponent.h */,
725F977A1C8A896F00265BE4 /* SUUserDriverCoreComponent.m */,
726DF88D1C84277500188804 /* SUStatusCompletionResults.h */,
61B93B250DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.h */,
61B93B260DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m */,
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */,
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */,
610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */,
6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */,
61B93C070DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h */,
61B93C080DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m */,
61B93A390DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.h */,
61B93A3A0DD02D6400DCD2F8 /* SUUIBasedUpdateDriver.m */,
610134710DD250470049ACDF /* SUUpdateDriver.h */,
610134720DD250470049ACDF /* SUUpdateDriver.m */,
61A354530DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h */,
61A354540DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m */,
72B767E81C9D114F00A07552 /* Update Drivers */,
72B767D81C9CD2E400A07552 /* SUUIBasedUpdateDriver.h */,
72B767D91C9CD2E400A07552 /* SUUIBasedUpdateDriver.m */,
72B767E01C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h */,
72B767E11C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m */,
72B767D41C9C8B5C00A07552 /* SUBasicUpdateDriver.h */,
72B767D51C9C8B5C00A07552 /* SUBasicUpdateDriver.m */,
72B767CC1C9B924900A07552 /* SUInstallerDriver.h */,
72B767CD1C9B924900A07552 /* SUInstallerDriver.m */,
7229E1BB1C98EFF200CB50D0 /* SUDownloadDriver.h */,
7229E1BC1C98EFF200CB50D0 /* SUDownloadDriver.m */,
72B767C81C9B707000A07552 /* SUAppcastDriver.h */,
72B767C91C9B707000A07552 /* SUAppcastDriver.m */,
);
name = Drivers;
sourceTree = "<group>";
@@ -1237,6 +1246,10 @@
725F97811C8A997300265BE4 /* User Driver */ = {
isa = PBXGroup;
children = (
725CB9561C7120410064365A /* SUUserDriver.h */,
725F97791C8A896F00265BE4 /* SUUserDriverCoreComponent.h */,
725F977A1C8A896F00265BE4 /* SUUserDriverCoreComponent.m */,
726DF88D1C84277500188804 /* SUStatusCompletionResults.h */,
7246E0A11C83B685003B4E75 /* SUStandardUpdaterController.h */,
7246E0A21C83B685003B4E75 /* SUStandardUpdaterController.m */,
726E4A361C89116000C57C6A /* SUStandardUserDriverDelegate.h */,
@@ -1284,6 +1297,22 @@
name = IPC;
sourceTree = "<group>";
};
72B767E81C9D114F00A07552 /* Update Drivers */ = {
isa = PBXGroup;
children = (
7229E1B51C97C91100CB50D0 /* SUUpdateDriver.h */,
72B767DC1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h */,
72B767DD1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m */,
7229E1B71C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h */,
7229E1B81C97CC4D00CB50D0 /* SUScheduledUpdateDriver.m */,
72B767D01C9C7B9300A07552 /* SUProbingUpdateDriver.h */,
72B767D11C9C7B9300A07552 /* SUProbingUpdateDriver.m */,
72B767E41C9CFD7200A07552 /* SUAutomaticUpdateDriver.h */,
72B767E51C9CFD7200A07552 /* SUAutomaticUpdateDriver.m */,
);
name = "Update Drivers";
sourceTree = "<group>";
};
FA1941C40D94A6EA00DD942E /* Configurations */ = {
isa = PBXGroup;
children = (
@@ -1334,6 +1363,7 @@
726E4A0E1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h in Headers */,
725F97A81C8B42D700265BE4 /* SUStandardUserDriverProtocol.h in Headers */,
726E4A101C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h in Headers */,
72B767DA1C9CD2E400A07552 /* SUUIBasedUpdateDriver.h in Headers */,
725CB95A1C7121830064365A /* SUStandardUserDriver.h in Headers */,
725CB9571C7120410064365A /* SUUserDriver.h in Headers */,
72162B061C82C8B30013C1C5 /* SUParameterAssert.h in Headers */,
@@ -1341,6 +1371,7 @@
726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */,
72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */,
611142E910FB1BE5009810AA /* bspatch.h in Headers */,
7229E1B61C97C91100CB50D0 /* SUUpdateDriver.h in Headers */,
729746401C9119F300FC134E /* SULocalMessagePort.h in Headers */,
61299B3609CB04E000B7442F /* Sparkle.h in Headers */,
61CFB3290E385186007A1735 /* Sparkle.pch in Headers */,
@@ -1348,9 +1379,8 @@
61B5FC0D09C4FC8200B25A18 /* SUAppcast.h in Headers */,
7246E0A31C83B685003B4E75 /* SUStandardUpdaterController.h in Headers */,
61B5FC7009C51F4A00B25A18 /* SUAppcastItem.h in Headers */,
72B767D61C9C8B5C00A07552 /* SUBasicUpdateDriver.h in Headers */,
6120721209CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h in Headers */,
61B93B270DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.h in Headers */,
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */,
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */,
5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */,
61B078CE15A5FB6100600039 /* SUCodeSigningVerifier.h in Headers */,
@@ -1365,24 +1395,27 @@
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */,
55C14F06136EF6DB00649790 /* SULog.h in Headers */,
726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */,
72B767E61C9CFD7200A07552 /* SUAutomaticUpdateDriver.h in Headers */,
618FA5220DAE8E8A0026945C /* SUPackageInstaller.h in Headers */,
72B767CA1C9B707000A07552 /* SUAppcastDriver.h in Headers */,
6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */,
618FA5050DAE8AB80026945C /* SUPlainInstaller.h in Headers */,
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */,
61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */,
72B767E21C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h in Headers */,
61A225A40D1C4AC000430CCD /* SUStandardVersionComparator.h in Headers */,
7229E1B91C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h in Headers */,
725F977B1C8A896F00265BE4 /* SUUserDriverCoreComponent.h in Headers */,
729746451C91212400FC134E /* SURemoteMessagePort.h in Headers */,
6196CFF909C72148000DC222 /* SUStatusController.h in Headers */,
72B767DE1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h in Headers */,
61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */,
61B93A3C0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.h in Headers */,
72B767D21C9C7B9300A07552 /* SUProbingUpdateDriver.h in Headers */,
7229E1BD1C98EFF200CB50D0 /* SUDownloadDriver.h in Headers */,
61299A8D09CA790200B7442F /* SUUnarchiver.h in Headers */,
72B767CE1C9B924900A07552 /* SUInstallerDriver.h in Headers */,
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */,
61B5FCDF09C52A9F00B25A18 /* SUUpdateAlert.h in Headers */,
610134730DD250470049ACDF /* SUUpdateDriver.h in Headers */,
612DCBAF0D488BC60015DBEA /* SUUpdatePermissionPrompt.h in Headers */,
61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */,
61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */,
61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */,
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */,
);
@@ -1921,35 +1954,38 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
72B767E31C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m in Sources */,
7297463C1C8FF6AE00FC134E /* SUCodeSigningVerifier.m in Sources */,
72B767E71C9CFD7200A07552 /* SUAutomaticUpdateDriver.m in Sources */,
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */,
61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */,
7229E1BE1C98EFF200CB50D0 /* SUDownloadDriver.m in Sources */,
61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */,
72B767D71C9C8B5C00A07552 /* SUBasicUpdateDriver.m in Sources */,
6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */,
61B93B280DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m in Sources */,
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */,
61299A6009CA6EB100B7442F /* SUConstants.m in Sources */,
725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */,
72B767DF1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m in Sources */,
72B767CF1C9B924900A07552 /* SUInstallerDriver.m in Sources */,
72A450541C69A68900D67EEA /* SUUpdatePermissionPromptResult.m in Sources */,
7229E1BA1C97CC4D00CB50D0 /* SUScheduledUpdateDriver.m in Sources */,
729746411C9119F300FC134E /* SULocalMessagePort.m in Sources */,
7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */,
725CB95B1C7121830064365A /* SUStandardUserDriver.m in Sources */,
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */,
6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */,
61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */,
72B767D31C9C7B9300A07552 /* SUProbingUpdateDriver.m in Sources */,
61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */,
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
7246E0A41C83B685003B4E75 /* SUStandardUpdaterController.m in Sources */,
725F977C1C8A896F00265BE4 /* SUUserDriverCoreComponent.m in Sources */,
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */,
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */,
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */,
61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */,
72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */,
72B767DB1C9CD2E400A07552 /* SUUIBasedUpdateDriver.m in Sources */,
729746461C91212400FC134E /* SURemoteMessagePort.m in Sources */,
729746581C936D5E00FC134E /* SUMessageTypes.m in Sources */,
);
+36
View File
@@ -0,0 +1,36 @@
//
// SUAppcastDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 3/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem, SUHost, SUAppcast;
@protocol SUUpdaterDelegate;
@protocol SUAppcastDriverDelegate <NSObject>
- (void)didFailToFetchAppcastWithError:(NSError *)error;
- (void)didFinishLoadingAppcast:(SUAppcast *)appcast;
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)appcastItem;
- (void)didNotFindUpdate;
@end
@interface SUAppcastDriver : NSObject
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(nullable id <SUAppcastDriverDelegate>)delegate;
- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates;
@property (nonatomic, readonly, copy) NSString *userAgent;
@property (nullable, nonatomic, readonly) SUAppcastItem *nonDeltaUpdateItem;
@end
NS_ASSUME_NONNULL_END
+183
View File
@@ -0,0 +1,183 @@
//
// SUAppcastDriver.m
// Sparkle
//
// Created by Mayur Pawashe on 3/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUAppcastDriver.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUStandardVersionComparator.h"
#import "SUOperatingSystem.h"
#import "SUUpdaterDelegate.h"
#import "SUHost.h"
#import "SUConstants.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUAppcastDriver ()
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, copy) NSString *userAgent;
@property (nullable, nonatomic, readonly, weak) id updater;
@property (nullable, nonatomic, readonly, weak) id <SUUpdaterDelegate> updaterDelegate;
@property (nullable, nonatomic) SUAppcastItem *nonDeltaUpdateItem;
@property (nullable, nonatomic, readonly) id <SUAppcastDriverDelegate> delegate;
@end
@implementation SUAppcastDriver
@synthesize host = _host;
@synthesize userAgent = _userAgent;
@synthesize updater = _updater;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize nonDeltaUpdateItem = _nonDeltaUpdateItem;
@synthesize delegate = _delegate;
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(id <SUUpdaterDelegate>)updaterDelegate delegate:(id <SUAppcastDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_host = host;
_updater = updater;
_updaterDelegate = updaterDelegate;
_delegate = delegate;
}
return self;
}
- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates
{
self.userAgent = userAgent;
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setUserAgentString:userAgent];
[appcast setHttpHeaders:httpHeaders];
[appcast fetchAppcastFromURL:appcastURL completionBlock:^(NSError *error) {
if (error != nil) {
[self.delegate didFailToFetchAppcastWithError:error];
} else {
[self appcastDidFinishLoading:appcast includesSkippedUpdates:includesSkippedUpdates];
}
}];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac includesSkippedUpdates:(BOOL)includesSkippedUpdates
{
[self.delegate didFinishLoadingAppcast:ac];
NSDictionary *userInfo = (ac != nil) ? @{ SUUpdaterAppcastNotificationKey: ac } : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
SUAppcastItem *item = nil;
SUAppcastItem *nonDeltaUpdateItem = nil;
// Now we have to find the best valid update in the appcast.
if ([self.updaterDelegate respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
{
item = [self.updaterDelegate bestValidUpdateInAppcast:ac forUpdater:self.updater];
if ([item isDeltaUpdate]) {
nonDeltaUpdateItem = [self.updaterDelegate bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
}
}
else // If not, we'll take care of it ourselves.
{
// Find the best supported update
SUAppcastItem *deltaUpdateItem = nil;
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
if (item && deltaUpdateItem) {
nonDeltaUpdateItem = item;
item = deltaUpdateItem;
}
}
if ([self itemContainsValidUpdate:item includesSkippedUpdates:includesSkippedUpdates]) {
self.nonDeltaUpdateItem = nonDeltaUpdateItem;
[self.delegate didFindValidUpdateWithAppcastItem:item];
} else {
[self.delegate didNotFindUpdate];
}
}
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
{
SUAppcastItem *item = nil;
for(SUAppcastItem *candidate in appcastItems) {
if ([[self class] hostSupportsItem:candidate]) {
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
item = candidate;
}
}
}
if (item && deltaItem) {
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][hostVersion];
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
*deltaItem = deltaUpdateItem;
}
}
return item;
}
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
{
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
BOOL minimumVersionOK = TRUE;
BOOL maximumVersionOK = TRUE;
// Check minimum and maximum System Version
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
}
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
}
return minimumVersionOK && maximumVersionOK;
}
- (id<SUVersionComparison>)versionComparator
{
id<SUVersionComparison> comparator = nil;
// Give the delegate a chance to provide a custom version comparator
if ([self.updaterDelegate respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [self.updaterDelegate versionComparatorForUpdater:self.updater];
}
// If we don't get a comparator from the delegate, use the default comparator
if (!comparator) {
comparator = [SUStandardVersionComparator defaultComparator];
}
return comparator;
}
- (BOOL)isItemNewer:(SUAppcastItem *)ui
{
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
}
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
{
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
if (skippedVersion == nil) { return NO; }
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui includesSkippedUpdates:(BOOL)includesSkippedUpdates
{
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && (includesSkippedUpdates || ![self itemContainsSkippedVersion:ui]);
}
@end
+12 -8
View File
@@ -2,18 +2,22 @@
// SUAutomaticUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUAUTOMATICUPDATEDRIVER_H
#define SUAUTOMATICUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUBasicUpdateDriver.h"
#import "SUUpdateDriver.h"
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
@protocol SUUpdaterDelegate;
@interface SUAutomaticUpdateDriver : NSObject <SUUpdateDriver>
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
@end
#endif
NS_ASSUME_NONNULL_END
+38 -81
View File
@@ -2,117 +2,74 @@
// SUAutomaticUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUAutomaticUpdateDriver.h"
#import "SULocalizations.h"
#import "SUUpdaterDelegate.h"
#import "SUUpdateDriver.h"
#import "SUHost.h"
#import "SUConstants.h"
#import "SUErrors.h"
#import "SUAppcastItem.h"
#import "SULog.h"
#import "SUStatusCompletionResults.h"
#import "SUUserDriver.h"
#import "SUUpdaterDelegate.h"
#import "SUCoreBasedUpdateDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
// If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise.
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
@interface SUAutomaticUpdateDriver () <SUCoreBasedUpdateDriverDelegate>
@interface SUUpdateDriver ()
@property (getter=isInterruptible) BOOL interruptible;
@end
@interface SUAutomaticUpdateDriver ()
@property (strong) NSTimer *showUpdateAlertTimer;
@property (nonatomic, readonly) SUCoreBasedUpdateDriver *coreDriver;
@end
@implementation SUAutomaticUpdateDriver
@synthesize showUpdateAlertTimer = _showUpdateAlertTimer;
@synthesize coreDriver = _coreDriver;
- (void)showUpdateAlert
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
{
self.interruptible = NO;
[self.userDriver showAutomaticUpdateFoundWithAppcastItem:self.updateItem reply:^(SUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self automaticUpdateAlertFinishedWithChoice:choice];
});
}];
self = [super init];
if (self != nil) {
_coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
- (void)automaticUpdateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(void (^)(void))completionBlock
{
switch (choice)
{
case SUInstallUpdateChoice:
[self installWithToolAndRelaunch:YES displayingUserInterface:YES];
break;
case SUInstallLaterChoice:
[self installWithToolAndRelaunch:NO displayingUserInterface:NO];
// We're already waiting on quit, just indicate that we're idle.
self.interruptible = YES;
break;
case SUSkipThisVersionChoice:
#warning this option should not exist
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
}
[self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:NO completion:completionBlock];
}
- (void)installerIsReadyForRelaunch
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
{
BOOL relaunch = YES;
BOOL showUI = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
[self.updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([self.updateItem isCriticalUpdate])
{
[self showUpdateAlert];
}
else
{
self.showUpdateAlertTimer = [NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO];
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
self.interruptible = YES;
}
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
- (void)installerDidFinishRelaunchPreparation
{
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
// We are done and can safely abort now
// The installer tool will keep the installation alive
[self abortUpdate];
}
- (void)basicDriverIsRequestingAbortUpdateWithError:(NSError *)error
{
[self abortUpdateWithError:error];
}
- (void)coreDriverIsRequestingAbortUpdateWithError:(NSError *)error
{
[self abortUpdateWithError:error];
}
- (void)abortUpdate
{
[self.showUpdateAlertTimer invalidate];
self.showUpdateAlertTimer = nil;
[super abortUpdate];
[self abortUpdateWithError:nil];
}
- (void)abortUpdateWithError:(NSError *)error
{
[self.coreDriver abortUpdateWithError:error];
}
@end
+29 -39
View File
@@ -1,55 +1,45 @@
//
// SUBasicUpdateDriver.h
// Sparkle,
// Sparkle
//
// Created by Andy Matuschak on 4/23/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUBASICUPDATEDRIVER_H
#define SUBASICUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUUpdateDriver.h"
@class SUAppcast, SUAppcastItem, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate>
NS_ASSUME_NONNULL_BEGIN
@property (strong, readonly) SUAppcastItem *updateItem;
@property (strong, readonly) NSURLDownload *download;
@property (copy, readonly) NSString *downloadPath;
@class SUHost, SUAppcastItem;
@protocol SUUpdaterDelegate;
- (void)checkForUpdatesAtURL:(NSURL *)URL;
@protocol SUBasicUpdateDriverDelegate <NSObject>
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
- (void)didFindValidUpdate;
- (void)didNotFindUpdate;
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)appcastItem;
- (void)downloadUpdate;
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
- (void)downloadDidFinish:(NSURLDownload *)d;
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error;
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
- (void)extractUpdate;
- (void)unarchiverExtractedProgress:(double)progress;
- (void)failedToApplyDeltaUpdate;
@optional
- (void)installerDidStart;
- (void)installerIsReadyForRelaunch;
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
- (void)cleanUpDownload;
- (void)abortUpdate;
- (void)abortUpdateWithError:(NSError *)error;
- (void)terminateApp;
- (void)basicDriverDidFinishLoadingAppcast;
@end
#endif
@interface SUBasicUpdateDriver : NSObject
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(id <SUBasicUpdateDriverDelegate>)delegate;
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock;
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, readonly) id updater; // if we didn't have legacy support, I'd remove this..
@property (nullable, nonatomic, readonly) id <SUUpdaterDelegate>updaterDelegate;
@property (nonatomic, readonly) NSString *userAgent;
@property (nullable, nonatomic, readonly) SUAppcastItem *nonDeltaUpdateItem;
- (void)abortUpdateWithError:(nullable NSError *)error;
@end
NS_ASSUME_NONNULL_END
+73 -605
View File
@@ -2,213 +2,98 @@
// SUBasicUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 4/23/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUBasicUpdateDriver.h"
#import "SUAppcastDriver.h"
#import "SUUpdaterDelegate.h"
#import "SUUserDriver.h"
#import "SUHost.h"
#import "SUOperatingSystem.h"
#import "SUStandardVersionComparator.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUBinaryDeltaCommon.h"
#import "SUFileManager.h"
#import "SUErrors.h"
#import "SULog.h"
#import "SULocalizations.h"
#import "SUAppcastItem.h"
#import "SULocalMessagePort.h"
#import "SURemoteMessagePort.h"
#import "SUMessageTypes.h"
#import "SUAppcast.h"
#import "SUHost.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUBasicUpdateDriver () <SUAppcastDriverDelegate>
@interface SUBasicUpdateDriver ()
@property (strong) SUAppcastItem *updateItem;
@property (strong) NSURLDownload *download;
@property (copy) NSString *downloadPath;
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
@property (copy) NSString *tempDir;
@property (nonatomic) BOOL postponedOnce;
@property (nonatomic) SULocalMessagePort *localPort;
@property (nonatomic) SURemoteMessagePort *remotePort;
@property (nonatomic) SUInstallerMessageType currentStage;
@property (nonatomic, weak, readonly) id<SUBasicUpdateDriverDelegate> delegate;
@property (nonatomic, readonly) SUAppcastDriver *appcastDriver;
@property (nonatomic, copy) void (^completionBlock)(void);
@end
@implementation SUBasicUpdateDriver
@synthesize updateItem;
@synthesize download;
@synthesize downloadPath;
@synthesize host = _host;
@synthesize updater = _updater;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize delegate = _delegate;
@synthesize appcastDriver = _appcastDriver;
@synthesize completionBlock = _completionBlock;
@synthesize nonDeltaUpdateItem;
@synthesize tempDir;
@synthesize postponedOnce;
@synthesize localPort = _localPort;
@synthesize remotePort = _remotePort;
@synthesize currentStage = _currentStage;
- (void)checkForUpdatesAtURL:(NSURL *)URL
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(id <SUUpdaterDelegate>)updaterDelegate delegate:(id <SUBasicUpdateDriverDelegate>)delegate
{
[super checkForUpdatesAtURL:URL];
if ([self.host isRunningOnReadOnlyVolume])
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [self.host name]] }]];
return;
self = [super init];
if (self != nil) {
_host = host;
_updater = updater;
_updaterDelegate = updaterDelegate;
_delegate = delegate;
_appcastDriver = [[SUAppcastDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self];
}
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setUserAgentString:[self.updater userAgentString]];
[appcast setHttpHeaders:[self.updater httpHeaders]];
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
if (error) {
[self abortUpdateWithError:error];
} else {
[self appcastDidFinishLoading:appcast];
}
}];
return self;
}
- (id<SUVersionComparison>)versionComparator
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock
{
id<SUVersionComparison> comparator = nil;
// Give the delegate a chance to provide a custom version comparator
if ([self.updaterDelegate respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [self.updaterDelegate versionComparatorForUpdater:self.updater];
}
// If we don't get a comparator from the delegate, use the default comparator
if (!comparator) {
comparator = [SUStandardVersionComparator defaultComparator];
}
return comparator;
}
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
{
SUAppcastItem *item = nil;
for(SUAppcastItem *candidate in appcastItems) {
if ([[self class] hostSupportsItem:candidate]) {
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
item = candidate;
}
}
}
self.completionBlock = completionBlock;
if (item && deltaItem) {
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][hostVersion];
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
*deltaItem = deltaUpdateItem;
}
if ([self.host isRunningOnReadOnlyVolume])
{
[self.delegate basicDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [self.host name]] }]];
} else {
[self.appcastDriver loadAppcastFromURL:appcastURL userAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:includesSkippedUpdates];
}
return item;
}
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
- (NSString *)userAgent
{
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
BOOL minimumVersionOK = TRUE;
BOOL maximumVersionOK = TRUE;
// Check minimum and maximum System Version
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
}
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
}
return minimumVersionOK && maximumVersionOK;
return self.appcastDriver.userAgent;
}
- (BOOL)isItemNewer:(SUAppcastItem *)ui
- (SUAppcastItem *)nonDeltaUpdateItem
{
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
return self.appcastDriver.nonDeltaUpdateItem;
}
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
- (void)didFailToFetchAppcastWithError:(NSError *)error
{
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
if (skippedVersion == nil) { return NO; }
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
[self.delegate basicDriverIsRequestingAbortUpdateWithError:error];
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
- (void)didFinishLoadingAppcast:(SUAppcast *)appcast
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
[self.updaterDelegate updater:self.updater didFinishLoadingAppcast:ac];
[self.updaterDelegate updater:self.updater didFinishLoadingAppcast:appcast];
}
NSDictionary *userInfo = (ac != nil) ? @{ SUUpdaterAppcastNotificationKey: ac } : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
SUAppcastItem *item = nil;
// Now we have to find the best valid update in the appcast.
if ([self.updaterDelegate respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
{
item = [self.updaterDelegate bestValidUpdateInAppcast:ac forUpdater:self.updater];
if ([item isDeltaUpdate]) {
self.nonDeltaUpdateItem = [self.updaterDelegate bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
}
}
else // If not, we'll take care of it ourselves.
{
// Find the best supported update
SUAppcastItem *deltaUpdateItem = nil;
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
if (item && deltaUpdateItem) {
self.nonDeltaUpdateItem = item;
item = deltaUpdateItem;
}
}
if ([self itemContainsValidUpdate:item]) {
self.updateItem = item;
[self didFindValidUpdate];
} else {
self.updateItem = nil;
[self didNotFindUpdate];
if ([self.delegate respondsToSelector:@selector(basicDriverDidFinishLoadingAppcast)]) {
[self.delegate basicDriverDidFinishLoadingAppcast];
}
}
- (void)didFindValidUpdate
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem
{
assert(self.updateItem);
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[self.updaterDelegate updater:self.updater didFindValidUpdate:self.updateItem];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
object:self.updater
userInfo:@{ SUUpdaterAppcastItemNotificationKey: self.updateItem }];
[self downloadUpdate];
userInfo:@{ SUUpdaterAppcastItemNotificationKey: updateItem }];
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem];
}
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem];
}
- (void)didNotFindUpdate
@@ -216,458 +101,41 @@
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[self.updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain
code:SUNoUpdateError
userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", "'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI)"), self.host.name]
}]];
}
- (void)downloadUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([self.updaterDelegate respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[self.updaterDelegate updater:self.updater
willDownloadUpdate:self.updateItem
withRequest:request];
}
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
{
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
NSString *cachePath = [self.host appCachePath];
self.tempDir = [cachePath stringByAppendingPathComponent:downloadFileName];
int cnt = 1;
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
{
self.tempDir = [cachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
}
// Create the temporary directory if necessary.
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:self.tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
if (!success)
{
// Okay, something's really broken with this user's file structure.
[self.download cancel];
self.download = nil;
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", self.tempDir] }]];
} else {
self.downloadPath = [self.tempDir stringByAppendingPathComponent:name];
[self.download setDestination:self.downloadPath allowOverwrite:YES];
}
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
{
assert(self.updateItem);
if (self.download != nil && self.downloadPath != nil) {
self.download = nil;
[self extractUpdate];
}
}
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
{
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
if (!failingUrl) {
failingUrl = [self.updateItem fileURL];
}
if ([self.updaterDelegate respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[self.updaterDelegate updater:self.updater
failedToDownloadUpdate:self.updateItem
error:error];
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
}];
if (failingUrl) {
userInfo[NSURLErrorFailingURLErrorKey] = failingUrl;
}
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
}
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
{
// We don't want the download system to extract our gzips.
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
}
- (void)unarchiverExtractedProgress:(double)__unused progress {}
- (void)installerDidStart {}
- (void)installerIsReadyForRelaunch {}
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
{
if (!SUInstallerMessageTypeIsLegal(self.currentStage, identifier)) {
SULog(@"Error: received out of order message with current stage: %d, requested stage: %d", self.currentStage, identifier);
return;
}
if (identifier == SUExtractedArchiveWithProgress) {
if (data.length == sizeof(double)) {
double progress = *(const double *)data.bytes;
[self unarchiverExtractedProgress:progress];
self.currentStage = identifier;
}
} else if (identifier == SUArchiveExtractionFailed) {
if ([self.updateItem isDeltaUpdate]) {
[self failedToApplyDeltaUpdate];
return;
}
// Don't have to store current stage because we're going to abort
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
} else if (identifier == SUValidationStarted) {
self.currentStage = identifier;
} else if (identifier == SUInstallationStartedStage1) {
self.currentStage = identifier;
[self installerDidStart];
} else if (identifier == SUInstallationFinishedStage1) {
self.remotePort = [[SURemoteMessagePort alloc] initWithServiceName:SUAutoUpdateServiceNameForHost(self.host) invalidationCallback:^{
dispatch_async(dispatch_get_main_queue(), ^{
#warning put in a custom error for connection closed
if (self.remotePort != nil) {
[self abortUpdate];
NSError *notFoundError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUNoUpdateError
userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", "'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI)"), self.host.name]
}
});
}];
if (self.remotePort == nil) {
#warning put in a custom error
[self abortUpdate];
} else {
self.currentStage = identifier;
[self installerIsReadyForRelaunch];
}
} else if (identifier == SUInstallationFinishedStage2) {
// Don't have to store current stage because we're severing our connection to the installer
[self.remotePort invalidate];
self.remotePort = nil;
[self.localPort invalidate];
self.localPort = nil;
[self terminateApp];
}
];
[self.delegate basicDriverIsRequestingAbortUpdateWithError:notFoundError];
}
- (void)extractUpdate
- (void)abortUpdateWithError:(nullable NSError *)error
{
self.localPort =
[[SULocalMessagePort alloc]
initWithServiceName:SUUpdateDriverServiceNameForHost(self.host)
messageCallback:^(int32_t identifier, NSData * _Nonnull data) {
dispatch_async(dispatch_get_main_queue(), ^{
[self handleMessageWithIdentifier:identifier data:data];
});
}
invalidationCallback:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.localPort != nil) {
#warning use a custom error
[self abortUpdate];
}
});
}];
if (self.localPort == nil) {
#warning use a custom error
[self abortUpdate];
} else {
NSError *error = nil;
if (![self launchAutoUpdate:&error]) {
[self abortUpdateWithError:error];
} else {
// Autoupdate takes ownership of cleaning up our temporary download directory now
self.tempDir = nil;
}
}
}
- (void)failedToApplyDeltaUpdate
{
// When a delta update fails to apply we fall back on updating via a full install.
self.updateItem = self.nonDeltaUpdateItem;
self.nonDeltaUpdateItem = nil;
[self downloadUpdate];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch
{
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
}
// Creates intermediate directories up until targetPath if they don't already exist,
// and removes the directory at targetPath if one already exists there
- (BOOL)preparePathForRelaunchTool:(NSString *)targetPath error:(NSError * __autoreleasing *)error
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
if ([fileManager fileExistsAtPath:targetPath]) {
NSError *removeError = nil;
if (![fileManager removeItemAtPath:targetPath error:&removeError]) {
if (error != NULL) {
*error = removeError;
}
return NO;
}
} else {
NSError *createDirectoryError = nil;
if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&createDirectoryError]) {
if (error != NULL) {
*error = createDirectoryError;
}
return NO;
}
}
return YES;
}
- (BOOL)launchAutoUpdate:(NSError * __autoreleasing *)outError
{
NSBundle *sparkleBundle = self.sparkleBundle;
NSString *relaunchPath = nil;
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
if (relaunchPathToCopy != nil) {
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
NSError *error = nil;
NSURL *relaunchURLToCopy = [NSURL fileURLWithPath:relaunchPathToCopy];
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
// We only need to run our copy of the app by spawning a task
// Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs
if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtURL:relaunchURLToCopy toURL:targetURL error:&error]) {
// Releasing quarantine is definitely important (didn't used to be) now that we launch AutoUpdate via LaunchServices
// Perhaps even if this fails, we should continue on in the hopes maybe this isn't a fatal error though
NSError *quarantineError = nil;
if (![fileManager releaseItemFromQuarantineAtRootURL:targetURL error:&quarantineError]) {
SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError);
}
relaunchPath = targetPath;
} else {
if (outError != NULL) {
*outError =
[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
}];
}
return NO;
if (error != nil) {
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
NSError *errorToDisplay = error;
int finiteRecursion=5;
do {
SULog(@"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, errorToDisplay.userInfo[NSURLErrorFailingURLErrorKey]);
errorToDisplay = errorToDisplay.userInfo[NSUnderlyingErrorKey];
} while(--finiteRecursion && errorToDisplay);
}
}
NSString *relaunchToolPath = [[NSBundle bundleWithPath:relaunchPath] executablePath];
if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) {
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
if (outError != NULL) {
*outError =
[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath]
}];
}
// We intentionally don't abandon the update here so that the host won't initiate another.
return NO;
}
NSString *pathToRelaunch = [self.host bundlePath];
if ([self.updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [self.updaterDelegate pathToRelaunchForUpdater:self.updater];
}
NSString *dsaSignature = self.updateItem.DSASignature == nil ? @"" : self.updateItem.DSASignature;
NSArray *launchArguments = @[
pathToRelaunch,
self.host.bundlePath,
self.tempDir,
self.downloadPath,
dsaSignature,
@"1"]; // last one signifies the relaunch tool should exit & reply back to us immediately
// Make sure the launched task finishes & replies back.
// If it succeeds, it will have launched a second instance of the tool through LaunchServices
// This is necessary if we are a XPC process, because otherwise we risk exiting prematurely
// Further, we don't launch through LS here because we don't want to reference AppKit here
int terminationStatus = 0;
BOOL taskDidLaunch = NO;
@try {
NSTask *launchedTask = [NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:launchArguments];
[launchedTask waitUntilExit];
taskDidLaunch = YES;
terminationStatus = launchedTask.terminationStatus;
} @catch (NSException *exception) {
SULog(@"Raised exception when launching update tool: %@", exception);
}
if (!taskDidLaunch || terminationStatus != 0) {
if (taskDidLaunch) {
SULog(@"Update tool failed with exit code: %d", terminationStatus);
}
if (outError != NULL) {
*outError =
[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while launching the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't launch relauncher at %@", relaunchToolPath]
}];
}
return NO;
}
return YES;
}
- (BOOL)mayUpdateAndRestart
{
return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]);
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
assert(self.updateItem);
if (![self mayUpdateAndRestart])
{
[self abortUpdate];
return;
}
// Give the host app an opportunity to postpone the install and relaunch.
if (!self.postponedOnce && [self.updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setTarget:self];
self.postponedOnce = YES;
if ([self.updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
return;
}
}
uint8_t response[2] = {(uint8_t)relaunch, (uint8_t)showUI};
NSData *responseData = [NSData dataWithBytes:response length:sizeof(response)];
[self.remotePort sendMessageWithIdentifier:SUResumeInstallationToStage2 data:responseData completion:^(BOOL success) {
if (!success) {
dispatch_async(dispatch_get_main_queue(), ^{
#warning put in a custom error
[self abortUpdate];
});
} else {
// We'll terminate later when the installer tells us stage 2 is done
}
}];
}
// Note: this is overridden by the automatic update driver to do nothing
- (void)terminateApp
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[self.updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([self.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) {
[self.updaterDelegate updaterWillRelaunchApplication:self.updater];
}
[self.userDriver terminateApplication];
}
- (void)cleanUpDownload
{
if (self.tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
{
BOOL success = NO;
NSError *error = nil;
success = [[NSFileManager defaultManager] removeItemAtPath:self.tempDir error:&error]; // Clean up the copied relauncher
if (!success) {
NSURL *tempDirURL = [NSURL fileURLWithPath:self.tempDir];
if (tempDirURL != nil) {
[[SUFileManager fileManagerAllowingAuthorization:NO] moveItemAtURLToTrash:tempDirURL error:NULL];
}
}
}
if (self.download != nil) {
[self.download cancel];
self.download = nil;
}
self.downloadPath = nil;
}
- (void)abortUpdate
{
if (self.localPort != nil) {
[self.localPort invalidate];
self.localPort = nil;
}
if (self.remotePort != nil) {
[self.remotePort invalidate];
self.remotePort = nil;
}
[self.userDriver dismissUpdateInstallation];
[self cleanUpDownload];
[[NSNotificationCenter defaultCenter] removeObserver:self];
self.updateItem = nil;
[super abortUpdate];
}
- (void)abortUpdateWithError:(NSError *)error
{
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
NSError *errorToDisplay = error;
int finiteRecursion=5;
do {
SULog(@"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, errorToDisplay.userInfo[NSURLErrorFailingURLErrorKey]);
errorToDisplay = errorToDisplay.userInfo[NSUnderlyingErrorKey];
} while(--finiteRecursion && errorToDisplay);
}
// Notify host app that update has aborted
if ([self.updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
[self.updaterDelegate updater:self.updater didAbortWithError:error];
}
[self abortUpdate];
if (self.completionBlock != nil) {
self.completionBlock();
self.completionBlock = nil;
}
}
@end
+55
View File
@@ -0,0 +1,55 @@
//
// SUCoreBasedUpdateDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUStatusCompletionResults.h"
NS_ASSUME_NONNULL_BEGIN
@class SUHost, SUAppcastItem;
@protocol SUUpdaterDelegate;
@protocol SUCoreBasedUpdateDriverDelegate <NSObject>
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem;
- (void)installerDidFinishRelaunchPreparation;
- (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
@optional
- (void)basicDriverDidFinishLoadingAppcast;
- (void)coreDriverDidFinishDownloadingUpdate;
- (void)installerDidStartInstalling;
- (void)installerDidExtractUpdateWithProgress:(double)progress;
- (void)coreDriverIsRequestingAppTermination;
@end
@interface SUCoreBasedUpdateDriver : NSObject
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(id<SUCoreBasedUpdateDriverDelegate>)delegate;
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock;
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem;
- (void)finishInstallationWithResponse:(SUInstallUpdateStatus)installUpdateStatus;
- (void)abortUpdateWithError:(nullable NSError *)error;
@end
NS_ASSUME_NONNULL_END
+182
View File
@@ -0,0 +1,182 @@
//
// SUCoreBasedUpdateDriver.m
// Sparkle
//
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUCoreBasedUpdateDriver.h"
#import "SUHost.h"
#import "SUUpdaterDelegate.h"
#import "SUBasicUpdateDriver.h"
#import "SUInstallerDriver.h"
#import "SUDownloadDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUCoreBasedUpdateDriver () <SUBasicUpdateDriverDelegate, SUDownloadDriverDelegate, SUInstallerDriverDelegate>
@property (nonatomic, readonly) SUBasicUpdateDriver *basicDriver;
@property (nonatomic) SUDownloadDriver *downloadDriver;
@property (nonatomic, readonly) SUInstallerDriver *installerDriver;
@property (nonatomic, weak, readonly) id<SUCoreBasedUpdateDriverDelegate> delegate;
@end
@implementation SUCoreBasedUpdateDriver
@synthesize basicDriver = _basicDriver;
@synthesize downloadDriver = _downloadDriver;
@synthesize installerDriver = _installerDriver;
@synthesize delegate = _delegate;
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(id<SUCoreBasedUpdateDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_delegate = delegate;
_basicDriver = [[SUBasicUpdateDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self];
_installerDriver = [[SUInstallerDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock
{
[self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:includesSkippedUpdates completion:completionBlock];
}
- (void)basicDriverDidFinishLoadingAppcast
{
if ([self.delegate respondsToSelector:@selector(basicDriverDidFinishLoadingAppcast)]) {
[self.delegate basicDriverDidFinishLoadingAppcast];
}
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem
{
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem];
}
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem
{
self.downloadDriver = [[SUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.basicDriver.host userAgent:self.basicDriver.userAgent delegate:self];
if ([self.basicDriver.updaterDelegate respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[self.basicDriver.updaterDelegate updater:self.basicDriver.updater
willDownloadUpdate:updateItem
withRequest:self.downloadDriver.request];
}
[self.downloadDriver downloadUpdate];
}
- (void)downloadDriverDidDownloadUpdate
{
// Now we have to extract the downloaded archive.
if ([self.delegate respondsToSelector:@selector(coreDriverDidFinishDownloadingUpdate)]) {
[self.delegate coreDriverDidFinishDownloadingUpdate];
}
NSString *downloadPath = self.downloadDriver.downloadPath;
assert(downloadPath != nil);
NSString *temporaryDirectory = self.downloadDriver.temporaryDirectory;
assert(temporaryDirectory != nil);
NSError *error = nil;
if (![self.installerDriver extractDownloadPath:downloadPath withUpdateItem:self.downloadDriver.updateItem temporaryDirectory:temporaryDirectory error:&error]) {
[self.delegate coreDriverIsRequestingAbortUpdateWithError:error];
} else {
[self.downloadDriver cancelTrashCleanup];
}
}
- (void)downloadDriverDidFailToDownloadUpdateWithError:(NSError *)error
{
if ([self.basicDriver.updaterDelegate respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[self.basicDriver.updaterDelegate updater:self.basicDriver.updater
failedToDownloadUpdate:self.downloadDriver.updateItem
error:error.userInfo[NSUnderlyingErrorKey]];
}
[self.delegate coreDriverIsRequestingAbortUpdateWithError:error];
}
- (void)installerDidStartInstalling
{
if ([self.delegate respondsToSelector:@selector(installerDidStartInstalling)]) {
[self.delegate installerDidStartInstalling];
}
}
- (void)installerDidExtractUpdateWithProgress:(double)progress
{
if ([self.delegate respondsToSelector:@selector(installerDidExtractUpdateWithProgress:)]) {
[self.delegate installerDidExtractUpdateWithProgress:progress];
}
}
- (void)installerDidFinishRelaunchPreparation
{
[self.delegate installerDidFinishRelaunchPreparation];
}
- (void)finishInstallationWithResponse:(SUInstallUpdateStatus)installUpdateStatus
{
switch (installUpdateStatus) {
case SUDismissUpdateInstallation:
[self.delegate coreDriverIsRequestingAbortUpdateWithError:nil];
break;
case SUInstallAndRelaunchUpdateNow:
[self.installerDriver installWithToolAndRelaunch:YES displayingUserInterface:YES];
break;
}
}
- (void)installerIsRequestingAppTermination
{
if ([self.basicDriver.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[self.basicDriver.updaterDelegate updater:self.basicDriver.updater willInstallUpdate:self.downloadDriver.updateItem];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([self.basicDriver.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) {
[self.basicDriver.updaterDelegate updaterWillRelaunchApplication:self.basicDriver.updater];
}
// If they don't respond or do anything, we'll just install after the user terminates the app anyway
if ([self.delegate respondsToSelector:@selector(coreDriverIsRequestingAppTermination)]) {
[self.delegate coreDriverIsRequestingAppTermination];
}
}
- (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error
{
[self.delegate coreDriverIsRequestingAbortUpdateWithError:error];
}
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
{
// A delegate may want to handle this type of error specially
[self.delegate basicDriverIsRequestingAbortUpdateWithError:error];
}
- (void)installerDidFailToApplyDeltaUpdate
{
SUAppcastItem *nonDeltaUpdateItem = self.basicDriver.nonDeltaUpdateItem;
assert(nonDeltaUpdateItem != nil);
[self downloadUpdateFromAppcastItem:nonDeltaUpdateItem];
}
- (void)abortUpdateWithError:(nullable NSError *)error
{
[self.installerDriver abortInstall];
[self.basicDriver abortUpdateWithError:error];
[self.downloadDriver cleanup];
}
@end
+39
View File
@@ -0,0 +1,39 @@
//
// SUDownloadDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 3/15/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SUDownloadDriverDelegate <NSObject>
- (void)downloadDriverDidDownloadUpdate;
- (void)downloadDriverDidFailToDownloadUpdateWithError:(NSError *)error;
@end
@class SUAppcastItem, SUHost;
@interface SUDownloadDriver : NSObject
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent delegate:(id<SUDownloadDriverDelegate>)delegate;
- (void)downloadUpdate;
@property (nonatomic, readonly) SUAppcastItem *updateItem;
@property (nonatomic, readonly) NSMutableURLRequest *request;
@property (nullable, nonatomic, readonly, copy) NSString *temporaryDirectory;
@property (nullable, nonatomic, readonly, copy) NSString *downloadPath;
- (void)cleanup;
- (void)cancelTrashCleanup;
@end
NS_ASSUME_NONNULL_END
+162
View File
@@ -0,0 +1,162 @@
//
// SUDownloadDriver.m
// Sparkle
//
// Created by Mayur Pawashe on 3/15/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUDownloadDriver.h"
#import "SUAppcastItem.h"
#import "SUFileManager.h"
#import "SULocalizations.h"
#import "SUHost.h"
#import "SUErrors.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUDownloadDriver () <NSURLDownloadDelegate>
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic) NSURLDownload *download;
@property (nonatomic, copy) NSString *temporaryDirectory;
@property (nonatomic, copy) NSString *downloadPath;
@property (nonatomic, weak) id<SUDownloadDriverDelegate> delegate;
@end
@implementation SUDownloadDriver
@synthesize updateItem = _updateItem;
@synthesize request = _request;
@synthesize host = _host;
@synthesize download = _download;
@synthesize temporaryDirectory = _temporaryDirectory;
@synthesize downloadPath = _downloadPath;
@synthesize delegate = _delegate;
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent delegate:(id<SUDownloadDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_updateItem = updateItem;
_host = host;
_delegate = delegate;
_request = [NSMutableURLRequest requestWithURL:updateItem.fileURL];
[_request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
}
return self;
}
- (void)downloadUpdate
{
self.download = [[NSURLDownload alloc] initWithRequest:self.request delegate:self];
}
- (void)dealloc
{
[self cleanup];
}
- (void)cancelTrashCleanup
{
self.temporaryDirectory = nil;
}
- (void)cleanup
{
NSString *temporaryDirectory = self.temporaryDirectory;
if (temporaryDirectory != nil) // temporaryDirectory contains downloadPath, so we implicitly delete both here.
{
if ([[NSFileManager defaultManager] fileExistsAtPath:temporaryDirectory]) {
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:temporaryDirectory error:NULL]; // Clean up the copied relauncher
if (!success) {
NSURL *tempDirURL = [NSURL fileURLWithPath:temporaryDirectory];
if (tempDirURL != nil) {
[[SUFileManager fileManagerAllowingAuthorization:NO] moveItemAtURLToTrash:tempDirURL error:NULL];
}
}
}
}
if (self.download != nil) {
[self.download cancel];
self.download = nil;
}
self.downloadPath = nil;
}
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
{
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
NSString *cachePath = [self.host appCachePath];
NSString *tempDir = [cachePath stringByAppendingPathComponent:downloadFileName];
int count = 1;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && count <= 999)
{
tempDir = [cachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, count++]];
}
// Create the temporary directory if necessary.
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
if (!success)
{
// Okay, something's really broken with this user's file structure.
[self.download cancel];
self.download = nil;
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", tempDir] }];
[self cleanup];
[self.delegate downloadDriverDidFailToDownloadUpdateWithError:error];
} else {
NSString *downloadPath = [tempDir stringByAppendingPathComponent:name];
self.downloadPath = downloadPath;
[self.download setDestination:downloadPath allowOverwrite:YES];
}
self.temporaryDirectory = tempDir;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
{
assert(self.updateItem);
// If this fails, then we must have already cleaned up / cancelled
if (self.download != nil && self.downloadPath != nil) {
self.download = nil;
[self.delegate downloadDriverDidDownloadUpdate];
}
}
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
{
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
if (!failingUrl) {
failingUrl = [self.updateItem fileURL];
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
}];
if (failingUrl) {
userInfo[NSURLErrorFailingURLErrorKey] = failingUrl;
}
NSError *downloadError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo];
[self.delegate downloadDriverDidFailToDownloadUpdateWithError:downloadError];
}
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
{
// We don't want the download system to extract our gzips.
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
}
@end
+40
View File
@@ -0,0 +1,40 @@
//
// SUInstallerDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 3/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SUUpdaterDelegate;
@class SUHost, SUAppcastItem;
@protocol SUInstallerDriverDelegate <NSObject>
- (void)installerDidStartInstalling;
- (void)installerDidExtractUpdateWithProgress:(double)progress;
- (void)installerDidFinishRelaunchPreparation;
- (void)installerIsRequestingAppTermination;
- (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error;
- (void)installerDidFailToApplyDeltaUpdate;
@end
@interface SUInstallerDriver : NSObject
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id<SUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SUInstallerDriverDelegate>)delegate;
- (BOOL)extractDownloadPath:(NSString *)downloadPath withUpdateItem:(SUAppcastItem *)updateItem temporaryDirectory:(NSString *)temporaryDirectory error:(NSError * __autoreleasing *)error;
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
- (void)abortInstall;
@end
NS_ASSUME_NONNULL_END
+424
View File
@@ -0,0 +1,424 @@
//
// SUInstallerDriver.m
// Sparkle
//
// Created by Mayur Pawashe on 3/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUInstallerDriver.h"
#import "SULog.h"
#import "SUMessageTypes.h"
#import "SULocalMessagePort.h"
#import "SURemoteMessagePort.h"
#import "SUUpdaterDelegate.h"
#import "SUAppcastItem.h"
#import "SULog.h"
#import "SULocalizations.h"
#import "SUErrors.h"
#import "SUHost.h"
#import "SUFileManager.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUInstallerDriver ()
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, readonly) NSBundle *sparkleBundle;
@property (nonatomic, weak, readonly) id<SUInstallerDriverDelegate> delegate;
@property (nonatomic) SUInstallerMessageType currentStage;
@property (nonatomic) SULocalMessagePort *localPort;
@property (nonatomic) SURemoteMessagePort *remotePort;
@property (nonatomic) BOOL postponedOnce;
@property (nonatomic, weak, readonly) id updater;
@property (nonatomic, weak, readonly) id<SUUpdaterDelegate> updaterDelegate;
@property (nonatomic) SUAppcastItem *updateItem;
@property (nonatomic, copy) NSString *downloadPath;
@property (nonatomic, copy) NSString *temporaryDirectory;
@end
@implementation SUInstallerDriver
@synthesize host = _host;
@synthesize sparkleBundle = _sparkleBundle;
@synthesize delegate = _delegate;
@synthesize currentStage = _currentStage;
@synthesize localPort = _localPort;
@synthesize remotePort = _remotePort;
@synthesize postponedOnce = _postponedOnce;
@synthesize updater = _updater;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize updateItem = _updateItem;
@synthesize downloadPath = _downloadPath;
@synthesize temporaryDirectory = _temporaryDirectory;
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(id<SUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SUInstallerDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_host = host;
_sparkleBundle = sparkleBundle;
_updater = updater;
_updaterDelegate = updaterDelegate;
_delegate = delegate;
}
return self;
}
- (BOOL)launchInstallTool:(NSError * __autoreleasing *)error
{
BOOL success = YES;
self.localPort =
[[SULocalMessagePort alloc]
initWithServiceName:SUUpdateDriverServiceNameForHost(self.host)
messageCallback:^(int32_t identifier, NSData * _Nonnull data) {
dispatch_async(dispatch_get_main_queue(), ^{
[self handleMessageWithIdentifier:identifier data:data];
});
}
invalidationCallback:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.localPort != nil) {
NSError *invalidationError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUInstallationError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while running the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey:@"The local port connection from the updater was invalidated"
}
];
[self.delegate installerIsRequestingAbortInstallWithError:invalidationError];
}
});
}];
if (self.localPort == nil) {
if (error != NULL) {
*error =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUInstallationError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while running the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey:@"The local port connection failed being created"
}
];
}
success = NO;
} else {
NSError *launchError = nil;
if (![self launchAutoUpdate:&launchError]) {
if (error != NULL) {
*error = launchError;
}
success = NO;
}
}
return success;
}
// This can be called multiple times (eg: if a delta update fails, this may be called again with a regular update item)
- (BOOL)extractDownloadPath:(NSString *)downloadPath withUpdateItem:(SUAppcastItem *)updateItem temporaryDirectory:(NSString *)temporaryDirectory error:(NSError * __autoreleasing *)error
{
self.updateItem = updateItem;
self.temporaryDirectory = temporaryDirectory;
self.downloadPath = downloadPath;
self.currentStage = SUInstallerNotStarted;
if (self.localPort == nil) {
return [self launchInstallTool:error];
}
return YES;
}
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
{
if (!SUInstallerMessageTypeIsLegal(self.currentStage, identifier)) {
SULog(@"Error: received out of order message with current stage: %d, requested stage: %d", self.currentStage, identifier);
return;
}
if (identifier == SUExtractedArchiveWithProgress) {
if (data.length == sizeof(double)) {
double progress = *(const double *)data.bytes;
[self.delegate installerDidExtractUpdateWithProgress:progress];
self.currentStage = identifier;
}
} else if (identifier == SUArchiveExtractionFailed) {
// If this is a delta update, there must be a regular update we can fall back to
if ([self.updateItem isDeltaUpdate]) {
[self.delegate installerDidFailToApplyDeltaUpdate];
} else {
// Don't have to store current stage because we're going to abort
[self.delegate installerIsRequestingAbortInstallWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
}
} else if (identifier == SUValidationStarted) {
self.currentStage = identifier;
} else if (identifier == SUInstallationStartedStage1) {
self.currentStage = identifier;
[self.delegate installerDidStartInstalling];
} else if (identifier == SUInstallationFinishedStage1) {
self.remotePort = [[SURemoteMessagePort alloc] initWithServiceName:SUAutoUpdateServiceNameForHost(self.host) invalidationCallback:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.remotePort != nil) {
NSError *remoteError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUInstallationError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while running the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey:@"The remote port connection was invalidated from the updater"
}
];
[self.delegate installerIsRequestingAbortInstallWithError:remoteError];
}
});
}];
if (self.remotePort == nil) {
NSError *remoteError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUInstallationError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while running the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey:@"The remote port connection failed being created"
}
];
[self.delegate installerIsRequestingAbortInstallWithError:remoteError];
} else {
self.currentStage = identifier;
[self.delegate installerDidFinishRelaunchPreparation];
}
} else if (identifier == SUInstallationFinishedStage2) {
// Don't have to store current stage because we're severing our connection to the installer
[self.remotePort invalidate];
self.remotePort = nil;
[self.localPort invalidate];
self.localPort = nil;
[self.delegate installerIsRequestingAppTermination];
}
}
// Creates intermediate directories up until targetPath if they don't already exist,
// and removes the directory at targetPath if one already exists there
- (BOOL)preparePathForRelaunchTool:(NSString *)targetPath error:(NSError * __autoreleasing *)error
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
if ([fileManager fileExistsAtPath:targetPath]) {
NSError *removeError = nil;
if (![fileManager removeItemAtPath:targetPath error:&removeError]) {
if (error != NULL) {
*error = removeError;
}
return NO;
}
} else {
NSError *createDirectoryError = nil;
if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&createDirectoryError]) {
if (error != NULL) {
*error = createDirectoryError;
}
return NO;
}
}
return YES;
}
- (BOOL)launchAutoUpdate:(NSError * __autoreleasing *)outError
{
NSBundle *sparkleBundle = self.sparkleBundle;
NSString *relaunchPath = nil;
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
if (relaunchPathToCopy != nil) {
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
NSError *error = nil;
NSURL *relaunchURLToCopy = [NSURL fileURLWithPath:relaunchPathToCopy];
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
// We only need to run our copy of the app by spawning a task
// Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs
if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtURL:relaunchURLToCopy toURL:targetURL error:&error]) {
// Releasing quarantine is definitely important (didn't used to be) now that we launch AutoUpdate via LaunchServices
// Perhaps even if this fails, we should continue on in the hopes maybe this isn't a fatal error though
NSError *quarantineError = nil;
if (![fileManager releaseItemFromQuarantineAtRootURL:targetURL error:&quarantineError]) {
SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError);
}
relaunchPath = targetPath;
} else {
if (outError != NULL) {
*outError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SURelaunchError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
}
];
}
return NO;
}
}
NSString *relaunchToolPath = [[NSBundle bundleWithPath:relaunchPath] executablePath];
if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) {
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
if (outError != NULL) {
*outError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SURelaunchError
userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath]
}
];
}
// We intentionally don't abandon the update here so that the host won't initiate another.
return NO;
}
NSString *pathToRelaunch = [self.host bundlePath];
if ([self.updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [self.updaterDelegate pathToRelaunchForUpdater:self.updater];
}
NSString *dsaSignature = (self.updateItem.DSASignature == nil) ? @"" : self.updateItem.DSASignature;
NSArray *launchArguments = @[
pathToRelaunch,
self.host.bundlePath,
self.temporaryDirectory,
self.downloadPath,
dsaSignature,
@"1"]; // last one signifies the relaunch tool should exit & reply back to us immediately
// Make sure the launched task finishes & replies back.
// If it succeeds, it will have launched a second instance of the tool through LaunchServices
// This is necessary if we are a XPC process, because otherwise we risk exiting prematurely
// Further, we don't launch through LS here because we don't want to reference AppKit here
int terminationStatus = 0;
BOOL taskDidLaunch = NO;
@try {
NSTask *launchedTask = [NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:launchArguments];
[launchedTask waitUntilExit];
taskDidLaunch = YES;
terminationStatus = launchedTask.terminationStatus;
} @catch (NSException *exception) {
SULog(@"Raised exception when launching update tool: %@", exception);
}
if (!taskDidLaunch || terminationStatus != 0) {
if (taskDidLaunch) {
SULog(@"Update tool failed with exit code: %d", terminationStatus);
}
if (outError != NULL) {
*outError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SURelaunchError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while launching the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't launch relauncher at %@", relaunchToolPath]
}
];
}
return NO;
}
return YES;
}
- (BOOL)mayUpdateAndRestart
{
return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]);
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
assert(self.updateItem);
if (![self mayUpdateAndRestart])
{
#warning we may have to propogate this... or return a boolean
[self abortInstall];
return;
}
// Give the host app an opportunity to postpone the install and relaunch.
if (!self.postponedOnce && [self.updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
{
// NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
// [invocation setSelector:@selector(installWithToolAndRelaunch:)];
// [invocation setArgument:&relaunch atIndex:2];
// [invocation setTarget:self];
// self.postponedOnce = YES;
// if ([self.updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
// return;
// }
}
uint8_t response[2] = {(uint8_t)relaunch, (uint8_t)showUI};
NSData *responseData = [NSData dataWithBytes:response length:sizeof(response)];
[self.remotePort sendMessageWithIdentifier:SUResumeInstallationToStage2 data:responseData completion:^(BOOL success) {
if (!success) {
dispatch_async(dispatch_get_main_queue(), ^{
NSError *remoteError =
[NSError
errorWithDomain:SUSparkleErrorDomain
code:SUInstallationError
userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while running the updater. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey:@"The remote port connection failed to send resume install message"
}
];
[self.delegate installerIsRequestingAbortInstallWithError:remoteError];
});
} else {
// We'll terminate later when the installer tells us stage 2 is done
}
}];
}
- (void)abortInstall
{
if (self.localPort != nil) {
[self.localPort invalidate];
self.localPort = nil;
}
if (self.remotePort != nil) {
[self.remotePort invalidate];
self.remotePort = nil;
}
}
@end
+13 -9
View File
@@ -2,18 +2,22 @@
// SUProbingUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/7/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUPROBINGUPDATEDRIVER_H
#define SUPROBINGUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUBasicUpdateDriver.h"
#import "SUUpdateDriver.h"
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
@protocol SUUpdaterDelegate;
@interface SUProbingUpdateDriver : NSObject <SUUpdateDriver>
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
// This replaces the old SUStatusChecker.
@interface SUProbingUpdateDriver : SUBasicUpdateDriver
@end
#endif
NS_ASSUME_NONNULL_END
+33 -15
View File
@@ -2,38 +2,56 @@
// SUProbingUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/7/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUProbingUpdateDriver.h"
#import "SUUpdaterDelegate.h"
#import "SUBasicUpdateDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUProbingUpdateDriver () <SUBasicUpdateDriverDelegate>
@property (nonatomic, readonly) SUBasicUpdateDriver *basicDriver;
@end
@implementation SUProbingUpdateDriver
// Stop as soon as we have an answer! Since the superclass implementations are not called, we are responsible for notifying the delegate.
@synthesize basicDriver = _basicDriver;
- (void)didFindValidUpdate
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(id <SUUpdaterDelegate>)updaterDelegate
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)])
[self.updaterDelegate updater:self.updater didFindValidUpdate:self.updateItem];
NSDictionary *userInfo = (self.updateItem != nil) ? @{ SUUpdaterAppcastItemNotificationKey: self.updateItem } : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:self.updater userInfo:userInfo];
self = [super init];
if (self != nil) {
_basicDriver = [[SUBasicUpdateDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(void (^)(void))completionBlock
{
[self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:NO completion:completionBlock];
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)__unused appcastItem
{
// Stop as soon as we have an answer
[self abortUpdate];
}
- (void)didNotFindUpdate
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)__unused error
{
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[self.updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
// Silently fail; the user doesn't need to know about the error
[self abortUpdate];
}
- (void)abortUpdate
{
[self.basicDriver abortUpdateWithError:nil];
}
@end
+12 -7
View File
@@ -2,18 +2,23 @@
// SUScheduledUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/15/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUSCHEDULEDUPDATEDRIVER_H
#define SUSCHEDULEDUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUUpdateDriver.h"
#import "SUUIBasedUpdateDriver.h"
@interface SUScheduledUpdateDriver : SUUIBasedUpdateDriver
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
@protocol SUUserDriver, SUUpdaterDelegate;
@interface SUScheduledUpdateDriver : NSObject <SUUpdateDriver>
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
@end
#endif
NS_ASSUME_NONNULL_END
+33 -27
View File
@@ -2,57 +2,63 @@
// SUScheduledUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/15/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUScheduledUpdateDriver.h"
#import "SUHost.h"
#import "SUErrors.h"
#import "SUUpdaterDelegate.h"
#import "SUVersionComparisonProtocol.h"
#import "SUUserDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUScheduledUpdateDriver ()
@interface SUScheduledUpdateDriver() <SUUIBasedUpdateDriverDelegate>
@property (assign) BOOL showErrors;
@property (nonatomic, readonly) SUUIBasedUpdateDriver *uiDriver;
@end
@implementation SUScheduledUpdateDriver
@synthesize showErrors;
@synthesize uiDriver = _uiDriver;
- (void)didFindValidUpdate
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
{
self.showErrors = YES; // We only start showing errors after we present the UI for the first time.
[super didFindValidUpdate];
self = [super init];
if (self != nil) {
_uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
- (void)didNotFindUpdate
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(void (^)(void))completionBlock
{
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[self.updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:NO completion:completionBlock];
}
- (void)abortUpdateWithError:(NSError *)error
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)__unused error
{
if (self.showErrors) {
[super abortUpdateWithError:error];
} else {
// Call delegate separately here because otherwise it won't know we stopped.
// Normally this gets called by the superclass
if ([self.updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
[self.updaterDelegate updater:self.updater didAbortWithError:error];
}
// Don't tell the user that no update was found or some appcast fetch error occurred for scheduled update checks
[self abortUpdateWithError:nil];
}
[self abortUpdate];
}
- (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
{
[self abortUpdateWithError:error];
}
- (void)abortUpdate
{
[self abortUpdateWithError:nil];
}
- (void)abortUpdateWithError:(nullable NSError *)error
{
[self.uiDriver abortUpdateWithError:error];
}
@end
+26 -10
View File
@@ -2,22 +2,38 @@
// SUUIBasedUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/5/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUUIBASEDUPDATEDRIVER_H
#define SUUIBASEDUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUBasicUpdateDriver.h"
@class SUStatusController;
NS_ASSUME_NONNULL_BEGIN
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver
@protocol SUUIBasedUpdateDriverDelegate <NSObject>
- (instancetype)initWithUpdater:(id)updater updaterDelegate:(id<SUUpdaterDelegate>)updaterDelegate userDriver:(id<SUUserDriver>)userDriver host:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle;
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
- (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
@optional
- (void)basicDriverDidFinishLoadingAppcast;
@end
#endif
@class SUHost;
@protocol SUUserDriver, SUUpdaterDelegate;
@interface SUUIBasedUpdateDriver : NSObject
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(id<SUUIBasedUpdateDriverDelegate>)delegate;
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock;
@property (nonatomic, readonly) id<SUUserDriver> userDriver;
- (void)abortUpdateWithError:(nullable NSError *)error;
@end
NS_ASSUME_NONNULL_END
+100 -120
View File
@@ -2,32 +2,80 @@
// SUUIBasedUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/5/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUUIBasedUpdateDriver.h"
#import "SUUpdaterDelegate.h"
#import "SUCoreBasedUpdateDriver.h"
#import "SUUserDriver.h"
#import "SUHost.h"
#import "SUConstants.h"
#import "SUUpdaterDelegate.h"
#import "SUAppcastItem.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUUIBasedUpdateDriver() <SUCoreBasedUpdateDriverDelegate>
@property (nonatomic, readonly) SUCoreBasedUpdateDriver *coreDriver;
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, weak, readonly) id updater;
@property (weak, nonatomic, readonly) id<SUUpdaterDelegate> updaterDelegate;
@property (nonatomic, weak, readonly) id<SUUIBasedUpdateDriverDelegate> delegate;
@end
@implementation SUUIBasedUpdateDriver
- (instancetype)initWithUpdater:(id)anUpdater updaterDelegate:(id<SUUpdaterDelegate>)updaterDelegate userDriver:(id<SUUserDriver>)userDriver host:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle
@synthesize coreDriver = _coreDriver;
@synthesize host = _host;
@synthesize updater = _updater;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize userDriver = _userDriver;
@synthesize delegate = _delegate;
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate delegate:(id<SUUIBasedUpdateDriverDelegate>)delegate
{
if ((self = [super initWithUpdater:anUpdater updaterDelegate:updaterDelegate userDriver:userDriver host:host sparkleBundle:sparkleBundle])) {
self.automaticallyInstallUpdates = NO;
self = [super init];
if (self != nil) {
_userDriver = userDriver;
_delegate = delegate;
_updater = updater;
_updaterDelegate = updaterDelegate;
_host = host;
_coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
// This indicates if automatic updates are allowed even if they may not be turned on at the moment
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(void (^)(void))completionBlock
{
[self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:includesSkippedUpdates completion:completionBlock];
}
- (void)basicDriverDidFinishLoadingAppcast
{
if ([self.delegate respondsToSelector:@selector(basicDriverDidFinishLoadingAppcast)]) {
[self.delegate basicDriverDidFinishLoadingAppcast];
}
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem
{
[self.userDriver showUpdateFoundWithAppcastItem:updateItem allowsAutomaticUpdates:[self allowsAutomaticUpdates] reply:^(SUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateAlertFinishedForUpdateItem:updateItem withChoice:choice];
if (choice == SUDownloadUpdateDone) {
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
}
});
}];
}
- (BOOL)allowsAutomaticUpdates
{
// Make sure the host allows automatic updates and
@@ -35,42 +83,7 @@
return (self.host.allowsAutomaticUpdates && [[NSFileManager defaultManager] isWritableFileAtPath:self.host.bundlePath]);
}
- (void)didFindValidUpdate
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[self.updaterDelegate updater:self.updater didFindValidUpdate:self.updateItem];
}
if (self.automaticallyInstallUpdates) {
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
return;
}
[self.userDriver showUpdateFoundWithAppcastItem:self.updateItem allowsAutomaticUpdates:[self allowsAutomaticUpdates] reply:^(SUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateAlertFinishedWithChoice:choice];
});
}];
}
- (void)didNotFindUpdate
{
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)])
[self.updaterDelegate updaterDidNotFindUpdate:self.updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
if (!self.automaticallyInstallUpdates) {
[self showNotice:^{
[self.userDriver showUpdateNotFoundWithAcknowledgement:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self abortUpdate];
});
}];
}];
}
}
- (void)updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice
- (void)updateAlertFinishedForUpdateItem:(SUAppcastItem *)updateItem withChoice:(SUUpdateAlertChoice)choice
{
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
@@ -82,125 +95,92 @@
break;
case SUDownloadUpdateCancelled:
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download != nil) {
if ([self.updaterDelegate respondsToSelector:@selector(userDidCancelDownload:)]) {
[self.updaterDelegate userDidCancelDownload:self.updater];
}
[self abortUpdate];
if ([self.updaterDelegate respondsToSelector:@selector(userDidCancelDownload:)]) {
[self.updaterDelegate userDidCancelDownload:self.updater];
}
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
});
break;
}
}];
[self downloadUpdate];
break;
}
case SUSkipThisVersionChoice:
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
break;
case SUInstallLaterChoice:
[self abortUpdate];
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
break;
}
}
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
- (void)coreDriverDidFinishDownloadingUpdate
{
[self.userDriver showDownloadDidReceiveResponse:response];
}
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
{
[self.userDriver showDownloadDidReceiveDataOfLength:length];
}
- (void)extractUpdate
{
// Now we have to extract the downloaded archive.
[self.userDriver showDownloadFinishedAndStartedExtractingUpdate];
[super extractUpdate];
}
- (void)unarchiverExtractedProgress:(double)progress
{
[self.userDriver showExtractionReceivedProgress:progress];
}
- (void)installerDidStart
- (void)installerDidStartInstalling
{
[self.userDriver showInstallingUpdate];
}
- (void)installerIsReadyForRelaunch
- (void)installerDidExtractUpdateWithProgress:(double)progress
{
[self.userDriver showExtractionReceivedProgress:progress];
}
- (void)installerDidFinishRelaunchPreparation
{
if (self.automaticallyInstallUpdates) {
[self installWithToolAndRelaunch:YES];
return;
}
[self.userDriver showExtractionFinishedAndReadyToInstallAndRelaunch:^(SUInstallUpdateStatus installUpdateStatus) {
dispatch_async(dispatch_get_main_queue(), ^{
switch (installUpdateStatus) {
case SUDismissUpdateInstallation:
[self abortUpdate];
break;
case SUInstallAndRelaunchUpdateNow:
[self installWithToolAndRelaunch:YES];
break;
}
[self.coreDriver finishInstallationWithResponse:installUpdateStatus];
});
}];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch
{
[super installWithToolAndRelaunch:relaunch];
}
- (void)terminateApp
- (void)coreDriverIsRequestingAppTermination
{
// if a user chooses to NOT relaunch the app (as is the case with WebKit
// when it asks you if you are sure you want to close the app with multiple
// tabs open), the status window still stays on the screen and obscures
// other windows; with this fix, it doesn't
[self.userDriver dismissUpdateInstallation];
[super terminateApp];
[self.userDriver terminateApplication];
}
- (void)abortUpdateWithError:(NSError *)error
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
{
[self showNotice:^{
[self.userDriver showUpdaterError:error acknowledgement:^{
// A delegate may want to handle this type of error specially
[self.delegate basicDriverIsRequestingAbortUpdateWithError:error];
}
- (void)coreDriverIsRequestingAbortUpdateWithError:(NSError *)error
{
[self.delegate uiDriverIsRequestingAbortUpdateWithError:error];
}
- (void)abortUpdateWithError:(nullable NSError *)error
{
void (^abortUpdate)(void) = ^{
[self.coreDriver abortUpdateWithError:error];
[self.userDriver dismissUpdateInstallation];
};
if (error != nil) {
NSError *nonNullError = error;
[self.userDriver showUpdaterError:nonNullError acknowledgement:^{
dispatch_async(dispatch_get_main_queue(), ^{
[super abortUpdateWithError:error];
abortUpdate();
});
}];
}];
}
// Calling deprecated modal alert methods just to preserve backwards compatibility
- (void)showNotice:(void (^)(void))noticeHandler
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([self.updaterDelegate respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
[self.updaterDelegate updaterWillShowModalAlert:self.updater];
} else {
abortUpdate();
}
noticeHandler();
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidShowModalAlert:)]) {
[self.updaterDelegate updaterDidShowModalAlert:self.updater];
}
#pragma clang diagnostic pop
}
@end
+6 -24
View File
@@ -2,36 +2,18 @@
// SUUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/7/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/15/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUUPDATEDRIVER_H
#define SUUPDATEDRIVER_H
NS_ASSUME_NONNULL_BEGIN
#import <Foundation/Foundation.h>
@protocol SUUpdateDriver <NSObject>
extern NSString *const SUUpdateDriverFinishedNotification;
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(void (^)(void))completionBlock;
@protocol SUUpdaterDelegate, SUUserDriver;
@class SUHost, SUUpdater;
@interface SUUpdateDriver : NSObject <NSURLDownloadDelegate>
@property (readonly, weak) id updater;
@property (strong) SUHost *host;
@property (nonatomic, readonly, weak) id<SUUpdaterDelegate> updaterDelegate;
@property (nonatomic, readonly) id<SUUserDriver> userDriver;
@property (nonatomic, readonly) NSBundle *sparkleBundle;
- (instancetype)initWithUpdater:(id)updater updaterDelegate:(id<SUUpdaterDelegate>)updaterDelegate userDriver:(id<SUUserDriver>)userDriver host:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle;
- (void)checkForUpdatesAtURL:(NSURL *)URL;
- (void)abortUpdate;
@property (getter=isInterruptible, readonly) BOOL interruptible;
@property (readonly) BOOL finished;
@property BOOL automaticallyInstallUpdates;
@end
#endif
NS_ASSUME_NONNULL_END
-69
View File
@@ -1,69 +0,0 @@
//
// SUUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/7/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUpdateDriver.h"
#import "SUHost.h"
#import "SULog.h"
#import "SUUserDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
@interface SUUpdateDriver ()
@property (weak) id updater;
@property (copy) NSURL *appcastURL;
@property (getter=isInterruptible) BOOL interruptible;
@end
@implementation SUUpdateDriver
@synthesize updater;
@synthesize userDriver = _userDriver;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize sparkleBundle = _sparkleBundle;
@synthesize host;
@synthesize interruptible;
@synthesize finished;
@synthesize appcastURL;
@synthesize automaticallyInstallUpdates;
// Note the updater type is intentionally left as 'id' instead of SUUpdater*
// We don't want to include a depedency to SUUpdater. The only reason we pass an updater is to pass it in
// when calling methods on its delegate. This is an unfortunate legacy design decision (i.e, these methods should have
// never taken an updater instance to begin with)
- (instancetype)initWithUpdater:(id)anUpdater updaterDelegate:(id<SUUpdaterDelegate>)updaterDelegate userDriver:(id<SUUserDriver>)userDriver host:(SUHost *)aHost sparkleBundle:(NSBundle *)sparkleBundle
{
if ((self = [super init])) {
self.updater = anUpdater;
self.host = aHost;
_userDriver = userDriver;
_updaterDelegate = updaterDelegate;
_sparkleBundle = sparkleBundle;
}
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (void)checkForUpdatesAtURL:(NSURL *)URL
{
self.appcastURL = URL;
}
- (void)abortUpdate
{
[self setValue:@YES forKey:@"finished"];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
}
@end
-10
View File
@@ -92,16 +92,6 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
- (void)checkForUpdatesInBackground;
/*!
Checks for updates and, if available, immediately downloads and installs them.
A progress dialog is shown but the user will never be prompted to read the
release notes.
You may want to respond to the userDidCancelDownload delegate method in case
the user clicks the "Cancel" button while the update is downloading.
*/
- (void)installUpdatesIfAvailable;
/*!
Returns the date of last update check.
+48 -57
View File
@@ -10,16 +10,16 @@
#import "SUUpdaterDelegate.h"
#import "SUHost.h"
#import "SUUpdatePermissionPromptResult.h"
#import "SUAutomaticUpdateDriver.h"
#import "SUProbingUpdateDriver.h"
#import "SUUserInitiatedUpdateDriver.h"
#import "SUScheduledUpdateDriver.h"
#import "SUUpdateDriver.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUCodeSigningVerifier.h"
#import "SUSystemProfiler.h"
#include <SystemConfiguration/SystemConfiguration.h>
#import "SUScheduledUpdateDriver.h"
#import "SUProbingUpdateDriver.h"
#import "SUUserInitiatedUpdateDriver.h"
#import "SUAutomaticUpdateDriver.h"
#import "SURemoteMessagePort.h"
#import "SUMessageTypes.h"
@@ -39,7 +39,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@property (strong) NSBundle *sparkleBundle;
@property (readonly, copy) NSURL *parameterizedFeedURL;
@property (strong) SUUpdateDriver *driver;
@property (strong) id <SUUpdateDriver> driver;
@property (strong) SUHost *host;
@end
@@ -73,8 +73,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
delegate = theDelegate;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that
// We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1];
@@ -179,17 +177,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
[self resetUpdateCycle];
}
- (void)updateDriverDidFinish:(NSNotification *)note
{
if ([note object] == self.driver && [self.driver finished])
{
self.driver = nil;
[self.userDriver showUpdateInProgress:NO];
[self updateLastUpdateCheckDate];
[self scheduleNextUpdateCheck];
}
}
- (NSDate *)lastUpdateCheckDate
{
return [self.host objectForUserDefaultsKey:SULastCheckTimeKey];
@@ -197,9 +184,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
- (void)updateLastUpdateCheckDate
{
[self willChangeValueForKey:@"lastUpdateCheckDate"];
[self willChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
[self didChangeValueForKey:@"lastUpdateCheckDate"];
[self didChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
}
- (void)scheduleNextUpdateCheck
@@ -243,7 +230,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// RUNS ON ITS OWN THREAD
// updater should be passed as a weak reference
static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SUUpdateDriver *inDriver)
static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id <SUUpdateDriver> inDriver)
{
@try {
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
@@ -307,48 +294,51 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SU
// Wouldn't want to annoy users on dial-up by establishing a connection every
// hour or so:
SUUpdateDriver *theUpdateDriver =
[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver alloc] : [SUScheduledUpdateDriver alloc])
initWithUpdater:self
updaterDelegate:self.delegate
userDriver:self.userDriver
host:self.host
sparkleBundle:self.sparkleBundle];
id <SUUpdateDriver> updateDriver;
if ([self automaticallyDownloadsUpdates]) {
updateDriver =
[[SUAutomaticUpdateDriver alloc]
initWithHost:self.host
sparkleBundle:self.sparkleBundle
updater:self
updaterDelegate:self.delegate];
} else {
updateDriver =
[[SUScheduledUpdateDriver alloc]
initWithHost:self.host
sparkleBundle:self.sparkleBundle
updater:self
userDriver:self.userDriver
updaterDelegate:self.delegate];
}
// We don't want the rechability check to act on the driver if the updater is going near death
// We don't want the reachability check to act on the driver if the updater is going near death
__weak SUUpdater *updater = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
SUCheckForUpdatesInBgReachabilityCheck(updater, theUpdateDriver);
SUCheckForUpdatesInBgReachabilityCheck(updater, updateDriver);
});
}
- (void)checkForUpdates
{
if (self.driver && [self.driver isInterruptible]) {
if (self.driver != nil) {
[self.driver abortUpdate];
}
SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self updaterDelegate:self.delegate userDriver:self.userDriver host:self.host sparkleBundle:self.sparkleBundle];
// if (self.driver && [self.driver isInterruptible]) {
// [self.driver abortUpdate];
// }
id <SUUpdateDriver> theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithHost:self.host sparkleBundle:self.sparkleBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate];
[self checkForUpdatesWithDriver:theUpdateDriver];
}
- (void)checkForUpdateInformation
{
[self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self updaterDelegate:self.delegate userDriver:self.userDriver host:self.host sparkleBundle:self.sparkleBundle]];
[self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithHost:self.host updater:self updaterDelegate:self.delegate]];
}
- (void)installUpdatesIfAvailable
{
if (self.driver && [self.driver isInterruptible]) {
[self.driver abortUpdate];
}
SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self updaterDelegate:self.delegate userDriver:self.userDriver host:self.host sparkleBundle:self.sparkleBundle];
theUpdateDriver.automaticallyInstallUpdates = YES;
[self checkForUpdatesWithDriver:theUpdateDriver];
}
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
- (void)checkForUpdatesWithDriver:(id <SUUpdateDriver> )d
{
if ([self updateInProgress]) { return; }
@@ -376,10 +366,17 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SU
[self checkIfConfiguredProperly];
NSURL *theFeedURL = [self parameterizedFeedURL];
if (theFeedURL) // Use a NIL URL to cancel quietly.
[self.driver checkForUpdatesAtURL:theFeedURL];
else
// Use a NIL URL to cancel quietly.
if (theFeedURL) {
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] completion:^{
self.driver = nil;
[self.userDriver showUpdateInProgress:NO];
[self updateLastUpdateCheckDate];
[self scheduleNextUpdateCheck];
}];
} else {
[self.driver abortUpdate];
}
}
- (void)cancelNextUpdateCycle
@@ -570,10 +567,8 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SU
// Abort any on-going updates
// A driver could be retained by another object (eg: a timer),
// so not aborting could mean it stays alive longer than we'd want
if ([self updateInProgress]) {
[self.driver abortUpdate];
self.driver = nil;
}
[self.driver abortUpdate];
self.driver = nil;
}
- (BOOL)updateInProgress
@@ -582,10 +577,6 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SU
return YES;
}
if (self.driver != nil && !self.driver.finished) {
return YES;
}
SURemoteMessagePort *remotePort = [[SURemoteMessagePort alloc] initWithServiceName:SUAutoUpdateServiceNameForHost(self.host) invalidationCallback:^{}];
BOOL installerAlive = (remotePort != nil);
[remotePort invalidate];
+1 -1
View File
@@ -10,7 +10,7 @@
#import "SUExport.h"
@protocol SUVersionComparison;
@class SUUpdater, SUAppcastItem;
@class SUUpdater, SUAppcast, SUAppcastItem;
// -----------------------------------------------------------------------------
// SUUpdater Notifications for events that might be interesting to more than just the delegate
+12 -8
View File
@@ -2,18 +2,22 @@
// SUUserInitiatedUpdateDriver.h
// Sparkle
//
// Created by Andy Matuschak on 5/30/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SUUSERINITIATEDUPDATEDRIVER_H
#define SUUSERINITIATEDUPDATEDRIVER_H
#import <Foundation/Foundation.h>
#import "SUUIBasedUpdateDriver.h"
#import "SUUpdateDriver.h"
@interface SUUserInitiatedUpdateDriver : SUUIBasedUpdateDriver
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
@protocol SUUpdaterDelegate, SUUserDriver;
@interface SUUserInitiatedUpdateDriver : NSObject <SUUpdateDriver>
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
@end
#endif
NS_ASSUME_NONNULL_END
+34 -36
View File
@@ -2,85 +2,83 @@
// SUUserInitiatedUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/30/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
// Created by Mayur Pawashe on 3/18/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUUserInitiatedUpdateDriver.h"
#import "SUHost.h"
#import "SUUIBasedUpdateDriver.h"
#import "SUUserDriver.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUUserInitiatedUpdateDriver ()
@interface SUUserInitiatedUpdateDriver () <SUUIBasedUpdateDriverDelegate>
@property (assign, getter=isCanceled) BOOL canceled;
@property (nonatomic, readonly) SUUIBasedUpdateDriver *uiDriver;
@property (nonatomic) BOOL canceledCheckForUpdates;
@end
@implementation SUUserInitiatedUpdateDriver
@synthesize canceled;
@synthesize uiDriver = _uiDriver;
@synthesize canceledCheckForUpdates = _canceledCheckForUpdates;
- (void)dismissCheckingForUpdates
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
{
[self.userDriver dismissUserInitiatedUpdateCheck];
}
- (void)cancelCheckForUpdates:(id)__unused sender
{
if (!self.canceled) {
[self dismissCheckingForUpdates];
self.canceled = YES;
self = [super init];
if (self != nil) {
_uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self];
}
return self;
}
- (void)checkForUpdatesAtURL:(NSURL *)URL
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(void (^)(void))completionBlock
{
[self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SUUserInitiatedCheckStatus completionStatus) {
[self.uiDriver.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SUUserInitiatedCheckStatus completionStatus) {
switch (completionStatus) {
case SUUserInitiatedCheckDone:
break;
case SUUserInitiatedCheckCancelled:
dispatch_async(dispatch_get_main_queue(), ^{
[self cancelCheckForUpdates:nil];
self.canceledCheckForUpdates = YES;
[self.uiDriver.userDriver dismissUserInitiatedUpdateCheck];
});
break;
}
}];
[super checkForUpdatesAtURL:URL];
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:YES completion:completionBlock];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
{
if (self.isCanceled)
{
[self abortUpdateWithError:error];
}
- (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
{
[self abortUpdateWithError:error];
}
- (void)basicDriverDidFinishLoadingAppcast
{
if (self.canceledCheckForUpdates) {
[self abortUpdate];
return;
}
[self dismissCheckingForUpdates];
[super appcastDidFinishLoading:ac];
}
- (void)abortUpdateWithError:(NSError *)error
{
[self dismissCheckingForUpdates];
[super abortUpdateWithError:error];
}
- (void)abortUpdate
{
[self dismissCheckingForUpdates];
[super abortUpdate];
[self abortUpdateWithError:nil];
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
- (void)abortUpdateWithError:(nullable NSError *)error
{
// We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version.
return [[self class] hostSupportsItem:ui] && [self isItemNewer:ui];
[self.uiDriver.userDriver dismissUserInitiatedUpdateCheck];
[self.uiDriver abortUpdateWithError:error];
}
@end