Browse Source

Capabilities

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
679acca0f6

+ 24 - 29
Brand/NCBrand.swift

@@ -251,46 +251,41 @@ class NCBrandColor: NSObject {
 
         if NCBrandOptions.shared.use_themingColor {
 
-            if let themingColor = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColor),
-               let themingColorElement = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorElement),
-               let themingColorText = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText) {
-
-                self.themingColor = themingColor
-                self.themingColorElement = themingColorElement
-                self.themingColorText = themingColorText
-                
-                // COLOR
-                if themingColor.first == "#" {
-                    if let color = UIColor(hex: themingColor) {
-                        brand = color
-                    } else {
-                        brand = customer
-                    }
+            self.themingColor = NCGlobal.shared.capabilityThemingColor
+            self.themingColorElement = NCGlobal.shared.capabilityThemingColorElement
+            self.themingColorText = NCGlobal.shared.capabilityThemingColorText
+
+            // COLOR
+            if themingColor.first == "#" {
+                if let color = UIColor(hex: themingColor) {
+                    brand = color
                 } else {
                     brand = customer
                 }
+            } else {
+                brand = customer
+            }
 
-                // COLOR TEXT
-                if themingColorText.first == "#" {
-                    if let color = UIColor(hex: themingColorText) {
-                        brandText = color
-                    } else {
-                        brandText = customerText
-                    }
+            // COLOR TEXT
+            if themingColorText.first == "#" {
+                if let color = UIColor(hex: themingColorText) {
+                    brandText = color
                 } else {
                     brandText = customerText
                 }
+            } else {
+                brandText = customerText
+            }
 
-                // COLOR ELEMENT
-                if themingColorElement.first == "#" {
-                    if let color = UIColor(hex: themingColorElement) {
-                        brandElement = color
-                    } else {
-                        brandElement = brand
-                    }
+            // COLOR ELEMENT
+            if themingColorElement.first == "#" {
+                if let color = UIColor(hex: themingColorElement) {
+                    brandElement = color
                 } else {
                     brandElement = brand
                 }
+            } else {
+                brandElement = brand
             }
 
             if brandElement.isTooLight() {

+ 6 - 5
File Provider Extension/FileProviderData.swift

@@ -84,7 +84,6 @@ class fileProviderData: NSObject {
         if domain == nil {
 
             guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return nil }
-            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: activeAccount.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
 
             account = activeAccount.account
             user = activeAccount.user
@@ -92,7 +91,9 @@ class fileProviderData: NSObject {
             accountUrlBase = activeAccount.urlBase
             homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId)
 
-            NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+            NCManageDatabase.shared.setCapabilities(account: account)
+
+            NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
 
             return tableAccount.init(value: activeAccount)
@@ -108,15 +109,15 @@ class fileProviderData: NSObject {
             let accountDomain = activeAccount.userId + " (" + host + ")"
             if accountDomain == domain!.identifier.rawValue {
 
-                let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: activeAccount.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-
                 account = activeAccount.account
                 user = activeAccount.user
                 userId = activeAccount.userId
                 accountUrlBase = activeAccount.urlBase
                 homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId)
 
-                NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+                NCManageDatabase.shared.setCapabilities(account: account)
+
+                NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
 
                 return tableAccount.init(value: activeAccount)

+ 4 - 2
Widget/Dashboard/DashboardData.swift

@@ -128,8 +128,10 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
     let result = NCManageDatabase.shared.getDashboardWidgetApplications(account: account.account).first
     let id: String = configuration?.applications?.identifier ?? (result?.id ?? "recommendations")
 
-    let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-    guard serverVersionMajor >= NCGlobal.shared.nextcloudVersion25 else {
+    // Capabilities
+    NCManageDatabase.shared.setCapabilities(account: account.account)
+
+    guard NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion25 else {
         return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_widget_available_nc25_", comment: "")))
     }
         

+ 4 - 2
Widget/Lockscreen/LockscreenData.swift

@@ -55,8 +55,10 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
         return completion(LockscreenData(date: Date(), isPlaceholder: true, activity: "", link: URL(string: "https://")!, quotaRelative: 0, quotaUsed: "", quotaTotal: "", error: false))
     }
 
-    let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-    if serverVersionMajor < NCGlobal.shared.nextcloudVersion25 {
+    // Capabilities
+    NCManageDatabase.shared.setCapabilities(account: account.account)
+
+    if NCGlobal.shared.capabilityServerVersionMajor < NCGlobal.shared.nextcloudVersion25 {
         completion(LockscreenData(date: Date(), isPlaceholder: false, activity: NSLocalizedString("_widget_available_nc25_", comment: ""), link: URL(string: "https://")!, quotaRelative: 0, quotaUsed: "", quotaTotal: "", error: true))
     }
 

+ 4 - 3
iOSClient/AppDelegate.swift

@@ -576,9 +576,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         _ = NCActionCenter.shared
 
         NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-        if serverVersionMajor > 0 {
-            NextcloudKit.shared.setup(nextcloudVersion: serverVersionMajor)
+        NCManageDatabase.shared.setCapabilities(account: account)
+
+        if NCGlobal.shared.capabilityServerVersionMajor > 0 {
+            NextcloudKit.shared.setup(nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor)
         }
 
         DispatchQueue.main.async {

+ 1 - 26
iOSClient/Data/NCElementsJSON.swift

@@ -29,33 +29,8 @@ import UIKit
         return instance
     }()
 
-    @objc public let capabilitiesVersionString: Array = ["ocs", "data", "version", "string"]
-    @objc public let capabilitiesVersionMajor: Array = ["ocs", "data", "version", "major"]
-
-    @objc public let capabilitiesFileSharingApiEnabled: Array = ["ocs", "data", "capabilities", "files_sharing", "api_enabled"]
-    @objc public let capabilitiesFileSharingPubPasswdEnforced: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "password", "enforced"]
-    @objc public let capabilitiesFileSharingPubExpireDateEnforced: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date", "enforced"]
-    @objc public let capabilitiesFileSharingPubExpireDateDays: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date", "days"]
-    @objc public let capabilitiesFileSharingInternalExpireDateEnforced: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_internal", "enforced"]
-    @objc public let capabilitiesFileSharingInternalExpireDateDays: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_internal", "days"]
-    @objc public let capabilitiesFileSharingRemoteExpireDateEnforced: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_remote", "enforced"]
-    @objc public let capabilitiesFileSharingRemoteExpireDateDays: Array = ["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_remote", "days"]
-    @objc public let capabilitiesFileSharingDefaultPermissions: Array = ["ocs", "data", "capabilities", "files_sharing", "default_permissions"]
-    @objc public let capabilitiesFileSharingSendPasswordMail: Array = ["ocs", "data", "capabilities", "files_sharing", "sharebymail", "send_password_by_mail"]
-
-    @objc public let capabilitiesThemingColor: Array = ["ocs", "data", "capabilities", "theming", "color"]
-    @objc public let capabilitiesThemingColorElement: Array = ["ocs", "data", "capabilities", "theming", "color-element"]
-    @objc public let capabilitiesThemingColorText: Array = ["ocs", "data", "capabilities", "theming", "color-text"]
-    @objc public let capabilitiesThemingName: Array = ["ocs", "data", "capabilities", "theming", "name"]
-    @objc public let capabilitiesThemingSlogan: Array = ["ocs", "data", "capabilities", "theming", "slogan"]
-
-    @objc public let capabilitiesWebDavRoot: Array = ["ocs", "data", "capabilities", "core", "webdav-root"]
-
-    @objc public let capabilitiesE2EEEnabled: Array = ["ocs", "data", "capabilities", "end-to-end-encryption", "enabled"]
-    @objc public let capabilitiesE2EEApiVersion: Array = ["ocs", "data", "capabilities", "end-to-end-encryption", "api-version"]
-
-    @objc public let capabilitiesExternalSites: Array = ["ocs", "data", "capabilities", "external"]
 
+    
     @objc public let capabilitiesRichdocumentsMimetypes: Array = ["ocs", "data", "capabilities", "richdocuments", "mimetypes"]
 
     @objc public let capabilitiesActivity: Array = ["ocs", "data", "capabilities", "activity", "apiv2"]

+ 42 - 0
iOSClient/Data/NCManageDatabase+Capabilities.swift

@@ -142,4 +142,46 @@ extension NCManageDatabase {
 
         return nil
     }
+
+    func setCapabilities(account: String, data: Data? = nil) {
+
+        let realm = try! Realm()
+        let json: JSON?
+
+        if let data = data {
+            json = JSON(data)
+        } else {
+            guard let result = realm.objects(tableCapabilities.self).filter("account == %@", account).first,
+                  let data = result.jsondata else {
+                return
+            }
+            json = JSON(data)
+        }
+
+        guard let json = json else { return }
+
+        NCGlobal.shared.capabilityServerVersion = json["ocs", "data", "version", "string"].stringValue
+        NCGlobal.shared.capabilityServerVersionMajor = json["ocs", "data", "version", "major"].intValue
+
+        NCGlobal.shared.capabilityFileSharingApiEnabled = json["ocs", "data", "capabilities", "files_sharing", "api_enabled"].boolValue
+        NCGlobal.shared.capabilityFileSharingPubPasswdEnforced = json["ocs", "data", "capabilities", "files_sharing", "public", "password", "enforced"].boolValue
+        NCGlobal.shared.capabilityFileSharingPubExpireDateEnforced = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date", "enforced"].boolValue
+        NCGlobal.shared.capabilityFileSharingPubExpireDateDays = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date", "days"].intValue
+        NCGlobal.shared.capabilityFileSharingInternalExpireDateEnforced = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_internal", "enforced"].boolValue
+        NCGlobal.shared.capabilityFileSharingInternalExpireDateDays = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_internal", "days"].intValue
+        NCGlobal.shared.capabilityFileSharingRemoteExpireDateEnforced = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_remote", "enforced"].boolValue
+        NCGlobal.shared.capabilityFileSharingRemoteExpireDateDays = json["ocs", "data", "capabilities", "files_sharing", "public", "expire_date_remote", "days"].intValue
+
+        NCGlobal.shared.capabilityThemingColor = json["ocs", "data", "capabilities", "theming", "color"].stringValue
+        NCGlobal.shared.capabilityThemingColorElement = json["ocs", "data", "capabilities", "theming", "color-element"].stringValue
+        NCGlobal.shared.capabilityThemingColorText = json["ocs", "data", "capabilities", "theming", "color-text"].stringValue
+        NCGlobal.shared.capabilityThemingName = json["ocs", "data", "capabilities", "theming", "name"].stringValue
+        NCGlobal.shared.capabilityThemingSlogan = json["ocs", "data", "capabilities", "theming", "slogan"].stringValue
+
+        NCGlobal.shared.capabilityE2EEEnabled = json["ocs", "data", "capabilities", "end-to-end-encryption", "enabled"].boolValue
+        NCGlobal.shared.capabilityE2EEApiVersion = json["ocs", "data", "capabilities", "end-to-end-encryption", "api-version"].stringValue
+
+        NCGlobal.shared.capabilityExternalSites = json["ocs", "data", "capabilities", "external"].exists()
+
+    }
 }

+ 3 - 3
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -236,12 +236,12 @@ extension tableMetadata {
 
     /// Return if is sharable (temp)
     // TODO: modifify for E2EE 2.0
-    func isSharable(sharing: Bool, serverVersion: Int) -> Bool {
-        guard sharing else { return false }
+    func isSharable() -> Bool {
+        guard NCGlobal.shared.capabilityFileSharingApiEnabled else { return false }
 
         if !e2eEncrypted && !isDirectoryE2EE {
             return true
-        } else if serverVersion >= NCGlobal.shared.nextcloudVersion26 && directory {
+        } else if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion26 && directory {
             // E2EE DIRECTORY SECURE FILE DROP (SHARE AVAILABLE)
             return true
         } else {

+ 8 - 10
iOSClient/Diagnostics/NCCapabilitiesView.swift

@@ -53,19 +53,15 @@ class NCCapabilitiesViewOO: ObservableObject {
         var available: Bool = false
 
         capabililies.removeAll()
-        json = ""
 
         // FILE SHARING
-        available = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        capabililies.append(Capability(text: "File sharing", image: UIImage(named: "share")!.resizeImage(size: CGSize(width: 25, height: 25))!, available: available))
+        capabililies.append(Capability(text: "File sharing", image: UIImage(named: "share")!.resizeImage(size: CGSize(width: 25, height: 25))!, available: NCGlobal.shared.capabilityFileSharingApiEnabled))
 
         // EXTERNAL SITE
-        available = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSites, exists: true)
-        capabililies.append(Capability(text: "External site", image: UIImage(systemName: "network")!, available: available))
+        capabililies.append(Capability(text: "External site", image: UIImage(systemName: "network")!, available: NCGlobal.shared.capabilityExternalSites))
 
         // E2EE
-        available = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEEnabled, exists: false)
-        capabililies.append(Capability(text: "End-to-End Encryption", image: UIImage(systemName: "lock")!, available: available))
+        capabililies.append(Capability(text: "End-to-End Encryption", image: UIImage(systemName: "lock")!, available: NCGlobal.shared.capabilityE2EEEnabled))
 
         // ACTIVITY
         if NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity) == nil {
@@ -131,9 +127,9 @@ class NCCapabilitiesViewOO: ObservableObject {
         available = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesGroupfoldersEnabled, exists: false)
         capabililies.append(Capability(text: "Group folders", image: UIImage(systemName: "person.2")!, available: available))
 
-        if let json = NCManageDatabase.shared.getCapabilities(account: account) {
-            self.json = json
-        }
+        // if let json = NCManageDatabase.shared.getCapabilities(account: account) {
+        //    self.json = json
+        // }
     }
 }
 
@@ -159,12 +155,14 @@ struct NCCapabilitiesView: View {
                 Section {
                     CapabilityName(text: capabilitiesViewOO.homeServer, image: Image(uiImage: UIImage(systemName: "house")!))
                 }
+                /*
                 Section {
                     ScrollView(.horizontal) {
                         Text(capabilitiesViewOO.json)
                             .font(.system(size: 12))
                     }
                 }
+                */
             }
         }
         .frame(maxWidth: .infinity, alignment: .top)

+ 2 - 9
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -67,9 +67,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     private var tipView: EasyTipView?
 
-    private var sharing: Bool = true
-    private var serverVersion: Int = 0
-
     // DECLARE
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
@@ -168,9 +165,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         appDelegate.activeViewController = self
 
-        sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        serverVersion = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-
         layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
         if layoutForView?.layout == NCGlobal.shared.layoutList {
@@ -987,8 +981,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.refreshControl.beginRefreshing()
         self.collectionView.reloadData()
 
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion20 {
+        if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion20 {
             NCNetworking.shared.unifiedSearchFiles(userBaseUrl: appDelegate, literal: literalSearch) { account, searchProviders in
                 self.providers = searchProviders
                 self.searchResults = []
@@ -1665,7 +1658,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         // ** IMPORT MUST BE AT THE END **
         //
 
-        if !metadata.isSharable(sharing: sharing, serverVersion: serverVersion) {
+        if !metadata.isSharable() {
             cell.hideButtonShare(true)
         }
         

+ 1 - 3
iOSClient/Main/NCActionCenter.swift

@@ -191,8 +191,6 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
     func openShare(viewController: UIViewController, metadata: tableMetadata, page: NCBrandOptions.NCInfoPagingTab) {
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-        let sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        let serverVersion = NCManageDatabase.shared.getCapabilitiesServerInt(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         var page = page
 
         NCActivityIndicator.shared.start(backgroundView: viewController.view)
@@ -215,7 +213,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 if activity == nil, let idx = pages.firstIndex(of: .activity) {
                     pages.remove(at: idx)
                 }
-                if !metadata.isSharable(sharing: sharing, serverVersion: serverVersion), let idx = pages.firstIndex(of: .sharing) {
+                if !metadata.isSharable(), let idx = pages.firstIndex(of: .sharing) {
                     pages.remove(at: idx)
                 }
                 (pages, page) = NCApplicationHandle().filterPages(pages: pages, page: page, metadata: metadata)

+ 1 - 2
iOSClient/Menu/AppDelegate+Menu.swift

@@ -37,7 +37,6 @@ extension AppDelegate {
         let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: appDelegate.account)
         let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: appDelegate.activeServerUrl, userBase: appDelegate)
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, appDelegate.activeServerUrl))
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
 
 
@@ -148,7 +147,7 @@ extension AppDelegate {
             actions.append(.seperator(order: 0))
         }
 
-        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 && directory?.richWorkspace == nil && !isDirectoryE2EE && NextcloudKit.shared.isNetworkReachable() {
+        if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion18 && directory?.richWorkspace == nil && !isDirectoryE2EE && NextcloudKit.shared.isNetworkReachable() {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_add_folder_info_", comment: ""), icon: UIImage(named: "addFolderInfo")!.image(color: UIColor.systemGray, size: 50), action: { _ in

+ 1 - 2
iOSClient/Menu/UIViewController+Menu.swift

@@ -62,8 +62,7 @@ extension UIViewController {
     func showProfileMenu(userId: String) {
 
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-        guard serverVersionMajor >= NCGlobal.shared.nextcloudVersion23 else { return }
+        guard NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion23 else { return }
 
         NextcloudKit.shared.getHovercard(for: userId) { account, card, _, _ in
             guard let card = card, account == appDelegate.account else { return }

+ 2 - 4
iOSClient/More/NCMore.swift

@@ -88,7 +88,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
 
         var item = NKExternalSite()
         var quota: String = ""
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
 
         // Clear
         functionMenu.removeAll()
@@ -131,8 +130,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         functionMenu.append(item)
 
         // ITEM : Shares
-        let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        if isFilesSharingEnabled {
+        if NCGlobal.shared.capabilityFileSharingApiEnabled {
             item = NKExternalSite()
             item.name = "_list_shares_"
             item.icon = "share"
@@ -168,7 +166,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         functionMenu.append(item)
 
         // ITEM : Trash
-        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion15 {
+        if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion15 {
             item = NKExternalSite()
             item.name = "_trash_view_"
             item.icon = "trash"

+ 25 - 0
iOSClient/NCGlobal.swift

@@ -404,4 +404,29 @@ class NCGlobal: NSObject {
     let configuration_disable_manage_account                    = "disable_manage_account"
     let configuration_disable_more_external_site                = "disable_more_external_site"
     let configuration_disable_openin_file                       = "disable_openin_file"
+
+    // CAPABILITIES
+    //
+    var capabilityServerVersionMajor: Int = 0
+    @objc var capabilityServerVersion: String = ""
+    
+    var capabilityFileSharingApiEnabled: Bool = false
+    var capabilityFileSharingPubPasswdEnforced: Bool = false
+    var capabilityFileSharingPubExpireDateEnforced: Bool = false
+    var capabilityFileSharingPubExpireDateDays: Int = 0
+    var capabilityFileSharingInternalExpireDateEnforced: Bool = false
+    var capabilityFileSharingInternalExpireDateDays: Int = 0
+    var capabilityFileSharingRemoteExpireDateEnforced: Bool = false
+    var capabilityFileSharingRemoteExpireDateDays: Int = 0
+
+    var capabilityThemingColor: String = ""
+    var capabilityThemingColorElement: String = ""
+    var capabilityThemingColorText: String = ""
+    @objc var capabilityThemingName: String = ""
+    @objc var capabilityThemingSlogan: String = ""
+
+    @objc var capabilityE2EEEnabled: Bool = false
+    @objc var capabilityE2EEApiVersion: String = ""
+
+    var capabilityExternalSites: Bool = false
 }

+ 1 - 2
iOSClient/Networking/E2EE/NCEndToEndMetadata.swift

@@ -202,7 +202,6 @@ class NCEndToEndMetadata: NSObject {
             return (0, "", NKError(errorCode: NCGlobal.shared.errorE2EE, errorDescription: "Error decoding JSON"))
         }
 
-        let versionE2EE = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion) ?? ""
         data.printJson()
 
         let decoder = JSONDecoder()
@@ -212,7 +211,7 @@ class NCEndToEndMetadata: NSObject {
         } else if (try? decoder.decode(E2eeV12.self, from: data)) != nil {
             return decoderMetadataV12(json, serverUrl: serverUrl, account: account, urlBase: urlBase, userId: userId, ownerId: ownerId)
         } else {
-            return (0, "", NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Server E2EE version " + versionE2EE + ", not compatible"))
+            return (0, "", NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Server E2EE version " + NCGlobal.shared.capabilityE2EEApiVersion + ", not compatible"))
         }
     }
 

+ 1 - 3
iOSClient/Networking/E2EE/NCNetworkingE2EE.swift

@@ -33,9 +33,7 @@ class NCNetworkingE2EE: NSObject {
 
     func isE2EEVersionWriteable(account: String) -> NKError? {
 
-        let versionE2EE = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion) ?? ""
-
-        if NCGlobal.shared.e2eeReadVersions.last == versionE2EE {
+        if NCGlobal.shared.e2eeReadVersions.last == NCGlobal.shared.capabilityE2EEApiVersion {
             return nil
         }
         

+ 1 - 2
iOSClient/Networking/NCNetworkingCheckRemoteUser.swift

@@ -27,7 +27,6 @@ class NCNetworkingCheckRemoteUser {
 
     func checkRemoteUser(account: String, error: NKError) {
 
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else {
             return
         }
@@ -40,7 +39,7 @@ class NCNetworkingCheckRemoteUser {
 
         // -----------------------
 
-        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion17 {
+        if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion17 {
 
             let token = CCUtility.getPassword(account)!
             if token.isEmpty {

+ 7 - 12
iOSClient/Networking/NCService.swift

@@ -178,33 +178,29 @@ class NCService: NSObject {
             }
 
             NCManageDatabase.shared.addCapabilitiesJSon(data, account: account)
-            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+            NCManageDatabase.shared.setCapabilities(account: account, data: data)
 
             // Setup communication
-            if serverVersionMajor > 0 {
-                NextcloudKit.shared.setup(nextcloudVersion: serverVersionMajor)
+            if NCGlobal.shared.capabilityServerVersionMajor > 0 {
+                NextcloudKit.shared.setup(nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor)
             }
 
             // Theming
-            let themingColorNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColor)
-            let themingColorElementNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorElement)
-            let themingColorTextNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText)
-            if themingColorNew != NCBrandColor.shared.themingColor || themingColorElementNew != NCBrandColor.shared.themingColorElement || themingColorTextNew != NCBrandColor.shared.themingColorText {
+            if NCGlobal.shared.capabilityThemingColor != NCBrandColor.shared.themingColor || NCGlobal.shared.capabilityThemingColorElement != NCBrandColor.shared.themingColorElement || NCGlobal.shared.capabilityThemingColorText != NCBrandColor.shared.themingColorText {
                 NCBrandColor.shared.settingThemingColor(account: account)
             }
 
             // Sharing & Comments
-            let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
             let comments = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesComments, exists: false)
             let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
-            if !isFilesSharingEnabled && !comments && activity == nil {
+            if !NCGlobal.shared.capabilityFileSharingApiEnabled && !comments && activity == nil {
                 self.appDelegate.disableSharesView = true
             } else {
                 self.appDelegate.disableSharesView = false
             }
 
             // Text direct editor detail
-            if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
+            if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
                 let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
                 NextcloudKit.shared.NCTextObtainEditorDetails(options: options) { account, editors, creators, data, error in
                     if error == .success && account == self.appDelegate.account {
@@ -214,8 +210,7 @@ class NCService: NSObject {
             }
 
             // External file Server
-            let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSites, exists: true)
-            if isExternalSitesServerEnabled {
+            if NCGlobal.shared.capabilityExternalSites {
                 NextcloudKit.shared.getExternalSite(options: options) { account, externalSites, data, error in
                     if error == .success && account == self.appDelegate.account {
                         NCManageDatabase.shared.deleteExternalSites(account: account)

+ 2 - 4
iOSClient/Settings/NCManageE2EE.swift

@@ -164,15 +164,13 @@ struct NCViewE2EE: View {
 
     var body: some View {
 
-        let versionE2EE = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion) ?? ""
-
         VStack {
 
             if manageE2EE.isEndToEndEnabled {
 
                 List {
 
-                    Section(header: Text(""), footer: Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + versionE2EE)) {
+                    Section(header: Text(""), footer: Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
                         Label {
                             Text(NSLocalizedString("_e2e_settings_activated_", comment: ""))
                         } icon: {
@@ -232,7 +230,7 @@ struct NCViewE2EE: View {
 
                 List {
 
-                    Section(header: Text(""), footer:Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + versionE2EE)) {
+                    Section(header: Text(""), footer:Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
                         HStack {
                             Label {
                                 Text(NSLocalizedString("_e2e_settings_start_", comment: ""))

+ 5 - 5
iOSClient/Settings/NCSettings.m

@@ -121,8 +121,8 @@
 
     // Section : E2EEncryption --------------------------------------------------------------
 
-    BOOL isE2EEEnabled = [[NCManageDatabase shared] getCapabilitiesServerBoolWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEEnabled exists:false];
-    NSString *versionE2EE = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEApiVersion];
+    BOOL isE2EEEnabled = [[NCGlobal shared] capabilityE2EEEnabled];
+    NSString *versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion];
 
     if (isE2EEEnabled == YES && [NCGlobal.shared.e2eeReadVersions containsObject:versionE2EE]) {
 
@@ -225,9 +225,9 @@
     
     appDelegate.activeViewController = self;
 
-    versionServer = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
-    themingName = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
-    themingSlogan = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
+    versionServer = [[NCGlobal shared] capabilityServerVersion];
+    themingName = [[NCGlobal shared] capabilityThemingName];
+    themingSlogan = [[NCGlobal shared] capabilityThemingSlogan];
 }
 
 #pragma mark - NotificationCenter

+ 6 - 6
iOSClient/Share/Advanced/NCShareCells.swift

@@ -322,15 +322,15 @@ class NCShareDateCell: UITableViewCell {
         case NCShareCommon.shared.SHARE_TYPE_LINK,
             NCShareCommon.shared.SHARE_TYPE_EMAIL,
             NCShareCommon.shared.SHARE_TYPE_GUEST:
-            return NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingPubExpireDateEnforced, exists: false)
+            return NCGlobal.shared.capabilityFileSharingPubExpireDateEnforced
         case NCShareCommon.shared.SHARE_TYPE_USER,
             NCShareCommon.shared.SHARE_TYPE_GROUP,
             NCShareCommon.shared.SHARE_TYPE_CIRCLE,
             NCShareCommon.shared.SHARE_TYPE_ROOM:
-            return NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingInternalExpireDateEnforced, exists: false)
+            return NCGlobal.shared.capabilityFileSharingInternalExpireDateEnforced
         case NCShareCommon.shared.SHARE_TYPE_REMOTE,
             NCShareCommon.shared.SHARE_TYPE_REMOTE_GROUP:
-            return NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingRemoteExpireDateEnforced, exists: false)
+            return NCGlobal.shared.capabilityFileSharingRemoteExpireDateEnforced
         default:
             return false
         }
@@ -341,15 +341,15 @@ class NCShareDateCell: UITableViewCell {
         case NCShareCommon.shared.SHARE_TYPE_LINK,
             NCShareCommon.shared.SHARE_TYPE_EMAIL,
             NCShareCommon.shared.SHARE_TYPE_GUEST:
-            return NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingPubExpireDateDays)
+            return NCGlobal.shared.capabilityFileSharingPubExpireDateDays
         case NCShareCommon.shared.SHARE_TYPE_USER,
             NCShareCommon.shared.SHARE_TYPE_GROUP,
             NCShareCommon.shared.SHARE_TYPE_CIRCLE,
             NCShareCommon.shared.SHARE_TYPE_ROOM:
-            return NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingInternalExpireDateDays)
+            return NCGlobal.shared.capabilityFileSharingInternalExpireDateDays
         case NCShareCommon.shared.SHARE_TYPE_REMOTE,
             NCShareCommon.shared.SHARE_TYPE_REMOTE_GROUP:
-            return NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingRemoteExpireDateDays)
+            return NCGlobal.shared.capabilityFileSharingRemoteExpireDateDays
         default:
             return 0
         }

+ 1 - 2
iOSClient/Share/NCShare.swift

@@ -195,8 +195,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
     }
 
     func checkEnforcedPassword(shareType: Int, completion: @escaping (String?) -> Void) {
-        guard let metadata = self.metadata,
-              NCManageDatabase.shared.getCapabilitiesServerBool(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesFileSharingPubPasswdEnforced, exists: false),
+        guard NCGlobal.shared.capabilityFileSharingPubPasswdEnforced,
               shareType == NCShareCommon.shared.SHARE_TYPE_LINK || shareType == NCShareCommon.shared.SHARE_TYPE_EMAIL
         else { return completion(nil) }
 

+ 2 - 2
iOSClient/Utility/CCUtility.m

@@ -364,8 +364,8 @@
 
 + (BOOL)isEndToEndEnabled:(NSString *)account
 {
-    BOOL isE2EEEnabled = [[NCManageDatabase shared] getCapabilitiesServerBoolWithAccount:account elements:NCElementsJSON.shared.capabilitiesE2EEEnabled exists:false];
-    NSString* versionE2EE = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:account elements:NCElementsJSON.shared.capabilitiesE2EEApiVersion];
+    BOOL isE2EEEnabled = [[NCGlobal shared] capabilityE2EEEnabled];
+    NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion];
     
     NSString *certificate = [self getEndToEndCertificate:account];
     NSString *publicKey = [self getEndToEndPublicKey:account];