Kaynağa Gözat

Change field localIdentifier to identifier

Marino Faggiana 8 yıl önce
ebeveyn
işleme
4428ec756f

+ 3 - 3
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.h

@@ -782,19 +782,19 @@ typedef enum {
 
 
 ///-----------------------------------
-/// @name Delete Notification
+/// @name set Notification
 ///-----------------------------------
 
 /**
  * Method read the notification of the server
  *
  * @param serverPath            -> NSString server
- * @param idNotification        -> NSString idNotification
+ * @param type                  -> NSString "POST" "DELETE"
  * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  *
  */
 
-- (void) deleteNotification:(NSString*)serverPath idNotification:(NSString *)idNotification onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
+- (void) setNotification:(NSString*)serverPath type:(NSString *)type onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
 @end
 

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

@@ -1380,15 +1380,14 @@
     }];
 }
 
-- (void) deleteNotification:(NSString*)serverPath idNotification:(NSString *)idNotification onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void (^)(NSHTTPURLResponse *, NSString *))successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest {
+- (void) setNotification:(NSString*)serverPath type:(NSString *)type 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 idNotification:idNotification onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
+    [request setNotification:serverPath type:type onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
         if (successRequest) {
             //Return success
             successRequest(response, request.redirectedServer);

+ 2 - 2
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -492,11 +492,11 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
  * Method read the notification of the server
  *
  * @param serverPath            -> NSString server
- * @param idNotification        -> NSString idNotification
+ * @param type                  -> NSString "POST" "DELETE"
  * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  *
  */
 
-- (void)deleteNotification:(NSString * _Nonnull)serverPath idNotification:(NSString * _Nonnull)idNotification onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nullable responseObject, NSError * _Nonnull))failure;
+- (void)setNotification:(NSString * _Nonnull)serverPath type:(NSString * _Nonnull)type onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nullable responseObject, NSError * _Nonnull))failure;
 
 @end

+ 2 - 4
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -637,13 +637,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [operation resume];
 }
 
-- (void) deleteNotification:(NSString *)serverPath idNotification:(NSString *)idNotification onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *, id))success failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
+- (void) setNotification:(NSString *)serverPath type:(NSString *)type onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *, id))success failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
     
     NSParameterAssert(success);
     
-    _requestMethod = @"DELETE";
-    
-    serverPath = [NSString stringWithFormat:@"%@/%@", serverPath, idNotification];
+    _requestMethod = type;
     
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil];
     

+ 1 - 1
iOSClient/CCGlobal.h

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

+ 2 - 2
iOSClient/FileSystem/CCCoreData.m

@@ -1464,7 +1464,7 @@
     TableAutomaticUpload *record = [TableAutomaticUpload MR_createEntityInContext:context];
         
     record.account = account;
-    record.assetLocalItentifier = metadataNet.assetLocalItentifier;
+    record.identifier = metadataNet.identifier;
     record.date = [NSDate date];
     record.fileName = metadataNet.fileName;
     record.selector = metadataNet.selector;
@@ -1488,7 +1488,7 @@
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] init];
         
         metadataNet.action = actionUploadAsset;                             // Default
-        metadataNet.assetLocalItentifier = record.assetLocalItentifier;
+        metadataNet.identifier = record.identifier;
         metadataNet.fileName = record.fileName;
         metadataNet.priority = [record.priority longValue];
         metadataNet.selector = record.selector;

+ 1 - 1
iOSClient/FileSystem/CCMetadata.h

@@ -69,7 +69,7 @@
 
 @property (nonatomic, strong) NSString *account;
 @property (nonatomic, strong) NSString *action;
-@property (nonatomic, strong) NSString *assetLocalItentifier;
+@property (nonatomic, strong) NSString *identifier;
 @property BOOL cryptated;
 @property (nonatomic, strong) NSDate *date;
 @property BOOL directory;

+ 1 - 1
iOSClient/FileSystem/CCMetadata.m

@@ -187,7 +187,7 @@
     
     [metadataNet setAccount: self.account];
     [metadataNet setAction: self.action];
-    [metadataNet setAssetLocalItentifier: self.assetLocalItentifier];
+    [metadataNet setIdentifier: self.identifier];
     [metadataNet setCryptated: self.cryptated];
     [metadataNet setDate: self.date];
     [metadataNet setDirectory: self.directory];

