From 13edab0e33334d25ff47ce3fe2ecdde65586b07d Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Fri, 4 May 2007 15:43:53 +0000 Subject: [PATCH] Bug 379647 Remove 4.x ldap address book migration from the trunk - Part 1 Remove ldap prefs service migration, r/sr=bienvenu --- .../addrbook/content/addressbook.js | 11 -- .../compose/content/MsgComposeCommands.js | 14 -- mail/components/preferences/compose.js | 4 - .../prefs/resources/content/pref-directory.js | 2 - .../addrbook/public/nsILDAPPrefsService.idl | 14 +- .../addrbook/resources/content/addressbook.js | 11 -- mailnews/addrbook/src/nsLDAPPrefsService.js | 177 +----------------- .../resources/content/MsgComposeCommands.js | 14 -- 8 files changed, 3 insertions(+), 244 deletions(-) diff --git a/mail/components/addrbook/content/addressbook.js b/mail/components/addrbook/content/addressbook.js index a7826883861..093dddb27f5 100644 --- a/mail/components/addrbook/content/addressbook.js +++ b/mail/components/addrbook/content/addressbook.js @@ -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(); diff --git a/mail/components/compose/content/MsgComposeCommands.js b/mail/components/compose/content/MsgComposeCommands.js index 82f109e2c80..62221400448 100644 --- a/mail/components/compose/content/MsgComposeCommands.js +++ b/mail/components/compose/content/MsgComposeCommands.js @@ -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; diff --git a/mail/components/preferences/compose.js b/mail/components/preferences/compose.js index a67f84a4587..01a18339780 100644 --- a/mail/components/preferences/compose.js +++ b/mail/components/preferences/compose.js @@ -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 diff --git a/mailnews/addrbook/prefs/resources/content/pref-directory.js b/mailnews/addrbook/prefs/resources/content/pref-directory.js index d621a1840f2..2766378a255 100644 --- a/mailnews/addrbook/prefs/resources/content/pref-directory.js +++ b/mailnews/addrbook/prefs/resources/content/pref-directory.js @@ -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(); } } diff --git a/mailnews/addrbook/public/nsILDAPPrefsService.idl b/mailnews/addrbook/public/nsILDAPPrefsService.idl index d4d79d62533..71c2f9a766e 100644 --- a/mailnews/addrbook/public/nsILDAPPrefsService.idl +++ b/mailnews/addrbook/public/nsILDAPPrefsService.idl @@ -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..autocomplete.enabled) - * to mozilla format (ldap_2.servers.directoryServer) - */ - void migratePrefsIfNeeded(); /** * This will create an array with entries diff --git a/mailnews/addrbook/resources/content/addressbook.js b/mailnews/addrbook/resources/content/addressbook.js index 3c6f619be76..2dd2aed8b8a 100644 --- a/mailnews/addrbook/resources/content/addressbook.js +++ b/mailnews/addrbook/resources/content/addressbook.js @@ -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(); diff --git a/mailnews/addrbook/src/nsLDAPPrefsService.js b/mailnews/addrbook/src/nsLDAPPrefsService.js index 3f6738b8b19..0f9cb2f7173 100644 --- a/mailnews/addrbook/src/nsLDAPPrefsService.js +++ b/mailnews/addrbook/src/nsLDAPPrefsService.js @@ -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(); diff --git a/mailnews/compose/resources/content/MsgComposeCommands.js b/mailnews/compose/resources/content/MsgComposeCommands.js index bc009cf62f7..28227dbd96c 100644 --- a/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mailnews/compose/resources/content/MsgComposeCommands.js @@ -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;