Marino Faggiana 7 years ago
parent
commit
0f9db49c65

+ 4 - 2
Picker/DocumentPickerViewController.swift

@@ -48,6 +48,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     var activeAccount: String = ""
     var activeUrl: String = ""
     var activeUser: String = ""
+    var activeUserID: String = ""
     var activePassword: String = ""
     var directoryUser: String = ""
     
@@ -90,6 +91,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
             activePassword = record.password
             activeUrl = record.url
             activeUser = record.user
+            activeUserID = record.userID
             directoryUser = CCUtility.getDirectoryActiveUser(activeUser, activeUrl: activeUrl)
             
             if serverUrl == nil {
@@ -224,7 +226,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         metadataNet.serverUrl = self.serverUrl
         metadataNet.selector = selectorReadFolder
         
-        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl)
+        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withUserID: activeUserID, withPassword: activePassword, withUrl: activeUrl)
         networkingOperationQueue.addOperation(ocNetworking)
         
         hud.visibleIndeterminateHud()
@@ -299,7 +301,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         metadataNet.selector = selectorDownloadThumbnail;
         metadataNet.serverUrl = self.serverUrl
         
-        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl)
+        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withUserID: activeUserID, withPassword: activePassword, withUrl: activeUrl)
         networkingOperationQueue.addOperation(ocNetworking)
     }
 

+ 1 - 0
Share/ShareViewController.h

@@ -41,6 +41,7 @@
 @property (nonatomic, strong) NSString *activeAccount;
 @property (nonatomic, strong) NSString *activeUrl;
 @property (nonatomic, strong) NSString *activeUser;
+@property (nonatomic, strong) NSString *activeUserID;
 @property (nonatomic, strong) NSString *activePassword;
 @property (nonatomic, strong) NSString *activeAccessToken;
 @property (nonatomic, strong) NSString *directoryUser;

+ 2 - 1
Share/ShareViewController.m

@@ -61,6 +61,7 @@
         _activePassword = recordAccount.password;
         _activeUrl = recordAccount.url;
         _activeUser = recordAccount.user;
+        _activeUserID = recordAccount.userID;
         _directoryUser = [CCUtility getDirectoryActiveUser:self.activeUser activeUrl:self.activeUrl];
         
         if ([_activeAccount isEqualToString:[CCUtility getActiveAccountExt]]) {
@@ -284,7 +285,7 @@
 {
     id operation;
    
-    operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl];
+    operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:_activeUser withUserID:_activeUserID withPassword:_activePassword withUrl:_activeUrl];
     
     [operation setQueuePriority:metadataNet.priority];
     

+ 1 - 1
iOSClient/Actions/CCActions.swift

@@ -164,7 +164,7 @@ class CCActions: NSObject {
             return
         }
         
