Browse Source

clear code

marinofaggiana 4 years ago
parent
commit
3af5aabb98

+ 5 - 5
iOSClient/AppDelegate.m

@@ -138,7 +138,7 @@
         [CCUtility setIntro:YES];
         [CCUtility setIntro:YES];
         
         
         if (self.account.length == 0) {
         if (self.account.length == 0) {
-            [self openLoginView:nil selector:k_intro_login openLoginWeb:false];
+            [self openLoginView:nil selector:NCBrandGlobal.shared.introLogin openLoginWeb:false];
         }
         }
         
         
     } else {
     } else {
@@ -301,7 +301,7 @@
     // check unauthorized server (401)
     // check unauthorized server (401)
     if ([CCUtility getPassword:self.account].length == 0) {
     if ([CCUtility getPassword:self.account].length == 0) {
         
         
-        [self openLoginView:self.window.rootViewController selector:k_intro_login openLoginWeb:true];
+        [self openLoginView:self.window.rootViewController selector:NCBrandGlobal.shared.introLogin openLoginWeb:true];
     }
     }
     
     
     // check certificate untrusted (-1202)
     // check certificate untrusted (-1202)
@@ -353,13 +353,13 @@
     }
     }
     
     
     // normal login
     // normal login
-    if (selector == k_intro_signup) {
+    if (selector == NCBrandGlobal.shared.introSignup) {
         
         
         if (!(_activeLoginWeb.isViewLoaded && _activeLoginWeb.view.window)) {
         if (!(_activeLoginWeb.isViewLoaded && _activeLoginWeb.view.window)) {
             
             
             self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
             self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
             
             
-            if (selector == k_intro_signup) {
+            if (selector == NCBrandGlobal.shared.introSignup) {
                 self.activeLoginWeb.urlBase = [[NCBrandOptions shared] linkloginPreferredProviders];
                 self.activeLoginWeb.urlBase = [[NCBrandOptions shared] linkloginPreferredProviders];
             } else {
             } else {
                 self.activeLoginWeb.urlBase = self.urlBase;
                 self.activeLoginWeb.urlBase = self.urlBase;
@@ -478,7 +478,7 @@
             [self settingAccount:newAccount urlBase:tableAccount.urlBase user:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account]];
             [self settingAccount:newAccount urlBase:tableAccount.urlBase user:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account]];
             [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
             [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
         } else {
         } else {
-            [self openLoginView:self.window.rootViewController selector:k_intro_login openLoginWeb:false];
+            [self openLoginView:self.window.rootViewController selector:NCBrandGlobal.shared.introLogin openLoginWeb:false];
         }
         }
     }
     }
 }
 }

+ 2 - 2
iOSClient/Brand/Intro/NCIntroViewController.swift

@@ -163,11 +163,11 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
     }
     }
 
 
     @IBAction func login(_ sender: Any) {
     @IBAction func login(_ sender: Any) {
-        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: Int(k_intro_login), openLoginWeb: false)
+        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: false)
     }
     }
 
 
     @IBAction func signup(_ sender: Any) {
     @IBAction func signup(_ sender: Any) {
-        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: Int(k_intro_signup), openLoginWeb: false)
+        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: NCBrandGlobal.shared.introSignup, openLoginWeb: false)
     }
     }
 
 
     @IBAction func host(_ sender: Any) {
     @IBAction func host(_ sender: Any) {

+ 9 - 0
iOSClient/Brand/NCBrand.swift

@@ -218,6 +218,11 @@ class NCBrandColor: NSObject {
 
 
     // Directory on Group
     // Directory on Group
     @objc let appDatabaseNextcloud                  = "Library/Application Support/Nextcloud"
     @objc let appDatabaseNextcloud                  = "Library/Application Support/Nextcloud"
+    @objc let appApplicationSupport                 = "Library/Application Support"
+    @objc let appUserData                           = "Library/Application Support/UserData"
+    @objc let appCertificates                       = "Library/Application Support/Certificates"
+    @objc let appScan                               = "Library/Application Support/Scan"
+    @objc let directoryProviderStorage              = "File Provider Storage"
 
 
     // Nextcloud version
     // Nextcloud version
     @objc let nextcloudVersion12: Int               =  12
     @objc let nextcloudVersion12: Int               =  12
@@ -230,6 +235,10 @@ class NCBrandColor: NSObject {
     let databaseDefault                             = "nextcloud.realm"
     let databaseDefault                             = "nextcloud.realm"
     let databaseSchemaVersion: UInt64               = 160
     let databaseSchemaVersion: UInt64               = 160
     
     
+    // Intro selector
+    @objc let introLogin: Int                       = 0
+    @objc let introSignup: Int                      = 1
+    
     // Avatar & Preview
     // Avatar & Preview
     let avatarSize: Int                             = 128
     let avatarSize: Int                             = 128
     @objc let sizePreview: CGFloat                  = 1024
     @objc let sizePreview: CGFloat                  = 1024

+ 0 - 11
iOSClient/CCGlobal.h

@@ -50,17 +50,6 @@
 #define CALL_ORIGIN NSLog(@"Origin: [%@]", [[[[NSThread callStackSymbols] objectAtIndex:1] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"[]"]] objectAtIndex:1])
 #define CALL_ORIGIN NSLog(@"Origin: [%@]", [[[[NSThread callStackSymbols] objectAtIndex:1] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"[]"]] objectAtIndex:1])
 #endif
 #endif
 
 
-// Directory on Group
-#define k_appApplicationSupport                         @"Library/Application Support"
-#define k_appUserData                                   @"Library/Application Support/UserData"
-#define k_appCertificates                               @"Library/Application Support/Certificates"
-#define k_appScan                                       @"Library/Application Support/Scan"
-#define k_DirectoryProviderStorage                      @"File Provider Storage"
-
-// Intro selector
-#define k_intro_login                                   0
-#define k_intro_signup                                  1
-
 // Constants to identify the different permissions of a file
 // Constants to identify the different permissions of a file
 #define k_permission_shared                             @"S"
 #define k_permission_shared                             @"S"
 #define k_permission_can_share                          @"R"
 #define k_permission_can_share                          @"R"

+ 1 - 1
iOSClient/More/NCMore.swift

@@ -417,7 +417,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
                 let manageAccount = CCManageAccount()
                 let manageAccount = CCManageAccount()
                 manageAccount.delete(self.appDelegate.account)
                 manageAccount.delete(self.appDelegate.account)
 
 
-                self.appDelegate.openLoginView(self, selector: Int(k_intro_login), openLoginWeb: false)
+                self.appDelegate.openLoginView(self, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: false)
             }
             }
 
 
             let actionNo = UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action: UIAlertAction) in
             let actionNo = UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action: UIAlertAction) in

