Browse Source

Merge branch 'Coherence' into small-fixes

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>

# Conflicts:
#	iOSClient/Main/Cell/CCCellMain.h
#	iOSClient/Main/Cell/CCCellMain.m
#	iOSClient/Main/Cell/CCCellMainTransfer.h
#	iOSClient/Main/Cell/CCCellMainTransfer.m
#	iOSClient/Main/NCMainCommon.swift
#	iOSClient/Media/NCMedia.swift
Philippe Weidmann 4 years ago
parent
commit
d6bae8a7f3
98 changed files with 637 additions and 1281 deletions
  1. 4 4
      Cartfile.resolved
  2. 4 2
      Carthage/Checkouts/SVGKit/Source/QuartzCore additions/CALayerWithClipRender.m
  3. 1 1
      File Provider Extension/FileProviderDomain.swift
  4. 0 1
      File Provider Extension/FileProviderEnumerator.swift
  5. 2 2
      File Provider Extension/FileProviderExtension+NetworkingDelegate.swift
  6. 1 1
      Libraries external/Imagemeter/IMImagemeterViewer.swift
  7. 8 8
      Nextcloud.xcodeproj/project.pbxproj
  8. 1 1
      Share/CCCellShareExt.h
  9. 1 1
      Share/CCCellShareExt.m
  10. 1 1
      Share/CCloadItemData.swift
  11. 1 1
      Share/NCSelectDestination.h
  12. 1 1
      Share/NCSelectDestination.m
  13. 1 1
      Share/ShareViewController.h
  14. 1 1
      Share/ShareViewController.m
  15. 1 4
      iOSClient/AppDelegate.h
  16. 49 56
      iOSClient/AppDelegate.m
  17. 1 1
      iOSClient/AudioRecorder/NCAudioRecorderViewController.swift
  18. 4 15
      iOSClient/AutoUpload/NCAutoUpload.m
  19. 16 1
      iOSClient/BrowserWeb/NCBrowserWeb.swift
  20. 3 13
      iOSClient/CCGlobal.h
  21. 1 1
      iOSClient/CryptoCloud.pch
  22. 0 1
      iOSClient/Database/NCDatabase.swift
  23. 4 109
      iOSClient/Database/NCManageDatabase.swift
  24. 0 1
      iOSClient/Favorites/CCFavorites.h
  25. 5 51
      iOSClient/Favorites/CCFavorites.m
  26. 1 1
      iOSClient/Login/CCLogin.h
  27. 1 1
      iOSClient/Login/CCLogin.m
  28. 1 5
      iOSClient/Main/CCMain.h
  29. 52 180
      iOSClient/Main/CCMain.m
  30. 1 1
      iOSClient/Main/CCSection.h
  31. 1 1
      iOSClient/Main/CCSection.m
  32. 1 2
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  33. 1 1
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  34. 2 3
      iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift
  35. 4 4
      iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
  36. 10 12
      iOSClient/Main/Menu/CCMain+Menu.swift
  37. 0 2
      iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift
  38. 15 284
      iOSClient/Main/NCMainCommon.swift
  39. 1 1
      iOSClient/Main/NCMainRefreshControl.swift
  40. 1 1
      iOSClient/Main/NCMainTabBar.swift
  41. 1 1
      iOSClient/Main/NCPhotosPickerViewController.swift
  42. 1 1
      iOSClient/ManageLocation+ManageAsset/CCManageLocation.h
  43. 1 1
      iOSClient/ManageLocation+ManageAsset/CCManageLocation.m
  44. 1 1
      iOSClient/MenuAccount/CCMenuAccount.h
  45. 1 1
      iOSClient/MenuAccount/CCMenuAccount.m
  46. 3 9
      iOSClient/Networking/CCNetworking.h
  47. 29 127
      iOSClient/Networking/CCNetworking.m
  48. 118 40
      iOSClient/Networking/NCNetworking.swift
  49. 7 7
      iOSClient/Networking/NCNetworkingE2EE.swift
  50. 8 23
      iOSClient/Networking/NCNetworkingNotificationCenter.swift
  51. 133 12
      iOSClient/Networking/NCOperationQueue.swift
  52. 42 24
      iOSClient/Networking/NCService.swift
  53. 1 1
      iOSClient/Networking/OCNetworking.h
  54. 1 1
      iOSClient/Networking/OCNetworking.m
  55. 1 1
      iOSClient/PeekPop/CCPeekPop.h
  56. 1 1
      iOSClient/PeekPop/CCPeekPop.m
  57. 1 1
      iOSClient/Settings/Acknowledgements.h
  58. 1 1
      iOSClient/Settings/Acknowledgements.m
  59. 3 8
      iOSClient/Settings/CCAdvanced.m
  60. 1 1
      iOSClient/Settings/CCManageAccount.h
  61. 1 1
      iOSClient/Settings/CCManageAccount.m
  62. 1 1
      iOSClient/Settings/CCManageAutoUpload.h
  63. 1 7
      iOSClient/Settings/CCManageAutoUpload.m
  64. 1 1
      iOSClient/Settings/CCSettings.h
  65. 2 26
      iOSClient/Settings/CCSettings.m
  66. 1 1
      iOSClient/Settings/NCManageEndToEndEncryption.m
  67. 5 7
      iOSClient/Share/NCSharePaging.swift
  68. 1 1
      iOSClient/Shares/NCShares.m
  69. BIN
      iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings
  70. BIN
      iOSClient/Supporting Files/fr.lproj/Localizable.strings
  71. BIN
      iOSClient/Supporting Files/gl.lproj/Localizable.strings
  72. BIN
      iOSClient/Supporting Files/id.lproj/Localizable.strings
  73. BIN
      iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings
  74. BIN
      iOSClient/Supporting Files/ko.lproj/Localizable.strings
  75. BIN
      iOSClient/Supporting Files/lt_LT.lproj/Localizable.strings
  76. BIN
      iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings
  77. 3 20
      iOSClient/Synchronize/CCSynchronize.h
  78. 3 141
      iOSClient/Synchronize/CCSynchronize.m
  79. 0 1
      iOSClient/Transfers/CCTransfers.h
  80. 10 14
      iOSClient/Transfers/CCTransfers.m
  81. 1 1
      iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.h
  82. 2 3
      iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m
  83. 1 1
      iOSClient/Utility/CCError.h
  84. 1 1
      iOSClient/Utility/CCError.m
  85. 1 1
      iOSClient/Utility/CCExifGeo.h
  86. 1 1
      iOSClient/Utility/CCExifGeo.m
  87. 1 1
      iOSClient/Utility/CCGraphics.h
  88. 1 1
      iOSClient/Utility/CCGraphics.m
  89. 1 1
      iOSClient/Utility/CCHud.h
  90. 1 1
      iOSClient/Utility/CCHud.m
  91. 1 1
      iOSClient/Utility/CCUtility.h
  92. 1 1
      iOSClient/Utility/CCUtility.m
  93. 18 1
      iOSClient/Utility/NCContentPresenter.swift
  94. 1 1
      iOSClient/Utility/NSString+TruncateToWidth.h
  95. 1 1
      iOSClient/Utility/NSString+TruncateToWidth.m
  96. 15 0
      iOSClient/Viewer/NCViewerQuickLook.swift
  97. 1 2
      iOSClient/Viewer/NCViewerVideo.swift
  98. 1 1
      iOSClient/main.m

+ 4 - 4
Cartfile.resolved

@@ -3,12 +3,12 @@ github "AssistoLab/DropDown" "v2.3.13"
 github "CocoaLumberjack/CocoaLumberjack" "3.6.1"
 github "FabrizioBrancati/Queuer" "2.1.1"
 github "MortimerGoro/MGSwipeTableCell" "1.6.8"
-github "SVGKit/SVGKit" "d9432035c6e2587358a0b838d00c2658ce16e7a2"
+github "SVGKit/SVGKit" "c533a0d7dac9268503371caf6200ff368b7b9753"
 github "SwiftyJSON/SwiftyJSON" "5.0.0"
 github "WeTransfer/WeScan" "1.2.0"
 github "WenchaoD/FSCalendar" "2.8.0"
 github "dzenbot/DZNEmptyDataSet" "v1.8.1"
-github "getsentry/sentry-cocoa" "5.1.1"
+github "getsentry/sentry-cocoa" "5.1.2"
 github "huri000/QuickLayout" "3.0.0"
 github "huri000/SwiftEntryKit" "1.2.3"
 github "ivanbruel/MarkdownKit" "1.6"
@@ -20,10 +20,10 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "1cec66e794b24e3a9b5fc9d61d593c4d9bee4b82"
+github "nextcloud/ios-communication-library" "4ae73a504e793ec9856daefef4415488fb35dd0f"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
-github "scenee/FloatingPanel" "v1.7.4"
+github "scenee/FloatingPanel" "v1.7.5"
 github "tilltue/TLPhotoPicker" "2.0.11"
 github "weichsel/ZIPFoundation" "0.9.10"
 github "yahoojapan/SwiftyXMLParser" "5.1.0"

+ 4 - 2
Carthage/Checkouts/SVGKit/Source/QuartzCore additions/CALayerWithClipRender.m

@@ -86,8 +86,10 @@
         
         // and mask with that
         CGContextClipToMask(ctx, layer.bounds, maskImage);
-        
-        CFRelease(maskImage);
+
+        if( maskImage != nil ) {
+            CFRelease(maskImage);
+        }
     }
 }
 

+ 1 - 1
File Provider Extension/FileProviderDomain.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/06/2019.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 0 - 1
File Provider Extension/FileProviderEnumerator.swift

@@ -292,7 +292,6 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
                     // Prepare DB
                     if offset == 0 {
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", account, serverUrl, k_metadataStatusNormal))
-                        NCManageDatabase.sharedInstance.setDateReadDirectory(serverUrl: serverUrl, account: account)
                         let metadatasInDownload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND (status == %d OR status == %d OR status == %d OR status == %d)", account, serverUrl, k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading, k_metadataStatusDownloadError), sorted: nil, ascending: false)
                         let metadatasInUpload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND (status == %d OR status == %d OR status == %d OR status == %d)", account, serverUrl, k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading, k_metadataStatusUploadError), sorted: nil, ascending: false)
                         if metadatasInDownload != nil {

+ 2 - 2
File Provider Extension/FileProviderExtension+NetworkingDelegate.swift

@@ -3,7 +3,7 @@
 //  File Provider Extension
 //
 //  Created by Marino Faggiana on 02/11/2019.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -26,7 +26,7 @@ import NCCommunication
 
 extension FileProviderExtension: NCNetworkingDelegate {
 
-    func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, error: Error?, statusCode: Int) {
+    func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, task: URLSessionTask, error: Error?, statusCode: Int) {
                 
         guard let ocIdTemp = description else { return }
         guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp)) else { return }

+ 1 - 1
Libraries external/Imagemeter/IMImagemeterViewer.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 12/11/2019.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 8 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -2494,7 +2494,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2545,7 +2545,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2588,7 +2588,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2632,7 +2632,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2682,7 +2682,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2732,7 +2732,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2774,7 +2774,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2819,7 +2819,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 62;
+				CURRENT_PROJECT_VERSION = 63;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (

+ 1 - 1
Share/CCCellShareExt.h

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 27/01/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/CCCellShareExt.m

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 29/07/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/CCloadItemData.swift

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 19/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/NCSelectDestination.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/NCSelectDestination.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/ShareViewController.h

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 26/01/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
Share/ShareViewController.m

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 26/01/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 4
iOSClient/AppDelegate.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -133,9 +133,6 @@
 - (void)configDynamicShortcutItems;
 - (BOOL)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem;
 
-// ApplicationIconBadgeNumber
-- (void)updateApplicationIconBadgeNumber;
-
 // TabBarController
 - (void)createTabBarController:(UITabBarController *)tabBarController;
 - (NSString *)getTabBarControllerActiveServerUrl;

+ 49 - 56
iOSClient/AppDelegate.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -806,7 +806,7 @@
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        NSInteger counterDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status = %d OR status == %d OR status == %d", k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading] sorted:@"fileName" ascending:true] count];
+        NSInteger counterDownload = [[NCOperationQueue shared] downloadCount];
         NSInteger counterUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status == %d OR status == %d OR status == %d", k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading] sorted:@"fileName" ascending:true] count];
 
         NSInteger total = counterDownload + counterUpload;
@@ -980,43 +980,47 @@
     if (self.activeAccount.length == 0 || self.maintenanceMode)
         return;
     
-    if ([NCBrandOptions sharedInstance].use_themingColor) {
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        NSString *themingColor = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColor];
-        NSString *themingColorElement = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
-        NSString *themingColorText = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColorText];
+        if ([NCBrandOptions sharedInstance].use_themingColor) {
+            
+            NSString *themingColor = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColor];
+            NSString *themingColorElement = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
+            NSString *themingColorText = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.activeAccount elements:NCElementsJSON.shared.capabilitiesThemingColorText];
 
-        [CCGraphics settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
-        
-        UIColor *color = NCBrandColor.sharedInstance.brand;
-        BOOL isTooLight = NCBrandColor.sharedInstance.brand.isTooLight;
-        BOOL isTooDark = NCBrandColor.sharedInstance.brand.isTooDark;
+            [CCGraphics settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
+            
+            UIColor *color = NCBrandColor.sharedInstance.brand;
+            BOOL isTooLight = NCBrandColor.sharedInstance.brand.isTooLight;
+            BOOL isTooDark = NCBrandColor.sharedInstance.brand.isTooDark;
+            
+            if (isTooLight) {
+                color = [NCBrandColor.sharedInstance.brand darkerBy:10];
+            } else if (isTooDark) {
+                color = [NCBrandColor.sharedInstance.brand lighterBy:10];
+            }
+            
+            NCBrandColor.sharedInstance.brand = color;
+                
+        } else {
         
-        if (isTooLight) {
-            color = [NCBrandColor.sharedInstance.brand darkerBy:10];
-        } else if (isTooDark) {
-            color = [NCBrandColor.sharedInstance.brand lighterBy:10];
+            NCBrandColor.sharedInstance.brand = NCBrandColor.sharedInstance.customer;
+            NCBrandColor.sharedInstance.brandElement = NCBrandColor.sharedInstance.customer;
+            NCBrandColor.sharedInstance.brandText = NCBrandColor.sharedInstance.customerText;
         }
-        
-        NCBrandColor.sharedInstance.brand = color;
             
-    } else {
+        [[NCMainCommon sharedInstance] createImagesThemingColor];
     
-        NCBrandColor.sharedInstance.brand = NCBrandColor.sharedInstance.customer;
-        NCBrandColor.sharedInstance.brandElement = NCBrandColor.sharedInstance.customer;
-        NCBrandColor.sharedInstance.brandText = NCBrandColor.sharedInstance.customerText;
-    }
-        
-    [[NCMainCommon sharedInstance] createImagesThemingColor];
+        [NCBrandColor.sharedInstance setDarkMode];
+    });
+                   
+    [self.window setTintColor:NCBrandColor.sharedInstance.textView];
     
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
 }
 
 - (void)changeTheming:(UIViewController *)viewController tableView:(UITableView *)tableView collectionView:(UICollectionView *)collectionView form:(BOOL)form
 {
-    // Dark Mode
-    [NCBrandColor.sharedInstance setDarkMode];
-    
     // View
     if (form) viewController.view.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
     else viewController.view.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
@@ -1036,23 +1040,7 @@
         viewController.tabBarController.tabBar.barTintColor = NCBrandColor.sharedInstance.backgroundView;
         viewController.tabBarController.tabBar.tintColor = NCBrandColor.sharedInstance.brandElement;
     }
-    
-    //tabBar button Plus
-    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-    if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
-        UINavigationController *navigationController = (UINavigationController *)[splitViewController.viewControllers firstObject];
-        if ([navigationController isKindOfClass:[UINavigationController class]]) {
-            UITabBarController *tabBarController = (UITabBarController *)navigationController.topViewController;
-            if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                [tabBarController.tabBar setNeedsDisplay];
-                UIButton *button = [tabBarController.view viewWithTag:99];
-                UIImage *buttonImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"tabBarPlus"] width:120 height:120 color:UIColor.whiteColor];
-                [button setImage:buttonImage forState:UIControlStateNormal];
-                button.backgroundColor = NCBrandColor.sharedInstance.brand;
-            }
-        }
-    }
-                
+
     // TableView
     if (tableView) {
         if (form) tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
@@ -1067,9 +1055,6 @@
         else collectionView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
         [collectionView reloadData];
     }
