Implement crude encrypted EventImage downloading
When a message image is clicked in an encrypted room, the full file will be download (no GUI indication for now, just a print in terminal) and opened when ready. Before downloading, copying the image address via right click will put the full image mxc:// URL in clipboard. After downloading, it will be the local downloaded image path instead.
This commit is contained in:
parent
5dbf06ba6c
commit
1ec8ed466f
15
TODO.md
15
TODO.md
|
@ -52,22 +52,21 @@
|
||||||
- Leave box button focus
|
- Leave box button focus
|
||||||
|
|
||||||
- two upload delegates height bug
|
- two upload delegates height bug
|
||||||
- Messed up message delegates position
|
|
||||||
|
|
||||||
- Pausing uploads doesn't work well, servers end up dropping the connection
|
- Pausing uploads doesn't work well, servers end up dropping the connection
|
||||||
- Pause upload, switch to other room, then come back, wrong state displayed
|
- Pause upload, switch to other room, then come back, wrong state displayed
|
||||||
|
|
||||||
- `code` not colored in room subtitle
|
- Messed up message delegates position
|
||||||
- In the "Leave me" room, "join > Hi > left" aren't combined
|
|
||||||
- Event delegates changing height don't scroll the list
|
- Event delegates changing height don't scroll the list
|
||||||
|
|
||||||
|
- In the "Leave me" room, "join > Hi > left" aren't combined
|
||||||
- When selecting text and scrolling up, selection stops working after a while
|
- When selecting text and scrolling up, selection stops working after a while
|
||||||
- Ensure all the text that should be copied is copied
|
- Ensure all the text that should be copied is copied
|
||||||
- Multiple messages are currently copied out of order
|
- Multiple messages are currently copied out of order
|
||||||
|
|
||||||
- Pressing backspace in composer sometimes doesn't work
|
- Pressing backspace in composer sometimes doesn't work
|
||||||
- Message order isn't preserved when sending a first message in a E2E
|
|
||||||
room, then while keys are being shared sending one with another account,
|
- `code` not colored in room subtitle
|
||||||
then sending one with the first account again
|
- Quote links color in room subtitles (e.g. "> http://foo.orgA)" )
|
||||||
|
|
||||||
- If account not in config anymore, discard ui state last page on startup
|
- If account not in config anymore, discard ui state last page on startup
|
||||||
- Do something when access token is invalid
|
- Do something when access token is invalid
|
||||||
|
@ -75,7 +74,6 @@
|
||||||
- Don't store states in delegates
|
- Don't store states in delegates
|
||||||
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
|
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
|
||||||
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
|
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
|
||||||
- Quote links color in room subtitles (e.g. "> http://foo.orgA)" )
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
|
@ -194,6 +192,7 @@
|
||||||
|
|
||||||
## Nio contributions
|
## Nio contributions
|
||||||
|
|
||||||
|
- Streaming download & decrypt
|
||||||
- Running blocking DB function calls in executor (WIP)
|
- Running blocking DB function calls in executor (WIP)
|
||||||
- `AsyncClient.share_group_session`: send device batches concurrently (WIP)
|
- `AsyncClient.share_group_session`: send device batches concurrently (WIP)
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,8 @@ class Thumbnail(Media):
|
||||||
parsed = urlparse(self.mxc)
|
parsed = urlparse(self.mxc)
|
||||||
|
|
||||||
if self.crypt_dict:
|
if self.crypt_dict:
|
||||||
|
# Matrix makes encrypted thumbs only available through the download
|
||||||
|
# end-point, not the thumbnail one
|
||||||
resp = await self.cache.backend.download(
|
resp = await self.cache.backend.download(
|
||||||
server_name = parsed.netloc,
|
server_name = parsed.netloc,
|
||||||
media_id = parsed.path.lstrip("/"),
|
media_id = parsed.path.lstrip("/"),
|
||||||
|
|
|
@ -6,8 +6,8 @@ HMxcImage {
|
||||||
id: image
|
id: image
|
||||||
width: fitSize.width
|
width: fitSize.width
|
||||||
height: fitSize.height
|
height: fitSize.height
|
||||||
|
|
||||||
horizontalAlignment: Image.AlignLeft
|
horizontalAlignment: Image.AlignLeft
|
||||||
|
|
||||||
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
||||||
Utils.urlExtension(loader.mediaUrl) === "gif"
|
Utils.urlExtension(loader.mediaUrl) === "gif"
|
||||||
thumbnail: ! animated && loader.thumbnailMxc
|
thumbnail: ! animated && loader.thumbnailMxc
|
||||||
|
@ -20,6 +20,8 @@ HMxcImage {
|
||||||
|
|
||||||
|
|
||||||
property EventMediaLoader loader
|
property EventMediaLoader loader
|
||||||
|
property bool downloaded: false
|
||||||
|
|
||||||
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
||||||
|
|
||||||
readonly property real maxHeight:
|
readonly property real maxHeight:
|
||||||
|
@ -54,7 +56,24 @@ HMxcImage {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
function download(callback) {
|
||||||
|
if (! downloaded) print("Downloading " + loader.mediaUrl + " ...")
|
||||||
|
|
||||||
|
const args = [loader.mediaUrl, loader.singleMediaInfo.media_crypt_dict]
|
||||||
|
|
||||||
|
py.callCoro("media_cache.get_media", args, path => {
|
||||||
|
if (! downloaded) print("Done: " + path)
|
||||||
|
downloaded = true
|
||||||
|
callback(path)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getOpenUrl(callback) {
|
function getOpenUrl(callback) {
|
||||||
|
if (image.isEncrypted && loader.mediaUrl) {
|
||||||
|
download(callback)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (image.isEncrypted) {
|
if (image.isEncrypted) {
|
||||||
callback(image.cachedPath)
|
callback(image.cachedPath)
|
||||||
return
|
return
|
||||||
|
@ -77,14 +96,22 @@ HMxcImage {
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: hover
|
id: hover
|
||||||
onHoveredChanged: {
|
onHoveredChanged: {
|
||||||
if (hovered) {
|
if (! hovered) {
|
||||||
|
eventDelegate.hoveredMediaTypeUrl = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image.isEncrypted && ! downloaded) {
|
||||||
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
|
[EventDelegate.Media.Image, loader.mediaUrl]
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
getOpenUrl(url => {
|
getOpenUrl(url => {
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
[EventDelegate.Media.Image, url]
|
[EventDelegate.Media.Image, url]
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
eventDelegate.hoveredMediaTypeUrl = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user