Skip to content

Commit

Permalink
Added sparkle framework
Browse files Browse the repository at this point in the history
  • Loading branch information
CodySchrank committed Apr 22, 2018
1 parent 0d2af41 commit b627cda
Show file tree
Hide file tree
Showing 494 changed files with 49,196 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
github "SwiftyBeaver/SwiftyBeaver"
github "sparkle-project/Sparkle" "ui-separation-and-xpc"

1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "SwiftyBeaver/SwiftyBeaver" "1.5.2"
github "sparkle-project/Sparkle" "67320fcb80bb802453e97542d0da4d0e6eae702d"
45 changes: 45 additions & 0 deletions Carthage/Checkouts/Sparkle/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackParameters: true
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
#DerivePointerAlignment: false
DisableFormat: false
#ForEachMacros: foreach,Q_FOREACH
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
#PointerAlignment: Right
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
Standard: Cpp03
TabWidth: 4
UseTab: Never
43 changes: 43 additions & 0 deletions Carthage/Checkouts/Sparkle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# With Carthage, if Sparkle is included as a Git submodule (e.g. with the
# --use-submodules option), the main module's .gitignore can't reach all the
# way inside the submodule to ignore the added Carthage/Build symlink, and Git
# keeps complaining about untracked changes in the submodule forever, which
# is very annoying. To avoid that issue, ignore here in Sparkle instead.
Carthage/Build

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
5 changes: 5 additions & 0 deletions Carthage/Checkouts/Sparkle/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: objective-c
osx_image: xcode9
before_install:
- brew update
script: make ci
34 changes: 34 additions & 0 deletions Carthage/Checkouts/Sparkle/Autoupdate/AgentConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// AgentConnection.h
// Sparkle
//
// Created by Mayur Pawashe on 7/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol AgentConnectionDelegate <NSObject>

- (void)agentConnectionDidInitiate;
- (void)agentConnectionDidInvalidate;

@end

@protocol SPUInstallerAgentProtocol;

@interface AgentConnection : NSObject

- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate;

- (void)startListener;
- (void)invalidate;

@property (nonatomic, readonly, nullable) id<SPUInstallerAgentProtocol> agent;
@property (nonatomic, readonly) BOOL connected;

@end

NS_ASSUME_NONNULL_END
108 changes: 108 additions & 0 deletions Carthage/Checkouts/Sparkle/Autoupdate/AgentConnection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// AgentConnection.m
// Sparkle
//
// Created by Mayur Pawashe on 7/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//

#import "AgentConnection.h"
#import "SPUMessageTypes.h"
#import "SPUInstallerAgentProtocol.h"
#import "SUInstallerAgentInitiationProtocol.h"


#include "AppKitPrevention.h"

@interface AgentConnection () <NSXPCListenerDelegate, SUInstallerAgentInitiationProtocol>

@property (nonatomic) NSXPCListener *xpcListener;
@property (nonatomic, nullable) NSXPCConnection *activeConnection;
@property (nonatomic, nullable) id<SPUInstallerAgentProtocol> agent;
@property (nonatomic, weak) id<AgentConnectionDelegate> delegate;
@property (nonatomic) BOOL connected;

@end

@implementation AgentConnection

@synthesize xpcListener = _xpcListener;
@synthesize activeConnection = _activeConnection;
@synthesize agent = _agent;
@synthesize delegate = _delegate;
@synthesize connected = _connected;

- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate
{
self = [super init];
if (self != nil) {
// Agents should always be the one that connect to daemons due to how mach bootstraps work
// For this reason, we are the ones that are creating a listener, not the agent
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUProgressAgentServiceNameForBundleIdentifier(bundleIdentifier)];
_xpcListener.delegate = self;
_delegate = delegate;
}
return self;
}

- (void)startListener
{
[self.xpcListener resume];
}

- (void)invalidate
{
self.delegate = nil;

[self.activeConnection invalidate];
self.activeConnection = nil;

[self.xpcListener invalidate];
self.xpcListener = nil;
}

- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
{
if (self.activeConnection != nil) {
[newConnection invalidate];
return NO;
}

newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentInitiationProtocol)];
newConnection.exportedObject = self;

newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SPUInstallerAgentProtocol)];

self.activeConnection = newConnection;

__weak AgentConnection *weakSelf = self;
newConnection.interruptionHandler = ^{
[weakSelf.activeConnection invalidate];
};

newConnection.invalidationHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.delegate agentConnectionDidInvalidate];
});
};

[newConnection resume];

self.agent = newConnection.remoteObjectProxy;

return YES;
}

- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
{
dispatch_async(dispatch_get_main_queue(), ^{
self.connected = YES;

[self.delegate agentConnectionDidInitiate];
self.delegate = nil;
});

acknowledgement();
}

@end
20 changes: 20 additions & 0 deletions Carthage/Checkouts/Sparkle/Autoupdate/AppInstaller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// AppInstaller.h
// Sparkle
//
// Created by Mayur Pawashe on 3/7/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SUUnarchiverProtocol.h"

@interface AppInstaller : NSObject

- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier;

- (void)start;

- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn));

@end
Loading

0 comments on commit b627cda

Please sign in to comment.