Ver código fonte

replace app with appDelegate

Marino Faggiana 7 anos atrás
pai
commit
2562f4737f

+ 10 - 2
iOSClient/Settings/Acknowledgements.m

@@ -24,6 +24,12 @@
 #import "Acknowledgements.h"
 #import "AppDelegate.h"
 
+@interface Acknowledgements ()
+{
+    AppDelegate *appDelegate;
+}
+@end
+
 @implementation Acknowledgements
 
 -  (id)initWithCoder:(NSCoder *)aDecoder
@@ -39,7 +45,9 @@
 {
     [super viewDidLoad];
     
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     self.navigationController.navigationBar.translucent = false;
     
     NSURL *rtfPath;
@@ -65,7 +73,7 @@
     [super viewDidAppear:animated];
     
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[app.reachability isReachable] hidden:NO];
+    [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     
     [self.txtTermini setContentOffset:CGPointZero animated:NO];
     self.txtTermini.hidden = false;

+ 25 - 22
iOSClient/Settings/CCManageAccount.m

@@ -32,6 +32,7 @@
 
 @interface CCManageAccount () <CCLoginDelegate, CCLoginDelegateWeb>
 {
+    AppDelegate *appDelegate;
     tableAccount *_tableAccount;
 }
 @end
@@ -44,6 +45,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
     
     NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
@@ -57,7 +60,7 @@
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"pickerAccount" rowType:XLFormRowDescriptorTypePicker];
     row.height = 100;
     row.selectorOptions = listAccount;
-    row.value = app.activeAccount;
+    row.value = appDelegate.activeAccount;
     [section addFormRow:row];
 
     // Section : USER INFORMATION -------------------------------------------
