Compare commits

...
466 Commits
Author SHA1 Message Date
Oleg Krupnov 7f1555d525 Merge branch 'master' of https://github.com/sparkle-project/Sparkle
# Conflicts:
#	CHANGELOG
#	Configurations/ConfigBinaryDelta.xcconfig
#	Configurations/ConfigCommon.xcconfig
#	Configurations/ConfigFramework.xcconfig
#	Configurations/ConfigTestApp.xcconfig
#	Configurations/ConfigUnitTest.xcconfig
#	Documentation/.gitignore
#	Documentation/Doxyfile
#	LICENSE
#	Resources/Images.xcassets/AppIcon.appiconset/Contents.json
#	Resources/Images.xcassets/AppIcon.appiconset/icon_128x128.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_128x128@2x.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_16x16.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_16x16@2x.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_256x256.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_32x32.png
#	Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
#	Resources/Screenshot.png
#	Resources/Sparkle.png
#	Sparkle.podspec
#	Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme
#	Sparkle/Autoupdate/Autoupdate-Info.plist
#	Sparkle/Autoupdate/Autoupdate.m
#	Sparkle/SUAppcast.h
#	Sparkle/SUAppcast.m
#	Sparkle/SUAppcastItem.h
#	Sparkle/SUAppcastItem.m
#	Sparkle/SUAutomaticUpdateAlert.h
#	Sparkle/SUAutomaticUpdateAlert.m
#	Sparkle/SUAutomaticUpdateDriver.m
#	Sparkle/SUBasicUpdateDriver.m
#	Sparkle/SUBinaryDeltaApply.m
#	Sparkle/SUBinaryDeltaCommon.h
#	Sparkle/SUBinaryDeltaCommon.m
#	Sparkle/SUBinaryDeltaCreate.h
#	Sparkle/SUBinaryDeltaCreate.m
#	Sparkle/SUBinaryDeltaTool.m
#	Sparkle/SUBinaryDeltaUnarchiver.m
#	Sparkle/SUCodeSigningVerifier.m
#	Sparkle/SUConstants.h
#	Sparkle/SUDSAVerifier.h
#	Sparkle/SUDSAVerifier.m
#	Sparkle/SUDiskImageUnarchiver.m
#	Sparkle/SUErrors.h
#	Sparkle/SUExport.h
#	Sparkle/SUGuidedPackageInstaller.h
#	Sparkle/SUGuidedPackageInstaller.m
#	Sparkle/SUHost.h
#	Sparkle/SUHost.m
#	Sparkle/SUInstaller.h
#	Sparkle/SUInstaller.m
#	Sparkle/SUPackageInstaller.m
#	Sparkle/SUPipedUnarchiver.m
#	Sparkle/SUPlainInstaller.m
#	Sparkle/SUPlainInstallerInternals.m
#	Sparkle/SUProbingUpdateDriver.m
#	Sparkle/SUScheduledUpdateDriver.m
#	Sparkle/SUStandardVersionComparator.h
#	Sparkle/SUStatus.xib
#	Sparkle/SUStatusController.m
#	Sparkle/SUSystemProfiler.m
#	Sparkle/SUUIBasedUpdateDriver.h
#	Sparkle/SUUIBasedUpdateDriver.m
#	Sparkle/SUUnarchiver.h
#	Sparkle/SUUnarchiver.m
#	Sparkle/SUUpdateAlert.h
#	Sparkle/SUUpdateAlert.m
#	Sparkle/SUUpdateDriver.h
#	Sparkle/SUUpdateDriver.m
#	Sparkle/SUUpdatePermissionPrompt.h
#	Sparkle/SUUpdatePermissionPrompt.m
#	Sparkle/SUUpdater.h
#	Sparkle/SUUpdater.m
#	Sparkle/SUUserInitiatedUpdateDriver.m
#	Sparkle/SUVersionComparisonProtocol.h
#	Sparkle/SUVersionDisplayProtocol.h
#	Sparkle/SUWindowController.m
#	Sparkle/Sparkle-Info.plist
#	Sparkle/Sparkle.pch
#	Sparkle/ar.lproj/SUUpdateAlert.xib
#	Sparkle/ar.lproj/Sparkle.strings
#	Sparkle/ca.lproj/SUAutomaticUpdateAlert.strings
#	Sparkle/ca.lproj/SUUpdateAlert.strings
#	Sparkle/ca.lproj/Sparkle.strings
#	Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/cs.lproj/SUUpdateAlert.xib
#	Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/cs.lproj/Sparkle.strings
#	Sparkle/cy.lproj/Sparkle.strings
#	Sparkle/da.lproj/SUUpdateAlert.xib
#	Sparkle/da.lproj/Sparkle.strings
#	Sparkle/de.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/de.lproj/SUUpdateAlert.xib
#	Sparkle/de.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/de.lproj/Sparkle.strings
#	Sparkle/el.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/el.lproj/SUUpdateAlert.xib
#	Sparkle/el.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/el.lproj/Sparkle.strings
#	Sparkle/en.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/en.lproj/SUUpdateAlert.xib
#	Sparkle/en.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/en.lproj/Sparkle.strings
#	Sparkle/es.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/es.lproj/SUUpdateAlert.xib
#	Sparkle/es.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/es.lproj/Sparkle.strings
#	Sparkle/fi.lproj/SUAutomaticUpdateAlert.strings
#	Sparkle/fi.lproj/SUUpdateAlert.strings
#	Sparkle/fi.lproj/Sparkle.strings
#	Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/fr.lproj/SUUpdateAlert.xib
#	Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/fr.lproj/Sparkle.strings
#	Sparkle/he.lproj/SUAutomaticUpdateAlert.strings
#	Sparkle/he.lproj/SUUpdateAlert.strings
#	Sparkle/he.lproj/Sparkle.strings
#	Sparkle/hu.lproj/Sparkle.strings
#	Sparkle/id.lproj/Sparkle.strings
#	Sparkle/is.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/is.lproj/SUUpdateAlert.xib
#	Sparkle/is.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/is.lproj/Sparkle.strings
#	Sparkle/it.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/it.lproj/SUUpdateAlert.xib
#	Sparkle/it.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/it.lproj/Sparkle.strings
#	Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/ja.lproj/SUUpdateAlert.xib
#	Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/ja.lproj/Sparkle.strings
#	Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/ko.lproj/SUUpdateAlert.xib
#	Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/ko.lproj/Sparkle.strings
#	Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/nb.lproj/SUUpdateAlert.xib
#	Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/nb.lproj/Sparkle.strings
#	Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/nl.lproj/SUUpdateAlert.xib
#	Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/nl.lproj/Sparkle.strings
#	Sparkle/no.lproj/SUAutomaticUpdateAlert.strings
#	Sparkle/no.lproj/SUUpdateAlert.strings
#	Sparkle/no.lproj/Sparkle.strings
#	Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/pl.lproj/SUUpdateAlert.xib
#	Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/pl.lproj/Sparkle.strings
#	Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/pt_BR.lproj/SUUpdateAlert.xib
#	Sparkle/pt_BR.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/pt_BR.lproj/Sparkle.strings
#	Sparkle/pt_PT.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/pt_PT.lproj/SUUpdateAlert.xib
#	Sparkle/pt_PT.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/pt_PT.lproj/Sparkle.strings
#	Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/ro.lproj/SUUpdateAlert.xib
#	Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/ro.lproj/Sparkle.strings
#	Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/ru.lproj/SUUpdateAlert.xib
#	Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/ru.lproj/Sparkle.strings
#	Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/sk.lproj/SUUpdateAlert.xib
#	Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/sk.lproj/Sparkle.strings
#	Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/sl.lproj/SUUpdateAlert.xib
#	Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/sv.lproj/SUUpdateAlert.xib
#	Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/sv.lproj/Sparkle.strings
#	Sparkle/th.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/th.lproj/SUUpdateAlert.xib
#	Sparkle/th.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/tr.lproj/SUUpdateAlert.xib
#	Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/tr.lproj/Sparkle.strings
#	Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/uk.lproj/SUUpdateAlert.xib
#	Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/zh_CN.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/zh_CN.lproj/SUUpdateAlert.xib
#	Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/zh_CN.lproj/Sparkle.strings
#	Sparkle/zh_TW.lproj/SUAutomaticUpdateAlert.xib
#	Sparkle/zh_TW.lproj/SUUpdateAlert.xib
#	Sparkle/zh_TW.lproj/SUUpdatePermissionPrompt.xib
#	Sparkle/zh_TW.lproj/Sparkle.strings
#	TestApplication/After Update/Sparkle Updated Test App.xcodeproj/project.pbxproj
#	TestApplication/After Update/Sparkle Updated Test App/AppDelegate.h
#	TestApplication/After Update/Sparkle Updated Test App/AppDelegate.m
#	TestApplication/After Update/Sparkle Updated Test App/Base.lproj/MainMenu.xib
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/Contents.json
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128.png
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128@2x.png
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16.png
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16@2x.png
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32.png
#	TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32@2x.png
#	TestApplication/After Update/Sparkle Updated Test App/Info.plist
#	TestApplication/After Update/Sparkle Updated Test App/main.m
#	TestApplication/English.lproj/InfoPlist.strings
#	TestApplication/English.lproj/MainMenu.xib
#	TestApplication/TestApplication-Info.plist
#	Tests/Resources/SparkleTestCodeSignApp.zip
#	Tests/Resources/signed-test-file.txt
#	Tests/Resources/test archive.zip
#	Tests/Resources/test-pubkey.pem
#	Tests/Resources/test.sparkle_guided.pkg
#	Tests/SUBinaryDeltaTest.m
#	Tests/SUCodeSigningVerifierTest.m
#	Tests/SUDSAVerifierTest.m
#	Tests/SUInstallerTest.m
#	Tests/SUPipedUnarchiverTest.m
#	Tests/SUUpdaterTest.m
#	Tests/SUVersionComparisonTest.m
#	Tests/SparkleTests-Info.plist
#	Vendor/CocoatechCore/NTSynchronousTask.m
#	Vendor/bsdiff/sais.c
#	Vendor/bsdiff/sais.h
2015-06-23 16:00:18 +03:00
Oleg Krupnov be8f682a34 Merging with the main fork 2015-06-23 15:52:35 +03:00
Oleg Krupnov d1904ed606 Updated to 10.10 losing all changes 2015-06-23 13:41:37 +03:00
Jake Petroules 51b62de4cb Fix some warnings. 2015-06-13 02:30:13 -07:00
Jake Petroules 4643becaff Upgrade settings. 2015-06-13 02:22:20 -07:00
Jake Petroules 4bbfac11aa Fix build with < 10.9 SDK. 2015-06-06 09:23:26 -07:00
Jake Petroules 0f4f7c3509 Fix build with < 10.10 SDK. 2015-06-06 08:40:17 -07:00
Jake Petroules 91af4db0c0 Update Podspec for 1.10.0. 2015-06-06 08:35:07 -07:00
Jake Petroules 21a894cd63 Fix warnings in unit test. 2015-06-06 08:35:07 -07:00
Jake Petroules e8035cc912 Silence warnings in third party code. 2015-06-06 08:35:07 -07:00
Jake Petroules 342aec164d Comment problematic clang-format property. 2015-06-06 08:35:07 -07:00
Kornel 517f7862ab Merge pull request #534 from zorgiepoo/app-update-validation
Improved app update validation
2015-06-06 11:53:41 +01:00
Zorg 6ca90a8c11 Clarification that DSA keys differ or are absent 2015-06-05 22:22:05 -04:00
Zorg a7e8e2aad5 Validate with the new public DSA key, not the old one 2015-06-05 21:59:32 -04:00
Zorg e9e5791e51 s/Pubic/Public/ 2015-06-05 21:46:52 -04:00
Zorg 7c705e5fff Remove redundant check that SUDSAVerifier does 2015-06-05 21:39:57 -04:00
Zorg b1d887264f Fix package validation from previous commit
Modern packages aren't distributed as bundles, and we wouldn't be able to obtain a "new" public DSA key from an update
2015-06-05 21:37:09 -04:00
Zorg da06dc80d6 Rely on code signing and the DSA key in the new app
Instead of relying on whether the DSA signature is provided in the appcast (which we can't trust), we rely on detecting if the public key in the new and old app differ. If they differ, then the code signatures from both apps must match. The idea is that code signing is reliable in being able to tell that the Info.plist and public DSA files came from the developer and are intact. This still allows a developer to lose access to their DSA private key, or to their Apple code signature, and be able to push new updates (as long as they didn't lose access to both). The new change, however, is that if the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed.
2015-06-05 18:57:36 -04:00
Kornel 2ed2f3def3 Merge pull request #554 from MaddTheSane/headers
Import the Foundation umbrella header in all the public headers.
2015-06-05 00:04:12 +01:00
C.W. Betts 3292c4ea10 Import the Foundation umbrella header in all the public headers.
This should prevent any undefined declaration warnings.
2015-06-04 11:13:48 -06:00
Kornel Lesiński fbc7a7fbf7 Log URL on appcast error 2015-05-27 19:16:55 +01:00
Kornel Lesiński 4733fe7785 Log URL on download error 2015-05-27 19:16:54 +01:00
Victor Figueiredo 8585d06bb5 pt-BR localization update 2015-05-21 00:27:57 +01:00
Kornel 4d111b96e4 Merge pull request #541 from zorgiepoo/unable-quarantine-fix
Only remove quarantine with -[NSURL setResourceValue:] when it's present
2015-05-10 02:15:54 +02:00
Zorg 0557a5ba5c Only remove quarantine with setResourceValue: when it's present
This should stop "Unable to quarantine: 93" messages from showing up in the console. Fixes issue #452
2015-05-08 23:55:23 -04:00
Zorg 3a304123d9 Renaming newBundlePath to installSourcePath 2015-05-04 23:15:17 -04:00
Zorg 87da4cc0f2 Distinguish between install path found and update being a package 2015-05-04 22:49:57 -04:00
Kornel 12f29384ea Merge pull request #539 from vslavik/fix-incomplete-implementation-warning
Fix appcastDidFinishLoading: incomplete implementation warning
2015-05-04 15:13:32 +02:00
Václav Slavík 253f7c1023 Fix appcastDidFinishLoading: incomplete implementation warning
appcastDidFinishLoading: was declared in SUUIBasedUpdateDriver, but
defined and used in SUUIBasedUpdateDriver. Move the declaration back to
the base class where it belongs.
2015-05-04 14:34:49 +02:00
Kornel Lesiński f19038e5fe Add test cases 2015-05-02 23:16:58 +02:00
Kornel Lesiński 619e4a60a2 Fixed test name 2015-05-02 22:49:55 +02:00
Kornel 6e92311aaa Merge pull request #537 from antonc27/master
Fix for crash while applying delta update
2015-04-29 18:41:57 +01:00
antonc27 7d7aeb9f65 - Fix for crash while applying delta update 2015-04-29 17:54:58 +02:00
Jake Petroules ae3d04660e Merge pull request #535 from tonyarnold/hotfix/foundation-import
Properly import Foundation to fix errors when building as a module
2015-04-27 18:36:31 -07:00
Tony Arnold 2068da1cf9 Properly import Foundationto fix errors when building as a module 2015-04-28 09:40:54 +10:00
Zorg 19fdb9276d Only do DSA verification if public key is available 2015-04-27 19:18:21 -04:00
Zorg f55d2a4439 Host app needn't be signed to verify signature of updated app 2015-04-26 16:28:17 -04:00
Zorg 28ea47f796 Improved app update validation. See discussion in issue #441
If an invalid DSA or invalid code signature is provided, the update will fail, regardless if one of these requirements is valid. The logic before is that the update will succeed if either a valid DSA or matched code signature is provided.
This still allows a code signature to change, be added, or be removed, as long as the DSA and the code signature (if provided) is valid. If no DSA is provided, then this is not possible, and the code signature from the host and update app must match.
2015-04-26 13:58:40 -04:00
Kornel Lesiński 9646b0b790 Optimized images 2015-04-26 00:31:02 +01:00
Kornel Lesiński afb524a46a Yosemite screenshot 2015-04-26 00:22:57 +01:00
Kornel Lesiński 56ac1c931b Preserve underlying errors 2015-04-25 21:37:08 +01:00
Jake Petroules 3a788e9546 Merge pull request #532 from sparkle-project/guidedinstall
Simpler guided install opt-in
2015-04-25 13:20:33 -07:00
Jake Petroules 0b2f37beb9 Merge pull request #533 from sparkle-project/dedelegate
De-delegate
2015-04-25 13:12:20 -07:00
Kornel Lesiński 353a5635e1 Removed appcast delegate 2015-04-25 21:08:44 +01:00
Kornel Lesiński 35dfed44de Removed update alert delegate 2015-04-25 20:37:01 +01:00
Kornel Lesiński 3680b0bb67 Removed automatic update alert delegate 2015-04-25 20:36:59 +01:00
Kornel Lesiński 209d6db3a1 Test guided installation 2015-04-25 12:44:21 +01:00
Kornel Lesiński bb7af6145f Removed unused arg 2015-04-25 12:42:11 +01:00
Kornel Lesiński 77fd19a134 Use completion block instead of a delegate 2015-04-25 12:41:09 +01:00
Kornel Lesiński 38a70c61c4 Use package.sparkle_guided.pkg instead of .sparkle_guided.plist indirection 2015-04-25 12:38:32 +01:00
Jake Petroules d2fd67ac84 Merge pull request #529 from sparkle-project/testsymbols
Expose Sparkle symbols to unit test app
2015-04-24 18:42:40 -07:00
Kornel Lesiński f911c29bf0 Expose Sparkle symbols to unit test app 2015-04-24 10:59:25 +01:00
Kornel Lesiński 63052aa3d1 Cache strings 2015-04-24 01:22:36 +01:00
Kornel Lesiński eb28fe7ebd Updated changelog 2015-04-24 00:35:20 +01:00
Kornel Lesiński 06c6a3b7f2 Use Cocoa to pipe to unarchivers 2015-04-23 01:37:13 +01:00
Kornel Lesiński d4843c90e8 Don't tie unarchiver to host 2015-04-23 01:21:37 +01:00
Kornel Lesiński 5ba0b2d656 Test unarchiver 2015-04-23 01:20:12 +01:00
Kornel Lesiński 482301aa0d Sorted xcodeproj 2015-04-23 01:06:05 +01:00
Kornel 87dfb72484 Merge pull request #523 from iwankerl/verify-final-code-signature
Verify final code signature for issue #441
2015-04-22 23:52:04 +01:00
Kornel Lesiński ea07f716b8 Revert "Register update with Launch Services; see #508"
This reverts commit a7d11f88c7.

Fixes #525
2015-04-22 23:46:27 +01:00
Kornel Lesiński e7786dde97 Travis :sadpanda:
Revert "CodeSignOnCopy in a parent project won't sign Autoupdate.app, so codesign by default"

