marinofaggiana 5 жил өмнө
parent
commit
e45f27287e

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1656,6 +1656,7 @@
 				F7D6650620FF341600BFBA9E /* NCMainCommon.swift */,
 				F73F537E1E929C8500F8678D /* CCMore.swift */,
 				F77444F7222816D5000D5EB0 /* NCPhotosPickerViewController.swift */,
+				F7A582D61A24DAB500E903D7 /* AppDelegate.m */,
 			);
 			path = Main;
 			sourceTree = "<group>";
@@ -2925,7 +2926,6 @@
 				F7C1CDD91E6DFC6F005D92BE /* Brand */,
 				F70211F31BAC56E9003FC03E /* Main */,
 				F7A582D71A24DAB500E903D7 /* AppDelegate.h */,
-				F7A582D61A24DAB500E903D7 /* AppDelegate.m */,
 				F7C8C1901B482CEA0048180E /* CCGlobal.h */,
 				F7F67BB81A24D27800EE80DA /* Images.xcassets */,
 				F7A321621E9E37960069AD1B /* Activity */,

+ 8 - 5
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -3197,7 +3197,7 @@
 
 - (void)getComments:(NSString *)serverPath fileID:(NSString *)fileID onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
-    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@", serverPath, fileID];
+    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@?format=json", serverPath, fileID];
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
 
     OCWebDAVClient *request = [OCWebDAVClient new];
@@ -3205,11 +3205,14 @@
     
     [request getComments:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
         
-        OCXMLParser *parser = [OCXMLParser new];
-        [parser initParserWithData:responseObject];
-        NSMutableArray *list = [parser.directoryList mutableCopy];
+        NSData *responseData = (NSData*) response;
         
-        successRequest(response, list, request.redirectedServer);
+        //Parse
+        NSError *error;
+        NSDictionary *jsongParsed = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
+        NSLog(@"[LOG] URL Asset : %@",jsongParsed);
+
+        successRequest(response, nil, request.redirectedServer);
         
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error) {
         

+ 0 - 0
iOSClient/AppDelegate.m → iOSClient/Main/AppDelegate.m


+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -117,7 +117,7 @@
 
 #pragma mark ===== Comments =====
 
-- (void)getCommentsWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl fileID:(NSString *)fileID completion:(void (^)(NSString *account, NSArray *list, NSString *message, NSInteger errorCode))completion;
+- (void)getCommentsWithAccount:(NSString *)account fileID:(NSString *)fileID completion:(void (^)(NSString *account, NSArray *list, NSString *message, NSInteger errorCode))completion;
 
 #pragma mark ===== Third Parts =====
 

+ 2 - 2
iOSClient/Networking/OCNetworking.m

@@ -2709,7 +2709,7 @@
 #pragma mark ===== Comments =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)getCommentsWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl fileID:(NSString *)fileID completion:(void (^)(NSString *account, NSArray *list, NSString *message, NSInteger errorCode))completion
+- (void)getCommentsWithAccount:(NSString *)account fileID:(NSString *)fileID completion:(void (^)(NSString *account, NSArray *list, NSString *message, NSInteger errorCode))completion
 {
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
     if (tableAccount == nil) {
@@ -2725,7 +2725,7 @@
     [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
     [communication setUserAgent:[CCUtility getUserAgent]];
     
-    [communication getComments:tableAccount.url fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer) {
+    [communication getComments:[NSString stringWithFormat:@"%@%@", tableAccount.url, k_dav] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer) {
         
         completion(account, list, nil, 0);
 

+ 2 - 17
iOSClient/Share/NCShare.storyboard

@@ -44,25 +44,10 @@
             </objects>
             <point key="canvasLocation" x="334.78260869565219" y="-167.41071428571428"/>
         </scene>
-        <!--View Controller-->
-        <scene sceneID="tNH-9u-08n">
-            <objects>
-                <viewController storyboardIdentifier="activity" id="Q5S-G4-EEF" sceneMemberID="viewController">
-                    <view key="view" contentMode="scaleToFill" id="7uF-QZ-62w">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                        <viewLayoutGuide key="safeArea" id="USS-2P-JRO"/>
-                    </view>
-                </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="NcC-LH-u4T" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="335" y="528"/>
-        </scene>
-        <!--View Controller-->
+        <!--Share Comments-->
         <scene sceneID="R3f-Og-D1Y">
             <objects>
-                <viewController storyboardIdentifier="comments" id="GMr-2Y-4vs" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="comments" id="GMr-2Y-4vs" customClass="NCShareComments" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="5MM-pX-rNX">
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

+ 17 - 1
iOSClient/Share/NCShare.swift

@@ -89,7 +89,9 @@ extension NCShare: PagingViewControllerDataSource {
             viewController.filterFileID = metadata!.fileID
             return viewController
         case 1:
-            return UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "comments")
+            let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "comments") as! NCShareComments
+            viewController.metadata = metadata!
+            return viewController
         case 2:
             return UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "sharing")
         default:
@@ -206,3 +208,17 @@ class NCShareHeaderView: UIView {
     @IBOutlet weak var info: UILabel!
     @IBOutlet weak var favorite: UIButton!
 }
+
+class NCShareComments: UIViewController {
+    
+    var metadata: tableMetadata?
+    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        OCNetworking.sharedManager()?.getCommentsWithAccount(appDelegate.activeAccount, fileID: metadata?.fileID, completion: { (account, list, message, errorCode) in
+            print("ciao")
+        })
+    }
+}