marinofaggiana 4 years ago
parent
commit
943aab75ec

+ 1 - 1
Cartfile.resolved

@@ -18,7 +18,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "52a8400313f053f1a8f082fe56d4082f7c0cfb81"
+github "nextcloud/ios-communication-library" "e68acdb51ca8edd3cab4687060557fccdef3971b"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.4"

+ 14 - 7
File Provider Extension/FileProviderData.swift

@@ -74,7 +74,8 @@ class fileProviderData: NSObject {
         if domain == nil {
             
             guard let tableAccount = NCManageDatabase.sharedInstance.getAccountActive() else { return false }
-            guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
+            let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerVersionMajor(account: tableAccount.account)
+            let webDavRoot = NCManageDatabase.sharedInstance.getCapabilitiesWebDavRoot(account: tableAccount.account)
             
             account = tableAccount.account
             accountUser = tableAccount.user
@@ -82,8 +83,8 @@ class fileProviderData: NSObject {
             accountPassword = CCUtility.getPassword(tableAccount.account)
             accountUrl = tableAccount.url
             homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
-            
-            NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
+                        
+            NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDavRoot: webDavRoot, davRoot: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.sharedInstance)
             NCNetworking.sharedInstance.delegate = providerExtension as? NCNetworkingDelegate
             
             return true
@@ -97,7 +98,10 @@ class fileProviderData: NSObject {
             guard let host = url.host else { continue }
             let accountDomain = tableAccount.userID + " (" + host + ")"
             if accountDomain == domain {
-                guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
+                
+                let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerVersionMajor(account: tableAccount.account)
+                let webDavRoot = NCManageDatabase.sharedInstance.getCapabilitiesWebDavRoot(account: tableAccount.account)
+                
                 account = tableAccount.account
                 accountUser = tableAccount.user
                 accountUserID = tableAccount.userID
@@ -106,7 +110,7 @@ class fileProviderData: NSObject {
                 accountUrl = tableAccount.url
                 homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
                 
-                NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
+                NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDavRoot: webDavRoot, davRoot: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.sharedInstance)
                 NCNetworking.sharedInstance.delegate = providerExtension as? NCNetworkingDelegate
 
                 foundAccount = true
@@ -127,7 +131,10 @@ class fileProviderData: NSObject {
         
         for tableAccount in tableAccounts {
             if accountFromItemIdentifier == tableAccount.account {
-                guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
+                
+                let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerVersionMajor(account: tableAccount.account)
+                let webDavRoot = NCManageDatabase.sharedInstance.getCapabilitiesWebDavRoot(account: tableAccount.account)
+                
                 account = tableAccount.account
                 accountUser = tableAccount.user
                 accountUserID = tableAccount.userID
@@ -135,7 +142,7 @@ class fileProviderData: NSObject {
                 accountUrl = tableAccount.url
                 homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
                 
-                NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
+                NCCommunicationCommon.sharedInstance.setup(user: accountUser, userId: accountUserID, password: accountPassword, url: accountUrl, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, webDavRoot: webDavRoot, davRoot: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.sharedInstance)
                 NCNetworking.sharedInstance.delegate = providerExtension as? NCNetworkingDelegate
                 
                 foundAccount = true

+ 4 - 3
Share/ShareViewController.m

@@ -61,10 +61,11 @@
         
     } else {
         
-        tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:tableAccount.account];
-
+        NSInteger serverVersionMajor = [[NCManageDatabase sharedInstance] getCapabilitiesServerVersionMajorWithAccount:tableAccount.account];
+        NSString *webDavRoot = [[NCManageDatabase sharedInstance] getCapabilitiesWebDavRootWithAccount:tableAccount.account];
+        
         // Networking
-        [[NCCommunicationCommon sharedInstance] setupWithUser:tableAccount.user userId:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] url:tableAccount.url userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
+        [[NCCommunicationCommon sharedInstance] setupWithUser:tableAccount.user userId:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] url:tableAccount.url userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups webDavRoot:webDavRoot davRoot:nil nextcloudVersion:serverVersionMajor delegate:[NCNetworking sharedInstance]];
        
         _activeAccount = tableAccount.account;
         

+ 2 - 1
iOSClient/AppDelegate.h

@@ -129,9 +129,10 @@
 - (void)startTimerErrorNetworking;
 - (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector openLoginWeb:(BOOL)openLoginWeb;
 
-// Setting Account
+// Setting Account & Communication
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword;
 - (void)deleteAccount:(NSString *)account wipe:(BOOL)wipe;
+- (void)settingSetupCommunicationCapabilities:(NSString *)account;
 
 // Quick Actions - ShotcutItem
 - (void)configDynamicShortcutItems;

+ 19 - 16
iOSClient/AppDelegate.m

@@ -56,7 +56,8 @@
     [CCUtility emptyTemporaryDirectory];
     
     // Networking
-    [[NCCommunicationCommon sharedInstance] setupWithUserAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups delegate:[NCNetworking sharedInstance]];
+    [[NCCommunicationCommon sharedInstance] setupWithDelegate:[NCNetworking sharedInstance]];
+    [[NCCommunicationCommon sharedInstance] setupWithUserAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups];
     
     // Verify upgrade
     if ([self upgrade]) {
@@ -426,7 +427,7 @@
 }
 
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Account =====
+#pragma mark ===== Account & Communication =====
 #pragma --------------------------------------------------------------------------------------------
 
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword
@@ -436,23 +437,11 @@
     self.activeUser = activeUser;
     self.activeUserID = activeUserID;
     self.activePassword = activePassword;
-    tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:activeAccount];
 
     (void)[NCNetworkingNotificationCenter shared];
 
-    [[NCCommunicationCommon sharedInstance] setupWithUser:activeUser userId:activeUserID password:activePassword url:activeUrl userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
-    
-    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
-    
-    NSInteger serverVersionMajor = [[NCManageDatabase sharedInstance] getCapabilitiesServerVersionMajorWithAccount:activeAccount];
-    if (serverVersionMajor > 0) {
-        [communication setupNextcloudVersion: serverVersionMajor];
-    }
-   
-    NSString *webDavRoot = [[NCManageDatabase sharedInstance] getCapabilitiesWebDavRootWithAccount:activeAccount];
-    if (webDavRoot != nil) {
-        [[NCCommunicationCommon sharedInstance] setupWithWebDavRoot:webDavRoot];
-    }
+    [[NCCommunicationCommon sharedInstance] setupWithUser:activeUser userId:activeUserID password:activePassword url:activeUrl];
+    [self settingSetupCommunicationCapabilities:activeAccount];
 }
 
 - (void)deleteAccount:(NSString *)account wipe:(BOOL)wipe
@@ -486,6 +475,20 @@
     }
 }
 
+- (void)settingSetupCommunicationCapabilities:(NSString *)account
+{
+    NSInteger serverVersionMajor = [[NCManageDatabase sharedInstance] getCapabilitiesServerVersionMajorWithAccount:account];
+    if (serverVersionMajor > 0) {
+        [[OCNetworking sharedManager].sharedOCCommunication setupNextcloudVersion: serverVersionMajor];
+        [[NCCommunicationCommon sharedInstance] setupWithNextcloudVersion:serverVersionMajor];
+     }
+    
+    NSString *webDavRoot = [[NCManageDatabase sharedInstance] getCapabilitiesWebDavRootWithAccount:account];
+    if (webDavRoot != nil) {
+        [[NCCommunicationCommon sharedInstance] setupWithWebDavRoot:webDavRoot];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Push Notifications =====
 #pragma --------------------------------------------------------------------------------------------

+ 4 - 1
iOSClient/Networking/NCService.swift

@@ -61,7 +61,7 @@ class NCService: NSObject {
                 
                 // Update User (+ userProfile.id) & active account & account network
                 guard let tableAccount = NCManageDatabase.sharedInstance.setAccountUserProfile(userProfile!) else {
-                    NCContentPresenter.shared.messageNotification("Accopunt", description: "Internal error : account not found on DB",  delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
+                    NCContentPresenter.shared.messageNotification("Account", description: "Internal error : account not found on DB",  delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
                     return
                 }
                 
@@ -147,6 +147,9 @@ class NCService: NSObject {
             
             if errorCode == 0 && data != nil {
                 NCManageDatabase.sharedInstance.addCapabilitiesJSon(data!, account: account)
+                
+                // Setup communication
+                self.appDelegate.settingSetupCommunicationCapabilities(account)
             }
         }