Added sending correct DevMate update requests.

This commit is contained in:
Dmytro Tretiakov committed 2015-07-06 17:37:21 +03:00
1 parent 4149bf0103
commit 90f35f87dc
8 files changed
+75 -2

No files matched your search

BIN
View File
Binary file not shown.
+12
View File
@@ -49,6 +49,7 @@
14950073195FCE4E00BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */ = {isa = PBXBuildFile; fileRef = 14958C6B19AEBC530061B14F /* signed-test-file.txt */; };
14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14958C6C19AEBC610061B14F /* test-pubkey.pem */; };
331726611B4ABAEB008B2D77 /* libDMCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 331726601B4ABABD008B2D77 /* libDMCore.a */; };
33545B8D1B4679080059250D /* com.devmate.UpdateInstaller.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 33545B811B4679080059250D /* com.devmate.UpdateInstaller.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
33545B921B4679810059250D /* install_service.m in Sources */ = {isa = PBXBuildFile; fileRef = 33545B771B46774D0059250D /* install_service.m */; };
33545B931B4687CD0059250D /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
@@ -371,6 +372,7 @@
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdaterTest.m; sourceTree = "<group>"; usesTabs = 0; };
14958C6B19AEBC530061B14F /* signed-test-file.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "signed-test-file.txt"; sourceTree = "<group>"; };
14958C6C19AEBC610061B14F /* test-pubkey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "test-pubkey.pem"; sourceTree = "<group>"; };
331726601B4ABABD008B2D77 /* libDMCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libDMCore.a; path = External/libDMCore.a; sourceTree = "<group>"; };
33545B771B46774D0059250D /* install_service.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = install_service.m; sourceTree = "<group>"; };
33545B781B46774D0059250D /* install_service.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = install_service.pch; sourceTree = "<group>"; };
33545B791B46774D0059250D /* SandboxService.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = SandboxService.plist; sourceTree = "<group>"; };
@@ -682,6 +684,7 @@
61B5F8F709C4CEB300B25A18 /* Security.framework in Frameworks */,
55C14F32136EFC2400649790 /* SystemConfiguration.framework in Frameworks */,
61B5FC4C09C4FD5E00B25A18 /* WebKit.framework in Frameworks */,
331726611B4ABAEB008B2D77 /* libDMCore.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -722,6 +725,7 @@
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
331726601B4ABABD008B2D77 /* libDMCore.a */,
0867D6A5FE840307C02AAC07 /* AppKit.framework */,
525A278F133D6AE900FD8D70 /* Cocoa.framework */,
0867D69BFE84028FC02AAC07 /* Foundation.framework */,
@@ -1891,6 +1895,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */;
buildSettings = {
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/External",
);
};
name = Debug;
};
@@ -1898,6 +1906,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941D50D94A70100DD942E /* ConfigFrameworkRelease.xcconfig */;
buildSettings = {
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/External",
);
};
name = Release;
};
+25
View File
@@ -60,6 +60,31 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)downloadReleaseNotesAndWaitUntilDone
{
NSURL *releaseNotesURL = self.updateItem.releaseNotesURL;
if (nil == releaseNotesURL || [releaseNotesURL isFileURL])
return;
static NSString * const kSUAutomaticUpdateParamName = @"autoupdate";
NSString *URLString = releaseNotesURL.absoluteString;
URLString = [URLString stringByAppendingFormat:@"%@%@=1", (releaseNotesURL.query != nil) ? @"&" : @"?", kSUAutomaticUpdateParamName];
releaseNotesURL = [NSURL URLWithString:URLString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:releaseNotesURL];
[request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
[self updateURLRequestHTTPHeaders:request];
[NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
}
- (void)didFindValidUpdate
{
// For correct DevMate statistics need to send request for Release Notes.
[self downloadReleaseNotesAndWaitUntilDone];
[super didFindValidUpdate];
}
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
+1
View File
@@ -31,6 +31,7 @@
- (void)didFindValidUpdate;
- (void)didNotFindUpdate;
- (void)updateURLRequestHTTPHeaders:(NSMutableURLRequest *)request;
- (void)downloadUpdate;
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
- (void)downloadDidFinish:(NSURLDownload *)d;
+23 -1
View File
@@ -22,6 +22,8 @@
#import "SUUpdater_Private.h"
#import "SUXPCInstaller.h"
CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFDataRef httpBodyData);
@interface SUBasicUpdateDriver ()
@property (strong) SUAppcastItem *updateItem;
@@ -53,10 +55,14 @@
return;
}
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
request.allHTTPHeaderFields = [self.updater httpHeaders];
[self updateURLRequestHTTPHeaders:request];
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setUserAgentString:[self.updater userAgentString]];
[appcast setHttpHeaders:[self.updater httpHeaders]];
[appcast setHttpHeaders:request.allHTTPHeaderFields];
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
if (error) {
[self abortUpdateWithError:error];
@@ -188,10 +194,26 @@
}]];
}
- (void)updateURLRequestHTTPHeaders:(NSMutableURLRequest *)request
{
CFBundleRef hostBundle = CFBundleCreate(kCFAllocatorDefault, (__bridge CFURLRef)[NSURL fileURLWithPath:self.host.bundlePath]);
NSDictionary *devmateHeaders = (__bridge_transfer NSDictionary *)DMCopyHTTPRequestHeaders(hostBundle, NULL);
if (devmateHeaders.count)
{
[request setAllHTTPHeaderFields:devmateHeaders];
}
if (NULL != hostBundle)
{
CFRelease(hostBundle);
}
}
- (void)downloadUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
[self updateURLRequestHTTPHeaders:request];
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
+5
View File
@@ -32,6 +32,11 @@
[self updateAlertFinishedWithChoice:choice];
}];
__weak SUUIBasedUpdateDriver *weakSelf = self;
self.updateAlert.releaseNotesRequestModifier = ^(NSMutableURLRequest *request) {
[weakSelf updateURLRequestHTTPHeaders:request];
};
id<SUVersionDisplay> versDisp = nil;
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[self.updater delegate] versionDisplayerForUpdater:self.updater];
+1
View File
@@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
@interface SUUpdateAlert : SUWindowController
@property (weak) id<SUVersionDisplay> versionDisplayer;
@property (copy) void (^releaseNotesRequestModifier)(NSMutableURLRequest *request);
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host completionBlock:(void(^)(SUUpdateAlertChoice))c;
+8 -1
View File
@@ -135,7 +135,14 @@
}
else
{
[[self.releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.updateItem.releaseNotesURL
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30];
if (self.releaseNotesRequestModifier != nil)
{
self.releaseNotesRequestModifier(request);
}
[[self.releaseNotesView mainFrame] loadRequest:request];
}
}
else