[Pkg-mozext-commits] [perspectives-extension] 02/44: Old preferences migration is done and tested successfully
David Prévot
taffit at moszumanska.debian.org
Sun Jun 26 04:59:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository perspectives-extension.
commit c47a53e9ff39424bd7f5e37067ebca3919b7dabc
Author: Alexey Vesnin <serxis at gmail.com>
Date: Thu May 14 12:59:53 2015 -0700
Old preferences migration is done and tested successfully
minor conflict resolution by dave during cherrypick
---
plugin/chrome/content/init.js | 39 ++++++++++++++++++++++++++++++++++--
plugin/chrome/content/initialize.xul | 3 ++-
plugin/defaults/preferences/prefs.js | 2 +-
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/plugin/chrome/content/init.js b/plugin/chrome/content/init.js
index 70f24af..4384fb9 100644
--- a/plugin/chrome/content/init.js
+++ b/plugin/chrome/content/init.js
@@ -24,8 +24,7 @@ var Pers_init = {
evtLoad: function(evt){
Perspectives.init_data();
Perspectives.initNotaries();
- var root_prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
+ var root_prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
// call this *after* the document has loaded
// so we have access to the stringbundle from statusbar.xul
@@ -47,5 +46,41 @@ var Pers_init = {
if(!Perspectives.root_prefs.getBoolPref("extensions.perspectives.show_label")){
document.getElementById("perspective-statusbar-label").hidden = true;
}
+ },
+
+ // Preference migration from old names to new ones. Written by Alexey Vesnin
+ migrateOldSettings: function() {
+ var preflist_numeric = ["perspectives.quorum_thresh","perspectives.required_duration","perspectives.security_settings","perspectives.max_timespan_for_inconsistency_test","perspectives.weak_consistency_time_limit","perspectives.max_cache_age_sec"];
+ var preflist_string = ["perspectives.svg","perspectives.whitelist","perspectives.additional_notary_list","perspectives.default_notary_list"];
+ var preflist_bool = ["perspectives.exceptions.permanent","perspectives.exceptions.enabled","perspectives.check_good_certificates","perspectives.require_user_permission","perspectives.show_label","perspectives.trust_https_with_weak_consistency","perspectives.prompt_update_all_https_setting","perspectives.enable_default_list_auto_update","perspectives.use_default_notary_list"];
+ var root_prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ var migration_needed = root_prefs.getBoolPref("extensions.perspectives.preference_migration");
+
+ var tmpNum = 0;
+ var tmpStr = "";
+ var tmpBool = true;
+
+ if (migration_needed){
+ for (index = 0; index < preflist_numeric.length; ++index) {
+ if (root_prefs.getPrefType(preflist_numeric[index]) !== root_prefs.PREF_INVALID){
+ tmpNum=root_prefs.getIntPref(preflist_numeric[index]);
+ root_prefs.setIntPref("extensions." + preflist_numeric[index],tmpNum);
+ }
+ }
+ for(index = 0; index < preflist_string.length; ++index) {
+ if(root_prefs.getPrefType(preflist_string[index]) !== root_prefs.PREF_INVALID){
+ tmpStr = root_prefs.getCharPref("" + preflist_string[index]);
+ root_prefs.setCharPref("extensions." + preflist_string[index],tmpStr);
+ }
+ }
+ for(index = 0; index < preflist_bool.length; ++index) {
+ if(root_prefs.getPrefType(preflist_bool[index]) !== root_prefs.PREF_INVALID){
+ tmpBool = root_prefs.getBoolPref("" + preflist_bool[index]);
+ root_prefs.setBoolPref("extensions." + preflist_bool[index],tmpBool);
+ }
+ }
+ root_prefs.setBoolPref("extensions.perspectives.preference_migration",false);
+ }
}
+
};
diff --git a/plugin/chrome/content/initialize.xul b/plugin/chrome/content/initialize.xul
index 8ac3910..c074e2e 100644
--- a/plugin/chrome/content/initialize.xul
+++ b/plugin/chrome/content/initialize.xul
@@ -9,7 +9,8 @@
<script type="application/x-javascript" src="init.js" />
<script type="application/x-javascript" src="notaries.js"/>
<script type="text/javascript">
-
+
+ Pers_init.migrateOldSettings();
// don't load or run anything until after the page has loaded
window.addEventListener('load', function(){ Pers_init.evtLoad(); }, false);
diff --git a/plugin/defaults/preferences/prefs.js b/plugin/defaults/preferences/prefs.js
index 94baf87..ee844d6 100755
--- a/plugin/defaults/preferences/prefs.js
+++ b/plugin/defaults/preferences/prefs.js
@@ -25,4 +25,4 @@ pref("extensions.perspectives.default_notary_list","");
pref("extensions.perspectives.use_default_notary_list",true);
pref("extensions.perspectives.enable_default_list_auto_update",false);
pref("extensions.perspectives.first_run", true);
-
+pref("extensions.perspectives.preference_migration", true);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git
More information about the Pkg-mozext-commits
mailing list