Sfoglia il codice sorgente

replace app with appDelegate

Marino Faggiana 7 anni fa
parent
commit
c975e296e3

+ 2 - 2
iOSClient/AppDelegate.m

@@ -192,7 +192,7 @@
 
     navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
     splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
-    [app aspectNavigationControllerBar:navigationController.navigationBar online:YES hidden:NO];
+    [self aspectNavigationControllerBar:navigationController.navigationBar online:YES hidden:NO];
     
     // Settings TabBar
     [self createTabBarController];
@@ -854,7 +854,7 @@
         safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom/2;
     }
     
-    [app aspectTabBar:tabBarController.tabBar hidden:NO];
+    [self aspectTabBar:tabBarController.tabBar hidden:NO];
     
     // File
     item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexFile];

+ 1 - 1
iOSClient/AutoUpload/NCAutoUpload.m

@@ -515,7 +515,7 @@
                 [[NCManageDatabase sharedInstance] addActivityClient:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder] fileID:@"" action:k_activityDebugActionAutoUpload selector:selector note:NSLocalizedString(@"_error_createsubfolders_upload_",nil) type:k_activityTypeFailure verbose:k_activityVerboseDefault activeUrl:appDelegate.activeUrl];
                 
                 if ([selector isEqualToString:selectorUploadAutoUploadAll])
-                    [app messageNotification:@"_error_" description:@"_error_createsubfolders_upload_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                    [appDelegate messageNotification:@"_error_" description:@"_error_createsubfolders_upload_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 
                 return false;
             }

+ 1 - 1
iOSClient/CCGlobal.h

@@ -33,7 +33,7 @@ extern NSString *const dav;
 #ifndef EXTENSION
 
 //AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-#define app ((AppDelegate *)[[UIApplication sharedApplication] delegate])
+//#define app ((AppDelegate *)[[UIApplication sharedApplication] delegate])
 #define CALL_ORIGIN NSLog(@"Origin: [%@]", [[[[NSThread callStackSymbols] objectAtIndex:1] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"[]"]] objectAtIndex:1])
 
 #endif

+ 11 - 7
iOSClient/Login/CCLogin.m

@@ -29,6 +29,8 @@
 
 @interface CCLogin ()
 {
+    AppDelegate *appDelegate;
+
     UIView *rootView;
 }
 @end
@@ -39,6 +41,8 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     self.imageBrand.image = [UIImage imageNamed:@"loginLogo"];
     self.login.backgroundColor = [NCBrandColor sharedInstance].customer;
     
@@ -100,10 +104,10 @@
     
     if (_loginType == loginModifyPasswordUser) {
         
-        _baseUrl.text = app.activeUrl;
+        _baseUrl.text = appDelegate.activeUrl;
         _baseUrl.userInteractionEnabled = NO;
         _baseUrl.textColor = [UIColor lightGrayColor];
-        _user.text = app.activeUser;
+        _user.text = appDelegate.activeUser;
         _user.userInteractionEnabled = NO;
         _user.textColor = [UIColor lightGrayColor];
     }
@@ -270,8 +274,8 @@
                 // Change Password
                 tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountPassword:account password:self.password.text];
             
-                // Setting App active account
-                [app settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activeUserID:tbAccount.userID activePassword:tbAccount.password];
+                // Setting appDelegate active account
+                [appDelegate settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activeUserID:tbAccount.userID activePassword:tbAccount.password];
 
                 // Dismiss
                 if ([self.delegate respondsToSelector:@selector(loginSuccess:)])
@@ -287,7 +291,7 @@
                 // Read User Profile
                 CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:account];
                 metadataNet.action = actionGetUserProfile;
