NCGlobal.swift 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. //
  2. // NCGlobal.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 22/02/21.
  6. // Copyright © 2021 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 Foundation
  24. class NCGlobal: NSObject {
  25. @objc static let shared: NCGlobal = {
  26. let instance = NCGlobal()
  27. return instance
  28. }()
  29. // Struct for Progress
  30. //
  31. struct progressType {
  32. var progress: Float
  33. var totalBytes: Int64
  34. var totalBytesExpected: Int64
  35. }
  36. // Struct for LayoutForView
  37. //
  38. struct layoutForViewType {
  39. var layout: String
  40. var sort: String
  41. var ascending: Bool
  42. var groupBy: String
  43. var directoryOnTop: Bool
  44. var titleButtonHeader: String
  45. var itemForLine: Int
  46. var imageBackgroud: String
  47. var imageBackgroudContentMode: String
  48. var colorBackground: String
  49. }
  50. // Directory on Group
  51. //
  52. @objc let appDatabaseNextcloud = "Library/Application Support/Nextcloud"
  53. @objc let appApplicationSupport = "Library/Application Support"
  54. @objc let appUserData = "Library/Application Support/UserData"
  55. @objc let appCertificates = "Library/Application Support/Certificates"
  56. @objc let appScan = "Library/Application Support/Scan"
  57. @objc let appBackground = "Library/Application Support/Background"
  58. @objc let directoryProviderStorage = "File Provider Storage"
  59. // Service
  60. //
  61. @objc let serviceShareKeyChain = "Crypto Cloud"
  62. let metadataKeyedUnarchiver = "it.twsweb.nextcloud.metadata"
  63. let refreshTask = "com.nextcloud.refreshTask"
  64. let processingTask = "com.nextcloud.processingTask"
  65. // Nextcloud version
  66. //
  67. let nextcloudVersion12: Int = 12
  68. let nextcloudVersion15: Int = 15
  69. let nextcloudVersion17: Int = 17
  70. let nextcloudVersion18: Int = 18
  71. let nextcloudVersion20: Int = 20
  72. // Database Realm
  73. //
  74. let databaseDefault = "nextcloud.realm"
  75. let databaseSchemaVersion: UInt64 = 175
  76. // Intro selector
  77. //
  78. @objc let introLogin: Int = 0
  79. let introSignup: Int = 1
  80. // Avatar & Preview size
  81. //
  82. let avatarSize: Int = 512
  83. let sizePreview: Int = 1024
  84. let sizeIcon: Int = 512
  85. // E2EE
  86. //
  87. let e2eeMaxFileSize: UInt64 = 500000000 // 500 MB
  88. let e2eePassphraseTest = "more over television factory tendency independence international intellectual impress interest sentence pony"
  89. @objc let e2eeVersion = "1.1"
  90. // Max Cache Proxy Video
  91. //
  92. let maxHTTPCache: Int64 = 10000000000 // 10 GB
  93. // NCSharePaging
  94. //
  95. let indexPageActivity: Int = 0
  96. let indexPageComments: Int = 1
  97. let indexPageSharing: Int = 2
  98. // NCViewerProviderContextMenu
  99. //
  100. let maxAutoDownload: UInt64 = 50000000 // 50MB
  101. let maxAutoDownloadCellular: UInt64 = 10000000 // 10MB
  102. // Nextcloud unsupported
  103. //
  104. let nextcloud_unsupported_version: Int = 13
  105. // Layout
  106. //
  107. let layoutList = "typeLayoutList"
  108. let layoutGrid = "typeLayoutGrid"
  109. let layoutViewMove = "LayoutMove"
  110. let layoutViewTrash = "LayoutTrash"
  111. let layoutViewOffline = "LayoutOffline"
  112. let layoutViewFavorite = "LayoutFavorite"
  113. let layoutViewFiles = "LayoutFiles"
  114. let layoutViewViewInFolder = "LayoutViewInFolder"
  115. let layoutViewTransfers = "LayoutTransfers"
  116. let layoutViewRecent = "LayoutRecent"
  117. let layoutViewShares = "LayoutShares"
  118. let layoutViewShareExtension = "LayoutShareExtension"
  119. // Button Type in Cell list/grid
  120. //
  121. let buttonMoreMore = "more"
  122. let buttonMoreStop = "stop"
  123. // Text - OnlyOffice - Collabora
  124. //
  125. let editorText = "text"
  126. let editorOnlyoffice = "onlyoffice"
  127. let editorCollabora = "collabora"
  128. let onlyofficeDocx = "onlyoffice_docx"
  129. let onlyofficeXlsx = "onlyoffice_xlsx"
  130. let onlyofficePptx = "onlyoffice_pptx"
  131. // Template
  132. //
  133. let templateDocument = "document"
  134. let templateSpreadsheet = "spreadsheet"
  135. let templatePresentation = "presentation"
  136. // Rich Workspace
  137. //
  138. let fileNameRichWorkspace = "Readme.md"
  139. // ContentPresenter
  140. //
  141. @objc let dismissAfterSecond: TimeInterval = 4
  142. @objc let dismissAfterSecondLong: TimeInterval = 10
  143. // Error
  144. //
  145. @objc let errorRequestExplicityCancelled: Int = 15
  146. @objc let errorBadRequest: Int = 400
  147. @objc let errorResourceNotFound: Int = 404
  148. @objc let errordMethodNotSupported: Int = 405
  149. @objc let errorConflict: Int = 409
  150. @objc let errorConnectionLost: Int = -1005
  151. @objc let errorBadServerResponse: Int = -1011
  152. @objc let errorInternalError: Int = -99999
  153. @objc let errorFileNotSaved: Int = -99998
  154. @objc let errorDecodeMetadata: Int = -99997
  155. @objc let errorE2EENotEnabled: Int = -99996
  156. @objc let errorOffline: Int = -99994
  157. @objc let errorCharactersForbidden: Int = -99993
  158. @objc let errorCreationFile: Int = -99992
  159. @objc let errorReadFile: Int = -99991
  160. // Constants to identify the different permissions of a file
  161. //
  162. @objc let permissionShared = "S"
  163. @objc let permissionCanShare = "R"
  164. @objc let permissionMounted = "M"
  165. @objc let permissionFileCanWrite = "W"
  166. @objc let permissionCanCreateFile = "C"
  167. @objc let permissionCanCreateFolder = "K"
  168. @objc let permissionCanDelete = "D"
  169. @objc let permissionCanRename = "N"
  170. @objc let permissionCanMove = "V"
  171. //Share permission
  172. //permissions - (int) 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1)
  173. //
  174. @objc let permissionReadShare: Int = 1
  175. @objc let permissionUpdateShare: Int = 2
  176. @objc let permissionCreateShare: Int = 4
  177. @objc let permissionDeleteShare: Int = 8
  178. @objc let permissionShareShare: Int = 16
  179. @objc let permissionMinFileShare: Int = 1
  180. @objc let permissionMaxFileShare: Int = 19
  181. @objc let permissionMinFolderShare: Int = 1
  182. @objc let permissionMaxFolderShare: Int = 31
  183. @objc let permissionDefaultFileRemoteShareNoSupportShareOption: Int = 3
  184. @objc let permissionDefaultFolderRemoteShareNoSupportShareOption: Int = 15
  185. // Metadata : FileType
  186. //
  187. @objc let metadataTypeFileAudio = "audio"
  188. @objc let metadataTypeFileCompress = "compress"
  189. @objc let metadataTypeFileDirectory = "directory"
  190. @objc let metadataTypeFileDocument = "document"
  191. @objc let metadataTypeFileImage = "image"
  192. @objc let metadataTypeFileUnknown = "unknow"
  193. @objc let metadataTypeFileVideo = "video"
  194. @objc let metadataTypeFileImagemeter = "imagemeter"
  195. // Filename Mask and Type
  196. //
  197. let keyFileNameMask = "fileNameMask"
  198. let keyFileNameType = "fileNameType"
  199. let keyFileNameAutoUploadMask = "fileNameAutoUploadMask"
  200. let keyFileNameAutoUploadType = "fileNameAutoUploadType"
  201. let keyFileNameOriginal = "fileNameOriginal"
  202. let keyFileNameOriginalAutoUpload = "fileNameOriginalAutoUpload"
  203. // Selector
  204. //
  205. let selectorDownloadFile = "downloadFile"
  206. let selectorDownloadAllFile = "downloadAllFile"
  207. let selectorReadFile = "readFile"
  208. let selectorListingFavorite = "listingFavorite"
  209. let selectorLoadFileView = "loadFileView"
  210. let selectorLoadFileQuickLook = "loadFileQuickLook"
  211. let selectorLoadCopy = "loadCopy"
  212. let selectorLoadOffline = "loadOffline"
  213. let selectorOpenIn = "openIn"
  214. let selectorPrint = "print"
  215. let selectorUploadAutoUpload = "uploadAutoUpload"
  216. let selectorUploadAutoUploadAll = "uploadAutoUploadAll"
  217. let selectorUploadFile = "uploadFile"
  218. let selectorSaveAlbum = "saveAlbum"
  219. let selectorSaveBackground = "saveBackground"
  220. let selectorSaveAlbumLivePhotoIMG = "saveAlbumLivePhotoIMG"
  221. let selectorSaveAlbumLivePhotoMOV = "saveAlbumLivePhotoMOV"
  222. // Metadata : Status
  223. //
  224. // 1) wait download/upload
  225. // 2) in download/upload
  226. // 3) downloading/uploading
  227. // 4) done or error
  228. //
  229. let metadataStatusNormal: Int = 0
  230. let metadataStatustypeDownload: Int = 1
  231. let metadataStatusWaitDownload: Int = 2
  232. let metadataStatusInDownload: Int = 3
  233. let metadataStatusDownloading: Int = 4
  234. let metadataStatusDownloadError: Int = 5
  235. let metadataStatusTypeUpload: Int = 6
  236. let metadataStatusWaitUpload: Int = 7
  237. let metadataStatusInUpload: Int = 8
  238. let metadataStatusUploading: Int = 9
  239. let metadataStatusUploadError: Int = 10
  240. let metadataStatusUploadForcedStart: Int = 11
  241. // Notification Center
  242. //
  243. @objc let notificationCenterApplicationDidEnterBackground = "applicationDidEnterBackground"
  244. let notificationCenterApplicationWillEnterForeground = "applicationWillEnterForeground"
  245. let notificationCenterApplicationDidBecomeActive = "applicationDidBecomeActive"
  246. @objc let notificationCenterInitializeMain = "initializeMain"
  247. @objc let notificationCenterChangeTheming = "changeTheming"
  248. let notificationCenterRichdocumentGrabFocus = "richdocumentGrabFocus"
  249. let notificationCenterReloadDataNCShare = "reloadDataNCShare"
  250. let notificationCenterCloseRichWorkspaceWebView = "closeRichWorkspaceWebView"
  251. let notificationCenterUpdateBadgeNumber = "updateBadgeNumber"
  252. @objc let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: ocId?, serverUrl?
  253. let notificationCenterReloadDataSourceNetworkForced = "reloadDataSourceNetworkForced" // userInfo: serverUrl?
  254. let notificationCenterChangeStatusFolderE2EE = "changeStatusFolderE2EE" // userInfo: serverUrl
  255. let notificationCenterDownloadStartFile = "downloadStartFile" // userInfo: ocId
  256. let notificationCenterDownloadedFile = "downloadedFile" // userInfo: ocId, selector, errorCode, errorDescription
  257. let notificationCenterDownloadCancelFile = "downloadCancelFile" // userInfo: ocId
  258. let notificationCenterUploadStartFile = "uploadStartFile" // userInfo: ocId
  259. @objc let notificationCenterUploadedFile = "uploadedFile" // userInfo: ocId, ocIdTemp, errorCode, errorDescription
  260. let notificationCenterUploadCancelFile = "uploadCancelFile" // userInfo: ocId, serverUrl, account
  261. let notificationCenterProgressTask = "progressTask" // userInfo: account, ocId, serverUrl, status, progress, totalBytes, totalBytesExpected
  262. let notificationCenterCreateFolder = "createFolder" // userInfo: ocId
  263. let notificationCenterDeleteFile = "deleteFile" // userInfo: ocId, fileNameView, typeFile, onlyLocal
  264. let notificationCenterRenameFile = "renameFile" // userInfo: ocId, errorCode, errorDescription
  265. let notificationCenterMoveFile = "moveFile" // userInfo: ocId, serverUrlTo
  266. let notificationCenterCopyFile = "copyFile" // userInfo: ocId, serverUrlFrom
  267. let notificationCenterFavoriteFile = "favoriteFile" // userInfo: ocId
  268. let notificationCenterMenuSearchTextPDF = "menuSearchTextPDF"
  269. let notificationCenterMenuDetailClose = "menuDetailClose"
  270. let notificationCenterChangedLocation = "changedLocation"
  271. let notificationStatusAuthorizationChangedLocation = "statusAuthorizationChangedLocation"
  272. }
  273. //let rootView = UIApplication.shared.keyWindow?.rootViewController?.view
  274. //DispatchQueue.main.async
  275. //DispatchQueue.main.asyncAfter(deadline: .now() + 0.1)
  276. //DispatchQueue.global().async
  277. //DispatchQueue.global(qos: .background).async
  278. //#if targetEnvironment(simulator)
  279. //#endif
  280. //dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  281. //dispatch_async(dispatch_get_main_queue(), ^{
  282. //dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  283. //#if TARGET_OS_SIMULATOR
  284. //#endif