Pārlūkot izejas kodu

OCNotifications

Marino Faggiana 8 gadi atpakaļ
vecāks
revīzija
d6abcedecc

+ 2 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.h

@@ -29,6 +29,7 @@
 @class AFURLSessionManager;
 @class AFSecurityPolicy;
 @class OCCapabilities;
+@class OCNotifications;
 
 
 @interface OCCommunication : NSObject
@@ -767,5 +768,5 @@ typedef enum {
 /// @name Get the server Notification
 ///-----------------------------------
 
-- (void) getNotificationsOfTheServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, OCCapabilities *capabilities, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
+- (void) getNotificationsOfTheServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, OCNotifications *notifications, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 @end

+ 7 - 4
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -37,6 +37,8 @@
 #import "AFURLSessionManager.h"
 #import "OCShareUser.h"
 #import "OCCapabilities.h"
+#import "OCNotifications.h"
+#import "OCXMLNotificationsParser.h"
 
 @interface OCCommunication ()
 
@@ -1284,7 +1286,7 @@
 
 #pragma mark - Get Notification Server
 
-- (void) getNotificationsOfTheServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, OCCapabilities *capabilities, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest{
+- (void) getNotificationsOfTheServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, OCNotifications *notifications, 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];
@@ -1292,15 +1294,16 @@
     OCWebDAVClient *request = [OCWebDAVClient new];
     request = [self getRequestWithCredentials:request];
     
-    
     [request getNotificationsOfTheServer:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
         
         NSData *responseData = (NSData*) responseObject;
-        OCXMLSharedParser *parser = [[OCXMLSharedParser alloc]init];
+        OCXMLNotificationsParser *parser = [[OCXMLNotificationsParser alloc] init];
             
         [parser initParserWithData:responseData];
+        NSMutableArray *notificationsList = [parser.notificationsList mutableCopy];
     
-        NSLog(@"parser");
+        //Return success
+        successRequest(response, notificationsList, request.redirectedServer);
         
     } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
         failureRequest(response, error, request.redirectedServer);

+ 4 - 4
Libraries external/OCCommunicationLib/OCCommunicationLib/OCXMLNotificationsParser.h

@@ -13,13 +13,13 @@
 
     NSMutableString *_xmlChars;
     NSMutableDictionary *_xmlBucket;
-    NSMutableArray *_notificationList;
-    OCNotifications *_currentNotification;
+    NSMutableArray *_notificationsList;
+    OCNotifications *_currentNotifications;
     BOOL isNotFirstFileOfList;
 }
 
-@property(nonatomic,strong) NSMutableArray *notificationList;
-@property(nonatomic,strong) OCNotifications *currentNotification;
+@property(nonatomic,strong) NSMutableArray *notificationsList;
+@property(nonatomic,strong) OCNotifications *currentNotifications;
 
 - (void)initParserWithData: (NSData*)data;
 

+ 3 - 3
Libraries external/OCCommunicationLib/OCCommunicationLib/OCXMLNotificationsParser.m

@@ -10,8 +10,8 @@
 
 @implementation OCXMLNotificationsParser
 
-@synthesize notificationList=_notificationList;
-@synthesize currentNotification=_currentNotification;
+@synthesize notificationsList =_notificationsList;
+@synthesize currentNotifications =_currentNotifications;
 
 
 /*
@@ -20,7 +20,7 @@
  */
 - (void)initParserWithData: (NSData*)data{
     
-    _notificationList = [[NSMutableArray alloc]init];
+    _notificationsList = [[NSMutableArray alloc]init];
     
     NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
     [parser setDelegate:self];

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -942,7 +942,7 @@
     [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
     [communication setUserAgent:[CCUtility getUserAgent:_typeCloud]];
     
-    [communication getNotificationsOfTheServer:[_activeUrl stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, OCCapabilities *capabilities, NSString *redirectedServer) {
+    [communication getNotificationsOfTheServer:[_activeUrl stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, OCNotifications *notifications, NSString *redirectedServer) {
         
         [self complete];