XapaJIaMnu/translateLocally

Native Messaging through Firefox launches GUI

jerinphilip opened this issue · 1 comments

I have translateLocally instances spawned all over when trying to use benchmark.

[jerin@thinkpad bergamot-translator]$ ps ax | grep translateLocally
 105888 ?        Sl     0:01 /usr/bin/translateLocally /home/jerin/.mozilla/native-messaging-hosts/translatelocally.json {c9cdf885-0431-4eed-8e18-967b1758c951}
 106231 ?        Sl     0:01 /usr/bin/translateLocally /home/jerin/.mozilla/native-messaging-hosts/translatelocally.json {c9cdf885-0431-4eed-8e18-967b1758c951}
 107096 pts/0    S+     0:00 grep translateLocally

// On Firefox, the first argument is path to a manifest file, and the second is the extension id. I'm intentionally
// not checking for known full paths, just for the common suffix shared by all browser implementations, so people
// with Firefox forks or weird Firefox installations can still use this functionality as long as they copy the
// manifest file into the right folder by themselves.
QRegularExpression manifestPattern("NativeMessagingHosts/([^/]+)\\.json$");
if (args.size() >= 2 && manifestPattern.match(args[0]).hasMatch())
return args[1];

image

Edit: wait so it pops up the GUI? Oh noes, I must have messed up the argument parsing in the last pull request. Yep, that regex doesn't match firefox linux "native-messaging-hosts/translatelocally.json". Nor does it match any of them on Windows.

That's a bug in the benchmarking code in the extension. It should close the connection to the native messaging client.

It is also expected that you'd have multiple instances open on the benchmark page as it uses its own instance, not the one that the add-on uses for translating webpages. Under normal circumstances you'd only have a single instance running (at least, only one started by Firefox.)