NCTrash.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // NCTrash.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 02/10/2018.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. import Foundation
  9. class NCTrash: UIViewController {
  10. @IBOutlet fileprivate weak var collectionView: UICollectionView!
  11. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  12. var path = ""
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. }
  16. override func viewWillAppear(_ animated: Bool) {
  17. super.viewWillAppear(animated)
  18. if path == "" {
  19. let userID = (appDelegate.activeUserID as NSString).addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlFragmentAllowed)
  20. path = k_dav + "/trashbin/" + userID! + "/trash/"
  21. }
  22. let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
  23. ocNetworking?.listingTrash(appDelegate.activeUrl, path:path, account: appDelegate.activeAccount, success: { (item) in
  24. NCManageDatabase.sharedInstance.deleteTrash(filePath: self.path)
  25. _ = NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])
  26. }, failure: { (message, errorCode) in
  27. print("error " + message!)
  28. })
  29. }
  30. }