mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-10 07:13:28 +01:00
Installs apps from AltStore via AltServer
This commit is contained in:
9
AltKit/AltKit.h
Normal file
9
AltKit/AltKit.h
Normal file
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// AltKit.h
|
||||
// AltKit
|
||||
//
|
||||
// Created by Riley Testut on 5/30/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSError+ALTServerError.h"
|
||||
17
AltKit/Bundle+AltStore.swift
Normal file
17
AltKit/Bundle+AltStore.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Bundle+AltStore.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/30/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension Bundle
|
||||
{
|
||||
struct Info
|
||||
{
|
||||
public static let deviceID = "ALTDeviceID"
|
||||
}
|
||||
}
|
||||
33
AltKit/NSError+ALTServerError.h
Normal file
33
AltKit/NSError+ALTServerError.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// NSError+ALTServerError.h
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/30/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSErrorDomain const AltServerErrorDomain;
|
||||
|
||||
typedef NS_ERROR_ENUM(AltServerErrorDomain, ALTServerError)
|
||||
{
|
||||
ALTServerErrorUnknown,
|
||||
ALTServerErrorConnectionFailed,
|
||||
ALTServerErrorLostConnection,
|
||||
|
||||
ALTServerErrorDeviceNotFound,
|
||||
ALTServerErrorDeviceWriteFailed,
|
||||
|
||||
ALTServerErrorInvalidRequest,
|
||||
ALTServerErrorInvalidResponse,
|
||||
|
||||
ALTServerErrorInvalidApp,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSError (ALTServerError)
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
14
AltKit/NSError+ALTServerError.m
Normal file
14
AltKit/NSError+ALTServerError.m
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// NSError+ALTServerError.m
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/30/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSError+ALTServerError.h"
|
||||
|
||||
NSErrorDomain const AltServerErrorDomain = @"com.rileytestut.AltServer";
|
||||
|
||||
@implementation NSError (ALTServerError)
|
||||
@end
|
||||
41
AltKit/Result+Conveniences.swift
Normal file
41
AltKit/Result+Conveniences.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Result+Conveniences.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/22/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension Result
|
||||
{
|
||||
init(_ value: Success?, _ error: Failure?)
|
||||
{
|
||||
switch (value, error)
|
||||
{
|
||||
case (let value?, _): self = .success(value)
|
||||
case (_, let error?): self = .failure(error)
|
||||
case (nil, nil): preconditionFailure("Either value or error must be non-nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension Result where Success == Void
|
||||
{
|
||||
init(_ success: Bool, _ error: Failure?)
|
||||
{
|
||||
if success
|
||||
{
|
||||
self = .success(())
|
||||
}
|
||||
else if let error = error
|
||||
{
|
||||
self = .failure(error)
|
||||
}
|
||||
else
|
||||
{
|
||||
preconditionFailure("Error must be non-nil if success is false")
|
||||
}
|
||||
}
|
||||
}
|
||||
48
AltKit/ServerProtocol.swift
Normal file
48
AltKit/ServerProtocol.swift
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ServerProtocol.swift
|
||||
// AltServer
|
||||
//
|
||||
// Created by Riley Testut on 5/24/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public let ALTServerServiceType = "_altserver._tcp"
|
||||
|
||||
// Can only automatically conform ALTServerError.Code to Codable, not ALTServerError itself
|
||||
extension ALTServerError.Code: Codable {}
|
||||
|
||||
public struct ServerRequest: Codable
|
||||
{
|
||||
public var udid: String
|
||||
public var contentSize: Int
|
||||
|
||||
public init(udid: String, contentSize: Int)
|
||||
{
|
||||
self.udid = udid
|
||||
self.contentSize = contentSize
|
||||
}
|
||||
}
|
||||
|
||||
public struct ServerResponse: Codable
|
||||
{
|
||||
public var success: Bool
|
||||
public var error: ALTServerError? {
|
||||
get {
|
||||
guard let code = self.errorCode else { return nil }
|
||||
return ALTServerError(code)
|
||||
}
|
||||
set {
|
||||
self.errorCode = newValue?.code
|
||||
}
|
||||
}
|
||||
|
||||
private var errorCode: ALTServerError.Code?
|
||||
|
||||
public init(success: Bool, error: ALTServerError?)
|
||||
{
|
||||
self.success = success
|
||||
self.error = error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user