瀏覽代碼

deleteNotification

Marino Faggiana 8 年之前
父節點
當前提交
6abdfdbc59

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

@@ -762,6 +762,8 @@ typedef enum {
                      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
 
+#pragma mark -  Server Notification
+
 ///-----------------------------------
 /// @name Get the server Notification
 ///-----------------------------------
@@ -778,4 +780,11 @@ typedef enum {
 
 - (void) getNotificationsOfServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *listOfNotifications, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
+
+
+- (void) deleteNotification:(NSString*)serverPath notification_id:(NSString *)notification_id onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
+
 @end
+
+
+

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

@@ -1252,7 +1252,6 @@
     } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
         failureRequest(response, error, request.redirectedServer);
     }];
-    
 }
 
 
@@ -1285,9 +1284,9 @@
     return operation;
 }
 
-#pragma mark - Get Notification Server
+#pragma mark - Notification Server
 
-- (void) getNotificationsOfServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *listOfNotifications, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest{
+- (void) getNotificationsOfServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *listOfNotifications, 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];
@@ -1381,6 +1380,22 @@
     }];
 }
 
+- (void) deleteNotification:(NSString*)serverPath notification_id:(NSString *)notification_id onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void (^)(NSHTTPURLResponse *, NSString *))successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest {
+    
+    serverPath = [serverPath encodeString:NSUTF8StringEncoding];
+    serverPath = [serverPath stringByAppendingString:k_url_acces_remote_notification_api];
+    
+    OCWebDAVClient *request = [OCWebDAVClient new];
+    request = [self getRequestWithCredentials:request];
+    
+    [request deleteNotification:serverPath notification_id:notification_id onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
+        
+    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
+        failureRequest(response, error, request.redirectedServer);
+    }];
+}
+
+
 #pragma mark - Clear Cache
 
 - (void)eraseURLCache

+ 5 - 3
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -466,7 +466,7 @@ 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
+#pragma mark - Notification
 
 ///-----------------------------------
 /// @name Get the server Notification
@@ -482,6 +482,8 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
  *
  */
 
-- (void) getNotificationsOfServer:(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;
+- (void) getNotificationsOfServer:(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;
+
+- (void)deleteNotification:(NSString * _Nonnull)serverPath notification_id:(NSString * _Nonnull)notification_id onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nullable responseObject, NSError * _Nonnull))failure;
+
 @end

+ 15 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -637,6 +637,21 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [operation resume];
 }
 
+- (void) deleteNotification:(NSString *)serverPath notification_id:(NSString *)notification_id onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *, id))success failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
+    
+    NSParameterAssert(success);
+    
+    _requestMethod = @"DELETE";
+    
+    serverPath = [NSString stringWithFormat:@"%@/%@", serverPath, notification_id];
+    
+    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
 
 - (void) setRedirectionBlockOnDatataskWithOCCommunication: (OCCommunication *) sharedOCCommunication andSessionManager:(AFURLSessionManager *) sessionManager{

+ 1 - 0
iOSClient/CCGlobal.h

@@ -262,6 +262,7 @@ extern NSString *const BKPasscodeKeychainServiceName;
 #define actionGetFeaturesSuppServer     @"getFeaturesSupportedByServer"
 #define actionGetUserAndGroup           @"getUserAndGroup"
 #define actionGetNotificationsOfServer  @"getNotificationsOfServer"
+#define actionDeleteNotifications       @"deleteNotifications"
 #define actionMoveFileOrFolder          @"moveFileOrFolder"
 #define actionReadFile                  @"readFile"
 #define actionReadFolder                @"readFolder"

+ 5 - 4
iOSClient/Main/CCMain.m

@@ -1006,12 +1006,9 @@
 }
 
 #pragma mark -
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ======================= NetWorking ==================================
-#pragma --------------------------------------------------------------------------------------------
 
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark ==== Request Server  ====
+#pragma mark ==== Notification  ====
 #pragma --------------------------------------------------------------------------------------------
 
 - (void)getNotificationsOfServerSuccess:(NSArray *)listOfNotifications
@@ -1034,6 +1031,10 @@
     app.capabilities = capabilities;
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ==== Request Server  ====
+#pragma --------------------------------------------------------------------------------------------
+
 - (void)getFeaturesSupportedByServerSuccess:(BOOL)hasCapabilitiesSupport hasForbiddenCharactersSupport:(BOOL)hasForbiddenCharactersSupport hasShareSupport:(BOOL)hasShareSupport hasShareeSupport:(BOOL)hasShareeSupport
 {
     app.hasServerCapabilitiesSupport = hasCapabilitiesSupport;

+ 14 - 0
iOSClient/Networking/OCNetworking.m

@@ -967,6 +967,20 @@
     }];
 }
 
+- (void)deleteNotifications
+{
+    OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
+    
+    [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
+    [communication setUserAgent:[CCUtility getUserAgent:_typeCloud]];
+    
+    [communication deleteNotification:[_activeUrl stringByAppendingString:@"/"] notification_id:0 onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
+        NSLog(@"a");
+    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
+        NSLog(@"b");
+    }];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark =====  Server =====
 #pragma --------------------------------------------------------------------------------------------