NCGlobal.swift 14 KB

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