Skip to content

Feat: Register ed2k:// and magnet: URI schemes automatically #793

@ngosang

Description

@ngosang

Summary

aMule should register itself as the OS-level handler for both the ed2k:// and magnet: URI schemes automatically, the same way auto-start was made cross-platform in #744 — with a toggle in Preferences and an option in the installer — instead of requiring users to edit the registry, LaunchServices, or .desktop/xdg-mime by hand.

Current state

The code already fully supports handling these links once they reach aMule:

  • CMagnetED2KConverter (src/MagnetURI.cpp) converts an eD2k-compatible magnet (xt=urn:ed2k:/urn:ed2khash: + xl=) into an ed2k:// link.
  • CamuleAppCommon::CheckPassedLink() and InitCommon() (src/amuleAppCommon.cpp) accept both ed2k:// and magnet: links passed on the command line and queue them via the ED2KLinks file.
  • The standalone ed2k tool (src/ED2KLinkParser.cpp) accepts magnet: and ed2k:// links.
  • amulecmd's Add command accepts both as well.

What is missing is the OS-level scheme registration:

  • Linux: org.amule.aMule.desktop declares only MimeType=x-scheme-handler/ed2k;. There is no x-scheme-handler/magnet, so magnet links from the browser never reach aMule. The ed2k association is also static (shipped in the .desktop); the user cannot toggle it.
  • Windows: packaging/windows/installer.nsi registers no URL protocol at all — neither ed2k nor magnet. Users must import a .reg file manually.
  • macOS: there is no Info.plist/CFBundleURLSchemes declaration; the OS only picks aMule up opportunistically through LaunchServices.

This is currently documented as a manual procedure on the website(User Manual → Utilities → ed2kBrowser Configuration). https://amule-org.github.io/docs/manual/utilities/ed2k

Requested change

Add automatic registration of the ed2k:// and magnet: schemes, implemented analogously to the auto-start feature from #744:

  1. A cross-platform manager class (mirroring AutostartManager), with the OS being the source of truth:

    • Windows: HKCU\Software\Classes\<scheme> URL-protocol keys pointing at the aMule (or ed2k) binary — per-user, no elevation.
    • Linux: register x-scheme-handler/ed2k and x-scheme-handler/magnet (via .desktop MimeType= + the per-user
      mimeapps.list/xdg-mime).
    • macOS: declare both schemes in the app bundle's Info.plist (CFBundleURLTypes) and/or register via LaunchServices.
    • Enable() / Disable() / IsEnabled() per scheme, idempotent, plus a SelfHeal-style fixup so a moved binary keeps working (same pattern as AutostartManager::SelfHealOnStartup()).
  2. A Preferences toggle (same place/style as the auto-start checkbox in PrefsUnifiedDlg) to enable/disable the associations, with a one-shot command-line option to match --configure-autostart (e.g. --configure-protocols on|off).

  3. An installer option (Windows NSIS Components page, analogous to the existing auto-start checkbox) that registers the schemes on install and cleans them up on uninstall.

Notes

  • magnet handling must keep its existing eD2k-compatibility requirement (magnet must carry xt=urn:ed2k:/urn:ed2khash: and xl=); BitTorrent-only magnets are out of scope.
  • Once shipped, the manual browser-setup section in the docs should be reduced => https://amule-org.github.io/docs/manual/utilities/ed2k

Reference implementation to mirror: #744 (cross-platform auto-start).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions