diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index 635aa345b4c..d4b508ee7e5 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -1908,6 +1908,7 @@ sub BuildMailNewsProjects() # $D becomes a suffix to target names for selecting either the debug or non-debug target of a project my($D) = $main::DEBUG ? "Debug" : ""; + my($dist_dir) = GetBinDirectory(); StartBuildModule("mailnews"); @@ -1928,6 +1929,8 @@ sub BuildMailNewsProjects() BuildOneProject(":mozilla:mailnews:import:macbuild:msgImport.mcp", "msgImport$D.shlb", 1, $main::ALIAS_SYM_FILES, 1); BuildOneProject(":mozilla:mailnews:import:text:macbuild:msgImportText.mcp", "msgImportText$D.shlb", 1, $main::ALIAS_SYM_FILES, 1); BuildOneProject(":mozilla:mailnews:import:eudora:macbuild:msgImportEudora.mcp", "msgImportEudora$D.shlb", 1, $main::ALIAS_SYM_FILES, 1); + + InstallResources(":mozilla:mailnews:addrbook:src:MANIFEST_COMPONENTS", "${dist_dir}Components"); EndBuildModule("mailnews"); } diff --git a/mozilla/mailnews/addrbook/Makefile.in b/mozilla/mailnews/addrbook/Makefile.in index 4b3b329cfc7..3144abaecac 100644 --- a/mozilla/mailnews/addrbook/Makefile.in +++ b/mozilla/mailnews/addrbook/Makefile.in @@ -26,6 +26,12 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +ifdef MOZ_LDAP_XPCOM +REQUIRES += mozldap necko +install:: + $(INSTALL) ./src/nsLDAPPrefsService.js $(DIST)/bin/components +endif + DIRS = public src build include $(topsrcdir)/config/rules.mk diff --git a/mozilla/mailnews/addrbook/macbuild/msgAddrbookIDL.mcp b/mozilla/mailnews/addrbook/macbuild/msgAddrbookIDL.mcp index 545ef40ef81..6ab3516ce76 100644 Binary files a/mozilla/mailnews/addrbook/macbuild/msgAddrbookIDL.mcp and b/mozilla/mailnews/addrbook/macbuild/msgAddrbookIDL.mcp differ diff --git a/mozilla/mailnews/addrbook/makefile.win b/mozilla/mailnews/addrbook/makefile.win index 9e08efce8ee..dda337d7dc0 100644 --- a/mozilla/mailnews/addrbook/makefile.win +++ b/mozilla/mailnews/addrbook/makefile.win @@ -23,6 +23,11 @@ DEPTH=..\.. include <$(DEPTH)\config\config.mak> +!if !defined(DISABLE_LDAP) +install:: + $(MAKE_INSTALL) .\src\nsLDAPPrefsService.js $(DIST)\bin\components +!endif + DIRS=public src prefs build include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/mailnews/addrbook/prefs/resources/content/pref-directory.js b/mozilla/mailnews/addrbook/prefs/resources/content/pref-directory.js index 83cf3cc3241..50c263e84cb 100644 --- a/mozilla/mailnews/addrbook/prefs/resources/content/pref-directory.js +++ b/mozilla/mailnews/addrbook/prefs/resources/content/pref-directory.js @@ -9,6 +9,11 @@ var gFromGlobalPref = false; var gUpdate = false; var gDeletedDirectories = new Array(); +var gLDAPPrefsService = Components.classes[ + "@mozilla.org/ldapprefs-service;1"].getService(); +gLDAPPrefsService = gLDAPPrefsService.QueryInterface( + Components.interfaces.nsILDAPPrefsService); + function onEditDirectories() { var args = {fromGlobalPref: gFromGlobalPref}; @@ -87,63 +92,6 @@ function createDirectoriesList(flag) } } -function migrate(pref_string) -{ - if (!gPrefInt) { - try { - gPrefInt = Components.classes["@mozilla.org/preferences;1"]; - gPrefInt = gPrefInt.getService(Components.interfaces.nsIPref); - } - catch (ex) { - gPrefInt = null; - } - } - try{ - var migrated = gPrefInt.GetBoolPref("ldap_2.prefs_migrated"); - } - catch(ex){ - migrated = false; - } - if (!migrated) { - try { - var ldapUrl = Components.classes["@mozilla.org/network/ldap-url;1"]; - ldapUrl = ldapUrl.getService(Components.interfaces.nsILDAPURL); - } - catch (ex) { - ldapUrl = null; - } - try { - var ldapService = Components.classes[ - "@mozilla.org/network/ldap-service;1"]. - getService(Components.interfaces.nsILDAPService); - } - catch (ex) - { - dump("failed to get ldapService \n"); - ldapService = null; - } - try{ - ldapUrl.host = gPrefInt.CopyCharPref(pref_string + ".serverName"); - if(ldapService) { - var base = gPrefInt.CopyUnicharPref(pref_string + ".searchBase"); - ldapUrl.dn = ldapService.UCS2toUTF8(base); - } - } - catch(ex) { - } - try { - var port = gPrefInt.CopyCharPref(pref_string + ".port"); - } - catch(ex) { - port = 389; - } - ldapUrl.port = port; - ldapUrl.scope = 0; - gPrefInt.SetUnicharPref(pref_string + ".uri", ldapUrl.spec); - gPrefInt.SetBoolPref("ldap_2.prefs_migrated", true); - } -} - function LoadDirectories(popup) { var children; @@ -198,7 +146,6 @@ function LoadDirectories(popup) item.setAttribute("value", arrayOfDirectories[i]); popup.appendChild(item); } - migrate(arrayOfDirectories[i]); gAvailDirectories[j] = new Array(2); gAvailDirectories[j][0] = arrayOfDirectories[i]; gAvailDirectories[j][1] = description; diff --git a/mozilla/mailnews/addrbook/public/Makefile.in b/mozilla/mailnews/addrbook/public/Makefile.in index d58e5158e0b..1e06d983407 100644 --- a/mozilla/mailnews/addrbook/public/Makefile.in +++ b/mozilla/mailnews/addrbook/public/Makefile.in @@ -45,6 +45,10 @@ XPIDLSRCS = \ nsIAbUpgrader.idl \ nsIAddbookUrl.idl \ $(NULL) +ifdef MOZ_LDAP_XPCOM +XPIDLSRCS += nsILDAPPrefsService.idl \ +endif + include $(topsrcdir)/config/rules.mk diff --git a/mozilla/mailnews/addrbook/public/makefile.win b/mozilla/mailnews/addrbook/public/makefile.win index 9b810ac129b..b7efd1c1e5b 100644 --- a/mozilla/mailnews/addrbook/public/makefile.win +++ b/mozilla/mailnews/addrbook/public/makefile.win @@ -38,6 +38,9 @@ XPIDLSRCS = \ .\nsIAbAddressCollecter.idl \ .\nsIAbUpgrader.idl \ .\nsIAddbookUrl.idl \ +!if !defined(DISABLE_LDAP) + .\nsILDAPPrefsService.idl \ +!endif $(NULL) diff --git a/mozilla/mailnews/addrbook/public/nsILDAPPrefsService.idl b/mozilla/mailnews/addrbook/public/nsILDAPPrefsService.idl new file mode 100644 index 00000000000..ee275b3c7b0 --- /dev/null +++ b/mozilla/mailnews/addrbook/public/nsILDAPPrefsService.idl @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2001 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Srilatha Moturi + * + * nsILDAPPrefsService.idl + */ + +#include "nsISupports.idl" +#include "nsILDAPURL.idl" +#include "nsILDAPService.idl" + +/** + * this service implements migrating ldap prefs from 4.x format + * to mozilla format. + */ +[scriptable, uuid(5a4911e0-44cd-11d5-9074-0010a4b26cda)] +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 migrate(); +}; diff --git a/mozilla/mailnews/addrbook/src/MANIFEST_COMPONENTS b/mozilla/mailnews/addrbook/src/MANIFEST_COMPONENTS new file mode 100644 index 00000000000..f29c5ec6e1e --- /dev/null +++ b/mozilla/mailnews/addrbook/src/MANIFEST_COMPONENTS @@ -0,0 +1 @@ +nsLDAPPrefsService.js diff --git a/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js b/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js new file mode 100644 index 00000000000..82312d4faa1 --- /dev/null +++ b/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js @@ -0,0 +1,250 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2001 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Srilatha Moturi + */ + +/* components defined in this file */ + +const NS_LDAPPREFSSERVICE_CONTRACTID = + "@mozilla.org/ldapprefs-service;1"; +const NS_LDAPPREFSSERVICE_CID = + Components.ID("{5a4911e0-44cd-11d5-9074-0010a4b26cda}"); +const NS_LDAPPREFSSERVICE_IID = Components.interfaces.nsILDAPPrefsService; + +/* interfaces used in this file */ +const nsISupports = Components.interfaces.nsISupports; +const nsIPref = Components.interfaces.nsIPref; +const nsILDAPURL = Components.interfaces.nsILDAPURL; +const nsILDAPService = Components.interfaces.nsILDAPService; + +/* nsLDAPPrefs service */ +function nsLDAPPrefsService() { + var arrayOfDirectories = null; + var j = 0; + try { + gPrefInt = Components.classes["@mozilla.org/preferences;1"]; + gPrefInt = gPrefInt.getService(nsIPref); + } + catch (ex) { + dump("failed to get prefs service!\n"); + return; + } + /* generate the list of directory servers from preferences */ + var children = gPrefInt.CreateChildList("ldap_2.servers"); + if(children) { + arrayOfDirectories = children.split(';'); + this.availDirectories = new Array(); + var position; + var description; + for (var i=0; i