marinofaggiana il y a 4 ans
Parent
commit
970dcdb572

+ 1 - 1
Cartfile.resolved

@@ -18,7 +18,7 @@ github "krzyzanowskim/OpenSSL" "1.0.218"
 github "malcommac/SwiftRichString" "3.7.2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
-github "nextcloud/ios-communication-library" "4a7bc0895957097c8d7fc7c31c95e68ae5940f3a"
+github "nextcloud/ios-communication-library" "d68177986a0452540406d2c8bff7cbeef8335b25"
 github "realm/realm-cocoa" "v5.3.5"
 github "rechsteiner/Parchment" "v2.4.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 4 - 13
File Provider Extension/FileProviderData.swift

@@ -84,11 +84,8 @@ class fileProviderData: NSObject {
             accountUrlBase = tableAccount.urlBase
             homeServerUrl = NCUtility.shared.getHomeServer(urlBase: tableAccount.urlBase, account: tableAccount.account)
                         
-            NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+            NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
-            // Background session
-            NCCommunicationBackground.shared.delegate = NCNetworking.shared
-            NCCommunicationBackground.shared.setupExtensionSession(capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, allowsCellularAccess: true)
             
             return true
         }
@@ -113,11 +110,8 @@ class fileProviderData: NSObject {
                 accountUrlBase = tableAccount.urlBase
                 homeServerUrl = NCUtility.shared.getHomeServer(urlBase: tableAccount.urlBase, account: tableAccount.account)
                 
-                NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+                NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
-                // Background session
-                NCCommunicationBackground.shared.delegate = NCNetworking.shared
-                NCCommunicationBackground.shared.setupExtensionSession(capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, allowsCellularAccess: true)
 
                 foundAccount = true
             }
@@ -148,12 +142,9 @@ class fileProviderData: NSObject {
                 accountUrlBase = tableAccount.urlBase
                 homeServerUrl = NCUtility.shared.getHomeServer(urlBase: tableAccount.urlBase, account: tableAccount.account)
                 
-                NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+                NCCommunicationCommon.shared.setup(account: account, user: accountUser, userId: accountUserID, password: accountPassword, urlBase: accountUrlBase, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
-                // Background session
-                NCCommunicationBackground.shared.delegate = NCNetworking.shared
-                NCCommunicationBackground.shared.setupExtensionSession(capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, allowsCellularAccess: true)
-
+                
                 foundAccount = true
             }
         }

+ 1 - 1
File Provider Extension/FileProviderEnumerator.swift

@@ -193,7 +193,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             
             for metadata in metadatas! {
                     
-                if metadata.e2eEncrypted || (metadata.session != "" && metadata.session != NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension) { continue }
+                if metadata.e2eEncrypted || (metadata.session != "" && metadata.session != NCCommunicationCommon.shared.sessionIdentifierExtension) { continue }
                     
                 fileProviderUtility.sharedInstance.createocIdentifierOnFileSystem(metadata: metadata)
                         

+ 3 - 9
File Provider Extension/FileProviderExtension.swift

@@ -291,12 +291,11 @@ class FileProviderExtension: NSFileProviderExtension {
             CCUtility.copyFile(atPath: atPath, toPath: toPath)
         }
         guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", ocId)) else { return }
-        guard let session = NCCommunicationBackground.sessionManagerBackgroundExtension else { return }
 
         let serverUrlFileName = metadata.serverUrl + "/" + fileName
         let fileNameLocalPath = url.path
         
-        if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: metadata.ocId, session: session) {
+        if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: metadata.ocId, session: NCCommunicationBackground.shared.sessionManagerTransferExtension) {
             
             NSFileProviderManager.default.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(metadata.fileId)) { (error) in }
         }
