Marino Faggiana 8 жил өмнө
parent
commit
8cc1ada5d0

+ 36 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCActivity.h

@@ -0,0 +1,36 @@
+//
+//  OCActivity.h
+//  ownCloud iOS library
+//
+//  Created by Marino Faggiana on 01/03/17.
+//  Copyright © 2017 TWS. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface OCActivity : NSObject
+
+@property NSInteger idActivity;
+@property (nonatomic, strong) NSDate *date;
+@property (nonatomic, strong) NSString *file;
+@property (nonatomic, strong) NSString *link;
+@property (nonatomic, strong) NSString *message;
+@property (nonatomic, strong) NSString *subject;
+
+@end
+

+ 28 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCActivity.m

@@ -0,0 +1,28 @@
+//
+//  OCActivity.m
+//  ownCloud iOS library
+//
+//  Created by Marino Faggiana on 01/03/17.
+//  Copyright © 2017 TWS. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import "OCActivity.h"
+
+@implementation OCActivity
+
+@end

+ 48 - 3
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -44,6 +44,7 @@
 #import "OCErrorMsg.h"
 #import "AFURLSessionManager.h"
 #import "OCShareUser.h"
+#import "OCActivity.h"
 #import "OCCapabilities.h"
 #import "OCNotifications.h"
 #import "OCNotificationsAction.h"
@@ -1509,7 +1510,7 @@
 - (void) getActivityServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *listOfActivity, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
 
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
-    serverPath = [serverPath stringByAppendingString:k_url_acces_remote_notification_api];
+    serverPath = [serverPath stringByAppendingString:k_url_acces_remote_activity_api];
     
     OCWebDAVClient *request = [OCWebDAVClient new];
     request = [self getRequestWithCredentials:request];
@@ -1521,9 +1522,53 @@
         //Parse
         NSError *error;
         NSDictionary *jsongParsed = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
-        NSLog(@"[LOG] Notifications : %@",jsongParsed);
+        NSLog(@"[LOG] Activity : %@",jsongParsed);
         
-        NSMutableArray *listOfNotifications = [NSMutableArray new];
+        NSMutableArray *listOfActivity = [NSMutableArray new];
+        
+        if (jsongParsed.allKeys > 0) {
+            
+            NSDictionary *ocs = [jsongParsed valueForKey:@"ocs"];
+            NSDictionary *meta = [ocs valueForKey:@"meta"];
+            NSDictionary *datas = [ocs valueForKey:@"data"];
+            
+            NSInteger statusCode = [[meta valueForKey:@"statuscode"] integerValue];
+
+            if (statusCode == kOCNotificationAPINoContent || statusCode == kOCNotificationAPISuccessful) {
+                
+                for (NSDictionary *data in datas) {
+                    
+                    OCActivity *activity = [OCActivity new];
+                    
+                    activity.idActivity = [[data valueForKey:@"id"] integerValue];
+                    
+                    NSString *dateString = [data valueForKey:@"date"];
+                    NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init];
+                    activity.date = [formatter dateFromString:dateString];
+
+                    activity.file = [data valueForKey:@"file"];
+                    activity.link = [data valueForKey:@"link"];
+                    activity.message = [data valueForKey:@"message"];
+                    activity.subject = [data valueForKey:@"subject"];
+                    
+                    [listOfActivity addObject:activity];
+                }
+                
+            } else {
+                
+                NSString *message = (NSString*)[meta objectForKey:@"message"];
+                
+                if ([message isKindOfClass:[NSNull class]]) {
+                    message = @"";
+                }
+                
+                NSError *error = [UtilsFramework getErrorWithCode:statusCode andCustomMessageFromTheServer:message];
+                failureRequest(response, error, request.redirectedServer);
+            }
+        }
+
+        //Return success
+        successRequest(response, listOfActivity, request.redirectedServer);
 
     } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
         failureRequest(response, error, request.redirectedServer);

+ 3 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCFrameworkConstants.h

@@ -56,6 +56,9 @@
 //Url to access to Remote Notification API
 #define k_url_acces_remote_notification_api @"ocs/v2.php/apps/notifications/api/v2/notifications"
 
+//Url to access to Remote Activity API
+#define k_url_acces_remote_activity_api @"ocs/v2.php/cloud/activity"
+
 //Url to access to User Profile API
 #define k_url_acces_remote_userprofile_api @"ocs/v1.php/cloud/users/"
 

+ 6 - 0
Libraries external/OCCommunicationLib/ownCloud iOS library.xcodeproj/project.pbxproj

@@ -53,6 +53,7 @@
 		F704980F1E369EF6008F5BB6 /* OCRichObjectStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = F704980C1E369EF6008F5BB6 /* OCRichObjectStrings.m */; };
 		F73C00351E56098300EEEFA7 /* OCUserProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = F73C00341E56098300EEEFA7 /* OCUserProfile.m */; };
 		F785C1341E6316A500469BAC /* OCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F785C1331E6316A500469BAC /* OCXMLListParser.m */; };
+		F7FB5F171E66E63B00389481 /* OCActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = F7FB5F161E66E63B00389481 /* OCActivity.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -150,6 +151,8 @@
 		F73C00341E56098300EEEFA7 /* OCUserProfile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCUserProfile.m; sourceTree = "<group>"; };
 		F785C1321E6316A500469BAC /* OCXMLListParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OCXMLListParser.h; path = OCWebDavClient/Parsers/OCXMLListParser.h; sourceTree = "<group>"; };
 		F785C1331E6316A500469BAC /* OCXMLListParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OCXMLListParser.m; path = OCWebDavClient/Parsers/OCXMLListParser.m; sourceTree = "<group>"; };
+		F7FB5F151E66E63B00389481 /* OCActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCActivity.h; sourceTree = "<group>"; };
+		F7FB5F161E66E63B00389481 /* OCActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCActivity.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -226,6 +229,8 @@
 		EA7CC89C183E11E600B6A4B4 /* OCCommunicationLib */ = {
 			isa = PBXGroup;
 			children = (
+				F7FB5F151E66E63B00389481 /* OCActivity.h */,
+				F7FB5F161E66E63B00389481 /* OCActivity.m */,
 				EAABAA30183E688900909831 /* OCFileDto.h */,
 				EAABAA31183E688900909831 /* OCFileDto.m */,
 				EA0599981BB96D14002C2864 /* OCShareUser.h */,
@@ -447,6 +452,7 @@
 				59A5B71F191907F100724BE3 /* AFNetworkReachabilityManager.m in Sources */,
 				EA7CC92E183E14A100B6A4B4 /* OCWebDAVClient.m in Sources */,
 				EAABAB1E1858594A00909831 /* OCChunkDto.m in Sources */,
+				F7FB5F171E66E63B00389481 /* OCActivity.m in Sources */,
 				EA73DC831B1C48EA00C3AC21 /* OCXMLServerErrorsParser.m in Sources */,
 				F785C1341E6316A500469BAC /* OCXMLListParser.m in Sources */,
 				1345E4601884213400153F14 /* OCXMLShareByLinkParser.m in Sources */,

+ 3 - 0
iOSClient/Main/CCMain.m

@@ -1166,6 +1166,9 @@
 
     metadataNet.action = actionGetUserProfile;
     [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+    
+    metadataNet.action = actionGetActivityServer;
+    [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
 }
 
 #pragma --------------------------------------------------------------------------------------------