+ 2 - 2
iOSClient/Settings/CCManageAccount.m

@@ -328,7 +328,7 @@
     
     
     // Open Login
     // Open Login
     if (accounts.count == 0) {
     if (accounts.count == 0) {
-        [appDelegate openLoginView:self selector:k_intro_login openLoginWeb:false];
+        [appDelegate openLoginView:self selector:NCBrandGlobal.shared.introLogin openLoginWeb:false];
     }
     }
 }
 }
 
 
@@ -381,7 +381,7 @@
 {
 {
     [self deselectFormRow:sender];
     [self deselectFormRow:sender];
     
     
-    [appDelegate openLoginView:self selector:k_intro_login openLoginWeb:false];
+    [appDelegate openLoginView:self selector:NCBrandGlobal.shared.introLogin openLoginWeb:false];
 }
 }
 
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------

+ 9 - 9
iOSClient/Utility/CCUtility.m

@@ -1012,7 +1012,7 @@
     [[NSFileManager defaultManager] setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:path error:nil];
     [[NSFileManager defaultManager] setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:path error:nil];
     
     
     // create Directory User Data
     // create Directory User Data
-    path = [[dirGroup URLByAppendingPathComponent:k_appUserData] path];
+    path = [[dirGroup URLByAppendingPathComponent:NCBrandGlobal.shared.appUserData] path];
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
     
     
@@ -1022,7 +1022,7 @@
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
     
     
     // create Directory Scan
     // create Directory Scan
-    path = [[dirGroup URLByAppendingPathComponent:k_appScan] path];
+    path = [[dirGroup URLByAppendingPathComponent:NCBrandGlobal.shared.appScan] path];
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
     
     
@@ -1033,8 +1033,8 @@
     
     
     // Directory Excluded From Backup
     // Directory Excluded From Backup
     [CCUtility addSkipBackupAttributeToItemAtURL:[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]];
     [CCUtility addSkipBackupAttributeToItemAtURL:[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]];
-    [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_DirectoryProviderStorage]];
-    [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_appUserData]];
+    [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.directoryProviderStorage]];
+    [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.appUserData]];
     
     
     #ifdef DEBUG
     #ifdef DEBUG
     NSLog(@"[LOG] Copy DB on Documents directory");
     NSLog(@"[LOG] Copy DB on Documents directory");
@@ -1094,7 +1094,7 @@
 // Return the path of directory Cetificates
 // Return the path of directory Cetificates
 + (NSString *)getDirectoryCerificates
 + (NSString *)getDirectoryCerificates
 {
 {
-    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_appCertificates] path];
+    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.appCertificates] path];
     
     
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
@@ -1104,7 +1104,7 @@
 
 
 + (NSString *)getDirectoryUserData
 + (NSString *)getDirectoryUserData
 {
 {
-    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_appUserData] path];
+    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.appUserData] path];
     
     
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
@@ -1114,7 +1114,7 @@
 
 
 + (NSString *)getDirectoryProviderStorage
 + (NSString *)getDirectoryProviderStorage
 {
 {
-    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_DirectoryProviderStorage] path];
+    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.directoryProviderStorage] path];
     
     
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
@@ -1188,7 +1188,7 @@
 + (void)removeGroupApplicationSupport
 + (void)removeGroupApplicationSupport
 {
 {
     NSURL *dirGroup = [CCUtility getDirectoryGroup];
     NSURL *dirGroup = [CCUtility getDirectoryGroup];
-    NSString *path = [[dirGroup URLByAppendingPathComponent:k_appApplicationSupport] path];
+    NSString *path = [[dirGroup URLByAppendingPathComponent:NCBrandGlobal.shared.appApplicationSupport] path];
     
     
     [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
     [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
 }
 }
@@ -1340,7 +1340,7 @@
 
 
 + (NSString *)getDirectoryScan
 + (NSString *)getDirectoryScan
 {
 {
-    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:k_appScan] path];
+    NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCBrandGlobal.shared.appScan] path];
     
     
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
     if (![[NSFileManager defaultManager] fileExistsAtPath:path])
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];