marinofaggiana 5 年之前
父节点
当前提交
a04f623188

+ 14 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -538,6 +538,10 @@
 		F7D4B69A2295666E000C2C86 /* FirebaseMLCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7D4B6932295666E000C2C86 /* FirebaseMLCommon.framework */; };
 		F7D4B69B2295666E000C2C86 /* GoogleMobileVision.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7D4B6942295666E000C2C86 /* GoogleMobileVision.framework */; };
 		F7D6650720FF341600BFBA9E /* NCMainCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7D6650620FF341600BFBA9E /* NCMainCommon.swift */; };
+		F7DBC37C23325E02001A85BA /* NCAppConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7DBC37B23325E01001A85BA /* NCAppConfigView.swift */; };
+		F7DBC37F23325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DBC37E23325E2E001A85BA /* NCXMLGetAppPasswordParser.m */; };
+		F7DBC38023325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DBC37E23325E2E001A85BA /* NCXMLGetAppPasswordParser.m */; };
+		F7DBC38123325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DBC37E23325E2E001A85BA /* NCXMLGetAppPasswordParser.m */; };
 		F7DFAA8A22E22EF100FC4527 /* NCShareLinkMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7DFAA8922E22EF100FC4527 /* NCShareLinkMenuView.xib */; };
 		F7DFB7E0219C312D00680748 /* NCRichDocumentTemplate.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DFB7DF219C312D00680748 /* NCRichDocumentTemplate.m */; };
 		F7DFB7E1219C312D00680748 /* NCRichDocumentTemplate.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DFB7DF219C312D00680748 /* NCRichDocumentTemplate.m */; };
@@ -1314,6 +1318,9 @@
 		F7D5328F1F5D443B006568B1 /* en-GB */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "en-GB"; path = "en-GB.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F7D532A41F5D4461006568B1 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F7D6650620FF341600BFBA9E /* NCMainCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainCommon.swift; sourceTree = "<group>"; };
