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

+ 33 - 0
iOSClient/Database/NCDatabase.swift

@@ -288,3 +288,36 @@ class tableTag: Object {
         return "fileID"
     }
 }
+
+class tableTrash: Object {
+    
+    @objc dynamic var account = ""
+    @objc dynamic var assetLocalIdentifier = ""
+    @objc dynamic var date = NSDate()
+    @objc dynamic var directory: Bool = false
+    @objc dynamic var directoryID = ""
+    @objc dynamic var e2eEncrypted: Bool = false
+    @objc dynamic var etag = ""
+    @objc dynamic var favorite: Bool = false
+    @objc dynamic var fileID = ""
+    @objc dynamic var fileName = ""
+    @objc dynamic var fileNameView = ""
+    @objc dynamic var iconName = ""
+    @objc dynamic var permissions = ""
+    @objc dynamic var session = ""
+    @objc dynamic var sessionError = ""
+    @objc dynamic var sessionSelector = ""
+    @objc dynamic var sessionTaskIdentifier: Int = 0
+    @objc dynamic var size: Double = 0
+    @objc dynamic var status: Int = 0
+    @objc dynamic var thumbnailExists: Bool = false
+    @objc dynamic var typeFile = ""
+    @objc dynamic var trashbinFileName = ""
+    @objc dynamic var trashbinOriginalLocation = ""
+    @objc dynamic var trashbinDeletionTime = NSDate()
+
+    override static func primaryKey() -> String {
+        return "fileID"
+    }
+}
+

+ 2 - 1
iOSClient/Database/NCManageDatabase.swift

@@ -57,7 +57,7 @@ class NCManageDatabase: NSObject {
         let config = Realm.Configuration(
         
             fileURL: dirGroup?.appendingPathComponent("\(k_appDatabaseNextcloud)/\(k_databaseDefault)"),
-            schemaVersion: 28,
+            schemaVersion: 29,
             
             // 10 : Version 2.18.0
             // 11 : Version 2.18.2
@@ -78,6 +78,7 @@ class NCManageDatabase: NSObject {
             // 26 : Version 2.22.0.4
             // 27 : Version 2.22.0.7
             // 28 : Version 2.22.3.5
+            // 29 : Version 2.23.5.2
             
             migrationBlock: { migration, oldSchemaVersion in
                 // We haven’t migrated anything yet, so oldSchemaVersion == 0

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -953,7 +953,7 @@ typedef enum {
 
 #pragma mark - Trash
 
-- (void)listingTrashbin:(NSString *)path withUserSessionToken:(NSString *)token onCommunication:(OCCommunication *)sharedOCCommunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest;
+- (void)listingTrash:(NSString *)path onCommunication:(OCCommunication *)sharedOCCommunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest;
 
 @end
 

+ 7 - 14
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -2810,33 +2810,26 @@
     }];
 }
 
-#pragma mark - Trash API
+#pragma mark - Trash
 
-- (void)listingTrashbin:(NSString *)path withUserSessionToken:(NSString *)token onCommunication:(OCCommunication *)sharedOCCommunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest
+- (void)listingTrash:(NSString *)path onCommunication:(OCCommunication *)sharedOCCommunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest
 {
-    if (!token){
-        token = @"no token";
-    }
-    
     path = [path encodeString:NSUTF8StringEncoding];
     
     OCWebDAVClient *request = [OCWebDAVClient new];
     request = [self getRequestWithCredentials:request];
     
-    [request listTrashbinPath:path user:_user userID:_userID onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
+    [request listTrash:path userID:_userID onCommunication:sharedOCCommunication success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
         
-        NSData *responseData = (NSData *)responseObject;
-        OCXMLParser *parser = [[OCXMLParser alloc]init];
-        [parser initParserWithData:responseData];
-        NSMutableArray *directoryList = [parser.directoryList mutableCopy];
+        OCXMLParser *parser = [OCXMLParser new];
+        [parser initParserWithData:responseObject];
+        NSMutableArray *list = [parser.directoryList mutableCopy];
         
-        //Return success
-        successRequest(response, directoryList, request.redirectedServer, token);
+        successRequest(response, list, request.redirectedServer, token);
         
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error, NSString *token) {
         
         failureRequest(response, error, token, request.redirectedServer);
-
     }];
 }
 

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -660,9 +660,9 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
 
 
 ///-----------------------------------
-/// Trashbin
+/// Trash
 ///-----------------------------------
 
-- (void)listTrashbinPath:(NSString *)path user:(NSString *)user userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure;
+- (void)listTrash:(NSString *)path userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure;
 
 @end

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -1208,7 +1208,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
 #pragma mark - Trash
 
-- (void)listTrashbinPath:(NSString *)path user:(NSString *)user userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure
+- (void)listTrash:(NSString *)path userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure
 {
     NSParameterAssert(success);
     
@@ -1240,7 +1240,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
-    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication withUserSessionToken:token success:success failure:failure];
+    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication withUserSessionToken:nil success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [operation resume];
 }

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -76,7 +76,7 @@
 - (void)createLinkRichdocumentsWithFileID:(NSString *)fileID success:(void(^)(NSString *link))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
 - (void)createAssetRichdocumentsWithFileName:(NSString *)fileName serverUrl:(NSString *)serverUrl success:(void(^)(NSString *link))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
 
-- (void)listingTrashs:(void(^)(NSArray *metadatas))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
+- (void)listingTrash:(void(^)(NSArray *metadatas))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
 
 @end
 

+ 2 - 2
iOSClient/Networking/OCNetworking.m

@@ -2273,7 +2273,7 @@
 #pragma mark =====  Trash OCS API =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)listingTrashs:(void(^)(NSArray *metadatas))success failure:(void (^)(NSString *message, NSInteger errorCode))failure
+- (void)listingTrash:(void(^)(NSArray *items))success failure:(void (^)(NSString *message, NSInteger errorCode))failure
 {
     OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
     
@@ -2282,7 +2282,7 @@
     
     NSString *path = [_activeUrl stringByAppendingString:k_dav];
 
-    [communication listingTrashbin:path withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
+    [communication listingTrash:path onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         NSLog(@"ok");
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
         NSLog(@"error");

+ 4 - 3
iOSClient/Trash/NCTrash.swift

@@ -16,10 +16,11 @@ class NCTrash: UICollectionViewController {
         super.viewDidLoad()
 
         let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
-        ocNetworking?.listingTrashs({ ([Any]?) in
-
+        
+        ocNetworking?.listingTrash({ (item) in
+            
         }, failure: { (message, errorCode) in
-           
+            
         })
     }