@@ -155,15 +158,15 @@
     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 UpdateForm];
 }
 
 - (void)changeTheming
 {
-    [app changeTheming:self];
+    [appDelegate changeTheming:self];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -194,7 +197,7 @@
 
 - (void)loginDisappear
 {
-    app.activeLogin = nil;
+    appDelegate.activeLogin = nil;
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -205,15 +208,15 @@
 {
     [self deselectFormRow:sender];
     
-    [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];
     
-    [app openLoginView:self loginType:loginAdd];
+    [appDelegate openLoginView:self loginType:loginAdd];
 }
 
 - (void)addAccountFoced
 {
-    [app openLoginView:self loginType:loginAddForced];
+    [appDelegate openLoginView:self loginType:loginAddForced];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -224,10 +227,10 @@
 {    
     [self deselectFormRow:sender];
     
-    [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];
     
-    [app openLoginView:self loginType:loginModifyPasswordUser];
+    [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
     
     [self UpdateForm];
 }
@@ -258,8 +261,8 @@
 
 - (void)deleteAccount:(NSString *)account
 {
-    [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];
     
     [[NCManageDatabase sharedInstance] clearTable:[tableAccount class] account:account];
     [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:account];
@@ -275,7 +278,7 @@
     [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:account];
     
     // Clear active user
-    [app settingActiveAccount:nil activeUrl:nil activeUser:nil activeUserID:nil activePassword:nil];
+    [appDelegate settingActiveAccount:nil activeUrl:nil activeUser:nil activeUserID:nil activePassword:nil];
 }
 
 - (void)answerDelAccount:(XLFormRowDescriptor *)sender
@@ -298,8 +301,8 @@
 
 - (void)ChangeDefaultAccount:(NSString *)account
 {
-    NSUInteger numInSession = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND session != ''", app.activeAccount] sorted:nil ascending:NO] count];
-    NSUInteger numInQueue = [app.netQueue operationCount];
+    NSUInteger numInSession = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND session != ''", appDelegate.activeAccount] sorted:nil ascending:NO] count];
+    NSUInteger numInQueue = [appDelegate.netQueue operationCount];
     
     if (numInSession+numInQueue > 0) {
         
@@ -308,14 +311,14 @@
         return;
     }
 
-    [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];
     
     // change account
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
     if (tableAccount) {
         
-        [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
+        [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
  
         // Init home
         [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
@@ -340,9 +343,9 @@
     XLFormPickerCell *pickerAccount = (XLFormPickerCell *)[[self.form formRowWithTag:@"pickerAccount"] cellForFormController:self];
     
     pickerAccount.rowDescriptor.selectorOptions = listAccount;
-    pickerAccount.rowDescriptor.value = app.activeAccount;
+    pickerAccount.rowDescriptor.value = appDelegate.activeAccount;
     
-    UIImage *avatar = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/avatar.png", app.directoryUser]];
+    UIImage *avatar = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/avatar.png", appDelegate.directoryUser]];
     if (avatar) {
     
         avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(40, 40) isAspectRation:YES];

+ 21 - 13
iOSClient/Settings/CCSettings.m

@@ -34,6 +34,12 @@
 #define alertViewEsci 1
 #define alertViewAzzeraCache 2
 
+@interface CCSettings ()
+{
+    AppDelegate *appDelegate;
+}
+@end
+
 @implementation CCSettings
 
 - (id)initWithCoder:(NSCoder *)aDecoder
@@ -42,11 +48,13 @@
     
     if (self) {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         [self initializeForm];
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
-        app.activeSettings = self;
+        appDelegate.activeSettings = self;
     }
     
     return self;
@@ -170,8 +178,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 reloadForm];
 }
@@ -179,7 +187,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -373,7 +381,7 @@
 
 - (void)synchronizeFavorites
 {    
-    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND favorite = true", app.activeAccount]  sorted:nil ascending:NO];
+    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND favorite = true", appDelegate.activeAccount]  sorted:nil ascending:NO];
     
     for (tableMetadata *metadata in metadatas) {
         
@@ -389,14 +397,14 @@
             if (![serverUrl hasSuffix:@"/"])
                 serverUrlBeginWith = [serverUrl stringByAppendingString:@"/"];
 
-            NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND (serverUrl = %@ OR serverUrl BEGINSWITH %@)", app.activeAccount, serverUrl, serverUrlBeginWith] sorted:@"serverUrl" ascending:true];
+            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:nil directoryID:directory.directoryID];
         } 
     }
     
-    [app.activeFavorites readListingFavorites];
+    [appDelegate.activeFavorites readListingFavorites];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -444,17 +452,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:
@@ -514,7 +522,7 @@
                 
                 [CCUtility setBlockCode:@""];
                 [[NCManageDatabase sharedInstance] setAllDirectoryUnLock];
-                [app.activeMain.tableView reloadData];
+                [appDelegate.activeMain.tableView reloadData];
             }
             
             // change simply
@@ -523,7 +531,7 @@
                 // disable passcode
                 [CCUtility setBlockCode:@""];
                 [[NCManageDatabase sharedInstance] setAllDirectoryUnLock];
-                [app.activeMain.tableView reloadData];
+                [appDelegate.activeMain.tableView reloadData];
                 
                 [CCUtility setSimplyBlockCode:![CCUtility getSimplyBlockCode]];
                 

+ 11 - 7
iOSClient/Share/CCShareOC.m

@@ -26,7 +26,9 @@
 #import "NCBridgeSwift.h"
 
 @interface CCShareOC ()
-
+{
+    AppDelegate *appDelegate;
+}
 @end
 
 @implementation CCShareOC
@@ -36,6 +38,8 @@
     self = [super initWithCoder:coder];
     if (self) {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         self.itemsShareWith = [[NSMutableArray alloc] init];
         
         [self initializeForm];
@@ -120,9 +124,9 @@
     
     [self reloadData];
     
-    if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, self.metadata.fileID]]) {
+    if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, self.metadata.fileID]]) {
         
-        self.fileImageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, self.metadata.fileID]];
+        self.fileImageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, self.metadata.fileID]];
         
     } else {
         
@@ -231,7 +235,7 @@
     
         for (NSString *idRemoteShared in self.itemsUserAndGroupLink) {
             
-            OCSharedDto *item = [app.sharesID objectForKey:idRemoteShared];
+            OCSharedDto *item = [appDelegate.sharesID objectForKey:idRemoteShared];
             
             XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:idRemoteShared rowType:XLFormRowDescriptorTypeButton];
 
@@ -281,7 +285,7 @@
         
     } else {
 
-        url = [NSString stringWithFormat:@"%@/%@%@", app.activeUrl, k_share_link_middle_part_url_after_version_8, sharedLink];
+        url = [NSString stringWithFormat:@"%@/%@%@", appDelegate.activeUrl, k_share_link_middle_part_url_after_version_8, sharedLink];
 
     }
 