+ 1 - 1
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.h

@@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
 + (NSFetchRequest<TableAutomaticUpload *> *)fetchRequest;
 
 @property (nullable, nonatomic, copy) NSString *account;
-@property (nullable, nonatomic, copy) NSString *assetLocalItentifier;
 @property (nullable, nonatomic, copy) NSDate *date;
 @property (nullable, nonatomic, copy) NSString *fileName;
+@property (nullable, nonatomic, copy) NSString *identifier;
 @property (nullable, nonatomic, copy) NSNumber *priority;
 @property (nullable, nonatomic, copy) NSString *selector;
 @property (nullable, nonatomic, copy) NSString *selectorPost;

+ 1 - 1
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.m

@@ -15,9 +15,9 @@
 }
 
 @dynamic account;
-@dynamic assetLocalItentifier;
 @dynamic date;
 @dynamic fileName;
+@dynamic identifier;
 @dynamic priority;
 @dynamic selector;
 @dynamic selectorPost;

+ 36 - 6
iOSClient/Main/CCMain.m

@@ -27,6 +27,8 @@
 #import "CCPhotosCameraUpload.h"
 #import "CCOfflineFolder.h"
 #import <OCCommunicationLib/OCNotifications.h>
+#import <OCCommunicationLib/OCNotificationsAction.h>
+#import <OCCommunicationLib/OCFrameworkConstants.h>
 
 #import "Nextcloud-Swift.h"
 
@@ -1036,29 +1038,57 @@
                         
                         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
                         
-                        metadataNet.action  = actionDeleteNotifications;
-                        metadataNet.options = [NSString stringWithFormat:@"%lu", (unsigned long)notification.idNotification];
+                        metadataNet.action  = actionSetNotification;
+                        metadataNet.serverUrl =  [NSString stringWithFormat:@"%@/%@/%@", app.activeUrl, k_url_acces_remote_notification_api, idNotification];
+                        metadataNet.options = @"DELETE";
                         
                         [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
                     }
                 }
             }];
         }
+        
+        // Action request
+        else {
+            
+            NSMutableArray *buttons = [NSMutableArray new];
+            for (OCNotificationsAction *action in notification.actions)
+                [buttons addObject:action.label];
+            
+            [JSAlertView alert:notification.subject withTitle:@"Server Notification" buttons:buttons withCompletionHandler:^(NSInteger buttonIndex, NSString *buttonTitle) {
+                
+                NSLog(@"Pressed %@ at index %ld", buttonTitle, (long)buttonIndex);
+                
+                for (OCNotificationsAction *action in notification.actions)
+                    if ([action.label isEqualToString:buttonTitle]) {
+                        
+                        /*
+                        CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+                        
+                        metadataNet.action  = actionSetNotification;
+                        metadataNet.serverUrl =  action.link;
+                        metadataNet.options = action.type;
+                        
+                        [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
+                        */ 
+                    }
+            }];
+        }
     }
 }
 
-- (void)deleteNotificationsSuccess:(CCMetadataNet *)metadataNet
+- (void)setNotificationSuccess:(CCMetadataNet *)metadataNet
 {
     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     
     NSString *idNotification = metadataNet.options;
     
-    [appDelegate.listOfNotifications  removeObjectForKey:idNotification];
+    [appDelegate.listOfNotifications removeObjectForKey:idNotification];
     
     NSLog(@"delete Notification id :%@", idNotification);
 }
 
-- (void)deleteNotificationsFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
+- (void)setNotificationFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
 {
     NSLog(@"Error Notification");
 }