+		F7DBC37B23325E01001A85BA /* NCAppConfigView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCAppConfigView.swift; sourceTree = "<group>"; };
+		F7DBC37D23325E2D001A85BA /* NCXMLGetAppPasswordParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCXMLGetAppPasswordParser.h; sourceTree = "<group>"; };
+		F7DBC37E23325E2E001A85BA /* NCXMLGetAppPasswordParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCXMLGetAppPasswordParser.m; sourceTree = "<group>"; };
 		F7DE9AB01F482FA5008DFE10 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F7DFAA8922E22EF100FC4527 /* NCShareLinkMenuView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareLinkMenuView.xib; sourceTree = "<group>"; };
 		F7DFB7DE219C312D00680748 /* NCRichDocumentTemplate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCRichDocumentTemplate.h; sourceTree = "<group>"; };
@@ -1542,6 +1549,8 @@
 		F70022871EC4C9100080073F /* Parsers */ = {
 			isa = PBXGroup;
 			children = (
+				F7DBC37D23325E2D001A85BA /* NCXMLGetAppPasswordParser.h */,
+				F7DBC37E23325E2E001A85BA /* NCXMLGetAppPasswordParser.m */,
 				F7B6ACD522FC2BD4008AB646 /* NCXMLCommentsParser.h */,
 				F7B6ACD422FC2BD3008AB646 /* NCXMLCommentsParser.m */,
 				F7D2D125230804DF00FD3ED7 /* NCXMLListParser.h */,
@@ -2394,6 +2403,7 @@
 				F75ADF441DC75FFE008A7347 /* CCLogin.storyboard */,
 				F7BF1B3F1D51E893000854F6 /* CCLogin.h */,
 				F7BF1B401D51E893000854F6 /* CCLogin.m */,
+				F7DBC37B23325E01001A85BA /* NCAppConfigView.swift */,
 				F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */,
 				F745B252222D88AE00346520 /* NCLoginQRCode.swift */,
 			);
@@ -3347,6 +3357,7 @@
 				F70022FC1EC4C9100080073F /* NSString+Encode.m in Sources */,
 				F7F878AF1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */,
 				F71459C91D12E3B700CAFEEC /* OCNetworking.m in Sources */,
+				F7DBC38023325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */,
 				F71459CD1D12E3B700CAFEEC /* AFViewShaker.m in Sources */,
 				F7D2D128230804E000FD3ED7 /* NCXMLListParser.m in Sources */,
 				F74E432720B5547700C2E54C /* NCNetworkingEndToEnd.m in Sources */,
@@ -3419,6 +3430,7 @@
 				F7434B3D20E2404300417916 /* OCExternalSites.m in Sources */,
 				F7D2D129230804E000FD3ED7 /* NCXMLListParser.m in Sources */,
 				F7434B4420E2405C00417916 /* OCUserProfile.m in Sources */,
+				F7DBC38123325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */,
 				F7434B5E20E241EC00417916 /* CCGraphics.m in Sources */,
 				F771E3D320E2392D00AFB62D /* FileProviderExtension.swift in Sources */,
 				F7434B5B20E241D100417916 /* NCEndToEndMetadata.swift in Sources */,
@@ -3599,6 +3611,7 @@
 				F78F74362163781100C2ADAD /* NCTrash.swift in Sources */,
 				F7417DB3216CE925007D05F5 /* NCTrashSectionHeaderFooter.swift in Sources */,
 				F7F878AE1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */,
+				F7DBC37C23325E02001A85BA /* NCAppConfigView.swift in Sources */,
 				F762CB141EACB66200B38484 /* XLFormRightImageButton.m in Sources */,
 				F73D71621F2673C200E233EB /* NCText.swift in Sources */,
 				F73B4EF81F470D9100BBEE4B /* LangDanishModel.cpp in Sources */,
@@ -3611,6 +3624,7 @@
 				F754EECC21772B6100BB1CDF /* SectionHeader.swift in Sources */,
 				F7B174C822FAC0A8000B7579 /* AppDelegate.m in Sources */,
 				F73CC0751E813DFF006E3047 /* BKPasscodeViewController.m in Sources */,
+				F7DBC37F23325E2E001A85BA /* NCXMLGetAppPasswordParser.m in Sources */,
 				F750374D1DBFA91A008FB480 /* ALView+PureLayout.m in Sources */,
 				F7381EE1218218C9000B1560 /* NCOffline.swift in Sources */,
 				F7D423861F0596C6009C9782 /* ReaderThumbRequest.m in Sources */,

+ 2 - 0
iOSClient/AppDelegate.h

@@ -40,6 +40,7 @@
 @class CCMore;
 @class NCMedia;
 @class NCOffline;
+@class NCAppConfigView;
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate, BKPasscodeLockScreenManagerDelegate, BKPasscodeViewControllerDelegate, TWMessageBarStyleSheet, CCNetworkingDelegate, PKPushRegistryDelegate>
 
@@ -120,6 +121,7 @@
 @property (nonatomic, retain) NCLoginWeb *activeLoginWeb;
 @property (nonatomic, retain) CCMore *activeMore;
 @property (nonatomic, retain) NCOffline *activeOffline;
+@property (nonatomic, retain) NCAppConfigView *appConfigView;
 
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;

+ 21 - 16
iOSClient/AppDelegate.m

@@ -36,7 +36,7 @@
 
 @class NCViewerRichdocument;
 
-@interface AppDelegate () <UNUserNotificationCenterDelegate, CCLoginDelegate, NCLoginWebDelegate>
+@interface AppDelegate () <UNUserNotificationCenterDelegate, CCLoginDelegate, NCLoginWebDelegate, NCAppConfigViewDelegate>
 {
 PKPushRegistry *pushRegistry;
 }
@@ -287,22 +287,20 @@ PKPushRegistry *pushRegistry;
         // use appConfig [MDM]
         if ([NCBrandOptions sharedInstance].use_configuration) {
             
-            NSDictionary *serverConfig = [[NSUserDefaults standardUserDefaults] dictionaryForKey:NCBrandConfiguration.sharedInstance.configuration_key];
+            if (!(_appConfigView.isViewLoaded && _appConfigView.view.window)) {
             
-            NSString *serverUrl = serverConfig[NCBrandConfiguration.sharedInstance.configuration_serverUrl];
-            NSString *username = serverConfig[NCBrandConfiguration.sharedInstance.configuration_username];
-            NSString *password = serverConfig[NCBrandConfiguration.sharedInstance.configuration_password];
+                self.appConfigView = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCAppConfigView"];
             
-            if (serverUrl && [serverUrl isKindOfClass:[NSString class]] && username && [username isKindOfClass:[NSString class]] && password && [password isKindOfClass:[NSString class]]) {
-            
-            } else {
-                [self messageNotification:@"MDM" description:@"Parameter XML error" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
+                self.appConfigView.delegate = delegate;
+                
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                    [viewController presentViewController:self.appConfigView animated:YES completion:nil];
+                });
             }
-            
+        
             return;
         }
         
-        
         // only for personalized LoginWeb [customer]
         if ([NCBrandOptions sharedInstance].use_login_web_personalized) {
             
@@ -314,8 +312,11 @@ PKPushRegistry *pushRegistry;
                 self.activeLoginWeb.loginType = loginType;
                 self.activeLoginWeb.delegate = delegate;
 
-                [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                    [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+                });
             }
+            
             return;
         }
         
