Browse Source

oneByOne -> true

Marino Faggiana 8 years ago
parent
commit
9c207587f9

+ 4 - 4
Picker/Base.lproj/MainInterface.storyboard

@@ -26,15 +26,15 @@
                                 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                                 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <prototypes>
                                 <prototypes>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="60" id="0H6-U8-fd4" userLabel="Cell" customClass="recordMetadataCell" customModule="Picker" customModuleProvider="target">
-                                        <rect key="frame" x="0.0" y="28" width="375" height="60"/>
+                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="50" id="0H6-U8-fd4" userLabel="Cell" customClass="recordMetadataCell" customModule="Picker" customModuleProvider="target">
+                                        <rect key="frame" x="0.0" y="28" width="375" height="50"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0H6-U8-fd4" id="44X-Sr-gc0">
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0H6-U8-fd4" id="44X-Sr-gc0">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="59"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="375" height="49.5"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                             <subviews>
                                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Wk9-rb-4yv">
                                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Wk9-rb-4yv">
-                                                    <rect key="frame" x="10" y="9" width="40" height="40"/>
+                                                    <rect key="frame" x="10" y="5" width="40" height="40"/>
                                                     <constraints>
                                                     <constraints>
                                                         <constraint firstAttribute="width" constant="40" id="OjC-WK-8oe"/>
                                                         <constraint firstAttribute="width" constant="40" id="OjC-WK-8oe"/>
                                                         <constraint firstAttribute="height" constant="40" id="mef-gN-2ly"/>
                                                         <constraint firstAttribute="height" constant="40" id="mef-gN-2ly"/>

+ 35 - 10
Picker/DocumentPickerViewController.swift

@@ -191,7 +191,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
                 metadataNet.session = download_session_foreground
                 metadataNet.session = download_session_foreground
                 metadataNet.taskStatus = Int(taskStatusResume)
                 metadataNet.taskStatus = Int(taskStatusResume)
                 
                 
-                let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: false, activityIndicator: false)
+                let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: true, activityIndicator: false)
                 networkingOperationQueue.addOperation(ocNetworking)
                 networkingOperationQueue.addOperation(ocNetworking)
             }
             }
         }
         }
@@ -206,38 +206,59 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     
     
     //  MARK: - Download
     //  MARK: - Download
     
     
+    func progressTask(_ fileID: String!, serverUrl: String!, cryptated: Bool, progress: Float) {
+        
+        hud.progress(progress)
+    }
+    
+    func cancelTransfer() {
+        
+        networkingOperationQueue.cancelAllOperations()
+    }
+    
     func downloadFileFailure(_ fileID: String!, serverUrl: String!, selector: String!, message: String!, errorCode: Int) {
     func downloadFileFailure(_ fileID: String!, serverUrl: String!, selector: String!, message: String!, errorCode: Int) {
         
         
         hud.hideHud()
         hud.hideHud()
         
         
-        if selector == selectorLoadFileView {
+        if selector == selectorLoadFileView && errorCode != -999 {
             
             
             let alert = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: message, preferredStyle: .alert)
             let alert = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: message, preferredStyle: .alert)
             alert.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
             alert.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
-                self.dismissGrantingAccess(to: nil)
+                //self.dismissGrantingAccess(to: nil)
+                NSLog("[LOG] Download Error \(fileID) \(message) (error \(errorCode))");
             })
             })
             
             
             self.present(alert, animated: true, completion: nil)
             self.present(alert, animated: true, completion: nil)
         }
         }
