Browse Source

move to NextcloudKit

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
c2ea10f184

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

@@ -321,7 +321,7 @@ import XLForm
             } // else: use default
 
             NextcloudKit.shared.NCTextCreateFile(fileNamePath: fileNamePath, editorId: editorId, creatorId: creatorId, templateId: templateIdentifier, customUserAgent: customUserAgent) { account, url, error in
-                guard error.errorCode == 0, account == self.appDelegate.account, let url = url else {
+                guard error == .success, account == self.appDelegate.account, let url = url else {
                     self.navigationItem.rightBarButtonItem?.isEnabled = true
                     NCContentPresenter.shared.showError(error: error)
                     return

+ 5 - 5
iOSClient/Networking/NCNetworking.swift

@@ -254,12 +254,12 @@ import Photos
         guard let host = URL(string: NCBrandOptions.shared.pushNotificationServerProxy)?.host else { return }
 
         NextcloudKit.shared.checkServer(serverUrl: NCBrandOptions.shared.pushNotificationServerProxy) { error in
-            guard error.errorCode == 0 else {
+            guard error == .success else {
                 completion(0)
                 return
             }
 
-            if error.errorCode == 0 {
+            if error == .success {
                 NCNetworking.shared.writeCertificate(host: host)
                 completion(error.errorCode)
             } else if error.errorCode == NSURLErrorServerCertificateUntrusted {
@@ -352,7 +352,7 @@ import Photos
                 NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: selector, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal)
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
 
-            } else if error.errorCode == 0 {
+            } else if error == .success {
 
                 NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: selector, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal, etag: etag)
                 NCManageDatabase.shared.addLocalFile(metadata: metadata)
@@ -782,7 +782,7 @@ import Photos
     @objc func searchFiles(urlBase: NCUserBaseUrl, literal: String, completion: @escaping (_ metadatas: [tableMetadata]?, _ error: NKError) -> ()) {
 
         NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase, depth: "infinity", literal: literal, showHiddenFiles: CCUtility.getShowHiddenFiles(), queue: NKCommon.shared.backgroundQueue) { (account, files, error) in
-            guard error.errorCode == 0 else {
+            guard error == .success else {
                 return completion(nil, error)
             }
 
@@ -1395,7 +1395,7 @@ import Photos
             completition(URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)))
         } else {
             NextcloudKit.shared.getDirectDownload(fileId: metadata.fileId) { _, url, error in
-                if error.errorCode == 0 && url != nil {
+                if error == .success && url != nil {
                     if let url = URL(string: url!) {
                         completition(url)
                     } else {

+ 8 - 8
iOSClient/Networking/NCService.swift

@@ -83,7 +83,7 @@ class NCService: NSObject {
     private func requestServerStatus() {
 
         NextcloudKit.shared.getServerStatus(serverUrl: appDelegate.urlBase, queue: NKCommon.shared.backgroundQueue) { serverProductName, _, versionMajor, _, _, extendedSupport, error in
-            guard error.errorCode == 0, extendedSupport == false else {
+            guard error == .success, extendedSupport == false else {
                 return
             }
 
@@ -101,7 +101,7 @@ class NCService: NSObject {
         guard !appDelegate.account.isEmpty else { return }
 
         NextcloudKit.shared.getUserProfile(queue: NKCommon.shared.backgroundQueue) { account, userProfile, error in
-            guard error.errorCode == 0, account == self.appDelegate.account else {
+            guard error == .success, account == self.appDelegate.account else {
                 NCBrandColor.shared.settingThemingColor(account: account)
                 if error.errorCode == 401 || error.errorCode == 403 {
                     NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, error: error)
@@ -130,7 +130,7 @@ class NCService: NSObject {
             let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
             NextcloudKit.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, queue: NKCommon.shared.backgroundQueue) { _, _, _, etag, error in
-                guard let etag = etag, error.errorCode == 0 else {
+                guard let etag = etag, error == .success else {
                     if error.errorCode == NCGlobal.shared.errorNotModified {
                         NCManageDatabase.shared.setAvatarLoaded(fileName: fileName)
                     }
@@ -148,7 +148,7 @@ class NCService: NSObject {
         guard !appDelegate.account.isEmpty else { return }
 
         NextcloudKit.shared.getCapabilities(queue: NKCommon.shared.backgroundQueue) { account, data, error in
-            guard error.errorCode == 0, let data = data else {
+            guard error == .success, let data = data else {
                 NCBrandColor.shared.settingThemingColor(account: account)
                 if error.errorCode == 401 || error.errorCode == 403 {
                     NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, error: error)
@@ -176,7 +176,7 @@ class NCService: NSObject {
             let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
             if isFilesSharingEnabled {
                 NextcloudKit.shared.readShares(parameters: NKShareParameter(), queue: NKCommon.shared.backgroundQueue) { account, shares, error in
-                    if error.errorCode == 0 {
+                    if error == .success {
                         NCManageDatabase.shared.deleteTableShare(account: account)
                         if shares != nil {
                             NCManageDatabase.shared.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
@@ -200,7 +200,7 @@ class NCService: NSObject {
             // Text direct editor detail
             if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
                 NextcloudKit.shared.NCTextObtainEditorDetails(queue: NKCommon.shared.backgroundQueue) { account, editors, creators, error in
-                    if error.errorCode == 0 && account == self.appDelegate.account {
+                    if error == .success && account == self.appDelegate.account {
                         NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
                     }
                 }
@@ -210,7 +210,7 @@ class NCService: NSObject {
             let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true)
             if isExternalSitesServerEnabled {
                 NextcloudKit.shared.getExternalSite(queue: NKCommon.shared.backgroundQueue) { account, externalSites, error in
-                    if error.errorCode == 0 && account == self.appDelegate.account {
+                    if error == .success && account == self.appDelegate.account {
                         NCManageDatabase.shared.deleteExternalSites(account: account)
                         for externalSite in externalSites {
                             NCManageDatabase.shared.addExternalSites(externalSite, account: account)
@@ -225,7 +225,7 @@ class NCService: NSObject {
             let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
             if userStatus {
                 NextcloudKit.shared.getUserStatus(queue: NKCommon.shared.backgroundQueue) { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, error in
-                    if error.errorCode == 0 && account == self.appDelegate.account && userId == self.appDelegate.userId {
+                    if error == .success && account == self.appDelegate.account && userId == self.appDelegate.userId {
                         NCManageDatabase.shared.setAccountUserStatus(userStatusClearAt: clearAt, userStatusIcon: icon, userStatusMessage: message, userStatusMessageId: messageId, userStatusMessageIsPredefined: messageIsPredefined, userStatusStatus: status, userStatusStatusIsUserDefined: statusIsUserDefined, account: account)
                     }
                 }

+ 1 - 1
iOSClient/Notification/NCNotification.swift

@@ -229,7 +229,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
     func tapRemove(with notification: NKNotifications) {
 
         NextcloudKit.shared.setNotification(serverUrl: nil, idNotification: notification.idNotification , method: "DELETE") { (account, error) in
-            if error.errorCode == 0 && account == self.appDelegate.account {
+            if error == .success && account == self.appDelegate.account {
 
                 if let index = self.notifications
                     .firstIndex(where: { $0.idNotification == notification.idNotification })  {

+ 1 - 1
iOSClient/Share/NCShareNetworking.swift

@@ -53,7 +53,7 @@ class NCShareNetworking: NSObject {
                 NCActivityIndicator.shared.stop()
             }
 
-            if error.errorCode == 0, let shares = shares {
+            if error == .success, let shares = shares {
                 NCManageDatabase.shared.addShare(urlBase: self.urlBase, account: self.metadata.account, shares: shares)
                 self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: self.metadata.account)
             } else {

+ 1 - 1
iOSClient/Utility/NCUtility.swift

@@ -109,7 +109,7 @@ class NCUtility: NSObject {
 
             NextcloudKit.shared.downloadContent(serverUrl: iconURL.absoluteString) { _, data, error in
 
-                if error.errorCode == 0 && data != nil {
+                if error == .success && data != nil {
 
                     if let image = UIImage(data: data!) {
 

+ 2 - 2
iOSClient/Viewer/NCViewer.swift

@@ -106,7 +106,7 @@ class NCViewer: NSObject {
 
                         NCActivityIndicator.shared.stop()
 
-                        if error.errorCode == 0 && account == self.appDelegate.account && url != nil {
+                        if error == .success && account == self.appDelegate.account && url != nil {
 
                             if let navigationController = viewController.navigationController {
 
@@ -171,7 +171,7 @@ class NCViewer: NSObject {
 
                             NCActivityIndicator.shared.stop()
 
-                            if error.errorCode == 0 && account == self.appDelegate.account && url != nil {
+                            if error == .success && account == self.appDelegate.account && url != nil {
 
                                 if let navigationController = viewController.navigationController {