Closed Bug 1835135 Opened 2 years ago Closed 2 years ago

gnome-search-provider: Configure application name in DBUS_BUS_NAME and DBUS_OBJECT_PATH

Categories

(Core :: Widget: Gtk, task, P3)

Desktop
Linux
task

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: jan, Assigned: stransky)

References

(Blocks 2 open bugs)

Details

(Keywords: nightly-community)

Attachments

(3 files, 1 obsolete file)

MOZ_APP_REMOTINGNAME can be firefox, firefox-beta, firefox-aurora, firefox-nightly, firefox-esr.

Current file: https://searchfox.org/mozilla-central/rev/ca52886e3b6051ca87861567e0c7628915f68780/browser/components/shell/nsGNOMEShellDBusHelper.h#18

DBUS_BUS_NAME "org.mozilla.Firefox.SearchProvider"
DBUS_OBJECT_PATH "/org/mozilla/Firefox/SearchProvider"

DBUS_BUS_NAME should be org.mozilla.MOZ_APP_REMOTINGNAME.SearchProvider
DBUS_OBJECT_PATH should be /org/mozilla/MOZ_APP_REMOTINGNAME/SearchProvider

MOZ_APP_REMOTINGNAME is already used here: https://searchfox.org/mozilla-central/rev/ca52886e3b6051ca87861567e0c7628915f68780/toolkit/xre/nsAppRunner.cpp#4637

g_set_prgname(gAppData->remotingName);

Blocks: 1835141
Priority: -- → P3
Flags: needinfo?(stransky)
Flags: needinfo?(stransky)
Assignee: nobody → stransky
Status: NEW → ASSIGNED

Unfortunately this doesn't work as DBus refuses to use interface/path names with '-' char.
As I see Bug 1805440 and Bug 1835141 it would be better to use env variable to set search provider DBus name.

Summary: gnome-search-provider: Use MOZ_APP_REMOTINGNAME in DBUS_BUS_NAME and DBUS_OBJECT_PATH → gnome-search-provider: Configure application name in DBUS_BUS_NAME and DBUS_OBJECT_PATH

org.mozilla.firefox_nightly and org.mozilla.thunderbird 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() with desktopid that you get from a new method XREAppData::GetDesktopId which should return:

    • if IsRunningUnderFlatpak()
      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.

Thanks. I think we should use XREAppData::GetDBusAppName() then and add ability to override the app name there.

Attachment #9336393 - Attachment is obsolete: true
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/964b57d61881 [Linux] Set correct application name to Gnome search provider r=emilio https://hg.mozilla.org/integration/autoland/rev/a7f56dd3c21c [Linux] Use XREAppData::GetDBusAppName() to create Gnome shell search provider DBus name/path r=emilio https://hg.mozilla.org/integration/autoland/rev/238468b1748e [Linux] Allow to override DBus application name by MOZ_DBUS_APP_NAME env variable r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
See Also: → 1831896
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: