Browse Source

new parse

marinofaggiana 5 years ago
parent
commit
fc2e640b9c

+ 8 - 0
iOSClient/Library/OCCommunicationLib/NCComments.h

@@ -24,6 +24,14 @@
 
 @interface NCComments : NSObject
 
+@property double messageID;
+@property (nonatomic, strong) NSString *verb;
+@property (nonatomic, strong) NSString *actorType;
+@property (nonatomic, strong) NSString *actorId;
+@property (nonatomic, strong) NSDate *creationDateTime;
+@property (nonatomic, strong) NSString *objectType;
+@property double objectId;
+@property (nonatomic, strong) NSString *actorDisplayName;
 @property BOOL isUnread;
 @property (nonatomic, strong) NSString *message;
 

+ 6 - 0
iOSClient/Library/OCCommunicationLib/NCComments.m

@@ -28,6 +28,12 @@
 {
     self = [super init];
     
+    self.verb = @"";
+    self.actorType = @"";
+    self.actorId = @"";
+    self.creationDateTime = [NSDate date];
+    self.objectType = @"";
+    self.actorDisplayName = @"";
     self.message = @"";
     
     return self;

+ 0 - 9
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -1497,24 +1497,15 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                           "<d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
                           "<d:prop>"
                           "<oc:id/>"
-                          "<oc:parentId/>"
-                          "<oc:topmostParentId/>"
-                          "<oc:childrenCount/>"
                           "<oc:verb/>"
                           "<oc:actorType/>"
                           "<oc:actorId/>"
                           "<oc:creationDateTime/>"
-                          "<oc:latestChildDateTime/>"
                           "<oc:objectType/>"
                           "<oc:objectId/>"
                           "<oc:isUnread/>"
                           "<oc:message/>"
                           "<oc:actorDisplayName/>"
-                          "<oc:mentions/>"
-                          "<oc:mention/>"
-                          "<oc:mentionType/>"
-                          "<oc:mentionId/>"
-                          "<oc:mentionDisplayName/>"
                           "</d:prop>"
                           "</d:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];

+ 5 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/NCXMLCommentsParser.h

@@ -26,8 +26,11 @@
 
 @interface NCXMLCommentsParser : NSObject <NSXMLParserDelegate>
 
-@property(nonatomic,strong) NSMutableArray *list;
-@property(nonatomic,strong) NCComments *currentComment;
+@property (nonatomic, strong) NSMutableArray *list;
+@property (nonatomic, strong) NCComments *currentComment;
+
+@property (nonatomic, strong) NSMutableString *xmlChars;
+@property (nonatomic, strong) NSString *status;
 
 - (void)initParserWithData: (NSData*)data;
 

+ 45 - 7
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/NCXMLCommentsParser.m

@@ -23,12 +23,6 @@
 
 #import "NCXMLCommentsParser.h"
 
-@interface NCXMLCommentsParser()
-
-@property (nonatomic, strong) NSMutableString *xmlChars;
-
-@end
-
 @implementation NCXMLCommentsParser
 
 - (void)initParserWithData: (NSData*)data{
@@ -60,13 +54,57 @@
             self.currentComment = [NCComments new];
         }
         
+    } else if ([elementName isEqualToString:@"oc:id"]) {
+        
+        self.currentComment.messageID = [self.xmlChars doubleValue];
+    
+    } else if ([elementName isEqualToString:@"oc:verb"]) {
+        
+        self.currentComment.verb = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"oc:actorType"]) {
+        
+        self.currentComment.actorType = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"oc:actorId"]) {
+        
+        self.currentComment.actorId = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"oc:creationDateTime"]) {
+        
+        NSDateFormatter *dateFormatter = [NSDateFormatter new];
+        [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
+        self.currentComment.creationDateTime = [dateFormatter dateFromString:[NSString stringWithString:self.xmlChars] ];
+        
+    } else if ([elementName isEqualToString:@"oc:objectType"]) {
+        
+        self.currentComment.objectType = [NSString stringWithString:self.xmlChars];
+    
+    } else if ([elementName isEqualToString:@"oc:objectId"]) {
+        
+        self.currentComment.objectId = [self.xmlChars doubleValue];
+        
+    } else if ([elementName isEqualToString:@"oc:isUnread"]) {
+        
+        self.currentComment.isUnread = [self.xmlChars boolValue];
+        
     } else if ([elementName isEqualToString:@"oc:message"]) {
         
         self.currentComment.message = [NSString stringWithString:self.xmlChars];
+    
+    } else if ([elementName isEqualToString:@"oc:actorDisplayName"]) {
+        
+        self.currentComment.actorDisplayName = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"d:status"]) {
+        
+        self.status = [NSString stringWithString:self.xmlChars];
         
     } else if ([elementName isEqualToString:@"d:response"]) {
     
-        [self.list addObject:self.currentComment];
+        if ([self.status containsString:@"200"]) {
+            [self.list addObject:self.currentComment];
+        }
     }
 }