Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Fix qz:launch on Mac
Browse files Browse the repository at this point in the history
Closes #94
  • Loading branch information
tresf committed Jan 20, 2016
1 parent 6a9aeb6 commit f742103
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
12 changes: 10 additions & 2 deletions ant/firefox/firefox-cert.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
bindir="$ffdir/Contents/Resources/"
prefdir="$ffdir/Contents/Resources/defaults/pref"
installdir="${apple.installdir}"
trayapp="$installdir" # use .app package
else
# Linux, etc
location=$(readlink -f "$0")
Expand All @@ -64,6 +65,7 @@ else
bindir="$ffdir"
prefdir="$ffdir/defaults/pref"
installdir="${linux.installdir}"
trayapp="" # skip
fi

# Firefox was not found, skip Firefox certificate installation
Expand Down Expand Up @@ -108,7 +110,11 @@ if [ "$1" == "uninstall" ]; then
ret2=$?
perl -pi -e "s#\\\${timestamp}#-1#g" "$bindir/${firefoxconfig.name}"
ret3=$?
if [ $ret1 -eq 0 ] && [ $ret2 -eq 0 ] && [ $ret3 -eq 0 ]; then
perl -pi -e "s#\\\${commonName}#$cname#g" "$bindir/${firefoxconfig.name}"
ret4=$?
perl -pi -e "s#\\\${trayApp}##g" "$bindir/${firefoxconfig.name}"
ret5=$?
if [ $ret1 -eq 0 ] && [ $ret2 -eq 0 ] && [ $ret3 -eq 0 ] && [ $ret4 -eq 0 ] && [ $ret5 -eq 0 ]; then
echo -e "${bash.success} Certificate removed successfully"
else
echo -e "${bash.failure} ${socket.name} Certificate removal failed"
Expand Down Expand Up @@ -177,7 +183,9 @@ if [ -f "$bindir/${firefoxconfig.name}" ]; then
ret3=$?
perl -pi -e "s#\\\${commonName}#$cname#g" "$bindir/${firefoxconfig.name}"
ret4=$?
if [ $ret1 -eq 0 ] && [ $ret2 -eq 0 ] && [ $ret3 -eq 0 ] && [ $ret4 -eq 0 ]; then
perl -pi -e "s#\\\${trayApp}#$trayapp#g" "$bindir/${firefoxconfig.name}"
ret5=$?
if [ $ret1 -eq 0 ] && [ $ret2 -eq 0 ] && [ $ret3 -eq 0 ] && [ $ret4 -eq 0 ] && [ $ret5 -eq 0 ]; then
echo -e "${bash.success} Certificate installed"
else
echo -e "${bash.failure} Certificate installation failed"
Expand Down
24 changes: 24 additions & 0 deletions ant/firefox/firefox-config.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var observer = {
} else if (needsCert()) {
deleteCertificate();
installCertificate();
registerProtocol();
}

// Compares the timestamp embedded in this script against that stored in the browser's about:config
Expand Down Expand Up @@ -51,6 +52,29 @@ var observer = {
}
}

// Register the specified protocol to open with the specified application
function registerProtocol() {
var trayApp = "${trayApp}";
if (!trayApp) { return; }
try {
var hservice = Components.classes["@mozilla.org/uriloader/handler-service;1"].getService(Components.interfaces.nsIHandlerService);
var pservice = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);

var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
file.initWithPath(trayApp);

var lhandler = Components.classes["@mozilla.org/uriloader/local-handler-app;1"].createInstance(Components.interfaces.nsILocalHandlerApp);
lhandler.executable = file;
lhandler.name = "${socket.name}";

var protocol = pservice.getProtocolHandlerInfo("${vendor.name}");
protocol.preferredApplicationHandler = lhandler;
protocol.preferredAction = 2; // useHelperApp
protocol.alwaysAskBeforeHandling = false;
hservice.store(protocol);
} catch (ignore) {}
}

// Returns true if the certificate already exists
function certExists(nickname) {
try {
Expand Down
8 changes: 6 additions & 2 deletions ant/windows/windows-keygen.js.in
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ function deleteFirefoxCertificate() {
var replacements = {
"${certData}" : "",
"${uninstall}" : "true",
"${commonName}" : cn
"${timestamp}" : "-1",
"${commonName}" : cn,
"${trayApp}" : ""
};

// 1. readPlainCert() reads in certificate, stripping non-base64 content
Expand All @@ -402,7 +404,9 @@ function installFirefoxCertificate() {
var replacements = {
"${certData}" : readPlainCert(derCert),
"${uninstall}" : "false",
"${timestamp}" : new Date().getTime()
"${timestamp}" : new Date().getTime(),
"${commonName}" : cn,
"${trayApp}" : ""
};

// 1. readPlainCert() reads in certificate, stripping non-base64 content
Expand Down

0 comments on commit f742103

Please sign in to comment.