rem: catch (ex) { dump("failed to get ldap url service!\n"); ldapUrl = null; }  var description = document.getElementById("description").value; var hostname = document.getElementById("hostname").value; var port = document.getElementById("port").value; var secure = document.getElementById("secure"); var login = document.getElementById("login"); var results = document.getElementById("results").value; var errorValue = null; gPref_string_desc = description; if ((!gPref_string_desc) || hasOnlyWhitespaces(gPref_string_desc)) errorValue = "invalidName"; else if ((!hostname) || hasOnlyWhitespaces(hostname)) errorValue = "invalidHostname"; else if (port && hasCharacters(port)) errorValue = "invalidPortNumber"; else if (results && hasCharacters(results)) errorValue = "invalidResults"; if (!errorValue) { pref_string_content = gPref_string_desc; if (gCurrentDirectory && gCurrentDirectoryString) { gPref_string_desc = gCurrentDirectoryString; } else { createUniqueServername(); gPref_string_desc = gPrefstring + gPref_string_desc; }  pref_string_title = gPref_string_desc +"." + "description"; var str = Components.classes["@mozilla.org/supports-wstring;1"] .createInstance(Components.interfaces.nsISupportsWString); str.data = pref_string_content; gPrefInt.setComplexValue(pref_string_title, Components.interfaces.nsISupportsWString, str);  ldapUrl.host = hostname; if(!gLdapService) { try { gLdapService = Components.classes[ "@mozilla.org/network/ldap-service;1"]. getService(Components.interfaces.nsILDAPService); } catch (ex) { dump("failed to get LdapService \n"); gLdapService = null; } } if (gLdapService) { pref_string_content = gLdapService. UCS2toUTF8(document.getElementById("basedn").value); ldapUrl.dn = pref_string_content; pref_string_content = gLdapService. UCS2toUTF8(document.getElementById("search").value); ldapUrl.filter = pref_string_content; } if (!port) { if (secure.checked) ldapUrl.port = kDefaultSecureLDAPPort; else ldapUrl.port = kDefaultLDAPPort; } else ldapUrl.port = port; if (document.getElementById("one").selected) { ldapUrl.scope = 1; } else { ldapUrl.scope = 2; } if (secure.checked) ldapUrl.options |= ldapUrl.OPT_SECURE; pref_string_title = gPref_string_desc + ".uri";  var uri = Components.classes["@mozilla.org/supports-wstring;1"] .createInstance(Components.interfaces.nsISupportsWString); uri.data = ldapUrl.spec; gPrefInt.setComplexValue(pref_string_title, Components.interfaces.nsISupportsWString, uri);  pref_string_content = results; pref_string_title = gPref_string_desc + ".maxHits"; if (pref_string_content != kDefaultMaxHits) { gPrefInt.setIntPref(pref_string_title, pref_string_content); } else { try { gPrefInt.clearUserPref(pref_string_title); } catch(ex) {} } pref_string_title = gPref_string_desc + ".auth.enabled"; pref_string_content = login.checked; gPrefInt.setBoolPref(pref_string_title, pref_string_content);  window.opener.gNewServer = description; window.opener.gNewServerString = gPref_string_desc;   window.opener.gUpdate = true; } else { var addressBookBundle = document.getElementById("bundle_addressBook"); var errorMsg = addressBookBundle.getString(errorValue); alert(errorMsg); }  
context: function onAccept(){  var pref_string_content = "";  var pref_string_title = "";  if (!gPrefInt) {    try {      gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]                           .getService(Components.interfaces.nsIPrefBranch);    }    catch (ex) {      dump("failed to get prefs service!\n");      gPrefInt = null;    }  }  try {    var ldapUrl = Components.classes["@mozilla.org/network/ldap-url;1"];    ldapUrl = ldapUrl.createInstance().              QueryInterface(Components.interfaces.nsILDAPURL);  }  catch (ex) {    dump("failed to get ldap url service!\n");    ldapUrl = null;  }  var description = document.getElementById("description").value;  var hostname = document.getElementById("hostname").value;  var port = document.getElementById("port").value;  var secure = document.getElementById("secure");  var login = document.getElementById("login");  var results = document.getElementById("results").value;  var errorValue = null;  gPref_string_desc = description;  if ((!gPref_string_desc) || hasOnlyWhitespaces(gPref_string_desc))    errorValue = "invalidName";  else if ((!hostname) || hasOnlyWhitespaces(hostname))    errorValue = "invalidHostname";  else if (port && hasCharacters(port))    errorValue = "invalidPortNumber";  else if (results && hasCharacters(results))    errorValue = "invalidResults";  if (!errorValue) {  pref_string_content = gPref_string_desc;  if (gCurrentDirectory && gCurrentDirectoryString)  {    gPref_string_desc = gCurrentDirectoryString;  }  else  {    createUniqueServername();    gPref_string_desc = gPrefstring + gPref_string_desc;  }  pref_string_title = gPref_string_desc +"." + "description";  var str = Components.classes["@mozilla.org/supports-wstring;1"]                      .createInstance(Components.interfaces.nsISupportsWString);  str.data = pref_string_content;  gPrefInt.setComplexValue(pref_string_title, Components.interfaces.nsISupportsWString, str);    ldapUrl.host = hostname;  if(!gLdapService) {    try {      gLdapService = Components.classes[          "@mozilla.org/network/ldap-service;1"].          getService(Components.interfaces.nsILDAPService);    }    catch (ex)    {       dump("failed to get LdapService \n");      gLdapService = null;    }  }  if (gLdapService) {    pref_string_content = gLdapService.                          UCS2toUTF8(document.getElementById("basedn").value);    ldapUrl.dn = pref_string_content;    pref_string_content = gLdapService.                          UCS2toUTF8(document.getElementById("search").value);    ldapUrl.filter = pref_string_content;  }  if (!port) {    if (secure.checked)      ldapUrl.port = kDefaultSecureLDAPPort;    else      ldapUrl.port = kDefaultLDAPPort;  }  else    ldapUrl.port = port;  if (document.getElementById("one").selected)  {    ldapUrl.scope = 1;  }  else {      ldapUrl.scope = 2;  }  if (secure.checked)    ldapUrl.options |= ldapUrl.OPT_SECURE;  pref_string_title = gPref_string_desc + ".uri";  var uri = Components.classes["@mozilla.org/supports-wstring;1"]                      .createInstance(Components.interfaces.nsISupportsWString);  uri.data = ldapUrl.spec;  gPrefInt.setComplexValue(pref_string_title, Components.interfaces.nsISupportsWString, uri);  pref_string_content = results;  pref_string_title = gPref_string_desc + ".maxHits";  if (pref_string_content != kDefaultMaxHits) {    gPrefInt.setIntPref(pref_string_title, pref_string_content);  }  else  {    try {      gPrefInt.clearUserPref(pref_string_title);    }    catch(ex) {}  }  pref_string_title = gPref_string_desc + ".auth.enabled";  pref_string_content = login.checked;  gPrefInt.setBoolPref(pref_string_title, pref_string_content);  window.opener.gNewServer = description;  window.opener.gNewServerString = gPref_string_desc;  // set window.opener.gUpdate to true so that LDAP Directory Servers  // dialog gets updated  window.opener.gUpdate = true;   }  else  {    var addressBookBundle = document.getElementById("bundle_addressBook");    var errorMsg = addressBookBundle.getString(errorValue);    alert(errorMsg);  }}
meta: 5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5459/d066d1f28f7302c776686c065ce228b20d19e89a/pref-directory-add.js/clean/mailnews/addrbook/prefs/resources/content/pref-directory-add.js