marinofaggiana vor 3 Jahren
Ursprung
Commit
a473e39b47

+ 0 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -275,7 +275,6 @@
 		F79EC784263161BA004E59D6 /* NCRenameFile.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F70D87CD25EE6E58008CBBBD /* NCRenameFile.storyboard */; };
 		F79EC78926316AC4004E59D6 /* NCPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F702F30725EE5D47008F8E80 /* NCPopupViewController.swift */; };
 		F79EDAA326B004980007D134 /* NCViewerVideoToolBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79EDA9F26B004980007D134 /* NCViewerVideoToolBar.swift */; };
-		F79EDAA426B004980007D134 /* NCKTVHTTPCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79EDAA026B004980007D134 /* NCKTVHTTPCache.swift */; };
 		F79EDAA526B004980007D134 /* NCViewerVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79EDAA126B004980007D134 /* NCViewerVideo.swift */; };
 		F79EDAA626B004980007D134 /* NCViewerAVPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79EDAA226B004980007D134 /* NCViewerAVPlayerViewController.swift */; };
 		F7A0D1352591FBC5008F8A13 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extensions.swift */; };
@@ -676,7 +675,6 @@
 		F79B645F26CA661600838ACA /* UIControl+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIControl+Extensions.swift"; sourceTree = "<group>"; };
 		F79B869A265E19D40085C0E0 /* NSMutableAttributedString+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+Extensions.swift"; sourceTree = "<group>"; };
 		F79EDA9F26B004980007D134 /* NCViewerVideoToolBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerVideoToolBar.swift; sourceTree = "<group>"; };
-		F79EDAA026B004980007D134 /* NCKTVHTTPCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCKTVHTTPCache.swift; sourceTree = "<group>"; };
 		F79EDAA126B004980007D134 /* NCViewerVideo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerVideo.swift; sourceTree = "<group>"; };
 		F79EDAA226B004980007D134 /* NCViewerAVPlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerAVPlayerViewController.swift; sourceTree = "<group>"; };
 		F7A0D1342591FBC5008F8A13 /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = "<group>"; };
@@ -1215,7 +1213,6 @@
 			isa = PBXGroup;
 			children = (
 				F79EDA9F26B004980007D134 /* NCViewerVideoToolBar.swift */,
-				F79EDAA026B004980007D134 /* NCKTVHTTPCache.swift */,
 				F79EDAA126B004980007D134 /* NCViewerVideo.swift */,
 				F79EDAA226B004980007D134 /* NCViewerAVPlayerViewController.swift */,
 			);
@@ -2128,7 +2125,6 @@
 				F7DFB7F0219C5B8000680748 /* NCCreateFormUploadAssets.swift in Sources */,
 				F73B422C2476764F00A30FD3 /* NCNotification.swift in Sources */,
 				371B5A2E23D0B04500FAFAE9 /* NCMenu.swift in Sources */,
-				F79EDAA426B004980007D134 /* NCKTVHTTPCache.swift in Sources */,
 				F79EDAA326B004980007D134 /* NCViewerVideoToolBar.swift in Sources */,
 				F77444F8222816D5000D5EB0 /* NCPickerViewController.swift in Sources */,
 				F72A47EC2487B06B005AD489 /* NCOperationQueue.swift in Sources */,

+ 0 - 129
iOSClient/Viewer/NCViewerVideo/NCKTVHTTPCache.swift