-    
-    // Tint Color GLOBAL WINDOW
-    [self.window setTintColor:NCBrandColor.sharedInstance.textView];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -1205,7 +1190,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[NCNetworking shared] uploadWithMetadata:metadata e2eEncrypted:true];
+                    [[NCNetworking shared] uploadWithMetadata:metadata];
                     
                     break;
                                         
@@ -1214,7 +1199,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[CCNetworking sharedNetworking] uploadFile:metadata taskStatus:k_taskStatusResume];
+                    [[NCNetworking shared] uploadWithMetadata:metadata];
                     
                     counterUpload++;
                     sizeUpload = sizeUpload + metadata.size;
@@ -1257,8 +1242,8 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                                           
-                [[CCNetworking sharedNetworking] uploadFile:metadata taskStatus:k_taskStatusResume];
-                
+                [[NCNetworking shared] uploadWithMetadata:metadata];
+                                
                 break;
                 
             } else {
@@ -1266,7 +1251,7 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                            
-                [[CCNetworking sharedNetworking] uploadFile:metadata taskStatus:k_taskStatusResume];
+                [[NCNetworking shared] uploadWithMetadata:metadata];
                            
                 counterUpload++;
                 sizeUpload = sizeUpload + metadata.size;
@@ -1312,7 +1297,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[CCNetworking sharedNetworking] uploadFile:metadata taskStatus:k_taskStatusResume];
+                    [[NCNetworking shared] uploadWithMetadata:metadata];
                     
                     break;
                     
@@ -1321,7 +1306,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[CCNetworking sharedNetworking] uploadFile:metadata taskStatus:k_taskStatusResume];
+                    [[NCNetworking shared] uploadWithMetadata:metadata];
                     
                     counterUpload++;
                     sizeUpload = sizeUpload + metadata.size;
@@ -1336,6 +1321,7 @@
     
     // Upload in pending
     //
+    /*
     NSString *sessionExtension = [[NCCommunicationCommon shared] sessionIdentifierExtension];
     NSArray *metadatasInUpload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session != %@ AND status == %d AND sessionTaskIdentifier == 0", sessionExtension, k_metadataStatusInUpload] sorted:nil ascending:true];
     for (tableMetadata *metadata in metadatasInUpload) {
@@ -1349,6 +1335,7 @@
     if (metadatasInUpload.count == 0) {
         [self.sessionPendingStatusInUpload removeAllObjects];
     }
+    */
     
     // Start Timer
     _timerProcessAutoUpload = [NSTimer scheduledTimerWithTimeInterval:k_timerProcessAutoUpload target:self selector:@selector(loadAutoUpload) userInfo:nil repeats:YES];
@@ -1369,7 +1356,14 @@
     NSArray *metadatasUploading = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session != %@ AND status == %d", sessionExtension, k_metadataStatusUploading] sorted:nil ascending:true];
     for (tableMetadata *metadata in metadatasUploading) {
         
-        NSURLSession *session = [[CCNetworking sharedNetworking] getSessionfromSessionDescription:metadata.session];
+        NSURLSession *session;
+        if ([metadata.session isEqualToString:NCCommunicationCommon.shared.sessionIdentifierBackground]) {
+            session = NCCommunicationBackground.shared.sessionManagerTransfer;
+        } else if ([metadata.session isEqualToString:NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan]) {
+            session = NCCommunicationBackground.shared.sessionManagerTransferWWan;
+        } else if ([metadata.session isEqualToString:NCCommunicationCommon.shared.sessionIdentifierExtension]) {
+            session = NCCommunicationBackground.shared.sessionManagerTransferExtension;
+        }
         
         [session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
             
@@ -1687,7 +1681,6 @@
     if (([actualVersion compare:@"2.19.1" options:NSNumericSearch] == NSOrderedAscending)) {
 
         [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:nil];
-        [[NCManageDatabase sharedInstance] setClearAllDateReadDirectory];
     }
     
     if (([actualVersion compare:@"2.22.0" options:NSNumericSearch] == NSOrderedAscending)) {

+ 1 - 1
iOSClient/AudioRecorder/NCAudioRecorderViewController.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 08/03/19.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 4 - 15
iOSClient/AutoUpload/NCAutoUpload.m

@@ -376,10 +376,10 @@
 
         // Select type of session
         
-        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto == NO) session = k_upload_session;
-        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo == NO) session = k_upload_session;
-        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto) session = k_upload_session_wwan;
-        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo) session = k_upload_session_wwan;
+        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto == NO) session = NCCommunicationCommon.shared.sessionIdentifierBackground;
+        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo == NO) session = NCCommunicationCommon.shared.sessionIdentifierBackground;
+        if (assetMediaType == PHAssetMediaTypeImage && tableAccount.autoUploadWWAnPhoto) session = NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan;
+        if (assetMediaType == PHAssetMediaTypeVideo && tableAccount.autoUploadWWAnVideo) session = NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan;
         
         NSDateFormatter *formatter = [NSDateFormatter new];
         
@@ -452,17 +452,11 @@
     if ([selector isEqualToString:selectorUploadAutoUploadAll] && [metadataFull count] > 0) {
     
         [[NCManageDatabase sharedInstance] addMetadatas:metadataFull];
-        
-        // Update icon badge number
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [appDelegate updateApplicationIconBadgeNumber];
-        });
     }
     
     // end loadingcand reload
     dispatch_async(dispatch_get_main_queue(), ^{
         [_hud hideHud];
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil ocId:nil action:k_action_NULL];
     });    
 }
 
@@ -476,11 +470,6 @@
         if ([metadata.sessionSelector isEqualToString:selectorUploadAutoUpload]) {
             (void)[[NCManageDatabase sharedInstance] addPhotoLibrary:@[asset] account:appDelegate.activeAccount];
         }
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            // Update icon badge number
-            [appDelegate updateApplicationIconBadgeNumber];
-        });
     }
 }
 

+ 16 - 1
iOSClient/BrowserWeb/NCBrowserWeb.swift

@@ -3,7 +3,22 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 22/08/2019.
-//  Copyright © 2019 TWS. All rights reserved.
+//  Copyright (c) 2019 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
 import Foundation

+ 3 - 13
iOSClient/CCGlobal.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 13/10/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -84,7 +84,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         107
+#define k_databaseSchemaVersion                         108
 
 // Intro selector
 #define k_intro_login                                   0
@@ -112,11 +112,6 @@
 #define k_permission_can_rename                         @"N"
 #define k_permission_can_move                           @"V"
 
-// Session
-#define k_upload_session                                @"it.twsweb.Crypto-Cloud.upload.session"
-#define k_upload_session_foreground                     @"it.twsweb.Crypto-Cloud.upload.sessionforeground"
-#define k_upload_session_wwan                           @"it.twsweb.Crypto-Cloud.upload.sessionwwan"
-
 // Service Key Share
 #define k_serviceShareKeyChain                          @"Crypto Cloud"
 #define k_metadataKeyedUnarchiver                       @"it.twsweb.nextcloud.metadata"
@@ -254,11 +249,6 @@
 #define k_trash_version_available                       14
 #define k_trash_version_available_more_fix              15
 
-// Cell Reload Data Source
-#define k_action_NULL                                   0
-#define k_action_MOD                                    1
-#define k_action_DEL                                    2
-
 // Toolbar Detail
 #define k_detail_Toolbar_Height                         49
 
@@ -311,13 +301,13 @@
 
 #define k_notificationCenter_initializeMain             @"initializeMain"
 #define k_notificationCenter_setTitleMain               @"setTitleMain"
-#define k_notificationCenter_clearDateReadDataSource    @"clearDateReadDataSource"          // userInfo: ocId?, serverUrl?
 #define k_notificationCenter_changeTheming              @"changeTheming"
 #define k_notificationCenter_splitViewChangeDisplayMode @"splitViewChangeDisplayMode"
 #define k_notificationCenter_synchronizationMedia       @"synchronizationMedia"             // userInfo: metadata, type
 #define k_notificationCenter_changeUserProfile          @"changeUserProfile"
 #define k_notificationCenter_richdocumentGrabFocus      @"richdocumentGrabFocus"
 #define k_notificationCenter_reloadDataNCShare          @"reloadDataNCShare"
+#define k_notificationCenter_reloadDataSource           @"reloadDataSource"                // userInfo: ocId?, serverUrl?
 
 #define k_notificationCenter_uploadFileStart            @"uploadFileStart"                  // userInfo: ocId, task, serverUrl, account
 #define k_notificationCenter_uploadedFile               @"uploadedFile"                     // userInfo: metadata, errorCode, errorDescription

+ 1 - 1
iOSClient/CryptoCloud.pch

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 17/09/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 0 - 1
iOSClient/Database/NCDatabase.swift

@@ -206,7 +206,6 @@ class tableDirectEditingEditors: Object {
 class tableDirectory: Object {
     
     @objc dynamic var account = ""
-    @objc dynamic var dateReadDirectory: NSDate? = nil
     @objc dynamic var e2eEncrypted: Bool = false
     @objc dynamic var etag = ""
     @objc dynamic var favorite: Bool = false

+ 4 - 109
iOSClient/Database/NCManageDatabase.swift

@@ -1224,30 +1224,6 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func clearDateRead(serverUrl: String, account: String) {
-        
-        let realm = try! Realm()
-
-        do {
-            try realm.write {
-
-                var predicate = NSPredicate()
-            
-                predicate = NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)
-                
-                guard let result = realm.objects(tableDirectory.self).filter(predicate).first else {
-                    return
-                }
-                
-                result.dateReadDirectory = nil
-                result.etag = ""
-                realm.add(result, update: .all)
-            }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-        }
-    }
-    
     @objc func getTableDirectory(predicate: NSPredicate) -> tableDirectory? {
         
         let realm = try! Realm()
@@ -1274,26 +1250,6 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setDateReadDirectory(serverUrl: String, account: String) {
-        
-        let realm = try! Realm()
-
-        realm.beginWrite()
-
-        guard let result = realm.objects(tableDirectory.self).filter("account == %@ AND serverUrl == %@", account, serverUrl).first else {
-            realm.cancelWrite()
-            return
-        }
-            
-        result.dateReadDirectory = NSDate()
-        
-        do {
-            try realm.commitWrite()
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-        }
-    }
-    
     @objc func renameDirectory(ocId: String, serverUrl: String) {
         
         let realm = try! Realm()
@@ -1314,25 +1270,6 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setClearAllDateReadDirectory() {
-        
-        let realm = try! Realm()
-
-        do {
-            try realm.write {
-            
-                let results = realm.objects(tableDirectory.self)
-
-                for result in results {
-                    result.dateReadDirectory = nil;
-                    result.etag = ""
-                }
-            }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-        }
-    }
-    
     @objc func setDirectory(serverUrl: String, offline: Bool, account: String) {
         
         let realm = try! Realm()
@@ -1894,10 +1831,7 @@ class NCManageDatabase: NSObject {
     
     @discardableResult
     @objc func addMetadata(_ metadata: tableMetadata) -> tableMetadata? {
-            
-        let serverUrl = metadata.serverUrl
-        let account = metadata.account
-        
+
         let realm = try! Realm()
 
         do {
@@ -1908,9 +1842,7 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return nil
         }
-        
-        self.setDateReadDirectory(serverUrl: serverUrl, account: account)
-        
+                
         return tableMetadata.init(value: metadata)
     }
     
@@ -1933,9 +1865,6 @@ class NCManageDatabase: NSObject {
             return nil
         }
         
-        for (serverUrl, account) in directoryToClearDate {
-            self.setDateReadDirectory(serverUrl: serverUrl, account: account)
-        }
         
         return Array(metadatas.map { tableMetadata.init(value:$0) })
     }
@@ -2008,10 +1937,6 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return
         }
-        
-        for (serverUrl, account) in directoryToClearDate {
-            self.setDateReadDirectory(serverUrl: serverUrl, account: account)
-        }
     }
     
     @discardableResult
@@ -2079,15 +2004,11 @@ class NCManageDatabase: NSObject {
             return nil
         }
         
-        self.setDateReadDirectory(serverUrl: result!.serverUrl, account: result!.account)
         return tableMetadata.init(value: result!)
     }
     
     @objc func updateMetadata(_ metadata: tableMetadata) -> tableMetadata? {
         
-        let account = metadata.account
-        let serverUrl = metadata.serverUrl
-        
         let realm = try! Realm()
 
         do {
@@ -2098,9 +2019,7 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return nil
         }
-        
-        self.setDateReadDirectory(serverUrl: serverUrl, account: account)
-        
+                
         return tableMetadata.init(value: metadata)
     }
     
@@ -2132,9 +2051,6 @@ class NCManageDatabase: NSObject {
         
         result.sessionTaskIdentifier = sessionTaskIdentifier
         result.status = status
-
-        let account = result.account
-        let serverUrl = result.serverUrl
         
         do {
             try realm.commitWrite()
@@ -2142,9 +2058,6 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return
         }
-        
-        // Update Date Read Directory
-        self.setDateReadDirectory(serverUrl: serverUrl, account: account)
     }
     
     @objc func setMetadataFavorite(ocId: String, favorite: Bool) {
@@ -2159,9 +2072,6 @@ class NCManageDatabase: NSObject {
         }
         
         result.favorite = favorite
-
-        let account = result.account
-        let serverUrl = result.serverUrl
         
         do {
             try realm.commitWrite()
@@ -2169,9 +2079,6 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return
         }
-        
-        // Update Date Read Directory
-        setDateReadDirectory(serverUrl: serverUrl, account: account)
     }
    
     @objc func setMetadataEncrypted(ocId: String, encrypted: Bool) {
@@ -2186,9 +2093,6 @@ class NCManageDatabase: NSObject {
         }
            
         result.e2eEncrypted = encrypted
-
-        let account = result.account
-        let serverUrl = result.serverUrl
            
         do {
             try realm.commitWrite()
@@ -2196,9 +2100,6 @@ class NCManageDatabase: NSObject {
             print("[LOG] Could not write to database: ", error)
             return
         }
-           
-        // Update Date Read Directory
-        setDateReadDirectory(serverUrl: serverUrl, account: account)
     }
        
     @objc func setMetadataFileNameView(serverUrl: String, fileName: String, newFileNameView: String, account: String) {
@@ -2213,19 +2114,13 @@ class NCManageDatabase: NSObject {
         }
                 
         result.fileNameView = newFileNameView
-        
-        let account = result.account
-        let serverUrl = result.serverUrl
-    
+            
         do {
             try realm.commitWrite()
         } catch let error {
             print("[LOG] Could not write to database: ", error)
             return
         }
-    
-        // Update Date Read Directory
-        setDateReadDirectory(serverUrl: serverUrl, account: account)
     }
     
     @objc func getMetadata(predicate: NSPredicate) -> tableMetadata? {

+ 0 - 1
iOSClient/Favorites/CCFavorites.h

@@ -41,7 +41,6 @@
 @property (nonatomic, strong) NSString *titleViewControl;
 
 - (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector;
-- (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action;
 - (void)listingFavorites;
 
 - (void)actionDelete:(NSIndexPath *)indexPath;

+ 5 - 51
iOSClient/Favorites/CCFavorites.m

@@ -67,9 +67,8 @@
     // Notification
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:k_notificationCenter_progressTask object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(favoriteFile:) name:k_notificationCenter_favoriteFile object:nil];
-    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDatasource) name:k_notificationCenter_reloadDataSource object:nil];
+
     // Metadata
     self.metadata = [tableMetadata new];
     
@@ -96,9 +95,6 @@
         self.title = NSLocalizedString(@"_favorites_", nil);
     
     [self changeTheming];
-    
-    // Query data source
-    [self queryDatasource];
 }
 
 - (void)viewDidAppear:(BOOL)animated
@@ -108,7 +104,7 @@
     // Active Main
     appDelegate.activeFavorites = self;
     
-    [self reloadDatasource:nil action:k_action_NULL];
+    [self reloadDatasource];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -127,35 +123,6 @@
     [appDelegate changeTheming:self tableView:self.tableView collectionView:nil form:false];
 }
 
