Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Conversation

@mariogrip
Copy link
Member

This adds watchers for xdg desktop file changes. It also figures out if
the appid id is "ubuntu-app-launch" or "standard xdg" style.

This spawns the first code to replace most (if not all) of
ubuntu-app-launch, but with QT!

This fixes: ubports/ubuntu-touch#1058

@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from 428d5cd to c581048 Compare August 15, 2019 19:46
@mariogrip
Copy link
Member Author

@dobey Should be fixed up now :)

@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from c581048 to ae2df97 Compare August 16, 2019 17:50
@mariogrip
Copy link
Member Author

@mardy There we go, that should fix it :) Also found a little error in my toStandardAppId() thats fixed now.

@mariogrip mariogrip requested a review from dobey August 16, 2019 20:50

void AppDrawerModel::appRemoved(const QString &appId)
// ubuntuAppId is appID without version suffix, see xdgwatcher.cpp.
void AppDrawerModel::appRemoved(const QString &appId, const QString &ubuntuAppId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing both in here, why not make the functions (which seem to not require the class object itself to be useful), into public static methods, and then just call XdgWatcher::stripAppIdVersion(appid) when needed below? This avoids a semi-duplicated argument, and makes the code easier to follow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem with that is that the "normal/standard" appID might not be the same as strippedAppId as the "ubuntu style" app id does not add the parent folder into app id.

example:
.local/share/desktop/kde/kate.desktop would be kde-kate as appID.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example where these conflics:

.local/share/desktop/ubports/system-settings_ubports_1.1.1.desktop would then be passed as ubports-system-settings_ubports_1.1.1 to appRemoved, then stripped to ubports-system-settings_ubports and that would be wrong, as "ubuntu style" appID does not append "folder name" as xdg one does

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, click hook does not create desktop files in a subdir, and we get the app ID for these from inside the desktop file, so this isn't an issue. I don't see any need to have extra special handling in here. The model has a list of app IDs, and one gets removed. there doesn't need to be extra logic for special cases in here.

}

// Ubuntu appID is filename without versionNumber after last "_"
const QString XdgWatcher::toUbuntuAppId(const QString rawAppID) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed to not have "Ubuntu" in the name. Perhaps it should be stripAppIdVersion instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah make sense, will update this

int idx = -1;
for (int i = 0; i < m_list.count(); i++) {
if (m_list.at(i)->appId() == appId) {
if (m_list.at(i)->appId() == appId || m_list.at(i)->appId() == ubuntuAppId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need the second comparison here (and thus the argument or need to strip the version) at all? Shouldn't the appId that gets passed in already have the version stripped always? In what cases would it not be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is to make sure we don't strip an "standard" appID by accident. Example is kate_kde.desktop, we would strip "_kde" in that case. Since the file has been removed we have no way of knowing if it's a "ubuntu style" app id.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I re-read the comment in XdgWatcher, and this is a hack to deal with the fact the file was removed. I will have to think a bit on this, but I'm certain we can handle it a better way.

Copy link
Member

@dobey dobey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because previous comments and GitHub is broke.

Copy link
Member

@UniversalSuperBox UniversalSuperBox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from 593caba to 443fc3f Compare September 13, 2019 17:27
@mariogrip
Copy link
Member Author

@dobey that should be better, now its a static method that gets called instead of passing it with the signal.

@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from 443fc3f to eed86d5 Compare September 13, 2019 21:14
@mariogrip
Copy link
Member Author

Cool! It builds now. Just ignore the others as they are only here due to changes to Jenkins.

Copy link
Member

@dobey dobey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more concerns that came up thinking about this.

// "Ubuntu style" appID is filename without versionNumber after last "_"
const QString XdgWatcher::stripAppIdVersion(const QString rawAppID) {
auto appIdComponents = rawAppID.split("_");
appIdComponents.removeLast();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only do this, if the appIdComponents.length() == 3, otherwise it is not a valid versioned app ID for the purposes here. This would also solve the concern above that we might strip kde_kate improperly. It would also simplify the code a fair bit, as we could then avoid special-casing below, and above, only passing the result of toAppId() around.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that make sense, will add that :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has still not been updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this, we may still improperly strip for example org_kde_kate, so we would still need to open the file to check


const QString XdgWatcher::toAppId(const QFileInfo fileInfo) const {
QFile qFile(fileInfo.absoluteFilePath());
qFile.open(QIODevice::ReadOnly);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we can just get rid of the whole need to open the file and check for X-Ubuntu-Application-ID entirely, and only use toStandardAppId() to get the app ID, since click hooks place the files as the correct ${APP_ID}.desktop filename. Then we can just always strip the version.

Copy link
Member Author

@mariogrip mariogrip Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i guess that should also work just fine, since we use to remove the app anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has still not been updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this, we may still improperly strip for example org_kde_kate, so we would still need to open the file to check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a real concern. KDE does not install applications in this manner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kde was just an example, but one app that does do this on my local system is krita_jpg_jpeg.desktop

connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &XdgWatcher::onDirectoryChanged);
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &XdgWatcher::onFileChanged);

const auto paths = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this will only watch directories in the host, this PR doesn't solve the issue for install/remove of apps in Libertine. How are we going to handle those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea to that was to make symlinks the .desktop to the standard locations instead, this makes it easier for libertine work on other DE (if needed)

@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from eed86d5 to 598f92f Compare December 1, 2019 03:10
@mariogrip
Copy link
Member Author

So, I added an internal registry, this way we will always give the correct id. This also really simplifies the code overall. and I think i covered all your comments @dobey. Please re-review :)

@mariogrip mariogrip changed the base branch from xenial_-_edge to xenial December 1, 2019 03:15
@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from 598f92f to 126b2b9 Compare December 1, 2019 03:16
@mariogrip mariogrip requested a review from dobey December 11, 2019 14:28

const QString XdgWatcher::toAppId(const QFileInfo fileInfo) const {
QFile qFile(fileInfo.absoluteFilePath());
qFile.open(QIODevice::ReadOnly);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a real concern. KDE does not install applications in this manner.

This adds watchers for xdg desktop file changes. It also figures out if
the appid id is "ubuntu-app-launch" or "standard xdg" style.

This spawns the first code to replace most (if not all) of
ubuntu-app-launch, but with QT!

This fixes: ubports/ubuntu-touch#1058
@mariogrip mariogrip force-pushed the xenial_-_edge_-_appwatcher branch from 126b2b9 to 0a52673 Compare December 11, 2019 18:52
Copy link
Member

@dobey dobey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this is not quite right, but I don't want to hold it up any longer on semantics.

@mariogrip mariogrip merged commit 5e3b45c into xenial Dec 11, 2019
@mariogrip mariogrip deleted the xenial_-_edge_-_appwatcher branch December 11, 2019 19:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drawer does not refresh apps

5 participants