Bug 379647 Remove 4.x ldap address book migration from the trunk - Part 1 Remove ldap prefs service migration, r/sr=bienvenu

This commit is contained in:
bugzilla%standard8.demon.co.uk 2007-05-04 15:43:53 +00:00
Родитель 8b579d6ee0
Коммит 13edab0e33
8 изменённых файлов: 3 добавлений и 244 удалений

Просмотреть файл

@ -183,17 +183,6 @@ function delayedOnLoadAddressBook()
InitCommonJS();
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
var ldapPrefs = null;
try {
ldapPrefs = Components.classes["@mozilla.org/ldapprefs-service;1"]
.getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {Components.utils.reportError("ERROR: Cannot get the LDAP service\n" + ex + "\n");}
if (ldapPrefs) {
ldapPrefs.migratePrefsIfNeeded();
}
GetCurrentPrefs();
AddPrefObservers();

Просмотреть файл

@ -86,7 +86,6 @@ var gMsgCompose;
var gAccountManager;
var gIOService;
var gPromptService;
var gLDAPPrefsService;
var gWindowLocked;
var gContentChanged;
var gAutoSaving;
@ -134,18 +133,6 @@ function InitializeGlobalVariables()
gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
if (gLDAPPrefsService) {
try {
gLDAPPrefsService = gLDAPPrefsService
.getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {Components.utils.reportError("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
if (gLDAPPrefsService) {
gLDAPPrefsService.migratePrefsIfNeeded();
}
}
gMsgCompose = null;
gWindowLocked = false;
gContentChanged = false;
@ -183,7 +170,6 @@ function ReleaseGlobalVariables()
gAccountManager = null;
gIOService = null;
gPromptService = null;
gLDAPPrefsService = null;
gCurrentIdentity = null;
gCurrentAutocompleteDirectory = null;
gAutocompleteSession = null;

Просмотреть файл

@ -52,10 +52,6 @@ var gComposePane = {
if (kLDAPPrefContractID in Components.classes)
this.mLDAPPrefsService = Components.classes[kLDAPPrefContractID].getService(Components.interfaces.nsILDAPPrefsService);
if (this.mLDAPPrefsService) {
this.mLDAPPrefsService.migratePrefsIfNeeded();
}
this.createDirectoriesList();
// build the local address book menu list. We do this by hand instead of using the xul template

Просмотреть файл

@ -18,8 +18,6 @@ function initLDAPPrefsService()
if (LDAP_PREF_CONTRACT in Components.classes)
{
gLDAPPrefsService = Components.classes[LDAP_PREF_CONTRACT].getService(Components.interfaces.nsILDAPPrefsService);
// Also ensure that 4.x prefences have been migrated
gLDAPPrefsService.migratePrefsIfNeeded();
}
}

Просмотреть файл

@ -43,20 +43,10 @@
#include "nsIPrefBranch.idl"
/**
* this service implements migrating ldap prefs from 4.x format
* to mozilla format.
* This service is obsolete and expected to go away very soon.
*/
[scriptable, uuid(37418e42-b5fc-442c-a599-4c8b3131205e)]
[scriptable, uuid(667f6ab8-dbaf-49cb-be43-45ffa032b3de)]
interface nsILDAPPrefsService: nsISupports {
/**
* Convert 4.x ldap prefs to mozilla format
* hostname, dn, scope, port are converted to uri
* Also converts the autocompletion preference from 4.x format
* (ldap_2.servers.<server-name>.autocomplete.enabled)
* to mozilla format (ldap_2.servers.directoryServer)
*/
void migratePrefsIfNeeded();
/**
* This will create an array with entries

Просмотреть файл

@ -180,17 +180,6 @@ function OnLoadAddressBook()
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_results.version");
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
var ldapPrefs = null;
try {
ldapPrefs = Components.classes["@mozilla.org/ldapprefs-service;1"]
.getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {Components.utils.reportError("ERROR: Cannot get the LDAP service\n" + ex + "\n");}
if (ldapPrefs) {
ldapPrefs.migratePrefsIfNeeded();
}
GetCurrentPrefs();
AddPrefObservers();

Просмотреть файл

@ -41,16 +41,13 @@
const NS_LDAPPREFSSERVICE_CONTRACTID =
"@mozilla.org/ldapprefs-service;1";
const NS_LDAPPREFSSERVICE_CID =
Components.ID("{37418e42-b5fc-442c-a599-4c8b3131205e}");
Components.ID("{667f6ab8-dbaf-49cb-be43-45ffa032b3de}");
/* interfaces used in this file */
const nsISupports = Components.interfaces.nsISupports;
const nsISupportsString = Components.interfaces.nsISupportsString;
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
const nsILDAPURL = Components.interfaces.nsILDAPURL;
const nsILDAPPrefsService = Components.interfaces.nsILDAPPrefsService;
const kDefaultLDAPPort = 389;
const kDefaultSecureLDAPPort = 636;
/* pref branches used in this file */
const prefRoot = "ldap_2.servers";
@ -59,8 +56,6 @@ const parent = "ldap_2.servers.";
/* nsLDAPPrefs service */
function nsLDAPPrefsService() {}
nsLDAPPrefsService.prototype.prefs_migrated = false;
nsLDAPPrefsService.prototype.QueryInterface =
function (iid) {
@ -115,176 +110,6 @@ function (prefBranch, aCount) {
return childList;
}
/* migrate 4.x ldap prefs to mozilla format.
Converts hostname, basedn, port to uri (nsLDAPURL).
*/
nsLDAPPrefsService.prototype.migratePrefsIfNeeded =
function () {
// Have we already migrated prefs during this instance?
if (this.prefs_migrated) return;
// Now check if the prefs have been migrated.
var prefInt = null;
var pref_string;
var ldapUrl = null;
var enable = false;
var host;
try {
prefInt = Components.classes["@mozilla.org/preferences-service;1"];
prefInt = prefInt.getService(Components.interfaces.nsIPrefBranch);
}
catch (ex) {
dump("nsLDAPPrefsService: failed to get prefs service!\n");
return;
}
var migrated = false;
try{
migrated = prefInt.getBoolPref("ldap_2.prefs_migrated");
}
catch(ex){}
if (migrated){
this.prefs_migrated = true;
return;
}
var useDirectory = null;
try{
useDirectory = prefInt.getBoolPref("ldap_2.servers.useDirectory");
}
catch(ex) {}
/* generate the list of directory servers from preferences */
var prefCount = {value:0};
var availDirectories = null;
var arrayOfDirectories;
try {
arrayOfDirectories = this.getServerList(prefInt, prefCount);
}
catch (ex) {
arrayOfDirectories = null;
}
if (arrayOfDirectories) {
var position;
var description;
var dirType;
var j = 0;
availDirectories = new Array();
for (var i = 0; i < prefCount.value; i++)
{
if ((arrayOfDirectories[i] != "ldap_2.servers.pab") &&
(arrayOfDirectories[i] != "ldap_2.servers.history")) {
try{
position = prefInt.getIntPref(arrayOfDirectories[i]+".position");
}
catch(ex){
position = 1;
}
try{
dirType = prefInt.getIntPref(arrayOfDirectories[i]+".dirType");
}
catch(ex){
dirType = 1;
}
if ((position != 0) && (dirType == 1)) {
try{
description = prefInt.getComplexValue(arrayOfDirectories[i]+".description",
Components.interfaces.nsISupportsString).data;
}
catch(ex){
description = null;
}
if (description) {
availDirectories[j] = new Array(2);
availDirectories[j][0] = arrayOfDirectories[i];
availDirectories[j][1] = description;
j++;
}
}
}
}
}
for (var i = 0; i < availDirectories.length; i++) {
pref_string = availDirectories[i][0];
try{
host = prefInt.getCharPref(pref_string + ".serverName");
}
catch (ex) {
host = null;
}
if (host) {
try {
ldapUrl = Components.classes["@mozilla.org/network/ldap-url;1"];
ldapUrl = ldapUrl.createInstance().QueryInterface(nsILDAPURL);
}
catch (ex) {
dump("failed to get ldap url!\n");
return;
}
ldapUrl.host = host;
try{
ldapUrl.dn = prefInt.getComplexValue(pref_string + ".searchBase",
nsISupportsString).data;
}
catch (ex) {
}
var secure = false;
try {
secure = prefInt.getBoolPref(pref_string + ".isSecure");
}
catch(ex) {// if this preference does not exist its ok
}
var port;
if (secure) {
ldapUrl.options |= ldapurl.OPT_SECURE;
port = kDefaultSecureLDAPPort;
}
else
port = kDefaultLDAPPort;
try {
port = prefInt.getIntPref(pref_string + ".port");
}
catch(ex) {
// if this preference does not exist we will use default values.
}
ldapUrl.port = port;
ldapUrl.scope = 2;
var uri = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
uri.data = ldapUrl.spec;
prefInt.setComplexValue(pref_string + ".uri", Components.interfaces.nsISupportsString, uri);
/* is this server selected for autocompletion?
if yes, convert the preference to mozilla format.
Atmost one server is selected for autocompletion.
*/
if (useDirectory && !enable){
try {
enable = prefInt.getBoolPref(pref_string + ".autocomplete.enabled");
}
catch(ex) {}
if (enable) {
prefInt.setCharPref("ldap_2.servers.directoryServer", pref_string);
}
}
}
}
try {
prefInt.setBoolPref("ldap_2.prefs_migrated", true);
var svc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
svc.savePrefFile(null);
}
catch (ex) {dump ("ERROR:" + ex + "\n");}
this.prefs_migrated = true;
}
/* factory for nsLDAPPrefs service (nsLDAPPrefsService) */
var nsLDAPPrefsFactory = new Object();

Просмотреть файл

@ -86,7 +86,6 @@ var gMsgCompose;
var gAccountManager;
var gIOService;
var gPromptService;
var gLDAPPrefsService;
var gWindowLocked;
var gContentChanged;
var gAutoSaving;
@ -132,18 +131,6 @@ function InitializeGlobalVariables()
gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
if (gLDAPPrefsService) {
try {
gLDAPPrefsService = gLDAPPrefsService
.getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {Components.utils.reportError("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
if (gLDAPPrefsService) {
gLDAPPrefsService.migratePrefsIfNeeded();
}
}
gMsgCompose = null;
gWindowLocked = false;
gContentChanged = false;
@ -181,7 +168,6 @@ function ReleaseGlobalVariables()
gAccountManager = null;
gIOService = null;
gPromptService = null;
gLDAPPrefsService = null;
gCurrentIdentity = null;
gCurrentAutocompleteDirectory = null;
gAutocompleteSession = null;