-- (void)deleteFile:(NSNotification *)notification
-{
-    if (self.view.window == nil) { return; }
-
-    NSDictionary *userInfo = notification.userInfo;
-    tableMetadata *metadata = userInfo[@"metadata"];
-    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
-    NSString *errorDescription = userInfo[@"errorDescription"];
-    
-    if (errorCode == 0 && metadata) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl ocId:metadata.ocId action:k_action_DEL];
-    } else {
-        [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-    }
-}
-
-- (void)favoriteFile:(NSNotification *)notification
-{
-    if (self.view.window == nil) { return; }
-    
-    NSDictionary *userInfo = notification.userInfo;
-    tableMetadata *metadata = userInfo[@"metadata"];
-    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
-    
-    if (errorCode == 0) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl ocId:metadata.ocId action:k_action_MOD];
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== DZNEmptyDataSetSource ====
 #pragma --------------------------------------------------------------------------------------------
@@ -246,8 +213,6 @@
                  for (tableMetadata *metadata in allRecordFavorite)
                      if (![filesOcId containsObject:metadata.ocId])
                          [[NCManageDatabase sharedInstance] setMetadataFavoriteWithOcId:metadata.ocId favorite:NO];
-                 
-                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_clearDateReadDataSource object:nil];
              }];
         
          } else if (errorCode != 0) {
@@ -316,7 +281,6 @@
         [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
         [[NCMainCommon sharedInstance] cancelAllTransfer];
         [NCUtility.sharedInstance stopActivityIndicator];
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil ocId:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];
@@ -444,20 +408,10 @@
     return metadata;
 }
 
-- (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action
-{
-    // test
-    if (appDelegate.activeAccount.length == 0 || self.view.window == nil) {
-        return;
-    }
-    
-    [self queryDatasource];
-}
-
-- (void)queryDatasource
+- (void)reloadDatasource
 {
     // test
-    if (appDelegate.activeAccount.length == 0) {
+    if (appDelegate.activeAccount.length == 0) { // || self.view.window == nil) {
         return;
     }
     

+ 1 - 1
iOSClient/Login/CCLogin.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 09/04/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Login/CCLogin.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 09/04/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 5
iOSClient/Main/CCMain.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -76,10 +76,6 @@
 
 - (void)uploadFileAsset:(NSMutableArray *)assets urls:(NSMutableArray *)urls serverUrl:(NSString *)serverUrl useSubFolder:(BOOL)useSubFolder session:(NSString *)session;
 
-- (void)reloadDatasource:(NSString *)serverUrl ocId:(NSString *)ocId action:(NSInteger)action;
-
-- (void)clearDateReadDataSource:(NSNotification *)notification;
-
 - (void)openAssetsPickerController;
 - (void)openImportDocumentPicker;
 - (void)createFolder;

+ 52 - 180
iOSClient/Main/CCMain.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -53,7 +53,6 @@
     
     // Datasource
     CCSectionDataSourceMetadata *sectionDataSource;
-    NSDate *_dateReadDataSource;
     
     // Search
     NSString *_searchFileName;
@@ -124,15 +123,13 @@
     self.searchController.searchBar.delegate = self;
     
     // Notification
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearDateReadDataSource:) name:k_notificationCenter_clearDateReadDataSource object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDatasource:) name:k_notificationCenter_reloadDataSource object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setTitle) name:k_notificationCenter_setTitleMain object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:k_notificationCenter_progressTask object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(favoriteFile:) name:k_notificationCenter_favoriteFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(renameFile:) name:k_notificationCenter_renameFile object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moveFile:) name:k_notificationCenter_moveFile object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(copyFile:) name:k_notificationCenter_copyFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createFolder:) name:k_notificationCenter_createFolder object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
     
     // Search
@@ -236,11 +233,6 @@
     if (self.navigationController.viewControllers.firstObject == self && self.serverUrl == nil) {
         self.serverUrl = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
     }
-    
-    // Query data source
-    if (self.searchController.isActive == false) {
-        [self queryDatasourceWithReloadData:YES serverUrl:self.serverUrl];
-    }
 }
 
 - (void)viewDidAppear:(BOOL)animated
@@ -277,6 +269,11 @@
     
     // Title
     [self setTitle];
+    
+    // Query data source
+    if (self.searchController.isActive == false) {
+        [self reloadDatasource:self.serverUrl ocId:nil];
+    }
 }
 
 - (void)viewWillDisappear:(BOOL)animated
@@ -325,9 +322,6 @@
 {
     [appDelegate changeTheming:self tableView:self.tableView collectionView:nil form:false];
     
-    // createImagesThemingColor
-    [[NCMainCommon sharedInstance] createImagesThemingColor];
-    
     // Refresh control
     refreshControl.tintColor = UIColor.lightGrayColor;
     refreshControl.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
@@ -345,13 +339,10 @@
     if (searchTextView && [searchTextView isKindOfClass:[UITextField class]]) {
         searchTextView.textColor = NCBrandColor.sharedInstance.textView;
     }
-    
     // Rich Workspace
     [self.viewRichWorkspace loadWithRichWorkspaceText:self.richWorkspaceText];
-    
     // Title
     [self setTitle];
-    
     // Reload Table View
     [self tableViewReloadData];
 }
@@ -368,9 +359,7 @@
 // Settings Advanced : removeAllFiles
 //
 - (void)initializeMain:(NSNotification *)notification
-{
-    _dateReadDataSource = nil;
-    
+{    
     // test
     if (appDelegate.activeAccount.length == 0)
         return;
@@ -411,17 +400,14 @@
         
         NSLog(@"[LOG] Request Service Server Nextcloud");
         [[NCService shared] startRequestServicesServer];
-        
-        // Clear datasorce
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:_serverUrl ocId:nil action:k_action_NULL];
-        
+                
         // Read this folder
         [self readFileReloadFolder];
                 
     } else {
         
         // reload datasource
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:_serverUrl ocId:nil action:k_action_NULL];
+        [self reloadDatasource:_serverUrl ocId:nil];
     }
     
     // Registeration push notification
@@ -455,8 +441,6 @@
             } else {
                 if (self.searchController.isActive) {
                     [self readFolder:self.serverUrl];
-                } else {
-                    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
                 }
             }
         }
@@ -470,16 +454,12 @@
     if (self.view.window == nil) { return; }
     
     NSDictionary *userInfo = notification.userInfo;
-    tableMetadata *metadata = userInfo[@"metadata"];
-    tableMetadata *metadataNew = userInfo[@"metadataNew"];
+//    tableMetadata *metadata = userInfo[@"metadata"];
+//    tableMetadata *metadataNew = userInfo[@"metadataNew"];
     NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
     NSString *errorDescription = userInfo[@"errorDescription"];
     
-    if (errorCode == 0) {
-        if ([metadata.serverUrl isEqualToString:self.serverUrl] || [metadataNew.serverUrl isEqualToString:self.serverUrl]) {
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-        }
-    } else {
+    if (errorCode != 0) {
         [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
     }
 }
@@ -489,16 +469,12 @@
     if (self.view.window == nil) { return; }
     
     NSDictionary *userInfo = notification.userInfo;
-    tableMetadata *metadata = userInfo[@"metadata"];
-    NSString *serverUrlTo = userInfo[@"serverUrlTo"];
+//    tableMetadata *metadata = userInfo[@"metadata"];
+//    NSString *serverUrlTo = userInfo[@"serverUrlTo"];
     NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
     NSString *errorDescription = userInfo[@"errorDescription"];
     
-    if (errorCode == 0) {
-        if ([metadata.serverUrl isEqualToString:self.serverUrl] || [serverUrlTo isEqualToString:self.serverUrl]) {
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-        }
-    } else {
+    if (errorCode != 0) {
         [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
     }
 }
@@ -514,12 +490,9 @@
     BOOL favorite = [userInfo[@"favorite"] boolValue];
     
     if (errorCode == 0) {
-        _dateReadDataSource = nil;
         if (self.searchController.isActive) {
             [self readFolder:self.serverUrl];
-        } else {
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:metadata.ocId action:k_action_MOD];
-        }
+        } 
         
         if (metadata.directory && favorite) {
                        
@@ -542,34 +515,6 @@
     }
 }
 
-- (void)renameFile:(NSNotification *)notification {
-    if (self.view.window == nil) { return; }
-
-    NSDictionary *userInfo = notification.userInfo;
-    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
-    NSString *errorDescription = userInfo[@"errorDescription"];
-    
-    if (errorCode == 0) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-    } else {
-        [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-    }
-}
-
-- (void)createFolder:(NSNotification *)notification {
-    if (self.view.window == nil) { return; }
-    
-    NSDictionary *userInfo = notification.userInfo;
-    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
-    NSString *errorDescription = userInfo[@"errorDescription"];
-    
-    if (errorCode == 0) {
-        [self reloadDatasource:self.serverUrl ocId:nil action:k_action_NULL];
-    } else {
-        [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== DZNEmptyDataSetSource ====
 #pragma --------------------------------------------------------------------------------------------
@@ -786,7 +731,7 @@
                     
                     tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:ocId serverUrl:serverUrl url:@"" contentType:@""];
                     
-                    metadataForUpload.session = k_upload_session;
+                    metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
                     metadataForUpload.sessionSelector = selectorUploadFile;
                     metadataForUpload.size = data.length;
                     metadataForUpload.status = k_metadataStatusWaitUpload;
@@ -802,8 +747,6 @@
                     } else {
                         
                         [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
-                        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-                            
                         [appDelegate startLoadAutoUpload];
                     }
 
@@ -838,7 +781,6 @@
 
 -(void)dismissFormUploadAssets
 {
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
 }
 
 - (void)openAssetsPickerController
@@ -850,7 +792,7 @@
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
                 
-                NCCreateFormUploadAssets *form = [[NCCreateFormUploadAssets alloc] initWithServerUrl:serverUrl assets:(NSMutableArray *)assets urls:(NSMutableArray *)urls cryptated:NO session:k_upload_session delegate:self];
+                NCCreateFormUploadAssets *form = [[NCCreateFormUploadAssets alloc] initWithServerUrl:serverUrl assets:(NSMutableArray *)assets urls:(NSMutableArray *)urls cryptated:NO session:NCCommunicationCommon.shared.sessionIdentifierBackground delegate:self];
                 
                 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:form];
                 [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
@@ -924,13 +866,11 @@
             
             if (metadata.directory == NO && ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] || [metadata.typeFile isEqualToString: k_metadataTypeFile_video])) {
                 
-                [[NCNetworking shared] downloadWithMetadata:metadata selector:selectorSave setFavorite:false completion:^(NSInteger errorCode) { }];
+                [[NCOperationQueue shared] downloadWithMetadata:metadata selector:selectorSave setFavorite:false];                
             }
         }
         
         [_hud hideHud];
-        
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
     });
     
     [self tableViewSelect:false];
@@ -1116,7 +1056,6 @@
         [[NCManageDatabase sharedInstance] addMetadatas:metadatasMOV];
         
         [appDelegate startLoadAutoUpload];
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
     }
 }
 
@@ -1136,7 +1075,6 @@
     // Search Mode
     if (self.searchController.isActive) {
         
-        [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:serverUrl account:appDelegate.activeAccount];
         _searchFileName = @""; // forced reload searchg
         [self updateSearchResultsForSearchController:self.searchController];
         
@@ -1173,9 +1111,7 @@
                             if (result == false) {
                                 [[NCContentPresenter shared] messageNotification:@"_error_e2ee_" description:@"_e2e_error_decode_metadata_" delay:k_dismissAfterSecond type:messageTypeError errorCode:-999];
                             }
-                            
-                            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
-                            
+                                                        
                         } else if (errorCode != kOCErrorServerPathNotFound) {
                             
                             [[NCContentPresenter shared] messageNotification:@"_e2e_error_get_metadata_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
@@ -1188,10 +1124,6 @@
                 }
             }
             
-            if ([serverUrl isEqualToString:_serverUrl]) {
-                [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
-            }
-        
         } else {
             [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
         }
@@ -1210,11 +1142,6 @@
     self.richWorkspaceText = directory.richWorkspace;
     [self setTableViewHeader];
     
-    // Load Datasource
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-    });
-    
     [[NCNetworking shared] readFileWithServerUrlFileName:self.serverUrl account:appDelegate.activeAccount completion:^(NSString *account, tableMetadata *metadata, NSInteger errorCode, NSString *errorDescription) {
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
@@ -1258,7 +1185,7 @@
                  _searchResultMetadatas = [[NSMutableArray alloc] initWithArray:metadatasDB];
                  _metadataFolder = nil;
                  
-                 [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:_serverUrl ocId:nil action:k_action_NULL];
+                 [self reloadDatasource:_serverUrl ocId:nil];
                  [self tableViewReloadData];
                  [self setTitle];
              }];
@@ -1317,14 +1244,14 @@
         
         if (_searchResultMetadatas.count == 0 && fileName.length == 0) {
 
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
+            [self reloadDatasource:_serverUrl ocId:nil];
         }
         
     } else {
         
         [self createRefreshControl];
 
-        [self reloadDatasource:self.serverUrl ocId:nil action:k_action_NULL];
+        [self reloadDatasource:_serverUrl ocId:nil];
     }
 }
 
@@ -1340,10 +1267,9 @@
         [self.searchController setActive:NO];
     
         _searchFileName = @"";
-        _dateReadDataSource = nil;
         _searchResultMetadatas = [NSMutableArray new];
         
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
+        [self reloadDatasource:_serverUrl ocId:nil];
     }
 
 }
@@ -1417,10 +1343,7 @@
 // DELEGATE : Select
 - (void)dismissSelectWithServerUrl:(NSString *)serverUrl metadata:(tableMetadata *)metadata type:(NSString *)type buttonType:(NSString *)buttonType overwrite:(BOOL)overwrite
 {
-    if (serverUrl == nil) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-    } else {
-        
+    if (serverUrl != nil) {
         // E2EE DENIED
         if ([CCUtility isFolderEncrypted:serverUrl e2eEncrypted:metadata.e2eEncrypted account:appDelegate.activeAccount]) {
             
@@ -1548,7 +1471,6 @@
         [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
         [[NCMainCommon sharedInstance] cancelAllTransfer];
         [NCUtility.sharedInstance stopActivityIndicator];
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil ocId:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];
@@ -2011,21 +1933,17 @@
                 // Prepare record metadata
                 tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:ocId serverUrl:self.serverUrl url:@"" contentType:@""];
             
-                metadataForUpload.session = k_upload_session;
+                metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
                 metadataForUpload.sessionSelector = selectorUploadFile;
                 metadataForUpload.size = metadata.size;
                 metadataForUpload.status = k_metadataStatusWaitUpload;
                             
                 // Add Medtadata for upload
                 [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
-                
-                [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
             }
         }
     }
-    
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-    
+        
     [appDelegate startLoadAutoUpload];
 }
 
@@ -2097,7 +2015,7 @@
                 [[NSFileManager defaultManager] removeItemAtPath:[CCUtility getDirectoryProviderStorageOcId:metadataLivePhoto.ocId] error:nil];
             }
             
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
+            [self reloadDatasource:metadata.serverUrl ocId:metadata.ocId];
         }]];
     }
     
@@ -2127,17 +2045,23 @@
 #pragma mark - ==== Datasource ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)clearDateReadDataSource:(NSNotification *)notification
+- (void)reloadDatasource:(NSNotification *)notification
 {
-    _dateReadDataSource = Nil;
+    NSDictionary *userInfo = notification.userInfo;
+    NSString *ocId = userInfo[@"ocId"];
+    NSString *serverUrl = userInfo[@"serverUrl"];
     
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
+    [self reloadDatasource:serverUrl ocId:ocId];
 }
 
-- (void)reloadDatasource:(NSString *)serverUrl ocId:(NSString *)ocId action:(NSInteger)action
+- (void)reloadDatasource:(NSString *)serverUrl ocId:(NSString *)ocId
 {
     // test
-    if (appDelegate.activeAccount.length == 0 || serverUrl.length == 0 || serverUrl == nil || self.view.window == nil)
+    if (appDelegate.activeAccount.length == 0 || serverUrl.length == 0 || serverUrl == nil) // || self.view.window == nil)
+        return;
+    
+    // Se non siamo nella dir appropriata esci
+    if ([serverUrl isEqualToString:self.serverUrl] == NO || self.serverUrl == nil)
         return;
     
     // Search Mode
@@ -2174,53 +2098,27 @@
         return;
     }
     
