Discussion:
mime aliases and inheritance vs. removed associations
Ryan Lortie
2014-11-09 19:18:04 UTC
Permalink
hi,

One more nag about the mimeapps spec, while we're at it.

We didn't take any care to think about aliases and inheritance.

Aliases are probably relatively easy: I think we should aim to only ever
store the canonical mime type names in the file, and if we are
processing a file with non-canonical names, we should treat it as if we
encountered the canonical name instead. That means that if someone
added an association at one level for 'application/acrobat' and then at
another level removed 'application/pdf' then the result would be that
the association is broken, regardless of what string is used to do the
lookup.

Inheritance is more difficult. What does it mean if, for example, gedit
is listed as an editor for text/plain, but then we specifically list it
as a [Removed] for text/html? Maybe even more interesting is what
happens if it explicitly listed as text/html but then we remove it for
all of text/plain? Is it only removed as a fallback, or is it removed
completely for all purposes?

I don't know that there are "natural" answers to these questions. In
the case of GLib we have two loops iterating (outer) over all parent
types, in order of most specific to most general, then (inner) over all
desktop file directories. If we encounter a remove instruction anywhere
on the way, we add the app to a blacklist that we keep for the duration
of the entire operation. This means that if an app removed for
text/html at any level it will prevent it from being used for text/html
even if it is added again for text/plain from a higher-level directory.
This might sound weird, but consider that removals are probably only
really recorded at the highest-level (ie: user) directory.

On the other hand it means that if the user removes text/plain then the
behaviour will depend on what exactly was specified in the system
directories. If text/html was specifically mentioned as being handled
then it will still be handled. If, however, only text/plain was
mentioned, then the user will have removed this association. That seems
slightly weird as well.

I guess it comes down to user intent in a way: what is the user really
wanting to do when they break an association between an generic text
editor and a file named index.html? Are they breaking an association
between this editor and all text files, or are they only intending to do
it for html? Maybe the solution to this problem in fact lies in
breaking specifically the association that the application declared?

I welcome any thoughts on this matter (and particularly if you can state
them more cogently than I've been able to do in this mail).

Cheers
Jerome Leclanche
2014-11-09 20:25:20 UTC
Permalink
Agreed on aliases.

As far as inheritance goes... Let's look at it on a case by case basis.

The user opens an HTML file. It opens with Firefox. They set notepad as the
app for HTML -> Notepad can now read HTML files.
Notepad should not implicitly be suddenly interested in all text files.

Let's imagine a "b64ark" format which stores multiple files in a base64
plain text format. This format inherits from text/plain but the user
associates it with Ark or some such, it doesn't mean ark can read all
plaintext files. This would happen a lot with XML files as well for example.

OK now let's imagine Firefox can read XML and svg files. The user doesn't
want it to open XML files so removes the assoc. It doesn't mean chrome
should stop reading svg files.

With all that in mind I don't think we should care too much about
inheritance unless it is explicit.
Post by Ryan Lortie
hi,
One more nag about the mimeapps spec, while we're at it.
We didn't take any care to think about aliases and inheritance.
Aliases are probably relatively easy: I think we should aim to only ever
store the canonical mime type names in the file, and if we are
processing a file with non-canonical names, we should treat it as if we
encountered the canonical name instead. That means that if someone
added an association at one level for 'application/acrobat' and then at
another level removed 'application/pdf' then the result would be that
the association is broken, regardless of what string is used to do the
lookup.
Inheritance is more difficult. What does it mean if, for example, gedit
is listed as an editor for text/plain, but then we specifically list it
as a [Removed] for text/html? Maybe even more interesting is what
happens if it explicitly listed as text/html but then we remove it for
all of text/plain? Is it only removed as a fallback, or is it removed
completely for all purposes?
I don't know that there are "natural" answers to these questions. In
the case of GLib we have two loops iterating (outer) over all parent
types, in order of most specific to most general, then (inner) over all
desktop file directories. If we encounter a remove instruction anywhere
on the way, we add the app to a blacklist that we keep for the duration
of the entire operation. This means that if an app removed for
text/html at any level it will prevent it from being used for text/html
even if it is added again for text/plain from a higher-level directory.
This might sound weird, but consider that removals are probably only
really recorded at the highest-level (ie: user) directory.
On the other hand it means that if the user removes text/plain then the
behaviour will depend on what exactly was specified in the system
directories. If text/html was specifically mentioned as being handled
then it will still be handled. If, however, only text/plain was
mentioned, then the user will have removed this association. That seems
slightly weird as well.
I guess it comes down to user intent in a way: what is the user really
wanting to do when they break an association between an generic text
editor and a file named index.html? Are they breaking an association
between this editor and all text files, or are they only intending to do
it for html? Maybe the solution to this problem in fact lies in
breaking specifically the association that the application declared?
I welcome any thoughts on this matter (and particularly if you can state
them more cogently than I've been able to do in this mail).
Cheers
_______________________________________________
xdg mailing list
http://lists.freedesktop.org/mailman/listinfo/xdg
Christophe Fergeau
2015-02-10 17:53:06 UTC
Permalink
Hey,

Vaguely related to that, I recently had an issue with glib 2.42 and the
way it looks up default applications when inheritance is involved.

If gedit is registered as a default for text/plain, and if text/html has
no default application, but epiphany says it can handle text/html files,
the logic in g_desktop_app_info_get_defaults_for_content_type() will
cause it to pick gedit as the favoured application for text/plain while
epiphany would imo be best when there is no exact match.

I've filed https://bugzilla.gnome.org/show_bug.cgi?id=744282 against
glib.

Christophe
Post by Ryan Lortie
hi,
One more nag about the mimeapps spec, while we're at it.
We didn't take any care to think about aliases and inheritance.
Aliases are probably relatively easy: I think we should aim to only ever
store the canonical mime type names in the file, and if we are
processing a file with non-canonical names, we should treat it as if we
encountered the canonical name instead. That means that if someone
added an association at one level for 'application/acrobat' and then at
another level removed 'application/pdf' then the result would be that
the association is broken, regardless of what string is used to do the
lookup.
Inheritance is more difficult. What does it mean if, for example, gedit
is listed as an editor for text/plain, but then we specifically list it
as a [Removed] for text/html? Maybe even more interesting is what
happens if it explicitly listed as text/html but then we remove it for
all of text/plain? Is it only removed as a fallback, or is it removed
completely for all purposes?
I don't know that there are "natural" answers to these questions. In
the case of GLib we have two loops iterating (outer) over all parent
types, in order of most specific to most general, then (inner) over all
desktop file directories. If we encounter a remove instruction anywhere
on the way, we add the app to a blacklist that we keep for the duration
of the entire operation. This means that if an app removed for
text/html at any level it will prevent it from being used for text/html
even if it is added again for text/plain from a higher-level directory.
This might sound weird, but consider that removals are probably only
really recorded at the highest-level (ie: user) directory.
On the other hand it means that if the user removes text/plain then the
behaviour will depend on what exactly was specified in the system
directories. If text/html was specifically mentioned as being handled
then it will still be handled. If, however, only text/plain was
mentioned, then the user will have removed this association. That seems
slightly weird as well.
I guess it comes down to user intent in a way: what is the user really
wanting to do when they break an association between an generic text
editor and a file named index.html? Are they breaking an association
between this editor and all text files, or are they only intending to do
it for html? Maybe the solution to this problem in fact lies in
breaking specifically the association that the application declared?
I welcome any thoughts on this matter (and particularly if you can state
them more cogently than I've been able to do in this mail).
Cheers
_______________________________________________
xdg mailing list
http://lists.freedesktop.org/mailman/listinfo/xdg
Ryan Lortie
2015-04-05 15:12:41 UTC
Permalink
hi,
Post by Ryan Lortie
One more nag about the mimeapps spec, while we're at it.
After thinking on this and getting some feedback, I'd like to propose a
couple of changes to the spec.

One should be a fairly simple straight-up clarification:

https://bugs.freedesktop.org/show_bug.cgi?id=89877

but it still leaves some questions unanswered. For example: do we reset
the blacklist (removed apps) between each iteration of the algorithm for
the different types in the inheritance chain when building the list of
apps that support a given type?

Another suggestion (originally inspired by a random thought from Lars)
is a bit of a big hammer, but it would completely avoid pretty much all
of the problems we've been having here (and I think the cost, in
practical terms, is pretty small):

https://bugs.freedesktop.org/show_bug.cgi?id=89880

I'd appreciate feedback on these two bugs.

Cheers
Vladimir Kudrya
2015-04-05 16:25:31 UTC
Permalink
Hello!
I`ve commented the bugs.
In short: about generic/specific types - good idea, but how apps would
tell generic and specific types apart?
About disabling removals - unneeded logic breaker.
Post by Ryan Lortie
hi,
Post by Ryan Lortie
One more nag about the mimeapps spec, while we're at it.
After thinking on this and getting some feedback, I'd like to propose a
couple of changes to the spec.
https://bugs.freedesktop.org/show_bug.cgi?id=89877
but it still leaves some questions unanswered. For example: do we reset
the blacklist (removed apps) between each iteration of the algorithm for
the different types in the inheritance chain when building the list of
apps that support a given type?
Another suggestion (originally inspired by a random thought from Lars)
is a bit of a big hammer, but it would completely avoid pretty much all
of the problems we've been having here (and I think the cost, in
https://bugs.freedesktop.org/show_bug.cgi?id=89880
I'd appreciate feedback on these two bugs.
Cheers
_______________________________________________
xdg mailing list
http://lists.freedesktop.org/mailman/listinfo/xdg
Loading...