Skip to content

Commit

Permalink
Merge pull request #1607 from Provenance-Emu/feature/nitotv
Browse files Browse the repository at this point in the history
Add nitotv methods for tvOS
  • Loading branch information
JoeMatt committed Oct 20, 2021
2 parents 68b3ffe + 0658a66 commit 8549d80
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
8 changes: 6 additions & 2 deletions PVLibrary/PVLibrary/Importer/iCloudSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,12 @@ public final class iCloudSync {
public static func initICloudDocuments() {
let fm = FileManager.default
if let currentiCloudToken = fm.ubiquityIdentityToken {
let newTokenData = NSKeyedArchiver.archivedData(withRootObject: currentiCloudToken)
UserDefaults.standard.set(newTokenData, forKey: UbiquityIdentityTokenKey)
do {
let newTokenData = try NSKeyedArchiver.archivedData(withRootObject: currentiCloudToken, requiringSecureCoding: false)
UserDefaults.standard.set(newTokenData, forKey: UbiquityIdentityTokenKey)
} catch {
ELOG("\(error.localizedDescription)")
}
} else {
UserDefaults.standard.removeObject(forKey: UbiquityIdentityTokenKey)
}
Expand Down
4 changes: 4 additions & 0 deletions Provenance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
B324C651219216FF009F4EDC /* PVLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B324C64E219216DD009F4EDC /* PVLibrary.framework */; };
B32746BD219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32746BC219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift */; };
B32746BE219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32746BC219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift */; };
B3290499270D1F95002707AC /* PVAppDelegate+NitoTV.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3290498270D1F95002707AC /* PVAppDelegate+NitoTV.swift */; };
B32D8F801EA7FDB900175FBF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A3D409717B2DCE4004DFFFC /* UIKit.framework */; };
B32D8F821EA7FDBE00175FBF /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B32D8F811EA7FDBE00175FBF /* GameController.framework */; };
B33468D320AB347300092CA6 /* CenterFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33468D120AB347300092CA6 /* CenterFlowLayout.swift */; };
Expand Down Expand Up @@ -729,6 +730,7 @@
B324C6212192059E009F4EDC /* PVMednafen.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PVMednafen.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B324C64E219216DD009F4EDC /* PVLibrary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PVLibrary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B32746BC219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PVGameLibraryCollectionFlowLayout.swift; sourceTree = "<group>"; };
B3290498270D1F95002707AC /* PVAppDelegate+NitoTV.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PVAppDelegate+NitoTV.swift"; sourceTree = "<group>"; };
B32D8F811EA7FDBE00175FBF /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
B33468D120AB347300092CA6 /* CenterFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterFlowLayout.swift; sourceTree = "<group>"; };
B33468D520AB392C00092CA6 /* CollectionViewInCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewInCollectionViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1133,6 +1135,7 @@
isa = PBXGroup;
children = (
1A3D40A717B2DCE4004DFFFC /* PVAppDelegate.swift */,
B3290498270D1F95002707AC /* PVAppDelegate+NitoTV.swift */,
B357A43B2709228E002C7C0F /* PVAppDelegate+AppCenter.swift */,
1AADCDB117BD997500F53CFE /* Categories */,
1A47C94A17BC310700C27644 /* Controller */,
Expand Down Expand Up @@ -2329,6 +2332,7 @@
1A2B13CD1D0DFF5100D0B863 /* PVSearchViewController.swift in Sources */,
1AD481DC1BA3544500FDA50A /* GCDWebServerDataRequest.m in Sources */,
B32746BE219BD65F00B78124 /* PVGameLibraryCollectionFlowLayout.swift in Sources */,
B3290499270D1F95002707AC /* PVAppDelegate+NitoTV.swift in Sources */,
B3B104C3218F2EF400210C39 /* PVAtari7800ControllerViewController.swift in Sources */,
B3E3B5DA202ED84100A11871 /* PVGameLibraryViewController.swift in Sources */,
B3D534E320AFF21900A83D4E /* Version.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
parallelizeBuildables = "YES"
buildImplicitDependencies = "NO">
<BuildActionEntries>
<BuildActionEntry
Expand Down
52 changes: 52 additions & 0 deletions Provenance/PVAppDelegate+NitoTV.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// PVAppDelegate+NitoTV.swift
// ProvenanceTV
//
// Created by Joseph Mattiello on 10/5/21.
// Copyright © 2021 Provenance Emu. All rights reserved.
//

import Foundation
import UIKit
import PVSupport

@objc
extension PVAppDelegate {
public func importFile(atURL url: URL) {

let man = FileManager.default
ILOG("[Provenance] host: \(url.host ?? "nil") path: \(url.path)")
let cache = uploadDirectory
do {
let attrs = try man.attributesOfItem(atPath: cache.path)
ILOG("[Provenance] cache attrs: \(attrs), cache path: \(cache)")
let last = url.lastPathComponent
let newPath = cache.appendingPathComponent(last)
let originalPath = url
try man.copyItem(at: originalPath, to: newPath)
} catch {
ELOG("\(error.localizedDescription)")
}
}

var uploadDirectory: URL {
let man = FileManager.default
let paths = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)
let first: URL = URL(string: paths.first!)!
let cache: URL = first.appendingPathComponent("Imports")
let path = cache.path
if !man.fileExists(atPath: path) {
WLOG("this path wasnt found; \(cache)")
let folderAttrs: [FileAttributeKey: Any] = [
.groupOwnerAccountName: "staff",
.ownerAccountName: "mobile"
]
do {
try man.createDirectory(at: cache, withIntermediateDirectories: true, attributes: folderAttrs)
} catch {
ELOG("\(error.localizedDescription)")
}
}
return cache
}
}
6 changes: 6 additions & 0 deletions Provenance/PVAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ final class PVAppDelegate: UIResponder, UIApplicationDelegate {
}

func application(_: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {

#if os(tvOS)
importFile(atURL: url)
return true
#else
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)

if url.isFileURL {
Expand Down Expand Up @@ -227,6 +232,7 @@ final class PVAppDelegate: UIResponder, UIApplicationDelegate {
}

return false
#endif
}

#if os(iOS)
Expand Down

0 comments on commit 8549d80

Please sign in to comment.