qzind / qz-print

Archive for legacy qz-print versions (1.8, 1.9). See https://github.com/qzind/tray for modern versions.
Other
141 stars 101 forks source link

Mime-type launcher #94

Closed tresf closed 8 years ago

tresf commented 9 years ago

A placeholder to add a mimetype/URI launcher for the web browsers which allows QZ Tray to be launched by URL, i.e.

image

Original request: "[Since] JS wont allow for waking the app, would it not be possible to define a MIME-type during the installation and just use that in order to wake the application from a website, just to get the connection for the two-way up and spinning"

I think this is doable at install time via a URL like

qz:launch

tresf commented 8 years ago

Initial support added via 66185b2, 4c40812 (Windows only). Linux and Mac will require some more research.

@klabarge if you're interested in researching the Linux side of things, please do and post your findings here.

tresf commented 8 years ago

Apple support added via b57c573f.

tresf commented 8 years ago

Linux support added via 5eb78bf which closes this issue out.

@lite1979 @klabarge can you test this out? The easiest way is to add this to an HTML file:

<a href="qz:launch">Launch QZ Tray</a>
klabarge commented 8 years ago

I compiled and installed the latest version on Ubuntu 14.04

I added the line:

<a href="qz:launch">Launch QZ Tray</a>

to sample.html to create a link.

When clicking the link in Chrome, the following dialogue appears:

image

When clicking "Launch Application," another instance of Chrome is launched. QZ Tray is not launched.

Doing this in Firefox results in the following:

image

tresf commented 8 years ago

Thanks Kyle. Can you try the following command please?

xdg-mime default qz-tray.desktop x-scheme-handler/qz

This will only affect the current logged in user but was the first approach I had tried.

tresf commented 8 years ago

Actually Kyle... instead can you try to run this command interactively, perhaps there's a bug with the way I'm calling it in our install script...

sudo update-desktop-database
klabarge commented 8 years ago

I first ran: sudo update-desktop-database and tried launching QZ Tray from both Chrome and Firefox.

  1. Chrome
    • Even after restarting the browser, a second instance of Chrome was launched. QZ Tray was not launched
  2. Firefox
    • A refresh of the page brought the dialogue below. After selecting "OK," QZ Tray was launched. image

I then ran xdg-mime default qz-tray.desktop x-scheme-handler/qz

tresf commented 8 years ago

Chrome works fine for me on both 14.04 and 12.04 so as long as I use that sudo update-desktop-database after install. I'm still perplexed as to why it needs to be run again...

In regards to it not launching for you in Chrome, try launching Google Chrome from command line via google-chrome and see if the error console says anything about why it won't launch.

tresf commented 8 years ago

Testing results (I will update this post for other distros):

tresf commented 8 years ago

Ubuntu 14.04 fixed via ba51664.

tresf commented 8 years ago

This seems to be broken for Firefox on OSX. Reopening.

tresf commented 8 years ago

Some more details about Firefox 43 + OS X 10.7:

Edit: Upstream bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=718422

Although Chrome and Safari work, Firefox seems to be pickier.

  1. The behavior between <a href="javascript:window.location("qz:launch");">... and <a href="qz:launch"> differs in Firefox on Mac which means we may need to change the code in sample.html to accommodate.
  2. If the following keys are added to about:config (Firefox on Mac), it shows the launch dialog, but doesn't have QZ Tray auto-filled as the application to launch.

    # Boolean
    network.protocol-handler.expose.qz=false
    network.protocol-handler.external.qz=true
    # String
    network.protocol-handler.app.qz=/Applications/QZ Tray.app
  3. Furthermore, selecting QZ Tray from the list of possible applications does not update the keys in about:config, so capturing the proper settings is proving difficult.

I've reached out to Mike Kaply for assistance. Perhaps he knows a trick to get this working. Note, this problem doesn't occur with mailto: links, which is what I used for my baseline when testing.

Edit: Update, this seems to remedy the problem... I've no idea how to automate this though.

  1. Open Firefox/Profiles/<current profile>.default/mimeTypes.rdf
  2. Add the following lines:

    <RDF:Description RDF:about="urn:scheme:handler:qz" NC:useSystemDefault="true" NC:alwaysAsk="false"/>
    <RDF:Description RDF:about="urn:scheme:qz" NC:value="qz">
     <NC:handlerProp RDF:resource="urn:scheme:handler:qz"/>
    </RDF:Description>
    <!-- FIND 
    <RDF:Seq RDF:about="urn:schemes:root">
     <RDF:li RDF:resource="urn:scheme:webcal"/>
     <RDF:li RDF:resource="urn:scheme:ircs"/>
     <RDF:li RDF:resource="urn:scheme:mailto"/>
     <RDF:li RDF:resource="urn:scheme:irc"/>
     APPEND -->
     <RDF:li RDF:resource="urn:scheme:qz" />
     <!--
    </RDF:Seq> -->
tresf commented 8 years ago

I think I figured out a fix. Ready to test via dd5956e.

tresf commented 8 years ago

Works so as long as preference network.protocol-handler.expose.qz is set to false, but only for physical qz:launch links, not for window.location.assign("qz:launch"); (how we recommend launching it).

Mike's offered to write a protocol handler... I think this is quite overkill, but I don't think we have an option at this point if we want our "Launch QZ Tray" button to work.