-    // Se non siamo nella dir appropriata esci
-    if ([serverUrl isEqualToString:self.serverUrl] == NO || self.serverUrl == nil) {
-        return;
-    }
-    
-    // Controllo data lettura Data Source
-    tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl]];
-    if (tableDirectory == nil) {
-        return;
-    }
-    
     // Get MetadataFolder
     if ([serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]])
         _metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, k_serverUrl_root]];
     else
-        _metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", tableDirectory.ocId]];
+        _metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl]];
     
-    // Remove optimization for encrypted directory
-    if (_metadataFolder.e2eEncrypted)
-        _dateReadDataSource = nil;
-
-    NSDate *dateDateRecordDirectory = tableDirectory.dateReadDirectory;
-    
-    if ([dateDateRecordDirectory compare:_dateReadDataSource] == NSOrderedDescending || dateDateRecordDirectory == nil || _dateReadDataSource == nil) {
-        
-        NSLog(@"[LOG] Rebuild Data Source File : %@", _serverUrl);
-
-        _dateReadDataSource = [NSDate date];
+    _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
+    _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
     
-        // Data Source
-        
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
-            CCSectionDataSourceMetadata *sectionDataSourceTemp = [self queryDatasourceWithReloadData:NO serverUrl:serverUrl];
+        NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl] sorted:nil ascending:NO];
+        
+        // [CCUtility getGroupBySettings]
+        CCSectionDataSourceMetadata *sectionDataSourceTemp = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:nil filterTypeFileImage:NO filterTypeFileVideo:NO sorted:[CCUtility getOrderSettings] ascending:[CCUtility getAscendingSettings] activeAccount:appDelegate.activeAccount];
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                sectionDataSource = sectionDataSourceTemp;
-                [self tableViewReloadData];
-            });
+        dispatch_async(dispatch_get_main_queue(), ^{
+            sectionDataSource = sectionDataSourceTemp;
+            [self tableViewReloadData];
         });
-        
-    } else {
-        
-        [self tableViewReloadData];
-
-         NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
-    }
+    });
     
     // BLINK
     if (self.blinkFileNamePath != nil) {
@@ -2248,32 +2146,6 @@
     }
 }
 
-- (CCSectionDataSourceMetadata *)queryDatasourceWithReloadData:(BOOL)withReloadData serverUrl:(NSString *)serverUrl
-{
-    // test
-    if (appDelegate.activeAccount.length == 0 || serverUrl == nil) {
-        return nil;
-    }
-    
-    // get auto upload folder
-    _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
-    _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
-    
-    CCSectionDataSourceMetadata *sectionDataSourceTemp = [CCSectionDataSourceMetadata new];
-
-    NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl] sorted:nil ascending:NO];
-    
-    // [CCUtility getGroupBySettings]
-    sectionDataSourceTemp = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:nil filterTypeFileImage:NO filterTypeFileVideo:NO sorted:[CCUtility getOrderSettings] ascending:[CCUtility getAscendingSettings] activeAccount:appDelegate.activeAccount];
-    
-    if (withReloadData) {
-        sectionDataSource = sectionDataSourceTemp;
-        [self tableViewReloadData];
-    }
-    
-    return sectionDataSourceTemp;
-}
-
 - (NSArray *)getMetadatasFromSelectedRows:(NSArray *)selectedRows
 {
     NSMutableArray *metadatas = [[NSMutableArray alloc] init];

+ 1 - 1
iOSClient/Main/CCSection.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Main/CCSection.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -228,8 +228,7 @@ extension NCCreateFormUploadConflictDelegate {
         } else {
             
             NCManageDatabase.sharedInstance.addMetadatas(metadatasNOConflict)
-            appDelegate.startLoadAutoUpload()
-            NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: serverUrl, ocId: nil, action: Int32(k_action_NULL))
+            appDelegate.startLoadAutoUpload()            
         }
                 
         dismiss(animated: true)

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

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 14/11/18.
-//  Copyright © 2017 Marino Faggiana. All rights reserved.
+//  Copyright © 2018 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 2 - 3
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 14/11/2018.
-//  Copyright © 2017 Marino Faggiana. All rights reserved.
+//  Copyright © 2018 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -412,7 +412,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         //Create metadata for upload
         let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.activeAccount, fileName: fileNameSave, ocId: UUID().uuidString, serverUrl: serverUrl, url: appDelegate.activeUrl, contentType: "")
         
-        metadataForUpload.session = k_upload_session
+        metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground
         metadataForUpload.sessionSelector = selectorUploadFile
         metadataForUpload.status = Int(k_metadataStatusWaitUpload)
                 
@@ -563,7 +563,6 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         }
         
         NCManageDatabase.sharedInstance.addMetadata(metadata)
-        NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: serverUrl, ocId: nil, action: Int32(k_action_NULL))
 
         self.appDelegate.startLoadAutoUpload()
                         

+ 4 - 4
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 9/03/2019.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import NCCommunication
 
 class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAudioPlayerDelegate, NCCreateFormUploadConflictDelegate {
     
@@ -230,7 +231,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
         
         let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.activeAccount, fileName: fileNameSave, ocId: UUID().uuidString, serverUrl: self.serverUrl, url: "", contentType: "")
         
-        metadataForUpload.session = k_upload_session
+        metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground
         metadataForUpload.sessionSelector = selectorUploadFile
         metadataForUpload.status = Int(k_metadataStatusWaitUpload)
         
@@ -265,8 +266,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
         CCUtility.copyFile(atPath: self.fileNamePath, toPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
                    
         NCManageDatabase.sharedInstance.addMetadata(metadata)
-        NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: self.serverUrl, ocId: nil, action: Int32(k_action_NULL))
-
+        
         self.appDelegate.startLoadAutoUpload()
         
         self.dismiss(animated: true, completion: nil)

+ 10 - 12
iOSClient/Main/Menu/CCMain+Menu.swift

@@ -75,7 +75,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("fileName")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil)
                 }
             )
         )
@@ -95,7 +95,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("date")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil)
                 }
             )
         )
@@ -115,7 +115,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("size")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil)
                 }
             )
         )
@@ -128,7 +128,7 @@ extension CCMain {
                 on: CCUtility.getDirectoryOnTop(),
                 action: { menuAction in
                     CCUtility.setDirectoryOnTop(!CCUtility.getDirectoryOnTop())
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil)
                 }
             )
         )
@@ -325,9 +325,7 @@ extension CCMain {
                             if(isOffline) {
                                 CCSynchronize.shared()?.readFolder(serverUrl, selector: selectorReadFolderWithDownload, account: appDelegate.activeAccount)
                             }
-                            DispatchQueue.main.async {
-                                self.tableView.reloadRows(at: [indexPath], with: .none)
-                            }
+                            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                         }
                     )
                 )
@@ -345,7 +343,8 @@ extension CCMain {
                                     NCManageDatabase.sharedInstance.deleteE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl))
                                     NCManageDatabase.sharedInstance.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: true, richWorkspace: nil, account: metadata.account)
                                     NCManageDatabase.sharedInstance.setMetadataEncrypted(ocId: metadata.ocId, encrypted: true)
-                                    NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: self.serverUrl, ocId: metadata.ocId, action: k_action_MOD)
+                                    
+                                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                                 } else {
                                     NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_mark_folder_", comment: ""), description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: .error, errorCode: errorCode)
                                 }
@@ -367,7 +366,8 @@ extension CCMain {
                                     NCManageDatabase.sharedInstance.deleteE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, "\(self.serverUrl ?? "")/\(metadata.fileName)"))
                                     NCManageDatabase.sharedInstance.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: false, richWorkspace: nil, account: metadata.account)
                                     NCManageDatabase.sharedInstance.setMetadataEncrypted(ocId: metadata.ocId, encrypted: false)
-                                    NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: self.serverUrl, ocId: metadata.ocId, action: k_action_MOD)
+                                    
+                                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                                 } else {
                                     NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_delete_mark_folder_", comment: ""), description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: .error, errorCode: errorCode)
                                 }
@@ -494,9 +494,7 @@ extension CCMain {
                                 
                             } else {
                                 NCManageDatabase.sharedInstance.setLocalFile(ocId: metadata.ocId, offline: !localFile!.offline)
-                                DispatchQueue.main.async {
-                                    self.tableView.reloadRows(at: [indexPath], with: .none)
-                                }
+                                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                             }
                         }
                     )

+ 0 - 2
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -147,8 +147,6 @@ extension NCDetailNavigationController {
                             NCNetworking.shared.download(metadata: metadata, selector: selectorLoadOffline) { (_) in }
                         } else {
                             NCManageDatabase.sharedInstance.setLocalFile(ocId: metadata.ocId, offline: !localFile!.offline)
-                            NotificationCenter.default.post(name: Notification.Name.init(rawValue:
-                                k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                         }
                     }
                 )

+ 15 - 284
iOSClient/Main/NCMainCommon.swift

@@ -40,13 +40,6 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
     var metadataEditPhoto: tableMetadata?
     var docController: UIDocumentInteractionController?
 
-    lazy var operationQueueReloadDatasource: OperationQueue = {
-        let queue = OperationQueue()
-        queue.name = "Reload main datasource queue"
-        queue.maxConcurrentOperationCount = 1
-        return queue
-    }()
-    
     //MARK: -
     
     struct NCMainCommonImages {
@@ -149,11 +142,18 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
             NCNetworking.shared.cancelUpload(metadata: metadata)
         } else {
         
-            var actionReloadDatasource = k_action_NULL
-            guard let session = CCNetworking.shared().getSessionfromSessionDescription(metadata.session) else { return }
+            var session: URLSession?
+            if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackground {
+                session = NCCommunicationBackground.shared.sessionManagerTransfer
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan {
+                session = NCCommunicationBackground.shared.sessionManagerTransferWWan
+            } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierExtension {
+                session = NCCommunicationBackground.shared.sessionManagerTransferExtension
+            }
+            
             var metadata = metadata
 
-            session.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) in
+            session!.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) in
                 
                 var cancel = false
                 
@@ -175,18 +175,13 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
                         catch { }
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                     }
-                    actionReloadDatasource = k_action_DEL
-                }
-                
-                DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-                    self.reloadDatasource(ServerUrl: metadata.serverUrl, ocId: metadata.ocId, action: actionReloadDatasource)
                 }
             }
         }
     }
     
     @objc func cancelAllTransfer() {
-        
+
         // Delete k_metadataStatusWaitUpload OR k_metadataStatusUploadError
         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "status == %d OR status == %d", appDelegate.activeAccount, k_metadataStatusWaitUpload, k_metadataStatusUploadError))
         
@@ -212,9 +207,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
             }
         }
         
-        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-            return
-        }
+        NCOperationQueue.shared.downloadCancelAll()
     }
     
     //MARK: -
@@ -235,7 +228,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
         
         // Download preview
         if downloadThumbnail {
-            NCNetworkingMain.sharedInstance.downloadThumbnail(with: metadata, view: collectionView, indexPath: indexPath)
+            NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: appDelegate.activeUrl, view: collectionView, indexPath: indexPath)
         }
         
         var isShare = false
@@ -475,7 +468,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
             cell.labelTitle.text = metadata.fileNameView
             
             // Download preview
-            NCNetworkingMain.sharedInstance.downloadThumbnail(with: metadata, view: tableView, indexPath: indexPath)
+            NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: appDelegate.activeUrl, view: tableView, indexPath: indexPath)
             
             // Share
             var isShare = false
@@ -765,37 +758,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
       
         return metadata
     }
-    
-    @objc func reloadDatasource(ServerUrl: String?, ocId: String?, action: Int32) {
-        
-        if operationQueueReloadDatasource.operationCount > 0 {
-            return
-        }
-        
-       
-        if self.appDelegate.activeMain != nil && ServerUrl != nil && self.appDelegate.activeMain.serverUrl == ServerUrl {
-            self.operationQueueReloadDatasource.addOperation {
-                DispatchQueue.main.async {
-                    self.appDelegate.activeMain.reloadDatasource(ServerUrl, ocId: ocId, action: Int(action))
-                }
-            }
-        }
-        if self.appDelegate.activeFavorites != nil && self.appDelegate.activeFavorites.viewIfLoaded?.window != nil {
-            self.operationQueueReloadDatasource.addOperation {
-                DispatchQueue.main.async {
-                    self.appDelegate.activeFavorites.reloadDatasource(ocId, action: Int(action))
-                }
-            }
-        }
-        if self.appDelegate.activeTransfers != nil && self.appDelegate.activeTransfers.viewIfLoaded?.window != nil {
-            self.operationQueueReloadDatasource.addOperation {
-                DispatchQueue.main.async {
-                    self.appDelegate.activeTransfers.reloadDatasource(ocId, action: Int(action))
-                }
-            }
-        }
-    }
-    
+
     @objc func isValidIndexPath(_ indexPath: IndexPath, view: Any) -> Bool {
         
         if view is UICollectionView {
@@ -951,235 +914,3 @@ class CCMainTabBarController : UITabBarController, UITabBarControllerDelegate {
         })
     }
 }
