Bug 1835135 Comment 5 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

[org.mozilla.firefox_nightly](https://github.com/canonical/firefox-snap/blob/c413ee6e5914502e5b45d926dc135e470b279b09/snapcraft.yaml#L492) and [org.mozilla.thunderbird](https://github.com/ubuntu/thunderbird/blob/410d099b887a2c5bdb59e16693790476696a80ae/snapcraft.yaml#L48) are already used for dbus in snapcraft.yaml.

* DBUS:
  XRemote dbus name seems to contain base64(profilename) so that parallel running profiles would be fine.
  But the search provider dbus name couldn't contain base64(profilename) because search-provider.ini would need to know it which is not possible.

  XREAppData::GetDBusAppName returns MOZ_APP_REMOTINGNAME with "\-" replaced with "\_" . 

  How it should probably be:
  XRemote: org.mozilla.<what GetDBusAppName returns>.<base64(profilename)>
  Search: org.mozilla.<what GetDBusAppName returns>.SearchProvider

  Snap doesn't support Gnome search providers yet: https://forum.snapcraft.io/t/gnome-shell-search-providers-in-snaps/5265


* bug 1826330:
The terms DesktopId and Wayland app id refer to <DesktopId>.desktop.
Call [g_set_prgname()](https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/toolkit/xre/nsAppRunner.cpp#4637) with desktopid that you get from a new method [XREAppData::GetDesktopId](https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/xpcom/glue/XREAppData.cpp#54) which should return:
  * if [IsRunningUnderFlatpak()](https://searchfox.org/mozilla-central/rev/f4d3fe187cf7dffa4c13b354bbde9bc47b5ccd3f/widget/gtk/WidgetUtilsGtk.cpp#140)
    org.mozilla.<MOZ_APP_REMOTINGNAME with "-" replaced with "_" > // to match org.mozilla.firefox.desktop, org.mozilla.thunderbird.desktop
    org.mozilla.<what GetDBusAppName returns>
  * else if SNAP_NAME env var is not empty:
    * If SNAP_INSTANCE_KEY env var is not empty:
      <SNAP_NAME>+<SNAP_INSTANCE_KEY>_<SNAP_NAME> // to match firefox+userdefinedaliasname_firefox.desktop, thunderbird+userdefinedaliasname_thunderbird.desktop
    * else
     <SNAP_NAME>_<SNAP_NAME> // to match firefox_firefox.desktop, thunderbird_thunderbird.desktop
  * else
    MOZ_APP_REMOTINGNAME // to match firefox-nightly.desktop, thunderbird.desktop

  Snap background:
  packagename can have multiple apps with desktop file. First apps' name is usually the same as packagename.
  `$ sudo snap install packagename`
  `$ sudo snap install packagename_userdefinedaliasname`
  `$ snap run packagename` is possible if appname==packagename
  `$ snap run packagename.appname` (packagename_appname.desktop)
  `$ snap run packagename_userdefinedaliasname` is possible if appname==packagename 
  `$ snap run packagename_userdefinedaliasname.appname` (packagename+userdefinedaliasname_appname.desktop)

    SNAP_NAME env var contains packagename.
    SNAP_INSTANCE_KEY env var contains userdefinedaliasname.
    SNAP_INSTANCE_NAME is packagename_userdefinedaliasname
    There is no env var for appname.

    `$ cat /var/lib/snapd/desktop/applications/firefox+minefield_firefox.desktop`
    > [Desktop Entry]
    > X-SnapInstanceName=firefox_minefield
    > [...]
    > Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/firefox+minefield_firefox.desktop /snap/bin/firefox_minefield %u
    > [...]

    I assume KDE Wayland ignores the BAMF_DESKTOP_FILE_HINT, otherwise it might have shown the correct icon.

* DBUS usage in https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/dom/system/linux/GeoclueLocationProvider.cpp#476
    At the moment, GetDBusAppName would just return firefox_nightly IIUC.
    https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.DesktopId
    >  The desktop file id (the basename of the desktop file). This property must be set by applications for authorization to work.

    Maybe the call to GetDBusAppName
    a) should be replaced with new GetDesktopId
    b) or should stay because it might break in case the DesktopId is "firefox+userdefinedaliasname_firefox".


---

https://dbus.freedesktop.org/doc/dbus-specification.html
> Note that the hyphen ('-') character is allowed in bus names but not in interface names. It is also **problematic** or not allowed in various specifications and APIs that refer to D-Bus, such as Flatpak application IDs, the DBusActivatable interface in the Desktop Entry Specification, and the convention that an application's "main" interface and object path resemble its bus name. To avoid situations that require special-case handling, **it is recommended that new D-Bus names consistently replace hyphens with underscores**.

* In case a Nightly flatpak package should ever be made, it should probably be named org.mozilla.firefox_nightly.
* Debian packages names require the opposite: "-" and not "_".
* These use "-" in Flatpak application ids:
https://flathub.org/apps/org.gnome.font-viewer
https://flathub.org/apps/com.github.bajoja.indicator-kdeconnect
* These use both:
org.gnome.Evolution-alarm-notify.desktop
org.kde.plasma.browser_integration.host.desktop (https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/)
[org.mozilla.firefox_nightly](https://github.com/canonical/firefox-snap/blob/c413ee6e5914502e5b45d926dc135e470b279b09/snapcraft.yaml#L492) and [org.mozilla.thunderbird](https://github.com/ubuntu/thunderbird/blob/410d099b887a2c5bdb59e16693790476696a80ae/snapcraft.yaml#L48) are already used for dbus in snapcraft.yaml.

* DBUS:
  XRemote dbus name seems to contain base64(profilename) so that parallel running profiles would be fine.
  But the search provider dbus name couldn't contain base64(profilename) because search-provider.ini would need to know it which is not possible.

  XREAppData::GetDBusAppName returns MOZ_APP_REMOTINGNAME with "\-" replaced with "\_" . 

  How it should probably be:
  XRemote: org.mozilla.<what GetDBusAppName returns>.<base64(profilename)>
  Search: org.mozilla.<what GetDBusAppName returns>.SearchProvider

  Snap doesn't support Gnome search providers yet: https://forum.snapcraft.io/t/gnome-shell-search-providers-in-snaps/5265


* bug 1826330:
The terms DesktopId and Wayland app id refer to <DesktopId>.desktop.
Call [g_set_prgname()](https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/toolkit/xre/nsAppRunner.cpp#4637) with desktopid that you get from a new method [XREAppData::GetDesktopId](https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/xpcom/glue/XREAppData.cpp#54) which should return:
  * if [IsRunningUnderFlatpak()](https://searchfox.org/mozilla-central/rev/f4d3fe187cf7dffa4c13b354bbde9bc47b5ccd3f/widget/gtk/WidgetUtilsGtk.cpp#140)
    org.mozilla.<MOZ_APP_REMOTINGNAME with "-" replaced with "_" > // to match org.mozilla.firefox.desktop, org.mozilla.thunderbird.desktop
    org.mozilla.<what GetDBusAppName returns>
  * else if SNAP_NAME env var is not empty:
    * If SNAP_INSTANCE_KEY env var is not empty:
      <SNAP_NAME>+<SNAP_INSTANCE_KEY>_<SNAP_NAME> // to match firefox+userdefinedaliasname_firefox.desktop, thunderbird+userdefinedaliasname_thunderbird.desktop
    * else
     <SNAP_NAME>_<SNAP_NAME> // to match firefox_firefox.desktop, thunderbird_thunderbird.desktop
  * else
    MOZ_APP_REMOTINGNAME // to match firefox-nightly.desktop, thunderbird.desktop

  Snap background:
  packagename can have multiple apps with desktop file. First app's name is usually the same as packagename.
  `$ sudo snap install packagename`
  `$ sudo snap install packagename_userdefinedaliasname`
  `$ snap run packagename` is possible if appname==packagename
  `$ snap run packagename.appname` (packagename_appname.desktop)
  `$ snap run packagename_userdefinedaliasname` is possible if appname==packagename 
  `$ snap run packagename_userdefinedaliasname.appname` (packagename+userdefinedaliasname_appname.desktop)

    SNAP_NAME env var contains packagename.
    SNAP_INSTANCE_KEY env var contains userdefinedaliasname.
    SNAP_INSTANCE_NAME is packagename_userdefinedaliasname
    There is no env var for appname.

    `$ cat /var/lib/snapd/desktop/applications/firefox+minefield_firefox.desktop`
    > [Desktop Entry]
    > X-SnapInstanceName=firefox_minefield
    > [...]
    > Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/firefox+minefield_firefox.desktop /snap/bin/firefox_minefield %u
    > [...]

    I assume KDE Wayland ignores the BAMF_DESKTOP_FILE_HINT, otherwise it might have shown the correct icon.

* DBUS usage in https://searchfox.org/mozilla-central/rev/0c2945ad4769e2d4428c72e6ddd78d60eb920394/dom/system/linux/GeoclueLocationProvider.cpp#476
    At the moment, GetDBusAppName would just return firefox_nightly IIUC.
    https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.DesktopId
    >  The desktop file id (the basename of the desktop file). This property must be set by applications for authorization to work.

    Maybe the call to GetDBusAppName
    a) should be replaced with new GetDesktopId
    b) or should stay because it might break in case the DesktopId is "firefox+userdefinedaliasname_firefox".


---

https://dbus.freedesktop.org/doc/dbus-specification.html
> Note that the hyphen ('-') character is allowed in bus names but not in interface names. It is also **problematic** or not allowed in various specifications and APIs that refer to D-Bus, such as Flatpak application IDs, the DBusActivatable interface in the Desktop Entry Specification, and the convention that an application's "main" interface and object path resemble its bus name. To avoid situations that require special-case handling, **it is recommended that new D-Bus names consistently replace hyphens with underscores**.

* In case a Nightly flatpak package should ever be made, it should probably be named org.mozilla.firefox_nightly.
* Debian packages names require the opposite: "-" and not "_".
* These use "-" in Flatpak application ids:
https://flathub.org/apps/org.gnome.font-viewer
https://flathub.org/apps/com.github.bajoja.indicator-kdeconnect
* These use both:
org.gnome.Evolution-alarm-notify.desktop
org.kde.plasma.browser_integration.host.desktop (https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/)

Back to Bug 1835135 Comment 5