@@ -336,11 +335,6 @@ class FileProviderExtension: NSFileProviderExtension {
                 var size = 0 as Double
                 var error: NSError?
                 
-                guard let session = NCCommunicationBackground.sessionManagerBackgroundExtension else {
-                    completionHandler(nil, NSFileProviderError(.noSuchItem))
-                    return
-                }
-                
                 guard let tableDirectory = fileProviderUtility.sharedInstance.getTableDirectoryFromParentItemIdentifier(parentItemIdentifier, account: fileProviderData.sharedInstance.account, homeServerUrl: fileProviderData.sharedInstance.homeServerUrl) else {
                     completionHandler(nil, NSFileProviderError(.noSuchItem))
                     return
@@ -373,7 +367,7 @@ class FileProviderExtension: NSFileProviderExtension {
                 fileURL.stopAccessingSecurityScopedResource()
                                 
                 let metadata = NCManageDatabase.sharedInstance.createMetadata(account: fileProviderData.sharedInstance.account, fileName: fileName, ocId: ocIdTemp, serverUrl: tableDirectory.serverUrl, urlBase: fileProviderData.sharedInstance.accountUrlBase, url: "", contentType: "", livePhoto: false)
-                metadata.session = NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension
+                metadata.session = NCCommunicationCommon.shared.sessionIdentifierExtension
                 metadata.size = size
                 metadata.status = Int(k_metadataStatusInUpload)
                 
@@ -382,7 +376,7 @@ class FileProviderExtension: NSFileProviderExtension {
                 let serverUrlFileName = tableDirectory.serverUrl + "/" + fileName
                 let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName)!
                 
-                if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: ocIdTemp, session: session) {
+                if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: ocIdTemp, session: NCCommunicationBackground.shared.sessionManagerTransferExtension) {
                     self.outstandingSessionTasks[URL(fileURLWithPath: fileNameLocalPath)] = task as URLSessionTask
                     NSFileProviderManager.default.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(ocIdTemp)) { (error) in }
                 }

+ 1 - 1
Share/ShareViewController.m

@@ -65,7 +65,7 @@
         NSString *webDav = [[NCUtility shared] getWebDAVWithAccount:tableAccount.account];
         
         // Networking
-        [[NCCommunicationCommon shared] setupWithAccount:tableAccount.account user:tableAccount.user userId:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] urlBase:tableAccount.urlBase userAgent:[CCUtility getUserAgent] webDav:webDav dav:nil nextcloudVersion:serverVersionMajor delegate:[NCNetworking shared]];
+        [[NCCommunicationCommon shared] setupWithAccount:tableAccount.account user:tableAccount.user userId:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] urlBase:tableAccount.urlBase userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups webDav:webDav dav:nil nextcloudVersion:serverVersionMajor delegate:[NCNetworking shared]];
        
         _account = tableAccount.account;
         _urlBase = tableAccount.urlBase;

+ 6 - 4
iOSClient/AppDelegate.m

@@ -83,6 +83,8 @@
         [CCUtility deleteAllChainStore];
         // remove all the App group key
         [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];
+        //
+        [self settingSetupCommunication:nil];
     } else {
         // FIX 3.0.5 lost urlbase
         if (tableAccount.urlBase.length == 0) {
@@ -460,7 +462,7 @@
 - (void)settingSetupCommunication:(NSString *)account
 {
     [[NCCommunicationCommon shared] setupWithDelegate:[NCNetworking shared]];
-    [[NCCommunicationCommon shared] setupWithUserAgent:[CCUtility getUserAgent]];
+    [[NCCommunicationCommon shared] setupWithUserAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups];
     [[NCCommunicationCommon shared] setupWithDav:[[NCUtility shared] getDAV]];
 
     if (account.length > 0) {
@@ -471,9 +473,9 @@
         [[NCCommunicationCommon shared] setupWithWebDav:[[NCUtility shared] getWebDAVWithAccount:account]];
     }
     
-    // Background session
-    [[NCCommunicationBackground shared] setupWithDelegate:[NCNetworking shared]];
-    [[NCCommunicationBackground shared] setupExtensionSessionWithCapabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups allowsCellularAccess:YES];
+    (void)[NCCommunicationBackground shared].sessionManagerTransfer;
+    (void)[NCCommunicationBackground shared].sessionManagerTransferWWan;
+    (void)[NCCommunicationBackground shared].sessionManagerTransferExtension;
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 4 - 4
iOSClient/AutoUpload/NCAutoUpload.m

@@ -395,10 +395,10 @@
         
         // Select type of session
         
-        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto == NO) session = NCCommunicationBackground.shared.sessionIdentifierBackground;
-        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo == NO) session = NCCommunicationBackground.shared.sessionIdentifierBackground;
-        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto) session = NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan;
-        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo) session = NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan;
+        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto == NO) session = NCCommunicationCommon.shared.sessionIdentifierBackground;
+        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo == NO) session = NCCommunicationCommon.shared.sessionIdentifierBackground;
+        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto) session = NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan;
+        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo) session = NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan;
         
         NSDateFormatter *formatter = [NSDateFormatter new];
         