-
-//MARK: - Networking Main
-
-class NCNetworkingMain: NSObject, IMImagemeterViewerDelegate {
-    @objc static let sharedInstance: NCNetworkingMain = {
-        let instance = NCNetworkingMain()
-        return instance
-    }()
-    
-    lazy var operationQueueNetworkingMain: OperationQueue = {
-        let queue = OperationQueue()
-        queue.name = "com.nextcloud.operationQueueNetworkingMain"
-        queue.maxConcurrentOperationCount = 1
-        return queue
-    }()
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
-    #if HC
-    // IMImagemeterViewerDelegate
-    func closeImagemeterViewer(metadata: tableMetadata?, bundleDirectory: String) {
-        guard let metadata = metadata else { return }
-        
-        let ocIdTemp = NSUUID().uuidString.lowercased()
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: metadata.fileName)!
-        let bundleDirectoryURL = URL(fileURLWithPath: bundleDirectory)
-        let fileNameZipUrl = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: metadata.fileName))
-        
-        // Create IMI
-        try? FileManager.default.removeItem(at: fileNameZipUrl)
-        do {
-            try FileManager().zipItem(at: bundleDirectoryURL, to:fileNameZipUrl)
-        } catch {
-            NCContentPresenter.shared.messageNotification("_error_", description: "Creation of IMI archive failed with error", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
-            return
-        }
-        
-        // Verify if is changed
-        if IMUtility.shared.IMIsChange(metadata: metadata, fileNameZipUrl: fileNameZipUrl) {
-            let com = IMCommunication.init()
-            _ = com.uploadFileIMI(serverUrl: metadata.serverUrl, fileName: metadata.fileName, fileNameLocalPath: fileNameLocalPath, ocId: ocIdTemp)
-        }
-        
-        // Remove bundle directory
-        try? FileManager.default.removeItem(atPath: bundleDirectory)
-    }
-    #endif
-    
-    @objc func downloadThumbnail(with metadata: tableMetadata, view: Any, indexPath: IndexPath) {
-        operationQueueNetworkingMain.addOperation(NCOperationNetworkingMain.init(metadata: metadata, view: view, indexPath: indexPath, networkingFunc: "downloadThumbnail"))
-    }
-    
-    func downloadThumbnail(with metadata: tableMetadata, view: Any, indexPath: IndexPath, closure: @escaping () -> ()) {
-        
-        if !metadata.isInvalidated && metadata.hasPreview && (!CCUtility.fileProviderStorageIconExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
-            var cell: NCImageCellProtocol?
-            
-            if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                cell = (view as! UICollectionView).cellForItem(at: indexPath) as? NCImageCellProtocol
-            } else  if view is UITableView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                cell = (view as! UITableView).cellForRow(at: indexPath) as? NCImageCellProtocol
-            }
-            
-            if (cell != nil) {
-                cell!.filePreviewImageView.image = nil
-                cell!.filePreviewImageView.backgroundColor = UIColor.lightGray
-            }
-            
-            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
-            let fileNameLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-                    
-            NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNameLocalPath: fileNameLocalPath, width: Int(k_sizePreview), height: Int(k_sizePreview)) { (account, data, errorCode, errorMessage) in
-                var cell: NCImageCellProtocol?
-                
-                if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                    cell = (view as! UICollectionView).cellForItem(at: indexPath) as? NCImageCellProtocol
-                } else  if view is UITableView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                    cell = (view as! UITableView).cellForRow(at: indexPath) as? NCImageCellProtocol
-                }
-                
-                if (cell != nil) {
-                    var previewImage: UIImage!
-                    if errorCode == 0 && data != nil {
-                        if let image = UIImage(data: data!) {
-                            previewImage = image
-                        }
-                    } else {
-                        if metadata.iconName.count > 0 {
-                            previewImage = UIImage(named: metadata.iconName)
-                        } else {
-                            previewImage = UIImage(named: "file")
-                        }
-                    }
-                    cell!.filePreviewImageView.backgroundColor = nil
-                    UIView.transition(with: cell!.filePreviewImageView,
-                    duration: 0.75,
-                    options: .transitionCrossDissolve,
-                    animations: { cell!.filePreviewImageView.image = previewImage!},
-                    completion: nil)
-                }
-                return closure()
-            }
-        }
-        return closure()
-    }
-}
-
-//MARK: - Operation Networking Main
-
-class NCOperationNetworkingMain: Operation {
-    
-    private var _executing : Bool = false
-    override var isExecuting : Bool {
-        get { return _executing }
-        set {
-            guard _executing != newValue else { return }
-            willChangeValue(forKey: "isExecuting")
-            _executing = newValue
-            didChangeValue(forKey: "isExecuting")
-        }
-    }
-
-    private var _finished : Bool = false
-    override var isFinished : Bool {
-        get { return _finished }
-        set {
-            guard _finished != newValue else { return }
-            willChangeValue(forKey: "isFinished")
-            _finished = newValue
-            didChangeValue(forKey: "isFinished")
-        }
-    }
-    
-    private var metadata: tableMetadata?
-    private var view: Any?
-    private var indexPath: IndexPath?
-    private var networkingFunc: String = ""
-
-    init(metadata: tableMetadata?, view: Any?, indexPath: IndexPath?, networkingFunc: String) {
-        super.init()
-        
-        if metadata != nil { self.metadata = metadata! }
-        if view != nil { self.view = view! }
-        if indexPath != nil { self.indexPath = indexPath! }
-        
-        self.networkingFunc = networkingFunc
-    }
-    
-    override func start() {
-        if !Thread.isMainThread {
-            
-            self.performSelector(onMainThread:#selector(start), with: nil, waitUntilDone: false)
-            
-        } else {
-        
-            isExecuting = true
-        
-            if isCancelled {
-                finish()
-            } else {
-                poolNetworking()
-            }
-        }
-    }
-    
-    func finish() {
-        isExecuting = false
-        isFinished = true
-    }
-    
-    override func cancel() {
-        super.cancel()
-        
-        if isExecuting {
-            complete()
-        }
-    }
-    
-    func complete() {
-        finish()
-        
-        UIApplication.shared.isNetworkActivityIndicatorVisible = false
-    }
-    
-    func poolNetworking() {
-        UIApplication.shared.isNetworkActivityIndicatorVisible = true
-        
-        switch networkingFunc {
-        case "downloadThumbnail":
-            NCNetworkingMain.sharedInstance.downloadThumbnail(with: metadata!, view: view!, indexPath: indexPath!) {
-                self.complete()
-            }
-        default:
-            print("error")
-        }
-    }
-}
-
-
-//MARK: - Function Main
-
-class NCFunctionMain: NSObject {
-    
-    @objc static let sharedInstance: NCFunctionMain = {
-        let instance = NCFunctionMain()
-        return instance
-    }()
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    
-    @objc func synchronizeOffline() {
-        
-        let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "serverUrl", ascending: true)
-        if (directories != nil) {
-            for directory: tableDirectory in directories! {
-                CCSynchronize.shared()?.readFolder(directory.serverUrl, selector: selectorReadFolderWithDownload, account: appDelegate.activeAccount)
-            }
-        }
-        
-        let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "fileName", ascending: true)
-        if (files != nil) {
-            for file: tableLocalFile in files! {
-                guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", file.ocId)) else {
-                    continue
-                }
-                CCSynchronize.shared()?.readFile(metadata.ocId, fileName: metadata.fileName, serverUrl: metadata.serverUrl, selector: selectorReadFileWithDownload, account: appDelegate.activeAccount)
-            }
-        }
-    }
-}
-
-

+ 1 - 1
iOSClient/Main/NCMainRefreshControl.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 20/01/2020.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2020 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Main/NCMainTabBar.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 06/01/2020.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Main/NCPhotosPickerViewController.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 11/11/2018.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2018 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/ManageLocation+ManageAsset/CCManageLocation.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 23/07/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/ManageLocation+ManageAsset/CCManageLocation.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 23/07/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/MenuAccount/CCMenuAccount.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 07/04/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/MenuAccount/CCMenuAccount.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 07/04/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 3 - 9
iOSClient/Networking/CCNetworking.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/06/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -37,14 +37,8 @@
 
 + (CCNetworking *)sharedNetworking;
 
-#pragma mark ===== Session =====
-
-- (NSURLSession *)getSessionfromSessionDescription:(NSString *)sessionDescription;
-- (void)invalidateAndCancelAllSession;
-
-#pragma mark ===== Upload =====
-
-- (void)uploadFile:(tableMetadata *)metadata taskStatus:(NSInteger)taskStatus;
+//- (NSURLSession *)getSessionfromSessionDescription:(NSString *)sessionDescription;
+//- (void)uploadFile:(tableMetadata *)metadata taskStatus:(NSInteger)taskStatus;
 
 @end
 

+ 29 - 127
iOSClient/Networking/CCNetworking.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/06/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -50,13 +50,9 @@
 - (id)init
 {    
     self = [super init];
-    
-    // Initialization Sessions
-    
-
+        
     [self sessionUpload];
     [self sessionWWanUpload];
-    [self sessionUploadForeground];
     
     return self;
 }
@@ -72,7 +68,7 @@
     
     if (sessionUpload == nil) {
         
-        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:k_upload_session];
+        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@""];
         
         configuration.allowsCellularAccess = YES;
         configuration.sessionSendsLaunchEvents = YES;
@@ -81,7 +77,7 @@
         configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
 
         sessionUpload = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
-        sessionUpload.sessionDescription = k_upload_session;
+        sessionUpload.sessionDescription = @"";
     }
     return sessionUpload;
 }
@@ -92,7 +88,7 @@
     
     if (sessionWWanUpload == nil) {
         
-        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:k_upload_session_wwan];
+        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@""];
         
         configuration.allowsCellularAccess = NO;
         configuration.sessionSendsLaunchEvents = YES;
@@ -101,47 +97,18 @@
         configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
         
         sessionWWanUpload = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
-        sessionWWanUpload.sessionDescription = k_upload_session_wwan;
+        sessionWWanUpload.sessionDescription = @"";
     }
     return sessionWWanUpload;
 }
 
-- (NSURLSession *)sessionUploadForeground
-{
-    static NSURLSession *sessionUploadForeground;
-    
-    if (sessionUploadForeground == nil) {
-        
-        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
-        
-        configuration.allowsCellularAccess = YES;
-        configuration.discretionary = NO;
-        configuration.HTTPMaximumConnectionsPerHost = k_maxHTTPConnectionsPerHost;
-        configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
-        
-        sessionUploadForeground = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
-        sessionUploadForeground.sessionDescription = k_upload_session_foreground;
-    }
-    return sessionUploadForeground;
-}
-
 - (NSURLSession *)getSessionfromSessionDescription:(NSString *)sessionDescription
 {
-    if ([sessionDescription isEqualToString:k_upload_session]) return [self sessionUpload];
-    if ([sessionDescription isEqualToString:k_upload_session_wwan]) return [self sessionWWanUpload];
-    if ([sessionDescription isEqualToString:k_upload_session_foreground]) return [self sessionUploadForeground];
+   
     
     return nil;
 }
 
-- (void)invalidateAndCancelAllSession
-{
- 
-    [[self sessionUpload] invalidateAndCancel];
-    [[self sessionWWanUpload] invalidateAndCancel];
-    [[self sessionUploadForeground] invalidateAndCancel];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== URLSession download/upload =====
 #pragma --------------------------------------------------------------------------------------------
@@ -409,7 +376,6 @@
     NSMutableURLRequest *request;
     PHAsset *asset;
     NSError *error;
-    NSString *serverUrl = metadata.serverUrl;
     
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
     if (tableAccount == nil) {
@@ -447,66 +413,27 @@
             [request setValue:[NSString stringWithFormat:@"%ld", dateFileCreation] forHTTPHeaderField:@"X-OC-Mtime"];
         }
     }
-     
-    // E2EE : CREATE AND SEND METADATA
-    if ([CCUtility isFolderEncrypted:metadata.serverUrl e2eEncrypted:metadata.e2eEncrypted account:tableAccount.account] && [CCUtility isEndToEndEnabled:tableAccount.account]) {
          
-#ifndef EXTENSION
-        
-        [[NCNetworkingE2EE shared] sendE2EMetadataWithAccount:tableAccount.account serverUrl:serverUrl fileNameRename:nil fileNameNewRename:nil deleteE2eEncryption:nil url:tableAccount.url upload:true completion:^(NSString *e2eToken, NSInteger errorCode, NSString *errorDescription) {
-            
-            if (errorCode == 0) {
-                
-                // NSURLSession
-                NSURLSession *sessionUpload;
-                if ([metadata.session isEqualToString:k_upload_session]) sessionUpload = [self sessionUpload];
-                else if ([metadata.session isEqualToString:k_upload_session_wwan]) sessionUpload = [self sessionWWanUpload];
-                else if ([metadata.session isEqualToString:k_upload_session_foreground]) sessionUpload = [self sessionUploadForeground];
-                
-                [request setValue:e2eToken forHTTPHeaderField:@"e2e-token"];
-                NSURLSessionUploadTask *uploadTask = [sessionUpload uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileName]]];
-                
-                // Manage uploadTask cancel,suspend,resume
-                if (taskStatus == k_taskStatusCancel) [uploadTask cancel];
-                else if (taskStatus == k_taskStatusSuspend) [uploadTask suspend];
-                else if (taskStatus == k_taskStatusResume) [uploadTask resume];
-                
-                // *** E2EE ***
-                [[NCManageDatabase sharedInstance] setMetadataSession:metadata.session sessionError:@"" sessionSelector:nil sessionTaskIdentifier:uploadTask.taskIdentifier status:k_metadataStatusUploading predicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
-                
-                NSLog(@"[LOG] Upload file %@ TaskIdentifier %lu", metadata.fileName, (unsigned long)uploadTask.taskIdentifier);
-                                                                
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadFileStart object:nil userInfo:@{@"ocId": metadata.ocId, @"task": uploadTask, @"serverUrl": metadata.serverUrl, @"account": metadata.account}];
-                
-            } else {
-                [[NCManageDatabase sharedInstance] setMetadataSession:metadata.session sessionError:errorDescription sessionSelector:nil sessionTaskIdentifier:k_taskIdentifierDone status:k_metadataStatusUploadError predicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadedFile object:nil userInfo:@{@"metadata": metadata, @"errorCode": @(errorCode), @"errorDescription": errorDescription}];
-            }
-        }];
-#endif
-        
-     } else {
+     // NSURLSession
+     NSURLSession *sessionUpload;
+//     if ([metadata.session isEqualToString:k_upload_session]) sessionUpload = [self sessionUpload];
+//     else if ([metadata.session isEqualToString:k_upload_session_wwan]) sessionUpload = [self sessionWWanUpload];
+     
+     NSURLSessionUploadTask *uploadTask = [sessionUpload uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileName]]];
+     
+     // Manage uploadTask cancel,suspend,resume
+     if (taskStatus == k_taskStatusCancel) [uploadTask cancel];
+     else if (taskStatus == k_taskStatusSuspend) [uploadTask suspend];
+     else if (taskStatus == k_taskStatusResume) [uploadTask resume];
+     
+     // *** PLAIN ***
+     [[NCManageDatabase sharedInstance] setMetadataSession:metadata.session sessionError:@"" sessionSelector:nil sessionTaskIdentifier:uploadTask.taskIdentifier status:k_metadataStatusUploading predicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
+     
+     NSLog(@"[LOG] Upload file %@ TaskIdentifier %lu", metadata.fileName, (unsigned long)uploadTask.taskIdentifier);
+     
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadFileStart object:nil userInfo:@{@"ocId": metadata.ocId, @"task": uploadTask, @"serverUrl": metadata.serverUrl, @"account": metadata.account}];
     
-         // NSURLSession
-         NSURLSession *sessionUpload;
-         if ([metadata.session isEqualToString:k_upload_session]) sessionUpload = [self sessionUpload];
-         else if ([metadata.session isEqualToString:k_upload_session_wwan]) sessionUpload = [self sessionWWanUpload];
-         else if ([metadata.session isEqualToString:k_upload_session_foreground]) sessionUpload = [self sessionUploadForeground];
-         
-         NSURLSessionUploadTask *uploadTask = [sessionUpload uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileName]]];
-         
-         // Manage uploadTask cancel,suspend,resume
-         if (taskStatus == k_taskStatusCancel) [uploadTask cancel];
-         else if (taskStatus == k_taskStatusSuspend) [uploadTask suspend];
-         else if (taskStatus == k_taskStatusResume) [uploadTask resume];
-         
-         // *** PLAIN ***
-         [[NCManageDatabase sharedInstance] setMetadataSession:metadata.session sessionError:@"" sessionSelector:nil sessionTaskIdentifier:uploadTask.taskIdentifier status:k_metadataStatusUploading predicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
-         
-         NSLog(@"[LOG] Upload file %@ TaskIdentifier %lu", metadata.fileName, (unsigned long)uploadTask.taskIdentifier);
-         
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadFileStart object:nil userInfo:@{@"ocId": metadata.ocId, @"task": uploadTask, @"serverUrl": metadata.serverUrl, @"account": metadata.account}];
-     }
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_reloadDataSource object:nil userInfo:@{@"ocId": metadata.ocId,@"serverUrl": metadata.serverUrl}];
 }
 
 - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
@@ -539,7 +466,6 @@
 {
     NSString *tempocId = metadata.ocId;
     NSString *errorMessage = @"";
-    BOOL isE2EEDirectory = false;
 
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
     if (tableAccount == nil) {
@@ -548,12 +474,7 @@
         [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadedFile object:nil userInfo:@{@"metadata": metadata, @"errorCode": @(errorCode), @"errorDescription": errorMessage}];
         return;
     }
-    
-    // is this a E2EE Directory ?
-    if ([CCUtility isFolderEncrypted:serverUrl e2eEncrypted:false account:tableAccount.account] && [CCUtility isEndToEndEnabled:tableAccount.account]) {
-        isE2EEDirectory = true;
-    }
-    
+
     // ERRORE
     if (errorCode != 0) {
         
@@ -569,7 +490,7 @@
                 
                 errorCode = 0;
                 
-                metadata.session = k_upload_session;
+                //metadata.session = k_upload_session;
                 metadata.sessionError = @"";
                 metadata.sessionTaskIdentifier = 0;
                 metadata.status = k_metadataStatusInUpload;
@@ -615,11 +536,6 @@
             
             // Add metadata ocId
             metadata.date = date;
-            if (isE2EEDirectory) {
-                metadata.e2eEncrypted = true;
-            } else {
-                metadata.e2eEncrypted = false;
-            }
             metadata.etag = etag;
             metadata.ocId = ocId;
             metadata.session = @"";
@@ -645,11 +561,6 @@
             
             // Replace Metadata
             metadata.date = date;
-            if (isE2EEDirectory) {
-                metadata.e2eEncrypted = true;
-            } else {
-                metadata.e2eEncrypted = false;
-            }
             metadata.etag = etag;
             metadata.ocId = ocId;
             metadata.session = @"";
@@ -698,18 +609,9 @@
             (void)[[NCManageDatabase sharedInstance] addLocalFileWithMetadata:metadata];
         }
     }