@@ -335,7 +339,7 @@
 {
     [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
     
-    OCSharedDto *shareDto = [app.sharesID objectForKey:self.shareLink];
+    OCSharedDto *shareDto = [appDelegate.sharesID objectForKey:self.shareLink];
     
     if ([rowDescriptor.tag isEqualToString:@"shareLinkSwitch"]) {
         
@@ -400,7 +404,7 @@
 {
     [super endEditing:rowDescriptor];
     
-    OCSharedDto *shareDto = [app.sharesID objectForKey:self.shareLink];
+    OCSharedDto *shareDto = [appDelegate.sharesID objectForKey:self.shareLink];
     
     if ([rowDescriptor.tag isEqualToString:@"expirationDate"]) {
         

+ 7 - 7
iOSClient/Shares/NCShares.m

@@ -79,11 +79,11 @@
     [super viewWillAppear:animated];
     
     // Color
-    [app aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.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];
 }
@@ -91,7 +91,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
     
     // Reload Table View
     [self.tableView reloadData];
@@ -180,7 +180,7 @@
 
 - (void)removeShares:(tableMetadata *)metadata tableShare:(tableShare *)tableShare
 {
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
  
     metadataNet.action = actionUnShare;
     metadataNet.fileID = metadata.fileID;
@@ -192,7 +192,7 @@
     if (tableShare.shareLink.length > 0) {
    
         metadataNet.share = tableShare.shareLink;
-        [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+        [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
     }
     
     // Unshare User&Group
@@ -200,7 +200,7 @@
     for (NSString *share in shareUserAndGroup) {
         
         metadataNet.share = [share stringByReplacingOccurrencesOfString:@" " withString:@""];
-        [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+        [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
     }
 }
 

+ 32 - 28
iOSClient/Transfers/CCTransfers.m

@@ -35,7 +35,9 @@
 #define uploadwwan 4
 
 @interface CCTransfers ()
-{    
+{
+    AppDelegate *appDelegate;
+
     // Datasource
     CCSectionDataSourceMetadata *_sectionDataSource;
 }
@@ -51,10 +53,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.activeTransfers = self;
+        appDelegate.activeTransfers = self;
     }
     return self;
 }
@@ -85,8 +89,8 @@
     [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];
     
     [self reloadDatasource];
 }
@@ -94,7 +98,7 @@
 - (void)changeTheming
 {
     if (self.isViewLoaded && self.view.window)
-        [app changeTheming:self];
+        [appDelegate changeTheming:self];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -152,7 +156,7 @@
     if (!fileID)
         return;
     
-    [app.listProgressMetadata setObject:[NSNumber numberWithFloat:progress] forKey:fileID];
+    [appDelegate.listProgressMetadata setObject:[NSNumber numberWithFloat:progress] forKey:fileID];
     
     NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:fileID];
     
@@ -172,7 +176,7 @@
 
 - (void)reloadTaskButton:(id)sender withEvent:(UIEvent *)event
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     UITouch * touch = [[event allTouches] anyObject];
@@ -185,13 +189,13 @@
         tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
         
         if (metadata)
-            [app.activeMain reloadTaskButton:metadata];
+            [appDelegate.activeMain reloadTaskButton:metadata];
     }
 }
 
 - (void)reloadAllTask
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     for (NSString *key in _sectionDataSource.allRecordsDataSource.allKeys) {
@@ -201,13 +205,13 @@
         if ([metadata.session containsString:@"upload"] && (metadata.sessionTaskIdentifier != k_taskIdentifierStop))
             continue;
         
-        [app.activeMain reloadTaskButton:metadata];
+        [appDelegate.activeMain reloadTaskButton:metadata];
     }
 }
 
 - (void)cancelTaskButton:(id)sender withEvent:(UIEvent *)event
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     UITouch * touch = [[event allTouches] anyObject];
@@ -220,13 +224,13 @@
         tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
         
         if (metadata)
-            [app.activeMain cancelTaskButton:metadata reloadTable:YES];
+            [appDelegate.activeMain cancelTaskButton:metadata reloadTable:YES];
     }
 }
 
 - (void)cancelAllTask
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     BOOL lastAndRefresh = NO;
@@ -241,13 +245,13 @@
         if ([metadata.session containsString:@"upload"] && ((metadata.sessionTaskIdentifier == k_taskIdentifierDone) || (metadata.sessionTaskIdentifier >= 0)))
             continue;
         
-        [app.activeMain cancelTaskButton:metadata reloadTable:lastAndRefresh];
+        [appDelegate.activeMain cancelTaskButton:metadata reloadTable:lastAndRefresh];
     }
 }
 
 - (void)stopTaskButton:(id)sender withEvent:(UIEvent *)event
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     UITouch * touch = [[event allTouches] anyObject];
@@ -260,13 +264,13 @@
         tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
         
         if (metadata)
