mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Group download data, text encoding name, and MIME type into one class
This commit is contained in:
1 parent
bce9c083c1
commit
f5afdc1cd8
19 files changed
+158
-173
No files matched your search
@@ -323,13 +323,13 @@
|
||||
72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; };
|
||||
72F9EC341D5BF542004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; };
|
||||
72F9EC351D5BF54E004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; };
|
||||
72F9EC381D5C04A9004AC8B6 /* SPUTemporaryDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC361D5C04A9004AC8B6 /* SPUTemporaryDownload.h */; };
|
||||
72F9EC3A1D5C04A9004AC8B6 /* SPUTemporaryDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC371D5C04A9004AC8B6 /* SPUTemporaryDownload.m */; };
|
||||
72F9EC3B1D5C15D0004AC8B6 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
72F9EC3C1D5C15EF004AC8B6 /* SPUTemporaryDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC371D5C04A9004AC8B6 /* SPUTemporaryDownload.m */; };
|
||||
72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC3D1D5E823F004AC8B6 /* SPUUpdaterTimer.h */; };
|
||||
72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; };
|
||||
72F9EC411D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; };
|
||||
72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72F9EC451D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */; };
|
||||
72F9EC461D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */; };
|
||||
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; };
|
||||
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; };
|
||||
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; };
|
||||
@@ -1025,10 +1025,10 @@
|
||||
72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUXPCServiceInfo.m; sourceTree = "<group>"; };
|
||||
72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdater.h; sourceTree = "<group>"; };
|
||||
72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdater.m; sourceTree = "<group>"; };
|
||||
72F9EC361D5C04A9004AC8B6 /* SPUTemporaryDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPUTemporaryDownload.h; path = TemporaryDownloader/SPUTemporaryDownload.h; sourceTree = SOURCE_ROOT; };
|
||||
72F9EC371D5C04A9004AC8B6 /* SPUTemporaryDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPUTemporaryDownload.m; path = TemporaryDownloader/SPUTemporaryDownload.m; sourceTree = SOURCE_ROOT; };
|
||||
72F9EC3D1D5E823F004AC8B6 /* SPUUpdaterTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdaterTimer.h; sourceTree = "<group>"; };
|
||||
72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUpdaterTimer.m; sourceTree = "<group>"; };
|
||||
72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUDownloadData.h; sourceTree = "<group>"; };
|
||||
72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUDownloadData.m; sourceTree = "<group>"; };
|
||||
8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = "<group>"; };
|
||||
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestWebServer.h; sourceTree = "<group>"; };
|
||||
@@ -1433,6 +1433,8 @@
|
||||
72B09CE61CE6BCBD0052EF9E /* SPUURLDownload.m */,
|
||||
7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */,
|
||||
7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */,
|
||||
72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */,
|
||||
72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */,
|
||||
61A225A20D1C4AC000430CCD /* SUStandardVersionComparator.h */,
|
||||
61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */,
|
||||
61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */,
|
||||
@@ -1725,8 +1727,6 @@
|
||||
724A0A351CF7AEEA00D8C3D5 /* main.m */,
|
||||
724A0A371CF7AEEA00D8C3D5 /* SUTemporaryDownloader.h */,
|
||||
724A0A381CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m */,
|
||||
72F9EC361D5C04A9004AC8B6 /* SPUTemporaryDownload.h */,
|
||||
72F9EC371D5C04A9004AC8B6 /* SPUTemporaryDownload.m */,
|
||||
724A0A391CF7AEEA00D8C3D5 /* SUTemporaryDownloaderProtocol.h */,
|
||||
);
|
||||
name = TemporaryDownloader;
|
||||
@@ -1850,6 +1850,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */,
|
||||
725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */,
|
||||
72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */,
|
||||
726E078D1CA891E9001A286B /* SPUUpdaterSettings.h in Headers */,
|
||||
@@ -1906,7 +1907,6 @@
|
||||
61B5F8ED09C4CE3C00B25A18 /* SPUUpdater.h in Headers */,
|
||||
61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */,
|
||||
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */,
|
||||
72F9EC381D5C04A9004AC8B6 /* SPUTemporaryDownload.h in Headers */,
|
||||
7267E5E51D3D90AA00D1BF90 /* SUFileManager.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -2742,8 +2742,8 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72F9EC3B1D5C15D0004AC8B6 /* SUConstants.m in Sources */,
|
||||
72F9EC3A1D5C04A9004AC8B6 /* SPUTemporaryDownload.m in Sources */,
|
||||
72F9EC411D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */,
|
||||
72F9EC461D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */,
|
||||
724A0A3B1CF7AEEA00D8C3D5 /* main.m in Sources */,
|
||||
7293A1B01CEE9B9800B957A7 /* SPUURLRequest.m in Sources */,
|
||||
724A0A3D1CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m in Sources */,
|
||||
@@ -2804,7 +2804,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72F9EC3C1D5C15EF004AC8B6 /* SPUTemporaryDownload.m in Sources */,
|
||||
7267E5DF1D3D8FFA00D1BF90 /* SPUInstallationInputData.m in Sources */,
|
||||
724BB3B01D3482BA005D534A /* SPUSystemAuthorization.m in Sources */,
|
||||
724BB3AA1D3347C2005D534A /* SUInstallerStatus.m in Sources */,
|
||||
@@ -2815,6 +2814,7 @@
|
||||
723B5DAA1CF7AB6A00365F95 /* SUPersistentDownloader.m in Sources */,
|
||||
72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */,
|
||||
724BB3A91D33461B005D534A /* SUXPCInstallerStatus.m in Sources */,
|
||||
72F9EC451D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */,
|
||||
72B767E31C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m in Sources */,
|
||||
72B767E71C9CFD7200A07552 /* SUAutomaticUpdateDriver.m in Sources */,
|
||||
7267E5E61D3D90AA00D1BF90 /* SUFileManager.m in Sources */,
|
||||
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SPUDownloadData.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* A class for containing downloaded data along with some information about it.
|
||||
*/
|
||||
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
/*!
|
||||
* The raw data that was downloaded.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
|
||||
/*!
|
||||
* The IANA charset encoding name if available. Eg: "utf-8"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
|
||||
|
||||
/*!
|
||||
* The MIME type if available. Eg: "text/plain"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// SPUDownloadData.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
static NSString *SPUDownloadDataKey = @"SPUDownloadData";
|
||||
static NSString *SPUDownloadTextEncodingKey = @"SPUDownloadTextEncoding";
|
||||
static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
|
||||
|
||||
@implementation SPUDownloadData
|
||||
|
||||
@synthesize data = _data;
|
||||
@synthesize textEncodingName = _textEncodingName;
|
||||
@synthesize MIMEType = _MIMEType;
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString *)MIMEType
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_data = data;
|
||||
_textEncodingName = textEncodingName;
|
||||
_MIMEType = MIMEType;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.data forKey:SPUDownloadDataKey];
|
||||
|
||||
if (self.textEncodingName != nil) {
|
||||
[coder encodeObject:self.textEncodingName forKey:SPUDownloadTextEncodingKey];
|
||||
}
|
||||
|
||||
if (self.MIMEType != nil) {
|
||||
[coder encodeObject:self.MIMEType forKey:SPUDownloadMIMETypeKey];
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUDownloadDataKey];
|
||||
if (data == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *textEncodingName = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadTextEncodingKey];
|
||||
|
||||
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadMIMETypeKey];
|
||||
|
||||
return [self initWithData:data textEncodingName:textEncodingName MIMEType:MIMEType];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+3
-2
@@ -17,6 +17,7 @@
|
||||
#import "SUUpdateAlert.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SPUApplicationInfo.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
@interface SPUStandardUserDriver ()
|
||||
|
||||
@@ -155,10 +156,10 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.activeUpdateAlert showUpdateReleaseNotesWithData:releaseNotesData textEncodingName:textEncodingName MIMEType:MIMEType];
|
||||
[self.activeUpdateAlert showUpdateReleaseNotesWithDownloadData:downloadData];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -10,10 +10,10 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUTemporaryDownload;
|
||||
@class SPUDownloadData;
|
||||
|
||||
// From the completion block, either data or error can be nil, but not both
|
||||
// The completion block returns on the main queue
|
||||
void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error));
|
||||
void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(SPUDownloadData * _Nullable download, NSError * _Nullable error));
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+5
-5
@@ -11,10 +11,10 @@
|
||||
#import "SUTemporaryDownloader.h"
|
||||
#import "SUTemporaryDownloaderProtocol.h"
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SPUTemporaryDownload.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(SPUTemporaryDownload * _Nullable, NSError * _Nullable))
|
||||
void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(SPUDownloadData * _Nullable, NSError * _Nullable))
|
||||
{
|
||||
id<SUTemporaryDownloaderProtocol> downloader = nil;
|
||||
NSXPCConnection *connection = nil;
|
||||
@@ -58,15 +58,15 @@ void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(S
|
||||
downloader = connection.remoteObjectProxy;
|
||||
}
|
||||
|
||||
[downloader startDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:request] completion:^(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error) {
|
||||
[downloader startDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:request] completion:^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedDownloadResult = YES;
|
||||
[connection invalidate];
|
||||
|
||||
if (download == nil || download.data == nil) {
|
||||
if (downloadData == nil || downloadData.data == nil) {
|
||||
completionBlock(nil, error);
|
||||
} else {
|
||||
completionBlock(download, nil);
|
||||
completionBlock(downloadData, nil);
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
Vendored
+3
-5
@@ -12,7 +12,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUUpdatePermission, SUAppcastItem;
|
||||
@class SPUUpdatePermission, SUAppcastItem, SPUDownloadData;
|
||||
|
||||
/*!
|
||||
The API in Sparkle for controlling the user interaction.
|
||||
@@ -127,13 +127,11 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
* This is only applicable if the release notes are linked from the appcast, and are not directly embedded inside of the appcast file.
|
||||
* That is, this may be invoked if the releaseNotesURL from the appcast item is non-nil.
|
||||
*
|
||||
* @param releaseNotesData The data for the release notes that was downloaded from the new update's appcast.
|
||||
* @param textEncodingName The text encoding name (eg: "utf-8"). This may be nil if one wasn't retrieved.
|
||||
* @param MIMEType The MIME type that was retrieved from the download. This may be nil if one wasn't retrieved.
|
||||
* @param downloadData The data for the release notes that was downloaded from the new update's appcast.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
|
||||
/*!
|
||||
* Show the user that the new update's release notes could not be downloaded
|
||||
|
||||
Vendored
+4
-4
@@ -15,7 +15,7 @@
|
||||
#import "SULocalizations.h"
|
||||
#import "SPUXPCServiceInfo.h"
|
||||
#import "SPUURLDownload.h"
|
||||
#import "SPUTemporaryDownload.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -77,10 +77,10 @@
|
||||
|
||||
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
||||
|
||||
SPUDownloadURLWithRequest(request, ^(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error) {
|
||||
if (download != nil) {
|
||||
SPUDownloadURLWithRequest(request, ^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
|
||||
if (downloadData != nil) {
|
||||
NSError *parseError = nil;
|
||||
NSArray *appcastItems = [self parseAppcastItemsFromXMLData:download.data error:&parseError];
|
||||
NSArray *appcastItems = [self parseAppcastItemsFromXMLData:downloadData.data error:&parseError];
|
||||
|
||||
if (appcastItems != nil) {
|
||||
self.items = appcastItems;
|
||||
|
||||
Vendored
+4
-5
@@ -15,7 +15,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SPUURLDownload.h"
|
||||
#import "SPUTemporaryDownload.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -145,10 +145,9 @@
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:updateItem.releaseNotesURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
|
||||
|
||||
id <SPUUserDriver> userDriver = self.userDriver;
|
||||
SPUDownloadURLWithRequest(request, ^(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error) {
|
||||
if (download != nil) {
|
||||
SPUTemporaryDownload *nonnullDownload = download;
|
||||
[userDriver showUpdateReleaseNotesWithData:nonnullDownload.data textEncodingName:nonnullDownload.textEncoding MIMEType:nonnullDownload.MIMEType];
|
||||
SPUDownloadURLWithRequest(request, ^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
|
||||
if (downloadData != nil) {
|
||||
[userDriver showUpdateReleaseNotesWithDownloadData:(SPUDownloadData * _Nonnull)downloadData];
|
||||
} else {
|
||||
[userDriver showUpdateReleaseNotesFailedToDownloadWithError:(NSError * _Nonnull)error];
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -15,7 +15,7 @@
|
||||
|
||||
@protocol SUUpdateAlertDelegate;
|
||||
|
||||
@class SUAppcastItem, SUHost;
|
||||
@class SUAppcastItem, SPUDownloadData, SUHost;
|
||||
@interface SUUpdateAlert : NSWindowController
|
||||
|
||||
@property (nonatomic, weak, readonly) id <SUVersionDisplay> versionDisplayer;
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer resumableCompletionBlock:(void (^)(SUInstallUpdateStatus))block;
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString *)textEncodingName MIMEType:(NSString *)MIMEType;
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
- (void)showReleaseNotesFailedToDownload;
|
||||
|
||||
- (IBAction)installUpdate:sender;
|
||||
|
||||
Vendored
+5
-4
@@ -19,6 +19,7 @@
|
||||
#import "SULog.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SPUApplicationInfo.h"
|
||||
#import "SPUUpdaterSettings.h"
|
||||
|
||||
@@ -199,16 +200,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
{
|
||||
if (!self.webViewFinishedLoading) {
|
||||
NSURL *baseURL = self.updateItem.releaseNotesURL.URLByDeletingLastPathComponent;
|
||||
// If a MIME type isn't provided, we will pick html as the default, as opposed to plain text. Questionable decision..
|
||||
NSString *chosenMIMEType = (MIMEType != nil) ? MIMEType : @"text/html";
|
||||
NSString *chosenMIMEType = (downloadData.MIMEType != nil) ? downloadData.MIMEType : @"text/html";
|
||||
// We'll pick utf-8 as the default text encoding name if one isn't provided which I think is reasonable
|
||||
NSString *chosenTextEncodingName = (textEncodingName != nil) ? textEncodingName : @"utf-8";
|
||||
NSString *chosenTextEncodingName = (downloadData.textEncodingName != nil) ? downloadData.textEncodingName : @"utf-8";
|
||||
|
||||
[[self.releaseNotesView mainFrame] loadData:releaseNotesData MIMEType:chosenMIMEType textEncodingName:chosenTextEncodingName baseURL:baseURL];
|
||||
[[self.releaseNotesView mainFrame] loadData:downloadData.data MIMEType:chosenMIMEType textEncodingName:chosenTextEncodingName baseURL:baseURL];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -27,6 +27,7 @@
|
||||
#import "SPUStandardUserDriver.h"
|
||||
#import "SPUStandardUserDriverDelegate.h"
|
||||
#import "SPUUserDriverCoreComponent.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
#import "SUUpdater.h" // deprecated
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// SPUTemporaryDownload.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUTemporaryDownload : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncoding:(NSString * _Nullable)textEncoding MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *textEncoding;
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,63 +0,0 @@
|
||||
//
|
||||
// SPUTemporaryDownload.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUTemporaryDownload.h"
|
||||
|
||||
static NSString *SPUTemporaryDownloadDataKey = @"SPUTemporaryDownloadData";
|
||||
static NSString *SPUTemporaryDownloadTextEncodingKey = @"SPUTemporaryDownloadTextEncoding";
|
||||
static NSString *SPUTemporaryDownloadMIMETypeKey = @"SPUTemporaryDownloadMIMEType";
|
||||
|
||||
@implementation SPUTemporaryDownload
|
||||
|
||||
@synthesize data = _data;
|
||||
@synthesize textEncoding = _textEncoding;
|
||||
@synthesize MIMEType = _MIMEType;
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncoding:(NSString * _Nullable)textEncoding MIMEType:(NSString *)MIMEType
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_data = data;
|
||||
_textEncoding = textEncoding;
|
||||
_MIMEType = MIMEType;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.data forKey:SPUTemporaryDownloadDataKey];
|
||||
|
||||
if (self.textEncoding != nil) {
|
||||
[coder encodeObject:self.textEncoding forKey:SPUTemporaryDownloadTextEncodingKey];
|
||||
}
|
||||
|
||||
if (self.MIMEType != nil) {
|
||||
[coder encodeObject:self.MIMEType forKey:SPUTemporaryDownloadMIMETypeKey];
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUTemporaryDownloadDataKey];
|
||||
if (data == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *textEncoding = [decoder decodeObjectOfClass:[NSString class] forKey:SPUTemporaryDownloadTextEncodingKey];
|
||||
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUTemporaryDownloadMIMETypeKey];
|
||||
|
||||
return [self initWithData:data textEncoding:textEncoding MIMEType:MIMEType];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,14 +7,14 @@
|
||||
//
|
||||
|
||||
#import "SUTemporaryDownloader.h"
|
||||
#import "SPUTemporaryDownload.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
@interface SUTemporaryDownloader () <NSURLDownloadDelegate>
|
||||
|
||||
@property (nonatomic, copy) void (^completionBlock)(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error);
|
||||
@property (nonatomic, copy) void (^completionBlock)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error);
|
||||
@property (nonatomic) NSURLDownload *download;
|
||||
@property (nonatomic, copy) NSString *downloadFilename;
|
||||
@property (nonatomic) NSURLResponse *response;
|
||||
@@ -28,7 +28,7 @@
|
||||
@synthesize downloadFilename = _downloadFilename;
|
||||
@synthesize response = _response;
|
||||
|
||||
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error))completionBlock
|
||||
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error))completionBlock
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.completionBlock = completionBlock;
|
||||
@@ -78,8 +78,8 @@
|
||||
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
|
||||
if (data != nil) {
|
||||
// See SUPersistentDownloader as to why sending the NSURLResponse object over is not a good idea
|
||||
SPUTemporaryDownload *download = [[SPUTemporaryDownload alloc] initWithData:data textEncoding:self.response.textEncodingName MIMEType:self.response.MIMEType];
|
||||
self.completionBlock(download, nil);
|
||||
SPUDownloadData *downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:self.response.textEncodingName MIMEType:self.response.MIMEType];
|
||||
self.completionBlock(downloadData, nil);
|
||||
} else {
|
||||
self.completionBlock(nil, [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", self.downloadFilename] }]);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUURLRequest;
|
||||
@class SPUTemporaryDownload;
|
||||
@class SPUDownloadData;
|
||||
|
||||
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
|
||||
@protocol SUTemporaryDownloaderProtocol
|
||||
|
||||
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUTemporaryDownload * _Nullable download, NSError * _Nullable error))completionBlock;
|
||||
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error))completionBlock;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "SPUStandardUserDriverDelegate.h"
|
||||
#import "SPUUserDriverCoreComponent.h"
|
||||
#import "SUInstallUpdateViewController.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
@interface SUPopUpTitlebarUserDriver()
|
||||
|
||||
@@ -178,7 +179,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)__unused releaseNotesData textEncodingName:(NSString * _Nullable)__unused textEncodingName MIMEType:(NSString * _Nullable)__unused MIMEType
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)__unused downloadData
|
||||
{
|
||||
// todo: this should really be implemented
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)__unused appcastItem reply:(void (^)(SUInstallUpdateStatus))__unused reply {}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)__unused releaseNotesData textEncodingName:(NSString * _Nullable)__unused textEncodingName MIMEType:(NSString * _Nullable)__unused MIMEType {}
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)__unused downloadData {}
|
||||
|
||||
- (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)__unused error {}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import "SPUCommandLineUserDriver.h"
|
||||
#import <AppKit/AppKit.h>
|
||||
#import "SPUApplicationInfo.h"
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
#define SCHEDULED_UPDATE_TIMER_THRESHOLD 2.0 // seconds
|
||||
|
||||
@@ -54,39 +55,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)idleOnUpdateChecks:(BOOL)shouldIdleOnUpdateChecks
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (shouldIdleOnUpdateChecks) {
|
||||
fprintf(stderr, "Error: Automatic update checking is disabled.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
[self.coreComponent idleOnUpdateChecks:shouldIdleOnUpdateChecks];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)startUpdateCheckTimerWithNextTimeInterval:(NSTimeInterval)timeInterval reply:(void (^)(SUUpdateCheckTimerStatus))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (timeInterval > SCHEDULED_UPDATE_TIMER_THRESHOLD) {
|
||||
if (self.verbose) {
|
||||
fprintf(stderr, "Too early to check for new updates. Next check is in %f seconds. Exiting.\n", timeInterval);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
[self.coreComponent startUpdateCheckTimerWithNextTimeInterval:timeInterval reply:reply];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)invalidateUpdateCheckTimer
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.coreComponent invalidateUpdateCheckTimer];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)requestUpdatePermissionWithSystemProfile:(NSArray *)__unused systemProfile reply:(void (^)(SPUUpdatePermission *))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -187,25 +155,25 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.verbose) {
|
||||
if ([MIMEType isEqualToString:@"text/plain"]) {
|
||||
if (downloadData.MIMEType != nil && [downloadData.MIMEType isEqualToString:@"text/plain"]) {
|
||||
NSStringEncoding encoding;
|
||||
if (textEncodingName == nil) {
|
||||
if (downloadData.textEncodingName == nil) {
|
||||
encoding = NSUTF8StringEncoding;
|
||||
} else {
|
||||
CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)textEncodingName);
|
||||
CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)downloadData.textEncodingName);
|
||||
if (cfEncoding != kCFStringEncodingInvalidId) {
|
||||
encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
|
||||
} else {
|
||||
encoding = NSUTF8StringEncoding;
|
||||
}
|
||||
}
|
||||
[self displayPlainTextReleaseNotes:releaseNotesData encoding:encoding];
|
||||
[self displayPlainTextReleaseNotes:downloadData.data encoding:encoding];
|
||||
} else {
|
||||
[self displayHTMLReleaseNotes:releaseNotesData];
|
||||
[self displayHTMLReleaseNotes:downloadData.data];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user