-        
-#ifndef EXTENSION
-
-    // E2EE : UNLOCK
-    tableMetadata *e2eeMetadataInSession = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND e2eEncrypted == 1 AND (status == %d OR status == %d)", metadata.account, metadata.serverUrl, k_metadataStatusInUpload, k_metadataStatusUploading]];
-    
-    if (isE2EEDirectory && e2eeMetadataInSession == nil) {
-        [[NCNetworkingE2EE shared] unlockWithAccount:tableAccount.account serverUrl:serverUrl completion:^(tableDirectory *directory, NSString *e2eToken, NSInteger errorCode, NSString *errorDescription) { }];
-    }
-#endif
     
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_uploadedFile object:nil userInfo:@{@"metadata": metadata, @"errorCode": @(errorCode), @"errorDescription": errorMessage}];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_reloadDataSource object:nil userInfo:@{@"ocId": metadata.ocId,@"serverUrl": metadata.serverUrl}];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 118 - 40
iOSClient/Networking/NCNetworking.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 23/10/19.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -27,10 +27,10 @@ import NCCommunication
 import Alamofire
 
 @objc public protocol NCNetworkingDelegate {
-    @objc optional func downloadProgress(_ progress: Double, fileName: String, ServerUrl: String, session: URLSession, task: URLSessionTask)
-    @objc optional func uploadProgress(_ progress: Double, fileName: String, ServerUrl: String, session: URLSession, task: URLSessionTask)
-    @objc optional func downloadComplete(fileName: String, serverUrl: String, etag: String?, date: NSDate?, dateLastModified: NSDate?, length: Double, description: String?, error: Error?, statusCode: Int)
-    @objc optional func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, error: Error?, statusCode: Int)
+    @objc optional func downloadProgress(_ progress: Double, totalBytes: Int64, totalBytesExpected: Int64, fileName: String, serverUrl: String, session: URLSession, task: URLSessionTask)
+    @objc optional func uploadProgress(_ progress: Double, totalBytes: Int64, totalBytesExpected: Int64, fileName: String, serverUrl: String, session: URLSession, task: URLSessionTask)
+    @objc optional func downloadComplete(fileName: String, serverUrl: String, etag: String?, date: NSDate?, dateLastModified: NSDate?, length: Double, description: String?, task: URLSessionTask, error: Error?, statusCode: Int)
+    @objc optional func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, task: URLSessionTask, error: Error?, statusCode: Int)
 }
 
 @objc class NCNetworking: NSObject, NCCommunicationCommonDelegate {
@@ -77,20 +77,12 @@ import Alamofire
         }
     }
     
-    func downloadProgress(_ progress: Double, fileName: String, ServerUrl: String, session: URLSession, task: URLSessionTask) {
-        delegate?.downloadProgress?(progress, fileName: fileName, ServerUrl: ServerUrl, session: session, task: task)
+    func downloadProgress(_ progress: Double, totalBytes: Int64, totalBytesExpected: Int64, fileName: String, serverUrl: String, session: URLSession, task: URLSessionTask) {
+        delegate?.downloadProgress?(progress, totalBytes: totalBytes, totalBytesExpected: totalBytesExpected, fileName: fileName, serverUrl: serverUrl, session: session, task: task)
     }
     
-    func uploadProgress(_ progress: Double, fileName: String, ServerUrl: String, session: URLSession, task: URLSessionTask) {
-        delegate?.uploadProgress?(progress, fileName: fileName, ServerUrl: ServerUrl, session: session, task: task)
-    }
-    
-    func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, error: Error?, statusCode: Int) {
-        delegate?.uploadComplete?(fileName: fileName, serverUrl: serverUrl, ocId: ocId, etag: etag, date: date, size:size, description: description, error: error, statusCode: statusCode)
-    }
-    
-    func downloadComplete(fileName: String, serverUrl: String, etag: String?, date: NSDate?, dateLastModified: NSDate?, length: Double, description: String?, error: Error?, statusCode: Int) {
-        delegate?.downloadComplete?(fileName: fileName, serverUrl: serverUrl, etag: etag, date: date, dateLastModified: dateLastModified, length: length, description: description, error: error, statusCode: statusCode)
+    func downloadComplete(fileName: String, serverUrl: String, etag: String?, date: NSDate?, dateLastModified: NSDate?, length: Double, description: String?, task: URLSessionTask, error: Error?, statusCode: Int) {
+        delegate?.downloadComplete?(fileName: fileName, serverUrl: serverUrl, etag: etag, date: date, dateLastModified: dateLastModified, length: length, description: description, task: task, error: error, statusCode: statusCode)
     }
     
     //MARK: - Pinning check
@@ -186,10 +178,10 @@ import Alamofire
                 metadata.status = Int(k_metadataStatusNormal)
                 
                 NCManageDatabase.sharedInstance.addMetadata(metadata)
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
             }
         }
-        
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
     }
     
     @objc func verifyDownloadRequestLost() {
@@ -203,6 +195,8 @@ import Alamofire
                     metadata.sessionError = ""
                     metadata.status = Int(k_metadataStatusNormal)
                     NCManageDatabase.sharedInstance.addMetadata(metadata)
+                    
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                 }
             }
         }
@@ -221,8 +215,8 @@ import Alamofire
         metadata.session = NCCommunicationCommon.shared.sessionIdentifierDownload
         if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
         
-        debugPrint("[LOG] Download Request: " + "\(self.downloadRequest.count)")
-        
+        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
+                
         NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in
             
             self.downloadRequest[fileNameLocalPath] = request
@@ -238,7 +232,7 @@ import Alamofire
         }) { (account, etag, date, length, error, errorCode, errorDescription) in
                         
             self.downloadRequest[fileNameLocalPath] = nil
-            
+           
             if errorCode == 0 {
                
                 metadata.date = date ?? NSDate()
@@ -262,15 +256,13 @@ import Alamofire
                 NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
                 
             } else if error?.isExplicitlyCancelledError ?? false {
-                
+                                
                 metadata.session = ""
                 metadata.sessionError = ""
                 metadata.status = Int(k_metadataStatusNormal)
                 
                 if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
-                
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
-
+            
             } else {
                 
                 metadata.session = ""
@@ -290,6 +282,8 @@ import Alamofire
                 NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
             }
             
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
+            
             completion(errorCode)
         }
     }
@@ -305,9 +299,9 @@ import Alamofire
         } else {
             CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+            
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
         }
-
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
     }
     
     @objc func verifyUploadRequestLost() {
@@ -319,14 +313,17 @@ import Alamofire
                 if request == nil {
                     CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
                     NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                    
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
                 }
             }
         }
     }
     
-    @objc func upload(metadata: tableMetadata, e2eEncrypted: Bool) {
+    @objc func upload(metadata: tableMetadata) {
            
         var metadataForUpload: tableMetadata?
+        var e2eEncrypted = false
         let internalContenType = NCCommunicationCommon.shared.getInternalContenType(fileName: metadata.fileNameView, contentType: metadata.contentType, directory: false)
         var fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
            
@@ -335,6 +332,10 @@ import Alamofire
             return
         }
            
+        if CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account) {
+            e2eEncrypted = true
+        }
+        
         if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
 
             metadata.contentType = internalContenType.contentType
@@ -349,13 +350,15 @@ import Alamofire
             }
                
             metadataForUpload = NCManageDatabase.sharedInstance.addMetadata(metadata)
-            
-            #if !EXTENSION
+           
             if e2eEncrypted {
+                #if !EXTENSION
                 NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
+                #endif
+            } else {
+                uploadFile(metadata: metadataForUpload!, account: account)
             }
-            #endif
-            
+           
         } else {
                
             CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadata, notification: true) { (extractMetadata, fileNamePath) in
@@ -374,16 +377,79 @@ import Alamofire
                 }
                        
                 metadataForUpload = NCManageDatabase.sharedInstance.addMetadata(extractMetadata)
-                
-                #if !EXTENSION
+               
                 if e2eEncrypted {
+                    #if !EXTENSION
                     NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
+                    #endif
+                } else {
+                    self.uploadFile(metadata: metadataForUpload!, account: account)
                 }
-                #endif
             }
         }
     }
     
+    private func uploadFile(metadata: tableMetadata, account: tableAccount) {
+        
+        var session: URLSession?
+        let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
+        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+        
+        if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackground || metadata.session == NCCommunicationCommon.shared.sessionIdentifierExtension {
+            session = NCCommunicationBackground.shared.sessionManagerTransfer
+        } else if metadata.session == NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan {
+            session = NCCommunicationBackground.shared.sessionManagerTransferWWan
+        }
+        
+        if let task = NCCommunicationBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: "", session: session!) {
+         
+            metadata.status = Int(k_metadataStatusUploading)
+            metadata.sessionError = ""
+            metadata.sessionTaskIdentifier = task.taskIdentifier
+            NCManageDatabase.sharedInstance.addMetadata(metadata)
+            
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "task":task, "serverUrl":metadata.serverUrl, "account":metadata.account])
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
+        }
+    }
+    
+    func uploadProgress(_ progress: Double, totalBytes: Int64, totalBytesExpected: Int64, fileName: String, serverUrl: String, session: URLSession, task: URLSessionTask) {
+        delegate?.uploadProgress?(progress, totalBytes: totalBytes, totalBytesExpected: totalBytesExpected, fileName: fileName, serverUrl: serverUrl, session: session, task: task)
+        
+        if let metadata = NCManageDatabase.sharedInstance.getMetadataInSessionFromFileName(fileName, serverUrl: serverUrl, taskIdentifier: task.taskIdentifier) {
+                        
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])
+        }
+    }
+    
+    func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, task: URLSessionTask, error: Error?, statusCode: Int) {
+        if delegate != nil {
+            delegate?.uploadComplete?(fileName: fileName, serverUrl: serverUrl, ocId: ocId, etag: etag, date: date, size:size, description: description, task: task, error: error, statusCode: statusCode)
+        } else {
+            
+            guard let metadata = NCManageDatabase.sharedInstance.getMetadataInSessionFromFileName(fileName, serverUrl: serverUrl, taskIdentifier: task.taskIdentifier) else {
+                return
+            }
+            
+            if error == nil && statusCode >= 200 && statusCode < 300 {
+                
+            } else if error != nil && (error! as NSError).code == NSURLErrorCancelled {
+                
+                if metadata.status == k_metadataStatusUploadForcedStart {
+                    
+                } else {
+                    
+                    CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+                    NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                                        
+                }
+            }
+            
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
+        }
+    }
+    
+    
     //MARK: - WebDav Read file, folder
     
     @objc func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ metadatas: [tableMetadata]?, _ errorCode: Int, _ errorDescription: String)->()) {
@@ -396,7 +462,6 @@ import Alamofire
                     
                     // Add directory
                     NCManageDatabase.sharedInstance.addDirectory(encrypted: metadataFolder.e2eEncrypted, favorite: metadataFolder.favorite, ocId: metadataFolder.ocId, fileId: metadataFolder.fileId, etag: metadataFolder.etag, permissions: metadataFolder.permissions, serverUrl: serverUrl, richWorkspace: metadataFolder.richWorkspace, account: account)
-                    NCManageDatabase.sharedInstance.setDateReadDirectory(serverUrl: serverUrl, account: account)
                     
                     // Add other directories
                     for metadata in metadatasFolder {
@@ -423,6 +488,8 @@ import Alamofire
                         NCManageDatabase.sharedInstance.addMetadatas(metadatasInUpload!)
                     }
                     
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
+                    
                     completion(account, metadataFolderInserted, metadatasInserted, errorCode, "")
                 }
             
@@ -500,6 +567,9 @@ import Alamofire
                         self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
                     }
                 }
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
+                
             } else if errorCode == 405 && overwrite {
                 self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": 0], errorDescription: "", completion: completion)
             } else {
@@ -570,6 +640,8 @@ import Alamofire
                 if metadata.directory {
                     NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
                 }
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
             }
             
             self.NotificationPost(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -602,6 +674,8 @@ import Alamofire
     
             if errorCode == 0 && metadata.account == account {
                 NCManageDatabase.sharedInstance.setMetadataFavorite(ocId: metadata.ocId, favorite: favorite)
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
             }
             
             self.NotificationPost(name: k_notificationCenter_favoriteFile, userInfo: ["metadata": metadata, "favorite": favorite, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -695,6 +769,8 @@ import Alamofire
                         try FileManager.default.moveItem(atPath: atPathIcon, toPath: toPathIcon)
                     } catch { }
                 }
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
             }
                     
             self.NotificationPost(name: k_notificationCenter_renameFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -743,9 +819,9 @@ import Alamofire
                     metadataNew = metadataMove
                 }
                 NCManageDatabase.sharedInstance.moveMedia(ocId: metadata.ocId, serverUrlTo: serverUrlTo)
-                
-                NCManageDatabase.sharedInstance.clearDateRead(serverUrl: metadata.serverUrl, account: account)
-                NCManageDatabase.sharedInstance.clearDateRead(serverUrl: serverUrlTo, account: account)
+                                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
             }
                     
             self.NotificationPost(name: k_notificationCenter_moveFile, userInfo: ["metadata": metadata, "metadataNew": metadataNew, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -782,6 +858,8 @@ import Alamofire
         
         NCCommunication.shared.copyFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite) { (account, errorCode, errorDescription) in
                     
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
+
             self.NotificationPost(name: k_notificationCenter_copyFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
         }
     }

+ 7 - 7
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -173,6 +173,7 @@ import Alamofire
                     } catch { }
                 }
                 
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                 self.NotificationPost(name: k_notificationCenter_deleteFile, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
             }
         }
@@ -236,6 +237,8 @@ import Alamofire
                 metadata.session = NCCommunicationCommon.shared.sessionIdentifierUpload
                 if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
                 
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
+                
                 NCCommunication.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: metadata.date as Date, dateModificationFile: metadata.date as Date, addCustomHeaders: ["e2e-token":e2eToken!], requestHandler: { (request) in
                     
                     NCNetworking.shared.uploadRequest[fileNameLocalPath] = request
@@ -276,9 +279,7 @@ import Alamofire
                         
                         CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                        
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
-                        
+                                                
                     } else if errorCode == 401 || errorCode == 403 {
                         
                         NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: metadata.account)
@@ -286,7 +287,6 @@ import Alamofire
                         CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
                         
                     } else if errorCode == Int(CFNetworkErrors.cfurlErrorServerCertificateUntrusted.rawValue) {
                         
@@ -294,9 +294,7 @@ import Alamofire
                         
                         CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                        
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
-                        
+                                                
                     } else {
                         
                         metadata.session = ""
@@ -309,6 +307,8 @@ import Alamofire
                     }
                         
                     NCNetworkingE2EE.shared.unlock(account: metadata.account, serverUrl: serverUrl) { (_, _, _, _) in }
+                    
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
                 }
                 
             } else {

+ 8 - 23
iOSClient/Networking/NCNetworkingNotificationCenter.swift

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 19/04/2020.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -43,13 +43,9 @@ import Foundation
 
     @objc func downloadFileStart(_ notification: NSNotification) {
         
-        if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let serverUrl = userInfo["serverUrl"] as? String {
-                
-                NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: serverUrl, ocId: ocId, action: Int32(k_action_MOD))
-                appDelegate.updateApplicationIconBadgeNumber()
-            }
-        }
+//        if let userInfo = notification.userInfo as NSDictionary? {
+//            if let ocId = userInfo["ocId"] as? String, let serverUrl = userInfo["serverUrl"] as? String { }
+//        }
     }
     
     @objc func downloadedFile(_ notification: NSNotification) {
@@ -63,7 +59,6 @@ import Foundation
                     
                     // Synchronized
                     if selector == selectorDownloadSynchronize {
-                        appDelegate.updateApplicationIconBadgeNumber()
                         return
                     }
                     
@@ -160,14 +155,10 @@ import Foundation
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         NCManageDatabase.sharedInstance.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         
-                        NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: metadata.serverUrl, ocId: metadata.ocId, action: Int32(k_action_DEL))
-                        
                     } else {
                         NCContentPresenter.shared.messageNotification("_download_file_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
                     }
                 }
-                
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
             }
         }
     }