-            [app.activeMain stopTaskButton:metadata];
+            [appDelegate.activeMain stopTaskButton:metadata];
     }
 }
 
 - (void)stopAllTask
 {
-    if (app.activeMain == nil)
+    if (appDelegate.activeMain == nil)
         return;
     
     for (NSString *key in _sectionDataSource.allRecordsDataSource.allKeys) {
@@ -274,14 +278,14 @@
         tableMetadata *metadata = [_sectionDataSource.allRecordsDataSource objectForKey:key];
         
         if ([metadata.session containsString:@"download"]) {
-            [app.activeMain cancelTaskButton:metadata reloadTable:YES];
+            [appDelegate.activeMain cancelTaskButton:metadata reloadTable:YES];
             continue;
         }
         
         if ([metadata.session containsString:@"upload"] && ((metadata.sessionTaskIdentifier == k_taskIdentifierDone) || (metadata.sessionTaskIdentifier >= 0)))
             continue;
         
-        [app.activeMain stopTaskButton:metadata];
+        [appDelegate.activeMain stopTaskButton:metadata];
     }    
 }
 
@@ -293,7 +297,7 @@
 {
     NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadataNet.fileID];
     
-    if (indexPath && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]]) {
+    if (indexPath && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadataNet.fileID]]) {
         
         [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
     }
@@ -306,12 +310,12 @@
 - (void)reloadDatasource
 {
     // test
-    if (app.activeAccount.length == 0)
+    if (appDelegate.activeAccount.length == 0)
         return;
     
-    NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND ((session CONTAINS 'upload') OR (session CONTAINS 'download' AND (sessionSelector != 'loadPlist')))", app.activeAccount] sorted:@"sessionTaskIdentifier" ascending:YES];
+    NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND ((session CONTAINS 'upload') OR (session CONTAINS 'download' AND (sessionSelector != 'loadPlist')))", appDelegate.activeAccount] sorted:@"sessionTaskIdentifier" ascending:YES];
     
-    _sectionDataSource  = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:app.listProgressMetadata e2eEncryptions:nil groupByField:@"session" activeAccount:app.activeAccount];
+    _sectionDataSource  = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:appDelegate.listProgressMetadata e2eEncryptions:nil groupByField:@"session" activeAccount:appDelegate.activeAccount];
         
     [_tableView reloadData];    
 }
@@ -595,9 +599,9 @@
     // ----------------------------------------------------------------------------------------------------------
     
     // assegnamo l'immagine anteprima se esiste, altrimenti metti quella standars
-    if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]]) {
+    if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID]]) {
         
-        cell.file.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
+        cell.file.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID]];
         
     } else {
         
@@ -628,7 +632,7 @@
         
         cell.labelInfoFile.text = [NSString stringWithFormat:@"%@", lunghezzaFile];
         
-        float progress = [[app.listProgressMetadata objectForKey:metadata.fileID] floatValue];
+        float progress = [[appDelegate.listProgressMetadata objectForKey:metadata.fileID] floatValue];
         if (progress > 0) {
             
             cell.progressView.progressTintColor = [UIColor blackColor];
@@ -681,13 +685,13 @@
         }
         
         // se non c'è una preview in bianconero metti l'immagine di default
-        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]] == NO)
+        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", appDelegate.directoryUser, metadata.fileID]] == NO)
             cell.file.image = [UIImage imageNamed:@"uploaddisable"];
         
         cell.labelTitle.enabled = NO;
         cell.labelInfoFile.text = [NSString stringWithFormat:@"%@", lunghezzaFile];
         
-        float progress = [[app.listProgressMetadata objectForKey:metadata.fileID] floatValue];
+        float progress = [[appDelegate.listProgressMetadata objectForKey:metadata.fileID] floatValue];
         if (progress > 0) {
             
             cell.progressView.progressTintColor = [UIColor blackColor];