@@ -343,7 +344,9 @@ PKPushRegistry *pushRegistry;
                 self.activeLoginWeb.loginType = loginType;
                 self.activeLoginWeb.delegate = delegate;
                 
-                [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                    [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+                });
             }
             
         } else if ([NCBrandOptions sharedInstance].disable_intro && [NCBrandOptions sharedInstance].disable_request_login_url) {
@@ -354,7 +357,9 @@ PKPushRegistry *pushRegistry;
             self.activeLoginWeb.loginType = loginType;
             self.activeLoginWeb.delegate = delegate;
             
-            [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+            });
             
         } else {
             
@@ -364,7 +369,7 @@ PKPushRegistry *pushRegistry;
                 _activeLogin.delegate = delegate;
                 _activeLogin.loginType = loginType;
                 
-                dispatch_async(dispatch_get_main_queue(), ^ {
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                     [viewController presentViewController:_activeLogin animated:YES completion:nil];
                 });
             }
@@ -376,7 +381,7 @@ PKPushRegistry *pushRegistry;
 {
     //
 }
-- (void)webDismiss
+- (void)loginWebDismiss
 {
     [self startTimerErrorNetworking];
 }

+ 1 - 1
iOSClient/Brand/File_Provider_Extension.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.24.0</string>
 	<key>CFBundleVersion</key>
-	<string>20</string>
+	<string>99</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 2 - 2
iOSClient/Brand/NCBrand.swift

@@ -120,9 +120,9 @@ class NCBrandColor: NSObject {
     @objc public let use_middlewarePing:                Bool = false
     @objc public let use_storeLocalAutoUploadAll:       Bool = false
     @objc public let use_imi_viewer:                    Bool = false                                                // Don't touch me !!
-    @objc public let use_configuration:                 Bool = false                                                // Don't touch me !!
+    @objc public let use_configuration:                 Bool = true                                                // Don't touch me !!
 
-    @objc public let disable_intro:                     Bool = false
+    @objc public let disable_intro:                     Bool = true
     @objc public let disable_request_login_url:         Bool = false
     @objc public let disable_multiaccount:              Bool = false
     @objc public let disable_manage_account:            Bool = false

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.24.0</string>
 	<key>CFBundleVersion</key>
-	<string>20</string>
+	<string>99</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -63,7 +63,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>20</string>
+	<string>99</string>
 	<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
 	<true/>
 	<key>Fabric</key>

+ 1 - 1
iOSClient/Login/CCLogin.m

@@ -309,7 +309,7 @@
     [self.delegate loginSuccess:_loginType];
 }
 
-- (void)webDismiss
+- (void)loginWebDismiss
 {   
     [self dismissViewControllerAnimated:YES completion:nil];
 }

+ 28 - 0
iOSClient/Login/CCLogin.storyboard

@@ -226,12 +226,40 @@
             </objects>
             <point key="canvasLocation" x="4511.594202898551" y="-1210.0446428571429"/>
         </scene>
