Browse Source

clear code

Marino Faggiana 6 years ago
parent
commit
4978a17912

+ 2 - 3
File Provider Extension/FileProviderEnumerator.swift

@@ -143,14 +143,13 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
                 serverUrlForFileName = (serverUrl as NSString).deletingLastPathComponent
             }
             
-            let ocNetworking = OCnetworking.init()
-            ocNetworking.readFile(withAccount: providerData.account, serverUrl: serverUrlForFileName, fileName: fileName, completion: { (account, metadata, message, errorCode) in
+            OCnetworking.sharedManager().readFile(withAccount: providerData.account, serverUrl: serverUrlForFileName, fileName: fileName, completion: { (account, metadata, message, errorCode) in
                 
                 if errorCode == 0 && account == self.providerData.account {
                     
                     if self.providerData.listServerUrlEtag[serverUrl] == nil || self.providerData.listServerUrlEtag[serverUrl] != metadata!.etag || metadatasFromDB == nil {
                         
-                        ocNetworking.readFolder(withAccount: self.providerData.account, serverUrl: serverUrl, depth: "1", completion: { (account, metadatas, metadataFolder, message, errorCode) in
+                        OCnetworking.sharedManager().readFolder(withAccount: self.providerData.account, serverUrl: serverUrl, depth: "1", completion: { (account, metadatas, metadataFolder, message, errorCode) in
                             
                             if errorCode == 0 && account == self.providerData.account {
                                 

+ 3 - 6
File Provider Extension/FileProviderExtension+Actions.swift

@@ -40,8 +40,7 @@ extension FileProviderExtension {
         
         let serverUrl = tableDirectory.serverUrl
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.createFolder(withAccount: providerData.account, serverUrl: serverUrl, fileName: directoryName, completion: { (account, fileID, date, message, errorCode) in
+        OCnetworking.sharedManager().createFolder(withAccount: providerData.account, serverUrl: serverUrl, fileName: directoryName, completion: { (account, fileID, date, message, errorCode) in
             
             if errorCode == 0 && account == self.providerData.account {
                 
@@ -150,8 +149,7 @@ extension FileProviderExtension {
         let serverUrlTo = tableDirectoryTo.serverUrl
         let fileNameTo = serverUrlTo + "/" + itemFrom.filename
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.moveFileOrFolder(withAccount:  providerData.account, fileName: fileNameFrom, fileNameTo: fileNameTo, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().moveFileOrFolder(withAccount:  providerData.account, fileName: fileNameFrom, fileNameTo: fileNameTo, completion: { (account, message, errorCode) in
             
             if errorCode == 0 && account == self.providerData.account {
                 
@@ -206,8 +204,7 @@ extension FileProviderExtension {
         let fileNamePathFrom = metadata.serverUrl + "/" + fileNameFrom
         let fileNamePathTo = metadata.serverUrl + "/" + itemName
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.moveFileOrFolder(withAccount: providerData.account, fileName: fileNamePathFrom, fileNameTo: fileNamePathTo, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().moveFileOrFolder(withAccount: providerData.account, fileName: fileNamePathFrom, fileNameTo: fileNamePathTo, completion: { (account, message, errorCode) in
             
             if errorCode == 0 && account == self.providerData.account {
                 

+ 2 - 4
File Provider Extension/FileProviderExtension+Network.swift

@@ -33,8 +33,7 @@ extension FileProviderExtension {
         
         let path = metadata.serverUrl + "/" + metadata.fileName
 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.deleteFileOrFolder(withAccount: providerData.account, path: path, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().deleteFileOrFolder(withAccount: providerData.account, path: path, completion: { (account, message, errorCode) in
             if errorCode == 0 || errorCode == 404 {
                 self.deleteFileSystem(for: metadata, serverUrl: metadata.serverUrl, itemIdentifier: itemIdentifier)
             }
@@ -67,8 +66,7 @@ extension FileProviderExtension {
         
         let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: self.providerData.accountUrl)
 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.settingFavorite(withAccount: providerData.account, fileName: fileNamePath, favorite: favorite, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().settingFavorite(withAccount: providerData.account, fileName: fileNamePath, favorite: favorite, completion: { (account, message, errorCode) in
             if errorCode == 0 && account == self.providerData.account {
                 // Change DB
                 metadata.favorite = favorite

+ 1 - 2
File Provider Extension/FileProviderExtension+Thumbnail.swift

@@ -46,8 +46,7 @@ extension FileProviderExtension {
                     let width = NCUtility.sharedInstance.getScreenWidthForPreview()
                     let height = NCUtility.sharedInstance.getScreenHeightForPreview()
                     
-                    let ocNetworking = OCnetworking.init()
-                    ocNetworking.downloadPreview(withAccount: providerData.account, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
+                    OCnetworking.sharedManager().downloadPreview(withAccount: providerData.account, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
                        
                         if errorCode == 0 && account == self.providerData.account {
                             do {

+ 1 - 2
File Provider Extension/FileProviderExtension.swift

@@ -238,8 +238,7 @@ class FileProviderExtension: NSFileProviderExtension, CCNetworkingDelegate {
             return
         }
             
-        let ocNetworking = OCnetworking.init()
-        let task = ocNetworking.download(withAccount: providerData.account, fileNameServerUrl: metadata.serverUrl + "/" + metadata.fileName, fileNameLocalPath: url.path, communication: CCNetworking.shared().sharedOCCommunicationExtensionDownload(), completion: { (account, lenght, etag, date, message, errorCode) in
+        let task = OCnetworking.sharedManager().download(withAccount: providerData.account, fileNameServerUrl: metadata.serverUrl + "/" + metadata.fileName, fileNameLocalPath: url.path, communication: CCNetworking.shared().sharedOCCommunicationExtensionDownload(), completion: { (account, lenght, etag, date, message, errorCode) in
             
             if errorCode == 0 && account == self.providerData.account {
                 

+ 1 - 2
iOSClient/Activity/CCActivity.m

@@ -147,8 +147,7 @@
 
 - (void)getActivity
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking getActivityWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *listOfActivity, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] getActivityWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *listOfActivity, NSString *message, NSInteger errorCode) {
         if (errorCode == 0) {
             [[NCManageDatabase sharedInstance] addActivityServer:listOfActivity account:account];
         }

+ 3 - 6
iOSClient/AppDelegate.m

@@ -392,8 +392,6 @@
     if (self.activeAccount.length == 0 || self.maintenanceMode)
         return;
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-
     [[NCPushNotificationEncryption sharedInstance] generatePushNotificationsKeyPair];
 
     NSString *pushToken = [CCUtility getPushNotificationToken];
@@ -403,8 +401,8 @@
     self.pnDeviceIdentifier = nil;
     self.pnDeviceIdentifierSignature = nil;
     self.pnPublicKey = nil;
-    
-    [ocNetworking subscribingPushNotificationWithAccount:self.activeAccount url:self.activeUrl pushToken:pushToken Hash:pushTokenHash devicePublicKey:devicePublicKey completion:^(NSString *account, NSString *deviceIdentifier, NSString *deviceIdentifierSignature, NSString *publicKey, NSString *message, NSInteger errorCode) {
+
+    [[OCnetworking sharedManager] subscribingPushNotificationWithAccount:self.activeAccount url:self.activeUrl pushToken:pushToken Hash:pushTokenHash devicePublicKey:devicePublicKey completion:^(NSString *account, NSString *deviceIdentifier, NSString *deviceIdentifierSignature, NSString *publicKey, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:self.activeAccount]) {
             NSLog(@"[LOG] Subscribed to Push Notification server & proxy successfully.");
@@ -423,8 +421,7 @@
     if (self.activeAccount.length == 0 || self.maintenanceMode)
         return;
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking unsubscribingPushNotificationWithAccount:self.activeAccount url:self.activeUrl deviceIdentifier:self.pnDeviceIdentifier deviceIdentifierSignature:self.pnDeviceIdentifierSignature publicKey:self.pnPublicKey completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] unsubscribingPushNotificationWithAccount:self.activeAccount url:self.activeUrl deviceIdentifier:self.pnDeviceIdentifier deviceIdentifierSignature:self.pnDeviceIdentifierSignature publicKey:self.pnPublicKey completion:^(NSString *account, NSString *message, NSInteger errorCode) {
        
         if (errorCode == 0) {
             NSLog(@"[LOG] Unsubscribed to Push Notification server & proxy successfully.");

+ 2 - 4
iOSClient/Favorites/CCFavorites.m

@@ -169,8 +169,7 @@
 {
     NSString *fileNameServerUrl = [CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:metadata.serverUrl activeUrl:appDelegate.activeUrl];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking settingFavoriteWithAccount:appDelegate.activeAccount fileName:fileNameServerUrl favorite:favorite completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] settingFavoriteWithAccount:appDelegate.activeAccount fileName:fileNameServerUrl favorite:favorite completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         if (errorCode == 0) {
             [[NCManageDatabase sharedInstance] setMetadataFavoriteWithFileID:metadata.fileID favorite:favorite];
             [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl fileID:metadata.fileID action:k_action_MOD];
@@ -190,8 +189,7 @@
     if (appDelegate.activeAccount.length == 0)
         return;
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking listingFavoritesWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] listingFavoritesWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             

+ 2 - 4
iOSClient/Login/CCLogin.m

@@ -169,8 +169,7 @@
     if ([self.baseUrl.text hasSuffix:@"/"])
         self.baseUrl.text = [self.baseUrl.text substringToIndex:[self.baseUrl.text length] - 1];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking serverStatusUrl:self.baseUrl.text completion:^(NSString *serverProductName, NSInteger versionMajor, NSInteger versionMicro, NSInteger versionMinor, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] serverStatusUrl:self.baseUrl.text completion:^(NSString *serverProductName, NSInteger versionMajor, NSInteger versionMicro, NSInteger versionMinor, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0) {
             
@@ -297,8 +296,7 @@
         self.login.enabled = NO;
         [self.activity startAnimating];
 
-        OCnetworking *ocNetworking = [OCnetworking new];
-        [ocNetworking checkServerUrl:[NSString stringWithFormat:@"%@%@", url, k_webDAV] user:user userID:user password:password completion:^(NSString *message, NSInteger errorCode) {
+        [[OCnetworking sharedManager] checkServerUrl:[NSString stringWithFormat:@"%@%@", url, k_webDAV] user:user userID:user password:password completion:^(NSString *message, NSInteger errorCode) {
             
             if (errorCode == 0) {
                 

+ 2 - 4
iOSClient/Main/CCDetail.m

@@ -217,8 +217,7 @@
             [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view];
             
             if ([self.metadataDetail.url isEqualToString:@""]) {
-                OCnetworking *ocNetworking = [OCnetworking new];
-                [ocNetworking createLinkRichdocumentsWithAccount:appDelegate.activeAccount fileID:self.metadataDetail.fileID completion:^(NSString *account, NSString *link, NSString *message, NSInteger errorCode) {
+                [[OCnetworking sharedManager] createLinkRichdocumentsWithAccount:appDelegate.activeAccount fileID:self.metadataDetail.fileID completion:^(NSString *account, NSString *link, NSString *message, NSInteger errorCode) {
                     
                     if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
                         
@@ -399,8 +398,7 @@
                 CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
                 CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
 
-                OCnetworking *ocNetworking = [OCnetworking new];
-                [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+                [[OCnetworking sharedManager] downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
 
                     self.navigationItem.titleView = nil;
                     self.title = metadata.fileNameView;

+ 15 - 28
iOSClient/Main/CCMain.m

@@ -1132,8 +1132,7 @@
         [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl fileID:nil action:k_action_NULL];
     });
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:_serverUrl fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:_serverUrl fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
        
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
         
@@ -1269,8 +1268,7 @@
     _loadingFolder = YES;
     [self tableViewReloadData];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0) {
             
@@ -1336,8 +1334,7 @@
 {
     NSString *startDirectory = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking searchWithAccount:appDelegate.activeAccount fileName:_searchFileName serverUrl:startDirectory contentType:nil date:nil depth:@"infinity" completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] searchWithAccount:appDelegate.activeAccount fileName:_searchFileName serverUrl:startDirectory contentType:nil date:nil depth:@"infinity" completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
        
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
@@ -1522,8 +1519,7 @@
         }
         
         // Verify if exists the fileName TO
-        OCnetworking *ocNetworking = [OCnetworking new];
-        [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:metadata.serverUrl fileName:fileNameNew completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+        [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:metadata.serverUrl fileName:fileNameNew completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
             
             if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
                 
@@ -1537,7 +1533,7 @@
                 NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@", metadata.serverUrl, metadata.fileName];
                 NSString *fileNameToPath = [NSString stringWithFormat:@"%@/%@", metadata.serverUrl, fileNameNew];
                 
-                [ocNetworking moveFileOrFolderWithAccount:appDelegate.activeAccount fileName:fileNamePath fileNameTo:fileNameToPath completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+                [[OCnetworking sharedManager] moveFileOrFolderWithAccount:appDelegate.activeAccount fileName:fileNamePath fileNameTo:fileNameToPath completion:^(NSString *account, NSString *message, NSInteger errorCode) {
                    
                     if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
                         // Rename metadata
@@ -1590,8 +1586,7 @@
 
 - (void)moveFileOrFolderMetadata:(tableMetadata *)metadata serverUrlTo:(NSString *)serverUrlTo numFile:(NSInteger)numFile ofFile:(NSInteger)ofFile
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:serverUrlTo fileName:metadata.fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:serverUrlTo fileName:metadata.fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
@@ -1612,7 +1607,7 @@
             NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@", metadata.serverUrl, metadata.fileName];
             NSString *fileNameToPath = [NSString stringWithFormat:@"%@/%@", serverUrlTo, metadata.fileName];
             
-            [ocNetworking moveFileOrFolderWithAccount:appDelegate.activeAccount fileName:fileNamePath fileNameTo:fileNameToPath completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+            [[OCnetworking sharedManager] moveFileOrFolderWithAccount:appDelegate.activeAccount fileName:fileNamePath fileNameTo:fileNameToPath completion:^(NSString *account, NSString *message, NSInteger errorCode) {
                 
                 [_hud hideHud];
                 
@@ -1775,8 +1770,7 @@
     [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl fileID:nil action:k_action_NULL];
     
     // Creeate folder Networking
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking createFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl fileName:fileNameFolder completion:^(NSString *account, NSString *fileID, NSDate *date, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] createFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl fileName:fileNameFolder completion:^(NSString *account, NSString *fileID, NSDate *date, NSString *message, NSInteger errorCode) {
        
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
@@ -1928,8 +1922,7 @@
 {
     NSString *fileName = [CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:serverUrl activeUrl:appDelegate.activeUrl];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking shareWithAccount:appDelegate.activeAccount fileName:fileName password:password permission:permission hideDownload:hideDownload completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] shareWithAccount:appDelegate.activeAccount fileName:fileName password:password permission:permission hideDownload:hideDownload completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -1956,8 +1949,7 @@
 
 - (void)unShare:(NSString *)share metadata:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking unshareAccount:appDelegate.activeAccount shareID:[share integerValue] completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] unshareAccount:appDelegate.activeAccount shareID:[share integerValue] completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -1990,8 +1982,7 @@
 
 - (void)updateShare:(NSString *)share metadata:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl password:(NSString *)password expirationTime:(NSString *)expirationTime permission:(NSInteger)permission hideDownload:(BOOL)hideDownload
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking shareUpdateAccount:appDelegate.activeAccount shareID:[share integerValue] password:password permission:permission expirationTime:expirationTime hideDownload:hideDownload completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] shareUpdateAccount:appDelegate.activeAccount shareID:[share integerValue] password:password permission:permission expirationTime:expirationTime hideDownload:hideDownload completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -2019,8 +2010,7 @@
 
 - (void)getUserAndGroup:(NSString *)find
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking getUserGroupWithAccount:appDelegate.activeAccount searchString:find completion:^(NSString *account, NSArray *item, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] getUserGroupWithAccount:appDelegate.activeAccount searchString:find completion:^(NSString *account, NSArray *item, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -2046,8 +2036,7 @@
 {
     NSString *fileName = [CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:serverUrl activeUrl:appDelegate.activeUrl];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking shareUserGroupWithAccount:appDelegate.activeAccount userOrGroup:user fileName:fileName permission:permission shareeType:shareeType completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] shareUserGroupWithAccount:appDelegate.activeAccount userOrGroup:user fileName:fileName permission:permission shareeType:shareeType completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -2074,8 +2063,7 @@
 
 - (void)openWindowShare:(tableMetadata *)metadata
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readShareWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readShareWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
         
@@ -2157,8 +2145,7 @@
 {
     NSString *fileNameServerUrl = [CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:self.serverUrl activeUrl:appDelegate.activeUrl];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking settingFavoriteWithAccount:appDelegate.activeAccount fileName:fileNameServerUrl favorite:favorite completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] settingFavoriteWithAccount:appDelegate.activeAccount fileName:fileNameServerUrl favorite:favorite completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         if (errorCode == 0 && [appDelegate.activeAccount isEqualToString:account]) {
             
             [[NCManageDatabase sharedInstance] setMetadataFavoriteWithFileID:metadata.fileID favorite:favorite];

+ 3 - 6
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -257,8 +257,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
             fileName = CCUtility.returnFileNamePath(fromFileName: fileName, serverUrl: serverUrl, activeUrl: appDelegate.activeUrl)
         }
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.createNewRichdocuments(withAccount: appDelegate.activeAccount, fileName: fileName, serverUrl: serverUrl, templateID: "\(selectTemplate.templateID)", completion: { (account, url, message, errorCode) in
+        OCnetworking.sharedManager().createNewRichdocuments(withAccount: appDelegate.activeAccount, fileName: fileName, serverUrl: serverUrl, templateID: "\(selectTemplate.templateID)", completion: { (account, url, message, errorCode) in
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 
@@ -288,8 +287,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         indicator.color = NCBrandColor.sharedInstance.brand
         indicator.startAnimating()
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.geTemplatesRichdocuments(withAccount: appDelegate.activeAccount, typeTemplate: typeTemplate, completion: { (account, listOfTemplate, message, errorCode) in
+        OCnetworking.sharedManager().geTemplatesRichdocuments(withAccount: appDelegate.activeAccount, typeTemplate: typeTemplate, completion: { (account, listOfTemplate, message, errorCode) in
             
             self.indicator.stopAnimating()
 
@@ -319,8 +317,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         
         let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + template.name + ".png"
 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.download(withAccount: appDelegate.activeAccount, url: template.preview, fileNameLocalPath: fileNameLocalPath, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().download(withAccount: appDelegate.activeAccount, url: template.preview, fileNameLocalPath: fileNameLocalPath, completion: { (account, message, errorCode) in
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 self.collectionView.reloadItems(at: [indexPath])

+ 3 - 6
iOSClient/Main/NCMainCommon.swift

@@ -845,16 +845,14 @@ class NCMainCommon: NSObject {
         var count: Int = 0
         var completionErrorCode: Int = 0
         var completionMessage = ""
-        
-        let ocNetworking = OCnetworking.init()
-        
+                
         for metadata in metadatas {
             
             self.appDelegate.filterFileID.add(metadata.fileID)
             
             let path = metadata.serverUrl + "/" + metadata.fileName
             
-            ocNetworking.deleteFileOrFolder(withAccount: appDelegate.activeAccount, path: path, completion: { (account, message, errorCode) in
+            OCnetworking.sharedManager().deleteFileOrFolder(withAccount: appDelegate.activeAccount, path: path, completion: { (account, message, errorCode) in
                 
                 if account == self.appDelegate.activeAccount {
                     
@@ -1169,8 +1167,7 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
             let width = NCUtility.sharedInstance.getScreenWidthForPreview()
             let height = NCUtility.sharedInstance.getScreenHeightForPreview()
             
-            let ocNetworking = OCnetworking.init()
-            ocNetworking.downloadPreview(withAccount: appDelegate.activeAccount, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
+            OCnetworking.sharedManager().downloadPreview(withAccount: appDelegate.activeAccount, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
               
                 if errorCode == 0 && account == self.appDelegate.activeAccount {
                     if CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {

+ 3 - 5
iOSClient/Media/CCMedia.m

@@ -604,8 +604,7 @@
     CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
     CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         counterThumbnail--;
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount] && [[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] && [self indexPathIsValid:indexPath] && !collectionViewReloadDataInProgress) {
@@ -670,8 +669,7 @@
     
     NSString *startDirectory = [[NCManageDatabase sharedInstance] getAccountStartDirectoryMediaTabView:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:startDirectory fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:startDirectory fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
 
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             if (![metadata.etag isEqualToString:[saveEtagForStartDirectory objectForKey:startDirectory]] || sectionDataSource.allRecordsDataSource.count == 0) {
@@ -679,7 +677,7 @@
                 isSearchMode = YES;
                 [self editingModeNO];
                 
-                [ocNetworking searchWithAccount:appDelegate.activeAccount fileName:@"" serverUrl:startDirectory contentType:@[@"image/%", @"video/%"] date:[NSDate distantPast] depth:@"infinity" completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
+                [[OCnetworking sharedManager] searchWithAccount:appDelegate.activeAccount fileName:@"" serverUrl:startDirectory contentType:@[@"image/%", @"video/%"] date:[NSDate distantPast] depth:@"infinity" completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
                     
                     if (errorCode == 0 && [appDelegate.activeAccount isEqualToString:account]) {
                         

+ 3 - 6
iOSClient/Move/CCMove.m

@@ -279,8 +279,7 @@
 
 - (void)readFile
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFileWithAccount:activeAccount serverUrl:_serverUrl fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFileWithAccount:activeAccount serverUrl:_serverUrl fileName:nil completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
         if (errorCode == 0) {
             tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, _serverUrl]];
             if ([metadata.etag isEqualToString:directory.etag] == NO) {
@@ -297,8 +296,7 @@
 
 - (void)readFolder
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFolderWithAccount:activeAccount serverUrl:_serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFolderWithAccount:activeAccount serverUrl:_serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:activeAccount]) {
             
@@ -342,8 +340,7 @@
 
 - (void)createFolder:(NSString *)fileNameFolder
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking createFolderWithAccount:activeAccount serverUrl:_serverUrl fileName:fileNameFolder completion:^(NSString *account, NSString *fileID, NSDate *date, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] createFolderWithAccount:activeAccount serverUrl:_serverUrl fileName:fileNameFolder completion:^(NSString *account, NSString *fileID, NSDate *date, NSString *message, NSInteger errorCode) {
        
         if (errorCode == 0 && [account isEqualToString:activeAccount]) {
             [self readFolder];

+ 7 - 11
iOSClient/Networking/NCService.swift

@@ -57,8 +57,7 @@ class NCService: NSObject {
             return
         }
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.getCapabilitiesWithAccount(appDelegate.activeAccount, completion: { (account, capabilities, message, errorCode) in
+        OCnetworking.sharedManager().getCapabilitiesWithAccount(appDelegate.activeAccount, completion: { (account, capabilities, message, errorCode) in
             
             if (errorCode == 0 && self.appDelegate.activeAccount == account!) {
                 
@@ -118,7 +117,7 @@ class NCService: NSObject {
                 // Read Notification
                 if (capabilities!.isNotificationServerEnabled) {
                     
-                    ocNetworking.getNotificationWithAccount(account!, completion: { (account, listOfNotifications, message, errorCode) in
+                    OCnetworking.sharedManager().getNotificationWithAccount(account!, completion: { (account, listOfNotifications, message, errorCode) in
                         
                         if (errorCode == 0 && account! == self.appDelegate.activeAccount) {
                             
@@ -190,7 +189,7 @@ class NCService: NSObject {
                 // Read External Sites
                 if (capabilities!.isExternalSitesServerEnabled) {
                     
-                    ocNetworking.getExternalSites(withAccount: account!, completion: { (account, listOfExternalSites, message, errorCode) in
+                    OCnetworking.sharedManager().getExternalSites(withAccount: account!, completion: { (account, listOfExternalSites, message, errorCode) in
                         
                         if (errorCode == 0 && account! == self.appDelegate.activeAccount) {
                             
@@ -222,7 +221,7 @@ class NCService: NSObject {
                     
                     self.appDelegate.sharesID.removeAllObjects()
                     
-                    ocNetworking.readShare(withAccount: account!, completion: { (account, items, message, errorCode) in
+                    OCnetworking.sharedManager().readShare(withAccount: account!, completion: { (account, items, message, errorCode) in
                         
                         if errorCode == 0 && account! == self.appDelegate.activeAccount {
                             
@@ -260,8 +259,7 @@ class NCService: NSObject {
             return
         }
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.getUserProfile(withAccount: appDelegate.activeAccount, completion: { (account, userProfile, message, errorCode) in
+        OCnetworking.sharedManager().getUserProfile(withAccount: appDelegate.activeAccount, completion: { (account, userProfile, message, errorCode) in
             
             if (errorCode == 0 && account! == self.appDelegate.activeAccount) {
                 
@@ -330,8 +328,7 @@ class NCService: NSObject {
             return
         }
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.getActivityWithAccount(appDelegate.activeAccount, completion: { (account, listOfActivity, message, errorCode) in
+        OCnetworking.sharedManager().getActivityWithAccount(appDelegate.activeAccount, completion: { (account, listOfActivity, message, errorCode) in
             if errorCode == 0 {
                 NCManageDatabase.sharedInstance.addActivityServer(listOfActivity as! [OCActivity], account: account!)
                 if (self.appDelegate.activeActivity != nil) {
@@ -359,8 +356,7 @@ class NCService: NSObject {
     
     private func requestServerStatus() {
 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.serverStatusUrl(appDelegate.activeUrl, completion: { (serverProductName, versionMajor, versionMicro, versionMinor, message, errorCode) in
+        OCnetworking.sharedManager().serverStatusUrl(appDelegate.activeUrl, completion: { (serverProductName, versionMajor, versionMicro, versionMinor, message, errorCode) in
             if errorCode == 0 {
                 if serverProductName == "owncloud" {
                     self.appDelegate.messageNotification("_warning_", description: "_warning_owncloud_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: Int(k_CCErrorInternalError))

+ 3 - 1
iOSClient/Networking/OCNetworking.h

@@ -30,7 +30,9 @@
 
 @class tableMetadata;
 
-@interface OCnetworking : NSObject <CCNetworkingDelegate>
+@interface OCnetworking : NSObject <NSURLSessionDelegate>
+
++ (OCnetworking *)sharedManager;
 
 #pragma mark ===== Server =====
 

+ 12 - 2
iOSClient/Networking/OCNetworking.m

@@ -31,6 +31,17 @@
 
 @implementation OCnetworking
 
++ (OCnetworking *)sharedManager {
+    static OCnetworking *sharedManager;
+    @synchronized(self)
+    {
+        if (!sharedManager) {
+            sharedManager = [OCnetworking new];
+        }
+        return sharedManager;
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Server =====
 #pragma --------------------------------------------------------------------------------------------
@@ -80,8 +91,7 @@
     [request addValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
     
     NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
-    //NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self.delegate delegateQueue:nil];
-    NSURLSession *session;
+    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
     
     NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
         

+ 2 - 4
iOSClient/Notification/CCNotification.swift

@@ -84,8 +84,7 @@ class CCNotification: UITableViewController {
 
                 tableView.setEditing(false, animated: true)
 
-                let ocNetworking = OCnetworking.init()
-                ocNetworking.setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: "\(self.appDelegate.activeUrl!)/\(k_url_acces_remote_notification_api)/\(notification.idNotification)", type: "DELETE", completion: { (account, message, errorCode) in
+                OCnetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: "\(self.appDelegate.activeUrl!)/\(k_url_acces_remote_notification_api)/\(notification.idNotification)", type: "DELETE", completion: { (account, message, errorCode) in
                     
                     if (errorCode == 0 && account! == self.appDelegate.activeAccount) {
                         
@@ -129,8 +128,7 @@ class CCNotification: UITableViewController {
                             
                             tableView.setEditing(false, animated: true)
 
-                            let ocNetworking = OCnetworking.init()
-                            ocNetworking.setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: (actionNotification as! OCNotificationsAction).link, type: (actionNotification as! OCNotificationsAction).type, completion: { (account, message, errorCode) in
+                            OCnetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: (actionNotification as! OCNotificationsAction).link, type: (actionNotification as! OCNotificationsAction).type, completion: { (account, message, errorCode) in
                                 
                                 if (errorCode == 0 && account! == self.appDelegate.activeAccount) {
                                     

+ 1 - 2
iOSClient/PeekPop/CCPeekPop.m

@@ -98,8 +98,7 @@
     CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
     CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:_metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] downloadPreviewWithAccount:appDelegate.activeAccount metadata:_metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
      
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             

+ 2 - 4
iOSClient/Select/NCSelect.swift

@@ -461,8 +461,7 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
     
     func createFolder(with fileName: String) {
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.createFolder(withAccount: appDelegate.activeAccount, serverUrl: serverUrl, fileName: fileName, completion: { (account, fileID, date, message, errorCode) in
+        OCnetworking.sharedManager().createFolder(withAccount: appDelegate.activeAccount, serverUrl: serverUrl, fileName: fileName, completion: { (account, fileID, date, message, errorCode) in
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 self.loadDatasource(withLoadFolder: true)
             } else if errorCode != 0 {
@@ -476,8 +475,7 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
         networkInProgress = true
         collectionView.reloadData()
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.readFolder(withAccount: appDelegate.activeAccount, serverUrl: serverUrl, depth: "1", completion: { (account, metadatas, metadataFolder, message, errorCode) in
+        OCnetworking.sharedManager().readFolder(withAccount: appDelegate.activeAccount, serverUrl: serverUrl, depth: "1", completion: { (account, metadatas, metadataFolder, message, errorCode) in
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
             

+ 1 - 2
iOSClient/Share/CCShareInfoCMOC.m

@@ -126,8 +126,7 @@ const PERMISSION_ALL = 31;
     
     _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking getSharePermissionsFileWithAccount:appDelegate.activeAccount fileNamePath:[NSString stringWithFormat:@"%@/%@", _metadata.serverUrl, _metadata.fileName] completion:^(NSString *account, NSString *permissions, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] getSharePermissionsFileWithAccount:appDelegate.activeAccount fileNamePath:[NSString stringWithFormat:@"%@/%@", _metadata.serverUrl, _metadata.fileName] completion:^(NSString *account, NSString *permissions, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
 

+ 2 - 4
iOSClient/Shares/NCShares.m

@@ -157,8 +157,7 @@
         shareString = [share stringByReplacingOccurrencesOfString:@" " withString:@""];
     }
     
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking unshareAccount:appDelegate.activeAccount shareID:[shareString integerValue] completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] unshareAccount:appDelegate.activeAccount shareID:[shareString integerValue] completion:^(NSString *account, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
@@ -294,8 +293,7 @@
         
         cell.fileImageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"file"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
         
-        OCnetworking *ocNetworking = [OCnetworking new];
-        [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:table.serverUrl fileName:table.fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+        [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:table.serverUrl fileName:table.fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
             
             if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
                 

+ 2 - 4
iOSClient/Synchronize/CCSynchronize.m

@@ -60,8 +60,7 @@
 
 - (void)readFolder:(NSString *)serverUrl selector:(NSString *)selector
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
@@ -206,8 +205,7 @@
 
 - (void)readFile:(NSString *)fileID fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString *)selector
 {
-    OCnetworking *ocNetworking = [OCnetworking new];
-    [ocNetworking readFileWithAccount:appDelegate.activeAccount serverUrl:serverUrl fileName:fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
+    [[OCnetworking sharedManager] readFileWithAccount:appDelegate.activeAccount serverUrl:serverUrl fileName:fileName completion:^(NSString *account, tableMetadata *metadata, NSString *message, NSInteger errorCode) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             

+ 5 - 10
iOSClient/Trash/NCTrash.swift

@@ -456,8 +456,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     @objc func loadListingTrash() {
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.listingTrash(withAccount: appDelegate.activeAccount, path: path, serverUrl: appDelegate.activeUrl, completion: { (account, item, message, errorCode) in
+        OCnetworking.sharedManager().listingTrash(withAccount: appDelegate.activeAccount, path: path, serverUrl: appDelegate.activeUrl, completion: { (account, item, message, errorCode) in
             
             self.refreshControl.endRefreshing()
 
@@ -483,8 +482,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         let fileName = appDelegate.activeUrl + tableTrash.filePath + tableTrash.fileName
         let fileNameTo = appDelegate.activeUrl + k_dav + "/trashbin/" + appDelegate.activeUserID + "/restore/" + tableTrash.fileName
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.moveFileOrFolder(withAccount: appDelegate.activeAccount, fileName: fileName, fileNameTo: fileNameTo, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().moveFileOrFolder(withAccount: appDelegate.activeAccount, fileName: fileName, fileNameTo: fileNameTo, completion: { (account, message, errorCode) in
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 NCManageDatabase.sharedInstance.deleteTrash(fileID: fileID, account: account!)
                 self.loadDatasource()
@@ -496,8 +494,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     func emptyTrash() {
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.emptyTrash(withAccount: appDelegate.activeAccount, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().emptyTrash(withAccount: appDelegate.activeAccount, completion: { (account, message, errorCode) in
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 NCManageDatabase.sharedInstance.deleteTrash(fileID: nil, account: self.appDelegate.activeAccount)
             } else if errorCode != 0 {
@@ -515,8 +512,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         
         let path = appDelegate.activeUrl + tableTrash.filePath + tableTrash.fileName
 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.deleteFileOrFolder(withAccount: appDelegate.activeAccount, path: path, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().deleteFileOrFolder(withAccount: appDelegate.activeAccount, path: path, completion: { (account, message, errorCode) in
             
             if errorCode == 0 {
                 
@@ -533,8 +529,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) {
                 
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.downloadPreviewTrash(withAccount: appDelegate.activeAccount, fileID: tableTrash.fileID, fileName: tableTrash.fileName, completion: { (account, message, errorCode) in
+        OCnetworking.sharedManager().downloadPreviewTrash(withAccount: appDelegate.activeAccount, fileID: tableTrash.fileID, fileName: tableTrash.fileName, completion: { (account, message, errorCode) in
             if errorCode == 0 && account == self.appDelegate.activeAccount && CCUtility.fileProviderStorageIconExists(tableTrash.fileID, fileNameView: tableTrash.fileName) {
                 self.collectionView.reloadItems(at: [indexPath])
             }

+ 2 - 4
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -110,8 +110,7 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
         
         if serverUrl != nil && metadata != nil {
             
-            let ocNetworking = OCnetworking.init()
-            ocNetworking.createAssetRichdocuments(withAccount: metadata?.account, fileName: metadata?.fileName, serverUrl: serverUrl, completion: { (account, url, message, errorCode) in
+            OCnetworking.sharedManager().createAssetRichdocuments(withAccount: metadata?.account, fileName: metadata?.fileName, serverUrl: serverUrl, completion: { (account, url, message, errorCode) in
                 
                 if (errorCode == 0) {
                     let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata!.fileNameView)', '\(url!)')"
@@ -125,8 +124,7 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
     
     func select(_ metadata: tableMetadata!, serverUrl: String!) {
         
-        let ocNetworking = OCnetworking.init()
-        ocNetworking.createAssetRichdocuments(withAccount: metadata?.account, fileName: metadata?.fileName, serverUrl: serverUrl, completion: { (account, url, message, errorCode) in
+        OCnetworking.sharedManager().createAssetRichdocuments(withAccount: metadata?.account, fileName: metadata?.fileName, serverUrl: serverUrl, completion: { (account, url, message, errorCode) in
             
             if (errorCode == 0) {
                 let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata.fileNameView)', '\(url!)')"