Marino Faggiana 6 жил өмнө
parent
commit
b6fef36e9f

+ 6 - 23
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -2773,7 +2773,7 @@
 
 
 - (void)createAssetRichdocuments:(NSString *)serverPath path:(NSString *)path onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *url, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
 - (void)createAssetRichdocuments:(NSString *)serverPath path:(NSString *)path onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *url, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
     
-    serverPath = [serverPath stringByAppendingString:k_url_create_link_mobile_editor];
+    serverPath = [serverPath stringByAppendingString:k_url_insert_assets_to_collabora];
     serverPath = [serverPath stringByAppendingString:@"?format=json"];
     serverPath = [serverPath stringByAppendingString:@"?format=json"];
     
     
     OCWebDAVClient *request = [[OCWebDAVClient alloc] init];
     OCWebDAVClient *request = [[OCWebDAVClient alloc] init];
@@ -2790,32 +2790,15 @@
         
         
         if (jsongParsed && jsongParsed.allKeys > 0) {
         if (jsongParsed && jsongParsed.allKeys > 0) {
             
             
-            NSDictionary *ocs = [jsongParsed valueForKey:@"ocs"];
-            NSDictionary *meta = [ocs valueForKey:@"meta"];
-            NSDictionary *data = [ocs valueForKey:@"data"];
-            
-            NSInteger statusCode = [[meta valueForKey:@"statuscode"] integerValue];
-            
-            if (statusCode == kOCUserProfileAPISuccessful) {
-                
-                if ([data valueForKey:@"url"] && ![[data valueForKey:@"url"] isKindOfClass:[NSNull class]]) {
+            if ([jsongParsed valueForKey:@"url"] && ![[jsongParsed valueForKey:@"url"] isKindOfClass:[NSNull class]]) {
                     
                     
-                    NSString *url = [data valueForKey:@"url"];
-                    successRequest(response, url, request.redirectedServer);
+                NSString *url = [jsongParsed valueForKey:@"url"];
+                successRequest(response, url, request.redirectedServer);
                     
                     
-                } else {
-                    failureRequest(response, [UtilsFramework getErrorWithCode:k_CCErrorWebdavResponseError andCustomMessageFromTheServer:NSLocalizedStringFromTable(@"_server_response_error_", @"Error", nil)], request.redirectedServer);
-                }
-                
             } else {
             } else {
-                
-                NSString *message = (NSString *)[meta objectForKey:@"message"];
-                if ([message isKindOfClass:[NSNull class]]) {
-                    message = NSLocalizedStringFromTable(@"_server_response_error_", @"Error", nil);
-                }
-                failureRequest(response, [UtilsFramework getErrorWithCode:statusCode andCustomMessageFromTheServer:message], request.redirectedServer);
+                failureRequest(response, [UtilsFramework getErrorWithCode:k_CCErrorWebdavResponseError andCustomMessageFromTheServer:NSLocalizedStringFromTable(@"_server_response_error_", @"Error", nil)], request.redirectedServer);
             }
             }
-            
+                
         } else {
         } else {
             failureRequest(response, [UtilsFramework getErrorWithCode:k_CCErrorWebdavResponseError andCustomMessageFromTheServer:NSLocalizedStringFromTable(@"_server_response_error_", @"Error", nil)], request.redirectedServer);
             failureRequest(response, [UtilsFramework getErrorWithCode:k_CCErrorWebdavResponseError andCustomMessageFromTheServer:NSLocalizedStringFromTable(@"_server_response_error_", @"Error", nil)], request.redirectedServer);
         }
         }

+ 3 - 0
iOSClient/Library/OCCommunicationLib/OCFrameworkConstants.h

@@ -73,6 +73,9 @@
 //Url to access to Mobile Editor OCS API
 //Url to access to Mobile Editor OCS API
 #define k_url_create_link_mobile_editor @"ocs/v2.php/apps/richdocuments/api/v1/document"
 #define k_url_create_link_mobile_editor @"ocs/v2.php/apps/richdocuments/api/v1/document"
 
 
+//Url to insert files directly from your Nextcloud to a Collabora Online document
+#define k_url_insert_assets_to_collabora @"apps/richdocuments/assets"
+
 //Version of the server that have share API
 //Version of the server that have share API
 #define k_version_support_shared [NSArray arrayWithObjects:  @"5", @"0", @"27", nil]
 #define k_version_support_shared [NSArray arrayWithObjects:  @"5", @"0", @"27", nil]
 
 

+ 6 - 0
iOSClient/Richdocument/NCRichdocument.swift

@@ -100,6 +100,12 @@ class NCRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler, CC
     
     
     func select(_ metadata: tableMetadata!, serverUrl: String!) {
     func select(_ metadata: tableMetadata!, serverUrl: String!) {
         
         
+        let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
+        ocNetworking?.createAssetRichdocuments(withFileName: metadata.fileName, serverUrl: serverUrl, success: { (url) in
+            print(url)
+        }, failure: { (message, errorCode) in
+            self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
+        })
     }
     }
     
     
     //MARK: -
     //MARK: -