-        let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl);
+        let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl);
 
         // Verify if exists the fileName TO
         guard (ocNetworking?.readFileSync("\(String(describing: serverUrl))/\(fileName)")) != nil else {

+ 2 - 1
iOSClient/AppDelegate.h

@@ -54,6 +54,7 @@
 @property (nonatomic, strong) NSString *activeAccount;
 @property (nonatomic, strong) NSString *activeUrl;
 @property (nonatomic, strong) NSString *activeUser;
+@property (nonatomic, strong) NSString *activeUserID;
 @property (nonatomic, strong) NSString *activePassword;
 @property (nonatomic, strong) NSString *directoryUser;
 @property (nonatomic, strong) NSString *activeEmail;
@@ -128,7 +129,7 @@
 - (void)openLoginView:(id)delegate loginType:(enumLoginType)loginType;
 
 // Setting Active Account
-- (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activePassword:(NSString *)activePassword;
+- (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword;
 
 // initializations 
 - (void)applicationInitialized;

+ 4 - 3
iOSClient/AppDelegate.m

@@ -140,7 +140,7 @@
 
         } else {
         
-            [self settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activePassword:account.password];
+            [self settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
         }
     }
     
@@ -381,11 +381,12 @@
 #pragma mark ===== Setting Active Account for all APP =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activePassword:(NSString *)activePassword
+- (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword
 {
     self.activeAccount = activeAccount;
     self.activeUrl = activeUrl;
     self.activeUser = activeUser;
+    self.activeUserID = activeUserID;
     self.activePassword = activePassword;
     
     self.directoryUser = [CCUtility getDirectoryActiveUser:activeUser activeUrl:activeUrl];
@@ -1266,7 +1267,7 @@
 {
     id operation;
     
-    operation = [[OCnetworking alloc] initWithDelegate:delegate metadataNet:metadataNet withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl];
+    operation = [[OCnetworking alloc] initWithDelegate:delegate metadataNet:metadataNet withUser:_activeUser withUserID:_activeUserID withPassword:_activePassword withUrl:_activeUrl];
         
     [operation setQueuePriority:metadataNet.priority];
     

+ 1 - 1
iOSClient/AutoUpload/NCAutoUpload.m

@@ -503,7 +503,7 @@
 
 - (BOOL)createFolderSubFolderAutoUploadFolderPhotos:(NSString *)folderPhotos useSubFolder:(BOOL)useSubFolder assets:(PHFetchResult *)assets selector:(NSString *)selector
 {
-    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withPassword:app.activePassword withUrl:app.activeUrl];
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withUserID:app.activeUserID withPassword:app.activePassword withUrl:app.activeUrl];
     
     if ([ocNetworking automaticCreateFolderSync:folderPhotos]) {
         

+ 24 - 14
iOSClient/Login/CCLogin.m

@@ -28,7 +28,6 @@
 
 @interface CCLogin ()
 {
-    UIAlertView *alertView;
     UIView *rootView;
 }
 @end
@@ -226,8 +225,11 @@
                 
                 dispatch_async(dispatch_get_main_queue(), ^{
                     
-                    alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_connection_error_",nil) message:[error localizedDescription] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-                    [alertView show];
+                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_connection_error_", nil) message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
+                    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
+                    
+                    [alertController addAction:okAction];
+                    [self presentViewController:alertController animated:YES completion:nil];
                 });
             }
             
@@ -272,7 +274,7 @@
     if ([[self.baseUrl.text substringFromIndex:[self.baseUrl.text length] - 1] isEqualToString:@"/"])
         self.baseUrl.text = [self.baseUrl.text substringToIndex:[self.baseUrl.text length] - 1];
     
-    OCnetworking *ocNet = [[OCnetworking alloc] initWithDelegate:self metadataNet:nil withUser:self.user.text withPassword:self.password.text withUrl:nil];
+    OCnetworking *ocNet = [[OCnetworking alloc] initWithDelegate:self metadataNet:nil withUser:self.user.text withUserID:self.user.text withPassword:self.password.text withUrl:nil];
     NSError *error = [ocNet checkServerSync:[NSString stringWithFormat:@"%@%@", self.baseUrl.text, webDAV]];
     
     if (!error) {
@@ -286,7 +288,7 @@
             tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountPassword:account password:self.password.text];
             
             // Setting App active account
-            [app settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activePassword:tbAccount.password];
+            [app settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activeUserID:tbAccount.userID activePassword:tbAccount.password];
 
             // Dismiss
             [self.delegate loginSuccess:_loginType];
@@ -300,7 +302,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 withPassword:self.password.text withUrl:self.baseUrl.text]];
+            [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]];
         }
         
     } else {
@@ -310,8 +312,11 @@
             NSString *description = [error.userInfo objectForKey:@"NSLocalizedDescription"];
             NSString *message = [NSString stringWithFormat:@"%@.\n%@", NSLocalizedStringFromTable(@"_not_possible_connect_to_server_", @"Error", nil), description];
             
-            alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_error_", nil) message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-            [alertView show];
+            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+            UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
+            
+            [alertController addAction:okAction];
+            [self presentViewController:alertController animated:YES completion:nil];
         }
     }
         
@@ -327,8 +332,11 @@
 {
     [[NCManageDatabase sharedInstance] deleteAccount:metadataNet.account];
     
-    alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_error_", nil) message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-    [alertView show];
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
+    
+    [alertController addAction:okAction];
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 - (void)getUserProfileSuccess:(CCMetadataNet *)metadataNet userProfile:(OCUserProfile *)userProfile
@@ -342,9 +350,11 @@
             
             [[NCManageDatabase sharedInstance] deleteAccount:metadataNet.account];
             
-            NSString *message = [NSString stringWithFormat:NSLocalizedString(@"_account_already_exists_", nil), userProfile.id];
-            alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_error_", nil) message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-            [alertView show];
+            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:[NSString stringWithFormat:NSLocalizedString(@"_account_already_exists_", nil), userProfile.id] preferredStyle:UIAlertControllerStyleAlert];
+            UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
+            
+            [alertController addAction:okAction];
+            [self presentViewController:alertController animated:YES completion:nil];
             
             return;
         }
@@ -362,7 +372,7 @@
         tableAccount *account = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
         
         // Setting App active account
-        [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activePassword:account.password];
+        [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
     
         // Ok ! Dismiss
         [self.delegate loginSuccess:_loginType];

+ 1 - 1
iOSClient/Login/CCLoginWeb.swift

@@ -79,7 +79,7 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
                 
                     if (tableAccount.account == account) {
                     
-                        appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activePassword: password)
+                        appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: password)
                         self.delegate?.loginSuccess(NSInteger(loginType.rawValue))
                 
                         self.viewController?.dismiss(animated: true, completion: nil)

+ 3 - 3
iOSClient/Main/CCMain.m

@@ -1118,7 +1118,7 @@
     tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
     
     // Setting App active account