-        
-        NSLog("[LOG] Download Error \(fileID) \(message) (error \(errorCode))");
     }
     }
 
 
     func downloadFileSuccess(_ fileID: String!, serverUrl: String!, selector: String!, selectorPost: String!) {
     func downloadFileSuccess(_ fileID: String!, serverUrl: String!, selector: String!, selectorPost: String!) {
         
         
         hud.hideHud()
         hud.hideHud()
         
         
+        let metadata = CCCoreData.getMetadataWithPreficate(NSPredicate(format: "(account == '\(activeAccount!)') AND (fileID == '\(fileID!)')"), context: nil)
+        
         switch selector {
         switch selector {
             
             
             case selectorLoadFileView :
             case selectorLoadFileView :
-            
+                
+                do {
+                    
+                    try FileManager.default.moveItem(atPath: "\(directoryUser!)/\(fileID!)", toPath: "\(directoryUser!)/\(metadata!.fileNamePrint!)")
+                    
+                } catch let error as NSError {
+        
+                    print(error)
+                }
+                
+                let url = URL(string: "file://\(directoryUser!)/\(metadata!.fileNamePrint!)".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)
+                self.dismissGrantingAccess(to: url)
+                
                 break
                 break
             
             
             case selectorLoadPlist :
             case selectorLoadPlist :
             
             
-                let metadata = CCCoreData.getMetadataWithPreficate(NSPredicate(format: "(account == '\(activeAccount!)') AND (fileID == '\(fileID!)')"), context: nil)
                 CCCoreData.downloadFilePlist(metadata, activeAccount: activeAccount, activeUrl: activeUrl, typeCloud: typeCloud, directoryUser: directoryUser)
                 CCCoreData.downloadFilePlist(metadata, activeAccount: activeAccount, activeUrl: activeUrl, typeCloud: typeCloud, directoryUser: directoryUser)
-            
                 tableView.reloadData()
                 tableView.reloadData()
             
             
             default :
             default :
@@ -282,7 +303,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         metadataNet.selector = selectorDownloadThumbnail;
         metadataNet.selector = selectorDownloadThumbnail;
         metadataNet.serverUrl = localServerUrl
         metadataNet.serverUrl = localServerUrl
 
 
-        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: false, activityIndicator: false)
+        let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: true, activityIndicator: false)
         networkingOperationQueue.addOperation(ocNetworking)
         networkingOperationQueue.addOperation(ocNetworking)
     }
     }
 }
 }
@@ -293,7 +314,7 @@ extension DocumentPickerViewController: UITableViewDelegate {
 
 
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         
         
-         return 60
+         return 50
     }
     }
 }
 }
 
 
@@ -365,6 +386,7 @@ extension DocumentPickerViewController: UITableViewDataSource {
                 // Download file
                 // Download file
                 let metadataNet = CCMetadataNet.init(account: activeAccount)!
                 let metadataNet = CCMetadataNet.init(account: activeAccount)!
             
             
+                metadataNet.action = actionDownloadFile
                 metadataNet.downloadData = true
                 metadataNet.downloadData = true
                 metadataNet.downloadPlist = false
                 metadataNet.downloadPlist = false
                 metadataNet.metadata = metadata
                 metadataNet.metadata = metadata
@@ -375,6 +397,9 @@ extension DocumentPickerViewController: UITableViewDataSource {
             
             
                 let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: true, activityIndicator: false)
                 let ocNetworking : OCnetworking = OCnetworking.init(delegate: self, metadataNet: metadataNet, withUser: activeUser, withPassword: activePassword, withUrl: activeUrl, withTypeCloud: typeCloud, oneByOne: true, activityIndicator: false)
                 networkingOperationQueue.addOperation(ocNetworking)
                 networkingOperationQueue.addOperation(ocNetworking)
+                
+                hud.visibleHudTitle(NSLocalizedString("_loading_", comment: ""), mode: MBProgressHUDMode.determinateHorizontalBar, color: self.navigationController?.view.tintColor)
+                hud.addButtonCancel(withTarget: self, selector: "cancelTransfer")
             }
             }
             
             
         } else {
         } else {

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -1445,7 +1445,7 @@
             metadataNet.session = download_session_foreground;
             metadataNet.session = download_session_foreground;
             metadataNet.taskStatus = taskStatusResume;
             metadataNet.taskStatus = taskStatusResume;
             
             
-            [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet oneByOne:NO];
+            [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet oneByOne:YES];
         }
         }
     }
     }
 }
 }