+        <!--App Config View-->
+        <scene sceneID="BeF-ke-GzC">
+            <objects>
+                <viewController storyboardIdentifier="NCAppConfigView" id="Ak5-da-5qm" customClass="NCAppConfigView" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="lrn-aT-NFz">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="uEr-qx-rv2">
+                                <rect key="frame" x="95.666666666666686" y="374.33333333333331" width="223" height="157.33333333333331"/>
+                            </imageView>
+                        </subviews>
+                        <color key="backgroundColor" red="0.0" green="0.50935935970000001" blue="0.78929150100000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <constraints>
+                            <constraint firstItem="uEr-qx-rv2" firstAttribute="centerX" secondItem="x9O-1Y-Id9" secondAttribute="centerX" id="aL5-QX-ULn"/>
+                            <constraint firstItem="uEr-qx-rv2" firstAttribute="centerY" secondItem="x9O-1Y-Id9" secondAttribute="centerY" id="rrc-Gc-BmU"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="x9O-1Y-Id9"/>
+                    </view>
+                    <connections>
+                        <outlet property="logoImage" destination="uEr-qx-rv2" id="g4x-Pf-mpw"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="JhO-p5-bOq" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="5477" y="-1214"/>
+        </scene>
     </scenes>
     <resources>
         <image name="exit" width="300" height="300"/>
         <image name="loginPassword" width="25" height="25"/>
         <image name="loginURL" width="25" height="25"/>
         <image name="loginUser" width="25" height="25"/>
+        <image name="logo" width="223" height="157.5"/>
         <image name="qrcode" width="300" height="300"/>
         <image name="visiblePassword" width="25" height="25"/>
     </resources>

+ 4 - 4
iOSClient/Login/NCLoginWeb.swift

@@ -25,7 +25,7 @@ import Foundation
 
 @objc protocol NCLoginWebDelegate: class {
     func loginSuccess(_: NSInteger)
-    @objc optional func webDismiss()
+    @objc optional func loginWebDismiss()
 }
 
 class NCLoginWeb: UIViewController {
@@ -83,7 +83,7 @@ class NCLoginWeb: UIViewController {
     
     @IBAction func touchUpInsideButtonExit(_ sender: UIButton) {
         self.dismiss(animated: true) {
-            self.delegate?.webDismiss?()
+            self.delegate?.loginWebDismiss?()
         }
     }
 }
@@ -138,7 +138,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                         
                         self.dismiss(animated: true) {
                             self.delegate?.loginSuccess(NSInteger(self.loginType))
-                            self.delegate?.webDismiss?()
+                            self.delegate?.loginWebDismiss?()
                         }
                     }
                     
@@ -165,7 +165,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                         
                         self.dismiss(animated: true) {
                             self.delegate?.loginSuccess(NSInteger(self.loginType))
-                            self.delegate?.webDismiss?()
+                            self.delegate?.loginWebDismiss?()
                         }
                     }
                 }

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -36,7 +36,7 @@
 #import "NCNetworkingEndToEnd.h"
 #import "PKDownloadButton.h"
 
