From 30ea9b2f7ad8e27313db8155c7e4b02e1a3f1585 Mon Sep 17 00:00:00 2001 From: jonasbits Date: Thu, 20 Feb 2014 01:01:13 +0100 Subject: [PATCH] auto detect of ppost.jar now works the way it should --- chrome/content/pennyPostOptions.js | 12 +++++++++--- chrome/content/ppost.js | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/chrome/content/pennyPostOptions.js b/chrome/content/pennyPostOptions.js index 42d08f8..d7db180 100644 --- a/chrome/content/pennyPostOptions.js +++ b/chrome/content/pennyPostOptions.js @@ -86,13 +86,19 @@ function onTestRegEx(){ * Tries to populate the path of ppost.jar automatically */ function onDetectStampProgram(){ - var jarpath=getJarPath(); - if(jarpath==''){ + getJarPath(function(data){ + var jarpath=data; + dialog.ppost.value=jarpath; + prefs.setCharPref('extensions.ppost.path', dialog.ppost.value); + }); + + //var jarpath=getJarPath(); + /*if(jarpath==''){ alert(gStrBundle.getString("jarpathdetectfail")); }else{ dialog.ppost.value=jarpath; prefs.setCharPref('extensions.ppost.path', dialog.ppost.value); - } + }*/ } /** diff --git a/chrome/content/ppost.js b/chrome/content/ppost.js index 6cc086e..55d95f5 100644 --- a/chrome/content/ppost.js +++ b/chrome/content/ppost.js @@ -35,7 +35,7 @@ var gStampTypes={ UNKNOWN:0, * Tries to get the path of ppost.jar relative to the extension folder * This jar is in the lib folder of the extension folder */ -function getJarPath(){ +function getJarPath(callback){ try{ var eid = "{3748ced8-ae28-48ac-a954-4bff3360f72d}"; /**var ext = Components.classes["@mozilla.org/extensions/manager;1"] @@ -49,7 +49,7 @@ function getJarPath(){ Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID(eid, function(addon) { addonLocation = addon.getResourceURI("/lib/ppost.jar").QueryInterface(Components.interfaces.nsIFileURL).file.path; - alert("Copy this " + addonLocation); + callback(addonLocation); }); //end of AddonManager async call /*if(!ext.exists()){ throw new Error('ppost.jar not found in '+ext.path); @@ -59,9 +59,9 @@ function getJarPath(){ }catch(ex){ Components.utils.reportError(ex); //ignore - return ''; + //return ''; } - return "Copy path from popup dialog"; + //return "Copy path from popup dialog"; } /**