[Pkg-mozext-commits] [automatic-save-folder] 73/133: Fix : Update the Add-ons detection for Firefox 4.0.* (Thanks to Rakundo) Add : Possibility to specify the size of the preference window in the localization files.

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:53 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch wip
in repository automatic-save-folder.

commit c28671a84aedbef4c34e7813e65b16c7cda92543
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Sat Jul 10 13:43:40 2010 +0000

    Fix : Update the Add-ons detection for Firefox 4.0.* (Thanks to Rakundo)
    Add : Possibility to specify the size of the preference window in the
          localization files.
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@79 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf.js             | 83 ++++++++++++++++++++++++++++++++++++++--------
 content/asf_download.js    | 53 ++++++++++++++++++++---------
 content/asf_right_click.js | 73 +++++++++++++++++++++++++++-------------
 content/common.dtd         |  2 +-
 content/options.xul        |  3 ++
 locale/en-US/asf.dtd       |  8 ++++-
 locale/fr/asf.dtd          | 10 ++++--
 locale/it/asf.dtd          |  8 ++++-
 locale/ru/asf.dtd          |  8 ++++-
 9 files changed, 189 insertions(+), 59 deletions(-)

diff --git a/content/asf.js b/content/asf.js
index 7ecd09a..c0b407c 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -34,18 +34,11 @@ var automatic_save_folder = {
 		
 	asf_load: function () {
 		
-		if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0) 
-		{
-			this.firefoxversion = "3";
-		}
-		else 
-		{
-			this.firefoxversion = "2";
-		}
+		this.checkFirefoxVersion();
 		
 		
-		// init the preference for firefox 3
-		if (this.firefoxversion == "3")
+		// init the preference for firefox 3+
+		if (this.firefoxversion >= "3")
 		{
 			// set lastdir to "enable" if the user just updated from previous version and had it disabled
 			var lastdir = document.getElementById("asf-lasdir");
@@ -61,6 +54,15 @@ var automatic_save_folder = {
 		this.asf_toggleradio(); // set the radio choice to the right place
 		this.asf_variablemode(); // check if variable mode is on or off, and change mode if needed
 		
+		// Resize the preferences window to match the localization needs.
+		// I don't know why width, or css width are not working, so let's use a script to resize the preferences window on load.
+		var resize = document.getElementById("asf-preferences-window-resize").value;
+		if (resize == "true")
+		{
+			var asf_pref_window = document.getElementById("asf_pref");
+			asf_pref_window.width = document.getElementById("asf-preferences-window-width").value;
+			asf_pref_window.height = document.getElementById("asf-preferences-window-height").value;
+		}
 		
 		
 		//Detect OS
@@ -467,7 +469,7 @@ var automatic_save_folder = {
 			document.getElementById("asf-rightclicktimeout").hidden = true;   // Hide the right-click timeout checkbox
 			document.getElementById("asf-rightclickdesc-ff2").hidden = false; // Show right-click not working on Firefox 2.0
 		}
-		if (this.firefoxversion == 3)
+		if (this.firefoxversion >= 3)
 		{
 			if (this.DownloadSort_isEnabled()) // if Download sort is installed, display a message "right click disabled"
 			{
@@ -834,8 +836,50 @@ var automatic_save_folder = {
 	},
 
 
+	checkFirefoxVersion: function() {
+		
+		if (this.versionChecker.compare(this.appInfo.version, "4.0b1") >= 0)
+		{
+			this.firefoxversion = "4";
+		}
+		else if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0) 
+		{
+			this.firefoxversion = "3";
+		}
+		else 
+		{
+			this.firefoxversion = "2";
+		}
+	},
+
+
 	DownloadSort_isEnabled: function() {
-		// Check for Download sort add-on, if enabled return true. (works only on 3.x)
+		// Check for Download sort add-on, if enabled return true. 
+		
+		if (this.firefoxversion >= 4)
+		{
+			/*
+			var DownloadSort = false;
+			Components.utils.import("resource://gre/modules/AddonManager.jsm");
+			AddonManager.getAddonByID("asf at mangaheart.org", function(addon) {
+			DownloadSort = addon.isActive;
+			});
+			//1st access to DownloadSort doesnt work - time to short ; New asynchronous addon manager is a problem :(
+			alert("1st try to get the version: " + DownloadSort);
+			alert("2nd try to get the version: " + DownloadSort);
+			return DownloadSort;
+			*/
+			
+			// let's use the same method than Firefox 3, but it doesn't detect enabled state in real time anymore
+			// Firefox need to be restarted for addon state to takes effect.
+			var enabledItems = this.prefManager.getCharPref("extensions.enabledAddons");
+			var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+			var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+			
+			if (DownloadSort >= 0) return true;
+		}
+		
+		// (works only on 3.x)
 		if (this.firefoxversion == 3)
 		{
 			var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
@@ -849,7 +893,18 @@ var automatic_save_folder = {
 
 
 	DownThemAll_isEnabled: function() {
-		// Check for DTA add-on, if enabled return true. (works only on 3.x)
+		// Check for DTA add-on, if enabled return true. 
+		
+		if (this.firefoxversion >= 4)
+		{
+			var enabledItems = this.prefManager.getCharPref("extensions.enabledAddons");
+			var dsort_GUUID = "{DDC359D1-844A-42a7-9AA1-88A850A938A8}";
+			var DTA = enabledItems.indexOf(dsort_GUUID,0);
+			
+			if (DTA >= 0) return true;
+		}
+		
+		//(works only on 3.x)
 		if (this.firefoxversion == 3)
 		{
 			var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
@@ -917,7 +972,7 @@ var automatic_save_folder = {
 		
 		//save the rightclick (set timeout for header(Content-Disposition:) true = 0, false = 1000)
 		// Only if DownloadSort is not enabled (prevent conflict)
-		if ( !this.DownloadSort_isEnabled() && this.firefoxversion == 3) // only for firefox 3, Firefox2 doesn't use timeout option
+		if ( !this.DownloadSort_isEnabled() && this.firefoxversion >= 3) // only for firefox 3+, Firefox2 doesn't use timeout option
 		{
 			var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout").checked;
 			this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == true ? 0 : 1000);
diff --git a/content/asf_download.js b/content/asf_download.js
index 409d8c5..2664386 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -37,14 +37,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		var prefManager = automatic_save_folder.prefManager;
 		var versionChecker = automatic_save_folder.versionChecker;
 		var appInfo = automatic_save_folder.appInfo;
-		if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
-		{
-			this.firefoxversion = "3";
-		}
-		else
-		{
-			this.firefoxversion = "2";
-		}
+		this.checkFirefoxVersion();
 		
 		// Enable Private Browsing support with filepicker - Thanks to Ehsan Akhgari at http://ehsanakhgari.org/
 		if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
@@ -86,7 +79,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		}
 		
 		// set the last saved path into asf.lastpath
-		if (this.firefoxversion == "3")   // take the download.lastDir if it's FF3
+		if (this.firefoxversion >= "3")   // take the download.lastDir if it's FF3
 		{
 			var folder = this.loadUnicodeString("browser.download.lastDir");
 		}
@@ -160,7 +153,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				}
 				else  // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
 				{
-					if (this.firefoxversion == "3")
+					if (this.firefoxversion >= "3")
 					{
 						var lastpath = this.loadUnicodeString("browser.download.lastDir");
 					}
@@ -178,7 +171,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			}
 			else // else, if savetype == 0  (folder is set to last folder)
 			{
-				if (this.firefoxversion == "3")
+				if (this.firefoxversion >= "3")
 				{
 					var lastpath = this.loadUnicodeString("browser.download.lastDir");
 				}
@@ -209,7 +202,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		
 		// in every case, set the new file hosted domain to tempdomain if not in private browsing
 		var inPrivateBrowsing = false;
-		if (this.firefoxversion == 3)
+		if (this.firefoxversion >= 3)
 		{
 			try {
 				var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
@@ -275,7 +268,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 								.getService(Components.interfaces.nsIProperties)
 								.get("Desk", Components.interfaces.nsILocalFile);
 			directory = desk;
-			if (this.firefoxversion == 3)
+			if (this.firefoxversion >= 3)
 			{
 				var dnldMgr = Components.classes["@mozilla.org/download-manager;1"]
 									.getService(Components.interfaces.nsIDownloadManager);
@@ -310,7 +303,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			this.saveUnicodeString("browser.download.lastDir", directory.path);
 		}
 		
-		if (this.firefoxversion == 3)
+		if (this.firefoxversion >= 3)
 		{
 		
 			var inPrivateBrowsing = false;
@@ -644,7 +637,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				folder = "...";
 			}
 		}
-		if (this.firefoxversion == 3)
+		if (this.firefoxversion >= 3)
 		{
 		
 			var inPrivateBrowsing = false;
@@ -1020,8 +1013,36 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 	},
 
 
+	checkFirefoxVersion: function() {
+		
+		if (this.versionChecker.compare(this.appInfo.version, "4.0b1") >= 0)
+		{
+			this.firefoxversion = "4";
+		}
+		else if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0) 
+		{
+			this.firefoxversion = "3";
+		}
+		else 
+		{
+			this.firefoxversion = "2";
+		}
+	},
+
+
 	DownThemAll_isEnabled: function() {
-		// Check for DTA add-on, if enabled return true. (works only on 3.x)
+		// Check for DTA add-on, if enabled return true. 
+		
+		if (this.firefoxversion >= 4)
+		{
+			var enabledItems = this.prefManager.getCharPref("extensions.enabledAddons");
+			var dsort_GUUID = "{DDC359D1-844A-42a7-9AA1-88A850A938A8}";
+			var DTA = enabledItems.indexOf(dsort_GUUID,0);
+			
+			if (DTA >= 0) return true;
+		}
+		
+		//(works only on 3.x)
 		if (this.firefoxversion == 3)
 		{
 			var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 31af772..50183e7 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -35,18 +35,15 @@ var automatic_save_folder = {
 		if (!asf_rightclick_loaded) 
 		{
 			asf_rightclick_loaded = true;
+			this.checkFirefoxVersion();
 			
 			// Right-click feature doesn't work on Firefox 2 (Can't detect installed add-on and prevent conflict with Download Sort)
-			if (this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
+			if (this.firefoxversion >= 3)
 			{
 				// Replace original Right-click menu with ASF Right-click menu
 				// Not compatible with Download Sort extension (Dsort rewrites the whole function, it will conflict with ASF).
 				// Detect if Download Sort is installed and enabled, and activate ASF rightclick only if DSort is not already loaded.
-				var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
-				var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
-				var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
-				
-				if (DownloadSort == -1)  // Download Sort is not enabled, load ASF rightclick replacement && Firefox 2.0 min
+				if (!this.DownloadSort_isEnabled())  // Download Sort is not enabled, load ASF rightclick replacement && Firefox 2.0 min
 				{
 					// adding ASF filtering function at the beginning of the getTargetFile function.
 					// Code from Paolo Amadini, MAF add-on developer. Thank you !
@@ -90,18 +87,6 @@ var automatic_save_folder = {
 			
 			// Setting private variables usable in this function
 			var prefManager = this.prefManager;		
-			var versionChecker = this.versionChecker;
-			var appInfo = this.appInfo;
-			
-			if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0) 
-			{
-				this.firefoxversion = "3";
-			}
-			else 
-			{
-				this.firefoxversion = "2";
-			}
-			
 			
 			// Check if there is any filter in list
 			var nbrfilters = 	prefManager.getIntPref("extensions.asf.filtersNumber");		
@@ -145,7 +130,7 @@ var automatic_save_folder = {
 			}
 			
 			// set the last folder path used into asf.lastpath
-			if (this.firefoxversion == "3")   // take the download.lastDir if it's FF3
+			if (this.firefoxversion >= "3")   // take the download.lastDir if it's FF3
 			{
 				var folder = this.loadUnicodeString("browser.download.lastDir");
 			}
@@ -219,7 +204,7 @@ var automatic_save_folder = {
 					}	
 					else  // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
 					{
-						if (this.firefoxversion == "3")
+						if (this.firefoxversion >= "3")
 						{
 							var lastpath = this.loadUnicodeString("browser.download.lastDir");
 						}
@@ -237,7 +222,7 @@ var automatic_save_folder = {
 				}
 				else // else, if savetype == 0  (folder is set to last folder)
 				{
-					if (this.firefoxversion == "3")
+					if (this.firefoxversion >= "3")
 					{
 						var lastpath = this.loadUnicodeString("browser.download.lastDir");
 					}
@@ -268,7 +253,7 @@ var automatic_save_folder = {
 			
 			// in every case, set the new file hosted domain to tempdomain if not in private browsing
 			var inPrivateBrowsing = false;
-			if (this.firefoxversion == 3)
+			if (this.firefoxversion >= 3)
 			{
 				try {
 					var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
@@ -312,7 +297,7 @@ var automatic_save_folder = {
 			this.saveUnicodeString("browser.download.lastDir", directory.path);		
 		}
 		
-		if (this.firefoxversion == 3)
+		if (this.firefoxversion >= 3)
 		{
 			
 			var inPrivateBrowsing = false;
@@ -705,6 +690,48 @@ var automatic_save_folder = {
 	},
 	
 	
+	checkFirefoxVersion: function() {
+		
+		if (this.versionChecker.compare(this.appInfo.version, "4.0b1") >= 0)
+		{
+			this.firefoxversion = "4";
+		}
+		else if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0) 
+		{
+			this.firefoxversion = "3";
+		}
+		else 
+		{
+			this.firefoxversion = "2";
+		}
+	},
+	
+	
+	DownloadSort_isEnabled: function() {
+		// Check for Download sort add-on, if enabled return true. 
+		
+		if (this.firefoxversion >= 4)
+		{
+			var enabledItems = this.prefManager.getCharPref("extensions.enabledAddons");
+			var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+			var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+			
+			if (DownloadSort >= 0) return true;
+		}
+		
+		// (works only on 3.x)
+		if (this.firefoxversion == 3)
+		{
+			var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
+			var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+			var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+			
+			if (DownloadSort >= 0) return true;
+		}
+		return false;
+	},
+	
+	
 	readHiddenPref: function(pref_place, type, ret) {
 		try 
 		{
diff --git a/content/common.dtd b/content/common.dtd
index e1a2db6..b97750f 100644
--- a/content/common.dtd
+++ b/content/common.dtd
@@ -1,2 +1,2 @@
 <!-- Current version -->
-<!ENTITY asf.version "1.0.2b Rev78">
\ No newline at end of file
+<!ENTITY asf.version "1.0.2b Rev79">
\ No newline at end of file
diff --git a/content/options.xul b/content/options.xul
index d6f7f3d..c21182f 100644
--- a/content/options.xul
+++ b/content/options.xul
@@ -150,6 +150,9 @@
 			<textbox id="asf-current-domain" value="" />
 			<textbox id="asf-current-filename" value="" />
 			<textbox id="asf-current-url" value="" />
+			<textbox id="asf-preferences-window-resize" value="&asf.preferences_window.resize;" />
+			<textbox id="asf-preferences-window-width" value="&asf.preferences_window.width;" />
+			<textbox id="asf-preferences-window-height" value="&asf.preferences_window.height;" />
 		</groupbox>
 	</vbox>
 	<vbox id="asf-tab-options" hidden="true" flex="1000">
diff --git a/locale/en-US/asf.dtd b/locale/en-US/asf.dtd
index 96af109..b3a6fab 100644
--- a/locale/en-US/asf.dtd
+++ b/locale/en-US/asf.dtd
@@ -1,4 +1,10 @@
-<!-- browser and save dialog-->
+<!-- ASF Settings -->
+<!-- Change the preferences window size to fit your localization. Default values : resize=false width=617 height=423, in pixels-->
+<!ENTITY asf.preferences_window.resize "false">
+<!ENTITY asf.preferences_window.width "617">
+<!ENTITY asf.preferences_window.height "423">
+
+<!-- browser and save dialog-->
 <!ENTITY prefwindow.title "Automatic Save Folder Preferences">
 <!ENTITY asf.label "Automatic Save Folder...">
 <!ENTITY asf.addedit.label "Add or edit a filter">
diff --git a/locale/fr/asf.dtd b/locale/fr/asf.dtd
index ab48174..1aba20a 100644
--- a/locale/fr/asf.dtd
+++ b/locale/fr/asf.dtd
@@ -1,4 +1,10 @@
-<!-- browser and save dialog-->
+<!-- ASF Settings -->
+<!-- Change the preferences window size to fit your localization. Default values : resize=false width=617 height=423, in pixels-->
+<!ENTITY asf.preferences_window.resize "true">
+<!ENTITY asf.preferences_window.width "647">
+<!ENTITY asf.preferences_window.height "423">
+
+<!-- browser and save dialog-->
 <!ENTITY prefwindow.title "Préférences pour Automatic Save Folder">
 <!ENTITY asf.label "Automatic Save Folder...">
 <!ENTITY asf.addedit.label "Ajouter ou éditer un filtre">
@@ -80,7 +86,7 @@
 
 <!ENTITY asf.options.groupbox5.label "Interface graphique">
 <!ENTITY asf.pathlist_defaultforceontop.bool "Dans les menus déroulants, afficher en premier le chemin d'enregistrement par défaut.">
-<!ENTITY asf.pathlist_alphasort.bool "Trier la liste des chemin d'enregistrement par ordre alphabétique.">
+<!ENTITY asf.pathlist_alphasort.bool "Trier la liste des chemins d'enregistrement par ordre alphabétique.">
 <!ENTITY asf.rowmatchinghighlight.label "Couleur de surbrillance lors de la séléction d'un filtre valide :">
 <!ENTITY asf.rowmatchinghighlight.color "Couleur d'ASF">
 <!ENTITY asf.rowmatchinghighlight.system "Couleur système">
diff --git a/locale/it/asf.dtd b/locale/it/asf.dtd
index f000cb1..f7e626d 100644
--- a/locale/it/asf.dtd
+++ b/locale/it/asf.dtd
@@ -1,4 +1,10 @@
-<!-- browser and save dialog-->
+<!-- ASF Settings -->
+<!-- Change the preferences window size to fit your localization. Default values : resize=false width=617 height=423, in pixels-->
+<!ENTITY asf.preferences_window.resize "false">
+<!ENTITY asf.preferences_window.width "617">
+<!ENTITY asf.preferences_window.height "423">
+
+<!-- browser and save dialog-->
 <!ENTITY prefwindow.title "Preferenze di Automatic Save Folder">
 <!ENTITY asf.label "Automatic Save Folder...">
 <!ENTITY asf.addedit.label "Aggiungi o modifica filtro">
diff --git a/locale/ru/asf.dtd b/locale/ru/asf.dtd
index 69ce3d7..95fa756 100644
--- a/locale/ru/asf.dtd
+++ b/locale/ru/asf.dtd
@@ -1,4 +1,10 @@
-<!-- browser and save dialog-->
+<!-- ASF Settings -->
+<!-- Change the preferences window size to fit your localization. Default values : resize=false width=617 height=423, in pixels-->
+<!ENTITY asf.preferences_window.resize "false">
+<!ENTITY asf.preferences_window.width "617">
+<!ENTITY asf.preferences_window.height "423">
+
+<!-- browser and save dialog-->
 <!ENTITY prefwindow.title "Настройки Automatic Save Folder">
 <!ENTITY asf.label "Automatic Save Folder...">
 <!ENTITY asf.addedit.label "Добавить или изменить фильтр">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/automatic-save-folder.git



More information about the Pkg-mozext-commits mailing list