NCTrash.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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: UICollectionViewController {
  10. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  11. var path = ""
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. }
  15. override func viewWillAppear(_ animated: Bool) {
  16. super.viewWillAppear(animated)
  17. if path == "" {
  18. let userID = (appDelegate.activeUserID as NSString).addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlFragmentAllowed)
  19. path = k_dav + "/trashbin/" + userID! + "/trash/"
  20. }
  21. let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
  22. ocNetworking?.listingTrash(appDelegate.activeUrl, path:path, account: appDelegate.activeAccount, success: { (item) in
  23. NCManageDatabase.sharedInstance.deleteTrash(filePath: self.path)
  24. _ = NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])
  25. }, failure: { (message, errorCode) in
  26. })
  27. }
  28. }