* Used to handle files described in event, such as caching(if autoCache is true) and download.
- * It is either used for caching or downloading. These two operations cannot be performed in the same FileHandler.
+ * It is either used for caching or downloading. These two operations can be performed in same FileHandler.(Set autoCache to true and then call downloadFile)
+ * But one Filehandler can only track one download/cache job.
*/
QtObject {
id: fileHandler
- required property var eventContent
/**
- * If autoCache is true, the file is automatically cached(thumbnail is downloaded if exists).
+ * Just set these four properties, any other properties will be automatically evaluated.
+ * The eventContent can be modified at any time.
+ * Modifying other properties can lead to unpredictable behavior.
*/
- required property bool autoCache
+ required property var eventContent
+ required property bool autoCache // thumbnail(if exists) will be downloaded if set to true
required property var kazvIOManager
required property var matrixSdk
- /**
- * Used to download or caching.
- * mxcUri, sha256, key, iv will be setted automatically
- * according to whether the file is encrypted or not.
- */
- property var mxcUri: ""
property var httpVer: matrixSdk.checkSpecVersion("v1.11") ? MK.MatrixSdk.AuthenticatedMediaV1 : MK.MatrixSdk.UnauthenticatedMediaV3
- property var url: fileHandler.mxcToHttp(httpVer, mxcUri)
- property var saveFileUrl: ""
- property var mediaId: mxcUri && fileHandler.getMediaId(fileHandler.mxcUri)
- property var fileInfo: "info" in eventContent ? eventContent.info : {}
+ property var encryptedFileMxcUri
+ property var encryptedFileSha256
+ property var encryptedFileKey
+ property var encryptedFileIv
- property var encryptedFile: "file" in eventContent ? eventContent.file : {}
- property var encryptedFileMxcUri: "url" in encryptedFile ? encryptedFile.url : ""
- property var encryptedFileSha256: "hashes" in encryptedFile && "sha256" in encryptedFile.hashes ? encryptedFile.hashes.sha256 : ""
- // property var encryptedFileAlg: "key" in encryptedFile && "alg" in encryptedFile.key ? encryptedFile.key.alg : ""
- property var encryptedFileKey: "key" in encryptedFile && "k" in encryptedFile.key ? encryptedFile.key.k : ""
- property var encryptedFileIv: "iv" in encryptedFile ? encryptedFile.iv : ""
+ property var encryptedThumbnailMxcUri
+ property var encryptedThumbnailSha256
+ property var encryptedThumbnailKey
+ property var encryptedThumbnailIv
- property var encryptedThumbnail: "thumbnail_file" in fileInfo ? fileInfo.thumbnail_file : {}
- property var encryptedThumbnailMxcUri: "url" in encryptedThumbnail ? encryptedThumbnail.url : ""
- property var encryptedThumbnailSha256: "hashes" in encryptedThumbnail && "sha256" in encryptedThumbnail.hashes ? encryptedThumbnail.hashes.sha256 : ""
- // property var encryptedFileAlg: "key" in encryptedThumbnail && "alg" in encryptedThumbnail.key ? encryptedThumbnail.key.alg : ""
- property var encryptedThumbnailKey: "key" in encryptedThumbnail && "k" in encryptedThumbnail.key ? encryptedThumbnail.key.k : ""
- property var encryptedThumbnailIv: "iv" in encryptedThumbnail ? encryptedThumbnail.iv : ""
+ property var unencryptedFileMxcUri
- property var unencryptedFileMxcUri: "url" in eventContent ? eventContent.url : ""
+ property var unencryptedThumbnailMxcUri
- property var unencryptedThumbnailMxcUri: "thumbnail_url" in fileInfo ? fileInfo.thumbnail_url : ""
+ property bool isValid
+ property bool isEncrypted
+ property bool hasEncryptedThumbnail
+ property bool hasUnencryptedThumbnail
/**
* Emit when start download, not emit when start cache.