|
@@ -253,62 +253,65 @@
|
|
|
|
|
|
- (void)loginCloud
|
|
|
{
|
|
|
- self.login.enabled = NO;
|
|
|
- self.loadingBaseUrl.hidden = NO;
|
|
|
-
|
|
|
// remove last char if /
|
|
|
if ([[self.baseUrl.text substringFromIndex:[self.baseUrl.text length] - 1] isEqualToString:@"/"])
|
|
|
self.baseUrl.text = [self.baseUrl.text substringToIndex:[self.baseUrl.text length] - 1];
|
|
|
|
|
|
NSError *error = [[NCNetworkingSync sharedManager] checkServer:[NSString stringWithFormat:@"%@%@", self.baseUrl.text, webDAV] user:self.user.text userID:self.user.text password:self.password.text];
|
|
|
|
|
|
- if (!error) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ self.login.enabled = NO;
|
|
|
+ self.loadingBaseUrl.hidden = NO;
|
|
|
+
|
|
|
+ if (!error) {
|
|
|
|
|
|
- // account
|
|
|
- NSString *account = [NSString stringWithFormat:@"%@ %@", self.user.text, self.baseUrl.text];
|
|
|
+ // account
|
|
|
+ NSString *account = [NSString stringWithFormat:@"%@ %@", self.user.text, self.baseUrl.text];
|
|
|
|
|
|
- if (_loginType == loginModifyPasswordUser) {
|
|
|
+ if (_loginType == loginModifyPasswordUser) {
|
|
|
|
|
|
- // Change Password
|
|
|
- tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountPassword:account password:self.password.text];
|
|
|
+ // 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 App active account
|
|
|
+ [app settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activeUserID:tbAccount.userID activePassword:tbAccount.password];
|
|
|
|
|
|
- // Dismiss
|
|
|
- if ([self.delegate respondsToSelector:@selector(loginSuccess:)])
|
|
|
- [self.delegate loginSuccess:_loginType];
|
|
|
+ // Dismiss
|
|
|
+ if ([self.delegate respondsToSelector:@selector(loginSuccess:)])
|
|
|
+ [self.delegate loginSuccess:_loginType];
|
|
|
|
|
|
- [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- [[NCManageDatabase sharedInstance] deleteAccount:account];
|
|
|
- [[NCManageDatabase sharedInstance] addAccount:account url:self.baseUrl.text user:self.user.text password:self.password.text];
|
|
|
+ [[NCManageDatabase sharedInstance] deleteAccount:account];
|
|
|
+ [[NCManageDatabase sharedInstance] addAccount:account url:self.baseUrl.text user:self.user.text password:self.password.text];
|
|
|
|
|
|
- // 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]];
|
|
|
- }
|
|
|
+ // 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]];
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- if ([error code] != NSURLErrorServerCertificateUntrusted) {
|
|
|
+ if ([error code] != NSURLErrorServerCertificateUntrusted) {
|
|
|
|
|
|
- NSString *description = [error.userInfo objectForKey:@"NSLocalizedDescription"];
|
|
|
- NSString *message = [NSString stringWithFormat:@"%@.\n%@", NSLocalizedStringFromTable(@"_not_possible_connect_to_server_", @"Error", nil), description];
|
|
|
+ NSString *description = [error.userInfo objectForKey:@"NSLocalizedDescription"];
|
|
|
+ NSString *message = [NSString stringWithFormat:@"%@.\n%@", NSLocalizedStringFromTable(@"_not_possible_connect_to_server_", @"Error", nil), description];
|
|
|
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
|
|
|
+ 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];
|
|
|
+ [alertController addAction:okAction];
|
|
|
+ [self presentViewController:alertController animated:YES completion:nil];
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- self.login.enabled = YES;
|
|
|
- self.loadingBaseUrl.hidden = YES;
|
|
|
+ self.login.enabled = YES;
|
|
|
+ self.loadingBaseUrl.hidden = YES;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
@@ -410,8 +413,12 @@
|
|
|
|
|
|
- (IBAction)handleButtonLogin:(id)sender
|
|
|
{
|
|
|
- if ([self.baseUrl.text length] > 0 && [self.user.text length] && [self.password.text length])
|
|
|
- [self performSelector:@selector(loginCloud) withObject:nil];
|
|
|
+ if ([self.baseUrl.text length] > 0 && [self.user.text length] && [self.password.text length]) {
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
|
+ [self performSelector:@selector(loginCloud) withObject:nil];
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (IBAction)handleAnnulla:(id)sender
|