+ 3 - 3
iOSClient/Main/CCMain.m

@@ -772,7 +772,7 @@
                     
                     tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:ocId serverUrl:serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:false];
                     
-                    metadataForUpload.session = NCCommunicationBackground.shared.sessionIdentifierBackground;
+                    metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
                     metadataForUpload.sessionSelector = selectorUploadFile;
                     metadataForUpload.size = data.length;
                     metadataForUpload.status = k_metadataStatusWaitUpload;
@@ -833,7 +833,7 @@
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
                 
-                NCCreateFormUploadAssets *form = [[NCCreateFormUploadAssets alloc] initWithServerUrl:serverUrl assets:(NSMutableArray *)assets cryptated:NO session:NCCommunicationBackground.shared.sessionIdentifierBackground delegate:self];
+                NCCreateFormUploadAssets *form = [[NCCreateFormUploadAssets alloc] initWithServerUrl:serverUrl assets:(NSMutableArray *)assets cryptated:NO session:NCCommunicationCommon.shared.sessionIdentifierBackground delegate:self];
                 
                 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:form];
                 [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
@@ -1836,7 +1836,7 @@
                 // Prepare record metadata
                 tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:ocId serverUrl:self.serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:false];
             
-                metadataForUpload.session = NCCommunicationBackground.shared.sessionIdentifierBackground;
+                metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
                 metadataForUpload.sessionSelector = selectorUploadFile;
                 metadataForUpload.size = metadata.size;
                 metadataForUpload.status = k_metadataStatusWaitUpload;

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -413,7 +413,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         //Create metadata for upload
         let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameSave, ocId: UUID().uuidString, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
         
-        metadataForUpload.session = NCCommunicationBackground.shared.sessionIdentifierBackground
+        metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground
         metadataForUpload.sessionSelector = selectorUploadFile
         metadataForUpload.status = Int(k_metadataStatusWaitUpload)
                 

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -231,7 +231,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
         
         let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileNameSave, ocId: UUID().uuidString, serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase ,url: "", contentType: "", livePhoto: false)
         
-        metadataForUpload.session = NCCommunicationBackground.shared.sessionIdentifierBackground
+        metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground
         metadataForUpload.sessionSelector = selectorUploadFile
         metadataForUpload.status = Int(k_metadataStatusWaitUpload)
         

+ 6 - 6
iOSClient/Main/NCMainCommon.swift