@@ -176,22 +167,16 @@ import Foundation
 
     @objc func uploadFileStart(_ notification: NSNotification) {
         
-        if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let serverUrl = userInfo["serverUrl"] as? String, let _ = userInfo["task"] as? URLSessionUploadTask {
-                
-                NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: serverUrl, ocId: ocId, action: Int32(k_action_MOD))
-                appDelegate.updateApplicationIconBadgeNumber()
-            }
-        }
+//        if let userInfo = notification.userInfo as NSDictionary? {
+//            if let ocId = userInfo["ocId"] as? String, let serverUrl = userInfo["serverUrl"] as? String, let _ = userInfo["task"] as? URLSessionUploadTask { }
+//        }
     }
     
     @objc func uploadedFile(_ notification: NSNotification) {
     
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int, let errorDescription = userInfo["errorDescription"] as? String {
-                
-                NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: metadata.serverUrl, ocId: metadata.ocId, action: Int32(k_action_MOD))
-                
+                                                
                 if metadata.account == appDelegate.activeAccount {
                     if errorCode == 0 {
                         appDelegate.startLoadAutoUpload()

+ 133 - 12
iOSClient/Networking/NCOperationQueue.swift

@@ -24,29 +24,150 @@
 
 import Foundation
 import Queuer
+import NCCommunication
 
-@objc class NCOperationQueue: ConcurrentOperation {
+@objc class NCOperationQueue: NSObject {
     @objc public static let shared: NCOperationQueue = {
         let instance = NCOperationQueue()
         return instance
     }()
     
-    let transferQueue = Queuer(name: "transferQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
-    let semaphore = Semaphore()
+    var downloadQueue = Queuer(name: "downloadQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
+    let readFolderSyncQueue = Queuer(name: "readFolderSyncQueue", maxConcurrentOperationCount: 1, qualityOfService: .default)
+    let downloadThumbnailQueue = Queuer(name: "downloadThumbnailQueue", maxConcurrentOperationCount: 10, qualityOfService: .default)
+    
+    // Download
+    @objc func download(metadata: tableMetadata, selector: String, setFavorite: Bool) {
+        downloadQueue.addOperation(NCOperationDownload.init(metadata: metadata, selector: selector, setFavorite: setFavorite))
+    }
+    @objc func downloadCancelAll() {
+        downloadQueue.cancelAll()
+    }
+    @objc func downloadCount() -> Int {
+        return downloadQueue.operationCount
+    }
+    
+    //
+    @objc func readFolderSync(serverUrl: String, selector: String ,account: String) {
+        readFolderSyncQueue.addOperation(NCOperationReadFolderSync.init(serverUrl: serverUrl, selector: selector, account: account))
+    }
+    
+    //
+    @objc func downloadThumbnail(metadata: tableMetadata, activeUrl: String, view: Any, indexPath: IndexPath) {
+        if metadata.hasPreview && (!CCUtility.fileProviderStorageIconExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
+            downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail.init(metadata: metadata, activeUrl: activeUrl, view: view, indexPath: indexPath))
+        }
+    }
+}
+
+//MARK: -
+
+class NCOperationDownload: ConcurrentOperation {
+   
+    private var metadata: tableMetadata
+    private var selector: String
+    private var setFavorite: Bool
+    
+    init(metadata: tableMetadata, selector: String, setFavorite: Bool) {
+        self.metadata = metadata
+        self.selector = selector
+        self.setFavorite = setFavorite
+    }
+    
+    override func start() {
+        if isCancelled {
+            self.finish()
+        } else {
+            NCNetworking.shared.download(metadata: self.metadata, selector: self.selector, setFavorite: self.setFavorite) { (_) in
+                self.finish()
+            }
+        }
+    }
+}
+
+//MARK: -
 
-    @objc func download(metadata: tableMetadata, selector: String, setFavorite: Bool = false) {
-        let concurrentOperation = ConcurrentOperation { operation in
+class NCOperationReadFolderSync: ConcurrentOperation {
+   
+    private var serverUrl: String
+    private var selector: String
+    private var account: String
+    
+    init(serverUrl: String, selector: String, account: String) {
+        self.serverUrl = serverUrl
+        self.selector = selector
+        self.account = account
+    }
+    
+    override func start() {
+        NCCommunication.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles()) { (account, files, errorCode, errorDescription) in
             
-            NCNetworking.shared.download(metadata: metadata, selector: selector, setFavorite: setFavorite) { (errorCode) in
-                
-                self.semaphore.continue()
+            if errorCode == 0 && files != nil {
+                NCManageDatabase.sharedInstance.convertNCCommunicationFilesToMetadatas(files!, useMetadataFolder: true, account: account) { (metadataFolder, metadatasFolder, metadatas) in
+                    
+                    if metadatas.count > 0 {
+                        CCSynchronize.shared()?.readFolder(withAccount: account, serverUrl: self.serverUrl, metadataFolder: metadataFolder, metadatas: metadatas, selector: self.selector)
+                    }
+                }
+            } else if errorCode == 404 {
+                NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: self.serverUrl, account: account)
             }
+            self.finish()
         }
-        concurrentOperation.addToQueue(transferQueue)
-        
-        debugPrint("[LOG] Download ADD QUEUE")
+    }
+}
+
+//MARK: -
 
-        semaphore.wait()
+class NCOperationDownloadThumbnail: ConcurrentOperation {
+   
+    private var metadata: tableMetadata
+    private var activeUrl: String
+    private var view: Any
+    private var indexPath: IndexPath
+    
+    init(metadata: tableMetadata, activeUrl: String, view: Any, indexPath: IndexPath) {
+        self.metadata = metadata
+        self.activeUrl = activeUrl
+        self.view = view
+        self.indexPath = indexPath
+    }
+    
+    override func start() {
+            
+        let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)!
+        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            
+        NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNameLocalPath: fileNameLocalPath, width: Int(k_sizePreview), height: Int(k_sizePreview)) { (account, data, errorCode, errorMessage) in
+            
+            if errorCode == 0 && data != nil  {
+                if let image = UIImage.init(data: data!) {
+                    
+                    if self.view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(self.indexPath, view: self.view) {
+                        if let cell = (self.view as! UICollectionView).cellForItem(at: self.indexPath) {
+                            if cell is NCListCell {
+                                (cell as! NCListCell).imageItem.image = image
+                            } else if cell is NCGridCell {
+                                (cell as! NCGridCell).imageItem.image = image
+                            } else if cell is NCGridMediaCell {
+                                (cell as! NCGridMediaCell).imageItem.image = image
+                            }
+                        }
+                    }
+                    
+                    if self.view is UITableView && CCUtility.fileProviderStorageIconExists(self.metadata.ocId, fileNameView: self.metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(self.indexPath, view: self.view) {
+                        if let cell = (self.view as! UITableView).cellForRow(at: self.indexPath) {
+                            if cell is CCCellMainTransfer {
+                                (cell as! CCCellMainTransfer).file.image = image
+                            } else if cell is CCCellMain {
+                                (cell as! CCCellMain).file.image = image
+                            }
+                        }
+                    }
+                }
+            }
+            self.finish()
+        }
     }
 }
 

+ 42 - 24
iOSClient/Networking/NCService.swift

@@ -54,12 +54,13 @@ class NCService: NSObject {
         }
         
         NCCommunication.shared.getUserProfile() { (account, userProfile, errorCode, errorDescription) in
-                 
+               
             if errorCode == 0 && account == self.appDelegate.activeAccount {
-                
+                                    
                 // Update User (+ userProfile.id) & active account & account network
                 guard let tableAccount = NCManageDatabase.sharedInstance.setAccountUserProfile(userProfile!) else {
                     NCContentPresenter.shared.messageNotification("Account", description: "Internal error : account not found on DB",  delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
+                        
                     return
                 }
                 
@@ -68,18 +69,34 @@ class NCService: NSObject {
                 
                 self.appDelegate.settingActiveAccount(tableAccount.account, activeUrl: tableAccount.url, activeUser: tableAccount.user, activeUserID: tableAccount.userID, activePassword: CCUtility.getPassword(tableAccount.account))
                 
-                // Call func thath required the userdID
                 self.appDelegate.activeFavorites.listingFavorites()
                 self.appDelegate.activeMedia.reloadDataSource(loadNetworkDatasource: true) { }
-                NCFunctionMain.sharedInstance.synchronizeOffline()
                 
-                DispatchQueue.global().async {
-                    
-                    let avatarUrl = "\(self.appDelegate.activeUrl!)/index.php/avatar/\(self.appDelegate.activeUser!)/\(k_avatar_size)".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
-                    let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(user, activeUrl: url) + "-" + self.appDelegate.activeUser + ".png"
-                    
-                    NCCommunication.shared.downloadContent(serverUrl: avatarUrl) { (account, data, errorCode, errorMessage) in
-                        if errorCode == 0 {
+                // Synchronize Offline ---
+                let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", tableAccount.account), sorted: "serverUrl", ascending: true)
+                if (directories != nil) {
+                    for directory: tableDirectory in directories! {
+                        CCSynchronize.shared()?.readFolder(directory.serverUrl, selector: selectorReadFolderWithDownload, account: tableAccount.account)
+                    }
+                }
+                
+                let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", tableAccount.account), sorted: "fileName", ascending: true)
+                if (files != nil) {
+                    for file: tableLocalFile in files! {
+                        guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", file.ocId)) else {
+                            continue
+                        }
+                        CCSynchronize.shared()?.readFile(metadata.ocId, fileName: metadata.fileName, serverUrl: metadata.serverUrl, selector: selectorReadFileWithDownload, account: tableAccount.account)
+                    }
+                }
+                // ---
+                        
+                let avatarUrl = "\(self.appDelegate.activeUrl!)/index.php/avatar/\(self.appDelegate.activeUser!)/\(k_avatar_size)".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
+                let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(user, activeUrl: url) + "-" + self.appDelegate.activeUser + ".png"
+                        
+                NCCommunication.shared.downloadContent(serverUrl: avatarUrl) { (account, data, errorCode, errorMessage) in
+                    if errorCode == 0 {
+                        DispatchQueue.global().async {
                             if let image = UIImage(data: data!) {
                                 try? FileManager.default.removeItem(atPath: fileNamePath)
                                 if let data = image.pngData() {
@@ -88,11 +105,10 @@ class NCService: NSObject {
                             }
                         }
                     }
-                  
-                    DispatchQueue.main.async {
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_changeUserProfile), object: nil)
-                    }
                 }
+                      
+                NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_changeUserProfile), object: nil)
+                    
                 
                 // Get Capabilities
                 self.requestServerCapabilities()
@@ -132,31 +148,33 @@ class NCService: NSObject {
         NCCommunication.shared.getCapabilities() { (account, data, errorCode, errorDescription) in
             
             if errorCode == 0 && data != nil {
-                NCManageDatabase.sharedInstance.addCapabilitiesJSon(data!, account: account)
                 
+                NCManageDatabase.sharedInstance.addCapabilitiesJSon(data!, account: account)
+            
                 // Setup communication
                 self.appDelegate.settingSetupCommunicationCapabilities(account)
-                
+            
                 // Theming
                 self.appDelegate.settingThemingColorBrand()
-                
+            
                 // File Sharing
                 let isFilesSharingEnabled = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
                 if (isFilesSharingEnabled && self.appDelegate.activeMain != nil) {
-                    
+                
                     OCNetworking.sharedManager()?.readShare(withAccount: account, completion: { (account, items, message, errorCode) in
                         if errorCode == 0 && account == self.appDelegate.activeAccount {
+                            
                             let itemsOCSharedDto = items as! [OCSharedDto]
                             NCManageDatabase.sharedInstance.deleteTableShare(account: account!)
                             self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: account!, activeUrl: self.appDelegate.activeUrl, items: itemsOCSharedDto)
-                            self.appDelegate.activeMain?.tableView?.reloadData()
-                            self.appDelegate.activeFavorites?.tableView?.reloadData()
+                            
                         } else {
+                            
                             NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
                         }
                     })
                 }
-                
+            
                 // NCTextObtainEditorDetails
                 let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
                 if serverVersionMajor >= k_nextcloud_version_18_0 {
@@ -180,13 +198,13 @@ class NCService: NSObject {
                 } else {
                     NCManageDatabase.sharedInstance.deleteExternalSites(account: account)
                 }
-                
+            
                 // Handwerkcloud
                 let isHandwerkcloudEnabled = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesHWCEnabled, exists: false)
                 if (isHandwerkcloudEnabled) {
                     self.requestHC()
                 }
-                            
+                
             } else if errorCode != 0 {
                 
                 self.appDelegate.settingThemingColorBrand()

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 10/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 10/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 26/08/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 26/08/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Settings/Acknowledgements.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 14/11/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Settings/Acknowledgements.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 14/11/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 3 - 8
iOSClient/Settings/CCAdvanced.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 06/11/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -185,10 +185,7 @@
     
     if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
         
-        [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];
-        
-        // force reload
-        [[NCManageDatabase sharedInstance] setClearAllDateReadDirectory];
+        [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];        
     }
     
     if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
@@ -291,9 +288,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        
-        [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
-        
+                
         [[NSURLCache sharedURLCache] setMemoryCapacity:0];
         [[NSURLCache sharedURLCache] setDiskCapacity:0];
         [KTVHTTPCache cacheDeleteAllCaches];

+ 1 - 1
iOSClient/Settings/CCManageAccount.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 12/03/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 12/03/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Settings/CCManageAutoUpload.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/09/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 7
iOSClient/Settings/CCManageAutoUpload.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/09/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -491,15 +491,9 @@
             return;
         }
         
-        // Clear data (old) Auto Upload
-        [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:[[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl] account:appDelegate.activeAccount];
-        
         // Settings new folder Automatatic upload
         [[NCManageDatabase sharedInstance] setAccountAutoUploadFileName:[CCUtility getLastPathFromServerUrl:serverUrl activeUrl:appDelegate.activeUrl]];
         [[NCManageDatabase sharedInstance] setAccountAutoUploadDirectory:[CCUtility deletingLastPathComponentFromServerUrl:serverUrl] activeUrl:appDelegate.activeUrl];
-        
-        // Clear data new Auto Upload
-        [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:serverUrl account:appDelegate.activeAccount];
     }
 }
 

+ 1 - 1
iOSClient/Settings/CCSettings.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 24/11/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 2 - 26
iOSClient/Settings/CCSettings.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 24/11/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -277,7 +277,7 @@
             
             [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 [CCUtility setFavoriteOffline:true];
-                [self synchronizeFavorites];
+                [appDelegate.activeFavorites listingFavorites];
             }]];
             
             [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
@@ -426,30 +426,6 @@
     }
 }
 
-- (void)synchronizeFavorites
-{    
-    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND favorite == true", appDelegate.activeAccount]  sorted:nil ascending:NO];
-    
-    for (tableMetadata *metadata in metadatas) {
-        
-        if (metadata.directory) {
-        
-            NSString *serverUrl = [CCUtility stringAppendServerUrl:metadata.serverUrl addFileName:metadata.fileName];
-            NSString *serverUrlBeginWith = serverUrl;
-            
-            if (![serverUrl hasSuffix:@"/"])
-                serverUrlBeginWith = [serverUrl stringByAppendingString:@"/"];
-
-            NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (serverUrl == %@ OR serverUrl BEGINSWITH %@)", appDelegate.activeAccount, serverUrl, serverUrlBeginWith] sorted:@"serverUrl" ascending:true];
-            
-            for (tableDirectory *directory in directories)
-                [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:directory.serverUrl account:appDelegate.activeAccount];
-        } 
-    }
-    
-    [appDelegate.activeFavorites listingFavorites];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Table View ===
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 1
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -388,7 +388,7 @@
 - (void)endToEndInitializeSuccess
 {
     // Reload All Datasource
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_clearDateReadDataSource object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_reloadDataSource object:nil];
 
     [self initializeForm];
 }

+ 5 - 7
iOSClient/Share/NCSharePaging.swift

@@ -31,7 +31,7 @@ class NCSharePaging: UIViewController {
     private let pagingViewController = NCShareHeaderViewController()
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
-    @objc var metadata: tableMetadata?
+    @objc var metadata = tableMetadata()
     @objc var indexPage: Int = 0
     
     override func viewDidLoad() {
@@ -83,9 +83,7 @@ class NCSharePaging: UIViewController {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         
-        appDelegate.activeMain?.reloadDatasource(self.appDelegate.activeMain?.serverUrl, ocId: nil, action: Int(k_action_NULL))
-        appDelegate.activeFavorites?.reloadDatasource(nil, action: Int(k_action_NULL))
-        appDelegate.activeOffline?.loadDatasource()
+        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId,"serverUrl":metadata.serverUrl])
     }
     
     @objc func exitTapped() {
@@ -133,17 +131,17 @@ extension NCSharePaging: PagingViewControllerDataSource {
             let viewController = UIStoryboard(name: "NCActivity", bundle: nil).instantiateInitialViewController() as! NCActivity
             viewController.insets = UIEdgeInsets(top: height - topSafeArea, left: 0, bottom: 0, right: 0)
             viewController.didSelectItemEnable = false
-            viewController.filterFileId = metadata!.fileId
+            viewController.filterFileId = metadata.fileId
             viewController.objectType = "files"
             return viewController
         case 1:
             let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "comments") as! NCShareComments
-            viewController.metadata = metadata!
+            viewController.metadata = metadata
             viewController.height = height
             return viewController
         case 2:
             let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "sharing") as! NCShare
-            viewController.metadata = metadata!
+            viewController.metadata = metadata
             viewController.height = height
             return viewController
         default:

+ 1 - 1
iOSClient/Shares/NCShares.m

@@ -286,7 +286,7 @@
                 
                 cell.fileImageView.image = [UIImage imageNamed:metadata.iconName];
                 
-                [[NCNetworkingMain sharedInstance] downloadThumbnailWith:metadata view:tableView indexPath:indexPath];
+                [[NCOperationQueue shared] downloadThumbnailWithMetadata:metadata activeUrl:appDelegate.activeUrl view:tableView indexPath:indexPath];
             }
         }
         

BIN
iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/fr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/gl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/id.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/ko.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/lt_LT.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings


+ 3 - 20
iOSClient/Synchronize/CCSynchronize.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 19/10/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -29,30 +29,13 @@
 
 @interface CCSynchronize : NSObject
 
-@property (nonatomic, strong) CCHud *hud;
-
 + (CCSynchronize *)sharedSynchronize;
 
-@property (nonatomic, strong) NSMutableOrderedSet *foldersInSynchronized;
-@property (nonatomic, strong) NSOperationQueue *operationSynchronizeQueue;
-
 - (void)readFolder:(NSString *)serverUrl selector:(NSString *)selector account:(NSString *)account;
 - (void)readFile:(NSString *)ocId fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString *)selector account:(NSString *)account;
 
-- (void)verifyChangeMedatas:(NSArray *)allRecordMetadatas serverUrl:(NSString *)serverUrl account:(NSString *)account withDownload:(BOOL)withDownload;
-
-@end
+- (void)readFolderWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas selector:(NSString *)selector;
 
-@interface CCOperationSynchronize : NSOperation
-
-- (id)initWithDelegate:(id)delegate serverUrl:(NSString *)serverUrl selector:(NSString *)selector account:(NSString *)account;
-
-@property (nonatomic, assign) BOOL isExecuting;
-@property (nonatomic, assign) BOOL isFinished;
-
-@property (nonatomic, weak) id delegate;
-@property (nonatomic, strong) NSString* account;
-@property (nonatomic, strong) NSString* serverUrl;
-@property (nonatomic, strong) NSString* selector;
+- (void)verifyChangeMedatas:(NSArray *)allRecordMetadatas serverUrl:(NSString *)serverUrl account:(NSString *)account withDownload:(BOOL)withDownload;
 
 @end

+ 3 - 141
iOSClient/Synchronize/CCSynchronize.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 19/10/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -40,13 +40,7 @@
     @synchronized(self)
     {
         if (!sharedSynchronize) {
-            
             sharedSynchronize = [CCSynchronize new];
-            sharedSynchronize.foldersInSynchronized = [NSMutableOrderedSet new];
-            
-            sharedSynchronize->_operationSynchronizeQueue = [NSOperationQueue new];
-            sharedSynchronize->_operationSynchronizeQueue.name = @"com.nextcloud.operationSynchronizeQueue";
-            sharedSynchronize->_operationSynchronizeQueue.maxConcurrentOperationCount = 1;
         }
         return sharedSynchronize;
     }
@@ -62,43 +56,17 @@
 
 - (void)readFolder:(NSString *)serverUrl selector:(NSString *)selector account:(NSString *)account
 {
-    id operation = [[CCOperationSynchronize alloc] initWithDelegate:self serverUrl:serverUrl selector:selector account:account];
-
-    [self.operationSynchronizeQueue addOperation:operation];
+    [[NCOperationQueue shared] readFolderSyncWithServerUrl:serverUrl selector:selector account:account];
 }
 
-- (void)readFolderSuccessFailureWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
+- (void)readFolderWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas selector:(NSString *)selector
 {
     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
 
-    // ERROR
-    if (errorCode != 0 || ![account isEqualToString:appDelegate.activeAccount]) {
-        
-        // Folder not present, remove it
-        if (errorCode == kOCErrorServerPathNotFound) {
-            
-            [[NCManageDatabase sharedInstance] deleteDirectoryAndSubDirectoryWithServerUrl:serverUrl account:account];
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
-        }
-        
-        return;
-    }
-    
-    // Add/update self Folder
-    if (!metadataFolder || !metadatas || [metadatas count] == 0) {
-        if (metadataFolder.serverUrl != nil) {
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadataFolder.serverUrl ocId:nil action:k_action_NULL];
-        }
-        return;
-    }
-    
     // Add metadata and update etag Directory
     [[NCManageDatabase sharedInstance] addMetadata:metadataFolder];
     [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:serverUrl serverUrlTo:nil etag:metadataFolder.etag ocId:metadataFolder.ocId fileId:metadataFolder.fileId encrypted:metadataFolder.e2eEncrypted richWorkspace:nil account:appDelegate.activeAccount];
     
-    // reload folder ../ *
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadataFolder.serverUrl ocId:nil action:k_action_NULL];
-    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
         
         NSMutableArray *metadatasForVerifyChange = [NSMutableArray new];
@@ -144,11 +112,6 @@
             [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
         }
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            if ([metadatasNotPresents count] > 0)
-                [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
-        });
-        
         // ----- Test : (MODIFY) -----
         
         for (tableMetadata *metadata in metadatas) {
@@ -232,8 +195,6 @@
                 
             [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", ocId]];
             [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", ocId]];
-                
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
         }
     }];
 }
