|
@@ -80,8 +80,7 @@ class NCService: NSObject {
|
|
|
}
|
|
|
|
|
|
private func requestUserProfile() {
|
|
|
-
|
|
|
- if appDelegate.account == "" { return }
|
|
|
+ guard !appDelegate.account.isEmpty else { return }
|
|
|
|
|
|
NCCommunication.shared.getUserProfile(queue: NCCommunicationCommon.shared.backgroundQueue) { account, userProfile, errorCode, errorDescription in
|
|
|
|
|
@@ -143,116 +142,113 @@ class NCService: NSObject {
|
|
|
}
|
|
|
|
|
|
private func requestServerCapabilities() {
|
|
|
-
|
|
|
- if appDelegate.account == "" { return }
|
|
|
+ guard !appDelegate.account.isEmpty else { return }
|
|
|
|
|
|
NCCommunication.shared.getCapabilities(queue: NCCommunicationCommon.shared.backgroundQueue) { account, data, errorCode, errorDescription in
|
|
|
|
|
|
- if errorCode == 0 && data != nil {
|
|
|
+ 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)
|
|
|
|
|
|
- NCManageDatabase.shared.addCapabilitiesJSon(data!, account: account)
|
|
|
+ guard errorCode == 0, let data = data else {
|
|
|
+ if errorCode == 401 || errorCode == 403 {
|
|
|
+ NCBrandColor.shared.settingThemingColor(account: account)
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
|
|
|
+
|
|
|
+ NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
|
|
|
+ NCManageDatabase.shared.addCapabilitiesJSon(data, account: account)
|
|
|
+ let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
|
|
|
|
|
|
- // Setup communication
|
|
|
- if serverVersionMajor > 0 {
|
|
|
- NCCommunicationCommon.shared.setup(nextcloudVersion: serverVersionMajor)
|
|
|
- }
|
|
|
- NCCommunicationCommon.shared.setup(webDav: NCUtilityFileSystem.shared.getWebDAV(account: account))
|
|
|
+ // Setup communication
|
|
|
+ if serverVersionMajor > 0 {
|
|
|
+ NCCommunicationCommon.shared.setup(nextcloudVersion: serverVersionMajor)
|
|
|
+ }
|
|
|
+ NCCommunicationCommon.shared.setup(webDav: NCUtilityFileSystem.shared.getWebDAV(account: account))
|
|
|
|
|
|
- // Theming
|
|
|
+ // 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 != themingColor || themingColorElementNew != themingColorElement || themingColorTextNew != themingColorText {
|
|
|
NCBrandColor.shared.settingThemingColor(account: account)
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
|
|
|
+ }
|
|
|
|
|
|
- // File Sharing
|
|
|
- let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
|
|
|
- if isFilesSharingEnabled {
|
|
|
- NCCommunication.shared.readShares(parameters: NCCShareParameter(), queue: NCCommunicationCommon.shared.backgroundQueue) { account, shares, errorCode, errorDescription in
|
|
|
- if errorCode == 0 {
|
|
|
- NCManageDatabase.shared.deleteTableShare(account: account)
|
|
|
- if shares != nil {
|
|
|
- NCManageDatabase.shared.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
|
|
|
- }
|
|
|
- self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: account)
|
|
|
- } else {
|
|
|
- NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
|
|
|
+ // File Sharing
|
|
|
+ let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
|
|
|
+ if isFilesSharingEnabled {
|
|
|
+ NCCommunication.shared.readShares(parameters: NCCShareParameter(), queue: NCCommunicationCommon.shared.backgroundQueue) { account, shares, errorCode, errorDescription in
|
|
|
+ if errorCode == 0 {
|
|
|
+ NCManageDatabase.shared.deleteTableShare(account: account)
|
|
|
+ if shares != nil {
|
|
|
+ NCManageDatabase.shared.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
|
|
|
}
|
|
|
+ self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: account)
|
|
|
+ } else {
|
|
|
+ NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- 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 {
|
|
|
- self.appDelegate.disableSharesView = true
|
|
|
- } else {
|
|
|
- self.appDelegate.disableSharesView = 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)
|
|
|
|
|
|
- // Text direct editor detail
|
|
|
- if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
|
|
|
- NCCommunication.shared.NCTextObtainEditorDetails(queue: NCCommunicationCommon.shared.backgroundQueue) { account, editors, creators, errorCode, _ in
|
|
|
- if errorCode == 0 && account == self.appDelegate.account {
|
|
|
- NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if !isFilesSharingEnabled && !comments && activity == nil {
|
|
|
+ self.appDelegate.disableSharesView = true
|
|
|
+ } else {
|
|
|
+ self.appDelegate.disableSharesView = false
|
|
|
+ }
|
|
|
|
|
|
- // External file Server
|
|
|
- let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true)
|
|
|
- if isExternalSitesServerEnabled {
|
|
|
- NCCommunication.shared.getExternalSite(queue: NCCommunicationCommon.shared.backgroundQueue) { account, externalSites, errorCode, _ in
|
|
|
- if errorCode == 0 && account == self.appDelegate.account {
|
|
|
- NCManageDatabase.shared.deleteExternalSites(account: account)
|
|
|
- for externalSite in externalSites {
|
|
|
- NCManageDatabase.shared.addExternalSites(externalSite, account: account)
|
|
|
- }
|
|
|
- }
|
|
|
+ // Text direct editor detail
|
|
|
+ if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
|
|
|
+ NCCommunication.shared.NCTextObtainEditorDetails(queue: NCCommunicationCommon.shared.backgroundQueue) { account, editors, creators, errorCode, _ in
|
|
|
+ if errorCode == 0 && account == self.appDelegate.account {
|
|
|
+ NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
|
|
|
}
|
|
|
-
|
|
|
- } else {
|
|
|
- NCManageDatabase.shared.deleteExternalSites(account: account)
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // User Status
|
|
|
- let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
|
|
|
- if userStatus {
|
|
|
- NCCommunication.shared.getUserStatus(queue: NCCommunicationCommon.shared.backgroundQueue) { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, errorCode, _ in
|
|
|
- if errorCode == 0 && 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)
|
|
|
+ // External file Server
|
|
|
+ let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true)
|
|
|
+ if isExternalSitesServerEnabled {
|
|
|
+ NCCommunication.shared.getExternalSite(queue: NCCommunicationCommon.shared.backgroundQueue) { account, externalSites, errorCode, _ in
|
|
|
+ if errorCode == 0 && account == self.appDelegate.account {
|
|
|
+ NCManageDatabase.shared.deleteExternalSites(account: account)
|
|
|
+ for externalSite in externalSites {
|
|
|
+ NCManageDatabase.shared.addExternalSites(externalSite, account: account)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ NCManageDatabase.shared.deleteExternalSites(account: account)
|
|
|
+ }
|
|
|
|
|
|
- // Added UTI for Collabora
|
|
|
- if let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) {
|
|
|
- for mimeType in richdocumentsMimetypes {
|
|
|
- NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: mimeType, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: NCGlobal.shared.editorCollabora, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
|
|
|
+ // User Status
|
|
|
+ let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
|
|
|
+ if userStatus {
|
|
|
+ NCCommunication.shared.getUserStatus(queue: NCCommunicationCommon.shared.backgroundQueue) { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, errorCode, _ in
|
|
|
+ if errorCode == 0 && 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)
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // Added UTI for ONLYOFFICE & Text
|
|
|
- if let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account) {
|
|
|
- for directEditing in directEditingCreators {
|
|
|
- NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: directEditing.mimetype, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: directEditing.editor, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
|
|
|
- }
|
|
|
+ // Added UTI for Collabora
|
|
|
+ if let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) {
|
|
|
+ for mimeType in richdocumentsMimetypes {
|
|
|
+ NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: mimeType, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: NCGlobal.shared.editorCollabora, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // Handwerkcloud
|
|
|
- // let isHandwerkcloudEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesHWCEnabled, exists: false)
|
|
|
- // if (isHandwerkcloudEnabled) {
|
|
|
- // self.requestHC()
|
|
|
- // }
|
|
|
-
|
|
|
- } else if errorCode != 0 {
|
|
|
-
|
|
|
- NCBrandColor.shared.settingThemingColor(account: account)
|
|
|
-
|
|
|
- if errorCode == 401 || errorCode == 403 {
|
|
|
- NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
|
|
|
+ // Added UTI for ONLYOFFICE & Text
|
|
|
+ if let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account) {
|
|
|
+ for directEditing in directEditingCreators {
|
|
|
+ NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: directEditing.mimetype, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: directEditing.editor, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
|
|
|
}
|
|
|
-
|
|
|
- } else {
|
|
|
- NCBrandColor.shared.settingThemingColor(account: account)
|
|
|
}
|
|
|
}
|
|
|
}
|