added iOS source code
[wl-app.git] / iOS / Pods / MZDownloadManager / MZDownloadManager / Classes / MZDownloadModel.swift
1 //
2 //  MZDownloadModel.swift
3 //  MZDownloadManager
4 //
5 //  Created by Muhammad Zeeshan on 19/04/2016.
6 //  Copyright © 2016 ideamakerz. All rights reserved.
7 //
8
9 import UIKit
10
11 public enum TaskStatus: Int {
12     case unknown, gettingInfo, downloading, paused, failed
13     
14     public func description() -> String {
15         switch self {
16         case .gettingInfo:
17             return "GettingInfo"
18         case .downloading:
19             return "Downloading"
20         case .paused:
21             return "Paused"
22         case .failed:
23             return "Failed"
24         default:
25             return "Unknown"
26         }
27     }
28 }
29
30 open class MZDownloadModel: NSObject {
31     
32     open var fileName: String!
33     open var fileURL: String!
34     open var status: String = TaskStatus.gettingInfo.description()
35     
36     open var file: (size: Float, unit: String)?
37     open var downloadedFile: (size: Float, unit: String)?
38     
39     open var remainingTime: (hours: Int, minutes: Int, seconds: Int)?
40     
41     open var speed: (speed: Float, unit: String)?
42     
43     open var progress: Float = 0
44     
45     open var task: URLSessionDownloadTask?
46     
47     open var startTime: Date?
48     
49     fileprivate(set) open var destinationPath: String = ""
50     
51     fileprivate convenience init(fileName: String, fileURL: String) {
52         self.init()
53         
54         self.fileName = fileName
55         self.fileURL = fileURL
56     }
57     
58     convenience init(fileName: String, fileURL: String, destinationPath: String) {
59         self.init(fileName: fileName, fileURL: fileURL)
60         
61         self.destinationPath = destinationPath
62     }
63 }