浏览代码

new API getNotificationsOfTheServer

Marino Faggiana 8 年之前
父节点
当前提交
7521ce2810

+ 15 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.h

@@ -763,4 +763,19 @@ typedef enum {
                      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
 
+///-----------------------------------
+/// @name Get the server Notification
+///-----------------------------------
+
+/**
+ * Method read the capabilities of the server
+ *
+ * @param serverPath  -> NSString server
+ * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
+ *
+ * @return capabilities -> OCCapabilities
+ *
+ */
+
+- (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;
 @end

+ 26 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -1282,6 +1282,32 @@
     return operation;
 }
 
+#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{
+    
+    serverPath = [serverPath encodeString:NSUTF8StringEncoding];
+    serverPath = [serverPath stringByAppendingString:k_url_acces_remote_notification_api];
+    
+    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];
+            
+        [parser initParserWithData:responseData];
+    
+        NSLog(@"parser");
+        
+    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
+        failureRequest(response, error, request.redirectedServer);
+    }];
+
+}
+
 #pragma mark - Clear Cache
 
 - (void)eraseURLCache

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

@@ -53,6 +53,9 @@
 //api/v1/thumbnail/{x}/{y}/{file}
 #define k_url_thumbnails @"index.php/apps/files/api/v1/thumbnail"
 
+//Url to access to Remote Notification API
+#define k_url_acces_remote_notification_api @"ocs/v2.php/apps/notifications/api/v2/notifications"
+
 //Version of the server that have share API
 #define k_version_support_shared [NSArray arrayWithObjects:  @"5", @"0", @"27", nil]
 

+ 8 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -466,4 +466,12 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
                             success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
                             failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id  _Nullable responseObject, NSError * _Nonnull error))failure;
 
+#pragma mark - Get Notification
+
+///-----------------------------------
+/// @name Get the server notification
+///-----------------------------------
+
+- (void) getNotificationsOfTheServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
+                         failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id  _Nullable responseObject, NSError * _Nonnull error))failure;
 @end

+ 17 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -620,6 +620,23 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     return operation;
 }
 
+#pragma mark - Get Notification
+
+- (void) getNotificationsOfTheServer:(NSString *)serverPath
+                onCommunication:(OCCommunication *)sharedOCCommunication
+                        success:(void(^)(NSHTTPURLResponse *, id))success
+                        failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
+    
+    NSParameterAssert(success);
+    
+    _requestMethod = @"GET";
+    
+    NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil];
+    
+    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
+    [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
+    [operation resume];
+}
 
 #pragma mark - Manage Redirections
 
@@ -667,5 +684,4 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     }];
 }
 
-
 @end

+ 0 - 1
iOSClient/AppDelegate.m

@@ -353,7 +353,6 @@
         
         //NSLog(@"[LOG] Read Folder for change Rev");
         //[[NSNotificationCenter defaultCenter] postNotificationName:@"readFileSelfFolderRev" object:nil];
-        
     });
 
     // 0.5 sec.

+ 20 - 19
iOSClient/CCGlobal.h

@@ -254,25 +254,26 @@ extern NSString *const BKPasscodeKeychainServiceName;
 #define selectorUploadRemovePhoto       @"uploadRemovePhoto"
 
 // Metadata.Net ACTION
-#define actionCreateFolder              @"createFolder"
-#define actionDeleteFileDirectory       @"deleteFileOrFolder"
-#define actionDownloadFile              @"downloadFile"
-#define actionDownloadThumbnail         @"downloadThumbnail"
-#define actionGetCapabilities           @"getCapabilitiesOfServer"
-#define actionGetFeaturesSuppServer     @"getFeaturesSupportedByServer"
-#define actionGetUserAndGroup           @"getUserAndGroup"
-#define actionMoveFileOrFolder          @"moveFileOrFolder"
-#define actionReadFile                  @"readFile"
-#define actionReadFolder                @"readFolder"
-#define actionReadShareServer           @"readShareServer"
-#define actionShare                     @"share"
-#define actionShareWith                 @"shareWith"
-#define actionUnShare                   @"unShare"
-#define actionUpdateShare               @"updateShare"
-#define actionUploadFile                @"uploadFile"
-#define actionUploadAsset               @"uploadAsset"
-#define actionUploadTemplate            @"uploadTemplate"
-#define actionUploadOnlyPlist           @"uploadOnlyPlist"
+#define actionCreateFolder                  @"createFolder"
+#define actionDeleteFileDirectory           @"deleteFileOrFolder"
+#define actionDownloadFile                  @"downloadFile"
+#define actionDownloadThumbnail             @"downloadThumbnail"
+#define actionGetCapabilities               @"getCapabilitiesOfServer"
+#define actionGetFeaturesSuppServer         @"getFeaturesSupportedByServer"
+#define actionGetUserAndGroup               @"getUserAndGroup"
+#define actionGetNotificationsOfTheServer   @"getNotificationsOfTheServer"
+#define actionMoveFileOrFolder              @"moveFileOrFolder"
+#define actionReadFile                      @"readFile"
+#define actionReadFolder                    @"readFolder"
+#define actionReadShareServer               @"readShareServer"
+#define actionShare                         @"share"
+#define actionShareWith                     @"shareWith"
+#define actionUnShare                       @"unShare"
+#define actionUpdateShare                   @"updateShare"
+#define actionUploadFile                    @"uploadFile"
+#define actionUploadAsset                   @"uploadAsset"
+#define actionUploadTemplate                @"uploadTemplate"
+#define actionUploadOnlyPlist               @"uploadOnlyPlist"
 
 // Tipi di sorgente directory
 #define sorceDirectoryAccount           0

+ 3 - 0
iOSClient/Main/CCMain.m

@@ -1049,6 +1049,9 @@
         metadataNet.action = actionGetCapabilities;
         [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
         
+        metadataNet.action = actionGetNotificationsOfTheServer;
+        [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+        
         metadataNet.action = actionReadFile;
         metadataNet.selector = selectorReadFileQuota;
         metadataNet.serverUrl = _localServerUrl;

+ 21 - 0
iOSClient/Networking/OCNetworking.m

@@ -931,6 +931,27 @@
     }];
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark =====  Notification =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)getNotificationsOfTheServer
+{
+    OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
+    
+    [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
+    [communication setUserAgent:[CCUtility getUserAgent:_typeCloud]];
+    
+    [communication getNotificationsOfTheServer:[_activeUrl stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, OCCapabilities *capabilities, NSString *redirectedServer) {
+        
+        [self complete];
+        
+    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
+        
+        [self complete];
+    }];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark =====  Server =====
 #pragma --------------------------------------------------------------------------------------------