NCDatabase.swift 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. //
  2. // NCDatabase.swift
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 06/05/17.
  6. // Copyright © 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import RealmSwift
  24. class tableAccount: Object {
  25. @objc dynamic var account = ""
  26. @objc dynamic var active: Bool = false
  27. @objc dynamic var address = ""
  28. @objc dynamic var autoUpload: Bool = false
  29. @objc dynamic var autoUploadBackground: Bool = false
  30. @objc dynamic var autoUploadCreateSubfolder: Bool = false
  31. @objc dynamic var autoUploadFileName = ""
  32. @objc dynamic var autoUploadDirectory = ""
  33. @objc dynamic var autoUploadFull: Bool = false
  34. @objc dynamic var autoUploadImage: Bool = false
  35. @objc dynamic var autoUploadVideo: Bool = false
  36. @objc dynamic var autoUploadWWAnPhoto: Bool = false
  37. @objc dynamic var autoUploadWWAnVideo: Bool = false
  38. @objc dynamic var businessSize: Double = 0
  39. @objc dynamic var businessType = ""
  40. @objc dynamic var dateSearchContentTypeImageVideo = NSDate.distantPast
  41. @objc dynamic var city = ""
  42. @objc dynamic var company = ""
  43. @objc dynamic var country = ""
  44. @objc dynamic var displayName = ""
  45. @objc dynamic var email = ""
  46. @objc dynamic var enabled: Bool = false
  47. @objc dynamic var loginFlow: Bool = false
  48. @objc dynamic var optimization = NSDate()
  49. @objc dynamic var phone = ""
  50. @objc dynamic var quota: Double = 0
  51. @objc dynamic var quotaFree: Double = 0
  52. @objc dynamic var quotaRelative: Double = 0
  53. @objc dynamic var quotaTotal: Double = 0
  54. @objc dynamic var quotaUsed: Double = 0
  55. @objc dynamic var role = ""
  56. @objc dynamic var startDirectoryPhotosTab = ""
  57. @objc dynamic var twitter = ""
  58. @objc dynamic var url = ""
  59. @objc dynamic var user = ""
  60. @objc dynamic var userID = ""
  61. @objc dynamic var webpage = ""
  62. @objc dynamic var zip = ""
  63. // HC
  64. @objc dynamic var hcIsTrial: Bool = false
  65. @objc dynamic var hcTrialExpired: Bool = false
  66. @objc dynamic var hcTrialRemainingSec: Double = 0
  67. @objc dynamic var hcTrialEndTime: NSDate? = nil
  68. @objc dynamic var hcAccountRemoveExpired: Bool = false
  69. @objc dynamic var hcAccountRemoveRemainingSec: Double = 0
  70. @objc dynamic var hcAccountRemoveTime: NSDate? = nil
  71. }
  72. class tableActivity: Object {
  73. @objc dynamic var account = ""
  74. @objc dynamic var idPrimaryKey = ""
  75. @objc dynamic var action = "Activity"
  76. @objc dynamic var date = NSDate()
  77. @objc dynamic var idActivity: Int = 0
  78. @objc dynamic var app = ""
  79. @objc dynamic var type = ""
  80. @objc dynamic var user = ""
  81. @objc dynamic var subject = ""
  82. @objc dynamic var subjectRich = ""
  83. let subjectRichItem = List<tableActivitySubjectRich>()
  84. @objc dynamic var icon = ""
  85. @objc dynamic var link = ""
  86. @objc dynamic var message = ""
  87. @objc dynamic var objectType = ""
  88. @objc dynamic var objectId: Int = 0
  89. @objc dynamic var objectName = ""
  90. @objc dynamic var note = ""
  91. @objc dynamic var selector = ""
  92. @objc dynamic var verbose: Bool = false
  93. override static func primaryKey() -> String {
  94. return "idPrimaryKey"
  95. }
  96. }
  97. class tableActivitySubjectRich: Object {
  98. @objc dynamic var account = ""
  99. @objc dynamic var idActivity: Int = 0
  100. @objc dynamic var idPrimaryKey = ""
  101. @objc dynamic var id = ""
  102. @objc dynamic var key = ""
  103. @objc dynamic var link = ""
  104. @objc dynamic var name = ""
  105. @objc dynamic var path = ""
  106. @objc dynamic var type = ""
  107. override static func primaryKey() -> String {
  108. return "idPrimaryKey"
  109. }
  110. }
  111. class tableActivityPreview: Object {
  112. @objc dynamic var account = ""
  113. @objc dynamic var idPrimaryKey = ""
  114. @objc dynamic var idActivity: Int = 0
  115. @objc dynamic var source = ""
  116. @objc dynamic var link = ""
  117. @objc dynamic var mimeType = ""
  118. @objc dynamic var fileId: Int = 0
  119. @objc dynamic var view = ""
  120. @objc dynamic var isMimeTypeIcon: Bool = false
  121. override static func primaryKey() -> String {
  122. return "idPrimaryKey"
  123. }
  124. }
  125. class tableCapabilities: Object {
  126. @objc dynamic var account = ""
  127. @objc dynamic var themingBackground = ""
  128. @objc dynamic var themingBackgroundDefault: Bool = false
  129. @objc dynamic var themingBackgroundPlain: Bool = false
  130. @objc dynamic var themingColor = ""
  131. @objc dynamic var themingColorElement = ""
  132. @objc dynamic var themingColorText = ""
  133. @objc dynamic var themingLogo = ""
  134. @objc dynamic var themingName = ""
  135. @objc dynamic var themingSlogan = ""
  136. @objc dynamic var themingUrl = ""
  137. @objc dynamic var versionMajor: Int = 0
  138. @objc dynamic var versionMicro: Int = 0
  139. @objc dynamic var versionMinor: Int = 0
  140. @objc dynamic var versionString = ""
  141. @objc dynamic var endToEndEncryption: Bool = false
  142. @objc dynamic var endToEndEncryptionVersion = ""
  143. let richdocumentsMimetypes = List<String>()
  144. @objc dynamic var richdocumentsDirectEditing: Bool = false
  145. // FILES SHARING
  146. @objc dynamic var isFilesSharingAPIEnabled: Bool = false
  147. @objc dynamic var filesSharingDefaulPermissions: Int = 0
  148. @objc dynamic var isFilesSharingGroupSharing: Bool = false
  149. @objc dynamic var isFilesSharingReSharing: Bool = false
  150. @objc dynamic var isFilesSharingPublicShareLinkEnabled: Bool = false
  151. @objc dynamic var isFilesSharingAllowPublicUploadsEnabled: Bool = false
  152. @objc dynamic var isFilesSharingAllowPublicUserSendMail: Bool = false
  153. @objc dynamic var isFilesSharingAllowPublicUploadFilesDrop: Bool = false
  154. @objc dynamic var isFilesSharingAllowPublicMultipleLinks: Bool = false
  155. @objc dynamic var isFilesSharingPublicExpireDateByDefaultEnabled: Bool = false
  156. @objc dynamic var isFilesSharingPublicExpireDateEnforceEnabled: Bool = false
  157. @objc dynamic var filesSharingPublicExpireDateDays : Int = 0
  158. @objc dynamic var isFilesSharingPublicPasswordEnforced: Bool = false
  159. @objc dynamic var isFilesSharingAllowUserSendMail: Bool = false
  160. @objc dynamic var isFilesSharingUserExpireDate: Bool = false
  161. @objc dynamic var isFilesSharingGroupEnabled: Bool = false
  162. @objc dynamic var isFilesSharingGroupExpireDate: Bool = false
  163. @objc dynamic var isFilesSharingFederationAllowUserSendShares: Bool = false
  164. @objc dynamic var isFilesSharingFederationAllowUserReceiveShares: Bool = false
  165. @objc dynamic var isFilesSharingFederationExpireDate: Bool = false
  166. @objc dynamic var isFileSharingShareByMailEnabled: Bool = false
  167. @objc dynamic var isFileSharingShareByMailPassword: Bool = false
  168. @objc dynamic var isFileSharingShareByMailUploadFilesDrop: Bool = false
  169. }
  170. class tableCertificates: Object {
  171. @objc dynamic var certificateLocation = ""
  172. }
  173. class tableDirectory: Object {
  174. @objc dynamic var account = ""
  175. @objc dynamic var dateReadDirectory: NSDate? = nil
  176. @objc dynamic var directoryID = ""
  177. @objc dynamic var e2eEncrypted: Bool = false
  178. @objc dynamic var etag = ""
  179. @objc dynamic var favorite: Bool = false
  180. @objc dynamic var fileID = ""
  181. @objc dynamic var lock: Bool = false
  182. @objc dynamic var offline: Bool = false
  183. @objc dynamic var permissions = ""
  184. @objc dynamic var serverUrl = ""
  185. override static func primaryKey() -> String {
  186. return "directoryID"
  187. }
  188. }
  189. class tableE2eEncryption: Object {
  190. @objc dynamic var account = ""
  191. @objc dynamic var authenticationTag = ""
  192. @objc dynamic var fileName = ""
  193. @objc dynamic var fileNameIdentifier = ""
  194. @objc dynamic var fileNamePath = ""
  195. @objc dynamic var key = ""
  196. @objc dynamic var initializationVector = ""
  197. @objc dynamic var metadataKey = ""
  198. @objc dynamic var metadataKeyIndex: Int = 0
  199. @objc dynamic var mimeType = ""
  200. @objc dynamic var serverUrl = ""
  201. @objc dynamic var version: Int = 1
  202. override static func primaryKey() -> String {
  203. return "fileNamePath"
  204. }
  205. }
  206. class tableE2eEncryptionLock: Object {
  207. @objc dynamic var account = ""
  208. @objc dynamic var date = NSDate()
  209. @objc dynamic var fileID = ""
  210. @objc dynamic var serverUrl = ""
  211. @objc dynamic var token = ""
  212. override static func primaryKey() -> String {
  213. return "fileID"
  214. }
  215. }
  216. class tableExternalSites: Object {
  217. @objc dynamic var account = ""
  218. @objc dynamic var icon = ""
  219. @objc dynamic var idExternalSite: Int = 0
  220. @objc dynamic var lang = ""
  221. @objc dynamic var name = ""
  222. @objc dynamic var type = ""
  223. @objc dynamic var url = ""
  224. }
  225. class tableGPS: Object {
  226. @objc dynamic var latitude = ""
  227. @objc dynamic var location = ""
  228. @objc dynamic var longitude = ""
  229. @objc dynamic var placemarkAdministrativeArea = ""
  230. @objc dynamic var placemarkCountry = ""
  231. @objc dynamic var placemarkLocality = ""
  232. @objc dynamic var placemarkPostalCode = ""
  233. @objc dynamic var placemarkThoroughfare = ""
  234. }
  235. class tableLocalFile: Object {
  236. @objc dynamic var account = ""
  237. @objc dynamic var date = NSDate()
  238. @objc dynamic var etag = ""
  239. @objc dynamic var exifDate = NSDate()
  240. @objc dynamic var exifLatitude = ""
  241. @objc dynamic var exifLongitude = ""
  242. @objc dynamic var favorite: Bool = false
  243. @objc dynamic var fileID = ""
  244. @objc dynamic var fileName = ""
  245. @objc dynamic var offline: Bool = false
  246. @objc dynamic var size: Double = 0
  247. override static func primaryKey() -> String {
  248. return "fileID"
  249. }
  250. }
  251. class tableMetadata: Object {
  252. @objc dynamic var account = ""
  253. @objc dynamic var assetLocalIdentifier = ""
  254. @objc dynamic var date = NSDate()
  255. @objc dynamic var directory: Bool = false
  256. @objc dynamic var e2eEncrypted: Bool = false
  257. @objc dynamic var etag = ""
  258. @objc dynamic var favorite: Bool = false
  259. @objc dynamic var fileID = ""
  260. @objc dynamic var fileName = ""
  261. @objc dynamic var fileNameView = ""
  262. @objc dynamic var hasPreview: Int = -1
  263. @objc dynamic var iconName = ""
  264. @objc dynamic var permissions = ""
  265. @objc dynamic var serverUrl = ""
  266. @objc dynamic var session = ""
  267. @objc dynamic var sessionError = ""
  268. @objc dynamic var sessionSelector = ""
  269. @objc dynamic var sessionTaskIdentifier: Int = 0
  270. @objc dynamic var size: Double = 0
  271. @objc dynamic var status: Int = 0
  272. @objc dynamic var typeFile = ""
  273. @objc dynamic var url = ""
  274. override static func primaryKey() -> String {
  275. return "fileID"
  276. }
  277. }
  278. class tableMedia: Object {
  279. @objc dynamic var account = ""
  280. @objc dynamic var assetLocalIdentifier = ""
  281. @objc dynamic var date = NSDate()
  282. @objc dynamic var directory: Bool = false
  283. @objc dynamic var e2eEncrypted: Bool = false
  284. @objc dynamic var etag = ""
  285. @objc dynamic var favorite: Bool = false
  286. @objc dynamic var fileID = ""
  287. @objc dynamic var fileName = ""
  288. @objc dynamic var fileNameView = ""
  289. @objc dynamic var hasPreview: Int = -1
  290. @objc dynamic var iconName = ""
  291. @objc dynamic var permissions = ""
  292. @objc dynamic var serverUrl = ""
  293. @objc dynamic var session = ""
  294. @objc dynamic var sessionError = ""
  295. @objc dynamic var sessionSelector = ""
  296. @objc dynamic var sessionTaskIdentifier: Int = 0
  297. @objc dynamic var size: Double = 0
  298. @objc dynamic var status: Int = 0
  299. @objc dynamic var typeFile = ""
  300. @objc dynamic var url = ""
  301. override static func primaryKey() -> String {
  302. return "fileID"
  303. }
  304. }
  305. class tablePhotoLibrary: Object {
  306. @objc dynamic var account = ""
  307. @objc dynamic var assetLocalIdentifier = ""
  308. @objc dynamic var creationDate: NSDate? = nil
  309. @objc dynamic var idAsset = ""
  310. @objc dynamic var modificationDate: NSDate? = nil
  311. @objc dynamic var mediaType: Int = 0
  312. override static func primaryKey() -> String {
  313. return "idAsset"
  314. }
  315. }
  316. class tableShare: Object {
  317. @objc dynamic var account = ""
  318. @objc dynamic var fileName = ""
  319. @objc dynamic var serverUrl = ""
  320. @objc dynamic var shareLink = ""
  321. @objc dynamic var shareUserAndGroup = ""
  322. }
  323. class tableTag: Object {
  324. @objc dynamic var account = ""
  325. @objc dynamic var fileID = ""
  326. @objc dynamic var tagIOS: Data? = nil
  327. override static func primaryKey() -> String {
  328. return "fileID"
  329. }
  330. }
  331. class tableTrash: Object {
  332. @objc dynamic var account = ""
  333. @objc dynamic var date = NSDate()
  334. @objc dynamic var directory: Bool = false
  335. @objc dynamic var fileID = ""
  336. @objc dynamic var fileName = ""
  337. @objc dynamic var filePath = ""
  338. @objc dynamic var hasPreview: Int = -1
  339. @objc dynamic var iconName = ""
  340. @objc dynamic var size: Double = 0
  341. @objc dynamic var typeFile = ""
  342. @objc dynamic var trashbinFileName = ""
  343. @objc dynamic var trashbinOriginalLocation = ""
  344. @objc dynamic var trashbinDeletionTime = NSDate()
  345. override static func primaryKey() -> String {
  346. return "fileID"
  347. }
  348. }