@@ -150,12 +150,12 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
         } else {
         
             var session: URLSession?
-            if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackground {
-                session = NCCommunicationBackground.sessionManagerBackground
-            } else if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan {
-                session = NCCommunicationBackground.sessionManagerBackgroundWWan
-            } else if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension {
-                session = NCCommunicationBackground.sessionManagerBackgroundExtension
+            if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackground {
+                session = NCCommunicationBackground.shared.sessionManagerTransfer
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan {
+                session = NCCommunicationBackground.shared.sessionManagerTransferWWan
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierExtension {
+                session = NCCommunicationBackground.shared.sessionManagerTransferExtension
             }
             
             session!.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) in

+ 18 - 20
iOSClient/Networking/NCNetworking.swift

@@ -34,7 +34,7 @@ import Queuer
     @objc optional func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, task: URLSessionTask, errorCode: Int, errorDescription: String)
 }
 
-@objc class NCNetworking: NSObject, NCCommunicationCommonDelegate, NCCommunicationBackgroundDelegate {
+@objc class NCNetworking: NSObject, NCCommunicationCommonDelegate {
     @objc public static let shared: NCNetworking = {
         let instance = NCNetworking()
         return instance
@@ -75,10 +75,8 @@ import Queuer
     
     func authenticationChallenge(_ challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
         if NCNetworking.shared.checkTrustedChallenge(challenge: challenge, directoryCertificate: CCUtility.getDirectoryCerificates()) {
-            NCCommunicationCommon.shared.writeLog("[LOG] Authentication challenge server trust")
             completionHandler(URLSession.AuthChallengeDisposition.useCredential, URLCredential.init(trust: challenge.protectionSpace.serverTrust!))
         } else {
-            NCCommunicationCommon.shared.writeLog("[LOG] Authentication challenge default handling")
             completionHandler(URLSession.AuthChallengeDisposition.performDefaultHandling, nil)
         }
     }
@@ -138,7 +136,7 @@ import Queuer
 
         BIO_free(mem)
         if x509cert == nil {
-            NCCommunicationCommon.shared.writeLog("[LOG] OpenSSL couldn't parse X509 Certificate")
+            print("[LOG] OpenSSL couldn't parse X509 Certificate")
         } else {
             if FileManager.default.fileExists(atPath: certNamePath) {
                 do {
@@ -352,10 +350,10 @@ import Queuer
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
         
-        if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackground || metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension {
-            session = NCCommunicationBackground.sessionManagerBackground
-        } else if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan {
-            session = NCCommunicationBackground.sessionManagerBackgroundWWan
+        if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackground || metadata.session == NCCommunicationCommon.shared.sessionIdentifierExtension {
+            session = NCCommunicationBackground.shared.sessionManagerTransfer
+        } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan {
+            session = NCCommunicationBackground.shared.sessionManagerTransferWWan
         }
         
         if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: metadata.creationDate as Date, dateModificationFile: metadata.date as Date, description: "", session: session!) {
@@ -448,7 +446,7 @@ import Queuer
                 
                 if metadata.status == k_metadataStatusUploadForcedStart {
                     
-                    NCManageDatabase.sharedInstance.setMetadataSession(ocId: ocId!, session: NCCommunicationBackground.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: Int(k_metadataStatusInUpload))
+                    NCManageDatabase.sharedInstance.setMetadataSession(ocId: ocId!, session: NCCommunicationCommon.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: Int(k_metadataStatusInUpload))
                     
                     NCNetworking.shared.upload(metadata: metadata) { (_, _) in }
                                             
@@ -491,9 +489,9 @@ import Queuer
     @objc func verifyUploadZombie() {
         
         var session: URLSession?
-        let sessionBackground = NCCommunicationBackground.shared.sessionIdentifierBackground
-        let sessionBackgroundWWan = NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan
-        let sessionBackgroundExtension = NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension
+        let sessionBackground = NCCommunicationCommon.shared.sessionIdentifierBackground
+        let sessionBackgroundWWan = NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan
+        let sessionBackgroundExtension = NCCommunicationCommon.shared.sessionIdentifierExtension
         
         // verify k_metadataStatusInUpload (BACKGROUND)
         let metadatasInUpload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "(session == %@ OR session == %@ OR session == %@) AND status == %d AND sessionTaskIdentifier == 0", sessionBackground, sessionBackgroundWWan, sessionBackgroundExtension, k_metadataStatusInUpload))
@@ -501,7 +499,7 @@ import Queuer
         for metadata in metadatasInUpload {
             DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
                 if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@ AND status == %d AND sessionTaskIdentifier == 0", metadata.ocId, k_metadataStatusInUpload)) {
-                    NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationBackground.shared.sessionIdentifierBackground, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: Int(k_metadataStatusWaitUpload))
+                    NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationCommon.shared.sessionIdentifierBackground, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: Int(k_metadataStatusWaitUpload))
                 }
             }
         }
@@ -511,12 +509,12 @@ import Queuer
         
         for metadata in metadatasUploading {
             
-            if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackground {
-                session = NCCommunicationBackground.sessionManagerBackground
-            } else if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan {
-                session = NCCommunicationBackground.sessionManagerBackgroundWWan
-            } else if metadata.session == NCCommunicationBackground.shared.sessionIdentifierBackgroundExtension {
-                session = NCCommunicationBackground.sessionManagerBackgroundExtension
+            if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackground {
+                session = NCCommunicationBackground.shared.sessionManagerTransfer
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan {
+                session = NCCommunicationBackground.shared.sessionManagerTransferWWan
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierExtension {
+                session = NCCommunicationBackground.shared.sessionManagerTransferExtension
             }
             
             var taskUpload: URLSessionTask?
@@ -530,7 +528,7 @@ import Queuer
                 
                 if taskUpload == nil {
                     if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@ AND status == %d", metadata.ocId, k_metadataStatusUploading)) {
-                        NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationBackground.shared.sessionIdentifierBackground, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: Int(k_metadataStatusWaitUpload))
+                        NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationCommon.shared.sessionIdentifierBackground, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: Int(k_metadataStatusWaitUpload))
                     }
                 }
             })

+ 5 - 8
iOSClient/Networking/NCNetworkingAutoUpload.swift

@@ -40,9 +40,7 @@ class NCNetworkingAutoUpload: NSObject {
         }
     }
     
-    // PRIVATE
-    
-    private func startTimer() {
+    func startTimer() {
         timerProcess = Timer.scheduledTimer(timeInterval: TimeInterval(k_timerAutoUpload), target: self, selector: #selector(process), userInfo: nil, repeats: true)
     }
 
@@ -56,18 +54,17 @@ class NCNetworkingAutoUpload: NSObject {
             return
         }
         
-        timerProcess?.invalidate()
-        
         let metadatasUpload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", k_metadataStatusInUpload, k_metadataStatusUploading))
         counterUpload = metadatasUpload.count
         for metadata in metadatasUpload {
             sizeUpload = sizeUpload + Int(metadata.size)
         }
         if sizeUpload > k_maxSizeOperationUpload {
-            startTimer()
             return
         }
-                
+        
+        timerProcess?.invalidate()
+        
         debugPrint("[LOG] PROCESS-AUTO-UPLOAD \(counterUpload)")
     
         let sessionSelectors = [selectorUploadFile, selectorUploadAutoUpload, selectorUploadAutoUploadAll]
@@ -113,7 +110,7 @@ class NCNetworkingAutoUpload: NSObject {
         if counterUpload == 0 {
             let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "status == %d", k_metadataStatusUploadError))
             for metadata in metadatas {
-                NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationBackground.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0 ,status: Int(k_metadataStatusWaitUpload))
+                NCManageDatabase.sharedInstance.setMetadataSession(ocId: metadata.ocId, session: NCCommunicationCommon.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0 ,status: Int(k_metadataStatusWaitUpload))
             }
         }
          

+ 0 - 7
iOSClient/Networking/NCService.swift

@@ -41,13 +41,6 @@ class NCService: NSObject {
             return
         }
         
-        if UIApplication.shared.applicationState == .background {
-            NCCommunicationCommon.shared.writeLog("[LOG] Request Services Server aborted because in background")
-            return
-        } else {
-            NCCommunicationCommon.shared.writeLog("[LOG] Start Request Services Server")
-        }
-
         self.requestUserProfile()
         self.requestServerStatus()
     }

+ 5 - 5
iOSClient/Transfers/CCTransfers.m

@@ -249,7 +249,7 @@
     } else {
         tableMetadata *metadata = [[NCManageDatabase sharedInstance] copyObjectWithMetadata:metadataForRecognizer];
         metadata.status = k_metadataStatusInUpload;
-        metadata.session = NCCommunicationBackground.shared.sessionIdentifierBackground;
+        metadata.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
        
         [[NCManageDatabase sharedInstance] addMetadata:metadata];
         [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
@@ -316,8 +316,8 @@
 
     NSInteger queueDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", sessionDownload] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
 
-    NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationBackground.shared.sessionIdentifierBackground] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
-    NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
+    NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackground] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
+    NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
     
     if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [sectionDataSource.sections objectAtIndex:section];
     if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSDate class]]) titleSection = [CCUtility getTitleSectionDate:[sectionDataSource.sections objectAtIndex:section]];
@@ -413,7 +413,7 @@
     // Footer Upload
     if ([titleSection containsString:@"upload"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
         
-        NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationBackground.shared.sessionIdentifierBackground] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
+        NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackground] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
         
         // element or elements ?
         if (queueUpload > 1) element_s = NSLocalizedString(@"_elements_",nil);
@@ -430,7 +430,7 @@
     // Footer Upload WWAN
     if ([titleSection containsString:@"upload"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
         
-        NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationBackground.shared.sessionIdentifierBackgroundWWan] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
+        NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan] page:0 limit:0 sorted:@"fileName" ascending:NO] count];
        
         // element or elements ?
         if (queueUploadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);

+ 1 - 1
iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m

@@ -172,7 +172,7 @@
     
     tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrlLocal urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:false];
     
-    metadataForUpload.session = NCCommunicationBackground.shared.sessionIdentifierBackground;
+    metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
     metadataForUpload.sessionSelector = selectorUploadFile;
     metadataForUpload.status = k_metadataStatusWaitUpload;