* WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * refactor: persist NKError kind and simplify user-friendly error messages Signed-off-by: Milen Pivchev <[email protected]> * refactor: detect virus-blocked uploads via NKError kind Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> * WIP Signed-off-by: Milen Pivchev <[email protected]> --------- Signed-off-by: Milen Pivchev <[email protected]>
405 lines
19 KiB
Swift
405 lines
19 KiB
Swift
// SPDX-FileCopyrightText: Nextcloud GmbH
|
|
// SPDX-FileCopyrightText: 2021 Marino Faggiana
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import UIKit
|
|
|
|
final class NCGlobal: Sendable {
|
|
static let shared = NCGlobal()
|
|
|
|
init() { }
|
|
|
|
// ENUM
|
|
//
|
|
public enum TypeFilterScanDocument: String {
|
|
case document = "document"
|
|
case original = "original"
|
|
}
|
|
|
|
// Directory on Group
|
|
//
|
|
let directoryProviderStorage = "File Provider Storage"
|
|
let appApplicationSupport = "Library/Application Support"
|
|
let appCertificates = "Library/Application Support/Certificates"
|
|
let appDatabaseNextcloud = "Library/Application Support/Nextcloud"
|
|
let appScan = "Library/Application Support/Scan"
|
|
let appUserData = "Library/Application Support/UserData"
|
|
|
|
// Service
|
|
//
|
|
let metadataKeyedUnarchiver = "it.twsweb.nextcloud.metadata"
|
|
let refreshTask = "com.nextcloud.refreshTask"
|
|
let processingTask = "com.nextcloud.processingTask"
|
|
|
|
// App
|
|
//
|
|
let appName = "files"
|
|
let appScheme = "nextcloud"
|
|
let talkName = "talk-message"
|
|
let spreedName = "spreed"
|
|
let twoFactorNotificatioName = "twofactor_nextcloud_notification"
|
|
let termsOfServiceName = "terms_of_service"
|
|
|
|
// OFFICE
|
|
//
|
|
let editorText: String = "text"
|
|
let editorEuroOffice: String = "eurooffice"
|
|
let editorCollabora: String = "richdocuments"
|
|
let editorOnlyOffice: String = "onlyoffice"
|
|
let editorWhiteboard: String = "whiteboard"
|
|
|
|
// Intro selector
|
|
//
|
|
let introLogin: Int = 0
|
|
let introSignUpWithProvider: Int = 1
|
|
|
|
// Avatar
|
|
//
|
|
// Shared download resolution for a 128-point avatar at 3x scale, also used without a UI context.
|
|
let avatarSize: Int = 384
|
|
let avatarSizeRounded: Int = 128
|
|
|
|
// Preview size
|
|
//
|
|
let size1024: CGSize = CGSize(width: 1024, height: 1024)
|
|
let size512: CGSize = CGSize(width: 512, height: 512)
|
|
let size256: CGSize = CGSize(width: 256, height: 256)
|
|
// Image extension
|
|
let previewExt1024 = ".1024.preview.jpg"
|
|
let previewExt512 = ".512.preview.jpg"
|
|
let previewExt256 = ".256.preview.jpg"
|
|
|
|
func getSizeExtension(column: Int, viewWidth: CGFloat) -> String {
|
|
if column == 0 { return previewExt256 }
|
|
let width = viewWidth / CGFloat(column)
|
|
|
|
switch (width * 4) {
|
|
case 0...384:
|
|
return previewExt256
|
|
case 385...768:
|
|
return previewExt512
|
|
default:
|
|
return previewExt1024
|
|
}
|
|
}
|
|
|
|
// MEDIA SEARCH
|
|
let mediaPropOrder = "getlastmodified"
|
|
|
|
// E2EE
|
|
//
|
|
let e2eePassphraseTest = "more over television factory tendency independence international intellectual impress interest sentence pony"
|
|
|
|
// CHUNK
|
|
let chunkSize = 100000000
|
|
|
|
// Layout
|
|
//
|
|
let layoutList = "typeLayoutList"
|
|
let layoutGrid = "typeLayoutGrid"
|
|
let layoutPhotoRatio = "typeLayoutPhotoRatio"
|
|
let layoutPhotoSquare = "typeLayoutPhotoSquare"
|
|
|
|
let layoutViewTrash = "LayoutTrash"
|
|
let layoutViewOffline = "LayoutOffline"
|
|
let layoutViewFavorite = "LayoutFavorite"
|
|
let layoutViewFiles = "LayoutFiles"
|
|
let layoutViewRecent = "LayoutRecent"
|
|
let layoutViewShares = "LayoutShares"
|
|
let layoutViewShareExtension = "LayoutShareExtension"
|
|
let layoutViewGroupfolders = "LayoutGroupfolders"
|
|
let layoutViewMedia = "LayoutMedia"
|
|
|
|
// Button Type in Cell list/grid
|
|
//
|
|
let buttonMoreMore = "more"
|
|
let buttonMoreLock = "moreLock"
|
|
|
|
// Rich Workspace
|
|
//
|
|
let fileNameRichWorkspace = "Readme.md"
|
|
|
|
// ContentPresenter
|
|
//
|
|
let dismissAfterSecond: TimeInterval = 5
|
|
let dismissAfterSecondLong: TimeInterval = 8
|
|
|
|
// Error
|
|
//
|
|
let errorNotModified: Int = 304
|
|
let errorBadRequest: Int = 400
|
|
let errorUnauthorized: Int = 401
|
|
let errorForbidden: Int = 403
|
|
let errorResourceNotFound: Int = 404
|
|
let errorMethodNotSupported: Int = 405
|
|
let errorConflict: Int = 409
|
|
let errorPreconditionFailed: Int = 412
|
|
let errorExpectationFailed: Int = 417
|
|
let errorInternalServerError: Int = 500
|
|
let errorMaintenance: Int = 503
|
|
let errorQuota: Int = 507
|
|
let errorUnauthorized997: Int = 997
|
|
let errorExplicitlyCancelled: Int = -999
|
|
let errorConnectionLost: Int = -1005
|
|
let errorNetworkNotAvailable: Int = -1009
|
|
let errorBadServerResponse: Int = -1011
|
|
let errorInternalError: Int = -99999
|
|
let errorFileNotSaved: Int = -99998
|
|
let errorOfflineNotAllowed: Int = -99997
|
|
let errorCharactersForbidden: Int = -99996
|
|
let errorCreationFile: Int = -99995
|
|
let errorReadFile: Int = -99994
|
|
let errorUnauthorizedFilesPasscode: Int = -99993
|
|
let errorDisableFilesApp: Int = -99992
|
|
let errorUnexpectedResponseFromDB: Int = -99991
|
|
let errorIncorrectFileName: Int = -99990
|
|
let errorVersionMismatch: Int = -99989
|
|
let errorNCSessionNotFound: Int = -99988
|
|
let errorNotPermission: Int = -99987
|
|
let errorTaskCancelled: Int = -99986
|
|
|
|
|
|
// E2EE
|
|
let errorE2EENotEnabled: Int = -98000
|
|
let errorE2EEVersion: Int = -98001
|
|
let errorE2EEKeyChecksums: Int = -98002
|
|
let errorE2EEKeyChecksumsEmpty: Int = -98003
|
|
let errorE2EEKeyEncodeMetadata: Int = -98004
|
|
let errorE2EEKeyDecodeMetadataV12: Int = -98005
|
|
let errorE2EEKeyVerifySignature: Int = -98006
|
|
let errorE2EEKeyVerifySignatureEmpty: Int = -98007
|
|
let errorE2EEKeyCiphertext: Int = -98008
|
|
let errorE2EEKeyFiledropCiphertext: Int = -98009
|
|
let errorE2EEJSon: Int = -98010
|
|
let errorE2EELock: Int = -98011
|
|
let errorE2EEEncryptFile: Int = -98012
|
|
let errorE2EEEncryptPayloadFile: Int = -98013
|
|
let errorE2EECounter: Int = -98014
|
|
let errorE2EEGenerateKey: Int = -98015
|
|
let errorE2EEEncodedKey: Int = -98016
|
|
let errorE2EENoUserFound: Int = -98017
|
|
let errorE2EEUploadInProgress: Int = -98018
|
|
let errorE2EEKeyDirectoryTop: Int = -98019
|
|
let errorE2EESendMetadata: Int = -98020
|
|
let errorE2EEReadOnly: Int = -98021
|
|
let errorE2EEServerKeyChanged: Int = -98022
|
|
|
|
|
|
// Selector
|
|
//
|
|
let selectorLoadFileView = "loadFileView"
|
|
let selectorLoadFileQuickLook = "loadFileQuickLook"
|
|
let selectorOpenIn = "openIn"
|
|
|
|
let selectorDownloadFile = "downloadFile"
|
|
|
|
let selectorUploadAutoUpload = "uploadAutoUpload"
|
|
let selectorUploadFile = "uploadFile"
|
|
let selectorUploadFileShareExtension = "uploadFileShareExtension"
|
|
|
|
let selectorSaveAlbum = "saveAlbum"
|
|
let selectorSaveAsScan = "saveAsScan"
|
|
let selectorOpenDetail = "openDetail"
|
|
let selectorSynchronizationOffline = "synchronizationOffline"
|
|
|
|
// Metadata : Status
|
|
//
|
|
// 0 normal
|
|
// ± 1 wait download/upload
|
|
// ± 2 downloading/uploading
|
|
// ± 3 error
|
|
//
|
|
let metadataStatusNormal: Int = 0
|
|
|
|
let metadataStatusWaitDownload: Int = -1
|
|
let metadataStatusDownloading: Int = -2
|
|
let metadataStatusDownloadError: Int = -3
|
|
|
|
let metadataStatusWaitUpload: Int = 1
|
|
let metadataStatusUploading: Int = 2
|
|
let metadataStatusUploadError: Int = 3
|
|
|
|
let metadataStatusWaitCreateFolder: Int = 10
|
|
let metadataStatusWaitDelete: Int = 11
|
|
let metadataStatusWaitRename: Int = 12
|
|
let metadataStatusWaitFavorite: Int = 13
|
|
let metadataStatusWaitCopy: Int = 14
|
|
let metadataStatusWaitMove: Int = 15
|
|
|
|
let metadataStatusUploadingAllMode = [1,2,3]
|
|
let metadataStatusDownloadingAllMode = [-1, -2, -3]
|
|
let metadataStatusForScreenAwake = [-1, -2, 1, 2]
|
|
let metadataStatusHideInView = [1, 2, 3, 11]
|
|
let metadataStatusWaitWebDav = [10, 11, 12, 13, 14, 15]
|
|
|
|
let metadatasStatusInWaiting = [-1, 1, 10, 11, 12, 13, 14, 15]
|
|
let metadatasStatusInError = [-3, 3]
|
|
let metadatasStatusInWaitingDownloadUpload = [-1, 1]
|
|
let metadatasStatusDownloadingUploading = [-2, 2]
|
|
|
|
// Auto upload subfolder granularity
|
|
//
|
|
let subfolderGranularityDaily = 2
|
|
let subfolderGranularityMonthly = 1
|
|
let subfolderGranularityYearly = 0
|
|
|
|
// Notification Center
|
|
//
|
|
let notificationCenterChangeUser = "changeUser" // userInfo: account, controller
|
|
let notificationCenterChangeTheming = "changeTheming" // userInfo: account
|
|
let notificationCenterRichdocumentGrabFocus = "richdocumentGrabFocus"
|
|
let notificationCenterReloadDataNCShare = "reloadDataNCShare"
|
|
let notificationCenterCloseRichWorkspaceWebView = "closeRichWorkspaceWebView"
|
|
let notificationCenterReloadAvatar = "reloadAvatar"
|
|
let notificationCenterCheckUserDelaultErrorDone = "checkUserDelaultErrorDone" // userInfo: account, controller
|
|
let notificationCenterServerDidUpdate = "serverDidUpdate" // userInfo: account
|
|
let notificationCenterNetworkReachability = "networkReachability"
|
|
|
|
let notificationCenterMenuSearchTextPDF = "menuSearchTextPDF"
|
|
let notificationCenterMenuGotToPageInPDF = "menuGotToPageInPDF"
|
|
|
|
let notificationCenterOpenMediaDetail = "openMediaDetail" // userInfo: ocId
|
|
|
|
let notificationCenterDismissScanDocument = "dismissScanDocument"
|
|
|
|
let notificationCenterEnableSwipeGesture = "enableSwipeGesture"
|
|
let notificationCenterDisableSwipeGesture = "disableSwipeGesture"
|
|
|
|
let notificationCenterPlayerIsPlaying = "playerIsPlaying"
|
|
let notificationCenterPlayerStoppedPlaying = "playerStoppedPlaying"
|
|
|
|
let notificationCenterUserInteractionMonitor = "serInteractionMonitor"
|
|
|
|
let notificationCenterNetworkingProcess = "networkingProcess"
|
|
let notificationCenterTransferCountChanged = "transferCountChanged"
|
|
|
|
// Networking Status
|
|
let networkingStatusCreateFolder = "statusCreateFolder"
|
|
let networkingStatusDelete = "statusDelete"
|
|
let networkingStatusRename = "statusRename"
|
|
let networkingStatusCopyMove = "statusCopyMove"
|
|
let networkingStatusFavorite = "statusFavorite"
|
|
|
|
let networkingStatusDownloading = "statusDownloading"
|
|
let networkingStatusDownloaded = "statusDownloaded"
|
|
let networkingStatusDownloadCancel = "statusDownloadCancel"
|
|
|
|
let networkingStatusUploading = "statusUploading"
|
|
let networkingStatusUploaded = "statusUploaded"
|
|
|
|
let networkingStatusReloadAvatar = "statusReloadAvatar"
|
|
|
|
// TIP
|
|
//
|
|
let tipPDFThumbnail = "tipPDFThumbnail"
|
|
let tipAccountRequest = "tipAccountRequest"
|
|
let tipScanAddImage = "tipScanAddImage"
|
|
let tipMediaDetailView = "tipMediaDetailView"
|
|
let tipAutoUploadButton = "tipAutoUploadButton"
|
|
|
|
// ACTION
|
|
//
|
|
let actionNoAction = "no-action"
|
|
let actionUploadAsset = "upload-asset"
|
|
let actionScanDocument = "add-scan-document"
|
|
let actionTextDocument = "create-text-document"
|
|
let actionVoiceMemo = "create-voice-memo"
|
|
|
|
// WIDGET ACTION
|
|
//
|
|
let widgetActionNoAction = "nextcloud://open-action?action=no-action"
|
|
let widgetActionUploadAsset = "nextcloud://open-action?action=upload-asset"
|
|
let widgetActionScanDocument = "nextcloud://open-action?action=add-scan-document"
|
|
let widgetActionTextDocument = "nextcloud://open-action?action=create-text-document"
|
|
let widgetActionVoiceMemo = "nextcloud://open-action?action=create-voice-memo"
|
|
|
|
// APPCONFIG
|
|
//
|
|
let configuration_brand = "brand"
|
|
|
|
let configuration_serverUrl = "serverUrl"
|
|
let configuration_username = "username"
|
|
let configuration_password = "password"
|
|
let configuration_apppassword = "apppassword"
|
|
|
|
let configuration_disable_intro = "disable_intro"
|
|
let configuration_disable_multiaccount = "disable_multiaccount"
|
|
let configuration_disable_crash_service = "disable_crash_service"
|
|
let configuration_disable_log = "disable_log"
|
|
let configuration_disable_more_external_site = "disable_more_external_site"
|
|
let configuration_disable_openin_file = "disable_openin_file"
|
|
let configuration_enforce_passcode_lock = "enforce_passcode_lock"
|
|
|
|
// MORE NEXTCLOUD APPS
|
|
//
|
|
let talkSchemeUrl = "nextcloudtalk://"
|
|
let notesSchemeUrl = "nextcloudnotes://"
|
|
let talkAppStoreUrl = "https://apps.apple.com/in/app/nextcloud-talk/id1296825574"
|
|
let notesAppStoreUrl = "https://apps.apple.com/in/app/nextcloud-notes/id813973264"
|
|
let moreAppsUrl = "itms-apps://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=nextcloud"
|
|
|
|
// SNAPSHOT PREVIEW
|
|
//
|
|
let defaultSnapshotConfiguration = "DefaultPreviewConfiguration"
|
|
|
|
// DIAGNOSTICS CLIENTS
|
|
//
|
|
let diagnosticIssueSyncConflicts = "sync_conflicts"
|
|
let diagnosticIssueProblems = "problems"
|
|
let diagnosticIssueVirusDetected = "virus_detected"
|
|
let diagnosticIssueE2eeErrors = "e2ee_errors"
|
|
|
|
let diagnosticProblemsForbidden = "CHARACTERS_FORBIDDEN"
|
|
let diagnosticProblemsBadResponse = "BAD_SERVER_RESPONSE"
|
|
let diagnosticProblemsUploadServerError = "UploadError.SERVER_ERROR"
|
|
|
|
// MEDIA LAYOUT
|
|
//
|
|
let mediaLayoutRatio = "mediaLayoutRatio"
|
|
let mediaLayoutSquare = "mediaLayoutSquare"
|
|
|
|
// DRAG & DROP
|
|
//
|
|
let metadataOcIdDataRepresentation = "text/com.nextcloud.ocId"
|
|
|
|
// GROUP AMIN
|
|
//
|
|
let groupAdmin = "admin"
|
|
|
|
// TASK DESCRIPTION
|
|
//
|
|
let taskDescriptionRetrievesProperties = "retrievesProperties"
|
|
let taskDescriptionSynchronization = "synchronization"
|
|
|
|
// LOG TAG
|
|
//
|
|
let logTagTask = "BGT"
|
|
let logTagLocation = "LOCATION"
|
|
let logTagBgSync = "BGSYNC"
|
|
let logTagE2EE = "E2EE"
|
|
let logTagPN = "PUSH NOTIFICATION"
|
|
let logTagSync = "SYNC"
|
|
let logTagServiceProficer = "SERVICE PROVIDER"
|
|
let logTagDatabase = "DB"
|
|
let logTagSpeedUpSyncMetadata = "SYNC METADATA"
|
|
let logTagMetadataUploadTransfers = "METADATA UPLOAD TRANSFERS"
|
|
let logTagMetadataDownloadTransfers = "METADATA DOWNLOAD TRANSFERS"
|
|
let logTagViewer = "VIEWERS"
|
|
let logTagMediaBackfill = "MEDIA BACKFILL"
|
|
let logTagMediaPlaceholder = "MEDIA PLACEHOLDER"
|
|
let logTagMediaPreview = "MEDIA PREVIEW"
|
|
let logTagBackgroundUpload = "BACKGROUND UPLOAD"
|
|
|
|
// USER DEFAULTS
|
|
//
|
|
let udMigrationMultiDomains = "migrationMultiDomains"
|
|
let udLastVersion = "lastVersion"
|
|
}
|
|
|
|
/**
|
|
Indicates whether Xcode is running SwiftUI previews.
|
|
*/
|
|
var isXcodeRunningForPreviews: Bool {
|
|
return ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
|
|
}
|