NCGlobal.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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 UIKit
  24. class NCGlobal: NSObject {
  25. static let shared = NCGlobal()
  26. // ENUM
  27. //
  28. public enum TypeFilterScanDocument: String {
  29. case document = "document"
  30. case original = "original"
  31. }
  32. // Directory on Group
  33. //
  34. let directoryProviderStorage = "File Provider Storage"
  35. let appApplicationSupport = "Library/Application Support"
  36. let appCertificates = "Library/Application Support/Certificates"
  37. let appDatabaseNextcloud = "Library/Application Support/Nextcloud"
  38. let appScan = "Library/Application Support/Scan"
  39. let appUserData = "Library/Application Support/UserData"
  40. // Service
  41. //
  42. let metadataKeyedUnarchiver = "it.twsweb.nextcloud.metadata"
  43. let refreshTask = "com.nextcloud.refreshTask"
  44. let processingTask = "com.nextcloud.processingTask"
  45. // App
  46. //
  47. let appName = "files"
  48. let appScheme = "nextcloud"
  49. let talkName = "talk-message"
  50. let spreedName = "spreed"
  51. let twoFactorNotificatioName = "twofactor_nextcloud_notification"
  52. // Nextcloud version
  53. //
  54. let nextcloudVersion12: Int = 12
  55. let nextcloudVersion15: Int = 15
  56. let nextcloudVersion17: Int = 17
  57. let nextcloudVersion18: Int = 18
  58. let nextcloudVersion20: Int = 20
  59. let nextcloudVersion23: Int = 23
  60. let nextcloudVersion24: Int = 24
  61. let nextcloudVersion25: Int = 25
  62. let nextcloudVersion26: Int = 26
  63. let nextcloudVersion27: Int = 27
  64. let nextcloudVersion28: Int = 28
  65. // Nextcloud unsupported
  66. //
  67. let nextcloud_unsupported_version: Int = 16
  68. // Intro selector
  69. //
  70. let introLogin: Int = 0
  71. let introSignup: Int = 1
  72. // Avatar
  73. //
  74. let avatarSize: Int = 128 * Int(UIScreen.main.scale)
  75. let avatarSizeRounded: Int = 128
  76. // Preview size
  77. //
  78. let size1024: CGSize = CGSize(width: 1024, height: 1024)
  79. let size512: CGSize = CGSize(width: 512, height: 512)
  80. let size256: CGSize = CGSize(width: 256, height: 256)
  81. // Image extension
  82. let previewExt1024 = ".1024.preview.jpg"
  83. let previewExt512 = ".512.preview.jpg"
  84. let previewExt256 = ".256.preview.jpg"
  85. func getSizeExtension(column: Int) -> String {
  86. if column == 0 { return previewExt256 }
  87. let width = UIScreen.main.bounds.width / CGFloat(column)
  88. switch (width * 4) {
  89. case 0...384:
  90. return previewExt256
  91. case 385...768:
  92. return previewExt512
  93. default:
  94. return previewExt1024
  95. }
  96. }
  97. // E2EE
  98. //
  99. let e2eePassphraseTest = "more over television factory tendency independence international intellectual impress interest sentence pony"
  100. let e2eeVersions = ["1.1", "1.2", "2.0"]
  101. let e2eeVersionV11 = "1.1"
  102. let e2eeVersionV12 = "1.2"
  103. let e2eeVersionV20 = "2.0"
  104. // CHUNK
  105. let chunkSizeMBCellular = 10000000
  106. let chunkSizeMBEthernetOrWiFi = 100000000
  107. // Video
  108. //
  109. let maxHTTPCache: Int64 = 10000000000 // 10 GB
  110. let fileNameVideoEncoded: String = "video_encoded.mp4"
  111. // NCViewerProviderContextMenu
  112. //
  113. let maxAutoDownload: UInt64 = 50000000 // 50MB
  114. let maxAutoDownloadCellular: UInt64 = 10000000 // 10MB
  115. // Layout
  116. //
  117. let layoutList = "typeLayoutList"
  118. let layoutGrid = "typeLayoutGrid"
  119. let layoutPhotoRatio = "typeLayoutPhotoRatio"
  120. let layoutPhotoSquare = "typeLayoutPhotoSquare"
  121. let layoutViewTrash = "LayoutTrash"
  122. let layoutViewOffline = "LayoutOffline"
  123. let layoutViewFavorite = "LayoutFavorite"
  124. let layoutViewFiles = "LayoutFiles"
  125. let layoutViewTransfers = "LayoutTransfers"
  126. let layoutViewRecent = "LayoutRecent"
  127. let layoutViewShares = "LayoutShares"
  128. let layoutViewShareExtension = "LayoutShareExtension"
  129. let layoutViewGroupfolders = "LayoutGroupfolders"
  130. let layoutViewMedia = "LayoutMedia"
  131. // Button Type in Cell list/grid
  132. //
  133. let buttonMoreMore = "more"
  134. let buttonMoreLock = "moreLock"
  135. // Standard height sections header/footer
  136. //
  137. let heightButtonsView: CGFloat = 50
  138. let heightHeaderTransfer: CGFloat = 50
  139. let heightSection: CGFloat = 30
  140. let heightFooter: CGFloat = 1
  141. let heightFooterButton: CGFloat = 30
  142. let endHeightFooter: CGFloat = 85
  143. // Text - OnlyOffice - Collabora - QuickLook
  144. //
  145. let editorText = "text"
  146. let editorOnlyoffice = "onlyoffice"
  147. let editorCollabora = "collabora"
  148. let editorQuickLook = "quicklook"
  149. let onlyofficeDocx = "onlyoffice_docx"
  150. let onlyofficeXlsx = "onlyoffice_xlsx"
  151. let onlyofficePptx = "onlyoffice_pptx"
  152. // Template
  153. //
  154. let templateDocument = "document"
  155. let templateSpreadsheet = "spreadsheet"
  156. let templatePresentation = "presentation"
  157. // Rich Workspace
  158. //
  159. let fileNameRichWorkspace = "Readme.md"
  160. // ContentPresenter
  161. //
  162. let dismissAfterSecond: TimeInterval = 4
  163. let dismissAfterSecondLong: TimeInterval = 7
  164. // Error
  165. //
  166. let errorRequestExplicityCancelled: Int = 15
  167. let errorNotModified: Int = 304
  168. let errorBadRequest: Int = 400
  169. let errorUnauthorized401: Int = 401
  170. let errorForbidden: Int = 403
  171. let errorResourceNotFound: Int = 404
  172. let errorMethodNotSupported: Int = 405
  173. let errorConflict: Int = 409
  174. let errorPreconditionFailed: Int = 412
  175. let errorUnsupportedMediaType: Int = 415
  176. let errorInternalServerError: Int = 500
  177. let errorMaintenance: Int = 503
  178. let errorQuota: Int = 507
  179. let errorUnauthorized997: Int = 997
  180. let errorExplicitlyCancelled: Int = -999
  181. let errorConnectionLost: Int = -1005
  182. let errorNetworkNotAvailable: Int = -1009
  183. let errorBadServerResponse: Int = -1011
  184. let errorInternalError: Int = -99999
  185. let errorFileNotSaved: Int = -99998
  186. let errorOffline: Int = -99997
  187. let errorCharactersForbidden: Int = -99996
  188. let errorCreationFile: Int = -99995
  189. let errorReadFile: Int = -99994
  190. let errorUnauthorizedFilesPasscode: Int = -99993
  191. let errorDisableFilesApp: Int = -99992
  192. let errorUnexpectedResponseFromDB: Int = -99991
  193. // E2EE
  194. let errorE2EENotEnabled: Int = -98000
  195. let errorE2EEVersion: Int = -98001
  196. let errorE2EEKeyChecksums: Int = -98002
  197. let errorE2EEKeyEncodeMetadata: Int = -98003
  198. let errorE2EEKeyDecodeMetadata: Int = -98004
  199. let errorE2EEKeyVerifySignature: Int = -98005
  200. let errorE2EEKeyCiphertext: Int = -98006
  201. let errorE2EEKeyFiledropCiphertext: Int = -98007
  202. let errorE2EEJSon: Int = -98008
  203. let errorE2EELock: Int = -98009
  204. let errorE2EEEncryptFile: Int = -98010
  205. let errorE2EEEncryptPayloadFile: Int = -98011
  206. let errorE2EECounter: Int = -98012
  207. let errorE2EEGenerateKey: Int = -98013
  208. let errorE2EEEncodedKey: Int = -98014
  209. let errorE2EENoUserFound: Int = -98015
  210. let errorE2EEUploadInProgress: Int = -98016
  211. // Selector
  212. //
  213. let selectorDownloadFile = "downloadFile"
  214. let selectorReadFile = "readFile"
  215. let selectorListingFavorite = "listingFavorite"
  216. let selectorLoadFileView = "loadFileView"
  217. let selectorLoadFileQuickLook = "loadFileQuickLook"
  218. let selectorOpenIn = "openIn"
  219. let selectorUploadAutoUpload = "uploadAutoUpload"
  220. let selectorUploadAutoUploadAll = "uploadAutoUploadAll"
  221. let selectorUploadFile = "uploadFile"
  222. let selectorUploadFileNODelete = "UploadFileNODelete"
  223. let selectorUploadFileShareExtension = "uploadFileShareExtension"
  224. let selectorSaveAlbum = "saveAlbum"
  225. let selectorSaveAsScan = "saveAsScan"
  226. let selectorOpenDetail = "openDetail"
  227. let selectorSynchronizationOffline = "synchronizationOffline"
  228. // Metadata : Status
  229. //
  230. // 0 normal
  231. // ± 1 wait download/upload
  232. // ± 2 downloading/uploading
  233. // ± 3 error
  234. //
  235. let metadataStatusNormal: Int = 0
  236. let metadataStatusWaitDownload: Int = -1
  237. let metadataStatusDownloading: Int = -2
  238. let metadataStatusDownloadError: Int = -3
  239. let metadataStatusWaitUpload: Int = 1
  240. let metadataStatusUploading: Int = 2
  241. let metadataStatusUploadError: Int = 3
  242. let metadataStatusWaitCreateFolder: Int = 10
  243. let metadataStatusWaitDelete: Int = 11
  244. let metadataStatusWaitRename: Int = 12
  245. let metadataStatusWaitFavorite: Int = 13
  246. let metadataStatusWaitCopy: Int = 14
  247. let metadataStatusWaitMove: Int = 15
  248. let metadataStatusInTransfer = [-1, -2, 1, 2]
  249. let metadataStatusFileDown = [-1, -2, -3]
  250. let metadataStatusHideInView = [1, 2, 3, 11]
  251. let metadataStatusHideInFileExtension = [1, 2, 3, 10, 11]
  252. let metadataStatusObserve = [-1, 1, 10, 11, 12, 13, 14, 15]
  253. let metadataStatusWaitWebDav = [10, 11, 12, 13, 14, 15]
  254. // Auto upload subfolder granularity
  255. //
  256. let subfolderGranularityDaily = 2
  257. let subfolderGranularityMonthly = 1
  258. let subfolderGranularityYearly = 0
  259. // Notification Center
  260. //
  261. let notificationCenterChangeUser = "changeUser" // userInfo: account, controller
  262. let notificationCenterChangeTheming = "changeTheming" // userInfo: account
  263. let notificationCenterRichdocumentGrabFocus = "richdocumentGrabFocus"
  264. let notificationCenterReloadDataNCShare = "reloadDataNCShare"
  265. let notificationCenterCloseRichWorkspaceWebView = "closeRichWorkspaceWebView"
  266. let notificationCenterReloadAvatar = "reloadAvatar"
  267. let notificationCenterClearCache = "clearCache"
  268. let notificationCenterChangeLayout = "changeLayout" // userInfo: account, serverUrl, layoutForView
  269. let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl?, clearDataSource
  270. let notificationCenterGetServerData = "getServerData" // userInfo: serverUrl?
  271. let notificationCenterChangeStatusFolderE2EE = "changeStatusFolderE2EE" // userInfo: serverUrl
  272. let notificationCenterDownloadStartFile = "downloadStartFile" // userInfo: ocId, ocIdTransfer, session, serverUrl, account
  273. let notificationCenterDownloadedFile = "downloadedFile" // userInfo: ocId, ocIdTransfer, session, session, serverUrl, account, selector, error
  274. let notificationCenterDownloadCancelFile = "downloadCancelFile" // userInfo: ocId, ocIdTransfer, session, serverUrl, account
  275. let notificationCenterUploadStartFile = "uploadStartFile" // userInfo: ocId, ocIdTransfer, session, serverUrl, account, fileName, sessionSelector
  276. let notificationCenterUploadedFile = "uploadedFile" // userInfo: ocId, ocIdTransfer, session, serverUrl, account, fileName, ocIdTransfer, error
  277. let notificationCenterUploadedLivePhoto = "uploadedLivePhoto" // userInfo: ocId, ocIdTransfer, session, serverUrl, account, fileName, ocIdTransfer, error
  278. let notificationCenterUploadCancelFile = "uploadCancelFile" // userInfo: ocId, ocIdTransfer, session, serverUrl, account
  279. let notificationCenterProgressTask = "progressTask" // userInfo: account, ocId, ocIdTransfer, session, serverUrl, status, chunk, e2eEncrypted, progress, totalBytes, totalBytesExpected
  280. let notificationCenterUpdateBadgeNumber = "updateBadgeNumber" // userInfo: counterDownload, counterUpload
  281. let notificationCenterCreateFolder = "createFolder" // userInfo: ocId, serverUrl, account, withPush, sceneIdentifier
  282. let notificationCenterDeleteFile = "deleteFile" // userInfo: [ocId], error
  283. let notificationCenterCopyMoveFile = "copyMoveFile" // userInfo: [ocId] serverUrl, account, dragdrop, type (copy, move)
  284. let notificationCenterRenameFile = "renameFile" // userInfo: serverUrl, account, error
  285. let notificationCenterFavoriteFile = "favoriteFile" // userInfo: ocId, serverUrl
  286. let notificationCenterFileExists = "fileExists" // userInfo: ocId, fileExists
  287. let notificationCenterMenuSearchTextPDF = "menuSearchTextPDF"
  288. let notificationCenterMenuGotToPageInPDF = "menuGotToPageInPDF"
  289. let notificationCenterOpenMediaDetail = "openMediaDetail" // userInfo: ocId
  290. let notificationCenterDismissScanDocument = "dismissScanDocument"
  291. let notificationCenterDismissUploadAssets = "dismissUploadAssets"
  292. let notificationCenterEnableSwipeGesture = "enableSwipeGesture"
  293. let notificationCenterDisableSwipeGesture = "disableSwipeGesture"
  294. let notificationCenterPlayerIsPlaying = "playerIsPlaying"
  295. let notificationCenterPlayerStoppedPlaying = "playerStoppedPlaying"
  296. // TIP
  297. //
  298. let tipNCViewerPDFThumbnail = "tipncviewerpdfthumbnail"
  299. let tipNCCollectionViewCommonAccountRequest = "tipnccollectionviewcommonaccountrequest"
  300. let tipNCScanAddImage = "tipncscanaddimage"
  301. let tipNCViewerMediaDetailView = "tipncviewermediadetailview"
  302. // ACTION
  303. //
  304. let actionNoAction = "no-action"
  305. let actionUploadAsset = "upload-asset"
  306. let actionScanDocument = "add-scan-document"
  307. let actionTextDocument = "create-text-document"
  308. let actionVoiceMemo = "create-voice-memo"
  309. // WIDGET ACTION
  310. //
  311. let widgetActionNoAction = "nextcloud://open-action?action=no-action"
  312. let widgetActionUploadAsset = "nextcloud://open-action?action=upload-asset"
  313. let widgetActionScanDocument = "nextcloud://open-action?action=add-scan-document"
  314. let widgetActionTextDocument = "nextcloud://open-action?action=create-text-document"
  315. let widgetActionVoiceMemo = "nextcloud://open-action?action=create-voice-memo"
  316. // APPCONFIG
  317. //
  318. let configuration_brand = "brand"
  319. let configuration_serverUrl = "serverUrl"
  320. let configuration_username = "username"
  321. let configuration_password = "password"
  322. let configuration_apppassword = "apppassword"
  323. let configuration_disable_intro = "disable_intro"
  324. let configuration_disable_multiaccount = "disable_multiaccount"
  325. let configuration_disable_crash_service = "disable_crash_service"
  326. let configuration_disable_log = "disable_log"
  327. let configuration_disable_more_external_site = "disable_more_external_site"
  328. let configuration_disable_openin_file = "disable_openin_file"
  329. // MORE NEXTCLOUD APPS
  330. //
  331. let talkSchemeUrl = "nextcloudtalk://"
  332. let notesSchemeUrl = "nextcloudnotes://"
  333. let talkAppStoreUrl = "https://apps.apple.com/in/app/nextcloud-talk/id1296825574"
  334. let notesAppStoreUrl = "https://apps.apple.com/in/app/nextcloud-notes/id813973264"
  335. let moreAppsUrl = "itms-apps://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=nextcloud"
  336. // SNAPSHOT PREVIEW
  337. //
  338. let defaultSnapshotConfiguration = "DefaultPreviewConfiguration"
  339. // FORBIDDEN CHARACTERS
  340. //
  341. // TODO: Remove this
  342. let forbiddenCharacters = ["/", "\\", ":", "\"", "|", "?", "*", "<", ">"]
  343. // DIAGNOSTICS CLIENTS
  344. //
  345. let diagnosticIssueSyncConflicts = "sync_conflicts"
  346. let diagnosticIssueProblems = "problems"
  347. let diagnosticIssueVirusDetected = "virus_detected"
  348. let diagnosticIssueE2eeErrors = "e2ee_errors"
  349. let diagnosticProblemsForbidden = "CHARACTERS_FORBIDDEN"
  350. let diagnosticProblemsBadResponse = "BAD_SERVER_RESPONSE"
  351. let diagnosticProblemsUploadServerError = "UploadError.SERVER_ERROR"
  352. // MEDIA LAYOUT
  353. //
  354. let mediaLayoutRatio = "mediaLayoutRatio"
  355. let mediaLayoutSquare = "mediaLayoutSquare"
  356. // DRAG & DROP
  357. //
  358. let metadataOcIdDataRepresentation = "text/com.nextcloud.ocId"
  359. // GROUP AMIN
  360. //
  361. let groupAdmin = "admin"
  362. // DATA TASK DESCRIPTION
  363. //
  364. let taskDescriptionRetrievesProperties = "retrievesProperties"
  365. let taskDescriptionSynchronization = "synchronization"
  366. let taskDescriptionDeleteFileOrFolder = "deleteFileOrFolder"
  367. }