-                [app.netQueue addOperation:[[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:self.user.text withUserID:self.user.text withPassword:self.password.text withUrl:self.baseUrl.text]];
+                [appDelegate.netQueue addOperation:[[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:self.user.text withUserID:self.user.text withPassword:self.password.text withUrl:self.baseUrl.text]];
             }
         
         } else {
@@ -358,8 +362,8 @@
         tableAccount *account = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
         if (account) {
         
-            // Setting App active account
-            [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
+            // Setting appDelegate active account
+            [appDelegate settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
     
             // Ok ! Dismiss
             if ([self.delegate respondsToSelector:@selector(loginSuccess:)])

+ 1 - 1
iOSClient/Main/CCSplit.m

@@ -210,7 +210,7 @@
     UINavigationController *secondaryNC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CCDetailNC"];
     
     // Color
-    [app aspectNavigationControllerBar:secondaryNC.navigationBar online:YES hidden:NO];
+    [appDelegate aspectNavigationControllerBar:secondaryNC.navigationBar online:YES hidden:NO];
     
     // Ensure back button is enabled
     UIViewController *detailViewController = [secondaryNC visibleViewController];

+ 3 - 2
iOSClient/ManageLocation+ManageAsset/CCManageLocation.m

@@ -63,12 +63,13 @@
 
 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
 {
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     CLLocation* location = [locations lastObject];
     
     NSLog(@"[LOG] update locationManager : latitude %+.6f, longitude %+.6f",location.coordinate.latitude, location.coordinate.longitude);
     
-    app.currentLatitude = location.coordinate.latitude;
-    app.currentLongitude = location.coordinate.longitude;
+    appDelegate.currentLatitude = location.coordinate.latitude;
+    appDelegate.currentLongitude = location.coordinate.longitude;
     
     [self.delegate changedLocation];
 }

+ 13 - 8
iOSClient/Networking/CCNetworking.m

@@ -589,7 +589,7 @@
         [_delegate reloadDatasource:serverUrl];
         
 #ifndef EXTENSION
-        [app updateApplicationIconBadgeNumber];
+        [(AppDelegate *)[[UIApplication sharedApplication] delegate] updateApplicationIconBadgeNumber];
 #endif
 }
 
@@ -654,7 +654,8 @@
 - (void)downloadFileSuccessFailure:(NSString *)fileName fileID:(NSString *)fileID etag:(NSString *)etag date:(NSDate *)date serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost errorCode:(NSInteger)errorCode
 {
 #ifndef EXTENSION
-    [app.listProgressMetadata removeObjectForKey:fileID];
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    [appDelegate.listProgressMetadata removeObjectForKey:fileID];
 #endif
     
     // Progress Task
@@ -989,7 +990,7 @@
                 [[NCManageDatabase sharedInstance] deleteQueueUploadWithAssetLocalIdentifier:assetLocalIdentifier selector:selector];
 #ifndef EXTENSION
                 // Next tableQueueUpload
-                [app performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
+                [(AppDelegate *)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
 #endif
             });
             
@@ -1003,7 +1004,7 @@
              [[NCManageDatabase sharedInstance] deleteQueueUploadWithAssetLocalIdentifier:assetLocalIdentifier selector:selector];
 #ifndef EXTENSION
              // Next tableQueueUpload
-             [app performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
+             [(AppDelegate *)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
 #endif
              
              // Manage uploadTask cancel,suspend,resume
@@ -1020,7 +1021,7 @@
         [self.delegate reloadDatasource:serverUrl];
         
 #ifndef EXTENSION
-    [app updateApplicationIconBadgeNumber];
+    [(AppDelegate *)[[UIApplication sharedApplication] delegate] updateApplicationIconBadgeNumber];
 #endif
     
 }
@@ -1071,7 +1072,8 @@
     if (errorCode != 0) {
         
 #ifndef EXTENSION
-        [app.listProgressMetadata removeObjectForKey:sessionID];
+        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        [appDelegate.listProgressMetadata removeObjectForKey:sessionID];
 #endif
         
         // Mark error only if not Cancelled Task
@@ -1106,7 +1108,8 @@
     [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", sessionID] clearDateReadDirectoryID:nil];
     
 #ifndef EXTENSION
-    [app.listProgressMetadata removeObjectForKey:sessionID];
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    [appDelegate.listProgressMetadata removeObjectForKey:sessionID];
 #endif
         
     NSLog(@"[LOG] Insert new upload : %@ - fileID : %@", metadata.fileName, metadata.fileID);
@@ -1325,6 +1328,8 @@
 - (void)readFileVerifyUpload:(NSString *)fileName serverUrl:(NSString *)serverUrl
 {
 #ifndef EXTENSION
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:_activeAccount];
     
     metadataNet.action = actionReadFile;
@@ -1332,7 +1337,7 @@
     metadataNet.serverUrl = serverUrl;
     metadataNet.selector = selectorReadFileVerifyUpload;
 
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
 #else
     NSLog(@"[LOG] Function not available for extension.");
 #endif

+ 11 - 10
iOSClient/Networking/OCNetworking.m

@@ -220,7 +220,7 @@
         if ([items count] == 0) {
             
 #ifndef EXTENSION
-            [app messageNotification:@"Server error" description:@"Read Folder WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError  errorCode:0];
+            [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Read Folder WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError  errorCode:0];
 #endif
 
             dispatch_async(dispatch_get_main_queue(), ^{
@@ -305,7 +305,7 @@
                 // ----- BUG #942 ---------
                 if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                    [app messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                    [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                     continue;
                 }
@@ -402,7 +402,7 @@
                 // ----- BUG #942 ---------
                 if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                    [app messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                    [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                     continue;
                 }
@@ -562,7 +562,7 @@
             // ----- BUG #942 ---------
             if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                [app messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                 continue;
             }
@@ -870,7 +870,7 @@
         if ([items count] == 0) {
        
 #ifndef EXTENSION
-            [app messageNotification:@"Server error" description:@"Read File WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+            [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Read File WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
             if([self.delegate respondsToSelector:@selector(readFileFailure:message:errorCode:)])
                 [self.delegate readFileFailure:_metadataNet message:@"Read File WebDAV : [items NULL] please fix" errorCode:0];
@@ -912,6 +912,7 @@
 - (void)readShareServer
 {
 #ifndef EXTENSION
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
     
     [communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
@@ -921,14 +922,14 @@
         
         BOOL openWindow = NO;
         
-        [app.sharesID removeAllObjects];
+        [appDelegate.sharesID removeAllObjects];
         
         tableAccount *recordAccount = [[NCManageDatabase sharedInstance] getAccountActive];
         
         if ([recordAccount.account isEqualToString:_metadataNet.account]) {
         
             for (OCSharedDto *item in items)
-                [app.sharesID setObject:item forKey:[@(item.idRemoteShared) stringValue]];
+                [appDelegate.sharesID setObject:item forKey:[@(item.idRemoteShared) stringValue]];
             
             if ([_metadataNet.selector isEqual:selectorOpenWindowShare]) openWindow = YES;
             
@@ -938,7 +939,7 @@
         }
         
         if([self.delegate respondsToSelector:@selector(readSharedSuccess:items:openWindow:)])
-            [self.delegate readSharedSuccess:_metadataNet items:app.sharesID openWindow:openWindow];
+            [self.delegate readSharedSuccess:_metadataNet items:appDelegate.sharesID openWindow:openWindow];
         
         [self complete];
         
@@ -1050,7 +1051,7 @@
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
         
 #ifndef EXTENSION
-        [app messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
+        [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
 #endif
         
         NSInteger errorCode = response.statusCode;
@@ -1091,7 +1092,7 @@
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
         
 #ifndef EXTENSION
-        [app messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
+        [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
 #endif
         
         NSInteger errorCode = response.statusCode;

+ 11 - 7
iOSClient/PeekPop/CCPeekPop.m

@@ -28,8 +28,10 @@
 #import "NCBridgeSwift.h"
 
 @interface CCPeekPop ()
+{
+    AppDelegate *appDelegate;
 
-
+}
 @end
 
 @implementation CCPeekPop
@@ -44,6 +46,8 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    
     self.preferredContentSize = CGSizeMake(640, 640);
     //detailVC?.preferredContentSize = CGSize(width: 0, height: 380)
     
@@ -89,7 +93,7 @@
 
 - (void)downloadThumbnailSuccess:(CCMetadataNet *)metadataNet
 {
-    UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.pvw",app.directoryUser, _metadata.fileID]];
+    UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.pvw",appDelegate.directoryUser, _metadata.fileID]];
     
     _imagePreview.image = image;
     
@@ -100,16 +104,16 @@
 
 - (void)downloadThumbnailFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
 {    
-    [app messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
+    [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
     
     [self dismissViewControllerAnimated:YES completion:nil];
 }
 
 - (void)downloadThumbnail:(tableMetadata *)metadata
 {
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     
-    NSString *serverUrl = app.activeMain.serverUrl;
+    NSString *serverUrl = appDelegate.activeMain.serverUrl;
     
     metadataNet.action = actionDownloadThumbnail;
     metadataNet.fileID = metadata.fileID;
@@ -119,12 +123,12 @@
     metadataNet.selector = selectorDownloadThumbnail;
     metadataNet.serverUrl = serverUrl;
     
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
 }
 
 - (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl
 {
-    NSString *fileName = [NSString stringWithFormat:@"%@/%@", [serverUrl stringByReplacingOccurrencesOfString:[CCUtility getHomeServerUrlActiveUrl:app.activeUrl] withString:@""], metadataFileName];
+    NSString *fileName = [NSString stringWithFormat:@"%@/%@", [serverUrl stringByReplacingOccurrencesOfString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl] withString:@""], metadataFileName];
     
     if ([fileName hasPrefix:@"/"]) fileName = [fileName substringFromIndex:1];
     

+ 21 - 17
iOSClient/Photos/CCPhotos.m

@@ -28,6 +28,8 @@
 
 @interface CCPhotos () <CCActionsDeleteDelegate, CCActionsDownloadThumbnailDelegate>
 {
+    AppDelegate *appDelegate;
+
     tableMetadata *_metadata;
 
     BOOL _cellEditing;
@@ -52,10 +54,12 @@
 {
     if (self = [super initWithCoder:aDecoder])  {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
-        app.activePhotos = self;
+        appDelegate.activePhotos = self;
     }
     
     return self;
@@ -94,11 +98,11 @@
     [super viewWillAppear:animated];
     
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
-    [app aspectTabBar:self.tabBarController.tabBar hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
+    [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
     // Plus Button
-    [app plusButtonVisibile:true];
+    [appDelegate plusButtonVisibile:true];
 
     
     [self reloadDatasource];
@@ -114,7 +118,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
     
     [self.collectionView reloadData];
 }
@@ -145,7 +149,7 @@
 
 - (void)setUINavigationBarDefault
 {
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     
     // select
     UIImage *icon = [UIImage imageNamed:@"seleziona"];
@@ -324,7 +328,7 @@
     
         NSString *fileNamePath = [NSTemporaryDirectory() stringByAppendingString:metadata.fileName];
         
-        [[NSFileManager defaultManager] linkItemAtPath:[NSString stringWithFormat:@"%@/%@", app.directoryUser, metadata.fileID] toPath:fileNamePath error:nil];
+        [[NSFileManager defaultManager] linkItemAtPath:[NSString stringWithFormat:@"%@/%@", appDelegate.directoryUser, metadata.fileID] toPath:fileNamePath error:nil];
         
         if ([[NSFileManager defaultManager] fileExistsAtPath:fileNamePath]) {
             
@@ -379,7 +383,7 @@
         BOOL existsIcon = NO;
         
         if (fileID) {
-            existsIcon = [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, fileID]];
+            existsIcon = [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, fileID]];
             indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:fileID];
         }
         
@@ -392,7 +396,7 @@
                 UIVisualEffectView *effect = [cell viewWithTag:200];
                 UIImageView *checked = [cell viewWithTag:300];
                 
-                imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, fileID]];
+                imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, fileID]];
                 effect.hidden = YES;
                 checked.hidden = YES;
             }
@@ -400,7 +404,7 @@
         
     } else {
         
-        [app messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
+        [appDelegate messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
     }
 }
 
@@ -491,7 +495,7 @@
     
     if ([self indexPathIsValid:indexPath]) {
     
-        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]])
+        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadataNet.fileID]])
             [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
     }
 }
@@ -516,13 +520,13 @@
 - (void)reloadDatasource
 {    
     // test
-    if (app.activeAccount.length == 0)
+    if (appDelegate.activeAccount.length == 0)
         return;
     
-    _directoryStartDatasource = [[NCManageDatabase sharedInstance] getAccountAutoUploadPath:app.activeUrl];
+    _directoryStartDatasource = [[NCManageDatabase sharedInstance] getAccountAutoUploadPath:appDelegate.activeUrl];
     NSDate *dateDateRecordDirectory = nil;
     
-    NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl BEGINSWITH %@", app.activeAccount, _directoryStartDatasource] sorted:@"dateReadDirectory" ascending:false];
+    NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl BEGINSWITH %@", appDelegate.activeAccount, _directoryStartDatasource] sorted:@"dateReadDirectory" ascending:false];
     if ([directories count] > 0) {
         tableDirectory *directory = [directories objectAtIndex:0];
         dateDateRecordDirectory = directory.dateReadDirectory;
@@ -534,7 +538,7 @@
 
         _dateReadDataSource = [NSDate date];
         NSArray *results = [[NCManageDatabase sharedInstance] getTableMetadatasPhotosWithServerUrl:_directoryStartDatasource];
-        _sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:results listProgressMetadata:nil e2eEncryptions:nil groupByField:@"date" activeAccount:app.activeAccount];
+        _sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:results listProgressMetadata:nil e2eEncryptions:nil groupByField:@"date" activeAccount:appDelegate.activeAccount];
         
         [self reloadCollection];
     }
@@ -624,10 +628,10 @@
         tableMetadata *metadata = [_sectionDataSource.allRecordsDataSource objectForKey:fileID];
     
         // Image
-        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]]) {
+        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID]]) {
         
             // insert Image
-            imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
+            imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID]];
         
         } else {
         

+ 6 - 3
iOSClient/QuickActions/CCQuickActions.m

@@ -30,6 +30,8 @@
 
 @interface CCQuickActions ()
 {
+    AppDelegate *appDelegate;
+
     CTAssetsPickerController *_picker;
     CCMove *_move;
     CCMain *_mainVC;
@@ -46,6 +48,7 @@
     
     dispatch_once(&once, ^{
         __quickActionsManager = [[CCQuickActions alloc] init];
+        __quickActionsManager->appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     });
     
     return __quickActionsManager;
@@ -91,7 +94,7 @@
     [checkmark setMargin:0.0 forVerticalEdge:NSLayoutAttributeRight horizontalEdge:NSLayoutAttributeTop];
     
     UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedIn:[CTAssetsPickerController class], nil];
-    [app aspectNavigationControllerBar:navBar online:YES hidden:NO];
+    [appDelegate aspectNavigationControllerBar:navBar online:YES hidden:NO];
     
     [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
         dispatch_async(dispatch_get_main_queue(), ^{
@@ -119,7 +122,7 @@
 {
     if (picker.selectedAssets.count > k_pickerControllerMax) {
         
-        [app messageNotification:@"_info_" description:@"_limited_dimension_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
+        [appDelegate messageNotification:@"_info_" description:@"_limited_dimension_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
         
         return NO;
     }
@@ -163,7 +166,7 @@
     _move.tintColor = [NCBrandColor sharedInstance].brandText;
     _move.barTintColor = [NCBrandColor sharedInstance].brand;
     _move.tintColorTitle = [NCBrandColor sharedInstance].brandText;
-    _move.networkingOperationQueue = app.netQueue;
+    _move.networkingOperationQueue = appDelegate.netQueue;
     
     [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
     

+ 37 - 33
iOSClient/Settings/CCAdvanced.m

@@ -27,7 +27,9 @@
 #import "NCBridgeSwift.h"
 
 @interface CCAdvanced ()
-
+{
+    AppDelegate *appDelegate;
+}
 @end
 
 @implementation CCAdvanced
@@ -150,6 +152,8 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
 }
 
@@ -162,8 +166,8 @@
     self.tableView.showsVerticalScrollIndicator = NO;
 
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
-    [app aspectTabBar:self.tabBarController.tabBar hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
+    [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
     [self recalculateSize];
 }
@@ -171,7 +175,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
 }
 
 - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
@@ -183,7 +187,7 @@
         [CCUtility setActivityVerboseHigh:[[rowDescriptor.value valueData] boolValue]];
         
         // Clear Date read Activity for force reload datasource
-        app.activeActivity.storeDateFirstActivity = nil;
+        appDelegate.activeActivity.storeDateFirstActivity = nil;
     }
     
     if ([rowDescriptor.tag isEqualToString:@"optimizedphoto"]) {
@@ -219,17 +223,17 @@
     switch (result)
     {
         case MFMailComposeResultCancelled:
-            [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
+            [appDelegate messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
             break;
         case MFMailComposeResultSaved:
-            [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
+            [appDelegate messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
             break;
         case MFMailComposeResultSent:
-            [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
+            [appDelegate messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode: error.code];
             break;
         case MFMailComposeResultFailed: {
             NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
-            [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode: error.code];
+            [appDelegate messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode: error.code];
         }
             break;
         default:
@@ -253,11 +257,11 @@
     // Email Recipents
     NSArray *toRecipents;
     
-    NSArray *activities = [[NCManageDatabase sharedInstance] getActivityWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", app.activeAccount]];
+    NSArray *activities = [[NCManageDatabase sharedInstance] getActivityWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", appDelegate.activeAccount]];
     
     if ([activities count] == 0) {
         
-        [app messageNotification:@"_info_" description:@"No activity found" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
+        [appDelegate messageNotification:@"_info_" description:@"No activity found" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
         return;
     }
     
@@ -305,7 +309,7 @@
         
     } else {
         
-        [app messageNotification:@"_error_" description:@"Impossible create file body" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+        [appDelegate messageNotification:@"_error_" description:@"Impossible create file body" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
     }
 }
 
@@ -317,9 +321,9 @@
 {
     [self deselectFormRow:sender];
     
-    [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:app.activeAccount];
+    [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:appDelegate.activeAccount];
         
-    [app.activeActivity reloadDatasource];
+    [appDelegate.activeActivity reloadDatasource];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -328,36 +332,36 @@
 
 - (void)removeAllFiles:(BOOL)removeIco
 {
-    [app maintenanceMode:YES];
+    [appDelegate maintenanceMode:YES];
     
     [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
     
-    [[NCManageDatabase sharedInstance] clearTable:[tableQueueDownload class] account:app.activeAccount];
-    [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:app.activeAccount];
+    [[NCManageDatabase sharedInstance] clearTable:[tableQueueDownload class] account:appDelegate.activeAccount];
+    [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:appDelegate.activeAccount];
     
-    [app.netQueue cancelAllOperations];
+    [appDelegate.netQueue cancelAllOperations];
     
-    [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+    [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:appDelegate.activeAccount activeUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC),dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         [[NSURLCache sharedURLCache] setMemoryCapacity:0];
         [[NSURLCache sharedURLCache] setDiskCapacity:0];
         
-        [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableE2eEncryption class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableE2eEncryption class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:appDelegate.activeAccount];
         [[NCManageDatabase sharedInstance] clearTable:[tableGPS class] account:nil];
-        [[NCManageDatabase sharedInstance] clearTable:[tableLocalFile class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:app.activeAccount];
-        [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableLocalFile class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:appDelegate.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:appDelegate.activeAccount];
         
         [[NCAutoUpload sharedInstance] alignPhotoLibrary];
         
-        [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl removeIco:removeIco];
+        [self emptyUserDirectoryUser:appDelegate.activeUser url:appDelegate.activeUrl removeIco:removeIco];
         
         [self emptyLocalDirectory];
         
@@ -367,7 +371,7 @@
         
         [self recalculateSize];
         
-        [app maintenanceMode:NO];
+        [appDelegate maintenanceMode:NO];
         
         dispatch_async(dispatch_get_main_queue(), ^{
             // Close HUD
@@ -462,8 +466,8 @@
         
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             
-            [app.netQueue cancelAllOperations];
-            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+            [appDelegate.netQueue cancelAllOperations];
+            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:appDelegate.activeAccount activeUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl];
             
             [[NSURLCache sharedURLCache] setMemoryCapacity:0];
             [[NSURLCache sharedURLCache] setDiskCapacity:0];
@@ -584,7 +588,7 @@
 
 - (NSNumber *)getUserDirectorySize
 {
-    NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
+    NSString *directoryUser = [CCUtility getDirectoryActiveUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl];
     NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
     unsigned long long count = 0;
     NSNumber *value = nil;

+ 15 - 8
iOSClient/Settings/CCManageAutoUpload.m

@@ -26,6 +26,12 @@
 #import "AppDelegate.h"
 #import "NCBridgeSwift.h"
 
+@interface CCManageAutoUpload ()
+{
+    AppDelegate *appDelegate;
+}
+@end
+
 @implementation CCManageAutoUpload
 
 //  From Settings
@@ -60,7 +66,8 @@
     XLFormDescriptor *form ;
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
-    
+ 
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
@@ -181,8 +188,8 @@
     self.tableView.showsVerticalScrollIndicator = NO;
 
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
-    [app aspectTabBar:self.tabBarController.tabBar hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
+    [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
     // Request permission for camera roll access
     [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
@@ -204,7 +211,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
 }
 
 -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
@@ -221,7 +228,7 @@
             
             // Default
             [[NCManageDatabase sharedInstance] setAccountAutoUploadFileName:nil];
-            [[NCManageDatabase sharedInstance] setAccountAutoUploadDirectory:nil activeUrl:app.activeUrl];
+            [[NCManageDatabase sharedInstance] setAccountAutoUploadDirectory:nil activeUrl:appDelegate.activeUrl];
             
             // verifichiamo che almeno uno dei servizi (foto video) siano attivi, in caso contrario attiviamo le foto
             if (account.autoUploadImage == NO && account.autoUploadVideo == NO) {
@@ -239,7 +246,7 @@
             [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadFull" state:NO];
 
             // remove
-            [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:app.activeAccount];
+            [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:appDelegate.activeAccount];
         }
         
         [self reloadForm];
@@ -284,9 +291,9 @@
             
         } else {
             
-            [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:app.activeAccount];
+            [[NCManageDatabase sharedInstance] clearTable:[tableQueueUpload class] account:appDelegate.activeAccount];
             
-            [[CCNetworking sharedNetworking] settingSessionsDownload:NO upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+            [[CCNetworking sharedNetworking] settingSessionsDownload:NO upload:YES taskStatus:k_taskStatusCancel activeAccount:appDelegate.activeAccount activeUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl];
             
             [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadFull" state:NO];
         }

+ 14 - 8
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -29,6 +29,8 @@
 
 @interface NCManageEndToEndEncryption ()
 {
+    AppDelegate *appDelegate;
+
     NSUInteger _failedAttempts;
     NSDate *_lockUntilDate;
 }
@@ -40,6 +42,8 @@
 {
     self = [super initWithCoder:aDecoder];
     if (self) {
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadForm) name:@"reloadManageEndToEndEncryption" object:nil];
         [self initializeForm];
     }
@@ -50,6 +54,8 @@
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadForm) name:@"reloadManageEndToEndEncryption" object:nil];
         [self initializeForm];
     }
@@ -85,7 +91,7 @@
         return;
     }
     
-    if ([CCUtility isEndToEndEnabled:app.activeAccount]) {
+    if ([CCUtility isEndToEndEnabled:appDelegate.activeAccount]) {
         
         // Section SERVICE ACTIVATED -------------------------------------------------
         
@@ -185,7 +191,7 @@
 
     if ([[CCUtility getBlockCode] length]) {
         
-        [app.endToEndInterface initEndToEndEncryption];
+        [appDelegate.endToEndInterface initEndToEndEncryption];
         
     } else {
         
@@ -282,20 +288,20 @@
 {
     [self deselectFormRow:sender];
     
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     
     metadataNet.action = actionDeleteEndToEndPublicKey;
-    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:appDelegate.endToEndInterface metadataNet:metadataNet];
 }
 
 - (void)deletePrivateKey:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
     
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     
     metadataNet.action = actionDeleteEndToEndPrivateKey;
-    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:appDelegate.endToEndInterface metadataNet:metadataNet];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -333,7 +339,7 @@
     
     if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
     
-        NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:app.activeAccount];
+        NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
         NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
     
         NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
@@ -350,7 +356,7 @@
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
         
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-            [CCUtility clearAllKeysEndToEnd:app.activeAccount];
+            [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
             [self initializeForm];
         }];
         

+ 6 - 3
iOSClient/Share/CCShareInfoCMOC.m

@@ -30,6 +30,7 @@
 
 @interface CCShareInfoCMOC ()
 {
+    AppDelegate *appDelegate;
     CCHud *_hud;
 }
 @end
@@ -115,6 +116,8 @@ const PERMISSION_ALL = 31;
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
     
     [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];
@@ -125,11 +128,11 @@ const PERMISSION_ALL = 31;
     _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
     [_hud visibleHudTitle:@"" mode:MBProgressHUDModeIndeterminate color:nil];
     
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     metadataNet.action = actionGetSharePermissionsFile;
     metadataNet.fileName = _metadata.fileName;
     metadataNet.serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:_metadata.directoryID];
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
 
     [self initializeForm];
 }
@@ -181,7 +184,7 @@ const PERMISSION_ALL = 31;
 {
     [_hud hideHud];
 
-    [app messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
+    [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
     
     [self dismissViewControllerAnimated:YES completion:nil];
 }

+ 4 - 1
iOSClient/Share/CCSharePermissionOC.m

@@ -27,6 +27,7 @@
 
 @interface CCSharePermissionOC ()
 {
+    AppDelegate *appDelegate;
     OCSharedDto *shareDto;
 }
 @end
@@ -146,6 +147,8 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
     
     [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];
@@ -153,7 +156,7 @@
     
     self.tableView.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
     
-    shareDto = [app.sharesID objectForKey:self.idRemoteShared];
+    shareDto = [appDelegate.sharesID objectForKey:self.idRemoteShared];
         
     [self initializeForm];    
 }

+ 7 - 3
iOSClient/Share/CCShareUserOC.m

@@ -26,7 +26,9 @@
 #import "NCBridgeSwift.h"
 
 @interface CCShareUserOC ()
-
+{
+    AppDelegate *appDelegate;
+}
 @end
 
 @implementation CCShareUserOC
@@ -94,6 +96,8 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    
     self.selectedItems = [[NSMutableArray alloc] init];
     
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
@@ -129,7 +133,7 @@
     // start share with a user if not be i 
     if ([self.directUser isEqual:[NSNull null]] == NO) {
     
-        if ([self.directUser length] > 0 && [self.directUser isEqualToString:app.activeUser] == NO) {
+        if ([self.directUser length] > 0 && [self.directUser isEqualToString:appDelegate.activeUser] == NO) {
         
             // User/Group/Federate
             [self.delegate shareUserAndGroup:self.directUser shareeType:self.shareType permission:permission];
@@ -201,7 +205,7 @@
             if ([item.shareWith isEqualToString:user.name] && ((item.shareType == shareTypeGroup && user.shareeType == 1) || (item.shareType != shareTypeGroup && user.shareeType == 0)))
                 [self.users removeObject:user];
         
-        if ([self.itemsShareWith containsObject:user.name] || [user.name isEqualToString:app.activeUser])
+        if ([self.itemsShareWith containsObject:user.name] || [user.name isEqualToString:appDelegate.activeUser])
             [self.users removeObject:user];
     }
     

+ 20 - 19
iOSClient/Synchronize/CCSynchronize.m

@@ -28,7 +28,7 @@
 
 @interface CCSynchronize () 
 {
-    // local
+    AppDelegate *appDelegate;
 }
 @end
 
@@ -43,8 +43,9 @@
         if (!sharedSynchronize) {
             
             sharedSynchronize = [CCSynchronize new];
-            
             sharedSynchronize.foldersInSynchronized = [NSMutableOrderedSet new];
+            sharedSynchronize->appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         }
         return sharedSynchronize;
     }
@@ -61,7 +62,7 @@
 
 - (void)readFolder:(NSString *)serverUrl selector:(NSString *)selector
 {
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     
     metadataNet.action = actionReadFolder;
     NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:serverUrl];
@@ -73,7 +74,7 @@
     metadataNet.selector = selector;
     metadataNet.serverUrl = serverUrl;
     
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
     
     NSLog(@"[LOG] %@ directory : %@", selector, serverUrl);
 }
@@ -87,7 +88,7 @@
     if (errorCode == 404 && [recordAccount.account isEqualToString:metadataNet.account]) {
         
         [[NCManageDatabase sharedInstance] deleteDirectoryAndSubDirectoryWithServerUrl:metadataNet.serverUrl];
-        [app.activeMain reloadDatasource:metadataNet.serverUrl];
+        [appDelegate.activeMain reloadDatasource:metadataNet.serverUrl];
     }
 }
 
@@ -112,13 +113,13 @@
         if ([recordAccount.account isEqualToString:metadataNet.account] == NO)
             return;
 
-        NSArray *recordsInSessions = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND session != ''", app.activeAccount, metadataNet.directoryID] sorted:nil ascending:NO];
+        NSArray *recordsInSessions = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND session != ''", appDelegate.activeAccount, metadataNet.directoryID] sorted:nil ascending:NO];
         
         // ----- Test : (DELETE) -----
         
         NSMutableArray *metadatasNotPresents = [NSMutableArray new];
         
-        NSArray *tableMetadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND session = ''", app.activeAccount, metadataNet.directoryID] sorted:nil ascending:NO];
+        NSArray *tableMetadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND session = ''", appDelegate.activeAccount, metadataNet.directoryID] sorted:nil ascending:NO];
         
         for (tableMetadata *record in tableMetadatas) {
             
@@ -139,8 +140,8 @@
         // delete metadata not present
         for (tableMetadata *metadata in metadatasNotPresents) {
         
-            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", app.directoryUser, metadata.fileID] error:nil];
-            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID] error:nil];
+            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", appDelegate.directoryUser, metadata.fileID] error:nil];
+            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID] error:nil];
             
             if (metadata.directory && metadataNet.serverUrl) {
                 
@@ -155,7 +156,7 @@
         
         dispatch_async(dispatch_get_main_queue(), ^{
             if ([metadatasNotPresents count] > 0)
-                [app.activeMain reloadDatasource:metadataNet.serverUrl];
+                [appDelegate.activeMain reloadDatasource:metadataNet.serverUrl];
         });
         
         // ----- Test : (MODIFY) -----
@@ -227,7 +228,7 @@
 
 - (void)readFileForFolder:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString *)selector
 {
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
     
     metadataNet.action = actionReadFile;
     metadataNet.fileName = fileName;
@@ -235,7 +236,7 @@
     metadataNet.selector = selector;
     metadataNet.serverUrl = serverUrl;
     
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
 }
 
 - (void)readFile:(tableMetadata *)metadata selector:(NSString *)selector
@@ -243,7 +244,7 @@
     NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:metadata.directoryID];
     if (!serverUrl) return;
         
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
         
     metadataNet.action = actionReadFile;
     metadataNet.fileID = metadata.fileID;
@@ -252,7 +253,7 @@
     metadataNet.selector = selector;
     metadataNet.serverUrl = serverUrl;
     
-    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
 }
 
 - (void)readFileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
@@ -271,7 +272,7 @@
         
             NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:metadataNet.directoryID];
             if (serverUrl)
-                [app.activeMain reloadDatasource:serverUrl];
+                [appDelegate.activeMain reloadDatasource:serverUrl];
         }
     }
 }
@@ -292,7 +293,7 @@
             tableMetadata *addMetadata = [[NCManageDatabase sharedInstance] addMetadata:metadata];
             
             if (addMetadata)
-                [self verifyChangeMedatas:[[NSArray alloc] initWithObjects:addMetadata, nil] serverUrl:metadataNet.serverUrl account:app.activeAccount withDownload:withDownload];
+                [self verifyChangeMedatas:[[NSArray alloc] initWithObjects:addMetadata, nil] serverUrl:metadataNet.serverUrl account:appDelegate.activeAccount withDownload:withDownload];
         }
         
         // Selector : selectorReadFileReloadFolder, selectorReadFileFolderWithDownload
@@ -353,8 +354,8 @@
         if (changeRev) {
             
             // remove file and ico
-            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", app.directoryUser, metadata.fileID] error:nil];
-            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID] error:nil];
+            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", appDelegate.directoryUser, metadata.fileID] error:nil];
+            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID] error:nil];
             
             [metadatas addObject:metadata];
         }
@@ -402,7 +403,7 @@
     [[NCManageDatabase sharedInstance] addQueueDownloadWithMetadatasNet:metadataNetToAdd];
     
     dispatch_async(dispatch_get_main_queue(), ^{
-        [app.activeMain reloadDatasource:serverUrl];
+        [appDelegate.activeMain reloadDatasource:serverUrl];
     });
 }
 

+ 11 - 7
iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m

@@ -27,6 +27,8 @@
 
 @interface CCUploadFromOtherUpp()
 {
+    AppDelegate *appDelegate;
+
     NSString *serverUrlLocal;
     NSString *destinationTitle;
 }
@@ -38,15 +40,17 @@
 {
     [super viewDidLoad];
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     self.navigationItem.rightBarButtonItem.title = NSLocalizedString(@"_cancel_", nil);
     self.title = NSLocalizedString(@"_upload_", nil);
     
-    serverUrlLocal= [CCUtility getHomeServerUrlActiveUrl:app.activeUrl];
+    serverUrlLocal= [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
     destinationTitle = NSLocalizedString(@"_home_", nil);
     
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
-    [app aspectTabBar:self.tabBarController.tabBar hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
+    [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
 }
 
 - (void)didReceiveMemoryWarning
@@ -90,9 +94,9 @@
         case 0:
             if (row == 0) {
                                 
-                NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", app.directoryUser, app.fileNameUpload] error:nil];
+                NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", appDelegate.directoryUser, appDelegate.fileNameUpload] error:nil];
                 NSString *fileSize = [CCUtility transformedSize:[[fileAttributes objectForKey:NSFileSize] longValue]];
-                nameLabel = (UILabel *)[cell viewWithTag:100]; nameLabel.text = [NSString stringWithFormat:@"%@ - %@", app.fileNameUpload, fileSize];
+                nameLabel = (UILabel *)[cell viewWithTag:100]; nameLabel.text = [NSString stringWithFormat:@"%@ - %@", appDelegate.fileNameUpload, fileSize];
             }
             break;
         case 2:
@@ -160,14 +164,14 @@
     viewController.tintColor = [NCBrandColor sharedInstance].brandText;
     viewController.barTintColor = [NCBrandColor sharedInstance].brand;
     viewController.tintColorTitle = [NCBrandColor sharedInstance].brandText;
-    viewController.networkingOperationQueue = app.netQueue;
+    viewController.networkingOperationQueue = appDelegate.netQueue;
 
     [self presentViewController:navigationController animated:YES completion:nil];
 }
 
 -(void)upload
 {
-    [[CCNetworking sharedNetworking] uploadFile:app.fileNameUpload serverUrl:serverUrlLocal session:k_upload_session taskStatus: k_taskStatusResume selector:@"" selectorPost:@"" errorCode:0 delegate:nil];
+    [[CCNetworking sharedNetworking] uploadFile:appDelegate.fileNameUpload serverUrl:serverUrlLocal session:k_upload_session taskStatus: k_taskStatusResume selector:@"" selectorPost:@"" errorCode:0 delegate:nil];
     
     [self dismissViewControllerAnimated:YES completion:nil];
 }