@@ -1,129 +0,0 @@
-//
-//  NCKTVHTTPCache.swift
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 28/10/2020.
-//  Copyright © 2020 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-import UIKit
-import KTVHTTPCache
-
-class NCKTVHTTPCache: NSObject {
-    @objc static let shared: NCKTVHTTPCache = {
-        let instance = NCKTVHTTPCache()
-        instance.setupHTTPCache()
-        return instance
-    }()
-    
-    func getVideoURL(metadata: tableMetadata) -> URL? {
-        
-        if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-            
-            return URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            
-        } else {
-            
-            guard let stringURL = (metadata.serverUrl + "/" + metadata.fileName).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { return nil }
-            
-            return NCKTVHTTPCache.shared.getProxyURL(stringURL: stringURL)
-        }
-    }
-    
-    func startProxy(user: String, password: String, metadata: tableMetadata) {
-        
-        guard let authData = (user + ":" + password).data(using: .utf8) else { return }
-        
-        let authValue = "Basic " + authData.base64EncodedString(options: [])
-        KTVHTTPCache.downloadSetAdditionalHeaders(["Authorization":authValue, "User-Agent":CCUtility.getUserAgent()])
-        
-        if !KTVHTTPCache.proxyIsRunning() {
-            do {
-                try KTVHTTPCache.proxyStart()
-            } catch let error {
-                print("Proxy Start error : \(error)")
-            }
-        }        
-    }
-    
-    func stopProxy(metadata: tableMetadata) {
-        
-        if KTVHTTPCache.proxyIsRunning() {
-            KTVHTTPCache.proxyStop()
-        }
-        
-        saveCache(metadata: metadata)
-    }
-    
-    func getProxyURL(stringURL: String) -> URL {
-        
-        return KTVHTTPCache.proxyURL(withOriginalURL: URL(string: stringURL))
-    }
-    
-    func getCacheCompleteFileURL(videoURL: URL?) -> URL? {
-        
-        return KTVHTTPCache.cacheCompleteFileURL(with: videoURL)
-    }
-    
-    func deleteCache(videoURL: URL?) {
-        
-        KTVHTTPCache.cacheDelete(with: videoURL)
-    }
-    
-    func saveCache(metadata: tableMetadata) {
-        
-        if !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView:metadata.fileNameView) {
-            
-            guard let stringURL = (metadata.serverUrl + "/" + metadata.fileName).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { return }
-            
-            let videoURL = URL(string: stringURL)
-            guard let url = KTVHTTPCache.cacheCompleteFileURL(with: videoURL) else { return }
-            
-            CCUtility.copyFile(atPath: url.path, toPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            NCManageDatabase.shared.addLocalFile(metadata: metadata)
-            KTVHTTPCache.cacheDelete(with: videoURL)
-            
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
-        }
-    }
-    
-    private func setupHTTPCache() {
-        
-        KTVHTTPCache.cacheSetMaxCacheLength(NCGlobal.shared.maxHTTPCache)
-        
-        if ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] != nil {
-            KTVHTTPCache.logSetConsoleLogEnable(true)
-        }
-        
-        do {
-            try KTVHTTPCache.proxyStart()
-        } catch let error {
-            print("Proxy Start error : \(error)")
-        }
-        
-        KTVHTTPCache.encodeSetURLConverter { (url) -> URL? in
-            print("URL Filter reviced URL : " + String(describing: url))
-            return url
-        }
-        
-        KTVHTTPCache.downloadSetUnacceptableContentTypeDisposer { (url, contentType) -> Bool in
-            print("Unsupport Content-Type Filter reviced URL : " + String(describing: url) + " " + String(describing: contentType))
-            return false
-        }
-    }
-}

+ 2 - 13
iOSClient/Viewer/NCViewerVideo/NCViewerAVPlayerViewController.swift

@@ -49,9 +49,7 @@ class NCViewerAVPlayerViewController: AVPlayerViewController {
     
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
-        
-        NCKTVHTTPCache.shared.startProxy(user: appDelegate.user, password: appDelegate.password, metadata: metadata)
-        
+                
         func play(url: URL) {
             
             player = AVPlayer(url: url)
@@ -101,19 +99,11 @@ class NCViewerAVPlayerViewController: AVPlayerViewController {
             
         } else {
             
-            /*
             NCCommunication.shared.getDirectDownload(fileId: metadata.fileId) { account, url, errorCode, errorDescription in
-                
                 if let url = URL(string: url) {
                     play(url: url)
                 }
             }
-            */
-            
-            if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
-                play(url: url)
-            }
-            
         }
     }
     
@@ -132,7 +122,6 @@ class NCViewerAVPlayerViewController: AVPlayerViewController {
             if rateObserverToken != nil {
                 player?.removeObserver(self, forKeyPath: "rate")
                 NotificationCenter.default.removeObserver(self, name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil)
-                NCKTVHTTPCache.shared.stopProxy(metadata: metadata)
                 self.rateObserverToken = nil
             }
         }
@@ -141,7 +130,7 @@ class NCViewerAVPlayerViewController: AVPlayerViewController {
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
         
         if keyPath != nil && keyPath == "rate" {
-           NCKTVHTTPCache.shared.saveCache(metadata: metadata)
+           //NCKTVHTTPCache.shared.saveCache(metadata: metadata)
         }
     }
 }