123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import Foundation
- class NCService: NSObject, OCNetworkingDelegate, CCLoginDelegate, CCLoginDelegateWeb {
-
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
- @objc static let sharedInstance: NCService = {
- let instance = NCService()
- return instance
- }()
-
-
-
- @objc func middlewarePing() {
-
- if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
- return;
- }
-
- guard let metadataNet = CCMetadataNet.init(account: appDelegate.activeAccount) else {
- return
- }
-
- metadataNet.action = actionMiddlewarePing
- metadataNet.serverUrl = NCBrandOptions.sharedInstance.middlewarePingUrl
-
-
- }
-
-
-
-
- func getCapabilitiesOfServerSuccessFailure(_ metadataNet: CCMetadataNet!, capabilities: OCCapabilities?, message: String?, errorCode: Int) {
-
-
- if (metadataNet.account != appDelegate.activeAccount) {
- return;
- }
-
- if (errorCode == 0) {
-
-
- NCManageDatabase.sharedInstance.addCapabilities(capabilities!)
-
-
-
-
- DispatchQueue.global().async {
-
- if (NCBrandOptions.sharedInstance.use_themingBackground) {
- }
- }
-
-
-
- if (NCManageDatabase.sharedInstance.getServerVersion() != capabilities!.versionMajor && appDelegate.activeMain != nil) {
- appDelegate.activeMain.cancelSearchBar()
- }
-
-
-
- } else {
-
-
- if (errorCode == kOCErrorServerUnauthorized) {
- appDelegate.openLoginView(self, loginType: loginModifyPasswordUser)
- }
-
- let error = "Get Capabilities failure error \(errorCode) \(message!)"
- print("[LOG] \(message!)")
-
- NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionCapabilities, selector: "Get Capabilities of Server", note: error, type: k_activityTypeFailure, verbose: true, activeUrl: appDelegate.activeUrl)
-
-
- appDelegate.settingThemingColorBrand()
- }
- }
-
- @objc func requestServerCapabilities() {
-
- if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
- return;
- }
-
- guard let metadataNet = CCMetadataNet.init(account: appDelegate.activeAccount) else {
- return
- }
-
- metadataNet.action = actionGetCapabilities;
- appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
- }
-
-
-
- func loginSuccess(_ loginType: Int) {
-
-
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil)
- }
- func loginClose() {
- appDelegate.activeLogin = nil;
- }
-
- func loginWebClose() {
- appDelegate.activeLoginWeb = nil;
- }
-
- }
|