-@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, NCLoginWebDelegate, NCSelectDelegate, UITextFieldDelegate>
+@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, NCLoginWebDelegate, NCAppConfigViewDelegate, NCSelectDelegate, UITextFieldDelegate>
 {
     AppDelegate *appDelegate;
         

+ 1 - 1
iOSClient/Main/CCMore.swift

@@ -24,7 +24,7 @@
 
 import UIKit
 
-class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLoginDelegate, NCLoginWebDelegate {
+class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLoginDelegate, NCLoginWebDelegate, NCAppConfigViewDelegate {
 
     @IBOutlet weak var themingBackground: UIImageView!
     @IBOutlet weak var disclosureIndicator: UIImageView!

+ 1 - 1
iOSClient/Main/CCSplit.m

@@ -27,7 +27,7 @@
 #import "NCAutoUpload.h"
 #import "NCBridgeSwift.h"
 
-@interface CCSplit () <CCLoginDelegate, NCLoginWebDelegate>
+@interface CCSplit () <CCLoginDelegate, NCLoginWebDelegate, NCAppConfigViewDelegate>
 {
     AppDelegate *appDelegate;
     BOOL prevRunningInFullScreen;

+ 5 - 0
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -662,6 +662,11 @@ class NCCreateScanDocument : NSObject, ImageScannerControllerDelegate {
         
         let scannerVC = ImageScannerController()
         scannerVC.imageScannerDelegate = self
+        scannerVC.navigationBar.isTranslucent = false
+        scannerVC.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
+        scannerVC.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
+        scannerVC.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
+        
         self.viewController?.present(scannerVC, animated: true, completion: nil)
     }
     

+ 1 - 0
iOSClient/Networking/OCNetworking.h

@@ -41,6 +41,7 @@
 - (void)checkServerUrl:(NSString *)serverUrl user:(NSString *)user userID:(NSString *)userID password:(NSString *)password completion:(void (^)(NSString *message, NSInteger errorCode))completion;
 - (void)serverStatusUrl:(NSString *)serverUrl completion:(void(^)(NSString *serverProductName, NSInteger versionMajor, NSInteger versionMicro, NSInteger versionMinor, BOOL extendedSupport, NSString *message, NSInteger errorCode))completion;
 - (void)downloadContentsOfUrl:(NSString *)serverUrl completion:(void(^)(NSData *data, NSString *message, NSInteger errorCode))completion;
+- (void)getAppPassword:(NSString *)serverUrl username:(NSString *)username password:(NSString *)password completion:(void(^)(NSString *token, NSString *message, NSInteger errorCode))completion;
 
 #pragma mark ===== Download / Upload =====
 

+ 52 - 0
iOSClient/Networking/OCNetworking.m

@@ -28,6 +28,7 @@
 #import "CCCertificate.h"
 #import "NSString+Encode.h"
 #import "NCBridgeSwift.h"
+#import "NCXMLGetAppPasswordParser.h"
 
 @implementation OCNetworking
 
@@ -319,6 +320,53 @@
     [task resume];
 }
 
+- (void)getAppPassword:(NSString *)serverUrl username:(NSString *)username password:(NSString *)password completion:(void(^)(NSString *token, NSString *message, NSInteger errorCode))completion
+{
+    NSData *authData = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding];
+    NSString *authValue = [NSString stringWithFormat: @"Basic %@",[authData base64EncodedStringWithOptions:0]];
+    NSString *URLString = [NSString stringWithFormat:@"%@/ocs/v2.php/core/getapppassword", serverUrl];
+    
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString] cachePolicy:0 timeoutInterval:20.0];
+    [request setValue:authValue forHTTPHeaderField:@"Authorization"];
+    [request addValue:[CCUtility getUserAgent] forHTTPHeaderField:@"User-Agent"];
+    [request addValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
+    
+    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
+    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
+    
+    NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
+        
+        if (error) {
+            
+            NSString *message;
+            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
+            NSInteger errorCode = httpResponse.statusCode;
+            
+            if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
+                errorCode = error.code;
+            
+            // Error
+            if (errorCode == 503)
+                message = NSLocalizedString(@"_server_error_retry_", nil);
+            else
+                message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
+            
+            completion(nil, message, errorCode);
+            
+        } else {
+            
+            NCXMLGetAppPasswordParser *parser = [NCXMLGetAppPasswordParser new];
+            [parser initParserWithData:data];
+            NSString *token = parser.token;
+            
+            completion(token, nil, 0);
+        }
+    }];
+    
+    [task resume];
+}
+
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== download / upload =====
 #pragma --------------------------------------------------------------------------------------------
@@ -2111,6 +2159,9 @@
 
 - (void)deletingServerNotification:(NSString *)serverUrl notificationId:(NSInteger)notificationId completion:(void(^)(NSString *message, NSInteger errorCode))completion
 {
+//    NSData *authData = [[NSString stringWithFormat:@"%@:%@", tableAccount.user, [CCUtility getPassword:tableAccount.account]] dataUsingEncoding:NSUTF8StringEncoding];
+//    NSString *authValue = [NSString stringWithFormat: @"Basic %@",[authData base64EncodedStringWithOptions:0]];
+
     // Delete
     NSString *URLString = [NSString stringWithFormat:@"%@/ocs/v2.php/apps/notifications/api/v2/notifications/%ld", serverUrl, (long)notificationId];
     
@@ -2120,6 +2171,7 @@
     }
     
     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString] cachePolicy:0 timeoutInterval:20.0];
+//    [request setValue:authValue forHTTPHeaderField:@"Authorization"];
     [request addValue:[CCUtility getUserAgent] forHTTPHeaderField:@"User-Agent"];
     [request addValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
     [request setHTTPMethod: @"DELETE"];

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -29,7 +29,7 @@
 
 #define actionSheetCancellaAccount 1
 
-@interface CCManageAccount () <CCLoginDelegate, NCLoginWebDelegate>
+@interface CCManageAccount () <CCLoginDelegate, NCLoginWebDelegate, NCAppConfigViewDelegate>
 {
     AppDelegate *appDelegate;
 }