Help fixing minor issue in notifications

Karthik Periagaram karthik.periagaram at gmail.com
Wed Aug 15 10:47:10 BST 2018


Hello everyone,


I need some help in fixing this bug[1].


I have the plasma-browser integration add-on enabled in my browser and
when downloading from places like google drive or similar file
upload/sharing websites, the notification in the system tray is
structured like this,


Downloading

[Title] [collapse button]

Source: https://www.foo.com/long-meaningless-base64-string

Destination: /path/to/bar/meaningful-file-name.ext

[size] of [total size]

[speed] ([time] remaining)

[progress bar] [pause] [stop]


The problem is that the [Title] field is the long, meaningless base64
string at the end of the source URL and not the much more meaningful
file name I save the file to. I filed the bug under
plasma-browser-integration, but I suspect the right repo to fix this
in is actually plasma-workspace. However, my reasoning has some...
gaps, so I would appreciate someone confirming I'm on the right track.
Here's my thought process:


The trail starts in plasma-browser-integration where the JSON object
downloadItem[2] is parsed to get the url/finalUrl (source) and the
filename (destination). This creates a DownloadJob (derived of KJob),
emiting a description with the source, the destination and a title,
"Downloading"[3]. From here, "somehow", a KJob ends up as one of
several JobView[4] instances populating a KuiServerEngine[5], one of
Plasma's DataEngines. The KuiServerEngine provides a method to set up
data fields[6]. Again, "somehow", "something" calls this method
(surely not this other class also confusingly called JobView[7]?) but
it ends up setting "labelX", "labelNameX" and "labelFileNameX" for X=0
(source) and 1(destination). Now, these data fields are eventually
read by JobDelegate.qml[8] which goes on to create the [Title] by
slicing the "labelFileName0" (instead of "labelFileName1") after the
last '/' character[9].


I propose the following patch[10] to fix this bug, but due to the
afore-mentioned gaps in knowledge, I'm not sure I'm handling all
possible corner cases. Please chime in on the review for my patch if
you have any questions (or answers!).


Thanks,

Karthik


[1] https://bugs.kde.org/show_bug.cgi?id=396744

[2] https://developer.chrome.com/extensions/downloads#type-DownloadItem

[3] https://cgit.kde.org/plasma-browser-integration.git/tree/host/downloadjob.cpp#n81

[4] https://cgit.kde.org/plasma-workspace.git/tree/dataengines/applicationjobs/kuiserverengine.h#n59

[5] https://cgit.kde.org/plasma-workspace.git/tree/dataengines/applicationjobs/kuiserverengine.h#n36

[6] https://cgit.kde.org/plasma-workspace.git/tree/dataengines/applicationjobs/kuiserverengine.cpp#n256

[7] https://cgit.kde.org/plasma-workspace.git/tree/kuiserver/jobview.cpp#n214

[8] https://cgit.kde.org/plasma-workspace.git/tree/applets/notifications/package/contents/ui/JobDelegate.qml#n37

[9] https://cgit.kde.org/plasma-workspace.git/tree/applets/notifications/package/contents/ui/JobDelegate.qml#n68

[10] https://phabricator.kde.org/D14857


More information about the Plasma-devel mailing list