This reverts commit 836c6ef09e.
2015-04-22 23:43:38 +01:00
Kornel Lesiński b02a65974d One-off post-update test app 2015-04-22 23:37:20 +01:00
Kornel Lesiński 6017c982c5 Silence warning (code is OK) 2015-04-22 23:27:47 +01:00
Kornel Lesiński 836c6ef09e CodeSignOnCopy in a parent project won't sign Autoupdate.app, so codesign by default 2015-04-22 23:22:00 +01:00
Kornel ab4a058ac4 Merge pull request #527 from zorgiepoo/binary-diff-verbose
BinaryDelta Verbosity/Improved Logging
2015-04-20 01:20:57 +01:00
Zorg da9e48cf29 Added comment why -[NSFileManager fileExistsAtPath:] is not used 2015-04-19 19:23:00 -04:00
Zorg 08aed29870 Fix tests from not compiling 2015-04-19 18:48:22 -04:00
Zorg f31921e775 Re-format BinaryDelta create usage slightly 2015-04-19 18:18:55 -04:00
Zorg 578ba9adaf Removing ()'s in Adding file log 2015-04-19 18:08:06 -04:00
Zorg efac6b053d Improved command line argument parsing 2015-04-19 18:02:28 -04:00
Zorg e978cb0a3a Update BinaryDelta formatting for creating/applying logs 2015-04-19 17:29:51 -04:00
Zorg b780b476c6 Add version command for BinaryDelta and for patches 2015-04-19 15:53:36 -04:00
Zorg ba75b79a97 Fix verbose & version flag parsing 2015-04-19 15:22:00 -04:00
Zorg f9043aa0e6 Added verbose logging to the files being applied/created
Files can be Added, Removed, Replaced, have a new permissions Mode, or changed via a Delta patch
2015-04-19 14:04:59 -04:00
Kornel 5890ec6cfe Merge pull request #519 from ProsoftEngineering/suppress-deprecated-warning
Suppress AuthorizationExecuteWithPrivileges deprecated warning
2015-04-19 15:30:49 +01:00
Zorg fef73cc297 Added verbose option to BinaryDelta
Everything is now printed to stderr now, now that we have a verbose option. Printing to same stream avoids out-of-order messages
2015-04-19 03:40:54 -04:00
Kornel c7a8d5d42a Merge pull request #524 from zorgiepoo/binary-delta-permissions
Binary delta Improvements
2015-04-19 00:31:53 +01:00
Zorg 9e9fef0d51 Add an extract property for creating/applying binary diffs
Before, an extract was assumed if nothing else matched. This can get quite confusing when adding new properties, so we shouldn't treat any property to be handled if nothing else was handled.
2015-04-18 17:59:52 -04:00
Kornel 509df736bc Merge pull request #526 from zorgiepoo/arc-autoupdate-release
Ensure termListen is not deallocated before -[NSRunningApplication run]
2015-04-18 18:47:28 +01:00
Zorg 063056e193 Ensure termListen is not deallocated before -[NSRunningApplication run]
Related: Issue #441
I have no evidence that this is the cause of the issue, but from what we do know from the crash logs submitted, it looks like Sparkle crashes or errors on the main thread. It also looks like it might be from an object release rather than copying (which is done on a different thread) being the issue (see issue #417 also). I'm leaning towards this being an issue after the project was converted to ARC.
2015-04-18 13:14:57 -04:00
Kornel Lesiński d1908b1645 Unused 2015-04-18 18:00:44 +01:00
Kornel Lesiński 06a1ab8787 Formatting 2015-04-18 18:00:44 +01:00
Zorg cd478a4c48 Fixing unused variable warnings 2015-04-17 19:07:36 -04:00
Zorg acbd622369 Add tests for invalid patch version inputs 2015-04-17 19:03:21 -04:00
Zorg 817bbc46b1 Add a test to make sure old patches still work 2015-04-17 18:52:42 -04:00
Zorg dbc9123dce Use SUBinaryDeltaMajorVersion instead of uint16_t for this cast 2015-04-17 18:40:08 -04:00
Zorg c2cb3094af Use after-tree instead of before-tree here. Oops. 2015-04-17 18:38:44 -04:00
Zorg 65931f6277 First delta minor version should now be 0 2015-04-17 17:55:32 -04:00
Zorg 0f6697214d Increase minor version for version 1 patches
Since BinaryDelta can still create patches for older versions, and since I've made fixes recently even for version 1 patches, we should increment this counter.
2015-04-17 17:53:05 -04:00
Zorg 3c78139ec8 Use enums for major/minor versions instead of #defines
This should be more typesafe
2015-04-17 17:50:21 -04:00
Zorg 5c921de24f Removing couple of unused variables 2015-04-17 17:20:54 -04:00
Zorg a715babce3 Create #defines for diff properties 2015-04-17 16:32:38 -04:00
Zorg fd68e649db Clarifying which BinaryDiff fields are available when 2015-04-17 15:14:51 -04:00
Zorg 186cfa8486 New patches will now be at major version 2
This will break backwards compatibility with version 1 patches, which generated tree hashes differently and did not handle applying permission changes in some cases.
A version flag is also added to BinaryDelta create for creating patches an older version of BinaryDelta apply can handle. This is only meant for transition purposes.
2015-04-17 14:53:54 -04:00
Zorg c5bc6fe95b s/executablePermissions/permissions/ 2015-04-17 02:29:27 -04:00
Zorg 285cd3063f Fix removeTree not working for symbolic links and added tests
I accidently broke this a few commits ago where I inserted a return value for it
2015-04-17 02:28:03 -04:00
Zorg 8a4f4677bd Add detection for ACLs and fail if they are present
Applications probably shouldn't contain ACLs for files inside their bundle. Dealing with these could be complicated, so we should just reject them.
2015-04-17 01:35:17 -04:00
Isaac Wankerl 57122a40e6 Back out of using the kSecCSCheckNestedCode flag.
This is less secure, but should enable the code to work with older code signatures.
2015-04-15 14:26:53 -05:00
Zorg e2fca42f6c Add error checking to a removeTree call 2015-04-15 00:09:32 -04:00
Zorg 443a6064b3 Add test with no files in before/after trees 2015-04-14 01:48:50 -04:00
Zorg 86754e0537 Adding another test case for empty directories 2015-04-14 01:47:01 -04:00
Zorg 78a940fcf4 Add tests for symlink permissions 2015-04-14 01:46:24 -04:00
Zorg 4029788163 Use lchmod for symlinks; fixes not being able to modify them 2015-04-14 01:44:19 -04:00
Zorg 16cd57b8eb Use XCTFail where appropriate 2015-04-14 00:36:30 -04:00
Zorg a5687d9c1d Track all Unix permissions
Rationale: given a before-hash and an after-hash, there should only be one way to create the diff file. It was possible to violate this before, if we let a file differ in a permission bit that wasn't executable.
2015-04-14 00:12:12 -04:00
Zorg e93888ad3f Add more permissions tests with directories and files 2015-04-14 00:09:03 -04:00
Zorg 7aaf002651 Track directories in binary delta hashes
This code was intended to track directories from the start, but it looks like it never did.
2015-04-13 20:41:10 -04:00
Isaac Wankerl 742648a166 Check the code signature of installed app in the SUPlainInstaller.
This should help prevent situations like issue #441 where Sparkle
creates broken app bundles.  In this case, the update will just report
as a failure instead of succeeding.
2015-04-13 15:48:17 -05:00
Isaac Wankerl c1f9fcb456 Add SUCodeSigningVerifier unit tests.
There's a zipped up sample app in the unit test target.  This gets unzipped to
a temporary folder and there are three versions of it: the original which is not
code signed at all, another with a valid code signature, and a third which
has had one of its resources removed after code signing to make it invalid.
2015-04-13 15:27:59 -05:00
Isaac Wankerl 47d56a5485 Use the bundleURL instead of executableURL with SecStaticCodeCreateWithPath()
The API docs say "For bundles, pass a URL to the root directory of the bundle…
If you pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized."
2015-04-13 12:55:20 -05:00
Isaac Wankerl 498ed027dd Perform a deep code signature verification with kSecCSCheckNestedCode 2015-04-13 12:51:20 -05:00
Isaac Wankerl 31d03b314d Add +[SUCodeSigningVerifier codeSignatureIsValidAtPath:error:]
Let's you check the validity of an arbitrary code signed app.
2015-04-13 11:47:34 -05:00
Isaac Wankerl 8bbe487c86 Refactor +[SUCodeSigningVerifier codeSignatureIsValidAtPath:error:] to +[SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:error:]
Explains more clearly what the method does.
2015-04-13 11:31:34 -05:00
Isaac Wankerl 4d6eeb363c Add +[SUCodeSigningVerifier applicationAtPathIsCodeSigned:]
Tests whether a particular app is code signed or not.  It does not verify the signature.
2015-04-13 11:25:44 -05:00
Zorg 419b6aabef Extracting files should take priority over changing permissions
Fixes a bug where permissions would change but a new (small) file would not be updated
2015-04-13 00:05:46 -04:00
Zorg 54522aa725 Reworked diffing file permissions
My initial attempt did not work correctly for directories that differed in permissions (since it removed them and all the files inside them). We are now setting a property for permission changes which can happen when a binary diff is created, or when it is skipped. Still have to figure out how backwards compatibility is going to work now..
2015-04-12 23:21:40 -04:00
Zorg d374d99e51 Only allow 0755 and 0644 permissions in after-tree 2015-04-12 19:57:40 -04:00
Zorg 33de6ed878 Don't think _DARWIN_NO_64_BIT_INODE is needed 2015-04-12 16:30:17 -04:00
Zorg 0c40d99740 Added invalid source test for BinaryDelta 2015-04-12 15:55:28 -04:00
Zorg bcab57d8f5 Handle exec. file changes, versioning, more error handling
BinaryDelta can now create proper diffs in the case if a non-executable file becomes an executable file, or vise versa. Currently for simplicit
y and backward-compatibility we delete then extract if an executable difference is found, rather than creating a diff. Files that contain an executable difference are unlikely to be large anyway.

We also change the tree hash function so it can track executable permission differences on files. It also now tracks file types so it is less collision-resistant for example in the case where a regular file becoming a symlink could have resulted in the same hash. Because the tree hash function changed, major & minor versioning to the format was introduced. Older minor versions remain compatible, but older major versions do not. In this case, we've only bumped the minor version. In this case, older versions can apply a patch created by a newer version, and newer versions can apply a patch created by an older version.

More error handling is now checked, some code improvements were made, and some adjustments were made to the tests with regard to the changes above.
2015-04-12 14:46:26 -04:00
Kornel 2ca0a739e5 Merge pull request #522 from zorgiepoo/binary-delta-tests
Binary delta tests
2015-04-11 16:13:02 +01:00
Zorg 9895f123a7 Comments changes to SUBinaryDeltaTest.m 2015-04-11 00:40:50 -04:00
Zorg 87dfe0a4ed Adding BinaryDelta creating/applying tests 2015-04-11 00:13:27 -04:00
Zorg 08434edf79 Move creating diffs into separate source file
Since a function for creating diffs is now exposed, this should make testing easier
This is also consistent with applying diffs being in a separate source file from the delta tool as well
2015-04-09 21:39:11 -04:00
Kornel 695e05eba4 Merge pull request #520 from ProsoftEngineering/xcode-63-update
Xcode 6.3 update
2015-04-09 23:58:59 +01:00
Brian Bergstrand b9a8adba73 Suppress Xcode 6.3 -Wcstring-format-directive warning
New warning fires for every NS/CF string format function.
2015-04-09 14:29:32 -05:00
Brian Bergstrand 91f504ed9f Update to Xcode 6.3 2015-04-09 14:27:48 -05:00
Brian Bergstrand 6033bd4228 Suppress AuthorizationExecuteWithPrivileges deprecated warning 2015-04-09 13:56:53 -05:00
Kornel 3de3b11523 Merge pull request #518 from zorgiepoo/binary-delta-stdout
Use stdout for Binary delta info messages
2015-04-09 00:36:25 +01:00
Zorg 707f86a2f4 Patch BinaryDeltaApply to use stdout for info messages too
See issue #516
2015-04-07 21:51:26 -04:00
JDuquennoy e9817380d2 Stdout used for non error outputs 2015-04-07 21:45:20 -04:00
Kornel 21999e4a75 Merge pull request #515 from zorgiepoo/bsdiff-sais
Change bsdiff's suffix sort algorithm to sais. Fixes #132
2015-04-05 23:28:14 +01:00
Zorg 616cc70775 Change bsdiff's suffix sort algorithm to sais. Fixes #132
Although #132 is marked as closed, the issue is still real. bsdiff can crash or hang when creating diffs on some files. In particular, bsdiff hangs/crashes in its recursive split function.

As you can see from:
http://stackoverflow.com/a/20305493/871119
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664

bsdiff 4.3 uses qsufsort for its suffix sorting algorithm, which has a bug causing the hanging/crashing. Our solution is to change the algorithm to use sais for suffix sorting:
https://sites.google.com/site/yuta256/sais

Notes:
*I had to change sais_index_type #define from int to off_t in sais.h/c and in some other places, to eliminate all warnings. Compiles cleanly with clang's -Weverything
*sais is claimed to be more efficient than other algorithms including qsufsort. If a more efficient (and stable) algorithm comes out, we may be able to swap it out in the future.
2015-04-05 15:01:49 -04:00
Kornel 09d98932d9 Merge pull request #513 from zorgiepoo/binary-delta-case-issue
Fix BinaryDelta failing on filenames changing case
2015-04-04 23:37:48 +01:00
Kornel 3b8513546e Merge pull request #514 from zorgiepoo/binary-delta-dir-change-issue
Fix BinaryDelta sometimes failing when a dir becomes a dir link
2015-04-04 23:37:36 +01:00
Zorg 5589a604b8 Use child/parent names with paths for better clarity 2015-04-04 16:44:36 -04:00
Zorg 44b027a178 Fix BinaryDelta sometimes failing when a dir becomes a dir link
This can occur in the following case:
--
original_tree:
	A/
	Current/
		B
new_tree:
	A/
		B
	Current -> A/
--
Because symbolic links are not followed, Current/B can be marked as deleted. If A/B is added before the deletion, then A will end up as an empty directory.
Our fix is to remove all subpaths of a file when it changes from a directory to another type of file. This should also decrease the size of the diff even in harmless cases such as when a directory changes into a regular file.
2015-04-04 13:29:29 -04:00
Zorg 2dfc8494d7 Fix BinaryDelta failing on filenames changing case
When a filename changes case, make sure we have the file deleted in the old tree before being extracted into the new one.
Note that we don't try creating a diff if a file is renamed with a different case, just like we don't track file names changing in other ways.
See issue #474
2015-04-03 17:45:43 -04:00
Kornel 729087f696 Merge pull request #511 from grahammiln/imageoptim
Crunching image size with ImageOptim
2015-04-01 17:15:31 +01:00
Graham Miln 7656128c55 Crunching image size with ImageOptim 2015-04-01 17:21:00 +02:00
Kornel 5fe670ce05 Merge pull request #510 from grahammiln/remove-cast
Removing redundate `NSString` cast; see #509
2015-04-01 15:34:54 +01:00
Graham Miln d700b69072 Removing redundate NSString cast; see #590 2015-04-01 16:23:29 +02:00
Kornel ddde2822fa Merge pull request #509 from grahammiln/launch-services
Register update with Launch Services; see #508
2015-04-01 11:20:16 +01:00
Graham Miln a7d11f88c7 Register update with Launch Services; see #508 2015-04-01 11:16:46 +02:00
Kornel e7ed4aa32f Merge pull request #492 from ksuther/french-change
Changed French string for automatically install updates checkbox
2015-03-12 17:06:20 +00:00
Kent Sutherland 090285ec7e Changed French string for automatically install updates as suggested by a French user:
« Automatiquement » before the two verbs is a little akward, not incorrect but unusual. And « à l’avenir » (« in the future » is really not necessary, usually they don’t mention it.
2015-03-12 11:43:15 -04:00
Jake Petroules bc99dbd560 Merge pull request #491 from MaddTheSane/xCode63someFix
Remove binaryDeltaSupported…
2015-02-25 22:47:47 -08:00
Jake Petroules fbd90763f9 Merge pull request #490 from MaddTheSane/modulesToXcconfig
Move the module build settings out of Xcode.
2015-02-25 22:46:53 -08:00
C.W. Betts f88439923f Fix some issues discovered when building on Xcode 6.3:
Remove binaryDeltaSupported, as libxar is no longer weak-linked.
2015-02-25 22:17:23 -07:00
C.W. Betts 8f4ab3eb56 Move the module build settings out of Xcode.
Because all of the other build settings are in the xcconfig files.
2015-02-25 21:51:09 -07:00
Kornel f216ef7a13 Merge pull request #489 from mgunneras/http-headers
Ability to add custom http headers to appcast request
2015-02-26 01:10:55 +00:00
Mattias Gunneras 1db20c4882 Bugfix for setting headers properly, not just key-value pairs on the class 2015-02-25 10:56:56 -05:00
Mattias Gunneras 0a6de47783 Added ability to inject custom http headers in appcast request 2015-02-25 09:42:31 -05:00
Kornel 2a1760a5a9 Merge pull request #482 from sparkle-project/hasLaunched
Always set hasLaunchedBefore
2015-02-08 11:10:47 +00:00
Kornel 65238c35a9 Merge pull request #472 from millerdev/fix-invalid-parameter
Fix invalid parameter error on check for updates
2015-02-08 11:10:32 +00:00
Kornel 5e4e904efd Merge pull request #469 from kainjow/master
Add ability for host bundle to specify a custom name
2015-02-08 11:07:55 +00:00
Kornel 4d6d766a21 Merge pull request #377 from grahammiln/guided-pkg-install
Added headless guided package installation
2015-02-08 11:04:14 +00:00
Kornel 2cb531066c Merge pull request #483 from stel/patch-1
Update podspec for 1.9.0
2015-01-27 08:40:59 +00:00
Dmitry Obukhov e41fbdee49 Update podspec for 1.9.0 2015-01-27 10:52:54 +03:00
Kornel Lesiński c2672cf89c Always set hasLaunchedBefore
Fixes #475
2015-01-25 11:00:23 +00:00
Kornel Lesiński 6146b0a002 Version bump 2015-01-25 10:54:43 +00:00
Kornel ce22598d13 Merge pull request #481 from MaddTheSane/useModules
Have Sparkle build a framework module.
2015-01-22 16:45:20 +00:00
C.W. Betts c067f7a13b Have Sparkle build a framework module. 2015-01-20 14:57:07 -07:00
Kornel Lesiński 89c21b3acd Updated changelog 2015-01-15 09:54:06 +00:00
Kornel Lesiński 2adadf56e1 Explicit @synthesize 2015-01-15 09:41:00 +00:00
Kornel 57530564a6 Merge pull request #446 from tonyarnold/skip-install
Skip installing the framework by default — fixes #419
2015-01-15 09:30:25 +00:00
Kornel 3bebcfdd68 Merge pull request #476 from greenbuffo/master
Fix Autoupdate.app crash on 10.7 (issue #441)
2015-01-14 23:12:36 +00:00
Chris Campbell b5fc2be113 Fix Autoupdate.app crash on 10.7 (issue #441)
Autoupdate.app can crash in the middle of installing an update, leaving
the user with a broken application. The crash is caused by the status
window’s controller (SUStatusController) being prematurely deallocated
before the window is closed. This change prevents such a crash by
keeping a strong reference to the SUStatusController in
TerminationListener.
2015-01-14 11:42:33 -05:00
Daniel Miller a8d96e0dce Fix invalid parameter error on check for updates
reason: Invalid parameter not satisfying: windowNibPath

See https://github.com/sparkle-project/Sparkle/issues/237#issuecomment-11618894
2014-12-31 00:17:46 -05:00
Kornel 6dc6240fab Merge pull request #471 from GerTeunis/master
Using a weak id delegate property will crash during instantiation of NIB on OS X 10.7
2014-12-28 21:05:36 +00:00
Ger Teunis 4aecd9056b Using a weak id delegate will crash during instantiation of NIB on OS X 10.7 2014-12-27 14:05:09 +01:00
Kevin Wojniak 979ab661de Add ability for host bundle to specify a custom name 2014-12-23 08:47:11 -08:00
Kornel fbd20b7084 Merge pull request #442 from sparkle-project/cachedir
Use Library/Caches rather than app support directory
2014-12-23 11:30:38 +00:00
Kornel d695893329 Merge pull request #465 from bitigchi/patch-1
Capital Case Correction
2014-12-22 20:55:48 +00:00
Kornel 8443f88bb2 Merge pull request #466 from bitigchi/patch-2
Small fixes
2014-12-22 20:55:35 +00:00
Kornel acb1568708 Merge pull request #467 from bitigchi/patch-3
Small fixes
2014-12-22 20:55:24 +00:00
Kornel 51581fd3f5 Merge pull request #468 from bitigchi/patch-4
Context fixes
2014-12-22 20:53:47 +00:00
Emir 15b2d6256f Context fixes
Fixed poor spelling and context issues.
2014-12-22 21:08:25 +02:00
Emir 5d2fd5ca6d Small fixes
Capitalisation and context fixes
2014-12-22 21:01:54 +02:00
Emir 6f0e194705 Small fixes
Capitalisation and context fixes
2014-12-22 20:58:33 +02:00
Emir 4f4800bf26 Capital Case Correction
Turkish-lang specific capitalisation correction.
2014-12-22 20:55:16 +02:00
Kornel 1d3d15d5c1 Merge pull request #461 from kylef/lzma
Add support for lzma compressed tarballs
2014-11-23 12:22:36 +00:00
Kyle Fuller f139ccc5e7 Add support for lzma compressed tarballs 2014-11-22 17:16:30 +01:00
Jake Petroules 760a1589ba Merge pull request #456 from vslavik/defer-SUClearLog
Don't call SUClearLog() unless logging something
2014-11-16 11:45:12 -08:00
Václav Slavík b9f987382c Don't call SUClearLog() unless logging something
Don't delete the log file and log app name to it when only checking for
updates - this is something done frequently, on many apps' startup.
Instead, clear the log before writing the first entry to it, so that it
stays untouched if there's nothing to add to it.

Log the application name before the first "real" log entry, instead of
doing it unconditionally every time checkForUpdatesWithDriver: is called.
2014-11-16 17:00:36 +01:00
Jake Petroules 313b146b8e Merge pull request #448 from ivira/master
Proofing of Ukrainian localization.
2014-11-02 11:04:28 -08:00
Jake Petroules 3676feef94 Merge pull request #449 from orzFly/patch-1
Fix a repeated string in Traditional Chinese
2014-11-02 11:01:22 -08:00
Yeechan Lu 7157782c4c Fix a repeated string in Traditional Chinese 2014-11-03 01:22:48 +08:00
Vera Tkachenko f803d31274 Proofing of Ukrainian localization. 2014-11-02 11:36:14 +02:00
Tony Arnold f996ad8e04 Skip installing the framework by default — fixes #419 2014-10-31 13:26:54 +11:00
Jake Petroules 91166ca7ea Merge pull request #445 from tonyarnold/fix-xcode-6.1-warnings
Update LastUpgradeCheck within xcschemes and pbjproject to 0610 for Xcode 6.1
2014-10-30 00:20:08 -07:00
Tony Arnold e1a6467792 Fix warnings under Xcode 6.1 relating the SUUpdateAlert XIB 2014-10-30 12:30:10 +11:00
Tony Arnold 152ed05389 Update LastUpgradeCheck within xcschemes and pbjproject to 0610 for Xcode 6.1 2014-10-30 12:24:53 +11:00
Kornel df57ff045d Merge pull request #444 from kainjow/master
Removed some pragmas
2014-10-27 22:22:30 +00:00
Kevin Wojniak c5868c6eea Removed useless sole pragma mark 2014-10-27 13:55:41 -07:00
Kevin Wojniak ebcbb71e8c Removed outdated SUClearLog comment 2014-10-27 13:54:59 -07:00
Kevin Wojniak a90b075eec Removed use of pragma once in SULog to be consistent with the other headers 2014-10-27 13:54:14 -07:00
Kevin Wojniak f7629eb044 Changed NSSortDescriptor key input to allow for removal of pragma 2014-10-27 13:52:03 -07:00
Kevin Wojniak f1132002b9 Removed pragma which disabled a warning that is no longer shown in Xcode 6.1 2014-10-27 13:51:05 -07:00
Kornel Lesiński 82674cfa9b Use Library/Caches rather than app support directory
Fixes #146
2014-10-20 23:49:33 +01:00
Kornel 096180e879 Merge pull request #439 from erik999/master
Fixed Swedish translations
2014-10-16 13:16:16 +01:00
Erik Vikström be7e968834 Fixing Swedish translations
See https://github.com/sparkle-project/Sparkle/issues/436
2014-10-16 08:59:51 +02:00
Kornel 7fcd8be9d2 Merge pull request #437 from MaddTheSane/exportErrors
Make the error definitions public
2014-10-14 11:57:36 +01:00
C.W. Betts 85f1815d8b Make the error definitions public 2014-10-13 18:24:32 -06:00
Kornel bb5e302980 Merge pull request #434 from codyrobbins/master
Changed a straight apostrophe into a curly one
2014-10-08 01:51:55 -04:00
Cody Robbins 814028cb83 Changed a straight apostrophe into a curly one
Changed the apostrophe in the title of the ‘Don’t Check’ button on the update permissions prompt dialog from a straight one to a curly one.
2014-10-07 14:28:52 -04:00
Kornel 7e1b47976d Merge pull request #432 from yetamrra/master
Add delegate method for errors
2014-10-04 13:38:42 -10:00
Benjamin Gordon feae8bf7b3 Call delegate didAbort in other drivers when showErrors is false. 2014-10-04 16:25:34 -06:00
Benjamin Gordon 7a6d4bd380 Added SUUpdater delegate method for failures. 2014-10-04 16:18:49 -06:00
Kornel 3f9e50d10f Merge pull request #426 from alfwatt/master
Check for a modal window being onscreen before trying to put up the Spar...
2014-09-23 19:30:52 -07:00
Kornel Lesiński ba407a84b9 Updated changelog 2014-09-23 18:57:43 -07:00
Alf Watt 86429ecd50 Check for a modal window being onscreen before trying to put up the Sparkle prompt. 2014-09-23 18:57:10 -07:00
Jake Petroules 0344e2d5fa Add screenshot to README showing Sparkle in action. 2014-09-06 21:51:47 -04:00
Jake Petroules 46f2c07587 Add instructions to the README for building release packages. 2014-08-27 22:15:12 -04:00
Jake Petroules 1690bfa9bd Fix package building for Debug configuration. 2014-08-27 22:03:22 -04:00
Jake Petroules 19c6098d30 Share the distribution scheme and configure it to run tests.
This way, we don't rely on automatic scheme creation in Travis, nor do
we have to update the Makefile for Travis if we want to add an
additional test target to the project.

Also, Travis should now build all targets (including BinaryDelta and
Sparkle Test App), giving us better build coverage.
2014-08-27 21:52:40 -04:00
Jake Petroules ecf602f589 Avoid hardcoded file paths. 2014-08-27 21:37:47 -04:00
Jake Petroules 49721abdaa Add ARM support to the system profiler as OS X might later run on it. 2014-08-27 21:19:09 -04:00
Jake Petroules d7ef18ec91 Use string constants in system profiler. 2014-08-27 21:11:45 -04:00
Jake Petroules 89081ca030 Eliminate a few more string constants. 2014-08-27 20:53:38 -04:00
Jake Petroules 8d74807b23 Use string constants for RSS element and attribute names. 2014-08-27 20:53:27 -04:00
Jake Petroules f72bd52e87 Fix minor spelling error. 2014-08-27 20:48:58 -04:00
Jake Petroules 771a4c9b6b Rename Sparkle appcast keys to make clear elements vs attributes. 2014-08-27 20:08:57 -04:00
Jake Petroules 945a82e9f0 Prefer string constants to strings. 2014-08-27 19:58:10 -04:00
Jake Petroules a4c5e78794 Merge branch 'tamasprezi-tags_fix' 2014-08-27 19:49:39 -04:00
Tamás Lustyik 25cda72d66 Fixed Sparkle tags parsing 2014-08-27 19:49:03 -04:00
Kornel d3c6bd0250 Merge pull request #414 from sparkle-project/visibility
Only export public symbols.
2014-08-26 10:22:21 +01:00
Jake Petroules aa88b40b24 Only export public symbols. 2014-08-25 18:58:12 -04:00
Jake Petroules c87ab4b9c1 Merge pull request #399 from MaddTheSane/errEnum
Have Sparkle’s error codes be defined using NS_ENUM.
2014-08-23 20:41:23 -04:00
Jake Petroules 352aa18377 Merge branch 'kainjow-master' 2014-08-23 20:35:15 -04:00
Jake Petroules 6638b7f9c4 Merge branch 'master' of https://github.com/kainjow/Sparkle into kainjow-master
Conflicts:
	Sparkle/SUUpdater.h
2014-08-23 20:34:49 -04:00
Jake Petroules ec5b2a22c8 Make sure CFBundleVersion is a semantic version number.
CFBundleShortVersionString is now used to embed the Git rev info instead.
2014-08-23 18:03:12 -04:00
Jake Petroules c926aa48f5 Spaces to tabs in Info.plist 2014-08-23 16:44:40 -04:00
Jake Petroules c839ccf916 BinaryDelta: avoid crash with bad paths. 2014-08-23 01:04:41 -04:00
Jake Petroules 0171677513 Fix Clang static analyzer warning.
Closes #385
2014-08-22 23:13:44 -04:00
Jake Petroules 3314d9e3a5 Add Sparkle Appcast attributes as constants. 2014-08-22 22:31:39 -04:00
Jake Petroules 2d33875017 Prefer named constants where available. 2014-08-22 22:04:59 -04:00
Jake Petroules 0ff409a3d9 Improve formatting in license file.
Use a more standard header and fix line length.
2014-08-22 21:50:35 -04:00
Jake Petroules e89d3a7e15 Clean up Autoupdate.m a bit. 2014-08-22 21:37:00 -04:00
Jake Petroules bce54912ee Remove dead code.
Does nothing, not needed.
2014-08-22 21:10:24 -04:00
Jake Petroules 0851dc9a67 Fix regression in SULocalizedString macro. 2014-08-22 20:39:56 -04:00
Jake Petroules bfaeffc8f9 Simplify code path. 2014-08-21 19:53:38 -04:00
Jake Petroules 223436a6b7 Silence direct ivar access warning. 2014-08-21 19:38:21 -04:00
Jake Petroules 8db491ade0 Further reduce macro usage. 2014-08-21 19:25:53 -04:00
Jake Petroules b774241f25 Use Info.plist keys instead of macros.
This helps ensure that all code paths are compiled during development, reducing the chance of build errors (especially in CI). Additionally, developers can change these values without having to rebuild Sparkle (but it is still safe because modifying the plist will break the code-signing seal).
2014-08-21 19:12:29 -04:00
Jake Petroules bb743d80e0 Reduce duplication and macros. 2014-08-21 18:41:16 -04:00
Jake Petroules 888c3d4797 Copy Autoupdate.app in a separate phase. 2014-08-21 18:12:46 -04:00
Jake Petroules 54de8d1f2a Properly set install names and rpaths for targets. 2014-08-21 17:52:35 -04:00
Jake Petroules 68dff7ac81 Keep settings in xcconfig, remove unnecessary ones. 2014-08-21 17:17:58 -04:00
Jake Petroules 83032dc7ac Use proper variables in shell scripts. 2014-08-21 17:14:48 -04:00
Jake Petroules 2820b36d7e Silence warnings in XCTest framework. 2014-08-21 17:01:44 -04:00
Jake Petroules 2a7b94bc9d Add CodeSignOnCopy, RemoveHeadersOnCopy attributes. 2014-08-21 17:01:27 -04:00
Jake Petroules c393d58fe5 Update podspec for v1.8. 2014-08-21 16:46:04 -04:00
Oleg Krupnov 54547db28e Merge branch 'master' of https://github.com/AJet/Sparkle
Conflicts:
	Sparkle.xcodeproj/project.pbxproj
2014-08-14 20:04:09 +03:00
Oleg Krupnov 5456da6ab2 Fixed typos in Polish localization
Updated project settings
2014-08-14 20:02:47 +03:00
Kevin Wojniak 8d8cc35c96 Use standard Denial-of-Service acronym. 2014-08-04 09:17:41 -07:00
C.W. Betts 69bfc27960 Retain binary compatibility with older versions of Sparkle. 2014-08-02 12:38:53 -06:00
C.W. Betts d2ebc47c1e Have Sparkle’s error codes be defined using NS_ENUM.
This has the benefit of setting their size/type (OSStatus), and more usable with Swift.
2014-07-29 20:03:10 -06:00
Kornel Lesiński ee73e4c3e9 Code formatting 2014-07-29 02:05:22 +01:00
Kornel Lesiński 8ecbb25274 Warn when version is missing 2014-07-29 02:05:12 +01:00
Jake Petroules e437b720a4 Merge pull request #398 from MaddTheSane/nsEnumedEnums
Change enums to NS_ENUMs
2014-07-26 17:00:00 -04:00
C.W. Betts b8e28910ba Change SUCharacterType to an NSInteger. 2014-07-26 14:50:49 -06:00
C.W. Betts 852b6e0976 Change ints in NS_ENUMs to NSIntegers. 2014-07-26 11:12:59 -06:00
C.W. Betts b7eb5403ff Replace typedef enums with typedef NS_ENUM.
For one thing, it make Swift happier. Also, we don’t have to worry about what size/type the value is.
2014-07-26 11:03:18 -06:00
Kornel Lesiński 0b186dc939 Updated changelog 2014-07-26 15:57:09 +01:00
Kornel Lesiński 22dff08b8d Make it clear that bundled DSA key is only for the test app 2014-07-26 15:45:31 +01:00
Kornel Lesiński b9e94d49ae Ensure that updateItem isn't freed during the update 2014-07-26 14:38:30 +01:00
Kornel Lesiński 867a91cbe4 Clarified error message 2014-07-26 02:26:40 +01:00
Kornel Lesiński aadadeef5b Version bump 2014-07-26 02:16:59 +01:00
Kornel Lesiński 7b7e3f6e23 Log detailed signature verification failures 2014-07-26 02:16:59 +01:00
Kornel Lesiński e2e37da3ce nil-safe dictionary 2014-07-26 02:16:59 +01:00
Kornel Lesiński 6d861c5d92 Rely on SULog prefix 2014-07-26 02:16:59 +01:00
Kornel Lesiński 80dee159de Simpler newline 2014-07-26 02:16:59 +01:00
Kornel Lesiński de9ec2a849 Always copy log to NSLog 2014-07-26 02:16:58 +01:00
Kornel Lesiński 7a1f627c79 Close windows before termination, not after 2014-07-26 02:16:58 +01:00
Kornel Lesiński cf7711fb83 Updated readme 2014-07-26 00:41:09 +01:00
Kornel Lesiński c7ec996c23 Add scheme required by xcodebuild 2014-07-26 00:04:53 +01:00
Kornel Lesiński a8c2a98379 Run unit tests in Travis 2014-07-25 23:47:31 +01:00
Kornel Lesiński 7148c0f3e6 Added others to podspec 2014-07-25 13:00:14 +01:00
Kornel 05b5758058 Merge pull request #393 from xhacker/podspec
Add podspec
2014-07-25 12:56:21 +01:00
Xhacker Liu c2f498f157 Add podspec. 2014-07-25 01:52:57 -07:00
Kornel Lesiński e11f8387b2 Added DSA verifier test 2014-07-25 02:19:29 +01:00
Kornel Lesiński d3198961d7 Don't crash using CFPreferences when defaultsDomain is unknown 2014-07-25 01:30:00 +01:00
Kornel Lesiński 3f37fe7674 Xcode upgrade check harassment marker 2014-07-25 01:28:32 +01:00
Kornel Lesiński 245b4e1608 Xcode’s being weird 2014-07-25 00:41:53 +01:00
Jake Petroules 9516d6d667 Merge pull request #387 from MaddTheSane/QuarantineVal
Quarantine removal
2014-07-21 18:06:27 -04:00
C.W. Betts b13b57e800 remove unnecessary return; 2014-07-19 21:46:29 -06:00
Kornel 9480f40522 Merge pull request #378 from grahammiln/travis
Add Travis continuous integration support
2014-07-20 02:55:16 +01:00
C.W. Betts 32d4de464d Don't use new code if specifically targeting OS versions that have the new API. 2014-07-19 15:05:08 -06:00
C.W. Betts 578666e9e6 Minor fix. 2014-07-19 14:44:06 -06:00
C.W. Betts 591d7d0049 Better, forward-compatible way of looking up NSURLQuarantinePropertiesKey, as suggested by @jakepetroules 2014-07-19 14:38:51 -06:00
Jake Petroules 417e018432 Merge pull request #388 from MaddTheSane/XcodeMaintanence
Xcode maintenance.
2014-07-18 16:04:49 -04:00
C.W. Betts fa2a121217 Xcode maintenance:
libxar is no longer weak-linked.
Removing undefined copy copies. Maybe they were icons?
Name the copy frameworks as "Copy Frameworks"
2014-07-18 13:47:26 -06:00
C.W. Betts 5a3fd1e12a Indenting code. 2014-07-18 13:31:54 -06:00
C.W. Betts cb19fe8864 Use some 10.10-specific APIs to remove the quarantine attribute. 2014-07-18 13:28:20 -06:00
C.W. Betts fb206d9f71 Use the system-available quarantine string to get the quarantine metadata attribute. 2014-07-18 13:03:31 -06:00
Jake Petroules 83c93809c4 Merge pull request #379 from sononum/master
avoid attempt to insert nil object into dictionary
2014-07-15 13:44:30 -04:00
Ulrich Zurucker b95f5bc83c avoid attempt to insert nil object into dictionary 2014-07-15 13:14:04 +02:00
grahammiln 35efebf76f Add Travis continuous integration support
Adding configuration file and extending makefile to support
http://travis-ci.org.
2014-07-14 14:50:49 +02:00
grahammiln 21657c9fb1 Added headless guided package installation
Added headless guided installation of pkg and mpkg files. Ported to
using ARC
and inlined documentation. The use of
`AuthorizationExecuteWithPrivileges` should be replaced with an XPC or
assistive external process in a future update. See
https://github.com/sparkle-project/Sparkle/issues/348
2014-07-13 16:53:45 +02:00
Jake Petroules cca13834ca Merge pull request #374 from MaddTheSane/patch-1
Update Autoupdate-Info.plist
2014-07-09 22:48:39 -04:00
MaddTheSane c36aee449d Update Autoupdate-Info.plist 2014-07-09 20:45:54 -06:00
Kornel Lesiński 2d15514466 Updated changelog 2014-07-10 00:28:22 +01:00
Kornel 2471a5f05d Merge pull request #368 from sparkle-project/autolayout
Rely on autolayout
2014-07-09 12:39:41 +01:00
Kornel d61e0d57a9 Merge pull request #373 from 1024jp/japaneseLocalization
Update Japanese localization
2014-07-09 12:38:57 +01:00
1024jp 7dc42eb6ea Update Japanese localization 2014-07-09 00:43:49 +02:00
Kornel 59114fb9dc Merge pull request #372 from MaddTheSane/addGreek
Include the Greek localization.
2014-07-08 17:53:40 +01:00
C.W. Betts 8f73838fa0 Include the Greek localization. 2014-07-08 10:32:01 -06:00
Kornel Lesiński fce6957a66 RSS-y Accept header
Fixes #284
2014-07-07 02:46:57 +01:00
Kornel Lesiński def8cfa1ff Whitespace-only clang-format changes 2014-07-07 02:25:04 +01:00
Kornel Lesiński 99df53ba96 Since it’s awakeFromNib, it won’t hurt to remove the view
#369
2014-07-07 02:05:45 +01:00
Kornel Lesiński 77d16de08a Separate autosave names for states with/without release notes 2014-07-07 02:03:35 +01:00
Kornel e040ccfef1 Merge pull request #336 from pornel/newdsa
New DSA verification code
2014-07-07 01:55:34 +01:00
Kornel Lesiński f2ca019cb0 Rely on autolayout 2014-07-07 01:49:08 +01:00
Kornel Lesiński 336db58e96 Removed UK initials from comments 2014-07-07 00:17:30 +01:00
Kornel Lesiński 6826505d3e Apply clang-format rules 2014-07-05 01:19:42 +01:00
Kornel Lesiński 8e41993ead Rely on precompiled header 2014-07-05 01:05:03 +01:00
Kornel Lesiński 19c3d2ebf3 Removed odd self=nil assignments 2014-07-05 01:05:03 +01:00
Kornel Lesiński c9a631d2e4 Removed unused method 2014-07-05 01:05:02 +01:00
Kornel Lesiński f2cd127729 Removed unnecessary params 2014-07-05 01:04:49 +01:00
Kornel Lesiński b001a3e52e Removed unnecessary initializer 2014-07-05 01:04:49 +01:00
Kornel Lesiński c9bb1bf81c Formatting 2014-07-05 01:04:49 +01:00
Kornel Lesiński d9c287c899 Double-check SecTransformExecute return value 2014-07-03 23:50:23 +01:00
Kornel Lesiński 18d7c5f8cd Fix potential memory leak 2014-07-03 23:50:20 +01:00
Kornel Lesiński 4697623be6 Add contributors to the License.txt file 2014-07-03 23:47:30 +01:00
Zachary Waldowski 4f1cfa0d9c Amend spurious copyright notice 2014-07-03 23:47:30 +01:00
Kornel Lesiński 697a3436e5 Deleted 10.6 code 2014-07-03 23:42:30 +01:00
Zachary Waldowski ae72844847 Make SUDSAVerifier forward-compatible with Lion security 2014-07-03 23:42:30 +01:00
Kornel Lesiński 8385dfd0f4 Quicker restart 2014-07-03 20:59:00 +01:00
Jake Petroules 31ee181ad2 Enable -Wdirect-ivar-access; the codebase is now clean of this warning. 2014-07-02 18:56:47 -04:00
Jake Petroules 0e14c9ca6a Convert remaining ivars to properties to avoid direct ivar access. 2014-07-02 18:55:54 -04:00
Jake Petroules aac2a91833 Avoid direct ivar access for existing properties. 2014-07-02 18:00:39 -04:00
Kornel ce10ccd97e Merge pull request #364 from MaddTheSane/ARC
Migrate the Disk Image and piped unarchiver to ARC.
2014-07-02 12:36:06 +01:00
C.W. Betts 77a58843fe Migrate the Disk Image and piped unarchiver to ARC. 2014-07-01 20:52:50 -06:00
Jake Petroules 3b1f97a298 Move remaining private ivars to properties/implementation. 2014-07-01 22:08:13 -04:00
Jake Petroules 7e4f74af14 Move private ivars to @implementation.
Declaration of ivars in @interface is deprecated in modern runtime.
2014-07-01 22:08:13 -04:00
Jake Petroules 4ac95c9560 Re-enable -Wobjc-interface-ivars warning.
Now that we are ARC and 64-bit...
2014-07-01 22:08:12 -04:00
Jake Petroules 6d7092f10a Remove some ivars in favor of properties. 2014-07-01 22:08:12 -04:00
Kornel c209639c4d Merge pull request #362 from sparkle-project/cfError
Release cfError independently of *error
2014-07-02 02:37:46 +01:00
Kornel 9ec502f5ab Merge pull request #360 from sparkle-project/tbz2
2.5MB → 720KB
2014-07-02 02:10:12 +01:00
Kornel Lesiński 8ae0f10162 Use noErr constant of OSStatus 2014-07-02 02:06:55 +01:00
Kornel Lesiński 6b86508d38 Always release cfError 2014-07-02 02:06:55 +01:00
Kornel Lesiński 841e14e8b8 Retain delegate for duration of the function 2014-07-02 02:06:27 +01:00
Jake Petroules 2bc1de6f1f Add missing __unused attributes. 2014-07-01 20:56:42 -04:00
Jake Petroules 3604e36917 Add missing __autoreleasing attributes. 2014-07-01 20:55:44 -04:00
Jake Petroules 69f349397b Turn off some extremely tough ARC warnings. 2014-07-01 20:55:16 -04:00
Jake Petroules c778dff301 Merge pull request #361 from MaddTheSane/patch-1
Make the setTestFeedURL test run.
2014-07-01 20:47:50 -04:00
MaddTheSane 51a012896f Make the setTestFeedURL test run.
I think the test framework saw `setTestFeedURL` as a setter. This change changes it to `testSetTestFeedURL`, which will run as a test.

And for some odd reason, crashes.
2014-07-01 18:45:34 -06:00
Kornel Lesiński 66962fe8d8 Merge branch 'ARC' of https://github.com/MaddTheSane/Sparkle
* 'ARC' of https://github.com/MaddTheSane/Sparkle:
  Fix a release bug.
  Force Xcode to use spaces on source code files.
  Convert Sparkle to ARC, take three.
2014-07-02 01:31:28 +01:00
Kornel Lesiński b463afee27 Use tarball to reduce distribution size by 70% 2014-07-02 01:24:31 +01:00
Kornel Lesiński 71c7e2f9a2 -f works as || true 2014-07-02 01:13:22 +01:00
Kornel Lesiński 969622840d Added localized string comments 2014-07-02 01:12:48 +01:00
Kornel Lesiński 6910ce4413 Added missing string 2014-07-02 01:12:48 +01:00
Jake Petroules 892c5f1054 Warn if Doxygen is not installed, when building documentation. 2014-07-01 19:47:30 -04:00
Jake Petroules 84cdbbd45b Include Sparkle Test App and BinaryDelta dSYM in binary package. 2014-07-01 19:45:42 -04:00
Jake Petroules d79507b663 Update version numbers. 2014-07-01 19:35:29 -04:00
Kornel Lesiński ab07cda5eb Merged Allow text to expand #346 2014-07-02 00:08:13 +01:00
Kornel f4e0fceeac Merge pull request #349 from sparkle-project/holydeletedcodebatman
Closures instead of temp dictionaries
2014-07-01 23:56:25 +01:00
Kornel Lesiński 9344928872 Updated changelog 2014-07-01 23:33:23 +01:00
Kornel Lesiński 5b123215ed Fixed whitespace in xcodeproj, applied sort-Xcode-project-file.sh 2014-07-01 02:57:37 +01:00
Kornel 2bebf0f2d1 Merge pull request #353 from sparkle-project/clang-format
Clang format
2014-07-01 02:56:19 +01:00
Jake Petroules 4a1eddadf2 Fix corruption of Xcode project caused by last merge. 2014-06-30 21:37:36 -04:00
Kornel 19473aae5e Merge pull request #351 from sparkle-project/doxygen
Documentation
2014-07-01 02:17:53 +01:00
Jake Petroules e0a1bbbac5 Convert normal comments to doc comments in SUUpdater/SUUpdaterDelegate.
Documentation will now show up for these classes in the Xcode sidebar
and in generated Doxygen documentation.
2014-06-30 21:16:29 -04:00
Jake Petroules ebf9a8172a Fix some Doxygen warnings. 2014-06-30 21:16:29 -04:00
Jake Petroules 676b713df0 Add a target to build Sparkle API documentation using Doxygen. 2014-06-30 21:16:28 -04:00
Kornel Lesiński b26bfeba0e Localize "The update is improperly signed."
#294
2014-07-01 02:13:24 +01:00
C.W. Betts 1c5523ed83 Merge branch 'master' into ARC 2014-06-30 19:09:40 -06:00
C.W. Betts 2acc9114e4 Force files modified via Xcode to use spaces. 2014-07-01 02:04:23 +01:00
C.W. Betts b87a89c24d Fix a release bug. 2014-06-30 19:03:26 -06:00
C.W. Betts 5106d7010a Merge branch 'master' into ARC 2014-06-30 18:58:55 -06:00
C.W. Betts 1a968424db Force Xcode to use spaces on source code files. 2014-06-30 18:57:01 -06:00
Kornel Lesiński 344433d468 Change brace style to Linux 2014-07-01 01:47:42 +01:00
C.W. Betts 000c4a9832 Merge branch 'master' into ARC 2014-06-30 18:34:24 -06:00
Kornel Lesiński 4e972c997c Use constant for queue identifier 2014-07-01 00:29:39 +01:00
Kornel Lesiński 55a7ca5b9c Removed unused synchronous installation 2014-07-01 00:27:17 +01:00
Kornel Lesiński bf9ba560f0 Use closure instead of info dict 2014-07-01 00:27:11 +01:00
Jake Petroules 2a2eef97a9 Add .clang-format configuration file for source code formatting. 2014-06-30 17:23:41 -04:00
Jake Petroules 0e68e5e590 Use asset catalogs and add more Retina-compatible icon sizes to ICNS. 2014-06-30 17:23:18 -04:00
Jake Petroules dedae6e626 Make Sparkle README icon 96x96 to display properly on Retina. 2014-06-30 17:22:25 -04:00
Jake Petroules b96a37f922 Silence warnings that only seem to be appearing due to a compiler bug. 2014-06-29 23:23:50 -04:00
Jake Petroules f3ed1fafe3 Use new operatingSystemVersion API when available. 2014-06-29 23:17:32 -04:00
Jake Petroules 3f829bd49c Clean up Xcode configuration.
Make use of inheritance by applying ConfigCommon to the root node and
move all UI-applied settings into xcconfig for easier management.
2014-06-29 23:02:35 -04:00
Jake Petroules 72d8e4e5a6 Add Xcode and Makefile targets to build a Sparkle release package.
Use `make release` to build Sparkle and create a Sparkle-VERSION.zip,
ready for upload.
2014-06-29 22:38:36 -04:00
Jake Petroules 5d0fa33725 Fix output encoding in localizable strings Makefile target. 2014-06-29 21:35:26 -04:00
Jake Petroules 6c9f27106f Make the repository significantly more organized.
Now everything is not pretty much all in one directory.
2014-06-29 21:27:33 -04:00
Kornel Lesiński b9b24be4bb Allow text to expand 2014-06-30 01:11:19 +01:00
Kornel Lesiński 1dd1fe44e1 Use single line mode on textfield that AutoLayout can’t wrap 2014-06-30 01:10:53 +01:00
Kornel Lesiński a7f5217f3d Added window autosave identifier
Fixes #52
2014-06-30 00:06:57 +01:00
Jake Petroules eb0411fb51 Restore original Sparkle icon.
This reverts: 984aac852f,
93ebf843c2,
8d2054e62a,
1325d3fe40,
2579f2c3a3,
and partially reverts 6ca5c3a337.

This icon belongs to a third party and should never have been merged.
2014-06-29 18:21:30 -04:00
Kornel e2674a7549 Merge pull request #344 from MaddTheSane/staticFix
Fix a bug pointed out by the Static Analyzer.
2014-06-29 22:50:50 +01:00
C.W. Betts b000517983 Fix a bug pointed out by the Static Analyzer. 2014-06-29 15:27:32 -06:00
Kornel 268c2c9bab Merge pull request #337 from pornel/autolayout
Switched SUUpdateAlert.xib to AutoLayout
2014-06-29 21:40:46 +01:00
Kornel Lesiński f464382475 Copied align to other XIBs 2014-06-29 21:38:31 +01:00
C.W. Betts 7a3890c9c0 Remove the left alignment on the description text. 2014-06-29 21:30:47 +01:00
Kornel Lesiński 73ecd41dae Switched SUUpdateAlert.xib to AutoLayout 2014-06-29 21:30:47 +01:00
Kornel 20fc16a7d5 Merge pull request #340 from sparkle-project/publicidentifiers
Keep old namespace and framework's bundle ID for backwards compatibility
2014-06-29 21:18:06 +01:00
Kornel Lesiński 6159e77565 Keep old namespace and framework's bundle ID for backwards compatibility
Partial revert of f916f2e723
2014-06-29 20:35:50 +01:00
Jake Petroules 20a8ffd955 Prefer real constants to preprocessor defines. 2014-06-29 03:01:43 -04:00
Jake Petroules 444809da92 Force feedURL/setFeedURL to be called on the main thread.
This is better than relying solely on documentation.
2014-06-29 02:54:45 -04:00
Jake Petroules 8c805970fb Don't crash if defaultName/defaultsDomain is nil. 2014-06-29 02:03:49 -04:00
Jake Petroules 70046f6e07 Quiet Clang static analyzer. 2014-06-29 01:19:03 -04:00
Jake Petroules 964587274c Add old release notes to change log. 2014-06-29 00:58:28 -04:00
Jake Petroules 44d544cf5a Link to Foundation and AppKit instead of Cocoa.
No need to pull in a CoreData dependency.
2014-06-29 00:33:17 -04:00
Jake Petroules 91f5d0125c Perform some Objective-C modernizations. 2014-06-29 00:25:35 -04:00
Jake Petroules cf4ab0d8e6 Remove trailing whitespace in source code files. 2014-06-29 00:08:52 -04:00
Jake Petroules 39db8e1dc6 Replace references to Mac OS X with OS X as the OS is now called. 2014-06-29 00:08:52 -04:00
Jake Petroules 04c8a23f2d Line wrap LICENSE in a sane manner, update. 2014-06-29 00:08:52 -04:00
Jake Petroules fa4daa0569 Update .gitignore; contents.xcworkspacedata need not be ignored. 2014-06-28 23:35:56 -04:00
Jake Petroules 8cd2241fed Silence useless warnings in test product. 2014-06-28 23:29:36 -04:00
Jake Petroules 1334414d2e Rename finish_installation to Autoupdate for consistency. 2014-06-28 23:29:36 -04:00
Jake Petroules 2049c95770 Add an aggregate target to easily build everything. 2014-06-28 23:11:16 -04:00
Jake Petroules d537efcf9b Remove unused file. 2014-06-28 23:01:34 -04:00
Jake Petroules f916f2e723 Replace references to andymatuschak.org with sparkle-project.org. 2014-06-28 22:58:12 -04:00
Jake Petroules 4ca9ba1ce3 Enable as many warnings as possible.
The codebase now compiles cleanly with -Wall -Weverything, minus a few.
2014-06-28 22:47:22 -04:00
Jake Petroules df6dc14ace Silence all warnings in bsdiff/bspatch.
Warnings should not be enabled for third party code.
2014-06-28 22:46:55 -04:00
Jake Petroules f8b0f2c5b7 Fix warnings. 2014-06-28 22:40:44 -04:00
Jake Petroules 8c94f4bb2d Explicitly mark unused parameters. 2014-06-28 22:40:17 -04:00
Jake Petroules 8ec5f0ca3c Avoid variable-length arrays in C. 2014-06-28 21:17:37 -04:00
Jake Petroules 2f16e3f526 Fix warning about explicitly synthesizing properties. 2014-06-28 21:15:11 -04:00
Jake Petroules a80eeedaeb Add missing header to fix warnings.
Otherwise, SUHost is only forward declared in this context.
2014-06-28 21:14:45 -04:00
Jake Petroules 08bc0d574e Fix use of potentially uninitialized variables. 2014-06-28 21:13:31 -04:00
Jake Petroules c015f5e968 Don’t attempt to return from a void method. 2014-06-28 21:12:54 -04:00
Jake Petroules 76d5480313 Add missing parameter types. 2014-06-28 21:12:21 -04:00
Jake Petroules 135bcb483e Let the compiler know that SULog is a format function.
This allows it to warn properly on malformed format strings.
2014-06-28 21:11:43 -04:00
Jake Petroules e2854d3a29 Add explicit casts for type conversions.
The +0 and >>0 in SUDSAVerifier are present for readability;
the compiler is more than capable of optimizing them into nothing.
2014-06-28 21:10:53 -04:00
Jake Petroules ef5a0a997d Make string constants static as they are not used outside the translation unit. 2014-06-28 21:08:49 -04:00
Jake Petroules 74158c6da9 Add missing extern declaration. 2014-06-28 21:08:08 -04:00
Jake Petroules e5d0015185 Don’t compare floating point values with == 2014-06-28 21:07:23 -04:00
Jake Petroules d390a58f72 BOOL is a signed char; make sure it’s only ever YES or NO, not in [2, 255]. 2014-06-28 21:04:57 -04:00
Jake Petroules 435f89c11f Replace id with specific types where appropriate. 2014-06-28 21:02:33 -04:00
Jake Petroules 9984eb9ba3 Remove unused exception parameters. 2014-06-28 21:00:14 -04:00
Jake Petroules 89f5c6eb4b Add __attribute__((noreturn)) to hint for compiler optimizations.
exit() logically guarantees the method will never return;
this attribute allows the compiler to optimize for this case.
2014-06-28 20:58:14 -04:00
Jake Petroules 9c787a08aa Remove trailing semicolons. 2014-06-28 20:55:48 -04:00
Jake Petroules 88bc70cb9a Silence sign conversion warnings in third party code. 2014-06-28 20:37:38 -04:00
Jake Petroules 7262555d72 Silence CSSM warnings in SUDSAVerifier. 2014-06-28 20:35:58 -04:00
Jake Petroules 1ce94b8e2f Xcode project: set organization name and class prefix. 2014-06-28 19:48:30 -04:00
Jake Petroules a62180b3ac Fix memory leak. 2014-06-28 19:42:59 -04:00
Jason Lee e7b7094372 zh-CN translate "Learn More" button 2014-06-28 23:44:23 +01:00
Kornel Lesiński e17d55146d Fixed potential CFRelease of NULL, code style fixes 2014-06-28 23:38:27 +01:00
Sam Deane 98e5959461 If the downloaded update fails the code signing check, log out some more detailed information to help with diagnosing the problem. 2014-06-28 23:26:12 +01:00
Kornel 06a897ed03 Merge pull request #39 from pornel/Xcode5xibs
Migrate xibs to Xcode 5
2014-06-28 23:19:41 +01:00
Kornel 2348532907 Merge pull request #335 from pornel/master
Finish moving all informal protocols to formal protocols.
2014-06-28 21:40:58 +01:00
Kornel Lesiński 98cde3310d Updated README 2014-06-28 21:27:44 +01:00
C.W. Betts 66b734322d Merge branch 'master' into ARC 2014-06-28 13:22:54 -06:00
C.W. Betts bb990ad172 Finish moving all informal protocols to formal protocols.
Fix improperly-named protocols.
2014-06-28 13:19:27 -06:00
C.W. Betts d33cc1efd6 Migrate the SUUpdateAlert xibs to Xcode 5. 2014-06-28 11:26:16 -06:00
C.W. Betts 1eedc27e5f Convert the xibs to Xcode 5.1 format.
The SUUpdateAlert wasn’t migrated in this commit because of the autolayout branch.
2014-06-28 11:24:26 -06:00
Kornel Lesiński 133a701d24 Remove option to install unverified updates 2014-06-25 02:04:41 +01:00
C.W. Betts 2459733d26 Remove unused autorelease pool class usage.
Do we even still use the BinaryDelta tool?
2014-06-22 19:07:43 -06:00
Kornel Lesiński 0585a22f07 Reflect version requirement in sample appcast 2014-06-22 19:41:36 +01:00
C.W. Betts 93e339f32e Convert Sparkle to ARC, take three. 2014-06-20 13:26:39 -06:00
Oleg Krupnov 3a52b7a503 Added XPC service for relaunching from sandboxed mode 2014-01-21 14:55:37 +02:00
Eugene Krupnov 75f86a6d98 Add Sandbox XPC Service 2014-01-20 19:59:46 +02:00
Oleg Krupnov 8d2f0d31d4 Converted encoding of strings files to UTF-8 2014-01-09 09:00:17 +02:00
Oleg Krupnov a7ca6d79de Improved Polish localization 2014-01-09 08:58:22 +02:00
Oleg Krupnov 076087d4f7 Improved Spanish localization 2014-01-08 15:16:00 +02:00
Oleg Krupnov 93b034b244 Improved Swedish localization 2013-11-04 22:30:07 +02:00
Oleg Krupnov 1fc5d2f215 Updated Italian localization 2013-10-21 18:31:51 +03:00
Oleg Krupnov 6dd689adfc Updated French localization 2013-10-21 13:08:42 +03:00
Oleg Krupnov fa3b83a8c7 Improved German localization 2013-10-21 12:10:56 +03:00
Oleg Krupnov 249331bd32 Improved Russian localization 2013-10-18 17:29:40 +03:00
Oleg Krupnov 262cbf2ff9 Removed unused resources, Russian 2013-10-16 14:13:14 +03:00
Oleg Krupnov 40ab94d684 Removed some dummy strings 2013-10-14 16:17:35 +03:00
Oleg Krupnov 20f73ffc94 Fixed Xcode5 warnings 2013-10-10 17:39:19 +03:00
Oleg Krupnov 11ccce2981 Removed unused strings 2013-10-10 17:39:10 +03:00
416 changed files with 26418 additions and 88762 deletions

No files matched your search

-1
View File
@@ -16,4 +16,3 @@ profile
## Ignore incredibly annoying .DS_Store files
.DS_Store
DerivedData/
Regular → Executable
+287 -1
View File
@@ -1,6 +1,71 @@
# 1.10.0
* Massive improvements to the BinaryDelta tool (Zorg)
- Ability to track file permissions (Zorg)
- Nicely formatted log output (Zorg)
- Numerous bug fixes in handling of symlinks, empty directories, case-insensitive names, etc. (Zorg)
- Refactored and modernized code (Zorg)
- libxar is no longer weak-linked (C.W. Betts)
* Double-check the code signature of the the app after installation (Isaac Wankerl)
* Added headless guided package installation (Graham Miln)
* Added ability to inject custom HTTP headers in appcast request (Mattias Gunneras)
* Changes to make unarching more reliable (Zorg, Kornel Lesiński)
* Have Sparkle build a framework module (C.W. Betts)
* Stdout used for non error outputs (JDuquennoy)
* French locale update (Kent Sutherland)
# 1.9.0
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
* Make the error definitions public (C.W. Betts)
* Add support for lzma compressed tarballs (Kyle Fuller)
* Back to SKIP_INSTALL=YES by default (Tony Arnold)
* Properly set install names and rpaths for targets (Jake Petroules)
* Use Library/Caches rather than app support directory (Kornel Lesiński)
* Check for a modal window being onscreen before trying to put up the Sparkle prompt (Alf Watt)
* Fixed crashes on 10.7 (Chris Campbell, Ger Teunis)
* Fixed Sparkle tags parsing (Tamás Lustyik)
* SULog code cleanups (Kevin Wojniak)
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
* Fix warnings under Xcode 6.1 relating the SUUpdateAlert XIB (Tony Arnold)
* Prefer string constants to strings (Jake Petroules)
* Use Info.plist keys instead of macros (Jake Petroules)
* Only export public symbols. (Jake Petroules)
* BinaryDelta: avoid crash with bad paths (Jake Petroules)
* Fixing Swedish translations (Erik Vikström)
* Turkish localization fixes (Emir)
* Proofing of Ukrainian localization (Vera Tkachenko)
# 1.8.0
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
* Detailed error log for failed signature checks (Kornel Lesiński)
* Converted Sparkle to ARC (C.W. Betts)
* Converted ivars to properties. (Jake Petroules)
* Cocoapod support (Xhacker Liu)
* Quarantine removal on OS X 10.10 (C.W. Betts)
* Updated Japanese localization (1024jp)
* Added Greek localization
# 1.7.1
* Removed option to install unverified updates (Kornel Lesiński)
* Added detailed log when code signing verification fails (Sam Deane)
* Restored original Sparkle icon. (Jake Petroules)
* Switched SUUpdateAlert.xib to AutoLayout (Kornel Lesiński)
* Replace references to andymatuschak.org with sparkle-project.org. (Jake Petroules)
* Several code cleanups, modernizations, fixed warnings and improved code formatting (Jake Petroules)
* Make the repository significantly more organized. (Jake Petroules)
* Xcode project: set organization name and class prefix. (Jake Petroules)
* Link to Foundation and AppKit instead of Cocoa. (Jake Petroules)
* Use new operatingSystemVersion API when available. (Jake Petroules)
* Add .clang-format configuration file for source code formatting. (Jake Petroules)
* Add a target to build Sparkle API documentation using Doxygen. (Jake Petroules)
# 1.7.0
* Dropped support for Mac OS X 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
* Dropped support for OS X 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
* Removed use of deprecated functions (Zachary Waldowski)
* Switched to modern Obj-C runtime and new literals syntax
* Removed pre-10.7 code. (C.W. Betts)
@@ -45,3 +110,224 @@
* Adding <sparkle:tags> appcast item element, <sparkle:criticalUpdate /> tag (Andy Matuschak)
* We have this check box that says "Automatically download and install updates in the future." But we only download them automatically. We still ask permission again before installing them. (Andy Matuschak)
# 1.5.0-beta6
* Important Changes
* Sparkle now requires DSA signatures on your updates. Check the documentation for more information on how to set that up if you don't already sign your updates. You can bypass this requirement if you deliver both your appcast and your updates over SSL.
* Sparkle will no longer display release notes located at file:// URLs, since Javascript on such a page would be able to read files on your file system.
* For security reasons, Sparkle will refuse to install updates which appear to "downgrade" the app.
* SUUpdater now implements new keys: "automaticallyDownloadsUpdates", "lastUpdateCheckDate", and "sendsSystemProfile."
* Fixed a bug that could prevent SUProbingUpdateDriver from working.
* Fixed a bug that prevented the updaterWillRelaunchApplication: delegate method from getting called.
* Fixed displaying release notes transmitted "loose" in the <description> key.
* Fixed Sparkle compilation on 10.4 systems.
* Fixed a bug that could cause window confusion if an app changed its LSUIElement at runtime.
* Added support for Sparkle 1.1's behavior of disabling updates when the check interval is 0.
* Sparkle can now handle appending parameters to URLs which already have parameters.
* If an update's sparkle:shortVersionString is the same as the host's CFBundleShortVersionString, the sparkle:version and CFBundleVersion will be presented in parentheticals.
# 1.5.0-beta5
* Important Changes!
* Made every Sparkle class private except for SUUpdater, SUAppcast, SUAppcastItem, and the SUVersionComparisonProtocol.
* There is now a single SUUpdater singleton for every host bundle; instead of -[SUUpdater setHostBundle], you can use +[SUUpdater updaterForBundle].
* Redefined the (entire) delegate protocol accordingly.
* Renamed -[SUUpdater updatePreferencesChanged] to -[SUUpdater resetUpdateCycle]. This provides better semantics for non-apps, which need to start the update cycle manually.
* -[SUUpdater checkForUpdatesWithDriver] is private. If you were using SUProbingUpdateDriver, you can now use -[SUUpdater checkForUpdateInformation] for a similar effect.
* All the user defaults keys are now private; instead, SUUpdater is KVC-compliant for automaticallyChecksForUpdates, updateCheckInterval, and feedURL.
* Reduced the size of the English-only framework by 25%.
* System profiling information is now only submitted to the server once per week; this will help normalize your statistics across users with different interval preferences.
* The feedParamatersForUpdater: delegate method now requires "displayKey" and "displayVersion" keys so that it can inform the user what's being sent.
* Added a delegate method called pathToRelaunchForUpdater: which can be used for plugins to provide the path which should be used when relaunching the client after installing an update.
* Added support for xml:lang to pick localized nodes in appcasts (for release notes, etc).
* Fixed a bug which would cause the "checking for updates" window to not disappear in certain extraordinary error conditions.
* Fixed a DSA signature checking bug for .tar.gz archives.
* Sparkle now refuses to update on any read-only volume, not just dmgs.
* Sparkle will clean up the host app's name and version before sending it as the user agent string; some non-ASCII characters were causing problems.
* Added an Italian localization courtesy Michele Longhi.
* Added a Swedish localization courtesy Daniel Bergman.
* Fixes to the French localization courtesy Ronald Leroux and Yann Ricqueberg.
* Fixes to the German localization courtesy Sven-S. Porst.
* Fixes to the Russian localization courtesy Alexander Bykov and Anton Sotkov.
* Fixed a number of issues related to archive format detection: I reverted back to extensions from UTIs.
* Focus behavior fixes for LSUIElement apps.
* The status window progress bar now animates even when indeterminate.
* Major refactorings to improve functionality for non-app bundles.
# 1.5.0-beta4
* Fixed a critical bug which prevented non-.dmgs from unarchiving properly.
* Added reporting of 64-bit capability to the profiling system.
# 1.5.0-beta3
* Added a new delegate method to SUUpdater.h to allow delegates to specify custom version comparators.
* Added a German localization, courtesy the Camino localizer team: Dominik Tobschall, Tobias Stohr, and Friedemann Bochow.
* Bug fixes:
* Fixed a serious bug which could cause a server to be DDoS'd (or the host app to crash!) if an appcast fails to be parsed.
* Fixed .tbz extraction if the archive was made with Stuffit.
* Fixed support for .tar.bz2 and .tar.gz; Sparkle has to assume the archive is a tar when it sees "bz2" and "gz"; don't use those without tarring.
* Fixed a typo which caused the shouldPromptForPermissionToCheckForUpdatesToHostBundle: method to not work in 1.5b2.
* Fixed .zip extraction on Tiger (Apple changed the UTI between releases)
* Fixed a crasher on Tiger.
* Fixed display of the default app icon when the host app doesn't have an icon.
* Sparkle now displays a sensible progress string and uses an indeterminate progress bar when the server doesn't report a file size.
* Fixed some memory leaks.
# 1.5.0-beta2
* Compatibility Issues:
* Most of the delegate method selectors have changed to scale better. See SUUpdater.h for changes; you'll likely have to make changes if you implement any delegate methods.
* If you're using .tar.gz or .tar.bz2 archives, name them ".tbz" or ".tgz" instead; Sparkle now uses UTIs for archive detection, and it's not smart about double extensions.
* I'm no longer supporting 10.3. This may or may not work on Panther—probably not.
* Sparkle's no longer built for ppc64 by default. If you want to ship that, feel free to build your own, but this saves a few hundred k.
* Enhancements:
* Sparkle now detects if the preferences for automatic update checks or the time interval change mid-cycle.
* If your product is a non-.app, you need to clue Sparkle in on the change by calling [[SUUpdater sharedUpdater] updatePreferencesChanged].
* Added a cancel to the "checking for updates..." dialog.
* Sparkle now cleans up all its litter in /tmp.
* Made SUUpdater's delegate an IBOutlet so you can hook it up in IB.
* Bug fixes:
* Sparkle no longer crashes on non-GC hosts when the user cancels an update's downloads.
* Sparkle no longer gets stuck in an inconsistent state or crashes when it can't parse the appcast on scheduled updates.
* Added the sharedUpdater method to SUUpdater, as it should have been.
* Fixed a bug where the "checking for updates..." window wouldn't go away if an error occurs while checking for updates.
* Made the dual-mode build configuration actually use the .xcconfig which builds it with GC support. (oops!)
* Fixed relaunching for prefpanes.
* Sparkle no longer fails to install updates on Snow Leopard (though there's still an issue with trashing the old version of the app, but it seems to be a 10.6 bug)
* Sparkle now handles redirects correctly under Tiger.
* Fixed the installation path for non-.app bundles.
* Fixed a bug which could crash Sparkle under non-English locales.
* Fixed a weird race condition which could cause the relaunch tool to never notice that its target relaunched.
* Fixed a bug where if the host app is inactive when an update occurs, the update alert sometimes doesn't become key.
* Minor textual fixes.
* Localizations:
* Dutch: Maarten Van Coile
* French: Yann Ricquebourg
* Spanish: Ernesto Gomez Cereijo
# 1.5.0-beta1
* The most important things to know:
* The 10.3 support is untested at best; sketchy at worst. Test with it thoroughly before you use it.
* Sparkle now asks for permission to update on second launch; don't be surprised at that. You can change that behavior with a delegate method; read SUUpdater.h for more info.
* We no longer distinguish between "check on startup" and "scheduled updates"; everything is scheduled, with the default being every day.
* The test application is using the new profiling features, but that's only for demonstration: these are off by default. More on this later.
* There are no localizations yet.
* New features:
* Sparkle now supports .pkgs. Just name the .pkg the name of the app and put in the update archive.
* Sparkle now sends optional demographic profiling information; set SUEnableSystemProfiling to YES in your Info.plist and check out the GET data sent to your webserver when fetching the appcast. More on this in the documentation. The test application has this on so you can see the behavior.
* Sparkle now supports updating non-.apps. Just call -setHostBundle: on the global SUUpdater to let it know what you're trying to update.
* Sparkle now supports garbage collection in the host app. Use "Sparkle-with-GC.framework" for that, but be aware it's 10.5-only.
* Sparkle is now 64-bit compatible, compiling both ppc64 and x86_64.
* Sparkle now supports a sparkle:minimumSystemVersion key you can set on appcast items. It does what you think it does.
* Sparkle now checks to see if the host app is running from a disk image and refuses to update if it is. (10.4+ only)
* Added support for entities in enclosure paths.
* The file size output is now formatted prettily.
* Sparkle now gives visual indication that it's checking for updates when the update's user initiated. ie: it pops up a status controller saying "checking for updates..."
* Added support for an SUPublicDSAKeyFile, so people don't have to copy/paste their entire key into their Info.plist. Set this key in your Info.plist to the filename of the key in your Resources directory.
* Added an actually maintainable codebase.
* Changes:
* Sparkle version comparison is now dramatically less stupid and verified by a bunch of unit tests. If something doesn't work the way you think it should, add a test to SUVersionComparisonTest.m
* Added a minimum to the check interval so that developers don't accidentally release their apps into the wild with 60-second test check intervals and have DOS-attack-like results. It's an hour now for release mode; feel free to change it.
* The relaunching process now uses a separate helper app, which is a much more robust method.
* Changed CFBundleShortVersionString behavior: Sparkle no longer uses Apple's about box style of displaying ShortVersionString (CFBundleVersion) when the latter is available.
* No more MD5 checking. Use DSA: it's actually secure.
* The abomination that was SUStatusChecker is dead. Use SUProbingUpdateDriver instead.
* Bugfixes:
* Fixed a huge bug with fully-automatic updating: before, if the user chose to relaunch later, the app would be running from the trash for a while. Now the buttons are "install and relaunch" or "install later."
* Sparkle forces Spotlight to reindex the updated app so that it won't keep pointing to the one in the trash.
* Sparkle trims whitespace from around DSA signatures; this could cause crashes before.
* Fixed a bug where the user choosing to skip a version would inhibit future automatic updates until the next launch.
* Fixed a bug that could occur when the app has a localized CFBundleName.
* .dmgs now work on Leopard.
* The status controller's button now sizes appropriately to the localization.
* Sparkle now works correctly with LSUIElement apps: it focuses them before displaying the update alert.
* Sparkle now deletes failed partial downloads.
* The update alert no longer floats above everything in the app.
* Fixed varied and sundry memory leaks.
* A ton of other things that I've forgotten or were too small to mention!
# 1.1
* Optimized framework size: now only 1.4mb with all localizations and 384kb with only English (an English-only version is in the Extras folder).
* Added a new SUStatusChecker class for programmatically determining if a new version is available (see the docs); thanks, Evan Schoenberg!
* Added support for apps using SIGCHLD; thanks, Augie Fackler!
* Added a zh_CN update from JT Lee
* Added a Polish update from Piotr Chylinski
* Fixed DMG support for images with /Applications symlinks.
* Fixed a really stupid interval-checking bug that could cause repeated hits to the appcast.
* Fixed a bug where the check interval would be inconsistent if a value of 0 was stored in the user defaults.
# 1.0
* Additions:
* Added real version comparison courtesy Kevin Ballard: Sparkle now knows that 0.89 < 1.0a3 < 1.0.
* Added many localizations courtesy David Kocher's localization team.
* Added a much better installation mechanism courtesy Allan Odgaard.
* Added a user agent string to the RSS fetch request.
* Added support for CFBundleShortVersionString in addition to CFBundleVersion, and support for a sparkle:shortVersionString attribute on the enclosure.
* Added support for CFBundleDisplayName if available.
* Changes:
* Automatic updating is now allowed by default, but only if DSA signing is on.
* Pressing Escape or closing the update alert now reminds the user later.
* Now when there's a stored check interval, Sparkle doesn't check immediately on startup the first time the app is launched because the user hasn't consented to it yet.
* The update alert now remembers its size and floats.
* Bug Fixes:
* Fixed installation of DMGs with multiple files enclosed.
* Fixed a nasty memory leak.
* Fixed a bug wherein having no value for allowing automatic updates would display a checkbox for the updates but would not honor it.
* Fixed a bug in zip extraction that occurred in Panther.
* Fixed release notes caching.
* Fixed a bug wherein Sparkle refused to authenticate the installation if the user had cancelled authentication previously in that session.
* Fixed a weird bug that would cause a second help menu to appear on first launch.
* Fixed a bug that could occur when changing the scheduled check interval.
* Fixed a bug wherein the host app could crash if the user clicked Remind Me Later before the release notes finished loading.
* Fixed a bug wherein the behavior was undefined if the user manually initiated a check when an automatic one was already taking place.
* Fixed wrapping on the description field in the update alert.
# 1.0-beta3
* Fixed a nasty crasher that occurred often when the user was not connected to the internet.
# 1.0-beta2
* Major Improvements:
* Fully automatic updating! (see the Documentation: this is beta and off by default)
* Added support for DSA signatures (see the Documentation).
* Added support for MD5 sum verification.
* Added Security.framework-based authentication for installing to privileged directories.
* Huge refactoring of the codebase: there's now a Sparkle Xcode project, Sparkle is now a framework, and everything is modular / abstracted. And no more code-generated interface.
* Minor Improvements:
* A SUUpdaterWillRestartNotification is sent out before restarting now.
* Added key equivalents to alert panel buttons.
* Error handling is much prettier now: technical messages are not presented to the user anymore.
* There's now a test app for developers to see what Sparkle's like before using it.
* Wrote new, pretty, extremely thorough documentation.
* Bug Fixes:
* Relaunch behavior is much improved and shouldn't fail in huge apps anymore.
* Fixed a bug wherein a failing tar command could crash the host app.
* Sparkle now looks at InfoPlist.strings in addition to Info.plist.
* Fixed some stupid typos.
# 1.0-beta1
* Major New Features:
* Sparkle now supports scheduled periodic updates—read the Readme for information on how to use it.
* Sparkle now supports WebKit-based release notes (for CSS and full HTML), which it displays in the main update alert, not a separate panel. The Readme has much more information. Sparkle will, of course, fall back on NSTextView if the host app does not include WebKit.
* Minor New Features:
* Added support for .zip update archives.
* Added support for .dmg update archives.
* Implemented Remind Me Later to replace simple update cancellation.
* Implemented Skip This Version functionality.
* Added support for multiple feeds via the user defaults SUFeedURL key taking precedent over the one in Info.plist.
* Added support for Sparkle's custom XML namespace, which is optional but may prove useful. See the Readme for more information.
* Bug Fixes:
* Sparkle will no longer enter an inconsistent state if the user tries to update again while one is already in progress.
* Sparkle now uses CFBundleName to determine the application's name instead of the app's filename.
* Sparkle no longer crashes if the user cancels during extraction.
* Lots of code refactoring.
# 0.1
* Initial Release
-1
View File
@@ -1,4 +1,3 @@
// BinaryDelta tool only
PRODUCT_NAME = BinaryDelta
GCC_PREFIX_HEADER =
-2
View File
@@ -1,4 +1,2 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigBinaryDelta.xcconfig"
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigBinaryDelta.xcconfig"
+64 -16
View File
@@ -1,29 +1,77 @@
// Common
FINISH_INSTALL_TOOL_NAME = Autoupdate
SPARKLE_BUNDLE_IDENTIFIER = org.andymatuschak.Sparkle
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
CURRENT_PROJECT_VERSION = 1.7.0
SPARKLE_APPEND_VERSION_NUMBER = 1
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
// if your app has a downgrade function or URL handler, turn this on
SPARKLE_AUTOMATED_DOWNGRADES = 0
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
// following on to always reset the name back to "MyApp":
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 10
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
ALWAYS_SEARCH_USER_PATHS = NO
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
ARCHS = x86_64
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 10.7
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)
GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\"
CLANG_ENABLE_OBJC_ARC = YES
// Enable warnings
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_SHADOW = YES
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ENABLE_MODULES = YES
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_SIGN_COMPARE = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_VARIABLE = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
GCC_WARN_PEDANTIC = YES
GCC_WARN_SHADOW = YES
GCC_WARN_SIGN_COMPARE = YES
GCC_WARN_STRICT_SELECTOR_MATCH = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VARIABLE = YES
// These should be removed once the conversion to ARC is complete
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-cstring-format-directive $(WARNING_CFLAGS_EXTRA)
+4 -1
View File
@@ -1,3 +1,5 @@
#include "ConfigCommon.xcconfig"
// Debug only
GCC_OPTIMIZATION_LEVEL = 0
@@ -5,4 +7,5 @@ DEBUG_INFORMATION_FORMAT = dwarf
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
SPARKLE_EXTRA_DEBUG = -DDEBUG
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
ONLY_ACTIVE_ARCH = YES
COPY_PHASE_STRIP = NO
+2
View File
@@ -1,3 +1,5 @@
#include "ConfigCommon.xcconfig"
// Release only
GCC_OPTIMIZATION_LEVEL = s
+7 -4
View File
@@ -1,10 +1,13 @@
// Framework only
INSTALL_PATH = @loader_path/../Frameworks
DYLIB_INSTALL_NAME_BASE = @rpath
DYLIB_COMPATIBILITY_VERSION = 1.6
DYLIB_CURRENT_VERSION = 1.7
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
PRODUCT_NAME = Sparkle
WRAPPER_EXTENSION = framework
FRAMEWORK_VERSION = A
INFOPLIST_FILE = Info.plist
GCC_PREFIX_HEADER = Sparkle.pch
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
SKIP_INSTALL = YES
DEFINES_MODULE = YES
+2 -2
View File
@@ -1,4 +1,4 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigFramework.xcconfig"
// Unit tests need access to non-public classes
GCC_SYMBOLS_PRIVATE_EXTERN = NO
-2
View File
@@ -1,4 +1,2 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigFramework.xcconfig"
+5 -1
View File
@@ -1,4 +1,8 @@
// Relaunch Tool only
PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
INFOPLIST_FILE = Sparkle/Autoupdate/Autoupdate-Info.plist
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
SKIP_INSTALL = YES
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_MODULES = NO
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigRelaunch.xcconfig"
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigRelaunch.xcconfig"
+4 -1
View File
@@ -1,5 +1,8 @@
// Test Application only
INFOPLIST_FILE = Test Application/Test Application-Info.plist
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
PRODUCT_NAME = Sparkle Test App
WRAPPER_EXTENSION = app
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_OBJC_ARC = NO
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
-2
View File
@@ -1,4 +1,2 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigTestApp.xcconfig"
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigTestApp.xcconfig"
+6 -5
View File
@@ -1,9 +1,10 @@
// Unit Test only
INFOPLIST_FILE = Tests/Sparkle Unit Tests-Info.plist
OTHER_LDFLAGS = -framework Cocoa -framework XCTest
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
PRODUCT_NAME = Sparkle Unit Tests
WRAPPER_EXTENSION = xctest
FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_LIBRARY_DIR)/Frameworks
GCC_PREFIX_HEADER = $(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h
GCC_PRECOMPILE_PREFIX_HEADER = YES
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
GCC_SYMBOLS_PRIVATE_EXTERN = NO
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigUnitTest.xcconfig"
-2
View File
@@ -1,3 +1 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigUnitTest.xcconfig"
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
set -e
if [ "$ACTION" = "" ] ; then
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
# because missing dSYMs in a release build SHOULD trigger a build failure
if [ "$CONFIGURATION" = "Release" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
fi
cd "$CONFIGURATION_BUILD_DIR/staging"
# Sorted file list groups similar files together, which improves tar compression
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
fi
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
set -e
if ! which -s git ; then
exit 0
fi
if [ -z "$SRCROOT" ] || \
[ -z "$BUILT_PRODUCTS_DIR" ] || \
[ -z "$INFOPLIST_PATH" ] || \
[ -z "$CURRENT_PROJECT_VERSION" ]; then
echo "$0: Must be run from Xcode!" 1>&2
exit 1
fi
# Get the current Git master hash
version=$(cd "$SRCROOT" ; git show-ref --abbrev heads/master | awk '{print $1}')
if [ -z "$version" ] ; then
echo "$0: Can't find a Git hash!" 1>&2
exit 0
fi
version="$CURRENT_PROJECT_VERSION git-$version"
# and use it to set the CFBundleShortVersionString value
export PATH="$PATH:/usr/libexec"
PlistBuddy -c "Set :CFBundleShortVersionString '$version'" \
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
+1
View File
@@ -0,0 +1 @@
html
+20
View File
@@ -0,0 +1,20 @@
PROJECT_NAME = Sparkle
PROJECT_NUMBER = 1.7.1
PROJECT_BRIEF = "A software update framework for OS X"
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
RECURSIVE = YES
INPUT = Sparkle
OUTPUT_DIRECTORY = Documentation
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST = YES
GENERATE_TODOLIST = YES
ALPHABETICAL_INDEX = YES
QT_AUTOBRIEF = YES
WARN_IF_UNDOCUMENTED = NO
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
if [ "$ACTION" = "" ] ; then
if which -s doxygen ; then
doxygen Documentation/Doxyfile
else
echo "warning: Doxygen not found in PATH"
fi
elif [ "$ACTION" = "clean" ] ; then
rm -rf "$SRCROOT/Documentation/html"
fi
Executable
+60
View File
@@ -0,0 +1,60 @@
Copyright (c) 2006-2013 Andy Matuschak.
Copyright (c) 2009-2013 Elgato Systems GmbH.
Copyright (c) 2011-2014 Kornel Lesiński.
Copyright (c) 2014 C.W. Betts.
Copyright (c) 2014 Petroules Corporation.
Copyright (c) 2014 Big Nerd Ranch.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=================
EXTERNAL LICENSES
=================
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>:
Copyright (c) 2003-2005 Colin Percival.
sais.c and sais.c, from sais-lite (2010/08/07) <https://sites.google.com/site/yuta256/sais>:
Copyright (c) 2008-2010 Yuta Mori.
SUDSAVerifier.m:
Copyright (c) 2011 Mark Hamlin.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted providing that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-38
View File
@@ -1,38 +0,0 @@
Copyright (c) 2006 Andy Matuschak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=================
EXTERNAL LICENSES
=================
License for bspatch.c and bsdiff.c, from bsdiff 4.3 (<http://www.daemonology.net/bsdiff/>:
/*-
* Copyright 2003-2005 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
Regular → Executable
+18 -4
View File
@@ -1,7 +1,21 @@
.PHONY: all localizable-strings
.PHONY: all localizable-strings release build test travis
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
localizable-strings:
rm en.lproj/Sparkle.strings || TRUE
genstrings -o en.lproj -s SULocalizedString *.m *.h
mv en.lproj/Localizable.strings en.lproj/Sparkle.strings
rm -f Sparkle/en.lproj/Sparkle.strings
genstrings -o Sparkle/en.lproj -s SULocalizedString Sparkle/*.m Sparkle/*.h
iconv -f UTF-16 -t UTF-8 < Sparkle/en.lproj/Localizable.strings > Sparkle/en.lproj/Sparkle.strings
rm Sparkle/en.lproj/Localizable.strings
release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
build:
xcodebuild clean build
test:
xcodebuild -scheme Distribution -configuration Debug test
travis: test
Regular → Executable
+33 -17
View File
@@ -1,30 +1,46 @@
# Sparkle <img src="Sparkle.png" width=48 height=48 alt="">
is an easy-to-use software update framework for Cocoa developers.
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle)
## This fork
An easy-to-use software update framework for Cocoa developers.
* Up to date with 10.9 SDK and Xcode 5/6. Supports Mac OS X 10.7+.
<img src="Resources/Screenshot.png" width="715" alt="Sparkle shows familiar update window with release notes">
## Changes since 1.5b
* Up-to-date with 10.10 SDK and Xcode 6. Supports OS X 10.7+.
* Cleaned up and modernized code, using ARC and Autolayout.
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
* Merged official Sparkle branch with truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
* Ability to mark updates as critical.
* Progress and status notifications for the host app.
* Name of finish_installation.app can be configured to match your app's name.
## Features
* True self-updating—no work required from the user.
* Displays release notes to the user via WebKit.
* True self-updating—the user can choose to automatically download and install all updates.
* Displays a detailed progress window to the user.
* Supports authentication for installing in secure locations.
* Really, really easy to install.
* Uses appcasts for release information.
* The user can choose to automatically download and install all updates.
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
* Supports DSA signatures for ultra-secure updates.
* Sparkle requires no code in your app, so it's trivial to upgrade or remove the module.
* Optionally sends user demographic information to the server when checking for updates.
* Supports Apple code signing and DSA signatures for ultra-secure updates.
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
* Displays release notes to the user via WebKit.
* Sparkle doesn't bug the user until second launch for better first impressions.
* Sparkle can install .pkg files for more complicated products.
* Supports bundles, preference panes, plugins, and other non-.app software.
* Supports branches due to minimum OS version requirements.
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
* Deep delegate support to make Sparkle work exactly as you need.
* Optionally sends system information to the server when checking for updates.
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
* Supports branches due to minimum OS version requirements.
## Developers
Building Sparkle requires Xcode 5 or above.
### API
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples).
### Building the distribution package
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed.
Alternatively, build the Distribution scheme in the Xcode UI.
-24
View File
@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.andymatuschak.Sparkle.relaunch</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.5</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSUIElement</key>
<string>1</string>
</dict>
</plist>
+65
View File
@@ -0,0 +1,65 @@
{
"images" : [
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16@2x.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32@2x.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128@2x.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File
File renamed without changes.
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Your Great App's Changelog</title>
<link>http://you.com/app/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 2.0 (2 bugs fixed; 3 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/2.0.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
<item>
<title>Version 1.5 (8 bugs fixed; 2 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/1.5.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
<item>
<title>Version 1.4 (5 bugs fixed; 2 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/1.4.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
</channel>
</rss>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

-37
View File
@@ -1,37 +0,0 @@
//
// SUAppcast.h
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
@protocol SUAppcastDelegate;
@class SUAppcastItem;
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
{
@private
NSArray *items;
NSString *userAgentString;
id<SUAppcastDelegate> delegate;
NSString *downloadFilename;
NSURLDownload *download;
}
@property (assign) id<SUAppcastDelegate> delegate;
@property (copy) NSString *userAgentString;
- (void)fetchAppcastFromURL:(NSURL *)url;
@property (readonly, copy) NSArray *items;
@end
@protocol SUAppcastDelegate <NSObject>
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
@end
#endif
-268
View File
@@ -1,268 +0,0 @@
//
// SUAppcast.m
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcast.h"
#import "SUConstants.h"
#import "SULog.h"
@interface NSXMLElement (SUAppcastExtensions)
@property (readonly, copy) NSDictionary *attributesAsDictionary;
@end
@implementation NSXMLElement (SUAppcastExtensions)
- (NSDictionary *)attributesAsDictionary
{
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSXMLNode *attribute in attributeEnum) {
dictionary[[attribute name]] = [attribute stringValue];
}
return dictionary;
}
@end
@interface SUAppcast () <NSURLDownloadDelegate>
@property (copy) NSString *downloadFilename;
@property (retain) NSURLDownload *download;
@property (copy) NSArray *items;
- (void)reportError:(NSError *)error;
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
@end
@implementation SUAppcast
@synthesize downloadFilename;
@synthesize delegate;
@synthesize userAgentString;
@synthesize download;
@synthesize items;
- (void)dealloc
{
self.items = nil;
self.userAgentString = nil;
self.downloadFilename = nil;
self.download = nil;
[super dealloc];
}
- (void)fetchAppcastFromURL:(NSURL *)url
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
if (userAgentString) {
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
}
self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease];
}
- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
{
NSString* destinationFilename = NSTemporaryDirectory();
if (destinationFilename)
{
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
[download setDestination:destinationFilename allowOverwrite:NO];
}
}
- (void)download:(NSURLDownload *)aDownload didCreateDestination:(NSString *)path
{
self.downloadFilename = path;
}
- (void)downloadDidFinish:(NSURLDownload *)aDownload
{
NSError *error = nil;
NSXMLDocument *document = nil;
BOOL failed = NO;
NSArray *xmlItems = nil;
NSMutableArray *appcastItems = [NSMutableArray array];
if (downloadFilename)
{
NSUInteger options = 0;
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease];
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
self.downloadFilename = nil;
}
else
{
failed = YES;
}
if (nil == document)
{
failed = YES;
}
else
{
xmlItems = [document nodesForXPath:@"/rss/channel/item" error:&error];
if (nil == xmlItems)
{
failed = YES;
}
}
if (failed == NO)
{
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
NSXMLNode *node;
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
while (failed == NO && (node = [nodeEnum nextObject]))
{
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
if ([[node children] count])
{
node = [node childAtIndex:0];
while (nil != node)
{
NSString *name = [node name];
if (name)
{
NSMutableArray *nodes = nodesDict[name];
if (nodes == nil)
{
nodes = [NSMutableArray array];
nodesDict[name] = nodes;
}
[nodes addObject:node];
}
node = [node nextSibling];
}
}
for (NSString *name in nodesDict)
{
node = [self bestNodeInNodes:nodesDict[name]];
if ([name isEqualToString:@"enclosure"])
{
// enclosure is flattened as a separate dictionary for some reason
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
dict[@"enclosure"] = encDict;
}
else if ([name isEqualToString:@"pubDate"])
{
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
if (date)
dict[name] = date;
}
else if ([name isEqualToString:@"sparkle:deltas"])
{
NSMutableArray *deltas = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
if ([[child name] isEqualToString:@"enclosure"])
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
}
dict[@"deltas"] = deltas;
}
else if (name != nil)
{
// add all other values as strings
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (theValue != nil) {
dict[name] = theValue;
}
}
}
NSString *errString;
SUAppcastItem *anItem = [[[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString] autorelease];
if (anItem)
{
[appcastItems addObject:anItem];
}
else
{
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
}
[nodesDict removeAllObjects];
[dict removeAllObjects];
}
}
if ([appcastItems count])
{
NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO] autorelease];
[appcastItems sortUsingDescriptors:@[sort]];
self.items = appcastItems;
}
if (failed)
{
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil)}]];
}
else if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
{
[delegate appcastDidFinishLoading:self];
}
}
- (void)download:(NSURLDownload *)aDownload didFailWithError:(NSError *)error
{
if (downloadFilename)
{
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
}
self.downloadFilename = nil;
[self reportError:error];
}
- (NSURLRequest *)download:(NSURLDownload *)aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
return request;
}
- (void)reportError:(NSError *)error
{
if ([delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
{
[delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
}
}
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes
{
// We use this method to pick out the localized version of a node when one's available.
if ([nodes count] == 1)
return nodes[0];
else if ([nodes count] == 0)
return nil;
NSMutableArray *languages = [NSMutableArray array];
NSString *lang;
NSUInteger i;
for (NSXMLElement *node in nodes) {
lang = [[node attributeForName:@"xml:lang"] stringValue];
[languages addObject:(lang ? lang : @"")];
}
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
if (i == NSNotFound) {
i = 0;
}
return nodes[i];
}
@end
-198
View File
@@ -1,198 +0,0 @@
//
// SUAppcastItem.m
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcastItem.h"
#import "SULog.h"
@interface SUAppcastItem ()
@property (copy, readwrite) NSString *title;
@property (copy, readwrite) NSDate *date;
@property (copy, readwrite) NSString *itemDescription;
@property (retain, readwrite) NSURL *releaseNotesURL;
@property (copy, readwrite) NSString *DSASignature;
@property (copy, readwrite) NSString *minimumSystemVersion;
@property (copy, readwrite) NSString *maximumSystemVersion;
@property (retain, readwrite) NSURL *fileURL;
@property (copy, readwrite) NSString *versionString;
@property (copy, readwrite) NSString *displayVersionString;
@property (copy, readwrite) NSDictionary *deltaUpdates;
@property (retain, readwrite) NSURL *infoURL;
@property (readwrite, copy) NSDictionary *propertiesDictionary;
@end
@implementation SUAppcastItem
@synthesize date;
@synthesize deltaUpdates;
@synthesize displayVersionString;
@synthesize DSASignature;
@synthesize fileURL;
@synthesize infoURL;
@synthesize itemDescription;
@synthesize maximumSystemVersion;
@synthesize minimumSystemVersion;
@synthesize releaseNotesURL;
@synthesize title;
@synthesize versionString;
@synthesize propertiesDictionary;
- (BOOL)isDeltaUpdate
{
return propertiesDictionary[@"enclosure"][@"sparkle:deltaFrom"] != nil;
}
- (BOOL)isCriticalUpdate
{
return [propertiesDictionary[@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
}
- (instancetype) initWithDictionary:(NSDictionary *)dict
{
return [self initWithDictionary:dict failureReason:nil];
}
- (instancetype) initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error
{
self = [super init];
if (self)
{
id enclosure = dict[@"enclosure"];
// Try to find a version string.
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
NSString *newVersion = enclosure[@"sparkle:version"];
if( newVersion == nil )
newVersion = dict[@"sparkle:version"]; // UK 2007-08-31 Get version from the item, in case it's a download-less item (i.e. paid upgrade).
if (newVersion == nil) // no sparkle:version attribute anywhere?
{
// Separate the url by underscores and take the last component, as that'll be closest to the end,
// then we remove the extension. Hopefully, this will be the version.
NSArray *fileComponents = [enclosure[@"url"] componentsSeparatedByString:@"_"];
if ([fileComponents count] > 1)
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
}
if(!newVersion )
{
if (error)
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
[self release];
return nil;
}
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
self.title = dict[@"title"];
self.date = dict[@"pubDate"];
self.itemDescription = dict[@"description"];
NSString* theInfoURL = dict[@"link"];
if( theInfoURL )
{
if( ![theInfoURL isKindOfClass: [NSString class]] )
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
else
self.infoURL = [NSURL URLWithString:theInfoURL];
}
// Need an info URL or an enclosure URL. Former to show "More Info"
// page, latter to download & install:
if( !enclosure && !theInfoURL )
{
if (error)
*error = @"No enclosure in feed item";
[self release];
return nil;
}
NSString* enclosureURLString = enclosure[@"url"];
if( !enclosureURLString && !theInfoURL )
{
if (error) {
*error = @"Feed item's enclosure lacks URL";
}
[self release];
return nil;
}
if( enclosureURLString ) {
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
self.fileURL = [NSURL URLWithString:fileURLString];
}
if (enclosure) {
self.DSASignature = enclosure[@"sparkle:dsaSignature"];
}
self.versionString = newVersion;
self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"];
self.maximumSystemVersion = dict[@"sparkle:maximumSystemVersion"];
NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"];
if (nil == shortVersionString) {
shortVersionString = dict[@"sparkle:shortVersionString"]; // fall back on the <item>
}
if (shortVersionString)
self.displayVersionString = shortVersionString;
else
self.displayVersionString = [self versionString];
// Find the appropriate release notes URL.
if (dict[@"sparkle:releaseNotesLink"])
self.releaseNotesURL = [NSURL URLWithString:dict[@"sparkle:releaseNotesLink"]];
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
else
self.releaseNotesURL = nil;
if (dict[@"deltas"])
{
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
NSArray *deltaDictionaries = dict[@"deltas"];
for (NSDictionary *deltaDictionary in deltaDictionaries) {
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
[fakeAppCastDict removeObjectForKey:@"deltas"];
fakeAppCastDict[@"enclosure"] = deltaDictionary;
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
[fakeAppCastDict release];
deltas[deltaDictionary[@"sparkle:deltaFrom"]] = deltaItem;
[deltaItem release];
}
self.deltaUpdates = deltas;
}
}
return self;
}
- (void)dealloc
{
self.title = nil;
self.date = nil;
self.itemDescription = nil;
self.releaseNotesURL = nil;
self.DSASignature = nil;
self.minimumSystemVersion = nil;
self.fileURL = nil;
self.versionString = nil;
self.displayVersionString = nil;
self.infoURL = nil;
self.propertiesDictionary = nil;
[super dealloc];
}
@end
-94
View File
@@ -1,94 +0,0 @@
//
// SUAutomaticUpdateAlert.m
// Sparkle
//
// Created by Andy Matuschak on 3/18/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUAutomaticUpdateAlert.h"
#import "SUHost.h"
@interface SUAutomaticUpdateAlert ()
@property (retain) SUAppcastItem *updateItem;
@property (assign) id<SUAutomaticUpdateAlertDelegateProtocol> delegate;
@property (retain) SUHost *host;
@end
@implementation SUAutomaticUpdateAlert
@synthesize delegate;
@synthesize host;
@synthesize updateItem;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:(id<SUAutomaticUpdateAlertDelegateProtocol>)del
{
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
if (self)
{
self.updateItem = item;
self.delegate = del;
self.host = aHost;
[self setShouldCascadeWindows:NO];
[[self window] center];
}
return self;
}
- (void)dealloc
{
self.host = nil;
self.updateItem = nil;
[super dealloc];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
- (IBAction)installNow:(id)sender
{
[self close];
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallNowChoice];
}
- (IBAction)installLater:(id)sender
{
[self close];
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallLaterChoice];
}
- (IBAction)doNotInstall:(id)sender
{
[self close];
[delegate automaticUpdateAlert:self finishedWithChoice:SUDoNotInstallChoice];
}
- (NSImage *)applicationIcon
{
return [host icon];
}
- (NSString *)titleText
{
if ([updateItem isCriticalUpdate])
{
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [host name]];
}
else
{
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
}
}
- (NSString *)descriptionText
{
if ([updateItem isCriticalUpdate])
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
}
else
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
}
}
@end
-168
View File
@@ -1,168 +0,0 @@
//
// SUAutomaticUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUAutomaticUpdateDriver.h"
#import "SUAutomaticUpdateAlert.h"
#import "SUHost.h"
#import "SUConstants.h"
// 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;
@implementation SUAutomaticUpdateDriver
- (void)showUpdateAlert
{
isInterruptible = NO;
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([host isBackgroundApplication])
{
[[alert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
if ([NSApp isActive])
[[alert window] makeKeyAndOrderFront:self];
else
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
// Sudden termination is available on 10.6+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
[processInfo disableSuddenTermination];
willUpdateOnTermination = YES;
if ([[updater delegate] 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];
[[updater delegate] updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([updateItem isCriticalUpdate])
{
[self showUpdateAlert];
}
else
{
showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain];
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
isInterruptible = YES;
}
}
- (void)stopUpdatingOnTermination
{
if (willUpdateOnTermination)
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
[processInfo enableSuddenTermination];
willUpdateOnTermination = NO;
if ([[updater delegate] respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
[[updater delegate] updater:updater didCancelInstallUpdateOnQuit:updateItem];
}
}
- (void)invalidateShowUpdateAlertTimer
{
[showUpdateAlertTimer invalidate];
[showUpdateAlertTimer release];
showUpdateAlertTimer = nil;
}
- (void)dealloc
{
[self stopUpdatingOnTermination];
[self invalidateShowUpdateAlertTimer];
[alert release];
[super dealloc];
}
- (void)abortUpdate
{
[self stopUpdatingOnTermination];
[self invalidateShowUpdateAlertTimer];
[super abortUpdate];
}
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
[[alert window] makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
}
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
{
switch (choice)
{
case SUInstallNowChoice:
[self stopUpdatingOnTermination];
[self installWithToolAndRelaunch:YES];
break;
case SUInstallLaterChoice:
postponingInstallation = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
// We're already waiting on quit, just indicate that we're idle.
isInterruptible = YES;
break;
case SUDoNotInstallChoice:
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
}
}
- (BOOL)shouldInstallSynchronously { return postponingInstallation; }
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
if (relaunch) {
[self stopUpdatingOnTermination];
}
showErrors = YES;
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
}
- (void)applicationWillTerminate:(NSNotification *)note
{
[self installWithToolAndRelaunch:NO];
}
- (void)abortUpdateWithError:(NSError *)error
{
if (showErrors)
[super abortUpdateWithError:error];
else
[self abortUpdate];
}
@end
-424
View File
@@ -1,424 +0,0 @@
//
// SUBasicUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 4/23/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUBasicUpdateDriver.h"
#import "SUHost.h"
#import "SUDSAVerifier.h"
#import "SUInstaller.h"
#import "SUStandardVersionComparator.h"
#import "SUUnarchiver.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUPlainInstaller.h"
#import "SUPlainInstallerInternals.h"
#import "SUBinaryDeltaCommon.h"
#import "SUCodeSigningVerifier.h"
#import "SUUpdater_Private.h"
#ifdef FINISH_INSTALL_TOOL_NAME
// FINISH_INSTALL_TOOL_NAME expands to unquoted finish_install
#define QUOTE_NS_STRING2(str) @"" #str
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
#else
#error FINISH_INSTALL_TOOL_NAME not defined
#endif
@implementation SUBasicUpdateDriver
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
if ([aHost 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), [aHost name]]}]];
return;
}
SUAppcast *appcast = [[SUAppcast alloc] init];
CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC.
[appcast release];
[appcast setDelegate:self];
[appcast setUserAgentString:[updater userAgentString]];
[appcast fetchAppcastFromURL:URL];
}
- (id <SUVersionComparison>)versionComparator
{
id <SUVersionComparison> comparator = nil;
// Give the delegate a chance to provide a custom version comparator
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [[updater delegate] versionComparatorForUpdater: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:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
}
- (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:[SUHost systemVersionString]] != NSOrderedDescending;
}
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
}
return minimumVersionOK && maximumVersionOK;
}
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
{
NSString *skippedVersion = [host objectForUserDefaultsKey:SUSkippedVersionKey];
if (skippedVersion == nil) { return NO; }
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
return [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
}
NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
SUAppcastItem *item = nil;
// Now we have to find the best valid update in the appcast.
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
{
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
}
else // If not, we'll take care of it ourselves.
{
// Find the first update we can actually use.
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
do {
item = [updateEnumerator nextObject];
} while (item && ![self hostSupportsItem:item]);
if (binaryDeltaSupported()) {
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[host version]];
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
nonDeltaUpdateItem = [item retain];
item = deltaUpdateItem;
}
}
}
updateItem = [item retain];
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
if (updateItem == nil) { [self didNotFindUpdate]; return; }
if ([self itemContainsValidUpdate:updateItem])
[self didFindValidUpdate];
else
[self didNotFindUpdate];
}
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
{
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
[self abortUpdateWithError:error];
}
- (void)didFindValidUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
[self downloadUpdate];
}
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[updater delegate] updaterDidNotFindUpdate:updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]]}]];
}
- (void)downloadUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name
{
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];
[tempDir release];
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
int cnt=1;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
{
[tempDir release];
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
}
// 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.
[download cancel];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir]}]];
}
downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
[download setDestination:downloadPath allowOverwrite:YES];
}
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
{
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:host];
if (newBundlePath)
{
NSError *error = nil;
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
return YES;
} else {
SULog(@"Code signature check on update failed: %@", error);
}
}
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
}
- (void)downloadDidFinish:(NSURLDownload *)d
{
[self extractUpdate];
}
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
}
- (BOOL)download:(NSURLDownload *)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)extractUpdate
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath updatingHost:host];
if (!unarchiver)
{
SULog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
[self unarchiverDidFail:nil];
return;
}
CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV.
[unarchiver setDelegate:self];
[unarchiver start];
}
- (void)failedToApplyDeltaUpdate
{
// When a delta update fails to apply we fall back on updating via a full install.
[updateItem release];
updateItem = nonDeltaUpdateItem;
nonDeltaUpdateItem = nil;
[self downloadUpdate];
}
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
if (ua) { CFRelease(ua); }
[self installWithToolAndRelaunch:YES];
}
- (void)unarchiverDidFail:(SUUnarchiver *)ua
{
if (ua) { CFRelease(ua); }
if ([updateItem isDeltaUpdate]) {
[self failedToApplyDeltaUpdate];
return;
}
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil)}]];
}
- (BOOL)shouldInstallSynchronously { return NO; }
- (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];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
if (![self validateUpdateDownloadedToPath:downloadPath extractedToPath:tempDir DSASignature:[updateItem DSASignature] publicDSAKey:[host publicDSAKey]])
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: @"The update is improperly signed."}]];
return;
}
#endif
if (![updater mayUpdateAndRestart])
{
[self abortUpdate];
return;
}
// Give the host app an opportunity to postpone the install and relaunch.
static BOOL postponedOnce = NO;
if (!postponedOnce && [[updater delegate] 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];
postponedOnce = YES;
if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) {
return;
}
}
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[[updater delegate] updater:updater willInstallUpdate:updateItem];
}
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
// 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 *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
if (relaunchPathToCopy != nil)
{
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: @{} error: &error];
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
relaunchPath = [targetPath retain];
else
[self abortUpdateWithError:[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] : @"")]}]];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
[[updater delegate] updaterWillRelaunchApplication:updater];
if(!relaunchPath || ![[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.
[self abortUpdateWithError:[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), [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;
}
NSString *pathToRelaunch = [host bundlePath];
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
}
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
tempDir,
relaunch ? @"1" : @"0",
showUI ? @"1" : @"0"]];
[NSApp terminate:self];
}
- (void)cleanUpDownload
{
if (tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
{
BOOL success = NO;
NSError * error = nil;
success = [[NSFileManager defaultManager] removeItemAtPath: tempDir error: &error]; // Clean up the copied relauncher
if( !success )
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tempDir stringByDeletingLastPathComponent] destination:@"" files:@[[tempDir lastPathComponent]] tag:NULL];
}
}
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
{
if (aHost != host) { return; }
NSError * dontThrow = nil;
[[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
}
- (void)abortUpdate
{
[[self retain] autorelease]; // In case the notification center was the last one holding on to us.
[self cleanUpDownload];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super abortUpdate];
}
- (void)abortUpdateWithError:(NSError *)error
{
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
SULog(@"Sparkle Error: %@", [error localizedDescription]);
}
if ([error localizedFailureReason]) {
SULog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
}
if (download) {
[download cancel];
}
[self abortUpdate];
}
- (void)dealloc
{
[updateItem release];
[nonDeltaUpdateItem release];
[download release];
[downloadPath release];
[tempDir release];
[relaunchPath release];
[super dealloc];
}
@end
-101
View File
@@ -1,101 +0,0 @@
//
// SUBinaryDeltaApply.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#import "SUBinaryDeltaApply.h"
#import "SUBinaryDeltaCommon.h"
#include <CommonCrypto/CommonDigest.h>
#import <Foundation/Foundation.h>
#include <bspatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <xar/xar.h>
static void applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
{
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
bspatch(4, (char **)argv);
unlink([patchFile fileSystemRepresentation]);
}
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile)
{
xar_t x = xar_open([patchFile UTF8String], READ);
if (!x) {
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile UTF8String]);
return 1;
}
NSString *expectedBeforeHash = nil;
NSString *expectedAfterHash = nil;
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (!strcmp(xar_subdoc_name(subdoc), "binary-delta-attributes")) {
const char *value = 0;
xar_subdoc_prop_get(subdoc, "before-sha1", &value);
if (value)
expectedBeforeHash = @(value);
xar_subdoc_prop_get(subdoc, "after-sha1", &value);
if (value)
expectedAfterHash = @(value);
}
}
if (!expectedBeforeHash || !expectedAfterHash) {
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
return 1;
}
fprintf(stderr, "Verifying source... ");
NSString *beforeHash = hashOfTree(source);
if (![beforeHash isEqualToString:expectedBeforeHash]) {
fprintf(stderr, "Source doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
return 1;
}
fprintf(stderr, "\nCopying files... ");
removeTree(destination);
copyTree(source, destination);
fprintf(stderr, "\nPatching... ");
xar_file_t file;
xar_iter_t iter = xar_iter_new();
for (file = xar_file_first(x, iter); file; file = xar_file_next(iter)) {
NSString *path = @(xar_get_path(file));
NSString *sourceFilePath = [source stringByAppendingPathComponent:path];
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
const char *value;
if (!xar_prop_get(file, "delete", &value) || !xar_prop_get(file, "delete-then-extract", &value)) {
removeTree(destinationFilePath);
if (!xar_prop_get(file, "delete", &value))
continue;
}
if (!xar_prop_get(file, "binary-delta", &value))
applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath);
else
xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]);
}
xar_close(x);
fprintf(stderr, "\nVerifying destination... ");
NSString *afterHash = hashOfTree(destination);
if (![afterHash isEqualToString:expectedAfterHash]) {
fprintf(stderr, "Destination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
removeTree(destination);
return 1;
}
fprintf(stderr, "\nDone!\n");
return 0;
}
-26
View File
@@ -1,26 +0,0 @@
//
// SUBinaryDeltaCommon.h
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#ifndef SUBINARYDELTACOMMON_H
#define SUBINARYDELTACOMMON_H
#include <fts.h>
@class NSString;
@class NSData;
extern int binaryDeltaSupported(void);
extern int compareFiles(const FTSENT **a, const FTSENT **b);
extern NSData *hashOfFile(FTSENT *ent);
extern NSString *hashOfTree(NSString *path);
extern void removeTree(NSString *path);
extern void copyTree(NSString *source, NSString *dest);
extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
NSString *temporaryFilename(NSString *base);
NSString *stringWithFileSystemRepresentation(const char*);
#endif
-164
View File
@@ -1,164 +0,0 @@
//
// SUBinaryDeltaCommon.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#include "SUBinaryDeltaCommon.h"
#include <CommonCrypto/CommonDigest.h>
#include <Foundation/Foundation.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <xar/xar.h>
int binaryDeltaSupported(void)
{
// OS X 10.4 didn't include libxar, so we link against it weakly.
// This checks whether libxar is available at runtime.
return xar_close != 0;
}
int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll((*a)->fts_name, (*b)->fts_name);
}
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
{
NSUInteger directoryLength = [directory length];
if ([path hasPrefix:directory])
return [path substringFromIndex:directoryLength];
return path;
}
NSString *stringWithFileSystemRepresentation(const char *input) {
NSFileManager *fm = [NSFileManager defaultManager];
return [fm stringWithFileSystemRepresentation:input length:strlen(input)];
}
NSString *temporaryFilename(NSString *base)
{
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
const char *fsrepr = [template fileSystemRepresentation];
char buffer[strlen(fsrepr)+1];
strcpy(buffer, fsrepr);
// mkstemp() can't be used, beause it returns a file descriptor, and XAR API requires a filename
return stringWithFileSystemRepresentation(mktemp(buffer));
}
static void _hashOfBuffer(unsigned char *hash, const char* buffer, size_t bufferLength)
{
assert(bufferLength <= UINT32_MAX);
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
CC_SHA1_Update(&hashContext, buffer, (CC_LONG)bufferLength);
CC_SHA1_Final(hash, &hashContext);
}
static void _hashOfFile(unsigned char* hash, FTSENT *ent)
{
if (ent->fts_info == FTS_SL) {
char linkDestination[MAXPATHLEN + 1];
ssize_t linkDestinationLength = readlink(ent->fts_path, linkDestination, MAXPATHLEN);
if (linkDestinationLength < 0) {
perror("readlink");
return;
}
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
return;
}
if (ent->fts_info == FTS_F) {
int fileDescriptor = open(ent->fts_path, O_RDONLY);
if (fileDescriptor == -1) {
perror("open");
return;
}
size_t fileSize = (size_t)ent->fts_statp->st_size;
if (fileSize == 0) {
_hashOfBuffer(hash, NULL, 0);
close(fileDescriptor);
return;
}
void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);
perror("mmap");
return;
}
_hashOfBuffer(hash, buffer, fileSize);
munmap(buffer, fileSize);
close(fileDescriptor);
return;
}
if (ent->fts_info == FTS_D)
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
}
NSData *hashOfFile(FTSENT *ent)
{
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
_hashOfFile(fileHash, ent);
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
}
NSString *hashOfTree(NSString *path)
{
const char *sourcePaths[] = {[path fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return nil;
}
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL)
continue;
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
_hashOfFile(fileHash, ent);
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
const char *relativePathBytes = [relativePath fileSystemRepresentation];
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
}
fts_close(fts);
unsigned char hash[CC_SHA1_DIGEST_LENGTH];
CC_SHA1_Final(hash, &hashContext);
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1];
size_t i;
for (i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
sprintf(hexHash + i * 2, "%02x", hash[i]);
return @(hexHash);
}
void removeTree(NSString *path)
{
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
}
void copyTree(NSString *source, NSString *dest)
{
[[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
}
-278
View File
@@ -1,278 +0,0 @@
//
// SUBinaryDeltaTool.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#define _DARWIN_NO_64_BIT_INODE 1
#include "SUBinaryDeltaCommon.h"
#include "SUBinaryDeltaApply.h"
#include <CommonCrypto/CommonDigest.h>
#include <Foundation/Foundation.h>
#include <fcntl.h>
#include <fts.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <xar/xar.h>
extern int bsdiff(int argc, const char **argv);
@interface CreateBinaryDeltaOperation : NSOperation
@property (copy) NSString *relativePath;
@property (retain) NSString *resultPath;
@property (retain) NSString *_fromPath;
@property (retain) NSString *_toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree;
@end
@implementation CreateBinaryDeltaOperation
@synthesize _fromPath = _fromPath;
@synthesize _toPath = _toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree
{
if ((self = [super init])) {
self.relativePath = relativePath;
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
}
return self;
}
- (void)main
{
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
const char *argv[] = {"/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
int result = bsdiff(4, argv);
if (!result)
self.resultPath = temporaryFile;
}
- (void)dealloc
{
self.relativePath = nil;
self.resultPath = nil;
self._fromPath = nil;
self._toPath = nil;
[super dealloc];
}
@end
static NSDictionary *infoForFile(FTSENT *ent)
{
NSData *hash = hashOfFile(ent);
NSNumber *size = nil;
if (ent->fts_info != FTS_D) {
size = [NSNumber numberWithUnsignedLongLong:ent->fts_statp->st_size];
}
return [NSDictionary dictionaryWithObjectsAndKeys:hash, @"hash", [NSNumber numberWithUnsignedShort:ent->fts_info], @"type", size, @"size", nil];
}
static NSString *absolutePath(NSString *path)
{
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
return [[url absoluteURL] path];
}
static NSString *temporaryPatchFile(NSString *patchFile)
{
NSString *path = absolutePath(patchFile);
NSString *directory = [path stringByDeletingLastPathComponent];
NSString *file = [path lastPathComponent];
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
}
static BOOL shouldSkipDeltaCompression(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo)
{
unsigned long long fileSize = [[newInfo objectForKey:@"size"] unsignedLongLongValue];
if (fileSize < 4096) {
return YES;
}
if (!originalInfo) {
return YES;
}
if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) {
return YES;
}
return NO;
}
static BOOL shouldDeleteThenExtract(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
}
if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) {
return YES;
}
return NO;
}
int main(int argc, char **argv)
{
@autoreleasepool {
if (argc != 5) {
usage:
fprintf(stderr, "Usage: BinaryDelta [create | apply] before-tree after-tree patch-file\n");
exit(1);
}
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *command = [NSString stringWithUTF8String:argv[1]];
NSString *oldPath = stringWithFileSystemRepresentation(argv[2]);
NSString *newPath = stringWithFileSystemRepresentation(argv[3]);
NSString *patchFile = stringWithFileSystemRepresentation(argv[4]);
if ([command isEqualToString:@"apply"]) {
int result = applyBinaryDelta(oldPath, newPath, patchFile);
[pool drain];
return result;
}
if (![command isEqualToString:@"create"]) {
[pool drain];
goto usage;
}
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
const char *sourcePaths[] = {[oldPath fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
[pool drain];
perror("fts_open");
return 1;
}
fprintf(stderr, "Processing %s...", [oldPath UTF8String]);
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(oldPath, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
[originalTreeState setObject:info forKey:key];
}
fts_close(fts);
NSString *beforeHash = hashOfTree(oldPath);
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
for (NSString *key in originalTreeState)
{
[newTreeState setObject:[NSNull null] forKey:key];
}
fprintf(stderr, "\nProcessing %s... ", [newPath UTF8String]);
sourcePaths[0] = [newPath fileSystemRepresentation];
fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
[pool drain];
perror("fts_open");
return 1;
}
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(newPath, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
NSDictionary *oldInfo = [originalTreeState objectForKey:key];
if ([info isEqual:oldInfo])
[newTreeState removeObjectForKey:key];
else
[newTreeState setObject:info forKey:key];
}
fts_close(fts);
NSString *afterHash = hashOfTree(newPath);
fprintf(stderr, "\nGenerating delta... ");
NSString *temporaryFile = temporaryPatchFile(patchFile);
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
xar_subdoc_t attributes = xar_subdoc_new(x, "binary-delta-attributes");
xar_subdoc_prop_set(attributes, "before-sha1", [beforeHash UTF8String]);
xar_subdoc_prop_set(attributes, "after-sha1", [afterHash UTF8String]);
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
NSMutableArray *deltaOperations = [NSMutableArray array];
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingSelector:@selector(compare:)];
for (NSString* key in keys) {
id value = [newTreeState valueForKey:key];
if ([value isEqual:[NSNull null]]) {
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, "delete", "true");
continue;
}
NSDictionary *originalInfo = [originalTreeState objectForKey:key];
NSDictionary *newInfo = [newTreeState objectForKey:key];
if (shouldSkipDeltaCompression(key, originalInfo, newInfo)) {
NSString *path = [newPath stringByAppendingPathComponent:key];
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
assert(newFile);
if (shouldDeleteThenExtract(key, originalInfo, newInfo)) {
xar_prop_set(newFile, "delete-then-extract", "true");
}
} else {
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath];
[deltaQueue addOperation:operation];
[deltaOperations addObject:operation];
[operation release];
}
}
[deltaQueue waitUntilAllOperationsAreFinished];
[deltaQueue release];
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
NSString *resultPath = [operation resultPath];
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
assert(newFile);
xar_prop_set(newFile, "binary-delta", "true");
unlink([resultPath fileSystemRepresentation]);
}
xar_close(x);
unlink([patchFile fileSystemRepresentation]);
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
unlink([temporaryFile fileSystemRepresentation]);
fprintf(stderr, "Done!\n");
return 0;
}
}
-72
View File
@@ -1,72 +0,0 @@
//
// SUCodeSigningVerifier.m
// Sparkle
//
// Created by Andy Matuschak on 7/5/12.
//
//
#include <Security/CodeSigning.h>
#include <Security/SecCode.h>
#import "SUCodeSigningVerifier.h"
#import "SULog.h"
@implementation SUCodeSigningVerifier
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error
{
OSStatus result;
SecRequirementRef requirement = NULL;
SecStaticCodeRef staticCode = NULL;
SecCodeRef hostCode = NULL;
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
if (result != 0) {
SULog(@"Failed to copy host code %d", result);
goto finally;
}
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
if (result != 0) {
SULog(@"Failed to copy designated requirement %d", result);
goto finally;
}
NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath];
if (!newBundle) {
SULog(@"Failed to load NSBundle for update");
result = -1;
goto finally;
}
result = SecStaticCodeCreateWithPath((CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
if (result != 0) {
SULog(@"Failed to get static code %d", result);
goto finally;
}
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error);
if (result != 0 && error) [*error autorelease];
finally:
if (hostCode) CFRelease(hostCode);
if (staticCode) CFRelease(staticCode);
if (requirement) CFRelease(requirement);
return (result == 0);
}
+ (BOOL)hostApplicationIsCodeSigned
{
OSStatus result;
SecCodeRef hostCode = NULL;
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
if (result != 0) return NO;
SecRequirementRef requirement = NULL;
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
if (hostCode) CFRelease(hostCode);
if (requirement) CFRelease(requirement);
return (result == 0);
}
@end
-18
View File
@@ -1,18 +0,0 @@
//
// SUDSAVerifier.h
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUDSAVERIFIER_H
#define SUDSAVERIFIER_H
#import <Cocoa/Cocoa.h>
@interface SUDSAVerifier : NSObject
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
@end
#endif
-355
View File
@@ -1,355 +0,0 @@
//
// SUDSAVerifier.m
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUDSAVerifier.h"
#import <Cocoa/Cocoa.h>
#include <Security/cssm.h>
/* CDSA Specific */
static CSSM_CSP_HANDLE cdsaInit( void );
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle );
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey );
static void cdsaReleaseKey( CSSM_KEY_PTR key );
static BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key );
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature );
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes );
/* Helper Functions */
static NSData *b64decode( NSString *str );
static NSData *rawKeyData( NSString *str );
@implementation SUDSAVerifier
#pragma mark -
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
{
if ( !encodedSignature || !pkeyString || !path ) return NO;
BOOL result = NO;
NSData *pathData = nil, *sigData = nil;
CFDataRef hashData = NULL;
CSSM_KEY_PTR pubKey = cdsaCreateKey((CFDataRef)rawKeyData(pkeyString)); // Create the DSA key
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
if ( !pubKey ) return NO;
if ( (cspHandle = cdsaInit()) == CSSM_INVALID_HANDLE ) goto validate_end; // Init CDSA
if ( !cdsaVerifyKey(cspHandle, pubKey) ) goto validate_end; // Verify the key is valid
if ( (pathData = [NSData dataWithContentsOfFile:path]) == nil ) goto validate_end; // File data
if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (CFDataRef)pathData)) == NULL ) goto validate_end; // Hash
// Remove any line feeds from end of signature
// (Not likely needed, but the verify _can_ fail if there is, so...)
if ( [encodedSignature characterAtIndex:[encodedSignature length] - 1] == '\n' ) {
NSMutableString *sig = [[encodedSignature mutableCopy] autorelease];
while ( [sig characterAtIndex:[sig length] - 1] == '\n' )
[sig deleteCharactersInRange:NSMakeRange([sig length] - 1, 1)];
encodedSignature = sig;
}
if ( (sigData = b64decode(encodedSignature)) == nil ) goto validate_end; // Decode signature
// Verify the signature on the file
result = cdsaVerifySignature( cspHandle, pubKey, hashData, (CFDataRef)sigData );
validate_end:
cdsaReleaseKey( pubKey );
cdsaRelease( cspHandle );
if ( hashData ) CFRelease( hashData );
return result;
}
@end
#pragma mark -
#pragma mark Misc Helper Functions
#pragma mark -
static NSData *b64decode( NSString *str )
{
if ( !str ) return nil;
NSMutableData *retval = nil;
NSData *input = [str dataUsingEncoding:NSUTF8StringEncoding];
UInt8 *ibuf = (UInt8 *)[input bytes], *buf = NULL, *a = NULL;
size_t len = [input length], i = 0, j = 0, size = ((len + 3) / 4) * 3;
static UInt8 table[256] = {
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 00-0F */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 10-1F */
99,99,99,99,99,99,99,99,99,99,99,62,99,99,99,63, /* 20-2F */
52,53,54,55,56,57,58,59,60,61,99,99,99,99,99,99, /* 30-3F */
99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
15,16,17,18,19,20,21,22,23,24,25,99,99,99,99,99, /* 50-5F */
99,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
41,42,43,44,45,46,47,48,49,50,51,99,99,99,99,99, /* 70-7F */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 80-8F */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 90-9F */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* A0-AF */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* B0-BF */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* C0-CF */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* D0-DF */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* E0-EF */
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 /* F0-FF */
};
retval = [NSMutableData dataWithLength:size];
buf = [retval mutableBytes];
if ( (a = calloc(4, sizeof(UInt8))) == NULL ) return nil;
do {
size_t ai = 0;
a[0] = a[1] = a[2] = a[3] = 0;
do {
UInt8 d = table[ibuf[i++]];
if ( d != 99 ) {
a[ai] = d;
ai++;
if ( ai == 4 ) break;
}
} while ( i < len );
if ( ai >= 2 ) buf[j] = (a[0] << 2) | (a[1] >> 4);
if ( ai >= 3 ) buf[j+1] = (a[1] << 4) | (a[2] >> 2);
if ( ai >= 4 ) buf[j+2] = (a[2] << 6) | a[3];
j += ai-1;
} while ( i < len );
free( a );
if ( j < size ) [retval setLength:j];
return retval;
}
static NSData *rawKeyData( NSString *key )
{
if ( (key == nil) || ([key length] == 0) ) return nil;
NSMutableString *t = [[key mutableCopy] autorelease];
// Remove the PEM guards (if present)
[t replaceOccurrencesOfString:@"-" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
[t replaceOccurrencesOfString:@"BEGIN PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
[t replaceOccurrencesOfString:@"END PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
// Remove any line feeds from the beginning of the key
while ( [t characterAtIndex:0] == '\n' ) {
[t deleteCharactersInRange:NSMakeRange(0, 1)];
}
// Remove any line feeds at the end of the key
while ( [t characterAtIndex:[t length] - 1] == '\n' ) {
[t deleteCharactersInRange:NSMakeRange([t length] - 1, 1)];
}
// Remove whitespace around each line of the key.
NSMutableArray *pkeyTrimmedLines = [NSMutableArray array];
NSCharacterSet *whiteSet = [NSCharacterSet whitespaceCharacterSet];
for (NSString *pkeyLine in [t componentsSeparatedByString:@"\n"])
{
[pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:whiteSet]];
}
key = [pkeyTrimmedLines componentsJoinedByString:@"\n"]; // Put them back together.
// Base64 decode to return the raw key bits (DER format rather than PEM)
return b64decode( key );
}
#pragma mark -
#pragma mark CDSA
#pragma mark -
/* Helper Functions */
static CSSM_DATA_PTR su_createData( CFDataRef bytes );
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData );
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes );
/* Memory functions */
static void *su_malloc( CSSM_SIZE size, void *ref );
static void su_free( void *ptr, void *ref );
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref );
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref );
/* Constants & Typedefs */
static CSSM_VERSION vers = { 2, 0 };
static const CSSM_GUID su_guid = { 'S', 'p', 'a', { 'r', 'k', 'l', 'e', 0, 0, 0, 0 } };
static CSSM_BOOL cssmInited = CSSM_FALSE;
static CSSM_API_MEMORY_FUNCS SU_MemFuncs = {
su_malloc,
su_free,
su_realloc,
su_calloc,
NULL
};
static CSSM_CSP_HANDLE cdsaInit( void )
{
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
CSSM_RETURN crtn;
if ( !cssmInited ) {
CSSM_PVC_MODE pvcPolicy = CSSM_PVC_NONE;
crtn = CSSM_Init( &vers, CSSM_PRIVILEGE_SCOPE_NONE, &su_guid, CSSM_KEY_HIERARCHY_NONE, &pvcPolicy, NULL );
if ( crtn ) return CSSM_INVALID_HANDLE;
cssmInited = CSSM_TRUE;
}
crtn = CSSM_ModuleLoad( &gGuidAppleCSP, CSSM_KEY_HIERARCHY_NONE, NULL, NULL );
if ( crtn ) return CSSM_INVALID_HANDLE;
crtn = CSSM_ModuleAttach( &gGuidAppleCSP, &vers, &SU_MemFuncs, 0, CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE, NULL, 0, NULL, &cspHandle );
if ( crtn ) return CSSM_INVALID_HANDLE;
return cspHandle;
}
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle )
{
if ( CSSM_ModuleDetach(cspHandle) != CSSM_OK ) return;
CSSM_ModuleUnload( &gGuidAppleCSP, NULL, NULL );
}
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey )
{
CSSM_KEY_PTR retval = NULL;
if ( !rawKey || (CFDataGetLength(rawKey) == 0) ) return NULL;
if ( (retval = su_malloc(sizeof(CSSM_KEY), NULL)) == NULL ) return NULL;
if ( !su_copyBytesToData(&(retval->KeyData), CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
su_free( retval, NULL );
return NULL;
}
CSSM_KEYHEADER_PTR hdr = &(retval->KeyHeader);
memset( hdr, 0, sizeof(CSSM_KEYHEADER) );
hdr->HeaderVersion = CSSM_KEYHEADER_VERSION;
hdr->CspId = su_guid;
hdr->BlobType = CSSM_KEYBLOB_RAW;
hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_X509;
hdr->AlgorithmId = CSSM_ALGID_DSA;
hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY;
hdr->KeyAttr = CSSM_KEYATTR_EXTRACTABLE;
hdr->KeyUsage = CSSM_KEYUSE_ANY;
return retval;
}
static void cdsaReleaseKey( CSSM_KEY_PTR key )
{
if ( key ) {
if ( key->KeyData.Data ) su_free( key->KeyData.Data, NULL );
su_free( key, NULL );
}
}
BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, CSSM_KEY_PTR key )
{
if ( key->KeyHeader.LogicalKeySizeInBits == 0 ) {
CSSM_RETURN crtn;
CSSM_KEY_SIZE keySize;
/* This will fail if the key isn't valid */
crtn = CSSM_QueryKeySizeInBits( cspHandle, CSSM_INVALID_HANDLE, key, &keySize );
if ( crtn ) return NO;
key->KeyHeader.LogicalKeySizeInBits = keySize.LogicalKeySizeInBits;
}
return YES;
}
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature )
{
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
CSSM_DATA_PTR plain = su_createData( msg ), cipher = su_createData( signature );
BOOL retval = NO;
if ( !plain || !cipher || (CSSM_CSP_CreateSignatureContext(cspHandle, CSSM_ALGID_SHA1WithDSA, NULL, key, &ccHandle) != CSSM_OK) )
goto verify_end;
retval = ( CSSM_VerifyData(ccHandle, plain, 1, CSSM_ALGID_NONE, cipher) == CSSM_OK );
verify_end:
su_freeData( plain, true );
su_freeData( cipher, true );
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
return retval;
}
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes )
{
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
CSSM_DATA_PTR data = su_createData( bytes ), dgst = su_createData( NULL );
CFDataRef retval = NULL;
if ( !data || !dgst || (CSSM_CSP_CreateDigestContext(cspHandle, CSSM_ALGID_SHA1, &ccHandle) != CSSM_OK) )
goto digest_end;
if ( CSSM_DigestData(ccHandle, data, 1, dgst) == CSSM_OK )
retval = CFDataCreate( kCFAllocatorDefault, (const UInt8 *)dgst->Data, (CFIndex)dgst->Length );
digest_end:
su_freeData( data, true );
su_freeData( dgst, true );
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
return retval;
}
/* Memory Functions */
static void *su_malloc( CSSM_SIZE size, void *ref )
{
return malloc( size );
}
static void su_free( void *ptr, void *ref )
{
free( ptr );
}
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref )
{
return realloc( ptr, size );
}
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref )
{
return calloc( num, size );
}
/* Helper Functions */
static CSSM_DATA_PTR su_createData( CFDataRef bytes )
{
CSSM_DATA_PTR data = su_malloc( sizeof(CSSM_DATA), NULL );
if ( !data ) return NULL;
data->Data = NULL;
data->Length = 0;
if ( bytes ) su_copyBytesToData( data, CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
return data;
}
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData )
{
if ( data ) {
if ( freeData && data->Data ) su_free( data->Data, NULL );
su_free( data, NULL );
}
}
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes )
{
Boolean retval = false;
if ( size && bytes ) {
if ( (data->Data = su_malloc(size, NULL)) ) {
memcpy( data->Data, bytes, size );
data->Length = size;
retval = true;
}
}
return retval;
}
-162
View File
@@ -1,162 +0,0 @@
//
// SUDiskImageUnarchiver.m
// Sparkle
//
// Created by Andy Matuschak on 6/16/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUDiskImageUnarchiver.h"
#import "SUUnarchiver_Private.h"
#import "NTSynchronousTask.h"
#import "SULog.h"
#include <CoreServices/CoreServices.h>
@implementation SUDiskImageUnarchiver
+ (BOOL)canUnarchivePath:(NSString *)path
{
return [[path pathExtension] isEqualToString:@"dmg"];
}
// Called on a non-main thread.
- (void)extractDMG
{
@autoreleasepool {
[self extractDMGWithPassword:nil];
}
}
// Called on a non-main thread.
- (void)extractDMGWithPassword:(NSString *)password
{
@autoreleasepool {
BOOL mountedSuccessfully = NO;
SULog(@"Extracting %@ as a DMG", archivePath);
// get a unique mount point path
NSString *mountPoint = nil;
FSRef tmpRef;
do
{
// Using NSUUID would make creating UUIDs be done in Cocoa,
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
CFUUIDRef uuid = CFUUIDCreate(NULL);
if (uuid)
{
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
if (uuidString)
{
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
}
CFRelease(uuid);
}
}
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
NSData *promptData = nil;
promptData = [NSData dataWithBytes:"yes\n" length:4];
NSArray* arguments = @[@"attach", archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
NSData *output = nil;
NSInteger taskResult = -1;
@try
{
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
taskResult = [task result];
output = [[[task output] copy] autorelease];
[task release];
}
@catch (NSException *localException)
{
goto reportError;
}
if (taskResult != 0)
{
NSString* resultStr = output ? [[[NSString alloc] initWithData: output encoding: NSUTF8StringEncoding] autorelease] : nil;
SULog( @"hdiutil failed with code: %d data: <<%@>>", taskResult, resultStr );
goto reportError;
}
mountedSuccessfully = YES;
// Now that we've mounted it, we need to copy out its contents.
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
NSError *error = nil;
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
if (error)
{
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
goto reportError;
}
for (NSString *item in contents)
{
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
// We skip any files in the DMG which are not readable.
if (![manager isReadableFileAtPath:fromPath]) {
continue;
}
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
{
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
goto reportError;
}
}
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
});
goto finally;
reportError:
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfFailure];
});
finally:
if (mountedSuccessfully)
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
else
SULog(@"Can't mount DMG %@",archivePath);
}
}
- (void)start
{
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self extractDMG];
});
}
+ (void)load
{
[self registerImplementation:self];
}
- (BOOL)isEncrypted:(NSData*)resultData
{
BOOL result = NO;
if(resultData)
{
NSString *data = [[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding] autorelease];
if ((data != nil) && !NSEqualRanges([data rangeOfString:@"passphrase-count"], NSMakeRange(NSNotFound, 0)))
{
result = YES;
}
}
return result;
}
@end
-249
View File
@@ -1,249 +0,0 @@
//
// SUHost.m
// Sparkle
//
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUHost.h"
#import "SUConstants.h"
#import "SUSystemProfiler.h"
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
#import "SULog.h"
@interface SUHost ()
@property (retain, readwrite) NSBundle *bundle;
@end
@implementation SUHost
@synthesize bundle;
- (instancetype)initWithBundle:(NSBundle *)aBundle
{
if ((self = [super init]))
{
if (aBundle == nil) aBundle = [NSBundle mainBundle];
self.bundle = aBundle;
if (![bundle bundleIdentifier]) {
SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle);
}
defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain];
if (!defaultsDomain) {
defaultsDomain = [[bundle bundleIdentifier] retain];
}
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
usesStandardUserDefaults = [defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
}
return self;
}
- (void)dealloc
{
[defaultsDomain release];
self.bundle = nil;
[super dealloc];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
- (NSString *)bundlePath
{
return [bundle bundlePath];
}
- (NSString *)appSupportPath
{
NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *appSupportPath = nil;
if (!appSupportPaths || [appSupportPaths count] == 0)
{
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
}
else {
appSupportPath = appSupportPaths[0];
}
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"];
return appSupportPath;
}
- (NSString *)installationPath
{
#if NORMALIZE_INSTALLED_APP_NAME
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]];
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) {
return normalizedAppPath;
}
#endif
return [bundle bundlePath];
}
- (NSString *)name
{
NSString *name = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
if (name) return name;
name = [self objectForInfoDictionaryKey:@"CFBundleName"];
if (name) return name;
return [[[NSFileManager defaultManager] displayNameAtPath:[bundle bundlePath]] stringByDeletingPathExtension];
}
- (NSString *)version
{
NSString *version = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
if (!version || [version isEqualToString:@""])
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
return version;
}
- (NSString *)displayVersion
{
NSString *shortVersionString = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (shortVersionString)
return shortVersionString;
else
return [self version]; // Fall back on the normal version string.
}
- (NSImage *)icon
{
// Cache the application icon.
NSString *iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
// the icon for the bundle. The filename you specify does not need to include the .icns
// extension, although it may."
//
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
if (!iconPath) {
iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
}
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
// Use a default icon if none is defined.
if (!icon) {
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);
NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
}
return icon;
}
- (BOOL)isRunningOnReadOnlyVolume
{
struct statfs statfs_info;
statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info);
return (statfs_info.f_flags & MNT_RDONLY);
}
- (BOOL)isBackgroundApplication
{
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
}
- (NSString *)publicDSAKey
{
// Maybe the key is just a string in the Info.plist.
NSString *key = [bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
if (key) { return key; }
// More likely, we've got a reference to a Resources file by filename:
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
if (!keyFilename) { return nil; }
NSError *ignoreErr = nil;
return [NSString stringWithContentsOfFile:[bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error: &ignoreErr];
}
- (NSArray *)systemProfile
{
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
}
- (id)objectForInfoDictionaryKey:(NSString *)key
{
return [bundle objectForInfoDictionaryKey:key];
}
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
{
return [[self objectForInfoDictionaryKey:key] boolValue];
}
- (id)objectForUserDefaultsKey:(NSString *)defaultName
{
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
if (usesStandardUserDefaults) {
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
}
CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
return CFBridgingRelease(obj);
}
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName;
{
if (usesStandardUserDefaults)
{
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
}
else
{
CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
}
}
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName
{
if (usesStandardUserDefaults) {
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
}
BOOL value;
CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
if (plr == NULL) {
value = NO;
}
else
{
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
CFRelease(plr);
}
return value;
}
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
{
if (usesStandardUserDefaults)
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
}
else
{
CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)@(value), (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
}
}
- (id)objectForKey:(NSString *)key {
return [self objectForUserDefaultsKey:key] ? [self objectForUserDefaultsKey:key] : [self objectForInfoDictionaryKey:key];
}
- (BOOL)boolForKey:(NSString *)key {
return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
}
+ (NSString *)systemVersionString
{
NSString *versionPlistPath = @"/System/Library/CoreServices/SystemVersion.plist";
return [NSDictionary dictionaryWithContentsOfFile:versionPlistPath][@"ProductVersion"];
}
@end
-28
View File
@@ -1,28 +0,0 @@
//
// SUInstaller.h
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#ifndef SUINSTALLER_H
#define SUINSTALLER_H
#import <Cocoa/Cocoa.h>
#import "SUVersionComparisonProtocol.h"
@class SUHost;
@interface SUInstaller : NSObject
+ (NSString *) appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host;
+ (void) installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator;
+ (void) finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate;
+ (NSString*) updateFolder;
@end
@interface NSObject (SUInstallerDelegateInformalProtocol)
- (void)installerFinishedForHost:(SUHost *)host;
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
@end
#endif
-182
View File
@@ -1,182 +0,0 @@
//
// SUInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUInstaller.h"
#import "SUPlainInstaller.h"
#import "SUPackageInstaller.h"
#import "SUHost.h"
#import "SUConstants.h"
#import "SULog.h"
@implementation SUInstaller
static NSString* sUpdateFolder = nil;
+(NSString*) updateFolder
{
return sUpdateFolder;
}
+ (BOOL)isAliasFolderAtPath:(NSString *)path
{
FSRef fileRef;
OSStatus err = noErr;
Boolean aliasFileFlag, folderFlag;
NSURL *fileURL = [NSURL fileURLWithPath:path];
if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef))
err = coreFoundationUnknownErr;
if (noErr == err)
err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag);
if (noErr == err)
return (BOOL)(aliasFileFlag && folderFlag);
else
return NO;
}
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr
{
// Search subdirectories for the application
NSString *currentFile,
*newAppDownloadPath = nil,
*bundleFileName = [[host bundlePath] lastPathComponent],
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
BOOL isPackage = NO;
NSString *fallbackPackagePath = nil;
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath: inUpdateFolder];
[sUpdateFolder release];
sUpdateFolder = [inUpdateFolder retain];
while ((currentFile = [dirEnum nextObject]))
{
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
{
isPackage = NO;
newAppDownloadPath = currentPath;
break;
}
else if ([[currentFile pathExtension] isEqualToString:@"pkg"] ||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
{
if ([[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
{
isPackage = YES;
newAppDownloadPath = currentPath;
break;
}
else
{
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
fallbackPackagePath = currentPath;
}
}
else
{
// Try matching on bundle identifiers in case the user has changed the name of the host app
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
if(incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]])
{
isPackage = NO;
newAppDownloadPath = currentPath;
break;
}
}
// Some DMGs have symlinks into /Applications! That's no good!
if ([self isAliasFolderAtPath:currentPath])
[dirEnum skipDescendents];
}
// We don't have a valid path. Try to use the fallback package.
if (newAppDownloadPath == nil && fallbackPackagePath != nil)
{
isPackage = YES;
newAppDownloadPath = fallbackPackagePath;
}
if (isPackagePtr) *isPackagePtr = isPackage;
return newAppDownloadPath;
}
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host
{
BOOL isPackage = NO;
NSString *path = [self installSourcePathInUpdateFolder:updateFolder forHost:host isPackage:&isPackage];
return isPackage ? nil : path;
}
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
{
BOOL isPackage = NO;
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
if (newAppDownloadPath == nil)
{
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package."}] delegate:delegate];
}
else
{
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class]) performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate synchronously:synchronously versionComparator:comparator];
}
}
+ (void)mdimportInstallationPath:(NSString *)installationPath
{
// *** GETS CALLED ON NON-MAIN THREAD!
SULog( @"mdimporting" );
NSTask *mdimport = [[[NSTask alloc] init] autorelease];
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
[mdimport setArguments:@[installationPath]];
@try
{
[mdimport launch];
[mdimport waitUntilExit];
}
@catch (NSException * launchException)
{
// No big deal.
SULog(@"Sparkle Error: %@", [launchException description]);
}
}
#define SUNotifyDictHostKey @"SUNotifyDictHost"
#define SUNotifyDictErrorKey @"SUNotifyDictError"
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate
{
if (result)
{
[self mdimportInstallationPath:installationPath];
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[delegate installerFinishedForHost:host];
});
}
}
else
{
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[delegate installerForHost:host failedWithError:error];
});
}
}
}
@end
-69
View File
@@ -1,69 +0,0 @@
//
// SUPackageInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPackageInstaller.h"
#import <Cocoa/Cocoa.h>
#import "SUConstants.h"
NSString *SUPackageInstallerCommandKey = @"SUPackageInstallerCommand";
NSString *SUPackageInstallerArgumentsKey = @"SUPackageInstallerArguments";
NSString *SUPackageInstallerHostKey = @"SUPackageInstallerHost";
NSString *SUPackageInstallerDelegateKey = @"SUPackageInstallerDelegate";
NSString *SUPackageInstallerInstallationPathKey = @"SUPackageInstallerInstallationPathKey";
@implementation SUPackageInstaller
+ (void)finishInstallationWithInfo:(NSDictionary *)info
{
[self finishInstallationToPath:info[SUPackageInstallerInstallationPathKey] withResult:YES host:info[SUPackageInstallerHostKey] error:nil delegate:info[SUPackageInstallerDelegateKey]];
}
+ (void)performInstallationWithInfo:(NSDictionary *)info
{
@autoreleasepool {
NSTask *installer = [NSTask launchedTaskWithLaunchPath:info[SUPackageInstallerCommandKey] arguments:info[SUPackageInstallerArgumentsKey]];
[installer waitUntilExit];
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationWithInfo:info];
});
}
}
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
{
NSString *command;
NSArray *args;
// Run installer using the "open" command to ensure it is launched in front of current application.
// -W = wait until the app has quit.
// -n = Open another instance if already open.
// -b = app bundle identifier
command = @"/usr/bin/open";
args = @[@"-W", @"-n", @"-b", @"com.apple.installer", path];
if (![[NSFileManager defaultManager] fileExistsAtPath:command])
{
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:@{NSLocalizedDescriptionKey: @"Couldn't find Apple's installer tool!"}];
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
}
else
{
NSDictionary *info = @{SUPackageInstallerCommandKey: command, SUPackageInstallerArgumentsKey: args, SUPackageInstallerHostKey: host, SUPackageInstallerDelegateKey: delegate, SUPackageInstallerInstallationPathKey: installationPath};
if (synchronously)
[self performInstallationWithInfo:info];
else {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self performInstallationWithInfo:info];
});
}
}
}
@end
-143
View File
@@ -1,143 +0,0 @@
//
// SUPipedUnarchiver.m
// Sparkle
//
// Created by Andy Matuschak on 6/16/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPipedUnarchiver.h"
#import "SUUnarchiver_Private.h"
#import "SULog.h"
@implementation SUPipedUnarchiver
+ (SEL)selectorConformingToTypeOfPath:(NSString *)path
{
static NSDictionary *typeSelectorDictionary;
if (!typeSelectorDictionary)
typeSelectorDictionary = [@{@".zip": @"extractZIP", @".tar": @"extractTAR",
@".tar.gz": @"extractTGZ", @".tgz": @"extractTGZ",
@".tar.bz2": @"extractTBZ", @".tbz": @"extractTBZ"} retain];
NSString *lastPathComponent = [path lastPathComponent];
for (id currentType in typeSelectorDictionary)
{
if ([currentType length] > [lastPathComponent length]) continue;
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
return NSSelectorFromString(typeSelectorDictionary[currentType]);
}
return NULL;
}
- (void)start
{
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:archivePath] toTarget:self withObject:nil];
}
+ (BOOL)canUnarchivePath:(NSString *)path
{
return ([self selectorConformingToTypeOfPath:path] != nil);
}
// This method abstracts the types that use a command line tool piping data from stdin.
- (void)extractArchivePipingDataToCommand:(NSString *)command
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
@autoreleasepool {
FILE *fp = NULL, *cmdFP = NULL;
char *oldDestinationString = NULL;
SULog(@"Extracting %@ using '%@'",archivePath,command);
// Get the file size.
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil][NSFileSize];
if (fs == nil) goto reportError;
// Thank you, Allan Odgaard!
// (who wrote the following extraction alg.)
fp = fopen([archivePath fileSystemRepresentation], "r");
if (!fp) goto reportError;
oldDestinationString = getenv("DESTINATION");
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
cmdFP = popen([command fileSystemRepresentation], "w");
size_t written;
if (!cmdFP) goto reportError;
char buf[32*1024];
size_t len;
while((len = fread(buf, 1, 32*1024, fp)))
{
written = fwrite(buf, 1, len, cmdFP);
if( written < len )
{
pclose(cmdFP);
goto reportError;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfExtractedLength:len];
});
}
pclose(cmdFP);
if (ferror(fp)) {
goto reportError;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
});
goto finally;
reportError:
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfFailure];
});
finally:
if (fp)
fclose(fp);
if (oldDestinationString)
setenv("DESTINATION", oldDestinationString, 1);
else
unsetenv("DESTINATION");
}
}
- (void)extractTAR
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
return [self extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
}
- (void)extractTGZ
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
return [self extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
}
- (void)extractTBZ
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
return [self extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
}
- (void)extractZIP
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
return [self extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
}
+ (void)load
{
[self registerImplementation:self];
}
@end
-86
View File
@@ -1,86 +0,0 @@
//
// SUPlainInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPlainInstaller.h"
#import "SUPlainInstallerInternals.h"
#import "SUConstants.h"
#import "SUHost.h"
static NSString * const SUInstallerPathKey = @"SUInstallerPath";
static NSString * const SUInstallerTargetPathKey = @"SUInstallerTargetPath";
static NSString * const SUInstallerTempNameKey = @"SUInstallerTempName";
static NSString * const SUInstallerHostKey = @"SUInstallerHost";
static NSString * const SUInstallerDelegateKey = @"SUInstallerDelegate";
static NSString * const SUInstallerResultKey = @"SUInstallerResult";
static NSString * const SUInstallerErrorKey = @"SUInstallerError";
static NSString * const SUInstallerInstallationPathKey = @"SUInstallerInstallationPath";
@implementation SUPlainInstaller
+ (void)finishInstallationWithInfo:(NSDictionary *)info
{
// *** GETS CALLED ON NON-MAIN THREAD!
[self finishInstallationToPath:info[SUInstallerInstallationPathKey] withResult:[info[SUInstallerResultKey] boolValue] host:info[SUInstallerHostKey] error:info[SUInstallerErrorKey] delegate:info[SUInstallerDelegateKey]];
}
+ (void)performInstallationWithInfo:(NSDictionary *)info
{
// *** GETS CALLED ON NON-MAIN THREAD!
@autoreleasepool {
NSError *error = nil;
NSString * oldPath = [info[SUInstallerHostKey] bundlePath];
NSString * installationPath = info[SUInstallerInstallationPathKey];
BOOL result = [self copyPathWithAuthentication:info[SUInstallerPathKey] overPath: installationPath temporaryName:info[SUInstallerTempNameKey] error:&error];
if( result )
{
BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath: oldPath];
BOOL differentFromNew = ![oldPath isEqualToString: installationPath];
if( haveOld && differentFromNew )
[self _movePathToTrash: oldPath]; // On success, trash old copy if there's still one due to renaming.
}
NSMutableDictionary *mutableInfo = [[info mutableCopy] autorelease];
mutableInfo[SUInstallerResultKey] = @(result);
mutableInfo[SUInstallerInstallationPathKey] = installationPath;
if (!result && error)
mutableInfo[SUInstallerErrorKey] = error;
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationWithInfo:mutableInfo];
});
}
}
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
{
// Prevent malicious downgrades:
#if !PERMIT_AUTOMATED_DOWNGRADES
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending)
{
NSString * errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
return;
}
#endif
NSString *targetPath = [host installationPath];
NSString *tempName = [self temporaryNameForPath:targetPath];
NSDictionary *info = @{SUInstallerPathKey: path, SUInstallerTargetPathKey: targetPath, SUInstallerTempNameKey: tempName, SUInstallerHostKey: host, SUInstallerDelegateKey: delegate, SUInstallerInstallationPathKey: installationPath};
if (synchronously)
[self performInstallationWithInfo:info];
else {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self performInstallationWithInfo:info];
});
}
}
@end
-591
View File
@@ -1,591 +0,0 @@
//
// SUPlainInstallerInternals.m
// Sparkle
//
// Created by Andy Matuschak on 3/9/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUPlainInstallerInternals.h"
#import "SUConstants.h"
#import "SULog.h"
#include <CoreServices/CoreServices.h>
#include <Security/Security.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/param.h>
static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
{
if ([NSThread isMainThread]) {
theBlock();
} else {
dispatch_sync(dispatch_get_main_queue(), theBlock);
}
}
@interface SUPlainInstaller (MMExtendedAttributes)
// Removes the directory tree rooted at |root| from the file quarantine.
// The quarantine was introduced on Mac OS X 10.5 and is described at:
//
// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html
//#apple_ref/doc/uid/TP40001369-DontLinkElementID_2
//
// If |root| is not a directory, then it alone is removed from the quarantine.
// Symbolic links, including |root| if it is a symbolic link, will not be
// traversed.
//
// Ordinarily, the quarantine is managed by calling LSSetItemAttribute
// to set the kLSItemQuarantineProperties attribute to a dictionary specifying
// the quarantine properties to be applied. However, it does not appear to be
// possible to remove an item from the quarantine directly through any public
// Launch Services calls. Instead, this method takes advantage of the fact
// that the quarantine is implemented in part by setting an extended attribute,
// "com.apple.quarantine", on affected files. Removing this attribute is
// sufficient to remove files from the quarantine.
+ (void)releaseFromQuarantine:(NSString*)root;
@end
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess)
{
int status;
pid_t pid = wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
returnValue = NO;
}
else
returnValue = NO;
signal(SIGCHLD, oldSigChildHandler);
return returnValue;
}
#pragma clang diagnostic pop
@implementation SUPlainInstaller (Internals)
+ (NSString *)temporaryNameForPath:(NSString *)path
{
// Let's try to read the version number so the filename will be more meaningful.
NSString *postFix;
NSString *version;
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
}
else
postFix = @"old";
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
// Now let's make sure we get a unique path.
unsigned int cnt=2;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
return [tempDir lastPathComponent];
}
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash: (BOOL*)outDidFindTrash
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
NSString *tempDir = nil;
UInt8 trashPath[MAXPATHLEN +1] = { 0 };
FSRef trashRef, pathRef;
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
FSCatalogInfo catInfo;
memset( &catInfo, 0, sizeof(catInfo) );
OSStatus err = FSPathMakeRef( (UInt8*) [path fileSystemRepresentation], &pathRef, NULL );
if( err == noErr )
{
err = FSGetCatalogInfo( &pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
vSrcRefNum = catInfo.volume;
}
if( err == noErr )
err = FSFindFolder( vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef );
if( err == noErr )
err = FSGetCatalogInfo( &trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
if( err == noErr && vSrcRefNum != catInfo.volume )
err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future.
if( err == noErr )
err = FSRefMakePath( &trashRef, trashPath, MAXPATHLEN );
if( err == noErr )
tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: (char*) trashPath length: strlen((char*) trashPath)];
if( outDidFindTrash )
*outDidFindTrash = (tempDir != nil);
if( !tempDir )
tempDir = [path stringByDeletingLastPathComponent];
// Let's try to read the version number so the filename will be more meaningful.
#if TRY_TO_APPEND_VERSION_NUMBER
NSString *postFix = nil;
NSString *version = nil;
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
}
else {
postFix = @"old";
}
NSString *prefix = [NSString stringWithFormat: @"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
#else
NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension];
#endif
NSString *tempName = [prefix stringByAppendingPathExtension: [path pathExtension]];
tempDir = [tempDir stringByAppendingPathComponent: tempName];
// Now let's make sure we get a unique path.
int cnt=2;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) {
tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]];
}
return tempDir;
}
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError **)error
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char* srcPath = [src fileSystemRepresentation];
const char* tmpPath = [tmp fileSystemRepresentation];
const char* dstPath = [dst fileSystemRepresentation];
struct stat dstSB;
if( stat(dstPath, &dstSB) != 0 ) // Doesn't exist yet, try containing folder.
{
const char* dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
if( stat(dstDirPath, &dstSB) != 0 )
{
NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst];
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
return NO;
}
}
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while (authStat == errAuthorizationDenied) {
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (authStat == errAuthorizationSuccess) {
res = YES;
char uidgid[42];
snprintf(uidgid, sizeof(uidgid), "%u:%u",
dstSB.st_uid, dstSB.st_gid);
// If the currently-running application is trusted, the new
// version should be trusted as well. Remove it from the
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done after the application is moved to its
// new home with "mv" in case it's moved across filesystems: if
// that happens, "mv" actually performs a copy and may result
// in the application being quarantined. It also needs to be
// done before "chown" changes ownership, because the ownership
// change will almost certainly make it impossible to change
// attributes to release the files from the quarantine.
if (res)
{
SULog(@"releaseFromQuarantine");
PerformOnMainThreadSync(^{
[self releaseFromQuarantine:src];
});
}
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
if( !res )
SULog( @"chown -R %s %s failed.", uidgid, srcPath );
}
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char* rmParams[] = { "-rf", tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog( @"rm failed" );
}
if( res && haveDst ) // Move old exe to tmp path.
{
const char* mvParams[] = { "-f", dstPath, tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
if( !res )
SULog( @"mv 1 failed" );
}
if( res ) // Move new exe to old exe's path.
{
const char* mvParams2[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
if( !res )
SULog( @"mv 2 failed" );
}
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
// }
AuthorizationFree(auth, 0);
// If the currently-running application is trusted, the new
// version should be trusted as well. Remove it from the
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done after the application is moved to its
// new home with "mv" in case it's moved across filesystems: if
// that happens, "mv" actually performs a copy and may result
// in the application being quarantined.
if (res)
{
SULog(@"releaseFromQuarantine after installing");
PerformOnMainThreadSync(^{
[self releaseFromQuarantine:dst];
});
}
if (!res)
{
// Something went wrong somewhere along the way, but we're not sure exactly where.
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
if (error != nil)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
}
}
else
{
if (error != nil)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
}
return res;
}
+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError **)error
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char* srcPath = [src fileSystemRepresentation];
const char* dstPath = [dst fileSystemRepresentation];
const char* dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
struct stat dstSB;
stat(dstContainerPath, &dstSB);
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while( authStat == errAuthorizationDenied )
{
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (authStat == errAuthorizationSuccess)
{
res = YES;
char uidgid[42];
snprintf(uidgid, sizeof(uidgid), "%d:%d",
dstSB.st_uid, dstSB.st_gid);
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
if( !res )
SULog(@"Can't set permissions");
}
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char* rmParams[] = { "-rf", dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog(@"Can't remove destination file");
}
if( res ) // Move!.
{
const char* mvParams[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
if( !res )
SULog(@"Can't move source file");
}
AuthorizationFree(auth, 0);
if (!res)
{
// Something went wrong somewhere along the way, but we're not sure exactly where.
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst];
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
}
}
else
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
}
return res;
}
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char* srcPath = [src fileSystemRepresentation];
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while( authStat == errAuthorizationDenied )
{
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (authStat == errAuthorizationSuccess)
{
res = YES;
if( res ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char* rmParams[] = { "-rf", srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog(@"Can't remove destination file");
}
AuthorizationFree(auth, 0);
if (!res)
{
// Something went wrong somewhere along the way, but we're not sure exactly where.
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src];
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
}
}
else
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
}
return res;
}
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error
{
BOOL success = YES;
if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] )
{
success = [self _removeFileAtPathWithForcedAuthentication: path error: error];
}
return success;
}
+ (void)_movePathToTrash:(NSString *)path
{
//SULog(@"Moving %@ to the trash.", path);
NSInteger tag = 0;
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag])
{
BOOL didFindTrash = NO;
NSString* trashPath = [self _temporaryCopyNameForPath: path didFindTrash: &didFindTrash];
if( didFindTrash )
{
NSError *err = nil;
if( ![self _movePathWithForcedAuthentication: path toPath: trashPath error: &err] )
SULog(@"Sparkle error: couldn't move %@ to the trash (%@). %@", path, trashPath, err);
}
else
SULog(@"Sparkle error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path);
}
else
;//SULog(@"Moved %@ to the trash.", path);
}
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error
{
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
OSStatus err;
BOOL hadFileAtDest = NO, didFindTrash = NO;
NSString *tmpPath = [self _temporaryCopyNameForPath: dst didFindTrash: &didFindTrash];
// Make FSRef for destination:
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
if( hadFileAtDest )
{
if (0 != access([dst fileSystemRepresentation], W_OK) || 0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
{
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
}
}
else
{
if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)
|| 0 != access([[[dst stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
{
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
}
}
if( hadFileAtDest )
{
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
if (err != noErr)
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
}
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
if (err == noErr && hadFileAtDest)
{
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
if (!success && hadFileAtDest)
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath]}];
return NO;
}
}
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
if (err == noErr)
{
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
if (!success)
{
// We better move the old version back to its old location
if (hadFileAtDest) {
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
}
if (!success && error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath]}];
return NO;
}
}
// If the currently-running application is trusted, the new
// version should be trusted as well. Remove it from the
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done after the application is moved to its
// new home in case it's moved across filesystems: if that
// happens, the move is actually a copy, and it may result
// in the application being quarantined.
PerformOnMainThreadSync(^{
[self releaseFromQuarantine:dst];
});
return YES;
}
@end
#include <dlfcn.h>
#include <errno.h>
#include <sys/xattr.h>
@implementation SUPlainInstaller (MMExtendedAttributes)
+ (int)removeXAttr:(const char*)name
fromFile:(NSString*)file
options:(int)options
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char* path = NULL;
@try {
path = [file fileSystemRepresentation];
}
@catch (id exception) {
// -[NSString fileSystemRepresentation] throws an exception if it's
// unable to convert the string to something suitable. Map that to
// EDOM, "argument out of domain", which sort of conveys that there
// was a conversion failure.
errno = EDOM;
return -1;
}
return removexattr(path, name, options);
}
+ (void)releaseFromQuarantine:(NSString*)root
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char* quarantineAttribute = "com.apple.quarantine";
const int removeXAttrOptions = XATTR_NOFOLLOW;
[self removeXAttr:quarantineAttribute
fromFile:root
options:removeXAttrOptions];
// Only recurse if it's actually a directory. Don't recurse into a
// root-level symbolic link.
NSDictionary* rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:root error:nil];
NSString* rootType = rootAttributes[NSFileType];
if (rootType == NSFileTypeDirectory) {
// The NSDirectoryEnumerator will avoid recursing into any contained
// symbolic links, so no further type checks are needed.
NSDirectoryEnumerator* directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:root];
NSString* file = nil;
while ((file = [directoryEnumerator nextObject])) {
[self removeXAttr:quarantineAttribute
fromFile:[root stringByAppendingPathComponent:file]
options:removeXAttrOptions];
}
}
}
@end
-35
View File
@@ -1,35 +0,0 @@
//
// SUProbingUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/7/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUProbingUpdateDriver.h"
#import "SUUpdater.h"
@implementation SUProbingUpdateDriver
// Stop as soon as we have an answer! Since the superclass implementations are not called, we are responsible for notifying the delegate.
- (void)didFindValidUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
[self abortUpdate];
}
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[updater delegate] updaterDidNotFindUpdate:updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[self abortUpdate];
}
@end
-42
View File
@@ -1,42 +0,0 @@
//
// SUScheduledUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/6/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUScheduledUpdateDriver.h"
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
@implementation SUScheduledUpdateDriver
- (void)didFindValidUpdate
{
showErrors = YES; // We only start showing errors after we present the UI for the first time.
[super didFindValidUpdate];
}
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[updater delegate] updaterDidNotFindUpdate:updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
}
- (void)abortUpdateWithError:(NSError *)error
{
if (showErrors)
[super abortUpdateWithError:error];
else
[self abortUpdate];
}
@end
-36
View File
@@ -1,36 +0,0 @@
//
// SUStandardVersionComparator.h
// Sparkle
//
// Created by Andy Matuschak on 12/21/07.
// Copyright 2007 Andy Matuschak. All rights reserved.
//
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
#define SUSTANDARDVERSIONCOMPARATOR_H
#import "SUVersionComparisonProtocol.h"
/*!
@class
@abstract Sparkle's default version comparator.
@discussion This comparator is adapted from MacPAD, by Kevin Ballard. It's "dumb" in that it does essentially string comparison, in components split by character type.
*/
@interface SUStandardVersionComparator : NSObject <SUVersionComparison>
/*!
@method
@abstract Returns a singleton instance of the comparator.
*/
+ (SUStandardVersionComparator *)defaultComparator;
/*!
@method
@abstract Compares version strings through textual analysis.
@discussion See the implementation for more details.
*/
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
@end
#endif
-589
View File
@@ -1,589 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="6"/>
</object>
<reference key="IBDocument.PluginDependencies" ref="0"/>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="780577916">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="245526436">
<string key="NSClassName">SUStatusController</string>
</object>
<object class="NSCustomObject" id="879485556">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="472338989">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="661323156">
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{200, 222}, {400, 107}}</string>
<int key="NSWTFlags">1886912512</int>
<string key="NSWindowTitle">Set in Code</string>
<object class="NSMutableString" key="NSWindowClass">
<characters key="NS.bytes">NSWindow</characters>
</object>
<object class="NSMutableString" key="NSViewClass">
<characters key="NS.bytes">View</characters>
</object>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{213, 107}</string>
<object class="NSView" key="NSWindowView" id="512815736">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSImageView" id="56655866">
<reference key="NSNextResponder" ref="512815736"/>
<int key="NSvFlags">268</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple PNG pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
</object>
</object>
<string key="NSFrame">{{24, 28}, {64, 64}}</string>
<reference key="NSSuperview" ref="512815736"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="381943368">
<int key="NSCellFlags">130560</int>
<int key="NSCellFlags2">33554432</int>
<object class="NSCustomResource" key="NSContents">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSApplicationIcon</string>
</object>
<int key="NSAlign">0</int>
<int key="NSScale">1</int>
<int key="NSStyle">0</int>
<bool key="NSAnimates">NO</bool>
</object>
<bool key="NSEditable">YES</bool>
</object>
<object class="NSTextField" id="692218720">
<reference key="NSNextResponder" ref="512815736"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{106, 75}, {277, 17}}</string>
<reference key="NSSuperview" ref="512815736"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="597081861">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">272629760</int>
<string key="NSContents">Status Text (set by loc. string in code)</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande-Bold</string>
<double key="NSSize">13</double>
<int key="NSfFlags">2072</int>
</object>
<reference key="NSControlView" ref="692218720"/>
<object class="NSColor" key="NSBackgroundColor" id="747797151">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="640273742">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
</object>
<object class="NSProgressIndicator" id="454270533">
<reference key="NSNextResponder" ref="512815736"/>
<int key="NSvFlags">1280</int>
<object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrame">{{107, 47}, {275, 20}}</string>
<reference key="NSSuperview" ref="512815736"/>
<int key="NSpiFlags">16394</int>
<double key="NSMaxValue">100</double>
</object>
<object class="NSButton" id="566879706">
<reference key="NSNextResponder" ref="512815736"/>
<int key="NSvFlags">259</int>
<string key="NSFrame">{{272, 12}, {114, 32}}</string>
<reference key="NSSuperview" ref="512815736"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="130218013">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Button</string>
<object class="NSFont" key="NSSupport" id="531315841">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="566879706"/>
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">1</int>
<reference key="NSAlternateImage" ref="531315841"/>
<string key="NSAlternateContents"/>
<object class="NSMutableString" key="NSKeyEquivalent">
<characters key="NS.bytes"/>
</object>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSTextField" id="65200871">
<reference key="NSNextResponder" ref="512815736"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{106, 22}, {167, 17}}</string>
<reference key="NSSuperview" ref="512815736"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="180962568">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">272629760</int>
<string key="NSContents">Small System Font Text</string>
<reference key="NSSupport" ref="531315841"/>
<reference key="NSControlView" ref="65200871"/>
<reference key="NSBackgroundColor" ref="747797151"/>
<reference key="NSTextColor" ref="640273742"/>
</object>
</object>
</object>
<string key="NSFrameSize">{400, 107}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{213, 129}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: applicationIcon</string>
<reference key="source" ref="56655866"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="56655866"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">value: applicationIcon</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">applicationIcon</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">maxValue: maxProgressValue</string>
<reference key="source" ref="454270533"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector" id="110266706">
<reference key="NSSource" ref="454270533"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">maxValue: maxProgressValue</string>
<string key="NSBinding">maxValue</string>
<string key="NSKeyPath">maxProgressValue</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">13</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: statusText</string>
<reference key="source" ref="65200871"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="65200871"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">value: statusText</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">statusText</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">17</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">title: buttonTitle</string>
<reference key="source" ref="566879706"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="566879706"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">title: buttonTitle</string>
<string key="NSBinding">title</string>
<string key="NSKeyPath">buttonTitle</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">21</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">title: windowTitle</string>
<reference key="source" ref="661323156"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="661323156"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">title: windowTitle</string>
<string key="NSBinding">title</string>
<string key="NSKeyPath">windowTitle</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">24</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="245526436"/>
<reference key="destination" ref="661323156"/>
</object>
<int key="connectionID">25</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: title</string>
<reference key="source" ref="692218720"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="692218720"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">value: title</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">title</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: progressValue</string>
<reference key="source" ref="454270533"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="454270533"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">value: progressValue</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">progressValue</string>
<reference key="NSPreviousConnector" ref="110266706"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">27</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">hidden: statusText</string>
<reference key="source" ref="65200871"/>
<reference key="destination" ref="245526436"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="65200871"/>
<reference key="NSDestination" ref="245526436"/>
<string key="NSLabel">hidden: statusText</string>
<string key="NSBinding">hidden</string>
<string key="NSKeyPath">statusText</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSIsNil</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">33</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">actionButton</string>
<reference key="source" ref="245526436"/>
<reference key="destination" ref="566879706"/>
</object>
<int key="connectionID">34</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">progressBar</string>
<reference key="source" ref="245526436"/>
<reference key="destination" ref="454270533"/>
</object>
<int key="connectionID">49</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="780577916"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="245526436"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="879485556"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="472338989"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="661323156"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="512815736"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">Window</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="512815736"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="56655866"/>
<reference ref="692218720"/>
<reference ref="454270533"/>
<reference ref="566879706"/>
<reference ref="65200871"/>
</object>
<reference key="parent" ref="661323156"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="56655866"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="381943368"/>
</object>
<reference key="parent" ref="512815736"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="692218720"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="597081861"/>
</object>
<reference key="parent" ref="512815736"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="454270533"/>
<reference key="parent" ref="512815736"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="566879706"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="130218013"/>
</object>
<reference key="parent" ref="512815736"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="65200871"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="180962568"/>
</object>
<reference key="parent" ref="512815736"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">53</int>
<reference key="object" ref="381943368"/>
<reference key="parent" ref="56655866"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">54</int>
<reference key="object" ref="597081861"/>
<reference key="parent" ref="692218720"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">55</int>
<reference key="object" ref="130218013"/>
<reference key="parent" ref="566879706"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">56</int>
<reference key="object" ref="180962568"/>
<reference key="parent" ref="65200871"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-3.ImportedFromIB2</string>
<string>11.ImportedFromIB2</string>
<string>12.ImportedFromIB2</string>
<string>16.ImportedFromIB2</string>
<string>5.IBEditorWindowLastContentRect</string>
<string>5.IBWindowTemplateEditedContentRect</string>
<string>5.ImportedFromIB2</string>
<string>5.windowTemplate.hasMinSize</string>
<string>5.windowTemplate.minSize</string>
<string>6.ImportedFromIB2</string>
<string>7.ImportedFromIB2</string>
<string>8.ImportedFromIB2</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
<string>{{294, 716}, {400, 107}}</string>
<string>{{294, 716}, {400, 107}}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<string>{213, 107}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">56</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">FirstResponder</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSApplication</string>
<string key="superclassName">NSResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">SUStatusController</string>
<string key="superclassName">SUWindowController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>actionButton</string>
<string>progressBar</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSButton</string>
<string>NSProgressIndicator</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">SUWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">Sparkle.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">NSApplicationIcon</string>
<string key="NS.object.0">{128, 128}</string>
</object>
</data>
</archive>
-129
View File
@@ -1,129 +0,0 @@
//
// SUStatusController.m
// Sparkle
//
// Created by Andy Matuschak on 3/14/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUStatusController.h"
#import "SUHost.h"
@interface SUStatusController ()
@property (copy) NSString *title, *buttonTitle;
@property (retain) SUHost *host;
@end
@implementation SUStatusController
@synthesize progressValue;
@synthesize maxProgressValue;
@synthesize statusText;
@synthesize title;
@synthesize buttonTitle;
@synthesize host;
@synthesize actionButton;
@synthesize progressBar;
- (instancetype)initWithHost:(SUHost *)aHost
{
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
if (self)
{
self.host = aHost;
[self setShouldCascadeWindows:NO];
}
return self;
}
- (void)dealloc
{
self.host = nil;
self.title = nil;
self.statusText = nil;
self.buttonTitle = nil;
[super dealloc];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
- (void)awakeFromNib
{
if ([host isBackgroundApplication]) {
[[self window] setLevel:NSFloatingWindowLevel];
}
[[self window] center];
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
[progressBar setUsesThreadedAnimation:YES];
}
- (NSString *)windowTitle
{
return [NSString stringWithFormat:SULocalizedString(@"Updating %@", nil), [host name]];
}
- (NSImage *)applicationIcon
{
return [host icon];
}
- (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText
{
self.title = aTitle;
self.maxProgressValue = aMaxProgressValue;
self.statusText = aStatusText;
}
- (void)setButtonTitle:(NSString *)aButtonTitle target:(id)target action:(SEL)action isDefault:(BOOL)isDefault
{
self.buttonTitle = aButtonTitle;
[self window];
[actionButton sizeToFit];
// Except we're going to add 15 px for padding.
[actionButton setFrameSize:NSMakeSize([actionButton frame].size.width + 15, [actionButton frame].size.height)];
// Now we have to move it over so that it's always 15px from the side of the window.
[actionButton setFrameOrigin:NSMakePoint([[self window] frame].size.width - 15 - [actionButton frame].size.width, [actionButton frame].origin.y)];
// Redisplay superview to clean up artifacts
[[actionButton superview] display];
[actionButton setTarget:target];
[actionButton setAction:action];
[actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
[self setButtonEnabled: (target != nil)];
}
- (BOOL)progressBarShouldAnimate
{
return YES;
}
- (void)setButtonEnabled:(BOOL)enabled
{
[actionButton setEnabled:enabled];
}
- (BOOL)isButtonEnabled
{
return [actionButton isEnabled];
}
- (void)setMaxProgressValue:(double)value
{
if (value < 0.0) value = 0.0;
maxProgressValue = value;
[self setProgressValue:0.0];
[progressBar setIndeterminate:(value == 0.0)];
[progressBar startAnimation:self];
[progressBar setUsesThreadedAnimation: YES];
}
@end
-156
View File
@@ -1,156 +0,0 @@
//
// SUSystemProfiler.m
// Sparkle
//
// Created by Andy Matuschak on 12/22/07.
// Copyright 2007 Andy Matuschak. All rights reserved.
// Adapted from Sparkle+, by Tom Harrington.
//
#import "SUSystemProfiler.h"
#import "SUHost.h"
#include <sys/sysctl.h>
@implementation SUSystemProfiler
+ (SUSystemProfiler *)sharedSystemProfiler
{
static SUSystemProfiler *sharedSystemProfiler = nil;
if (!sharedSystemProfiler) {
sharedSystemProfiler = [[self alloc] init];
}
return sharedSystemProfiler;
}
- (NSDictionary *)modelTranslationTable
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
return [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease];
}
- (NSMutableArray *)systemProfileArrayForHost:(SUHost *)host
{
NSDictionary *modelTranslation = [self modelTranslationTable];
// Gather profile information and append it to the URL.
NSMutableArray *profileArray = [NSMutableArray array];
NSArray *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"];
int error = 0;
int value = 0;
size_t length = sizeof(value);
// OS version
NSString *currentSystemVersion = [SUHost systemVersionString];
if (currentSystemVersion != nil) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion] forKeys:profileDictKeys]];
}
// CPU type (decoder info for values found here is in mach/machine.h)
error = sysctlbyname("hw.cputype", &value, &length, NULL, 0);
int cpuType = -1;
if (error == 0) {
cpuType = value;
NSString *visibleCPUType;
switch(value) {
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
default: visibleCPUType = @"Unknown"; break;
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cputype",@"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.cpu64bit_capable", &value, &length, NULL, 0);
if (error != 0) {
error = sysctlbyname("hw.optional.x86_64", &value, &length, NULL, 0); //x86 specific
}
if (error != 0) {
error = sysctlbyname("hw.optional.64bitops", &value, &length, NULL, 0); //PPC specific
}
BOOL is64bit = NO;
if (error == 0) {
is64bit = value == 1;
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpu64bit", @"CPU is 64-Bit?", @(is64bit), is64bit ? @"Yes" : @"No"] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.cpusubtype", &value, &length, NULL, 0);
if (error == 0) {
NSString *visibleCPUSubType;
if (cpuType == 7) {
// Intel
// TODO: other Intel processors, like Core i7, i5, i3, Xeon?
visibleCPUSubType = is64bit ? @"Intel Core 2" : @"Intel Core"; // If anyone knows how to tell a Core Duo from a Core Solo, please email tph@atomicbird.com
} else if (cpuType == 18) {
// PowerPC
switch(value) {
case 9: visibleCPUSubType=@"G3"; break;
case 10: case 11: visibleCPUSubType=@"G4"; break;
case 100: visibleCPUSubType=@"G5"; break;
default: visibleCPUSubType=@"Other"; break;
}
} else {
visibleCPUSubType = @"Other";
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpusubtype",@"CPU Subtype", @(value), visibleCPUSubType] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.model", NULL, &length, NULL, 0);
if (error == 0) {
char *cpuModel = (char *)malloc(sizeof(char) * length);
if (cpuModel != NULL) {
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
if (error == 0) {
NSString *rawModelName = @(cpuModel);
NSString *visibleModelName = modelTranslation[rawModelName];
if (visibleModelName == nil) {
visibleModelName = rawModelName;
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"model",@"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]];
}
free(cpuModel);
}
}
// Number of CPUs
error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0);
if (error == 0) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ncpu",@"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]];
}
// User preferred language
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
if ([languages count] > 0) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"lang",@"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
}
// Application sending the request
NSString *appName = [host name];
if (appName) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appName",@"Application Name", appName, appName] forKeys:profileDictKeys]];
}
NSString *appVersion = [host version];
if (appVersion) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appVersion",@"Application Version", appVersion, appVersion] forKeys:profileDictKeys]];
}
// Number of displays?
// CPU speed
unsigned long hz;
size_t hz_size = sizeof(unsigned long);
if (sysctlbyname("hw.cpufrequency", &hz, &hz_size, NULL, 0) == 0) {
unsigned long mhz = hz / 1000000;
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpuFreqMHz",@"CPU Speed (GHz)", @(mhz), @(mhz / 1000.)] forKeys:profileDictKeys]];
}
// amount of RAM
unsigned long bytes;
size_t bytes_size = sizeof(unsigned long);
if (sysctlbyname("hw.memsize", &bytes, &bytes_size, NULL, 0) == 0) {
double megabytes = bytes / (1024.*1024.);
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ramMB",@"Memory (MB)", @(megabytes), @(megabytes)] forKeys:profileDictKeys]];
}
return profileArray;
}
@end
-225
View File
@@ -1,225 +0,0 @@
//
// SUUIBasedUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/5/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUIBasedUpdateDriver.h"
#import "SUUpdateAlert.h"
#import "SUUpdater_Private.h"
#import "SUHost.h"
#import "SUStatusController.h"
#import "SUConstants.h"
@implementation SUUIBasedUpdateDriver
- (void)didFindValidUpdate
{
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:host];
[updateAlert setDelegate:self];
id<SUVersionDisplay> versDisp = nil;
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[updater delegate] versionDisplayerForUpdater: updater];
}
[updateAlert setVersionDisplayer: versDisp];
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
}
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([host isBackgroundApplication])
{
[[updateAlert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
if ([NSApp isActive])
[[updateAlert window] makeKeyAndOrderFront:self];
else
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
[[updater delegate] updaterDidNotFindUpdate:updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [host name], [host displayVersion]];
[self showModalAlert:alert];
[self abortUpdate];
}
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
[[updateAlert window] makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
}
- (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice
{
[updateAlert release]; updateAlert = nil;
[host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice)
{
case SUInstallUpdateChoice:
statusController = [[SUStatusController alloc] initWithHost:host];
[statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
[statusController showWindow:self];
[self downloadUpdate];
break;
case SUOpenInfoURLChoice:
[[NSWorkspace sharedWorkspace] openURL: [updateItem infoURL]];
[self abortUpdate];
break;
case SUSkipThisVersionChoice:
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
case SURemindMeLaterChoice:
[self abortUpdate];
break;
}
}
- (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response
{
[statusController setMaxProgressValue:[response expectedContentLength]];
}
- (NSString *)humanReadableSizeFromDouble:(double)value
{
if (value < 1000) {
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
}
if (value < 1000 * 1000) {
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
}
if (value < 1000 * 1000 * 1000) {
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")];
}
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
}
- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length
{
[statusController setProgressValue:[statusController progressValue] + (double)length];
if ([statusController maxProgressValue] > 0.0)
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[statusController progressValue]], [self humanReadableSizeFromDouble:[statusController maxProgressValue]]]];
else
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[statusController progressValue]]]];
}
- (IBAction)cancelDownload: (id)sender
{
if (download)
[download cancel];
[self abortUpdate];
}
- (void)extractUpdate
{
// Now we have to extract the downloaded archive.
[statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[statusController setButtonEnabled:NO];
[super extractUpdate];
}
- (void)unarchiver:(SUUnarchiver *)ua extractedLength:(unsigned long)length
{
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
if ([statusController maxProgressValue] == 0.0)
{
NSDictionary * attributes;
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil];
[statusController setMaxProgressValue:[attributes[NSFileSize] doubleValue]];
}
[statusController setProgressValue:[statusController progressValue] + (double)length];
}
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
[statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
[statusController setProgressValue:1.0]; // Fill the bar.
[statusController setButtonEnabled:YES];
[statusController setButtonTitle:SULocalizedString(@"Install and Relaunch", nil) target:self action:@selector(installAndRestart:) isDefault:YES];
[[statusController window] makeKeyAndOrderFront: self];
[NSApp requestUserAttention:NSInformationalRequest];
}
- (void)installAndRestart: (id)sender
{
[self installWithToolAndRelaunch:YES];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch
{
[statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[statusController setButtonEnabled:NO];
[super installWithToolAndRelaunch:relaunch];
// 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
if (statusController)
{
[statusController close];
[statusController autorelease];
statusController = nil;
}
}
- (void)abortUpdateWithError:(NSError *)error
{
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat: @"%@", [error localizedDescription]];
[self showModalAlert:alert];
[super abortUpdateWithError:error];
}
- (void)abortUpdate
{
if (statusController)
{
[statusController close];
[statusController autorelease];
statusController = nil;
}
[super abortUpdate];
}
- (void)showModalAlert:(NSAlert *)alert
{
if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
[[updater delegate] updaterWillShowModalAlert: updater];
}
// When showing a modal alert we need to ensure that background applications
// are focused to inform the user since there is no dock icon to notify them.
if ([host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
[alert setIcon:[host icon]];
[alert runModal];
if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
[[updater delegate] updaterDidShowModalAlert: updater];
}
@end
-39
View File
@@ -1,39 +0,0 @@
//
// SUUnarchiver.m
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUUnarchiver.h"
#import "SUUnarchiver_Private.h"
@implementation SUUnarchiver
@synthesize delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
{
for (id current in [self unarchiverImplementations])
{
if ([current canUnarchivePath:path]) {
return [[[current alloc] initWithPath:path host:host] autorelease];
}
}
return nil;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], archivePath]; }
- (void)start
{
// No-op
}
@end
-71
View File
@@ -1,71 +0,0 @@
//
// SUUnarchiver_Private.m
// Sparkle
//
// Created by Andy Matuschak on 6/17/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUnarchiver_Private.h"
@implementation SUUnarchiver (Private)
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
{
if ((self = [super init]))
{
archivePath = [path copy];
updateHost = [host retain];
}
return self;
}
- (void)dealloc
{
[archivePath release];
[updateHost release];
[super dealloc];
}
+ (BOOL)canUnarchivePath:(NSString *)path
{
return NO;
}
- (void)notifyDelegateOfExtractedLength:(size_t)length
{
if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
[delegate unarchiver:self extractedLength:length];
}
}
- (void)notifyDelegateOfSuccess
{
if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) {
[delegate unarchiverDidFinish:self];
}
}
- (void)notifyDelegateOfFailure
{
if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) {
[delegate unarchiverDidFail:self];
}
}
static NSMutableArray *gUnarchiverImplementations;
+ (void)registerImplementation:(Class)implementation
{
if (!gUnarchiverImplementations) {
gUnarchiverImplementations = [[NSMutableArray alloc] init];
}
[gUnarchiverImplementations addObject:implementation];
}
+ (NSArray *)unarchiverImplementations
{
return [NSArray arrayWithArray:gUnarchiverImplementations];
}
@end
-55
View File
@@ -1,55 +0,0 @@
//
// SUUpdateAlert.h
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUUPDATEALERT_H
#define SUUPDATEALERT_H
#import "SUWindowController.h"
#import "SUVersionDisplayProtocol.h"
@protocol SUUpdateAlertDelegate;
typedef enum
{
SUInstallUpdateChoice,
SURemindMeLaterChoice,
SUSkipThisVersionChoice,
SUOpenInfoURLChoice
} SUUpdateAlertChoice;
@class WebView, SUAppcastItem, SUHost;
@interface SUUpdateAlert : SUWindowController {
SUAppcastItem *updateItem;
SUHost *host;
IBOutlet WebView *releaseNotesView;
IBOutlet NSTextField *description;
IBOutlet NSButton *installButton; // UK 2007-08-31.
IBOutlet NSButton *skipButton;
IBOutlet NSButton *laterButton;
NSProgressIndicator *releaseNotesSpinner;
BOOL webViewFinishedLoading;
}
@property (assign) id<SUUpdateAlertDelegate> delegate;
@property (assign) id<SUVersionDisplay> versionDisplayer;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
- (IBAction)installUpdate:sender;
- (IBAction)skipThisVersion:sender;
- (IBAction)remindMeLater:sender;
@end
@protocol SUUpdateAlertDelegate <NSObject>
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
@optional
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate: (BOOL*)shouldAllowAutoUpdate;
@end
#endif
-356
View File
@@ -1,356 +0,0 @@
//
// SUUpdateAlert.m
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
// -----------------------------------------------------------------------------
// Headers:
// -----------------------------------------------------------------------------
#import "SUUpdateAlert.h"
#import "SUHost.h"
#import <WebKit/WebKit.h>
#import "SUConstants.h"
@interface WebView ()
-(void) setDrawsBackground: (BOOL)state;
@end
@implementation SUUpdateAlert
@synthesize delegate;
@synthesize versionDisplayer;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost
{
self = [super initWithHost:host windowNibName:@"SUUpdateAlert"];
if (self)
{
host = [aHost retain];
updateItem = [item retain];
[self setShouldCascadeWindows:NO];
// Alex: This dummy line makes sure that the binary is linked against WebKit.
// The SUUpdateAlert.xib file contains a WebView and if we don't link against WebKit,
// we will get a runtime crash when decoding the NIB. It is better to get a link error.
[WebView MIMETypesShownAsHTML];
}
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
- (void)dealloc
{
[updateItem release];
[host release];
[super dealloc];
}
- (void)endWithSelection:(SUUpdateAlertChoice)choice
{
[releaseNotesView stopLoading:self];
[releaseNotesView setFrameLoadDelegate:nil];
[releaseNotesView setPolicyDelegate:nil];
[releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
[self close];
if ([delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
[delegate updateAlert:self finishedWithChoice:choice];
}
- (IBAction)installUpdate: (id)sender
{
[self endWithSelection:SUInstallUpdateChoice];
}
- (IBAction)openInfoURL: (id)sender
{
[self endWithSelection:SUOpenInfoURLChoice];
}
- (IBAction)skipThisVersion: (id)sender
{
[self endWithSelection:SUSkipThisVersionChoice];
}
- (IBAction)remindMeLater: (id)sender
{
[self endWithSelection:SURemindMeLaterChoice];
}
- (void)displayReleaseNotes
{
// Set the default font
[releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
WebPreferences *prefs = [releaseNotesView preferences];
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
familyName = @"Lucida Grande";
}
[prefs setStandardFontFamily:familyName];
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
[prefs setPlugInsEnabled:NO];
[releaseNotesView setFrameLoadDelegate:self];
[releaseNotesView setPolicyDelegate:self];
// Stick a nice big spinner in the middle of the web view until the page is loaded.
NSRect frame = [[releaseNotesView superview] frame];
releaseNotesSpinner = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)] autorelease];
[releaseNotesSpinner setStyle:NSProgressIndicatorSpinningStyle];
[releaseNotesSpinner startAnimation:self];
webViewFinishedLoading = NO;
[[releaseNotesView superview] addSubview:releaseNotesSpinner];
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
if ([updateItem releaseNotesURL])
{
if ([[updateItem releaseNotesURL] isFileURL])
{
[[releaseNotesView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons&mdash;Javascript would be able to read files on your file system." baseURL:nil];
}
else
{
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
}
}
else
{
[[releaseNotesView mainFrame] loadHTMLString:[updateItem itemDescription] baseURL:nil];
}
}
- (BOOL)showsReleaseNotes
{
NSNumber *shouldShowReleaseNotes = [host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
if (shouldShowReleaseNotes == nil)
{
// UK 2007-09-18: Don't show release notes if RSS item contains no description and no release notes URL:
return( ([updateItem itemDescription] != nil
&& [[[updateItem itemDescription] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|| [updateItem releaseNotesURL] != nil );
}
else
return [shouldShowReleaseNotes boolValue];
}
- (BOOL)allowsAutomaticUpdates
{
BOOL allowAutoUpdates = YES; // Defaults to YES.
if( [host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] )
allowAutoUpdates = [host boolForInfoDictionaryKey: SUAllowsAutomaticUpdatesKey];
// UK 2007-08-31: Give delegate a chance to modify this choice:
if( delegate && [delegate respondsToSelector: @selector(updateAlert:shouldAllowAutoUpdate:)] )
[delegate updateAlert: self shouldAllowAutoUpdate: &allowAutoUpdates];
return allowAutoUpdates;
}
- (void)awakeFromNib
{
NSString* sizeStr = [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey];
if ([host isBackgroundApplication]) {
[[self window] setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! UK 2007-09-04
}
[[self window] setFrameAutosaveName: sizeStr ? @"" : @"SUUpdateAlertFrame"];
// We're gonna do some frame magic to match the window's size to the description field and the presence of the release notes view.
NSRect frame = [[self window] frame];
BOOL showReleaseNotes = [self showsReleaseNotes]; // UK 2007-09-18
if (!showReleaseNotes) // UK 2007-09-18
{
// Resize the window to be appropriate for not having a huge release notes view.
frame.size.height -= [releaseNotesView frame].size.height + 40; // Extra 40 is for the release notes label and margin.
if ([self allowsAutomaticUpdates]) {
frame.size.height += 10; // Make room for the check box.
}
// Hiding the resize handles is not enough on 10.5, you can still click
// where they would be, so we set the min/max sizes to be equal to
// inhibit resizing completely:
[[self window] setShowsResizeIndicator: NO];
[[self window] setMinSize: frame.size];
[[self window] setMaxSize: frame.size];
}
else if (![self allowsAutomaticUpdates])
{
NSRect boxFrame = [[[releaseNotesView superview] superview] frame];
boxFrame.origin.y -= 20;
boxFrame.size.height += 20;
[[[releaseNotesView superview] superview] setFrame:boxFrame];
}
if( [updateItem fileURL] == nil ) // UK 2007-08-31 (whole if clause)
{
[installButton setTitle: SULocalizedString( @"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed." )];
[installButton setAction: @selector(openInfoURL:)];
}
// Make sure button widths are OK:
#define DISTANCE_BETWEEN_BUTTONS 3
#define DISTANCE_BETWEEN_BUTTON_GROUPS 12
CGFloat minimumWindowWidth = [[self window] frame].size.width -NSMaxX([installButton frame]) +NSMinX([skipButton frame]); // Distance between contents and left/right edge.
NSDictionary* attrs = @{NSFontAttributeName: [installButton font]};
NSSize titleSize = [[installButton title] sizeWithAttributes: attrs];
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
NSRect installBtnBox = [installButton frame];
installBtnBox.origin.x += installBtnBox.size.width -titleSize.width;
installBtnBox.size.width = titleSize.width;
[installButton setFrame: installBtnBox];
minimumWindowWidth += titleSize.width;
titleSize = [[laterButton title] sizeWithAttributes: attrs];
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
NSRect laterBtnBox = [installButton frame];
laterBtnBox.origin.x = installBtnBox.origin.x -DISTANCE_BETWEEN_BUTTONS -titleSize.width;
laterBtnBox.size.width = titleSize.width;
[laterButton setFrame: laterBtnBox];
minimumWindowWidth += DISTANCE_BETWEEN_BUTTONS +titleSize.width;
titleSize = [[skipButton title] sizeWithAttributes: attrs];
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
NSRect skipBtnBox = [skipButton frame];
skipBtnBox.size.width = titleSize.width;
[skipButton setFrame: skipBtnBox];
minimumWindowWidth += DISTANCE_BETWEEN_BUTTON_GROUPS +titleSize.width;
if( showReleaseNotes ) // UK 2007-09-18 (whole block)
{
if( sizeStr )
{
NSSize desiredSize = NSSizeFromString( sizeStr );
NSSize sizeDiff = NSZeroSize;
// NSBox* boxView = (NSBox*)[[releaseNotesView superview] superview];
//[boxView setBorderType: NSNoBorder];
[releaseNotesView setDrawsBackground: NO];
sizeDiff.width = desiredSize.width -[releaseNotesView frame].size.width;
sizeDiff.height = desiredSize.height -[releaseNotesView frame].size.height;
frame.size.width += sizeDiff.width;
frame.size.height += sizeDiff.height;
// No resizing:
[[self window] setShowsResizeIndicator:NO];
[[self window] setMinSize:frame.size];
[[self window] setMaxSize:frame.size];
}
}
if (frame.size.width < minimumWindowWidth) {
frame.size.width = minimumWindowWidth;
}
[[self window] setFrame: frame display: NO];
[[self window] center];
if (showReleaseNotes) // UK 2007-09-18
{
[self displayReleaseNotes];
}
[[[releaseNotesView superview] superview] setHidden: !showReleaseNotes]; // UK 2007-09-18
}
-(BOOL)showsReleaseNotesText
{
return( [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey] == nil );
}
- (BOOL)windowShouldClose:note
{
[self endWithSelection:SURemindMeLaterChoice];
return YES;
}
- (NSImage *)applicationIcon
{
return [host icon];
}
- (NSString *)titleText
{
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is available!", nil), [host name]];
}
- (NSString *)descriptionText
{
NSString *updateItemVersion = [updateItem displayVersionString];
NSString *hostVersion = [host displayVersion];
// Display more info if the version strings are the same; useful for betas.
if( !versionDisplayer && [updateItemVersion isEqualToString:hostVersion] )
{
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [updateItem versionString]];
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [host version]];
}
else {
[versionDisplayer formatVersion: &updateItemVersion andVersion: &hostVersion];
}
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [host name], updateItemVersion, hostVersion];
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:frame
{
if ([frame parentFrame] == nil) {
webViewFinishedLoading = YES;
[releaseNotesSpinner setHidden:YES];
[sender display]; // necessary to prevent weird scroll bar artifacting
}
}
- (void)webView:sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:frame decisionListener:listener
{
if (webViewFinishedLoading) {
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
[listener ignore];
}
else {
[listener use];
}
}
// Clean up the contextual menu.
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease];
if (webViewMenuItems)
{
for (NSMenuItem *menuItem in defaultMenuItems)
{
NSInteger tag = [menuItem tag];
switch (tag)
{
case WebMenuItemTagOpenLinkInNewWindow:
case WebMenuItemTagDownloadLinkToDisk:
case WebMenuItemTagOpenImageInNewWindow:
case WebMenuItemTagDownloadImageToDisk:
case WebMenuItemTagOpenFrameInNewWindow:
case WebMenuItemTagGoBack:
case WebMenuItemTagGoForward:
case WebMenuItemTagStop:
case WebMenuItemTagReload:
[webViewMenuItems removeObjectIdenticalTo: menuItem];
}
}
}
return webViewMenuItems;
}
@end
-48
View File
@@ -1,48 +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"
NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
@implementation SUUpdateDriver
@synthesize host;
@synthesize interruptible = isInterruptible;
@synthesize finished;
- (instancetype) initWithUpdater:(SUUpdater *)anUpdater
{
if ((self = [super init])) {
updater = anUpdater;
}
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h
{
appcastURL = [URL copy];
host = [h retain];
}
- (void)abortUpdate
{
[self setValue:@YES forKey:@"finished"];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
}
- (void)dealloc
{
self.host = nil;
[appcastURL release];
[super dealloc];
}
@end
-40
View File
@@ -1,40 +0,0 @@
//
// SUUpdatePermissionPrompt.h
// Sparkle
//
// Created by Andy Matuschak on 1/24/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#ifndef SUUPDATEPERMISSIONPROMPT_H
#define SUUPDATEPERMISSIONPROMPT_H
#import "SUWindowController.h"
typedef enum {
SUAutomaticallyCheck,
SUDoNotAutomaticallyCheck
} SUPermissionPromptResult;
@protocol SUUpdatePermissionPromptDelegateProtocol;
@class SUHost;
@interface SUUpdatePermissionPrompt : SUWindowController {
SUHost *host;
NSArray *systemProfileInformationArray;
id<SUUpdatePermissionPromptDelegateProtocol> delegate;
IBOutlet NSTextField *descriptionTextField;
IBOutlet NSView *moreInfoView;
IBOutlet NSButton *moreInfoButton;
IBOutlet NSTableView *profileTableView;
}
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegateProtocol>)d;
- (IBAction)toggleMoreInfo:(id)sender;
- (IBAction)finishPrompt:(id)sender;
@end
@protocol SUUpdatePermissionPromptDelegateProtocol <NSObject>
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result;
@end
#endif
-139
View File
@@ -1,139 +0,0 @@
//
// SUUpdatePermissionPrompt.m
// Sparkle
//
// Created by Andy Matuschak on 1/24/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUpdatePermissionPrompt.h"
#import "SUHost.h"
#import "SUConstants.h"
@interface SUUpdatePermissionPrompt ()
@property BOOL isShowingMoreInfo, shouldSendProfile;
@end
@implementation SUUpdatePermissionPrompt
- (BOOL)shouldAskAboutProfile
{
return [[host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
}
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegateProtocol>)d
{
self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"];
if (self)
{
host = [aHost retain];
delegate = d;
self.isShowingMoreInfo = NO;
self.shouldSendProfile = [self shouldAskAboutProfile];
systemProfileInformationArray = [profile retain];
[self setShouldCascadeWindows:NO];
}
return self;
}
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id)d
{
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
if ([aHost isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
id prompt = [[[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d] autorelease];
[NSApp runModalForWindow:[prompt window]];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
- (void)awakeFromNib
{
if (![self shouldAskAboutProfile])
{
NSRect frame = [[self window] frame];
frame.size.height -= [moreInfoButton frame].size.height;
[[self window] setFrame:frame display:YES];
} else {
// Set the table view's delegate so we can disable row selection.
[profileTableView setDelegate:(id)self];
}
}
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row { return NO; }
- (void)dealloc
{
[host release];
[systemProfileInformationArray release];
[super dealloc];
}
- (NSImage *)icon
{
return [host icon];
}
- (NSString *)promptDescription
{
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [host name]];
}
- (IBAction)toggleMoreInfo:(id)sender
{
self.isShowingMoreInfo = !_isShowingMoreInfo;
NSView *contentView = [[self window] contentView];
NSRect contentViewFrame = [contentView frame];
NSRect windowFrame = [[self window] frame];
NSRect profileMoreInfoViewFrame = [moreInfoView frame];
NSRect profileMoreInfoButtonFrame = [moreInfoButton frame];
NSRect descriptionFrame = [descriptionTextField frame];
if (_isShowingMoreInfo)
{
// Add the subview
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
profileMoreInfoViewFrame.origin.x = descriptionFrame.origin.x;
profileMoreInfoViewFrame.size.width = descriptionFrame.size.width;
windowFrame.size.height += profileMoreInfoViewFrame.size.height;
windowFrame.origin.y -= profileMoreInfoViewFrame.size.height;
[moreInfoView setFrame:profileMoreInfoViewFrame];
[moreInfoView setHidden:YES];
[contentView addSubview:moreInfoView
positioned:NSWindowBelow
relativeTo:moreInfoButton];
} else {
// Remove the subview
[moreInfoView setHidden:NO];
[moreInfoView removeFromSuperview];
contentViewFrame.size.height -= profileMoreInfoViewFrame.size.height;
windowFrame.size.height -= profileMoreInfoViewFrame.size.height;
windowFrame.origin.y += profileMoreInfoViewFrame.size.height;
}
[[self window] setFrame:windowFrame display:YES animate:YES];
[contentView setFrame:contentViewFrame];
[contentView setNeedsDisplay:YES];
[moreInfoView setHidden:(!_isShowingMoreInfo)];
}
- (IBAction)finishPrompt:(id)sender
{
if (![delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) {
[NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", delegate];
}
[host setBool:_shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey];
[delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)];
[[self window] close];
[NSApp stopModal];
}
@end
-170
View File
@@ -1,170 +0,0 @@
//
// SUUpdater.h
// Sparkle
//
// Created by Andy Matuschak on 1/4/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUUPDATER_H
#define SUUPDATER_H
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
@interface SUUpdater : NSObject
{
@private
SUUpdateDriver *driver;
SUHost *host;
}
@property (assign) IBOutlet id delegate;
+ (SUUpdater *)sharedUpdater;
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
- (instancetype)initForBundle:(NSBundle *)bundle;
@property (readonly, strong) NSBundle *hostBundle;
@property BOOL automaticallyChecksForUpdates;
@property NSTimeInterval updateCheckInterval;
@property (copy) NSURL *feedURL; // *** MUST BE CALLED ON MAIN THREAD ***
@property (nonatomic, copy) NSString *userAgentString;
@property BOOL sendsSystemProfile;
@property BOOL automaticallyDownloadsUpdates;
// This IBAction is meant for a main menu item. Hook up any menu item to this action,
// and Sparkle will check for updates and report back its findings verbosely.
- (IBAction)checkForUpdates:(id)sender;
// This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
// in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
// update is found, it will be downloaded and prepped for installation.
- (void)checkForUpdatesInBackground;
// Date of last update check. Returns nil if no check has been performed.
@property (readonly, copy) NSDate *lastUpdateCheckDate;
// This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
// (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
- (void)checkForUpdateInformation;
// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
- (void)resetUpdateCycle;
@property (readonly) BOOL updateInProgress;
@end
// -----------------------------------------------------------------------------
// SUUpdater Notifications for events that might be interesting to more than just the delegate
// The updater will be the notification object
// -----------------------------------------------------------------------------
extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
extern NSString *const SUUpdaterDidFindValidUpdateNotification;
extern NSString *const SUUpdaterDidNotFindUpdateNotification;
extern NSString *const SUUpdaterWillRestartNotification;
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
extern NSString *const SUUpdaterAppcastItemNotificationKey;
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
@interface NSObject (SUUpdaterDelegateInformalProtocol)
// Use this to keep Sparkle from popping up e.g. while your setup assistant is showing:
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle;
// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
// Override this to dynamically specify the entire URL.
- (NSString*)feedURLStringForUpdater:(SUUpdater*)updater;
// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
// Implement this if you want to do some special handling with the appcast once it finishes loading.
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
// If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
// a valid update, if any, in the given appcast.
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
// Sent when a valid update is found by the update driver.
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
// Sent when a valid update is not found.
- (void)updaterDidNotFindUpdate:(SUUpdater *)update;
// Sent immediately before installing the specified update.
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
// Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
// This is not called if the user didn't relaunch on the previous update, in that case it will immediately
// restart.
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
// Some apps *can not* be relaunched in certain circumstances. They can use this method
// to prevent a relaunch "hard":
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
// Called immediately before relaunching.
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
// This method allows you to provide a custom version comparator.
// If you don't implement this method or return nil, the standard version comparator will be used.
- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
// This method allows you to provide a custom version comparator.
// If you don't implement this method or return nil, the standard version displayer will be used.
- (id <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
// Called before and after, respectively, an updater shows a modal alert window, to give the host
// the opportunity to hide attached windows etc. that may get in the way:
-(void) updaterWillShowModalAlert:(SUUpdater *)updater;
-(void) updaterDidShowModalAlert:(SUUpdater *)updater;
// Called when an update is scheduled to be silently installed on quit.
// The invocation can be used to trigger an immediate silent install and relaunch.
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)update immediateInstallationInvocation:(NSInvocation *)invocation;
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)update;
@end
// -----------------------------------------------------------------------------
// Constants:
// -----------------------------------------------------------------------------
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
#if defined(DEBUG) && DEBUG && 0
#define SU_MIN_CHECK_INTERVAL 60
#else
#define SU_MIN_CHECK_INTERVAL 60*60
#endif
#if defined(DEBUG) && DEBUG && 0
#define SU_DEFAULT_CHECK_INTERVAL 60
#else
#define SU_DEFAULT_CHECK_INTERVAL 60*60*24
#endif
#endif
-573
View File
@@ -1,573 +0,0 @@
//
// SUUpdater.m
// Sparkle
//
// Created by Andy Matuschak on 1/4/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUHost.h"
#import "SUUpdatePermissionPrompt.h"
#import "SUAutomaticUpdateDriver.h"
#import "SUProbingUpdateDriver.h"
#import "SUUserInitiatedUpdateDriver.h"
#import "SUScheduledUpdateDriver.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUCodeSigningVerifier.h"
#include <SystemConfiguration/SystemConfiguration.h>
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
NSString *const SUUpdaterDidNotFindUpdateNotification = @"SUUpdaterDidNotFindUpdateNotification";
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNotificationKey";
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
@interface SUUpdater () <SUUpdatePermissionPromptDelegateProtocol>
@property (retain) NSTimer *checkTimer;
- (instancetype)initForBundle:(NSBundle *)bundle;
- (void)startUpdateCycle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
- (void)scheduleNextUpdateCheck;
- (void)registerAsObserver;
- (void)unregisterAsObserver;
- (void)updateDriverDidFinish:(NSNotification *)note;
@property (readonly, copy) NSURL *parameterizedFeedURL;
-(void) notifyWillShowModalAlert;
-(void) notifyDidShowModalAlert;
@end
@implementation SUUpdater
@synthesize delegate;
@synthesize checkTimer;
@synthesize userAgentString = customUserAgentString;
#pragma mark Initialization
static NSMutableDictionary *sharedUpdaters = nil;
static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
+ (SUUpdater *)sharedUpdater
{
return [self updaterForBundle:[NSBundle mainBundle]];
}
// SUUpdater has a singleton for each bundle. We use the fact that NSBundle instances are also singletons, so we can use them as keys. If you don't trust that you can also use the identifier as key
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle
{
if (bundle == nil) bundle = [NSBundle mainBundle];
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
if (updater == nil) {
updater = [[[[self class] alloc] initForBundle:bundle] autorelease];
}
return updater;
}
// This is the designated initializer for SUUpdater, important for subclasses
- (instancetype)initForBundle:(NSBundle *)bundle
{
self = [super init];
if (bundle == nil) bundle = [NSBundle mainBundle];
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
if (self) {
[self registerAsObserver];
}
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
if (updater)
{
[self release];
self = [updater retain];
}
else if (self)
{
if (sharedUpdaters == nil) {
sharedUpdaters = [[NSMutableDictionary alloc] init];
}
sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]] = self;
host = [[SUHost alloc] initWithBundle:bundle];
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
// Saving-the-developer-from-a-stupid-mistake-check:
BOOL hasPublicDSAKey = [host publicDSAKey] != nil;
BOOL isMainBundle = [bundle isEqualTo:[NSBundle mainBundle]];
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
if (!isMainBundle && !hasPublicDSAKey) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
[self notifyDidShowModalAlert];
} else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
[self notifyDidShowModalAlert];
}
#endif
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:0];
}
return self;
}
// This will be used when the updater is instantiated in a nib such as MainMenu
- (instancetype)init
{
return [self initForBundle:[NSBundle mainBundle]];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
-(void) notifyWillShowModalAlert
{
if( [delegate respondsToSelector: @selector(updaterWillShowModalAlert:)] )
[delegate updaterWillShowModalAlert: self];
}
-(void) notifyDidShowModalAlert
{
if( [delegate respondsToSelector: @selector(updaterDidShowModalAlert:)] )
[delegate updaterDidShowModalAlert: self];
}
- (void)startUpdateCycle
{
BOOL shouldPrompt = NO;
// If the user has been asked about automatic checks, don't bother prompting
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKey])
{
shouldPrompt = NO;
}
// Does the delegate want to take care of the logic for when we should ask permission to update?
else if ([delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)])
{
shouldPrompt = [delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
}
// Has he been asked already? And don't ask if the host has a default value set in its Info.plist.
else if ([host objectForKey:SUEnableAutomaticChecksKey] == nil)
{
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) {
[self setAutomaticallyChecksForUpdates:[host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]];
}
// Now, we don't want to ask the user for permission to do a weird thing on the first launch.
// We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
else if (![host objectForKey:SUPromptUserOnFirstLaunchKey])
{
if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
[host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
else
shouldPrompt = YES;
}
else
shouldPrompt = YES;
}
if (shouldPrompt)
{
NSArray *profileInfo = [host systemProfile];
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:YES]];
}
[SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self];
// We start the update checks and register as observer for changes after the prompt finishes
}
else
{
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
[self scheduleNextUpdateCheck];
}
}
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result
{
[self setAutomaticallyChecksForUpdates:(result == SUAutomaticallyCheck)];
// Schedule checks, but make sure we ignore the delayed call from KVO
[self resetUpdateCycle];
}
- (void)updateDriverDidFinish:(NSNotification *)note
{
if ([note object] == driver && [driver finished])
{
[driver release]; driver = nil;
[self scheduleNextUpdateCheck];
}
}
- (NSDate *)lastUpdateCheckDate
{
return [host objectForUserDefaultsKey:SULastCheckTimeKey];
}
- (void)scheduleNextUpdateCheck
{
if (checkTimer)
{
[checkTimer invalidate];
self.checkTimer = nil; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
}
if (![self automaticallyChecksForUpdates]) return;
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [self lastUpdateCheckDate];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
// Now we want to figure out how long until we check again.
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
if (intervalSinceCheck < updateCheckInterval)
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
else
delayUntilCheck = 0; // We're overdue! Run one now.
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
}
-(void) putFeedURLIntoDictionary: (NSMutableDictionary*)theDict // You release this.
{
theDict[@"feedURL"] = [self feedURL];
}
-(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDriver /* RUNS ON ITS OWN THREAD */
{
@try {
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
// can block, and it can be waiting a long time on slow networks, and we
// wouldn't want to beachball the main thread for a background operation.
// We could use asynchronous reachability callbacks, but those aren't
// reliable enough and can 'get lost' sometimes, which we don't want.
@autoreleasepool {
SCNetworkConnectionFlags flags = 0;
BOOL isNetworkReachable = YES;
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
dispatch_sync(dispatch_get_main_queue(), ^{
[self putFeedURLIntoDictionary:theDict]; // Get feed URL on main thread, it's not safe to call elsewhere.
});
const char *hostname = [[theDict[@"feedURL"] host] cStringUsingEncoding: NSUTF8StringEncoding];
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
Boolean reachabilityResult = NO;
// If the feed's using a file:// URL, we won't be able to use reachability.
if (reachability != NULL) {
SCNetworkReachabilityGetFlags(reachability, &flags);
CFRelease(reachability);
}
if( reachabilityResult )
{
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
//NSLog(@"reachable = %s, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO"));
if( !(reachable || automatic || local) )
isNetworkReachable = NO;
}
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
dispatch_async(dispatch_get_main_queue(), ^{
[self checkForUpdatesWithDriver: isNetworkReachable ? inDriver : nil];
});
}
} @catch (NSException *localException) {
SULog(@"UNCAUGHT EXCEPTION IN UPDATE CHECK TIMER: %@",[localException reason]);
// Don't propagate the exception beyond here. In Carbon apps that would trash the stack.
}
}
- (void)checkForUpdatesInBackground
{
// Background update checks should only happen if we have a network connection.
// Wouldn't want to annoy users on dial-up by establishing a connection every
// hour or so:
SUUpdateDriver * theUpdateDriver = [[[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver];
});
}
- (BOOL)mayUpdateAndRestart
{
return( !delegate || ![delegate respondsToSelector: @selector(updaterShouldRelaunchApplication:)] || [delegate updaterShouldRelaunchApplication: self] );
}
- (IBAction)checkForUpdates: (id)sender
{
if (driver && [driver isInterruptible]) {
[driver abortUpdate];
}
[self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]];
}
- (void)checkForUpdateInformation
{
[self checkForUpdatesWithDriver:[[[SUProbingUpdateDriver alloc] initWithUpdater:self] autorelease]];
}
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
{
if ([self updateInProgress]) { return; }
if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
SUClearLog();
SULog( @"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath: [[NSBundle mainBundle] bundlePath]] );
[self willChangeValueForKey:@"lastUpdateCheckDate"];
[host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
[self didChangeValueForKey:@"lastUpdateCheckDate"];
if( [delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![delegate updaterMayCheckForUpdates: self] )
{
[self scheduleNextUpdateCheck];
return;
}
driver = [d retain];
// If we're not given a driver at all, just schedule the next update check and bail.
if (!driver)
{
[self scheduleNextUpdateCheck];
return;
}
NSURL* theFeedURL = [self parameterizedFeedURL];
if( theFeedURL ) // Use a NIL URL to cancel quietly.
[driver checkForUpdatesAtURL: theFeedURL host:host];
else
[driver abortUpdate];
}
- (void)registerAsObserver
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:0 context:SUUpdaterDefaultsObservationContext];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:SUUpdaterDefaultsObservationContext];
}
- (void)unregisterAsObserver
{
@try
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
}
@catch (NSException *e)
{
NSLog(@"Sparkle Error: [SUUpdater unregisterAsObserver] called, but the updater wasn't registered as an observer.");
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context == SUUpdaterDefaultsObservationContext)
{
// Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking.
// Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them.
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
- (void)resetUpdateCycle
{
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
[self scheduleNextUpdateCheck];
}
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
{
[host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey];
// Hack to support backwards compatibility with older Sparkle versions, which supported
// disabling updates by setting the check interval to 0.
if (automaticallyCheckForUpdates && [self updateCheckInterval] == 0) {
[self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL];
}
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
// Provide a small delay in case multiple preferences are being updated simultaneously.
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
}
- (BOOL)automaticallyChecksForUpdates
{
// Don't automatically update when the check interval is 0, to be compatible with 1.1 settings.
if ([self updateCheckInterval] == 0) {
return NO;
}
return [host boolForKey:SUEnableAutomaticChecksKey];
}
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
{
[host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
}
- (BOOL)automaticallyDownloadsUpdates
{
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) {
return NO;
}
// Otherwise, automatically downloading updates is allowed. Does the user want it?
return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
}
- (void)setFeedURL:(NSURL *)feedURL
{
[host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
}
- (NSURL *)feedURL // *** MUST BE CALLED ON MAIN THREAD ***
{
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
NSString *appcastString = [host objectForKey:SUFeedURLKey];
if( [delegate respondsToSelector: @selector(feedURLStringForUpdater:)] )
appcastString = [delegate feedURLStringForUpdater: self];
if (!appcastString) // Can't find an appcast string!
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the SUFeedURL key in either the Info.plist or the user defaults!"];
NSCharacterSet* quoteSet = [NSCharacterSet characterSetWithCharactersInString: @"\"\'"]; // Some feed publishers add quotes; strip 'em.
NSString* castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
if( !castUrlStr || [castUrlStr length] == 0 )
return nil;
else
return [NSURL URLWithString: castUrlStr];
}
- (NSString *)userAgentString
{
if (customUserAgentString) {
return customUserAgentString;
}
NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [host name], [host displayVersion], version ? version : @"?"];
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
return [[[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding] autorelease];
}
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile
{
[host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
}
- (BOOL)sendsSystemProfile
{
return [host boolForKey:SUSendProfileInfoKey];
}
- (NSURL *)parameterizedFeedURL
{
NSURL *baseFeedURL = [self feedURL];
// Determine all the parameters we're attaching to the base feed URL.
BOOL sendingSystemProfile = [self sendsSystemProfile];
// Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.
NSDate *lastSubmitDate = [host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
if (!lastSubmitDate) {
lastSubmitDate = [NSDate distantPast];
}
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
NSArray *parameters = @[];
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
}
if (sendingSystemProfile)
{
parameters = [parameters arrayByAddingObjectsFromArray:[host systemProfile]];
[host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
}
if ([parameters count] == 0) { return baseFeedURL; }
// Build up the parameterized URL.
NSMutableArray *parameterStrings = [NSMutableArray array];
for (NSDictionary *currentProfileInfo in parameters) {
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[currentProfileInfo[@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[currentProfileInfo[@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}
NSString *separatorCharacter = @"?";
if ([baseFeedURL query]) {
separatorCharacter = @"&"; // In case the URL is already http://foo.org/baz.xml?bat=4
}
NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@%@%@", [baseFeedURL absoluteString], separatorCharacter, [parameterStrings componentsJoinedByString:@"&"]];
// Clean it up so it's a valid URL
return [NSURL URLWithString:appcastStringWithProfile];
}
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
{
[host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey];
if (updateCheckInterval == 0) { // For compatibility with 1.1's settings.
[self setAutomaticallyChecksForUpdates:NO];
}
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
// Provide a small delay in case multiple preferences are being updated simultaneously.
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
}
- (NSTimeInterval)updateCheckInterval
{
// Find the stored check interval. User defaults override Info.plist.
NSNumber *intervalValue = [host objectForKey:SUScheduledCheckIntervalKey];
if (intervalValue)
return [intervalValue doubleValue];
else
return SU_DEFAULT_CHECK_INTERVAL;
}
- (void)dealloc
{
[self unregisterAsObserver];
[host release];
if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
[super dealloc];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(checkForUpdates:)) {
return ![self updateInProgress];
}
return YES;
}
- (BOOL)updateInProgress
{
return driver && ([driver finished] == NO);
}
- (NSBundle *)hostBundle { return [host bundle]; }
@end
-88
View File
@@ -1,88 +0,0 @@
//
// SUUserInitiatedUpdateDriver.m
// Sparkle
//
// Created by Andy Matuschak on 5/30/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUserInitiatedUpdateDriver.h"
#import "SUStatusController.h"
#import "SUHost.h"
@implementation SUUserInitiatedUpdateDriver
- (void)closeCheckingWindow
{
if (checkingController)
{
[[checkingController window] close];
[checkingController release];
checkingController = nil;
}
}
- (void)cancelCheckForUpdates:sender
{
[self closeCheckingWindow];
isCanceled = YES;
}
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
checkingController = [[SUStatusController alloc] initWithHost:aHost];
[[checkingController window] center]; // Force the checking controller to load its window.
[checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
[checkingController showWindow:self];
[super checkForUpdatesAtURL:URL host:aHost];
// For background applications, obtain focus.
// Useful if the update check is requested from another app like System Preferences.
if ([aHost isBackgroundApplication])
{
[NSApp activateIgnoringOtherApps:YES];
}
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
if (isCanceled)
{
[self abortUpdate];
return;
}
[self closeCheckingWindow];
[super appcastDidFinishLoading:ac];
}
- (void)abortUpdateWithError:(NSError *)error
{
[self closeCheckingWindow];
[super abortUpdateWithError:error];
}
- (void)abortUpdate
{
[self closeCheckingWindow];
[super abortUpdate];
}
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
{
if (isCanceled)
{
[self abortUpdate];
return;
}
[super appcast:ac failedToLoadWithError:error];
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
// 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 hostSupportsItem:ui] && [self isItemNewer:ui];
}
@end
-29
View File
@@ -1,29 +0,0 @@
//
// SUVersionComparisonProtocol.h
// Sparkle
//
// Created by Andy Matuschak on 12/21/07.
// Copyright 2007 Andy Matuschak. All rights reserved.
//
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
#define SUVERSIONCOMPARISONPROTOCOL_H
#import <Cocoa/Cocoa.h>
/*!
@protocol
@abstract Implement this protocol to provide version comparison facilities for Sparkle.
*/
@protocol SUVersionComparison
/*!
@method
@abstract An abstract method to compare two version strings.
@discussion Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a, and NSOrderedSame if they are equivalent.
*/
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
@end
#endif
-27
View File
@@ -1,27 +0,0 @@
//
// SUVersionDisplayProtocol.h
// EyeTV
//
// Created by Uli Kusterer on 08.12.09.
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
/*!
@protocol
@abstract Implement this protocol to apply special formatting to the two
version numbers.
*/
@protocol SUVersionDisplay
/*!
@method
@abstract An abstract method to format two version strings.
@discussion You get both so you can display important distinguishing
information, but leave out unnecessary/confusing parts.
*/
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
@end
-27
View File
@@ -1,27 +0,0 @@
//
// SUWindowController.m
// Sparkle
//
// Created by Andy Matuschak on 2/13/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUWindowController.h"
#import "SUHost.h"
@implementation SUWindowController
- (instancetype)initWithHost:(SUHost *)host windowNibName:(NSString *)nibName
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:nibName ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[[host bundle] sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:nibName ofType:@"nib"];
}
self = [super initWithWindowNibPath:path owner:self];
return self;
}
@end
-36
View File
@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Your Great App's Changelog</title>
<link>http://you.com/app/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 2.0 (2 bugs fixed; 3 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/2.0.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your Great App 2.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
</item>
<item>
<title>Version 1.5 (8 bugs fixed; 2 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/1.5.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your Great App 1.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
</item>
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
<item>
<title>Version 1.4 (5 bugs fixed; 2 new features)</title>
<sparkle:releaseNotesLink>
http://you.com/app/1.4.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your Great App 1.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
</item>
</channel>
</rss>
BIN
View File
Binary file not shown.
-18
View File
@@ -1,18 +0,0 @@
//
// Sparkle.pch
// Sparkle
//
// Created by Andy Matuschak on 7/23/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#ifdef __OBJC__
#define SPARKLE_BUNDLE [NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"]
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
#import <Cocoa/Cocoa.h>
#import "SUConstants.h"
#endif
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

+26
View File
@@ -0,0 +1,26 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.9.0"
s.summary = "A software update framework for OS X"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
s.license = {
:type => 'MIT',
:file => 'LICENSE'
}
s.authors = {
'Andy Matuschak' => 'andy@andymatuschak.org',
'Kornel Lesiński' => 'pornel@pornel.net',
'C.W. Betts' => 'computers57@hotmail.com',
'Jake Petroules' => 'jake.petroules@petroules.com',
}
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.public_header_files = 'Sparkle.framework/Headers/*.h'
s.vendored_framework = 'Sparkle.framework'
s.resources = 'Sparkle.framework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
s.requires_arc = true
end
-5
View File
@@ -1,5 +0,0 @@
*.pbxuser
*.perspectivev3
*.mode1v3
project.xcworkspace/
xcuserdata/
+574 -165
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "612279D80DB5470200AB99EA"
BuildableName = "Sparkle Unit Tests.xctest"
BlueprintName = "Sparkle Unit Tests"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+100
View File
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
BuildableName = "Sparkle.framework"
BlueprintName = "Sparkle"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "612279D80DB5470200AB99EA"
BuildableName = "Sparkle Unit Tests.xctest"
BlueprintName = "Sparkle Unit Tests"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
BuildableName = "Sparkle.framework"
BlueprintName = "Sparkle"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugXPCServices = "NO"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
BuildableName = "Sparkle.framework"
BlueprintName = "Sparkle"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
BuildableName = "Sparkle.framework"
BlueprintName = "Sparkle"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+2 -4
View File
@@ -6,10 +6,8 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Sparkle</string>
<key>CFBundleIdentifier</key>
<string>org.andymatuschak.sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
@@ -23,7 +21,7 @@
<key>LSBackgroundOnly</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
<string>1</string>
<key>NSMainNibFile</key>
+210
View File
@@ -0,0 +1,210 @@
#import <AppKit/AppKit.h>
#import "SUInstaller.h"
#import "SUHost.h"
#import "SUStandardVersionComparator.h"
#import "SUStatusController.h"
#import "SUPlainInstallerInternals.h"
#import "SULog.h"
#include <unistd.h>
/*!
* If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback.
*/
static const NSTimeInterval SUInstallationTimeLimit = 5;
/*!
* Time this app uses to recheck if the parent has already died.
*/
static const NSTimeInterval SUParentQuitCheckInterval = .25;
@interface TerminationListener : NSObject
@property (copy) NSString *hostpath;
@property (copy) NSString *executablepath;
@property (assign) pid_t parentprocessid;
@property (copy) NSString *folderpath;
@property (copy) NSString *selfPath;
@property (copy) NSString *installationPath;
@property (strong) NSTimer *watchdogTimer;
@property (strong) NSTimer *longInstallationTimer;
@property (strong) SUHost *host;
@property (assign) BOOL shouldRelaunch;
@property (assign) BOOL shouldShowUI;
@property (strong) SUStatusController *statusController;
- (void)parentHasQuit;
- (void)relaunch;
- (void)install;
- (void)showAppIconInDock:(NSTimer *)aTimer;
- (void)watchdog:(NSTimer *)aTimer;
@end
@implementation TerminationListener
@synthesize hostpath;
@synthesize executablepath;
@synthesize parentprocessid;
@synthesize folderpath;
@synthesize selfPath;
@synthesize installationPath;
@synthesize watchdogTimer;
@synthesize longInstallationTimer;
@synthesize host;
@synthesize shouldRelaunch;
@synthesize shouldShowUI;
@synthesize statusController;
- (instancetype)initWithHostPath:(NSString *)inhostpath executablePath:(NSString *)execpath parentProcessId:(pid_t)ppid folderPath:(NSString *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
{
if (!(self = [super init])) {
return nil;
}
self.hostpath = inhostpath;
self.executablepath = execpath;
self.parentprocessid = ppid;
self.folderpath = infolderpath;
self.selfPath = inSelfPath;
self.shouldRelaunch = relaunch;
self.shouldShowUI = showUI;
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
if (alreadyTerminated)
[self parentHasQuit];
else
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
return self;
}
- (void)dealloc
{
[self.longInstallationTimer invalidate];
[self.statusController close];
}
- (void)parentHasQuit
{
[self.watchdogTimer invalidate];
self.longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
target: self selector: @selector(showAppIconInDock:)
userInfo:nil repeats:NO];
if (self.folderpath)
[self install];
else
[self relaunch];
}
- (void)watchdog:(NSTimer *)__unused aTimer
{
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.parentprocessid]) {
[self parentHasQuit];
}
}
- (void)showAppIconInDock:(NSTimer *)__unused aTimer
{
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
}
- (void)relaunch __attribute__((noreturn))
{
if (self.shouldRelaunch)
{
NSString *appPath = nil;
if (!self.folderpath || ![self.executablepath isEqualToString:self.hostpath])
appPath = self.executablepath;
else
appPath = self.installationPath;
[[NSWorkspace sharedWorkspace] openFile:appPath];
}
if (self.folderpath)
{
NSError *theError = nil;
if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError])
SULog(@"Couldn't remove update folder: %@.", theError);
}
[[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL];
exit(EXIT_SUCCESS);
}
- (void)install
{
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostpath];
self.host = [[SUHost alloc] initWithBundle:theBundle];
self.installationPath = [[self.host installationPath] copy];
if (self.shouldShowUI) {
SUStatusController *statusCtl = [[SUStatusController alloc] initWithHost:self.host]; // We quit anyway after we've installed, so leak this for now.
[statusCtl setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
[statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
maxProgressValue: 0 statusText: @""];
[statusCtl showWindow:self];
[self.statusController close]; // If there's an existing status controller, close it before we release our strong reference to it.
self.statusController = statusCtl; // Keep a strong reference to the status controller, or else it might get prematurely deallocated.
}
[SUInstaller installFromUpdateFolder:self.folderpath
overHost:self.host
installationPath:self.installationPath
versionComparator:[SUStandardVersionComparator defaultComparator]
completionHandler:^(NSError *error) {
if (error) {
if (self.shouldShowUI) {
NSRunAlertPanel(@"", @"%@", @"OK", @"", @"", [error localizedDescription]);
}
exit(EXIT_FAILURE);
} else {
[self relaunch];
}
}];
}
@end
int main(int __unused argc, const char __unused *argv[])
{
@autoreleasepool
{
NSArray *args = [[NSProcessInfo processInfo] arguments];
if (args.count < 5 || args.count > 7) {
return EXIT_FAILURE;
}
BOOL shouldShowUI = (args.count > 6) ? [args[6] boolValue] : YES;
if (shouldShowUI) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
[NSApplication sharedApplication];
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:args[1]
executablePath:args[2]
parentProcessId:[args[3] intValue]
folderPath:args[4]
shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES
shouldShowUI:shouldShowUI
selfPath:[[NSBundle mainBundle] bundlePath]];
[[NSApplication sharedApplication] run];
// Ensure termListen is not deallocated by ARC before caling -[NSApplication run]
[termListen class];
}
return EXIT_SUCCESS;
}
Vendored Executable
+26
View File
@@ -0,0 +1,26 @@
//
// SUAppcast.h
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
#import <Foundation/NSURLDownload.h>
#import "SUExport.h"
@class SUAppcastItem;
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
@property (copy) NSString *userAgentString;
@property (copy) NSDictionary *httpHeaders;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
@property (readonly, copy) NSArray *items;
@end
#endif
Vendored Executable
+278
View File
@@ -0,0 +1,278 @@
//
// SUAppcast.m
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcast.h"
#import "SUConstants.h"
#import "SULog.h"
@interface NSXMLElement (SUAppcastExtensions)
@property (readonly, copy) NSDictionary *attributesAsDictionary;
@end
@implementation NSXMLElement (SUAppcastExtensions)
- (NSDictionary *)attributesAsDictionary
{
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSXMLNode *attribute in attributeEnum) {
dictionary[[attribute name]] = [attribute stringValue];
}
return dictionary;
}
@end
@interface SUAppcast () <NSURLDownloadDelegate>
@property (strong) void (^completionBlock)(NSError *);
@property (copy) NSString *downloadFilename;
@property (strong) NSURLDownload *download;
@property (copy) NSArray *items;
- (void)reportError:(NSError *)error;
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
@end
@implementation SUAppcast
@synthesize downloadFilename;
@synthesize completionBlock;
@synthesize userAgentString;
@synthesize httpHeaders;
@synthesize download;
@synthesize items;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
{
self.completionBlock = block;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
if (self.userAgentString) {
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
}
if (self.httpHeaders) {
for (NSString *key in self.httpHeaders) {
id value = [self.httpHeaders objectForKey:key];
[request setValue:value forHTTPHeaderField:key];
}
}
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
{
NSString *destinationFilename = NSTemporaryDirectory();
if (destinationFilename)
{
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
[self.download setDestination:destinationFilename allowOverwrite:NO];
}
}
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
{
self.downloadFilename = path;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
{
NSError *error = nil;
NSXMLDocument *document = nil;
BOOL failed = NO;
NSArray *xmlItems = nil;
NSMutableArray *appcastItems = [NSMutableArray array];
if (self.downloadFilename)
{
NSUInteger options = 0;
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:self.downloadFilename] options:options error:&error];
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
self.downloadFilename = nil;
}
else
{
failed = YES;
}
if (nil == document)
{
failed = YES;
}
else
{
xmlItems = [document nodesForXPath:@"/rss/channel/item" error:&error];
if (nil == xmlItems)
{
failed = YES;
}
}
if (failed == NO)
{
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
NSXMLNode *node;
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
while (failed == NO && (node = [nodeEnum nextObject]))
{
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
if ([[node children] count])
{
node = [node childAtIndex:0];
while (nil != node)
{
NSString *name = [node name];
if (name)
{
NSMutableArray *nodes = nodesDict[name];
if (nodes == nil)
{
nodes = [NSMutableArray array];
nodesDict[name] = nodes;
}
[nodes addObject:node];
}
node = [node nextSibling];
}
}
for (NSString *name in nodesDict)
{
node = [self bestNodeInNodes:nodesDict[name]];
if ([name isEqualToString:SURSSElementEnclosure])
{
// enclosure is flattened as a separate dictionary for some reason
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
dict[name] = encDict;
}
else if ([name isEqualToString:SURSSElementPubDate])
{
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
if (date)
dict[name] = date;
}
else if ([name isEqualToString:SUAppcastElementDeltas])
{
NSMutableArray *deltas = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
if ([[child name] isEqualToString:SURSSElementEnclosure])
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
}
dict[name] = deltas;
}
else if ([name isEqualToString:SUAppcastElementTags]) {
NSMutableArray *tags = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
[tags addObject:[child name]];
}
dict[name] = tags;
}
else if (name != nil)
{
// add all other values as strings
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (theValue != nil) {
dict[name] = theValue;
}
}
}
NSString *errString;
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
if (anItem)
{
[appcastItems addObject:anItem];
}
else
{
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
}
[nodesDict removeAllObjects];
[dict removeAllObjects];
}
}
if ([appcastItems count]) {
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
[appcastItems sortUsingDescriptors:@[sort]];
self.items = appcastItems;
}
if (failed) {
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil) }]];
} else {
self.completionBlock(nil);
self.completionBlock = nil;
}
}
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
{
if (self.downloadFilename) {
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
}
self.downloadFilename = nil;
[self reportError:error];
}
- (NSURLRequest *)download:(NSURLDownload *)__unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)__unused redirectResponse
{
return request;
}
- (void)reportError:(NSError *)error
{
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
}]);
self.completionBlock = nil;
}
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes
{
// We use this method to pick out the localized version of a node when one's available.
if ([nodes count] == 1)
return nodes[0];
else if ([nodes count] == 0)
return nil;
NSMutableArray *languages = [NSMutableArray array];
NSString *lang;
NSUInteger i;
for (NSXMLElement *node in nodes) {
lang = [[node attributeForName:@"xml:lang"] stringValue];
[languages addObject:(lang ? lang : @"")];
}
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
if (i == NSNotFound) {
i = 0;
}
return nodes[i];
}
@end
Vendored Regular → Executable
+8 -6
View File
@@ -9,23 +9,25 @@
#ifndef SUAPPCASTITEM_H
#define SUAPPCASTITEM_H
@interface SUAppcastItem : NSObject
#include "SUExport.h"
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
@property (copy, readonly) NSDate *date;
@property (copy, readonly) NSString *itemDescription;
@property (retain, readonly) NSURL *releaseNotesURL;
@property (strong, readonly) NSURL *releaseNotesURL;
@property (copy, readonly) NSString *DSASignature;
@property (copy, readonly) NSString *minimumSystemVersion;
@property (copy, readonly) NSString *maximumSystemVersion;
@property (retain, readonly) NSURL *fileURL;
@property (strong, readonly) NSURL *fileURL;
@property (copy, readonly) NSString *versionString;
@property (copy, readonly) NSString *displayVersionString;
@property (copy, readonly) NSDictionary *deltaUpdates;
@property (retain, readonly) NSURL *infoURL; // UK 2007-08-31
@property (strong, readonly) NSURL *infoURL;
// Initializes with data from a dictionary provided by the RSS class.
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
@@ -33,7 +35,7 @@
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
@property (readonly, copy) NSDictionary *propertiesDictionary;
- (NSURL *)infoURL; // UK 2007-08-31
- (NSURL *)infoURL;
@end
Vendored Executable
+180
View File
@@ -0,0 +1,180 @@
//
// SUAppcastItem.m
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcastItem.h"
#import "SULog.h"
@interface SUAppcastItem ()
@property (copy, readwrite) NSString *title;
@property (copy, readwrite) NSDate *date;
@property (copy, readwrite) NSString *itemDescription;
@property (strong, readwrite) NSURL *releaseNotesURL;
@property (copy, readwrite) NSString *DSASignature;
@property (copy, readwrite) NSString *minimumSystemVersion;
@property (copy, readwrite) NSString *maximumSystemVersion;
@property (strong, readwrite) NSURL *fileURL;
@property (copy, readwrite) NSString *versionString;
@property (copy, readwrite) NSString *displayVersionString;
@property (copy, readwrite) NSDictionary *deltaUpdates;
@property (strong, readwrite) NSURL *infoURL;
@property (readwrite, copy) NSDictionary *propertiesDictionary;
@end
@implementation SUAppcastItem
@synthesize date;
@synthesize deltaUpdates;
@synthesize displayVersionString;
@synthesize DSASignature;
@synthesize fileURL;
@synthesize infoURL;
@synthesize itemDescription;
@synthesize maximumSystemVersion;
@synthesize minimumSystemVersion;
@synthesize releaseNotesURL;
@synthesize title;
@synthesize versionString;
@synthesize propertiesDictionary;
- (BOOL)isDeltaUpdate
{
return self.propertiesDictionary[SURSSElementEnclosure][SUAppcastAttributeDeltaFrom] != nil;
}
- (BOOL)isCriticalUpdate
{
return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
return [self initWithDictionary:dict failureReason:nil];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error
{
self = [super init];
if (self) {
id enclosure = dict[SURSSElementEnclosure];
// Try to find a version string.
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
NSString *newVersion = enclosure[SUAppcastAttributeVersion];
if (newVersion == nil) {
newVersion = dict[SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
}
if (newVersion == nil) // no sparkle:version attribute anywhere?
{
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, enclosure[SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
// Separate the url by underscores and take the last component, as that'll be closest to the end,
// then we remove the extension. Hopefully, this will be the version.
NSArray *fileComponents = [enclosure[SURSSAttributeURL] componentsSeparatedByString:@"_"];
if ([fileComponents count] > 1) {
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
}
}
if (!newVersion) {
if (error) {
*error = [NSString stringWithFormat:@"Feed item lacks %@ attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)", SUAppcastAttributeVersion];
}
return nil;
}
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
self.title = dict[SURSSElementTitle];
self.date = dict[SURSSElementPubDate];
self.itemDescription = dict[SURSSElementDescription];
NSString *theInfoURL = dict[SURSSElementLink];
if (theInfoURL) {
if (![theInfoURL isKindOfClass:[NSString class]]) {
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
} else {
self.infoURL = [NSURL URLWithString:theInfoURL];
}
}
// Need an info URL or an enclosure URL. Former to show "More Info"
// page, latter to download & install:
if (!enclosure && !theInfoURL) {
if (error) {
*error = @"No enclosure in feed item";
}
return nil;
}
NSString *enclosureURLString = enclosure[SURSSAttributeURL];
if (!enclosureURLString && !theInfoURL) {
if (error) {
*error = @"Feed item's enclosure lacks URL";
}
return nil;
}
if (enclosureURLString) {
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
self.fileURL = [NSURL URLWithString:fileURLString];
}
if (enclosure) {
self.DSASignature = enclosure[SUAppcastAttributeDSASignature];
}
self.versionString = newVersion;
self.minimumSystemVersion = dict[SUAppcastElementMinimumSystemVersion];
self.maximumSystemVersion = dict[SUAppcastElementMaximumSystemVersion];
NSString *shortVersionString = enclosure[SUAppcastAttributeShortVersionString];
if (nil == shortVersionString) {
shortVersionString = dict[SUAppcastAttributeShortVersionString]; // fall back on the <item>
}
if (shortVersionString) {
self.displayVersionString = shortVersionString;
} else {
self.displayVersionString = self.versionString;
}
// Find the appropriate release notes URL.
if (dict[SUAppcastElementReleaseNotesLink]) {
self.releaseNotesURL = [NSURL URLWithString:dict[SUAppcastElementReleaseNotesLink]];
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
} else {
self.releaseNotesURL = nil;
}
NSArray *deltaDictionaries = dict[SUAppcastElementDeltas];
if (deltaDictionaries) {
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
for (NSDictionary *deltaDictionary in deltaDictionaries) {
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary;
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
deltas[deltaDictionary[SUAppcastAttributeDeltaFrom]] = deltaItem;
}
self.deltaUpdates = deltas;
}
}
return self;
}
@end
+6 -13
View File
@@ -11,27 +11,20 @@
#import "SUWindowController.h"
@protocol SUAutomaticUpdateAlertDelegateProtocol;
typedef enum
{
SUInstallNowChoice,
SUInstallLaterChoice,
SUDoNotInstallChoice
} SUAutomaticInstallationChoice;
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
SUInstallNowChoice,
SUInstallLaterChoice,
SUDoNotInstallChoice
};
@class SUAppcastItem, SUHost;
@interface SUAutomaticUpdateAlert : SUWindowController
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:(id<SUAutomaticUpdateAlertDelegateProtocol>)delegate;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
- (IBAction)installNow:sender;
- (IBAction)installLater:sender;
- (IBAction)doNotInstall:sender;
@end
@protocol SUAutomaticUpdateAlertDelegateProtocol <NSObject>
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
@end
#endif
+89
View File
@@ -0,0 +1,89 @@
//
// SUAutomaticUpdateAlert.m
// Sparkle
//
// Created by Andy Matuschak on 3/18/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUAutomaticUpdateAlert.h"
#import "SUHost.h"
@interface SUAutomaticUpdateAlert ()
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
@property (strong) SUAppcastItem *updateItem;
@property (strong) SUHost *host;
@end
@implementation SUAutomaticUpdateAlert
@synthesize host;
@synthesize updateItem;
@synthesize completionBlock;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
{
self = [super initWithWindowNibName:@"SUAutomaticUpdateAlert"];
if (self) {
self.updateItem = item;
self.completionBlock = block;
self.host = aHost;
[self setShouldCascadeWindows:NO];
[[self window] center];
}
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (IBAction)installNow:(id)__unused sender
{
[self close];
self.completionBlock(SUInstallNowChoice);
self.completionBlock = nil;
}
- (IBAction)installLater:(id)__unused sender
{
[self close];
self.completionBlock(SUInstallLaterChoice);
self.completionBlock = nil;
}
- (IBAction)doNotInstall:(id)__unused sender
{
[self close];
self.completionBlock(SUDoNotInstallChoice);
self.completionBlock = nil;
}
- (NSImage *)applicationIcon
{
return [self.host icon];
}
- (NSString *)titleText
{
if ([self.updateItem isCriticalUpdate])
{
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
}
else
{
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]];
}
}
- (NSString *)descriptionText
{
if ([self.updateItem isCriticalUpdate])
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
}
else
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
}
}
@end
Loaded 100 of 416 files, more files were not shown because too many files have changed in this diff. Show more