-    [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activePassword:account.password];
+    [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
         
@@ -2171,7 +2171,7 @@
     NSString *directoryIDTo = [[NCManageDatabase sharedInstance] getDirectoryID:serverUrlTo];
     if (!directoryIDTo) return;
     
-    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withPassword:app.activePassword withUrl:app.activeUrl];
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withUserID:app.activeUserID withPassword:app.activePassword withUrl:app.activeUrl];
             
     NSError *error = [ocNetworking readFileSync:[NSString stringWithFormat:@"%@/%@", serverUrlTo, metadata.fileName]];
             
@@ -3020,7 +3020,7 @@
             
         tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:[sender argument]];
         if (tableAccount)
-            [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activePassword:tableAccount.password];
+            [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
     
         // go to home sweet home
         [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];

+ 3 - 1
iOSClient/Move/CCMove.m

@@ -30,6 +30,7 @@
     NSString *activePassword;
     NSString *activeUrl;
     NSString *activeUser;
+    NSString *activeUserID;
     NSString *directoryUser;
     
     BOOL _loadingFolder;
@@ -52,6 +53,7 @@
         activePassword = recordAccount.password;
         activeUrl = recordAccount.url;
         activeUser = recordAccount.user;
+        activeUserID = recordAccount.userID;
         directoryUser = [CCUtility getDirectoryActiveUser:activeUser activeUrl:activeUrl];
         
     } else {
@@ -251,7 +253,7 @@
 
 - (void)addNetworkingQueue:(CCMetadataNet *)metadataNet
 {
-    OCnetworking *operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:activeUser withPassword:activePassword withUrl:activeUrl];
+    OCnetworking *operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:activeUser withUserID:activeUserID withPassword:activePassword withUrl:activeUrl];
         
     _networkingOperationQueue.maxConcurrentOperationCount = k_maxConcurrentOperation;
     [_networkingOperationQueue addOperation:operation];

+ 2 - 0
iOSClient/Networking/CCNetworking.m

@@ -36,6 +36,7 @@
     NSString *_activeAccount;
     NSString *_activePassword;
     NSString *_activeUser;
+    NSString *_activeUserID;
     NSString *_activeUrl;
     NSString *_directoryUser;
 }
@@ -84,6 +85,7 @@
     _activeAccount = tableAccount.account;
     _activePassword = tableAccount.password;
     _activeUser = tableAccount.user;
+    _activeUserID = tableAccount.userID;
     _activeUrl = tableAccount.url;
     _directoryUser = [CCUtility getDirectoryActiveUser:_activeUser activeUrl:_activeUrl];
 }

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -34,7 +34,7 @@
 
 @interface OCnetworking : NSOperation <CCNetworkingDelegate>
 
-- (id)initWithDelegate:(id <OCNetworkingDelegate>)delegate metadataNet:(CCMetadataNet *)metadataNet withUser:(NSString *)withUser withPassword:(NSString *)withPassword withUrl:(NSString *)withUrl;
+- (id)initWithDelegate:(id <OCNetworkingDelegate>)delegate metadataNet:(CCMetadataNet *)metadataNet withUser:(NSString *)withUser withUserID:(NSString *)withUserID withPassword:(NSString *)withPassword withUrl:(NSString *)withUrl;
 
 @property (nonatomic, weak) id <OCNetworkingDelegate> delegate;
 

+ 3 - 1
iOSClient/Networking/OCNetworking.m

@@ -34,6 +34,7 @@
 @interface OCnetworking ()
 {
     NSString *_activeUser;
+    NSString *_activeUserID;
     NSString *_activePassword;
     NSString *_activeUrl;
     
@@ -44,7 +45,7 @@
 
 @implementation OCnetworking
 
-- (id)initWithDelegate:(id <OCNetworkingDelegate>)delegate metadataNet:(CCMetadataNet *)metadataNet withUser:(NSString *)withUser withPassword:(NSString *)withPassword withUrl:(NSString *)withUrl
+- (id)initWithDelegate:(id <OCNetworkingDelegate>)delegate metadataNet:(CCMetadataNet *)metadataNet withUser:(NSString *)withUser withUserID:(NSString *)withUserID withPassword:(NSString *)withPassword withUrl:(NSString *)withUrl
 {
     self = [super init];
     
@@ -56,6 +57,7 @@
         _metadataNet = [metadataNet copy];
         
         _activeUser = withUser;
+        _activeUserID = withUserID;
         _activePassword = withPassword;
         _activeUrl = withUrl;        
     }

+ 2 - 2
iOSClient/Settings/CCManageAccount.m

@@ -267,7 +267,7 @@
     [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:account];
     
     // Clear active user
-    [app settingActiveAccount:nil activeUrl:nil activeUser:nil activePassword:nil];
+    [app settingActiveAccount:nil activeUrl:nil activeUser:nil activeUserID:nil activePassword:nil];
 }
 
 - (void)answerDelAccount:(XLFormRowDescriptor *)sender
@@ -306,7 +306,7 @@
     // change account
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
     if (tableAccount)
-        [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activePassword:tableAccount.password];
+        [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
  
     // Init home
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];