@@ -1574,7 +1604,7 @@
             if ([app.typeCloud isEqualToString:typeCloudNextcloud] || [app.typeCloud isEqualToString:typeCloudOwnCloud]) {
             
                 metadataNet.action = actionReadFile;
-                metadataNet.assetLocalItentifier = asset.localIdentifier;
+                metadataNet.identifier = asset.localIdentifier;
                 metadataNet.cryptated = cryptated;
                 metadataNet.fileName = fileName;
                 metadataNet.priority = NSOperationQueuePriorityVeryHigh;

+ 2 - 3
iOSClient/Networking/OCNetworking.h

@@ -31,7 +31,6 @@
 #import "CCCoreData.h"
 
 
-
 @protocol OCNetworkingDelegate;
 
 @interface OCnetworking : NSOperation <CCNetworkingDelegate>
@@ -97,8 +96,8 @@
 - (void)getNotificationsOfServerSuccess:(NSArray *)listOfNotifications;
 - (void)getNotificationsOfServerFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
-- (void)deleteNotificationsSuccess:(CCMetadataNet *)metadataNet;
-- (void)deleteNotificationsFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
+- (void)setNotificationSuccess:(CCMetadataNet *)metadataNet;
+- (void)setNotificationFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
 // HUD
 - (void)progressTask:(NSString *)fileID serverUrl:(NSString *)serverUrl cryptated:(BOOL)cryptated progress:(float)progress;

+ 8 - 8
iOSClient/Networking/OCNetworking.m

@@ -201,7 +201,7 @@
 
 - (void)uploadAsset
 {
-    [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:_metadataNet.assetLocalItentifier fileName:_metadataNet.fileName serverUrl:_metadataNet.serverUrl cryptated:_metadataNet.cryptated session:_metadataNet.session taskStatus:_metadataNet.taskStatus selector:_metadataNet.selector selectorPost:_metadataNet.selectorPost parentRev:nil errorCode:_metadataNet.errorCode delegate:self];
+    [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:_metadataNet.identifier fileName:_metadataNet.fileName serverUrl:_metadataNet.serverUrl cryptated:_metadataNet.cryptated session:_metadataNet.session taskStatus:_metadataNet.taskStatus selector:_metadataNet.selector selectorPost:_metadataNet.selectorPost parentRev:nil errorCode:_metadataNet.errorCode delegate:self];
 }
 
 - (void)uploadTemplate
@@ -966,19 +966,19 @@
     }];
 }
 
-- (void)deleteNotifications
+- (void)setNotification
 {
     OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
     
     [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
     [communication setUserAgent:[CCUtility getUserAgent:_typeCloud]];
     
-    NSString *idNotification = _metadataNet.options;
+    NSString *type = _metadataNet.options;
     
-    [communication deleteNotification:[_activeUrl stringByAppendingString:@"/"] idNotification:idNotification onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
+    [communication setNotification:_metadataNet.serverUrl type:type onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
         
-        if ([self.delegate respondsToSelector:@selector(deleteNotificationsSuccess:)])
-            [self.delegate deleteNotificationsSuccess:_metadataNet];
+        if ([self.delegate respondsToSelector:@selector(setNotificationSuccess:)])
+            [self.delegate setNotificationSuccess:_metadataNet];
         
         [self complete];
         
@@ -988,8 +988,8 @@
         if (errorCode == 0)
             errorCode = error.code;
         
-        if([self.delegate respondsToSelector:@selector(deleteNotificationsFailure:message:errorCode:)])
-            [self.delegate deleteNotificationsFailure:_metadataNet message:[error.userInfo valueForKey:@"NSLocalizedDescription"] errorCode:errorCode];
+        if([self.delegate respondsToSelector:@selector(setNotificationFailure:message:errorCode:)])
+            [self.delegate setNotificationFailure:_metadataNet message:[error.userInfo valueForKey:@"NSLocalizedDescription"] errorCode:errorCode];
         
         // Request trusted certificated
         if ([error code] == NSURLErrorServerCertificateUntrusted)

+ 1 - 1
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -1221,7 +1221,7 @@
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
             
         metadataNet.action = actionUploadAsset;
-        metadataNet.assetLocalItentifier = asset.localIdentifier;
+        metadataNet.identifier = asset.localIdentifier;
         if (assetsFull) {
             metadataNet.selector = selectorUploadAutomaticAll;
             metadataNet.selectorPost = selectorUploadRemovePhoto;

+ 1 - 1
iOSClient/cryptocloud.xcdatamodeld/cryptocloud 7.xcdatamodel/contents

@@ -29,9 +29,9 @@
     </entity>
     <entity name="TableAutomaticUpload" representedClassName="TableAutomaticUpload" syncable="YES">
         <attribute name="account" optional="YES" attributeType="String" syncable="YES"/>
-        <attribute name="assetLocalItentifier" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="fileName" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="identifier" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="priority" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="selector" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="selectorPost" optional="YES" attributeType="String" syncable="YES"/>