@@ -289,109 +250,10 @@
 // MULTI THREAD
 - (void)SynchronizeMetadatas:(NSArray *)metadatas withDownload:(BOOL)withDownload
 {
-    NSString *oldServerUrl;
-    NSMutableArray *serverUrlToReload = [NSMutableArray new];
-
     for (tableMetadata *metadata in metadatas) {
-        
-        // Clear date for dorce refresh view
-        if (![oldServerUrl isEqualToString:metadata.serverUrl]) {
-            oldServerUrl = metadata.serverUrl;
-            [serverUrlToReload addObject:metadata.serverUrl];
-            [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:metadata.serverUrl account:metadata.account];
-        }
-
         [[NCOperationQueue shared] downloadWithMetadata:metadata selector:selectorDownloadSynchronize setFavorite:false];
-        //[[NCNetworking shared] downloadWithMetadata:metadata selector:selectorDownloadSynchronize setFavorite:false completion:^(NSInteger errorCode) { }];
-    }
-        
-    for (NSString *serverUrl in serverUrlToReload) {
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl ocId:nil action:k_action_NULL];
     }
 }
 
 @end
 
-@implementation CCOperationSynchronize
-
-- (id)initWithDelegate:(id)delegate serverUrl:(NSString *)serverUrl selector:(NSString *)selector account:(NSString *)account
-{
-    self = [super init];
-    
-    if (self) {
-        self.delegate = delegate;
-        self.serverUrl = serverUrl;
-        self.selector = selector;
-        self.account = account;
-    }
-    
-    return self;
-}
-
-- (void)start
-{
-    if (![NSThread isMainThread]) {
-        [self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO];
-        return;
-    }
-    
-    [self willChangeValueForKey:@"isExecuting"];
-    _isExecuting = YES;
-    [self didChangeValueForKey:@"isExecuting"];
-    
-    if (self.isCancelled) {
-        
-        [self finish];
-        
-    } else {
-        
-        [self poolNetworking];
-    }
-}
-
-- (void)finish
-{
-    [self willChangeValueForKey:@"isExecuting"];
-    [self willChangeValueForKey:@"isFinished"];
-    
-    _isExecuting = NO;
-    _isFinished = YES;
-    
-    [self didChangeValueForKey:@"isExecuting"];
-    [self didChangeValueForKey:@"isFinished"];
-}
-
-- (void)cancel
-{
-    if (_isExecuting) {
-        
-        [self complete];
-    }
-    
-    [super cancel];
-}
-
-- (void)poolNetworking
-{
-    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
-    
-    [[NCCommunication shared] readFileOrFolderWithServerUrlFileName:self.serverUrl depth:@"1" showHiddenFiles:[CCUtility getShowHiddenFiles] customUserAgent:nil addCustomHeaders:nil completionHandler:^(NSString *account, NSArray *files, NSInteger errorCode, NSString *errorDescription) {
-               
-        [[NCManageDatabase sharedInstance] convertNCCommunicationFilesToMetadatas:files useMetadataFolder:true account:account completion:^(tableMetadata *metadataFolder, NSArray<tableMetadata *> *metadatasFolder, NSArray<tableMetadata *> *metadatas) {
-            
-            if ([self.delegate respondsToSelector:@selector(readFolderSuccessFailureWithAccount:serverUrl:metadataFolder:metadatas:selector:message:errorCode:)])
-                [self.delegate readFolderSuccessFailureWithAccount:self.account serverUrl:self.serverUrl metadataFolder:metadataFolder metadatas:metadatas selector:self.selector message:errorDescription errorCode:errorCode];
-            
-            [self complete];
-        }];
-    }];
-}
-
-- (void)complete
-{
-    [self finish];
-    
-    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
-}
-
-@end

+ 0 - 1
iOSClient/Transfers/CCTransfers.h

@@ -28,5 +28,4 @@
 
 @property (nonatomic, weak) IBOutlet UITableView *tableView;
 
-- (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action;
 @end

+ 10 - 14
iOSClient/Transfers/CCTransfers.m

@@ -78,18 +78,17 @@
     UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressTableView:)];
     [self.tableView addGestureRecognizer:longPressRecognizer];
     
-    // changeTheming
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:k_notificationCenter_progressTask object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDatasource) name:k_notificationCenter_reloadDataSource object:nil];
+
     [self changeTheming];
-    
-    [self reloadDatasource:nil action:k_action_NULL];
 }
 
 - (void)viewDidAppear:(BOOL)animated
 {
     [super viewDidAppear:animated];
         
-    [self reloadDatasource:nil action:k_action_NULL];
+    [self reloadDatasource];
 }
 
 - (void)changeTheming
@@ -230,10 +229,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_all_task_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
         [[NCMainCommon sharedInstance] cancelAllTransfer];
-        [NCUtility.sharedInstance stopActivityIndicator];
-        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil ocId:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];
@@ -253,8 +249,8 @@
         [[NCMainCommon sharedInstance] cancelTransferMetadata:metadataForRecognizer reloadDatasource:false uploadStatusForcedStart:true];
     } else {
         metadataForRecognizer.status = k_metadataStatusInUpload;
-        metadataForRecognizer.session = k_upload_session;
-        [[CCNetworking sharedNetworking] uploadFile:[[NCManageDatabase sharedInstance] addMetadata:metadataForRecognizer] taskStatus:k_taskStatusResume];
+        metadataForRecognizer.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
+        [[NCNetworking shared] uploadWithMetadata:[[NCManageDatabase sharedInstance] addMetadata:metadataForRecognizer]];
     }
 }
 
@@ -262,7 +258,7 @@
 #pragma mark - ==== Datasource ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action
+- (void)reloadDatasource
 {
     // test
     if (appDelegate.activeAccount.length == 0 || self.view.window == nil)
@@ -316,8 +312,8 @@
 
     NSInteger queueDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", sessionDownload] sorted:nil ascending:NO] count];
 
-    NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_upload_session, k_upload_session_foreground] sorted:nil ascending:NO] count];
-    NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_upload_session_wwan] sorted:nil ascending:NO] count];
+    NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackground] sorted:nil ascending:NO] count];
+    NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan] sorted:nil ascending:NO] count];
     
     if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [sectionDataSource.sections objectAtIndex:section];
     if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSDate class]]) titleSection = [CCUtility getTitleSectionDate:[sectionDataSource.sections objectAtIndex:section]];
@@ -413,7 +409,7 @@
     // Footer Upload
     if ([titleSection containsString:@"upload"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
         
-        NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_upload_session, k_upload_session_foreground] sorted:nil ascending:NO] count];
+        NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackground] sorted:nil ascending:NO] count];
         
         // element or elements ?
         if (queueUpload > 1) element_s = NSLocalizedString(@"_elements_",nil);
@@ -430,7 +426,7 @@
     // Footer Upload WWAN
     if ([titleSection containsString:@"upload"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
         
-        NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_upload_session_wwan] sorted:nil ascending:NO] count];
+        NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", NCCommunicationCommon.shared.sessionIdentifierBackgroundWWan] sorted:nil ascending:NO] count];
        
         // element or elements ?
         if (queueUploadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);

+ 1 - 1
iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/12/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 2 - 3
iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 01/12/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -172,7 +172,7 @@
     
     tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrlLocal url:@"" contentType:@""];
     
-    metadataForUpload.session = k_upload_session;
+    metadataForUpload.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
     metadataForUpload.sessionSelector = selectorUploadFile;
     metadataForUpload.status = k_metadataStatusWaitUpload;
     
@@ -181,7 +181,6 @@
     
     // Add Medtadata for upload
     [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrlLocal ocId:metadataForUpload.ocId action:k_action_NULL];
 
     [appDelegate startLoadAutoUpload];
     

+ 1 - 1
iOSClient/Utility/CCError.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCError.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCExifGeo.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 03/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCExifGeo.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 03/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCGraphics.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCGraphics.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 04/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCHud.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 22/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCHud.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 22/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCUtility.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 02/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/CCUtility.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 02/02/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 18 - 1
iOSClient/Utility/NCContentPresenter.swift

@@ -3,7 +3,22 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 23/12/2019.
-//  Copyright © 2019 TWS. All rights reserved.
+//  Copyright (c) 2019 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
 import SwiftEntryKit
@@ -53,6 +68,8 @@ class NCContentPresenter: NSObject {
                        
         // No notification message
         if errorCode == -999 { return }         // Cancelled transfer
+        else if errorCode == 200 { return }     // Transfer stopped
+        else if errorCode == 207 { return }     // WebDAV multistatus
         else if errorCode == -1001 { return }   // Time out
         else if errorCode == -1005 { return }   // Connection lost
         else if errorCode == 0 && type == messageType.error { return }

+ 1 - 1
iOSClient/Utility/NSString+TruncateToWidth.h

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 06/04/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 1 - 1
iOSClient/Utility/NSString+TruncateToWidth.m

@@ -3,7 +3,7 @@
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 06/04/16.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //

+ 15 - 0
iOSClient/Viewer/NCViewerQuickLook.swift

@@ -5,6 +5,21 @@
 //  Created by Marino Faggiana on 03/05/2020.
 //  Copyright © 2020 Marino Faggiana. All rights reserved.
 //
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
 
 import Foundation
 import QuickLook

+ 1 - 2
iOSClient/Viewer/NCViewerVideo.swift

@@ -107,8 +107,7 @@ class NCViewerVideo: NSObject {
                 _ = NCManageDatabase.sharedInstance.addLocalFile(metadata: self.metadata)
                 KTVHTTPCache.cacheDelete(with: self.videoURL)
                 
-                // reload Data Source
-                NCMainCommon.sharedInstance.reloadDatasource(ServerUrl:self.metadata.serverUrl, ocId: self.metadata.ocId, action: k_action_MOD)
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":self.metadata.ocId,"serverUrl":self.metadata.serverUrl])
             }
         }
     }

+ 1 - 1
iOSClient/main.m

@@ -3,7 +3,7 @@
 //  Nextcloud iOS
 //
 //  Created by Marino Faggiana on 25/11/14.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //