Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions
nsDirPrefs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DIR_ReplicationInfo
struct  DIR_Server

Defines

#define kPreviousListVersion   2
#define kCurrentListVersion   3
#define PREF_LDAP_GLOBAL_TREE_NAME   "ldap_2"
#define PREF_LDAP_VERSION_NAME   "ldap_2.version"
#define PREF_LDAP_SERVER_TREE_NAME   "ldap_2.servers"
#define kAllDirectoryRoot   "moz-abdirectory://"
#define kMDBDirectoryRoot   "moz-abmdbdirectory://"
#define kMDBDirectoryRootLen   21
#define kLDAPDirectoryRoot   "moz-abldapdirectory://"
#define kLDAPDirectoryRootLen   22
#define kPersonalAddressbook   "abook.mab"
#define kPersonalAddressbookUri   "moz-abmdbdirectory://abook.mab"
#define kCollectedAddressbook   "history.mab"
#define kCollectedAddressbookUri   "moz-abmdbdirectory://history.mab"
#define kABFileName_PreviousSuffix   ".na2" /* final v2 address book format */
#define kABFileName_PreviousSuffixLen   4
#define kABFileName_CurrentSuffix   ".mab" /* v3 address book extension */
#define kMainLdapAddressBook   "ldap.mab" /* v3 main ldap address book file */
#define DIR_Server_typedef   1 /* this quiets a redeclare warning in libaddr */
#define DIR_POS_APPEND   0x80000000
#define DIR_POS_DELETE   0x80000001
#define DIR_NOTIFY_ADD   0x00000001
#define DIR_NOTIFY_DELETE   0x00000002
#define DIR_NOTIFY_PROPERTY_CHANGE   0x00000004
#define DIR_NOTIFY_SCRAMBLE   0x00000008
#define DIR_NOTIFY_ALL   0x0000000F
#define DIR_AUTO_COMPLETE_ENABLED   0x00000001 /* Directory is configured for autocomplete addressing */
#define DIR_ENABLE_AUTH   0x00000002 /* Directory is configured for LDAP simple authentication */
#define DIR_SAVE_PASSWORD   0x00000004
#define DIR_IS_SECURE   0x00000008
#define DIR_SAVE_RESULTS   0x00000010 /* not used by the FEs */
#define DIR_EFFICIENT_WILDCARDS   0x00000020 /* not used by the FEs */
#define DIR_LDAP_VERSION3   0x00000040
#define DIR_LDAP_VLV_DISABLED   0x00000080 /* not used by the FEs */
#define DIR_LDAP_VLV_SUPPORTED   0x00000100 /* not used by the FEs */
#define DIR_LDAP_ROOTDSE_PARSED   0x00000200 /* not used by the FEs */
#define DIR_AUTO_COMPLETE_NEVER   0x00000400 /* Directory is never to be used for autocompletion */
#define DIR_REPLICATION_ENABLED   0x00000800 /* Directory is configured for offline use */
#define DIR_REPLICATE_NEVER   0x00001000 /* Directory is never to be replicated */
#define DIR_UNDELETABLE   0x00002000
#define DIR_POSITION_LOCKED   0x00004000
#define DIR_SAVING_SERVER   0x40000000
#define DIR_CLEAR_SERVER   0x80000000
#define DIR_SUBSET_HTML_ALL   0x00000001
#define DIR_SUBSET_LDAP_ALL   0x00000002
#define DIR_SUBSET_LDAP_AUTOCOMPLETE   0x00000004
#define DIR_SUBSET_LDAP_REPLICATE   0x00000008
#define DIR_SUBSET_PAB_ALL   0x00000010

Typedefs

typedef struct _DIR_ReplicationInfo DIR_ReplicationInfo
typedef struct DIR_Server DIR_Server
typedef PRInt32(* DIR_NOTIFICATION_FN )(DIR_Server *server, PRUint32 flag, DIR_PrefId id, void *inst_data)

Enumerations

enum  DirectoryType {
  LDAPDirectory, HTMLDirectory, PABDirectory, MAPIDirectory,
  FixedQueryLDAPDirectory = 777
}
enum  DIR_AttributeId {
  cn, givenname, sn, mail,
  telephonenumber, o, ou, l,
  street, auth, carlicense, businesscategory,
  departmentnumber, description, employeetype, facsimiletelephonenumber,
  manager, objectclass, postaladdress, postalcode,
  secretary, title, custom1, custom2,
  custom3, custom4, custom5, nickname,
  mobiletelephonenumber, pager, homephone
}
enum  DIR_DescriptionCode { DIR_ValidDescription = 0, DIR_DuplicateDescription, DIR_InvalidDescription }
enum  DIR_PrefId {
  idNone = 0, idPrefName, idPosition, idRefCount,
  idDescription, idServerName, idSearchBase, idFileName,
  idPort, idMaxHits, idUri, idLastSearchString,
  idType, idCSID, idLocale, idPositionLocked,
  idDeletable, idStopFiltersOnHit, idIsOffline, idIsSecure,
  idVLVDisabled, idSaveResults, idEfficientWildcards, idEnableAuth,
  idSavePassword, idCustomFilters, idCustomAttributes, idAutoCompleteNever,
  idAutoCompleteEnabled, idAutoCompleteFilter, idTokenSeps, idColumnAttributes,
  idDnAttributes, idDnAttributesCount, idSuppressedAttributes, idSuppressedAttributesCount,
  idUriAttributes, idUriAttributesCount, idBasicSearchAttributes, idBasicSearchAttributesCount,
  idCustomDisplayUrl, idAuthDn, idPassword, idSearchPairList,
  idReplNever, idReplEnabled, idReplDescription, idReplFileName,
  idReplFilter, idReplLastChangeNumber, idReplDataVersion, idReplSyncURL,
  idReplExcludedAttributes, idReplExcludedAttributesCount, idPalmCategory, idPalmSyncTimeStamp,
  idProtocolVersion
}

Functions

nsVoidArrayDIR_GetDirectories ()
nsresult DIR_GetDirServers ()
nsresult DIR_ShutDown (void)
nsresult DIR_AddNewAddressBook (const PRUnichar *dirName, const char *fileName, PRBool migrating, const char *uri, int maxHits, const char *authDn, DirectoryType dirType, DIR_Server **pServer)
nsresult DIR_ContainsServer (DIR_Server *pServer, PRBool *hasDir)
nsresult DIR_DecrementServerRefCount (DIR_Server *)
nsresult DIR_IncrementServerRefCount (DIR_Server *)
nsVoidArrayFE_GetDirServers (void)
nsresult DIR_InitServerWithType (DIR_Server *server, DirectoryType dirType)
nsresult DIR_InitServer (DIR_Server *)
nsresult DIR_CopyServer (DIR_Server *in, DIR_Server **out)
PRBool DIR_AreServersSame (DIR_Server *first, DIR_Server *second)
DIR_ServerDIR_LookupServer (char *serverName, PRInt32 port, char *searchBase)
nsresult DIR_DeleteServer (DIR_Server *)
nsresult DIR_DeleteServerFromList (DIR_Server *)
nsresult DIR_DeleteServerList (nsVoidArray *wholeList)
PRBool DIR_SetServerPosition (nsVoidArray *wholeList, DIR_Server *server, PRInt32 position)
nsresult DIR_GetServerPreferences (nsVoidArray **list)
nsresult DIR_SaveServerPreferences (nsVoidArray *wholeList)
void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, PRBool oldstyle)
void DIR_SavePrefsForOneServer (DIR_Server *server)
nsresult DIR_CleanUpServerPreferences (nsVoidArray *deletedList)
void DIR_ClearPrefBranch (const char *branch)
nsresult DIR_GetDirServerSubset (nsVoidArray *wholeList, nsVoidArray *subList, PRUint32 flags)
PRInt32 DIR_GetDirServerSubsetCount (nsVoidArray *wholeList, PRUint32 flags)
DIR_DescriptionCode DIR_ValidateDirectoryDescription (nsVoidArray *wholeList, DIR_Server *serverToValidate)
char * DIR_CreateServerPrefName (DIR_Server *server, char *name)
void DIR_SetServerFileName (DIR_Server *pServer, const char *leafName)
const char * DIR_GetAttributeName (DIR_Server *server, DIR_AttributeId id)
const char ** DIR_GetAttributeStrings (DIR_Server *server, DIR_AttributeId id)
const char * DIR_GetFirstAttributeString (DIR_Server *server, DIR_AttributeId id)
const char * DIR_GetFilterString (DIR_Server *server)
const char * DIR_GetReplicationFilter (DIR_Server *server)
const char * DIR_GetTokenSeparators (DIR_Server *server)
PRBool DIR_RepeatFilterForTokens (DIR_Server *server, const char *filter)
PRBool DIR_SubstStarsForSpaces (DIR_Server *server, const char *filter)
PRBool DIR_UseCustomAttribute (DIR_Server *server, DIR_AttributeId id)
PRBool DIR_IsDnAttribute (DIR_Server *s, const char *attr)
PRBool DIR_IsAttributeExcludedFromHtml (DIR_Server *s, const char *attr)
PRBool DIR_IsUriAttribute (DIR_Server *s, const char *attrib)
nsresult DIR_AttributeNameToId (DIR_Server *server, const char *attrName, DIR_AttributeId *id)
void DIR_SetAuthDN (DIR_Server *s, const char *dn)
void DIR_SetPassword (DIR_Server *s, const char *password)
char * DIR_Unescape (const char *src, PRBool makeHtml)
PRBool DIR_IsEscapedAttribute (DIR_Server *s, const char *attrib)
char * DIR_BuildUrl (DIR_Server *s, const char *dn, PRBool forAddToAB)
void DIR_SetAutoCompleteEnabled (nsVoidArray *list, DIR_Server *server, PRBool enabled)
PRBool DIR_RegisterNotificationCallback (DIR_NOTIFICATION_FN fn, PRUint32 flags, void *inst_data)
PRBool DIR_DeregisterNotificationCallback (DIR_NOTIFICATION_FN fn, void *inst_data)
PRBool DIR_SendNotification (DIR_Server *server, PRUint32 flag, DIR_PrefId id)
DIR_PrefId DIR_AtomizePrefName (const char *prefname)
char * DIR_CopyServerStringPref (DIR_Server *server, DIR_PrefId prefid, PRInt16 csid)
PRBool DIR_SetServerStringPref (DIR_Server *server, DIR_PrefId prefid, char *pref, PRInt16 csid)
PRBool DIR_TestFlag (DIR_Server *server, PRUint32 flag)
void DIR_SetFlag (DIR_Server *server, PRUint32 flag)
void DIR_ClearFlag (DIR_Server *server, PRUint32 flag)
void DIR_ForceFlag (DIR_Server *server, PRUint32 flag, PRBool forceOnOrOff)
char * DIR_ConvertToServerCharSet (DIR_Server *s, char *src, PRInt16 srcCsid)
char * DIR_ConvertFromServerCharSet (DIR_Server *s, char *src, PRInt16 dstCsid)
char * DIR_ConvertString (PRInt16 srcCSID, PRInt16 dstCSID, const char *string)

Class Documentation

struct _DIR_ReplicationInfo

Definition at line 188 of file nsDirPrefs.h.

Class Members
char * dataVersion
char * description
char ** excludedAttributes
PRInt32 excludedAttributesCount
char * fileName
char * filter
PRInt32 lastChangeNumber
char * syncURL
struct DIR_Server

Definition at line 204 of file nsDirPrefs.h.

Collaboration diagram for DIR_Server:
Class Members
char * authDn
char * autoCompleteFilter
DIR_AttributeId * basicSearchAttributes
PRInt32 basicSearchAttributesCount
char * columnAttributes
PRInt16 csid
nsVoidArray * customAttributes
char * customDisplayUrl
nsVoidArray * customFilters
char * description
DirectoryType dirType
char ** dnAttributes
PRInt32 dnAttributesCount
PRPackedBool efficientWildcards
PRPackedBool enableAuth
char * fileName
PRUint32 flags
PRPackedBool isOffline
PRPackedBool isSecure
char * lastSearchString
char * locale
PRInt32 maxHits
PRInt32 PalmCategoryId
PRUint32 PalmSyncTimeStamp
char * password
PRInt32 port
PRInt32 position
char * prefName
PRUint32 refCount
DIR_ReplicationInfo * replInfo
PRPackedBool savePassword
PRPackedBool saveResults
char * searchBase
char * searchPairList
char * serverName
PRPackedBool stopFiltersOnHit
char ** suppressedAttributes
PRInt32 suppressedAttributesCount
char * tokenSeps
char * uri
char ** uriAttributes
PRInt32 uriAttributesCount

Define Documentation

#define DIR_AUTO_COMPLETE_ENABLED   0x00000001 /* Directory is configured for autocomplete addressing */

Definition at line 397 of file nsDirPrefs.h.

#define DIR_AUTO_COMPLETE_NEVER   0x00000400 /* Directory is never to be used for autocompletion */

Definition at line 407 of file nsDirPrefs.h.

#define DIR_CLEAR_SERVER   0x80000000

Definition at line 427 of file nsDirPrefs.h.

#define DIR_EFFICIENT_WILDCARDS   0x00000020 /* not used by the FEs */

Definition at line 402 of file nsDirPrefs.h.

#define DIR_ENABLE_AUTH   0x00000002 /* Directory is configured for LDAP simple authentication */

Definition at line 398 of file nsDirPrefs.h.

#define DIR_IS_SECURE   0x00000008

Definition at line 400 of file nsDirPrefs.h.

#define DIR_LDAP_ROOTDSE_PARSED   0x00000200 /* not used by the FEs */

Definition at line 406 of file nsDirPrefs.h.

#define DIR_LDAP_VERSION3   0x00000040

Definition at line 403 of file nsDirPrefs.h.

#define DIR_LDAP_VLV_DISABLED   0x00000080 /* not used by the FEs */

Definition at line 404 of file nsDirPrefs.h.

#define DIR_LDAP_VLV_SUPPORTED   0x00000100 /* not used by the FEs */

Definition at line 405 of file nsDirPrefs.h.

#define DIR_NOTIFY_ADD   0x00000001

Definition at line 379 of file nsDirPrefs.h.

#define DIR_NOTIFY_ALL   0x0000000F

Definition at line 383 of file nsDirPrefs.h.

#define DIR_NOTIFY_DELETE   0x00000002

Definition at line 380 of file nsDirPrefs.h.

Definition at line 381 of file nsDirPrefs.h.

#define DIR_NOTIFY_SCRAMBLE   0x00000008

Definition at line 382 of file nsDirPrefs.h.

#define DIR_POS_APPEND   0x80000000

Definition at line 312 of file nsDirPrefs.h.

#define DIR_POS_DELETE   0x80000001

Definition at line 313 of file nsDirPrefs.h.

#define DIR_POSITION_LOCKED   0x00004000

Definition at line 411 of file nsDirPrefs.h.

#define DIR_REPLICATE_NEVER   0x00001000 /* Directory is never to be replicated */

Definition at line 409 of file nsDirPrefs.h.

#define DIR_REPLICATION_ENABLED   0x00000800 /* Directory is configured for offline use */

Definition at line 408 of file nsDirPrefs.h.

#define DIR_SAVE_PASSWORD   0x00000004

Definition at line 399 of file nsDirPrefs.h.

#define DIR_SAVE_RESULTS   0x00000010 /* not used by the FEs */

Definition at line 401 of file nsDirPrefs.h.

#define DIR_SAVING_SERVER   0x40000000

Definition at line 420 of file nsDirPrefs.h.

#define DIR_Server_typedef   1 /* this quiets a redeclare warning in libaddr */

Definition at line 202 of file nsDirPrefs.h.

#define DIR_SUBSET_HTML_ALL   0x00000001

Definition at line 432 of file nsDirPrefs.h.

#define DIR_SUBSET_LDAP_ALL   0x00000002

Definition at line 433 of file nsDirPrefs.h.

Definition at line 434 of file nsDirPrefs.h.

Definition at line 435 of file nsDirPrefs.h.

#define DIR_SUBSET_PAB_ALL   0x00000010

Definition at line 436 of file nsDirPrefs.h.

#define DIR_UNDELETABLE   0x00002000

Definition at line 410 of file nsDirPrefs.h.

#define kABFileName_CurrentSuffix   ".mab" /* v3 address book extension */

Definition at line 68 of file nsDirPrefs.h.

#define kABFileName_PreviousSuffix   ".na2" /* final v2 address book format */

Definition at line 66 of file nsDirPrefs.h.

Definition at line 67 of file nsDirPrefs.h.

#define kAllDirectoryRoot   "moz-abdirectory://"

Definition at line 52 of file nsDirPrefs.h.

#define kCollectedAddressbook   "history.mab"

Definition at line 62 of file nsDirPrefs.h.

#define kCollectedAddressbookUri   "moz-abmdbdirectory://history.mab"

Definition at line 63 of file nsDirPrefs.h.

Definition at line 45 of file nsDirPrefs.h.

#define kLDAPDirectoryRoot   "moz-abldapdirectory://"

Definition at line 57 of file nsDirPrefs.h.

Definition at line 58 of file nsDirPrefs.h.

#define kMainLdapAddressBook   "ldap.mab" /* v3 main ldap address book file */

Definition at line 69 of file nsDirPrefs.h.

#define kMDBDirectoryRoot   "moz-abmdbdirectory://"

Definition at line 54 of file nsDirPrefs.h.

Definition at line 55 of file nsDirPrefs.h.

#define kPersonalAddressbook   "abook.mab"

Definition at line 60 of file nsDirPrefs.h.

#define kPersonalAddressbookUri   "moz-abmdbdirectory://abook.mab"

Definition at line 61 of file nsDirPrefs.h.

Definition at line 44 of file nsDirPrefs.h.

Definition at line 46 of file nsDirPrefs.h.

#define PREF_LDAP_SERVER_TREE_NAME   "ldap_2.servers"

Definition at line 48 of file nsDirPrefs.h.

#define PREF_LDAP_VERSION_NAME   "ldap_2.version"

Definition at line 47 of file nsDirPrefs.h.


Typedef Documentation

typedef PRInt32(* DIR_NOTIFICATION_FN)(DIR_Server *server, PRUint32 flag, DIR_PrefId id, void *inst_data)

Definition at line 385 of file nsDirPrefs.h.

typedef struct DIR_Server DIR_Server

Enumeration Type Documentation

Enumerator:
cn 
givenname 
sn 
mail 
telephonenumber 
o 
ou 
l 
street 
auth 
carlicense 
businesscategory 
departmentnumber 
description 
employeetype 
facsimiletelephonenumber 
manager 
objectclass 
postaladdress 
postalcode 
secretary 
title 
custom1 
custom2 
custom3 
custom4 
custom5 
nickname 
mobiletelephonenumber 
pager 
homephone 

Definition at line 81 of file nsDirPrefs.h.

{
       cn,
       givenname,
       sn,
       mail,
       telephonenumber,   /* work */
       o,
       ou,
       l,
       street,
       auth,
       /* mscott: I've added these extra DIR_AttributeIDs because the new address book can handle these */
       carlicense,
       businesscategory,
       departmentnumber,
       description,
       employeetype,
       facsimiletelephonenumber,
       /* jpegPhoto */
       manager,
       objectclass,
       postaladdress,
       postalcode,
       secretary,
       title,
       custom1,
       custom2,
       custom3,
       custom4,
       custom5, 
       nickname, /* only valid on address book directories as LDAP does not have a nick name field */
       mobiletelephonenumber,  /* cell phone */
       pager,
       homephone
} DIR_AttributeId;
Enumerator:
DIR_ValidDescription 
DIR_DuplicateDescription 
DIR_InvalidDescription 

Definition at line 119 of file nsDirPrefs.h.

enum DIR_PrefId
Enumerator:
idNone 
idPrefName 
idPosition 
idRefCount 
idDescription 
idServerName 
idSearchBase 
idFileName 
idPort 
idMaxHits 
idUri 
idLastSearchString 
idType 
idCSID 
idLocale 
idPositionLocked 
idDeletable 
idStopFiltersOnHit 
idIsOffline 
idIsSecure 
idVLVDisabled 
idSaveResults 
idEfficientWildcards 
idEnableAuth 
idSavePassword 
idCustomFilters 
idCustomAttributes 
idAutoCompleteNever 
idAutoCompleteEnabled 
idAutoCompleteFilter 
idTokenSeps 
idColumnAttributes 
idDnAttributes 
idDnAttributesCount 
idSuppressedAttributes 
idSuppressedAttributesCount 
idUriAttributes 
idUriAttributesCount 
idBasicSearchAttributes 
idBasicSearchAttributesCount 
idCustomDisplayUrl 
idAuthDn 
idPassword 
idSearchPairList 
idReplNever 
idReplEnabled 
idReplDescription 
idReplFileName 
idReplFilter 
idReplLastChangeNumber 
idReplDataVersion 
idReplSyncURL 
idReplExcludedAttributes 
idReplExcludedAttributesCount 
idPalmCategory 
idPalmSyncTimeStamp 
idProtocolVersion 

Definition at line 126 of file nsDirPrefs.h.

Enumerator:
LDAPDirectory 
HTMLDirectory 
PABDirectory 
MAPIDirectory 
FixedQueryLDAPDirectory 

Definition at line 72 of file nsDirPrefs.h.


Function Documentation

nsresult DIR_AddNewAddressBook ( const PRUnichar dirName,
const char *  fileName,
PRBool  migrating,
const char *  uri,
int  maxHits,
const char *  authDn,
DirectoryType  dirType,
DIR_Server **  pServer 
)

Definition at line 351 of file nsDirPrefs.cpp.

{
  DIR_Server * server = (DIR_Server *) PR_Malloc(sizeof(DIR_Server));
  DIR_InitServerWithType (server, dirType);
  if (!dir_ServerList)
    DIR_GetDirServers();
  if (dir_ServerList)
  {
    NS_ConvertUCS2toUTF8 utf8str(dirName);
    server->description = ToNewCString(utf8str);
    server->position = kDefaultPosition; // don't set position so alphabetic sort will happen.
    
    if (fileName)
      server->fileName = nsCRT::strdup(fileName);
    else
      DIR_SetFileName(&server->fileName, kPersonalAddressbook);
    if (dirType == LDAPDirectory) {
      // We don't actually allow the password to be saved in the preferences;
      // this preference is (effectively) ignored by the current code base.  
      // It's here because versions of Mozilla 1.0 and earlier (maybe 1.1alpha
      // too?) would blow away the .auth.dn preference if .auth.savePassword
      // is not set.  To avoid trashing things for users who switch between
      // versions, we'll set it.  Once the versions in question become 
      // obsolete enough, this workaround can be gotten rid of.
      server->savePassword = PR_TRUE;
      if (uri)
        server->uri = nsCRT::strdup(uri);
      if (authDn)
        server->authDn = nsCRT::strdup(authDn);
      // force new LDAP directories to be treated as v3 this includes the case when 
      // we are migrating directories.
      DIR_ForceFlag(server, DIR_LDAP_VERSION3, PR_TRUE);
    }
    if (maxHits)
      server->maxHits = maxHits;
    
    dir_ServerList->AppendElement(server);
    if (!migrating) {
      DIR_SavePrefsForOneServer(server); 
    }
    else if (!server->prefName)
    {
      // Need to return pref names here so the caller will be able to get the
      // right directory properties. For migration, pref names were already
      // created so no need to get unique ones via DIR_CreateServerPrefName().
      if (!strcmp(server->fileName, kPersonalAddressbook))
        server->prefName = nsCRT::strdup("ldap_2.servers.pab");
      else if (!strcmp(server->fileName, kCollectedAddressbook))
        server->prefName = nsCRT::strdup("ldap_2.servers.history");
      else
      {
        char * leafName = dir_ConvertDescriptionToPrefName (server);
        if (leafName)
          server->prefName = PR_smprintf(PREF_LDAP_SERVER_TREE_NAME".%s", leafName);
      }
    }
#ifdef DEBUG_sspitzer
    else {
      printf("don't set the prefs, they are already set since this ab was migrated\n");
    }
#endif
    *pServer = server;
    
    // save new address book into pref file 
    nsresult rv = NS_OK;
    nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
    if (NS_FAILED(rv) || !pPref) 
      return NS_ERROR_FAILURE;
    pPref->SavePrefFile(nsnull);
    
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool DIR_AreServersSame ( DIR_Server first,
DIR_Server second 
)

Definition at line 1548 of file nsDirPrefs.cpp.

{
       return dir_AreServersSame(first, second, PR_TRUE);
}

Here is the call graph for this function:

DIR_PrefId DIR_AtomizePrefName ( const char *  prefname)

Definition at line 1231 of file nsDirPrefs.cpp.

{
       DIR_PrefId rc = idNone;

       /* Skip the "ldap_2.servers.<server-name>." portion of the string.
        */
       if (PL_strstr(prefname, PREF_LDAP_SERVER_TREE_NAME) == prefname)
       {
              prefname = PL_strchr(&prefname[PL_strlen(PREF_LDAP_SERVER_TREE_NAME) + 1], '.');
              if (!prefname)
                     return idNone;
              else
                     prefname = prefname + 1;
       }


       switch (prefname[0]) {
       case 'a':
              if (PL_strstr(prefname, "autoComplete.") == prefname)
              {
                     switch (prefname[13]) {
                     case 'e': /* autoComplete.enabled */
                            rc = idAutoCompleteEnabled;
                            break;
                     case 'f':
                            rc = idAutoCompleteFilter;
                            break;
                     case 'n':
                            rc = idAutoCompleteNever;
                            break;
                     }
              }
              else if (PL_strstr(prefname, "auth.") == prefname)
              {
                     switch (prefname[5]) {
                     case 'd': /* auth.dn */
                            rc = idAuthDn;
                            break;
                     case 'e': /* auth.enabled */
                            rc = idEnableAuth;
                            break;
                     case 'p': /* auth.password */
                            rc = idPassword;
                            break;
                     case 's': /* auth.savePassword */
                            rc = idSavePassword;
                            break;
                     }
              }
              else if (PL_strstr(prefname, "attributes.") == prefname)
              {
                     rc = idCustomAttributes;
              }
              break;

       case 'b':
              rc = idBasicSearchAttributes;
              break;

       case 'c':
              switch (prefname[1]) {
              case 'h': /* charset */
                     rc = idCSID;
                     break;
              case 's': /* the new csid pref that replaced char set */
                     rc = idCSID;
                     break;
              case 'o': /* columns */
                     rc = idColumnAttributes;
                     break;
              case 'u': /* customDisplayUrl */
                     rc = idCustomDisplayUrl;
                     break;
              }
              break;

       case 'd':
              switch (prefname[1]) {
              case 'e': /* description */
                     rc = idDescription;
                     break;
              case 'i': /* dirType */
                     rc = idType;
                     break;
              }
              break;

       case 'e':
              switch (prefname[1]) {
              case 'e': /* efficientWildcards */
                     rc = idEfficientWildcards;
                     break;
              }
              break;

       case 'f':
              if (PL_strstr(prefname, "filter") == prefname)
              {
                     rc = idCustomFilters;
              }
              else
              {
                     rc = idFileName;
              }
              break;

       case 'h':
              if (PL_strstr(prefname, "html.") == prefname)
              {
                     switch (prefname[5]) {
                     case 'd':
                            rc = idDnAttributes;
                            break;
                     case 's':
                            rc = idSuppressedAttributes;
                            break;
                     case 'u':
                            rc = idUriAttributes;
                            break;
                     }
              }
              break;
              
       case 'i':
              switch (prefname[2]) {
              case 'O': /* filename */
                     rc = idIsOffline;
                     break;
              case 'S': /* filename */
                     rc = idIsSecure;
                     break;
              }
              break;
       case 'l':
              rc = idLocale;
              break;

       case 'm':
              rc = idMaxHits;
              break;

       case 'p':
              switch (prefname[1]) {
              case 'o':
                     switch (prefname[2]) {
                     case 'r': /* port */
                            rc = idPort;
                            break;
                     case 's': /* position */
                            rc = idPosition;
                            break;
                     }
                     break;
                case  'r': /* protocolVersion */
                    rc = idProtocolVersion;
              }
              break;

       case 'r':
              if (PL_strstr(prefname, "replication.") == prefname)
              {
                     switch (prefname[12]) {
                     case 'd':
                            switch (prefname[13]) {
                                   case 'a': /* replication.dataVersion */
                                          rc = idReplDataVersion;
                                          break;
                                   case 'e': /* replication.description */
                                          rc = idReplDescription;
                                          break;
                            }
                            break;
                     case 'e':
                            switch (prefname[13]) {
                            case 'n': /* replication.enabled */
                                   rc = idReplEnabled;
                                   break;
                            case 'x': /* replication.excludedAttributes */
                                   rc = idReplExcludedAttributes;
                                   break;
                            }
                            break;
                     case 'f':
                            switch (prefname[15]) {
                            case 'e': /* replication.fileName */
                                   rc = idReplFileName;
                                   break;
                            case 't': /* replication.filter */
                                   rc = idReplFilter;
                                   break;
                            }
                            break;
                     case 'l': /* replication.lastChangeNumber */
                            rc = idReplLastChangeNumber;
                            break;
                     case 'n': /* replication.never */
                            rc = idReplNever;
                            break;
                     case 's': /* replication.syncURL */
                            rc = idReplSyncURL;
                            break;
                     }
              }
              break;

       case 's':
              switch (prefname[1]) {
              case 'a': /* saveResults */
                     rc = idSaveResults;
                     break;
              case 'e':
                     switch (prefname[2]) {
                     case 'a':
                            switch (prefname[6]) {
                            case 'B': /* searchBase */
                                   rc = idSearchBase;
                                   break;
                            case 'S': /* searchString */
                                   rc = idLastSearchString;
                                   break;
                            }
                            break;
                     case 'r': /* serverName */
                            rc = idServerName;
                            break;
                     }
                     break;
              }
              break;

       case 'u': /* uri */
              rc = idUri;
              break;



       case 'v': /* vlvDisabled */
              rc = idVLVDisabled;
              break;
       case 'P':
              switch (prefname[4]) {
                     case 'C': /* PalmCategoryId */
                            rc = idPalmCategory;
                            break;
                     case 'S': /* PalmSyncTimeStamp */
                            rc = idPalmSyncTimeStamp;
                            break;
              }
              break;
       }

       PR_ASSERT(rc != idNone);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult DIR_AttributeNameToId ( DIR_Server server,
const char *  attrName,
DIR_AttributeId id 
)

Definition at line 2090 of file nsDirPrefs.cpp.

{
       nsresult status = NS_OK;

       /* Look for a default attribute with a matching name.
        */
       switch (attrName[0])
       {
       case 'a':
        if (!nsCRT::strcasecmp(attrName, "auth"))
                     *id = auth;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'b':
        if (!nsCRT::strcasecmp(attrName, "businesscategory"))
                     *id = businesscategory;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'c' :
        if (!nsCRT::strcasecmp(attrName, "cn"))
                     *id = cn;
        else if (!nsCRT::strcasecmp(attrName, "carlicense"))
                     *id = carlicense;
        else if (!nsCRT::strncasecmp(attrName, "custom", 6))
              {
                     switch (attrName[6])
                     {
                     case '1': *id = custom1; break;
                     case '2': *id = custom2; break;
                     case '3': *id = custom3; break;
                     case '4': *id = custom4; break;
                     case '5': *id = custom5; break;
                     default: status = NS_ERROR_FAILURE; 
                     }
              }
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'd':
        if (!nsCRT::strcasecmp(attrName, "departmentnumber"))
                     *id = departmentnumber;
              else
            if (!nsCRT::strcasecmp(attrName, "description"))
                            *id = description;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'e':
        if (!nsCRT::strcasecmp(attrName, "employeetype"))
                     *id = employeetype;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'f':
        if (!nsCRT::strcasecmp(attrName, "facsimiletelephonenumber"))
                     *id = facsimiletelephonenumber;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'g':
        if (!nsCRT::strcasecmp(attrName, "givenname"))
                     *id = givenname; 
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'h':
        if (!nsCRT::strcasecmp(attrName, "homephone"))
                     *id = homephone;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'l':
        if (!nsCRT::strcasecmp(attrName, "l"))
                     *id = l;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'm':
        if (!nsCRT::strcasecmp(attrName, "mail"))
                     *id = mail;
        else if (!nsCRT::strcasecmp(attrName, "manager"))
                     *id = manager;
        else if (!nsCRT::strcasecmp(attrName, "mobiletelephonenumber"))
                     *id = mobiletelephonenumber;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'n':
        if (!nsCRT::strcasecmp(attrName, "nickname"))
                     *id = nickname;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'o':
        if (!nsCRT::strcasecmp(attrName, "o"))
                     *id = o;
        else if (!nsCRT::strcasecmp(attrName, "ou"))
                     *id = ou;
        else if (!nsCRT::strcasecmp(attrName, "objectclass"))
                     *id = objectclass;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 'p':
        if (!nsCRT::strcasecmp(attrName, "pager"))
                     *id = pager;
        else if (!nsCRT::strcasecmp(attrName, "postalcode"))
                     *id = postalcode;
        else if (!nsCRT::strcasecmp(attrName, "postaladdress"))
                     *id = postaladdress;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 's': 
        if (!nsCRT::strcasecmp(attrName, "street"))
                     *id = street;
        else if (!nsCRT::strcasecmp(attrName, "sn"))
                     *id = sn;
        else if (!nsCRT::strcasecmp(attrName, "secretary"))
                     *id = secretary;
              else
                     status = NS_ERROR_FAILURE;
              break;
       case 't':
        if (!nsCRT::strcasecmp(attrName, "telephonenumber"))
                     *id = telephonenumber;
        else if (!nsCRT::strcasecmp(attrName, "title"))
                     *id = title;
              else
                     status = NS_ERROR_FAILURE;
              break;
       default:
              status = NS_ERROR_FAILURE;
       }

       return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* DIR_BuildUrl ( DIR_Server s,
const char *  dn,
PRBool  forAddToAB 
)

Definition at line 1798 of file nsDirPrefs.cpp.

{
       /* OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE */
       PR_ASSERT(PR_FALSE);
       return NS_OK;
       /* OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE  OBSOLETE */
}
void DIR_ClearFlag ( DIR_Server server,
PRUint32  flag 
)

Definition at line 4339 of file nsDirPrefs.cpp.

{
       PR_ASSERT(server);
       if (server)
              server->flags &= ~flag;
}

Here is the caller graph for this function:

void DIR_ClearPrefBranch ( const char *  branch)

Definition at line 3243 of file nsDirPrefs.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
  if (NS_FAILED(rv) || !pPref) 
    return;
  
  pPref->DeleteBranch (branch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult DIR_ContainsServer ( DIR_Server pServer,
PRBool hasDir 
)

Definition at line 331 of file nsDirPrefs.cpp.

{
  if (dir_ServerList)
  {
    PRInt32 count = dir_ServerList->Count();
    PRInt32 i;
    for (i = 0; i < count; i++)
    {
      DIR_Server* server = (DIR_Server *)(dir_ServerList->ElementAt(i));
      if (server == pServer)
      {
        *hasDir = PR_TRUE;
        return NS_OK;
      }
    }
  }
  *hasDir = PR_FALSE;
  return NS_OK;
}

Here is the caller graph for this function:

char* DIR_ConvertFromServerCharSet ( DIR_Server s,
char *  src,
PRInt16  dstCsid 
)

Definition at line 4370 of file nsDirPrefs.cpp.

{
       return DIR_ConvertString((PRInt16)(server ? server->csid : CS_DEFAULT), dstCSID, src);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* DIR_ConvertString ( PRInt16  srcCSID,
PRInt16  dstCSID,
const char *  string 
)

Definition at line 4375 of file nsDirPrefs.cpp.

{
    return nsCRT::strdup(string);
}

Here is the caller graph for this function:

char* DIR_ConvertToServerCharSet ( DIR_Server s,
char *  src,
PRInt16  srcCsid 
)

Definition at line 4365 of file nsDirPrefs.cpp.

{
       return DIR_ConvertString(srcCSID, (PRInt16)(server ? server->csid : CS_DEFAULT), src);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult DIR_CopyServer ( DIR_Server in,
DIR_Server **  out 
)

Definition at line 595 of file nsDirPrefs.cpp.

{
       nsresult err = NS_OK;
       if (in) {
              *out = (DIR_Server*)PR_Malloc(sizeof(DIR_Server));
              if (*out)
              {
                     memset(*out, 0, sizeof(DIR_Server));

                     if (in->prefName)
                     {
                (*out)->prefName = nsCRT::strdup(in->prefName);
                            if (!(*out)->prefName)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->description)
                     {
                (*out)->description = nsCRT::strdup(in->description);
                            if (!(*out)->description)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->serverName)
                     {
                (*out)->serverName = nsCRT::strdup(in->serverName);
                            if (!(*out)->serverName)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->searchBase)
                     {
                (*out)->searchBase = nsCRT::strdup(in->searchBase);
                            if (!(*out)->searchBase)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->fileName)
                     {
                (*out)->fileName = nsCRT::strdup(in->fileName);
                            if (!(*out)->fileName)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->columnAttributes)
                     {
                (*out)->columnAttributes = nsCRT::strdup(in->columnAttributes);
                            if (!(*out)->columnAttributes)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->locale)
                     {
                (*out)->locale = nsCRT::strdup(in->locale);
                            if (!(*out)->locale)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     (*out)->position = in->position;
                     (*out)->port = in->port;
                     (*out)->maxHits = in->maxHits;
                     (*out)->isSecure = in->isSecure;
                     (*out)->saveResults = in->saveResults;
                     (*out)->isOffline = in->isOffline;
                     (*out)->efficientWildcards = in->efficientWildcards;
                     (*out)->dirType = in->dirType;
                     (*out)->csid = in->csid;

                     (*out)->flags = in->flags;
                     
                     (*out)->enableAuth = in->enableAuth;
                     (*out)->savePassword = in->savePassword;
                     if (in->authDn)
                     {
                (*out)->authDn = nsCRT::strdup (in->authDn);
                            if (!(*out)->authDn)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }
                     if (in->password)
                     {
                (*out)->password = nsCRT::strdup (in->password);
                            if (!(*out)->password)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->customAttributes)
                     {
                            (*out)->customAttributes = new nsVoidArray();
                            if ((*out)->customAttributes)
                            {
                                   nsVoidArray *list = in->customAttributes;
                                   DIR_Attribute *attribute = nsnull;
                                   PRInt32 count = list->Count();
                                   PRInt32 i;
                                   for (i = 0; i < count; i++)
                                   {
                                          attribute = (DIR_Attribute *)list->ElementAt(i);
                                          if (attribute)
                                          {
                                                 DIR_Attribute *outAttr = DIR_CopyAttribute (attribute);
                                                 if (outAttr)
                                                        ((*out)->customAttributes)->AppendElement(outAttr);
                                                 else
                                                        err = NS_ERROR_OUT_OF_MEMORY;
                                          }
                                   }
                            }
                            else
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->customFilters)
                     {
                            (*out)->customFilters = new nsVoidArray();
                            if ((*out)->customFilters)
                            {
                                   nsVoidArray *list = in->customFilters;
                                   DIR_Filter *filter = nsnull;

                                   PRInt32 count = list->Count();
                                   PRInt32 i;
                                   for (i = 0; i < count; i++)
                                   {
                                          filter = (DIR_Filter *)list->ElementAt(i);
                                          if (filter)
                                          {
                                                 DIR_Filter *outFilter = DIR_CopyFilter (filter);
                                                 if (outFilter)
                                                        ((*out)->customFilters)->AppendElement(outFilter);
                                                 else
                                                        err = NS_ERROR_OUT_OF_MEMORY;
                                          }
                                   }
                            }
                            else
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->autoCompleteFilter)
                     {
                (*out)->autoCompleteFilter = nsCRT::strdup(in->autoCompleteFilter);
                            if (!(*out)->autoCompleteFilter)
                                   err = NS_ERROR_OUT_OF_MEMORY;
                     }

                     if (in->replInfo)
                            (*out)->replInfo = dir_CopyReplicationInfo (in->replInfo);

                     if (in->basicSearchAttributesCount > 0)
                     {
                            PRInt32 bsaLength = in->basicSearchAttributesCount * sizeof(DIR_AttributeId);
                            (*out)->basicSearchAttributes = (DIR_AttributeId*) PR_Malloc(bsaLength);
                            if ((*out)->basicSearchAttributes)
                            {
                                   memcpy((*out)->basicSearchAttributes, in->basicSearchAttributes, bsaLength);
                                   (*out)->basicSearchAttributesCount = in->basicSearchAttributesCount;
                            }
                     }

                     dir_CopyTokenList (in->dnAttributes, in->dnAttributesCount,
                            &(*out)->dnAttributes, &(*out)->dnAttributesCount);
                     dir_CopyTokenList (in->suppressedAttributes, in->suppressedAttributesCount,
                            &(*out)->suppressedAttributes, &(*out)->suppressedAttributesCount);
                     dir_CopyTokenList (in->uriAttributes, in->uriAttributesCount,
                            &(*out)->uriAttributes, &(*out)->uriAttributesCount);

                     if (in->customDisplayUrl)
                (*out)->customDisplayUrl = nsCRT::strdup (in->customDisplayUrl);
                     if (in->searchPairList)
                (*out)->searchPairList = nsCRT::strdup (in->searchPairList);

                     (*out)->refCount = 1;
              }
              else {
                     err = NS_ERROR_OUT_OF_MEMORY;
                     (*out) = nsnull;
              }
       }
       else {
              PR_ASSERT (0);
              err = NS_ERROR_FAILURE;
              (*out) = nsnull;
       }

       return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* DIR_CopyServerStringPref ( DIR_Server server,
DIR_PrefId  prefid,
PRInt16  csid 
)

Definition at line 1170 of file nsDirPrefs.cpp.

{
       char *pref;

       if (!server)
              return nsnull;

       switch (prefid) {
       case idAuthDn:
              pref = server->authDn;
              break;
       case idPassword:
              pref = server->password;
              break;
       case idSearchBase:
              pref = server->searchBase;
              break;
       default:
              PR_ASSERT(0);
              pref = nsnull;
              break;
       }

       if (pref)
              pref = DIR_ConvertFromServerCharSet(server, pref, csid);

       return pref;
}

Here is the call graph for this function:

char* DIR_CreateServerPrefName ( DIR_Server server,
char *  name 
)

Definition at line 2683 of file nsDirPrefs.cpp.

{
  /* we are going to try to be smart in how we generate our server
     pref name. We'll try to convert the description into a pref name
     and then verify that it is unique. If it is unique then use it... */
  char * leafName = nsnull;
  char * prefName = nsnull;
  PRBool isUnique = PR_FALSE;

  if (name)
    leafName = nsCRT::strdup(name);
  else
    leafName = dir_ConvertDescriptionToPrefName (server);

  if (!leafName || !*leafName)
  {
    // we need to handle this in case the description has no alphanumeric chars
    // it's very common for cjk users
    leafName = nsCRT::strdup("_nonascii");
  }

  if (leafName)
  {
    PRInt32 uniqueIDCnt = 0;
        char **children = nsnull;
    /* we need to verify that this pref string name is unique */
    prefName = PR_smprintf(PREF_LDAP_SERVER_TREE_NAME".%s", leafName);
    isUnique = PR_FALSE;
    PRUint32 prefCount;
    nsresult rv = dir_GetChildList(NS_LITERAL_CSTRING(PREF_LDAP_SERVER_TREE_NAME "."),
                                   &prefCount, &children);
    if (NS_SUCCEEDED(rv))
    {
      while (!isUnique && prefName)
      {
        isUnique = PR_TRUE; /* now flip the logic and assume we are unique until we find a match */
        for (PRUint32 i = 0; i < prefCount && isUnique; ++i)
        {
          if (!nsCRT::strcasecmp(children[i], prefName)) /* are they the same branch? */
            isUnique = PR_FALSE;
        }
        if (!isUnique) /* then try generating a new pref name and try again */
        {
          PR_smprintf_free(prefName);
          prefName = PR_smprintf(PREF_LDAP_SERVER_TREE_NAME".%s_%d", leafName, ++uniqueIDCnt);
        }
      } /* if we have a list of pref Names */

      NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, children);
    } /* while we don't have a unique name */

    // fallback to "user_directory_N" form if we failed to verify
    if (!isUnique && prefName)
    {
      PR_smprintf_free(prefName);
      prefName = nsnull;
    }

    PR_Free(leafName);

  } /* if leafName */

  if (!prefName) /* last resort if we still don't have a pref name is to use user_directory string */
    return PR_smprintf(PREF_LDAP_SERVER_TREE_NAME".user_directory_%d", ++dir_UserId);
  else
    return prefName;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 426 of file nsDirPrefs.cpp.

{
  NS_ASSERTION((server != nsnull), "server is null");
       if (server && --server->refCount <= 0)
          return DIR_DeleteServer(server);
        else
          return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1711 of file nsDirPrefs.cpp.

{
       if (server)
       {
              dir_DeleteServerContents(server);
              PR_Free(server);
       }

       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1722 of file nsDirPrefs.cpp.

{
       if (!server)
              return NS_ERROR_NULL_POINTER;

       nsresult rv = NS_OK;
       nsCOMPtr<nsILocalFile> dbPath;

       nsCOMPtr<nsIAddrBookSession> abSession = 
                do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv); 
       if(NS_SUCCEEDED(rv))
         rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
       
       if (NS_SUCCEEDED(rv))
       {
    // close the database, as long as it isn't the special ones 
    // (personal addressbook and collected addressbook)
    // which can never be deleted.  There was a bug where we would slap in
    // "abook.mab" as the file name for LDAP directories, which would cause a crash
    // on delete of LDAP directories.  this is just extra protection.
    if (strcmp(server->fileName, kPersonalAddressbook) && 
        strcmp(server->fileName, kCollectedAddressbook)) {
              nsCOMPtr<nsIAddrDatabase> database;

              rv = dbPath->AppendNative(nsDependentCString(server->fileName));
              NS_ENSURE_SUCCESS(rv, rv);

              // close file before delete it
              nsCOMPtr<nsIAddrDatabase> addrDBFactory = 
                       do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);

              if (NS_SUCCEEDED(rv) && addrDBFactory)
                     rv = addrDBFactory->Open(dbPath, PR_FALSE, PR_TRUE, getter_AddRefs(database));
              if (database)  /* database exists */
              {
                     database->ForceClosed();
                     rv = dbPath->Remove(PR_FALSE);
                     NS_ENSURE_SUCCESS(rv, rv);
              }
    }

              nsVoidArray *dirList = DIR_GetDirectories();
              DIR_SetServerPosition(dirList, server, DIR_POS_DELETE);
              DIR_DeleteServer(server);

              rv = NS_OK;
              nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
              if (NS_FAILED(rv) || !pPref) 
                     return NS_ERROR_FAILURE;

              pPref->SavePrefFile(nsnull);

              return NS_OK;
       }

       return NS_ERROR_NULL_POINTER;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1780 of file nsDirPrefs.cpp.

{
       DIR_Server *server = nsnull;
       
       /* TBD: Send notifications? */
       PRInt32 count = wholeList->Count();
       PRInt32 i;
       for (i = count - 1; i >=0; i--)
       {
              server = (DIR_Server *)wholeList->ElementAt(i);
              if (server != nsnull)
                     DIR_DeleteServer(server);
       }
       delete wholeList;
       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1131 of file nsDirPrefs.cpp.

{
       DIR_Callback *cb, *cbPrev=nsnull;

       for (cb = dir_CallbackList; cb && cb->fn != fn && cb->data != inst_data; cb = cb->next)
              cbPrev = cb;

       if (cb == nsnull)
              return PR_FALSE;

       if (cb == dir_CallbackList)
              dir_CallbackList = cb->next;
       else
              cbPrev->next = cb->next;

       PR_Free(cb);
       return PR_TRUE;
}
void DIR_ForceFlag ( DIR_Server server,
PRUint32  flag,
PRBool  forceOnOrOff 
)

Definition at line 4347 of file nsDirPrefs.cpp.

{
       PR_ASSERT(server);
       if (server)
       {
              if (setIt)
                     server->flags |= flag;
              else
                     server->flags &= ~flag;
       }
}

Here is the caller graph for this function:

const char* DIR_GetAttributeName ( DIR_Server server,
DIR_AttributeId  id 
)

Definition at line 3915 of file nsDirPrefs.cpp.

{
       char *result = nsnull;

       /* First look in the custom attributes in case the attribute is overridden */
       nsVoidArray *list = server->customAttributes;
       DIR_Attribute *walkList = nsnull;

       PRInt32  count = list->Count();
       PRInt32  i;
       for (i = 0; i < count; i++)
       {
              if ((walkList = (DIR_Attribute *)list->ElementAt(i)) != nsnull)
              {
                     if (walkList->id == id)
                            result = walkList->prettyName;
              }
       }

       /* If we didn't find it, look in our own static list of attributes */
//     if (!result)
//     {
//            DIR_DefaultAttribute *def;
//            if ((def = DIR_GetDefaultAttribute(id)) != nsnull)
//                   result = (char*)XP_GetString(def->resourceId);
//     }

       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3946 of file nsDirPrefs.cpp.

{
       const char **result = nsnull;

       if (server && server->customAttributes)
       {
              /* First look in the custom attributes in case the attribute is overridden */
              nsVoidArray *list = server->customAttributes;
              DIR_Attribute *walkList = nsnull;
              PRInt32  count = list->Count();
              PRInt32  i;
              for (i = 0; i < count; i++)
              {
                     while ((walkList = (DIR_Attribute *)list->ElementAt(i)) != nsnull)
                     {
                            if (walkList->id == id)
                                   result = (const char**)walkList->attrNames;
                     }
              }
       }

       /* If we didn't find it, look in our own static list of attributes */
       if (!result)
       {
              static const char *array[2];
              array[0] = DIR_GetDefaultAttribute(id)->name;
              array[1] = nsnull;
              result = (const char**)array;
       }
       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 223 of file nsDirPrefs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 230 of file nsDirPrefs.cpp.

{
  nsresult rv = NS_OK;
  
  if (!dir_ServerList)
  {
    nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
    if (NS_FAILED(rv) || !pPref) 
              return NS_ERROR_FAILURE;
    
    /* we need to build the DIR_Server list */ 
    rv = DIR_GetServerPreferences(&dir_ServerList);
    
    /* Register the preference call back if necessary. */
    if (NS_SUCCEEDED(rv) && (!dir_ServerPrefCallbackRegistered))
    {
      dir_ServerPrefCallbackRegistered = PR_TRUE;
      pPref->RegisterCallback(PREF_LDAP_SERVER_TREE_NAME, dir_ServerPrefCallback, nsnull);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult DIR_GetDirServerSubset ( nsVoidArray wholeList,
nsVoidArray subList,
PRUint32  flags 
)

Definition at line 1821 of file nsDirPrefs.cpp.

{
       if (wholeList && subList && flags)
       {
              PRInt32 i;
              PRInt32 numItems = wholeList->Count();

              for (i = 0; i < numItems; i++)
              {
                     DIR_Server *s = (DIR_Server*) wholeList->ElementAt(i);
                     if (DIR_SUBSET_MATCH(s, flags))
                     {
                            subList->AppendElement(s);
                     }
              }
              return NS_OK;
       }
       return NS_ERROR_FAILURE;
}

Here is the caller graph for this function:

Definition at line 1841 of file nsDirPrefs.cpp.

{
       PRInt32 count = 0;

       if (wholeList && flags)
       {
              PRInt32 i;
              PRInt32 numItems = wholeList->Count();

              for (i = 0; i < numItems; i++)
              {
                     DIR_Server *s = (DIR_Server*) wholeList->ElementAt(i);
                     if (DIR_SUBSET_MATCH(s, flags))
                     {
                            count++;
                     }
              }
       }

       return count;
}
const char* DIR_GetFilterString ( DIR_Server server)

Definition at line 3993 of file nsDirPrefs.cpp.

{
       if (!server)
              return nsnull;

       DIR_Filter *filter = (DIR_Filter *)server->customFilters->SafeElementAt(0);
       if (filter)
              return filter->string;
       return nsnull;
}

Definition at line 3979 of file nsDirPrefs.cpp.

{
       const char **array = DIR_GetAttributeStrings (server, id);
       return array[0];
}

Here is the call graph for this function:

void DIR_GetPrefsForOneServer ( DIR_Server server,
PRBool  reinitialize,
PRBool  oldstyle 
)

Definition at line 2751 of file nsDirPrefs.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
  if (NS_FAILED(rv) || !pPref) 
    return;
  
  PRBool  prefBool;
  char    *prefstring = server->prefName;
  char     tempstring[256];
  char    *csidString  = nsnull;
  PRBool forcePrefSave = PR_FALSE;  /* if when reading in the prefs we did something that forces us to save the branch...*/
  
  if (reinitialize)
  {
    /* If we're reinitializing, we need to save off the runtime volatile
    * data which isn't stored in persistent JS prefs and restore it
    */
    PRUint32 oldRefCount = server->refCount;
    server->prefName = nsnull;
    dir_DeleteServerContents(server);
    DIR_InitServer(server);
    server->prefName = prefstring;
    server->refCount = oldRefCount; 
  }
  
  // this call fills in tempstring with the position pref, and
  // we then check to see if it's locked.
  server->position = DIR_GetIntPref (prefstring, "position", tempstring, kDefaultPosition);
  PRBool bIsLocked;
  pPref->PrefIsLocked(tempstring, &bIsLocked);
  DIR_ForceFlag(server, DIR_UNDELETABLE | DIR_POSITION_LOCKED, bIsLocked);
  
  server->isSecure = DIR_GetBoolPref (prefstring, "isSecure", tempstring, PR_FALSE);
  server->saveResults = DIR_GetBoolPref (prefstring, "saveResults", tempstring, PR_TRUE);                       
  server->efficientWildcards = DIR_GetBoolPref (prefstring, "efficientWildcards", tempstring, PR_TRUE);                       
  server->port = DIR_GetIntPref (prefstring, "port", tempstring, server->isSecure ? LDAPS_PORT : LDAP_PORT);
  if (server->port == 0)
    server->port = server->isSecure ? LDAPS_PORT : LDAP_PORT;
  server->maxHits = DIR_GetIntPref (prefstring, "maxHits", tempstring, kDefaultMaxHits);
  
  if (0 == PL_strcmp(prefstring, "ldap_2.servers.pab") || 
    0 == PL_strcmp(prefstring, "ldap_2.servers.history")) 
  {
    // get default address book name from addressbook.properties 
    server->description = DIR_GetLocalizedStringPref(prefstring, "description", tempstring, "");
  }
  else
    server->description = DIR_GetStringPref (prefstring, "description", tempstring, "");
  
  server->serverName = DIR_GetStringPref (prefstring, "serverName", tempstring, "");
  server->searchBase = DIR_GetStringPref (prefstring, "searchBase", tempstring, "");
  server->isOffline = DIR_GetBoolPref (prefstring, "isOffline", tempstring, kDefaultIsOffline);
  server->dirType = (DirectoryType)DIR_GetIntPref (prefstring, "dirType", tempstring, LDAPDirectory);
  if (server->dirType == PABDirectory)
  {
    /* make sure there is a PR_TRUE PAB */
    if (!server->serverName || !*server->serverName)
      server->isOffline = PR_FALSE;
    server->saveResults = PR_TRUE; /* never let someone delete their PAB this way */
  }
  
  /* load in the column attributes */
  if (server->dirType == PABDirectory || server->dirType == MAPIDirectory)
    server->columnAttributes = DIR_GetStringPref(prefstring, "columns", tempstring, kDefaultPABColumnHeaders);
  else
    server->columnAttributes = DIR_GetStringPref(prefstring, "columns", tempstring, kDefaultLDAPColumnHeaders);
  
  server->fileName = DIR_GetStringPref (prefstring, "filename", tempstring, "");
  if ( (!server->fileName || !*(server->fileName)) && !oldstyle) /* if we don't have a file name and this is the new branch get a file name */
    DIR_SetServerFileName (server, server->serverName);
  if (server->fileName && *server->fileName)
    DIR_ConvertServerFileName(server);
  
  // the string "s" is the default uri ( <scheme> + "://" + <filename> )
  nsCString s((server->dirType == PABDirectory || server->dirType == MAPIDirectory) ? kMDBDirectoryRoot : kLDAPDirectoryRoot);
  s.Append (server->fileName);
  server->uri = DIR_GetStringPref (prefstring, "uri", tempstring, s.get ());
  
  server->lastSearchString = DIR_GetStringPref (prefstring, "searchString", tempstring, "");
  
  /* This is where site-configurable attributes and filters are read from JavaScript */
  DIR_GetCustomAttributePrefs (prefstring, server);
  DIR_GetCustomFilterPrefs (prefstring, server, tempstring);
  
  /* The replicated attributes and basic search attributes can only be
        * attributes which are in our predefined set (DIR_AttributeId) so
         * store those in an array of IDs for more convenient access
        */
  dir_GetReplicationInfo (prefstring, server, tempstring);
  
  server->PalmCategoryId = DIR_GetIntPref (prefstring, "PalmCategoryId", tempstring, -1);
  server->PalmSyncTimeStamp = DIR_GetIntPref (prefstring, "PalmSyncTimeStamp", tempstring, 0);
  
  /* Get authentication prefs */
  server->enableAuth = DIR_GetBoolPref (prefstring, "auth.enabled", tempstring, kDefaultEnableAuth);
  server->authDn = DIR_GetStringPref (prefstring, "auth.dn", tempstring, nsnull);
  server->savePassword = DIR_GetBoolPref (prefstring, "auth.savePassword", tempstring, kDefaultSavePassword);
  if (server->savePassword)
    server->password = DIR_GetStringPref (prefstring, "auth.password", tempstring, "");
  
  char *versionString = DIR_GetStringPref(prefstring, "protocolVersion", 
                                          tempstring, "3");
  DIR_ForceFlag(server, DIR_LDAP_VERSION3, !strcmp(versionString, "3"));
  nsCRT::free(versionString);

  prefBool = DIR_GetBoolPref (prefstring, "autoComplete.enabled", tempstring, kDefaultAutoCompleteEnabled);
  DIR_ForceFlag (server, DIR_AUTO_COMPLETE_ENABLED, prefBool);
  prefBool = DIR_GetBoolPref (prefstring, "autoComplete.never", tempstring, kDefaultAutoCompleteNever);
  DIR_ForceFlag (server, DIR_AUTO_COMPLETE_NEVER, prefBool);
  server->autoCompleteFilter = DIR_GetStringPref (prefstring, "autoComplete.filter", tempstring, nsnull);
  
  /* read in the I18N preferences for the directory --> locale and csid */
  
  /* okay we used to write out the csid as a integer pref called "charset" then we switched to a string pref called "csid" 
  for I18n folks. So we want to read in the old integer pref and if it is not kDefaultPABCSID (which is a bogus -1), 
  then use it as the csid and when we save the server preferences later on we'll clear the old "charset" pref so we don't
  have to do this again. Otherwise, we already have a string pref so use that one */
  
  csidString = DIR_GetStringPref (prefstring, "csid", tempstring, nsnull);
  if (csidString) /* do we have a csid string ? */
  {
    server->csid = CS_UTF8;
    //        server->csid = INTL_CharSetNameToID (csidString);
    PR_Free(csidString);
  }
  else 
  { 
    /* try to read it in from the old integer style char set preference */
    if (server->dirType == PABDirectory || server->dirType == MAPIDirectory)
      server->csid = (PRInt16) DIR_GetIntPref (prefstring, "charset", tempstring, kDefaultPABCSID);
    else
      server->csid = (PRInt16) DIR_GetIntPref (prefstring, "charset", tempstring, kDefaultLDAPCSID);     
    
    forcePrefSave = PR_TRUE; /* since we read from the old pref we want to force the new pref to be written out */
  }
  
  if (server->csid == CS_DEFAULT || server->csid == CS_UNKNOWN)
    server->csid = CS_UTF8;
  //          server->csid = INTL_GetCharSetID(INTL_DefaultTextWidgetCsidSel);
  
  /* now that the csid is taken care of, read in the locale preference */
  server->locale = DIR_GetStringPref (prefstring, "locale", tempstring, nsnull);
  
  prefBool = DIR_GetBoolPref (prefstring, "vlvDisabled", tempstring, kDefaultVLVDisabled);
  DIR_ForceFlag (server, DIR_LDAP_VLV_DISABLED | DIR_LDAP_ROOTDSE_PARSED, prefBool);
  
  server->customDisplayUrl = DIR_GetStringPref (prefstring, "customDisplayUrl", tempstring, "");
  
  if (!oldstyle /* we don't care about saving old directories */ && forcePrefSave && !dir_IsServerDeleted(server) )
    DIR_SavePrefsForOneServer(server); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3985 of file nsDirPrefs.cpp.

{
       if (server && server->replInfo)
              return server->replInfo->filter;
       else
              return nsnull;
}

Definition at line 3050 of file nsDirPrefs.cpp.

{
  nsresult err = NS_OK;
  nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &err)); 
  if (NS_FAILED(err) || !pPref) 
    return NS_ERROR_FAILURE;
  
  PRInt32 position = 1;
  PRInt32 version = -1;
  char **oldChildren = nsnull;
  PRBool savePrefs = PR_FALSE;
  PRBool migrating = PR_FALSE;
  nsVoidArray *oldList = nsnull;
  nsVoidArray *obsoleteList = nsnull;
  nsVoidArray *newList = nsnull;
  PRInt32 i, j, count;
  
  
  /* Update the ldap list version and see if there are old prefs to migrate. */
  if (pPref->GetIntPref(PREF_LDAP_VERSION_NAME, &version) == PREF_NOERROR)
  {
    if (version < kPreviousListVersion)
    {
      pPref->SetIntPref(PREF_LDAP_VERSION_NAME, kCurrentListVersion);
      
      /* Look to see if there's an old-style "ldap_1" tree in prefs */
      PRUint32 prefCount;
      err = dir_GetChildList(NS_LITERAL_CSTRING("ldap_1."),
        &prefCount, &oldChildren);
      if (NS_SUCCEEDED(err))
      {
        if (prefCount > 0)
        {
          migrating = PR_TRUE;
          position = dir_GetPrefsFrom40Branch(&oldList);
        }
        NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, oldChildren);
      }
    }
  }
  
  /* Find the new-style "ldap_2.servers" tree in prefs */
  err = dir_GetPrefsFrom45Branch(&newList, migrating ? &obsoleteList : nsnull);
  
  /* Merge the new tree onto the old tree, old on top, new at bottom */
  if (NS_SUCCEEDED(err) && oldList && newList)
  {
    DIR_Server *newServer;
    
    /* Walk through the new list looking for servers that are duplicates of
    * ones in the old list.  Mark any duplicates for non-inclusion in the
    * final list.
    */
    PRInt32 newCount = newList->Count();
    for (i = 0; i < newCount; i++)
    {
      newServer = (DIR_Server *)newList->ElementAt(i);
      if (nsnull != newServer)
      {
        DIR_Server *oldServer;
        
        PRInt32 oldCount = oldList->Count();
        for (j = 0; j < oldCount; j++)
        {
          oldServer = (DIR_Server *)oldList->ElementAt(j);
          if (nsnull != oldServer)
          {
          /* Don't add servers which are in the old list and don't add a
          * second personal address book.
            */
            if (dir_AreServersSame(newServer, oldServer, PR_FALSE) ||
                (oldServer->dirType == PABDirectory && !oldServer->isOffline &&
                 newServer->dirType == PABDirectory && !newServer->isOffline))
            {
            /* Copy any new prefs out of the new server.
              */
              PR_FREEIF(oldServer->prefName);
              oldServer->prefName  = nsCRT::strdup(newServer->prefName);
              /* since the pref name has now been set, we can generate a proper
              file name in case we don't have one already */
              if (!oldServer->fileName || !*oldServer->fileName)
                DIR_SetServerFileName(oldServer, nsnull); 
              
              oldServer->flags     = newServer->flags;
              
              /* Mark the new version of the server as one not to be moved
              * to the final list.
              */
              newServer->position = 0;
              break;
            }
          }
        }
      }
    }
    
    /* Walk throught the new list again.  This time delete duplicates and
    * move the rest to the old (final) list.
    */
    count = newList->Count();
    for (i = count - 1; i >= 0; i--)
    {
      newServer = (DIR_Server *)newList->ElementAt(i);
      if (!dir_IsServerDeleted(newServer))
      {
      /* Make sure new servers are placed after old servers, but
      * keep them in relative order.
        */
        if (!DIR_TestFlag(newServer, DIR_POSITION_LOCKED))
        {
        /* The server at position 2 (i.e. Netcenter) must be left
        * at position 2.
          */
          if (newServer->position > 2) 
            newServer->position += position;
        }
        oldList->AppendElement(newServer);
      }
      else
      {
        DIR_DecrementServerRefCount(newServer);
      }
    }
    newList->Clear();
    DIR_DeleteServerList(newList);
    
    *list = oldList;
    savePrefs = PR_TRUE;
  }
  else
    *list = newList;
  
    /* Remove any obsolete servers from the list.
    * Note that we only remove obsolete servers when we are migrating.  We
    * don't do it otherwise because that would keep users from manually
    * re-adding these servers (which they should be allowed to do).
    */
  if (NS_SUCCEEDED(err) && obsoleteList)
  {
    DIR_Server *obsoleteServer;
    nsVoidArray *walkObsoleteList = obsoleteList;
    
    count = walkObsoleteList->Count();
    for (i = 0; i < count;i++)
    {
      if (nsnull != (obsoleteServer = (DIR_Server *)walkObsoleteList->ElementAt(i)))
      {
        DIR_Server *existingServer;
        nsVoidArray *walkExistingList = *list;
        
        PRInt32 existCount = walkExistingList->Count();
        for (j = 0; j < existCount;j++)
        {
          existingServer = (DIR_Server *)walkExistingList->ElementAt(j);
          if (nsnull != existingServer)
          {
            if (dir_AreServersSame(existingServer, obsoleteServer, PR_FALSE))
            {
              savePrefs = PR_TRUE;
              DIR_DecrementServerRefCount(existingServer);
              (*list)->RemoveElement(existingServer);
              break;
            }
          }
        }
      }
    }
  }
  if (obsoleteList)
    DIR_DeleteServerList(obsoleteList);
  
  if (version < kCurrentListVersion)
  {
    pPref->SetIntPref(PREF_LDAP_VERSION_NAME, kCurrentListVersion);
    // see if we have the ab upgrader.  if so, skip this, since we
    // will be migrating.
    nsresult rv;
    nsCOMPtr <nsIAbUpgrader> abUpgrader = do_GetService(NS_AB4xUPGRADER_CONTRACTID, &rv);
    if (NS_FAILED(rv) || !abUpgrader) 
    {
      // if we can upgrade, don't touch the 4.x pab.
      // if we can't, move the 4.x pab aside
      dir_ConvertToMabFileName();
    }
  }
  /* Write the merged list so we get it next time we ask */
  if (savePrefs)
    DIR_SaveServerPreferences(*list);
 
  DIR_SortServersByPosition(*list);
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4051 of file nsDirPrefs.cpp.

{
       return server->tokenSeps ? server->tokenSeps : kDefaultTokenSeps;
}

Definition at line 435 of file nsDirPrefs.cpp.

{
  NS_ASSERTION((server != nsnull), "server is null");
  if (server)
    server->refCount++;
  return NS_OK;
}

Definition at line 471 of file nsDirPrefs.cpp.

{
  NS_ASSERTION((server != nsnull), "server is null");
  if (server)
  {
    memset(server, 0, sizeof(DIR_Server));
    server->saveResults = PR_TRUE;
    server->efficientWildcards = kDefaultEfficientWildcards;
    server->port = LDAP_PORT;
    server->maxHits = kDefaultMaxHits;
    server->isOffline = kDefaultIsOffline;
    server->refCount = 1;
    server->position = kDefaultPosition;
    server->csid = CS_UTF8;
    server->locale = nsnull;
    server->uri = nsnull;
    // initialize the palm category
    server->PalmCategoryId = -1;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 448 of file nsDirPrefs.cpp.

{
  DIR_InitServer(server);
  server->dirType = dirType;
  if (dirType == LDAPDirectory)
  {
    server->columnAttributes = nsCRT::strdup(kDefaultLDAPColumnHeaders);
    server->isOffline = PR_TRUE;
    server->csid = CS_UTF8;
    server->locale = nsnull;
  }
  else if (dirType == PABDirectory || dirType == MAPIDirectory)
  {
    server->columnAttributes = nsCRT::strdup(kDefaultPABColumnHeaders);
    server->isOffline = PR_FALSE;
    server->csid = CS_UTF8;
    //        server->csid = INTL_GetCharSetID(INTL_DefaultTextWidgetCsidSel);
    server->locale = nsnull; /* get the locale we are going to use with this AB */
    /*        server->locale = INTL_GetCollationKeyLocale(nsnull); */
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4113 of file nsDirPrefs.cpp.

{
       if (s && s->suppressedAttributes)
       {
              /* Look in the server object to see if there are prefs to tell
               * us which attributes shouldn't be shown in HTML
               */
              PRInt32 i;
              for (i = 0; i < s->suppressedAttributesCount; i++)
              {
            if (!nsCRT::strcasecmp(attrib, s->suppressedAttributes[i]))
                            return PR_TRUE;
              }
       }
       /* else don't exclude it. By default we show everything */

       return PR_FALSE;
}

Here is the call graph for this function:

PRBool DIR_IsDnAttribute ( DIR_Server s,
const char *  attr 
)

Definition at line 4073 of file nsDirPrefs.cpp.

{
       if (s && s->dnAttributes)
       {
              /* Look in the server object to see if there are prefs to tell
               * us which attributes contain DNs
               */
              PRInt32 i;
              for (i = 0; i < s->dnAttributesCount; i++)
              {
            if (!nsCRT::strcasecmp(attrib, s->dnAttributes[i]))
                            return PR_TRUE;
              }
       }
       else
       {
              /* We have some default guesses about what attributes 
               * are likely to contain DNs 
               */
              switch (tolower(attrib[0]))
              {
              case 'm':
            if (!nsCRT::strcasecmp(attrib, "manager") || 
                !nsCRT::strcasecmp(attrib, "member"))
                            return PR_TRUE;
                     break;
              case 'o':
            if (!nsCRT::strcasecmp(attrib, "owner"))
                            return PR_TRUE;
                     break;
              case 'u':
            if (!nsCRT::strcasecmp(attrib, "uniquemember"))
                            return PR_TRUE;
                     break;
              }
       }
       return PR_FALSE;
}

Here is the call graph for this function:

PRBool DIR_IsEscapedAttribute ( DIR_Server s,
const char *  attrib 
)

Definition at line 4219 of file nsDirPrefs.cpp.

{
       /* We're not exposing this setting in JS prefs right now, but in case we
        * might want to in the future, leave the DIR_Server* in the prototype.
        */

       switch (tolower(attrib[0]))
       {
       case 'p':
        if (!nsCRT::strcasecmp(attrib, "postaladdress"))
                     return PR_TRUE;
              break;
       case 'f': 
        if (!nsCRT::strcasecmp(attrib, "facsimiletelephonenumber"))
                     return PR_TRUE;
              break;
       case 'o':
        if (!nsCRT::strcasecmp(attrib, "othermail"))
                     return PR_TRUE;
              break;
       }
       return PR_FALSE;
}

Here is the call graph for this function:

PRBool DIR_IsUriAttribute ( DIR_Server s,
const char *  attrib 
)

Definition at line 4132 of file nsDirPrefs.cpp.

{
       if (s && s->uriAttributes)
       {
              /* Look in the server object to see if there are prefs to tell
               * us which attributes are URLs
               */
              PRInt32 i;
              for (i = 0; i < s->uriAttributesCount; i++)
              {
            if (!nsCRT::strcasecmp(attrib, s->uriAttributes[i]))
                            return PR_TRUE;
              }
       }
       else
       {
              /* We have some default guesses about what attributes 
               * are likely to contain URLs
               */
              switch (tolower(attrib[0]))
              {
              case 'l':
            if (   !nsCRT::strcasecmp(attrib, "labeleduri")
                || !nsCRT::strcasecmp(attrib, "labeledurl"))
                            return PR_TRUE;
                     break;
              case 'u':
            if (!nsCRT::strcasecmp(attrib, "url"))
                            return PR_TRUE;
                     break;
              }
       }
       return PR_FALSE;
}

Here is the call graph for this function:

DIR_Server* DIR_LookupServer ( char *  serverName,
PRInt32  port,
char *  searchBase 
)

Definition at line 1553 of file nsDirPrefs.cpp.

{
       PRInt32 i;
       DIR_Server *server;

       if (!serverName || !searchBase || !dir_ServerList)
              return nsnull;

       for (i = dir_ServerList->Count() - 1; i >= 0; i--)
       {
              server = (DIR_Server *)dir_ServerList->ElementAt(i);
              if (   server->port == port
            && server->serverName && nsCRT::strcasecmp(server->serverName, serverName) == 0
            && server->searchBase && nsCRT::strcasecmp(server->searchBase, searchBase) == 0)
              {
                     return server;
              }
       }

       return nsnull;
}

Here is the call graph for this function:

Definition at line 1105 of file nsDirPrefs.cpp.

{
       DIR_Callback *cb;

       for (cb = dir_CallbackList; cb; cb = cb->next)
       {
              if (cb->fn == fn)
              {
                     cb->flags = flags;
                     return PR_TRUE;
              }
       }

       cb = (DIR_Callback *)PR_Malloc(sizeof(DIR_Callback));
       if (!cb)
              return PR_FALSE;

       cb->fn    = fn;
       cb->flags = flags;
       cb->data  = inst_data;
       cb->next  = dir_CallbackList;
       dir_CallbackList = cb;

       return PR_TRUE;
}
PRBool DIR_RepeatFilterForTokens ( DIR_Server server,
const char *  filter 
)

Definition at line 4025 of file nsDirPrefs.cpp.

{
       if (!server)
              return nsnull;

       DIR_Filter *f;
       
       if (!filter)
              f = (DIR_Filter *)server->customFilters->SafeElementAt(0);
       else
              f = DIR_LookupFilter (server, filter);

       return f ? (f->flags & DIR_F_REPEAT_FILTER_FOR_TOKENS) != 0 : kDefaultRepeatFilterForTokens;
}

Here is the call graph for this function:

Definition at line 3639 of file nsDirPrefs.cpp.

{
       char *prefstring;
       char tempstring[256];
       char * csidAsString = nsnull;

       if (server->prefName == nsnull)
              server->prefName = DIR_CreateServerPrefName (server, nsnull);
       prefstring = server->prefName;

       DIR_SetFlag(server, DIR_SAVING_SERVER);

       DIR_SetIntPref (prefstring, "position", tempstring, server->position, kDefaultPosition);

       // Only save the non-default address book name
       if (0 != PL_strcmp(prefstring, "ldap_2.servers.pab") &&
              0 != PL_strcmp(prefstring, "ldap_2.servers.history")) 
              DIR_SetStringPref (prefstring, "description", tempstring, server->description, "");

       DIR_SetStringPref (prefstring, "serverName", tempstring, server->serverName, "");
       DIR_SetStringPref (prefstring, "searchBase", tempstring, server->searchBase, "");
       DIR_SetStringPref (prefstring, "filename", tempstring, server->fileName, "");
       if (server->port == 0)
              server->port = server->isSecure ? LDAPS_PORT : LDAP_PORT;
       DIR_SetIntPref (prefstring, "port", tempstring, server->port, server->isSecure ? LDAPS_PORT : LDAP_PORT);
       DIR_SetIntPref (prefstring, "maxHits", tempstring, server->maxHits, kDefaultMaxHits);
       DIR_SetBoolPref (prefstring, "isSecure", tempstring, server->isSecure, PR_FALSE);
       DIR_SetBoolPref (prefstring, "saveResults", tempstring, server->saveResults, PR_TRUE);
       DIR_SetBoolPref (prefstring, "efficientWildcards", tempstring, server->efficientWildcards, PR_TRUE);
       DIR_SetStringPref (prefstring, "searchString", tempstring, server->lastSearchString, "");
       DIR_SetIntPref (prefstring, "dirType", tempstring, server->dirType, LDAPDirectory);
       DIR_SetBoolPref (prefstring, "isOffline", tempstring, server->isOffline, kDefaultIsOffline);

  if (server->dirType == LDAPDirectory)
      DIR_SetStringPref(prefstring, "uri", tempstring, server->uri, "");

       /* save the column attributes */
       if (server->dirType == PABDirectory || server->dirType == MAPIDirectory)
              DIR_SetStringPref(prefstring, "columns", tempstring, server->columnAttributes, kDefaultPABColumnHeaders);
       else
              DIR_SetStringPref(prefstring, "columns", tempstring, server->columnAttributes, kDefaultLDAPColumnHeaders);

       DIR_SetBoolPref (prefstring, "autoComplete.enabled", tempstring, DIR_TestFlag(server, DIR_AUTO_COMPLETE_ENABLED), kDefaultAutoCompleteEnabled);
       DIR_SetStringPref (prefstring, "autoComplete.filter", tempstring, server->autoCompleteFilter, nsnull);
       DIR_SetBoolPref (prefstring, "autoComplete.never", tempstring, DIR_TestFlag(server, DIR_AUTO_COMPLETE_NEVER), kDefaultAutoCompleteNever);

       /* save the I18N information for the directory */
       
       /* I18N folks want us to save out the csid as a string.....*/
/*     csidAsString = (char *) INTL_CsidToCharsetNamePt(server->csid);*/ /* this string is actually static we should not free it!!! */
       csidAsString = NULL; /* this string is actually static we should not free it!!! */
       if (csidAsString)
              DIR_SetStringPref(prefstring, "csid", tempstring, csidAsString, nsnull);
       
       /* since we are no longer writing out the csid as an integer, make sure that preference is removed.
          kDefaultPABCSID is a bogus csid value that when we read back in we can recognize as an outdated pref */

       /* this is dirty but it works...this is how we assemble the pref name in all of the DIR_SetString/bool/intPref functions */
       PL_strcpy(tempstring, prefstring);
       PL_strcat(tempstring, ".");
       PL_strcat(tempstring, "charset");
       DIR_ClearIntPref(tempstring);  /* now clear the pref */

       /* now save the locale string */
       DIR_SetStringPref(prefstring, "locale", tempstring, server->locale, nsnull);

       /* Save authentication prefs */
       DIR_SetBoolPref (prefstring, "auth.enabled", tempstring, server->enableAuth, kDefaultEnableAuth);
       DIR_SetBoolPref (prefstring, "auth.savePassword", tempstring, server->savePassword, kDefaultSavePassword);
    DIR_SetStringPref (prefstring, "auth.dn", tempstring, server->authDn, "");
       if (server->savePassword && server->authDn && server->password)
       {
              DIR_SetStringPref (prefstring, "auth.password", tempstring, server->password, "");
       }
       else
       {
              DIR_SetStringPref (prefstring, "auth.password", tempstring, "", "");
              PR_FREEIF (server->password);
       }

       DIR_SetBoolPref (prefstring, "vlvDisabled", tempstring, DIR_TestFlag(server, DIR_LDAP_VLV_DISABLED), kDefaultVLVDisabled);

        DIR_SetStringPref(prefstring, "protocolVersion", tempstring,
                          DIR_TestFlag(server, DIR_LDAP_VERSION3) ? "3" : "2",
                          "3");

       DIR_SaveCustomAttributes (prefstring, tempstring, server);
       DIR_SaveCustomFilters (prefstring, tempstring, server);

       dir_SaveReplicationInfo (prefstring, tempstring, server);
       
       DIR_SetIntPref (prefstring, "PalmCategoryId", tempstring, server->PalmCategoryId, -1);
       DIR_SetIntPref (prefstring, "PalmSyncTimeStamp", tempstring, server->PalmSyncTimeStamp, 0);

       DIR_SetStringPref (prefstring, "customDisplayUrl", tempstring, server->customDisplayUrl, "");

       DIR_ClearFlag(server, DIR_SAVING_SERVER);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3738 of file nsDirPrefs.cpp.

{
       if (wholeList)
       {
              nsresult rv = NS_OK;
              nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
              if (NS_FAILED(rv) || !pPref) 
                     return NS_ERROR_FAILURE;

              PRInt32  i;
              PRInt32  count = wholeList->Count();
              DIR_Server *server;

              for (i = 0; i < count; i++)
              {
                     server = (DIR_Server *) wholeList->ElementAt(i);
                     if (server)
                            DIR_SavePrefsForOneServer(server);
              }
              pPref->SetIntPref(PREF_LDAP_GLOBAL_TREE_NAME".user_id", dir_UserId);
       }

       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool DIR_SendNotification ( DIR_Server server,
PRUint32  flag,
DIR_PrefId  id 
)

Definition at line 1150 of file nsDirPrefs.cpp.

{
       PRBool sent = PR_FALSE;
       DIR_Callback *cb, *cbNext;

       for (cb = dir_CallbackList; cb; cb = cbNext)
       {
              cbNext = cb->next;

              if (cb->flags & flag)
              {
                     sent = PR_TRUE;
                     cb->fn(server, flag, id, cb->data);
              }
       }

       return sent;
}

Here is the caller graph for this function:

void DIR_SetAuthDN ( DIR_Server s,
const char *  dn 
)

Definition at line 4167 of file nsDirPrefs.cpp.

{
       char *tmp = nsnull;

       PR_ASSERT(dn && s);
       if (!dn || !s)
              return;
       if (s->authDn && !PL_strcmp(dn, s->authDn))
              return; /* no change - no need to broadcast */

    tmp = nsCRT::strdup (dn);
       if (tmp)
       {
              /* Always remember the authDn in the DIR_Server, so that users only
               * have to authenticate to the server once during a session. Whether
               * or not we push the authDN into the prefs is a separate issue, and 
               * is covered by the prefs read/write code
               */
              PR_FREEIF(s->authDn);
              s->authDn = tmp;
       }
       if (s->savePassword)
              DIR_SavePrefsForOneServer (s);
}

Here is the call graph for this function:

void DIR_SetAutoCompleteEnabled ( nsVoidArray list,
DIR_Server server,
PRBool  enabled 
)
void DIR_SetFlag ( DIR_Server server,
PRUint32  flag 
)

Definition at line 4332 of file nsDirPrefs.cpp.

{
       PR_ASSERT(server);
       if (server)
              server->flags |= flag;
}

Here is the caller graph for this function:

void DIR_SetPassword ( DIR_Server s,
const char *  password 
)

Definition at line 4193 of file nsDirPrefs.cpp.

{
       char *tmp = nsnull;

       PR_ASSERT(password && s);
       if (!password || !s)
              return; 
       if (s->password && !PL_strcmp(password, s->password))
              return; /* no change - no need to broadcast */

    tmp = nsCRT::strdup (password);
       if (tmp)
       {
              /* Always remember the password in the DIR_Server, so that users only
               * have to authenticate to the server once during a session. Whether
               * or not we push the password into the prefs is a separate issue, and 
               * is covered by the prefs read/write code
               */
              PR_FREEIF(s->password);
              s->password = tmp;
       }
       if (s->savePassword)
              DIR_SavePrefsForOneServer (s);
}

Here is the call graph for this function:

void DIR_SetServerFileName ( DIR_Server pServer,
const char *  leafName 
)

Definition at line 2637 of file nsDirPrefs.cpp.

{
       char * tempName = nsnull; 
       const char * prefName = nsnull;
       PRUint32 numHeaderBytes = 0; 

       if (server && (!server->fileName || !(*server->fileName)) )
       {
          PR_FREEIF(server->fileName); // might be one byte empty string.
              /* make sure we have a pref name...*/
              if (!server->prefName || !*server->prefName)
                     server->prefName = DIR_CreateServerPrefName (server, nsnull);

              /* set default personal address book file name*/
              if ((server->position == 1) && (server->dirType == PABDirectory))
            server->fileName = nsCRT::strdup(kPersonalAddressbook);
              else
              {
                     /* now use the pref name as the file name since we know the pref name
                        will be unique */
                     prefName = server->prefName;
                     if (prefName && *prefName)
                     {
                            /* extract just the pref name part and not the ldap tree name portion from the string */
                            numHeaderBytes = PL_strlen(PREF_LDAP_SERVER_TREE_NAME) + 1; /* + 1 for the '.' b4 the name */
                            if (PL_strlen(prefName) > numHeaderBytes) 
                    tempName = nsCRT::strdup(prefName + numHeaderBytes);

                            if (tempName)
                            {
                                   server->fileName = PR_smprintf("%s%s", tempName, kABFileName_CurrentSuffix);
                                   PR_Free(tempName);
                            }
                     }
              }

              if (!server->fileName || !*server->fileName) /* when all else has failed, generate a default name */
              {
                     if (server->dirType == LDAPDirectory)
                            DIR_SetFileName(&(server->fileName), kMainLdapAddressBook); /* generates file name with an ldap prefix */
                     else
                            DIR_SetFileName(&(server->fileName), kPersonalAddressbook);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool DIR_SetServerPosition ( nsVoidArray wholeList,
DIR_Server server,
PRInt32  position 
)

Definition at line 797 of file nsDirPrefs.cpp.

 {
   nsresult rv = NS_OK;
   nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
   if (NS_FAILED(rv) || !pPref) 
     return PR_FALSE;
   
   PRInt32    i, count, num;
   PRBool     resort = PR_FALSE;
   DIR_Server *s=nsnull;
   
   switch (position) {
   case DIR_POS_APPEND:
   /* Do nothing if the request is to append a server that is already
               * in the list.
     */
     count = wholeList->Count();
     for (i= 0; i < count; i++)
     {
       if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nsnull)
         if (s == server)
           return PR_FALSE;
     }
     /* In general, if there are any servers already in the list, set the
     * position to the position of the last server plus one.  If there
     * are none, set it to position 1.
     */
     if (count > 0)
     {
     /* Exception to the rule: if the last server is a locked server,
     * find the position of last unlocked server.  If there are no
     * unlocked servers, set the position to 1; otherwise, set it to
     * the position of the last unlocked server plus one.  In either
     * case the list must be resorted (to find the correct position).
       */
       s = (DIR_Server *)wholeList->ElementAt(count - 1);
       if (DIR_TestFlag(s, DIR_POSITION_LOCKED))
       {
         DIR_Server *sLast = nsnull;
         
         for (i= 0; i < count; i++)
         {
           if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nsnull)
             if (!DIR_TestFlag(s, DIR_POSITION_LOCKED))
               sLast = s;
         }
         
         if (sLast)
           server->position = sLast->position + 1;
         else
           server->position = 1;
         
         resort = PR_TRUE;
       }
       else
         server->position = s->position + 1;
     }
     else
       server->position = 1;
     
     wholeList->AppendElement(server);
     
     if (wholeList == dir_ServerList)
       DIR_SendNotification(server, DIR_NOTIFY_ADD, idNone);
     break;
     
   case DIR_POS_DELETE:
   /* Undeletable servers cannot be deleted.
     */
     if (DIR_TestFlag(server, DIR_UNDELETABLE))
       return PR_FALSE;
     
       /* Remove the prefs corresponding to the given server.  If the prefName
       * value is nsnull, the server has never been saved and there are no
       * prefs to remove.
     */
     if (server->prefName)
     {
       char tempstring[256];
       
       DIR_ClearPrefBranch(server->prefName);
       // mark the server as deleted by setting its position to 0
       DIR_SetIntPref (server->prefName, "position", tempstring, 0, -1);
     }
     
     /* If the server is in the server list, remove it.
     */
     num = wholeList->IndexOf(server);
     if (num >= 0)
     {
     /* The list does not need to be re-sorted if the server is the
     * last one in the list.
       */
       count = wholeList->Count();
       if (num == count - 1)
       {
         wholeList->RemoveElementAt(num);
       }
       else
       {
         resort = PR_TRUE;
         wholeList->RemoveElement(server);
       }
       
       if (wholeList == dir_ServerList)
         DIR_SendNotification(server, DIR_NOTIFY_DELETE, idNone);
     }
     break;
     
   default:
   /* See if the server is already in the list.
     */
     count = wholeList->Count();
     for (i= 0; i < count; i++)
     {
       if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nsnull)
         if (s == server)
           break;
     }
     
     /* If the server is not in the list, add it to the beginning and re-sort.
     */
     if (s == nsnull)
     {
       server->position = position;
       wholeList->AppendElement(server);
       resort = PR_TRUE;
       
       if (wholeList == dir_ServerList)
         DIR_SendNotification(server, DIR_NOTIFY_ADD, idNone);
     }
     
     /* Servers with locked position values cannot be moved.
     */
     else if (DIR_TestFlag(server, DIR_POSITION_LOCKED))
       return PR_FALSE;
     
       /* Don't re-sort if the server is already in the requested position.
     */
     else if (server->position != position)
     {
       server->position = position;
       wholeList->RemoveElement(server);
       wholeList->AppendElement(server);
       resort = PR_TRUE;
     }
     break;
        }
        
        /* Make sure our position changes get saved back to prefs
        */
        DIR_SaveServerPreferences(wholeList);
        
        return resort;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool DIR_SetServerStringPref ( DIR_Server server,
DIR_PrefId  prefid,
char *  pref,
PRInt16  csid 
)

Definition at line 1199 of file nsDirPrefs.cpp.

{
       PRBool rc = PR_TRUE;

       if (!server || !pref)
              return PR_FALSE;

       pref = DIR_ConvertToServerCharSet(server, pref, csid);

       switch (prefid) {
       case idAuthDn:
              PR_FREEIF(server->authDn);
              server->authDn = pref;
              break;
       case idPassword:
              PR_FREEIF(server->password);
              server->password = pref;
              break;
       case idSearchBase:
              PR_FREEIF(server->searchBase);
              server->searchBase = pref;
              break;
       default:
              PR_ASSERT(0);
              rc = PR_FALSE;
              break;
       }

       return PR_FALSE;
}

Here is the call graph for this function:

Definition at line 295 of file nsDirPrefs.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv)); 
  if (NS_FAILED(rv) || !pPref) 
    return NS_ERROR_FAILURE;
  pPref->SavePrefFile(nsnull);
  
  if (dir_ServerList)
  {
    PRInt32 count = dir_ServerList->Count();
    PRInt32 i;
    for (i = 0; i < count; i++)
    {
      DIR_DeleteServer((DIR_Server *)(dir_ServerList->ElementAt(i)));
    }
    delete dir_ServerList;
    dir_ServerList = nsnull;
  }
  
  /* unregister the preference call back, if necessary.
  * we need to do this as DIR_Shutdown() is called when switching profiles
  * when using turbo.  (see nsAbDirectoryDataSource::Observe())
  * When switching profiles, prefs get unloaded and then re-loaded
  * we don't want our callback to get called for all that.
  * We'll reset our callback the first time DIR_GetDirServers() is called
  * after we've switched profiles.
  */
  if (dir_ServerPrefCallbackRegistered) {
    pPref->UnregisterCallback(PREF_LDAP_SERVER_TREE_NAME, dir_ServerPrefCallback, nsnull);
    dir_ServerPrefCallbackRegistered = PR_FALSE;
  }
  
  return NS_OK;
}

Here is the call graph for this function:

PRBool DIR_SubstStarsForSpaces ( DIR_Server server,
const char *  filter 
)

Definition at line 4041 of file nsDirPrefs.cpp.

{
       const DIR_Filter *filterStruct = DIR_LookupFilter (server, filter);
       if (filterStruct)
              return (filterStruct->flags & DIR_F_SUBST_STARS_FOR_SPACES) != 0;

       return kDefaultSubstStarsForSpaces;
}

Here is the call graph for this function:

PRBool DIR_TestFlag ( DIR_Server server,
PRUint32  flag 
)

Definition at line 4325 of file nsDirPrefs.cpp.

{
       if (server)
              return NS_OK != (server->flags & flag);
       return PR_FALSE;
}

Here is the caller graph for this function:

char* DIR_Unescape ( const char *  src,
PRBool  makeHtml 
)

Definition at line 4244 of file nsDirPrefs.cpp.

{
/* Borrowed from libnet\mkparse.c */
#define UNHEX(C) \
       ((C >= '0' && C <= '9') ? C - '0' : \
       ((C >= 'A' && C <= 'F') ? C - 'A' + 10 : \
       ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : 0)))

       char *dest = nsnull;
       PRUint32 destLength = 0;

       PRUint32 dollarCount = 0;
       PRUint32 convertedLengthOfDollar = makeHtml ? 4 : 1;

       const char *tmpSrc = src;

       while (*tmpSrc)
              if (*tmpSrc++ == '$')
                     dollarCount++;

       destLength = PL_strlen(src) + (dollarCount * convertedLengthOfDollar);
       dest = (char*) PR_Malloc (destLength + 1);
       if (dest)
       {
              char *tmpDst = dest;
              *dest = '\0';
              tmpSrc = src;

              while (*tmpSrc)
              {
                     switch (*tmpSrc)
                     {
                     case '$':
                            /* A dollar sign is a linebreak. This is easy for HTML, but if we're converting
                             * for the Address Book or something without multiple lines, just put in a space
                             */
                            if (makeHtml)
                            {
                                   *tmpDst++ = '<';
                                   *tmpDst++ = 'B';
                                   *tmpDst++ = 'R';
                                   *tmpDst++ = '>';
                            }
                            else
                                   *tmpDst++ = ' ';
                            break;
                     case '\\': {
                            /* A backslash indicates that two hex digits follow, which we're supposed to
                             * convert. The spec sez that '$', '#' and '\'' (single quote) must be encoded
                             * this way. 
                             */
                            PRBool didEscape = PR_FALSE;
                            char c1 = *(tmpSrc + 1);
                            if (c1 && (nsCRT::IsAsciiDigit(c1) || nsCRT::IsAsciiAlpha(c1)))
                            {
                                   char c2 = *(tmpSrc + 2);
                                   if (c2 && (nsCRT::IsAsciiDigit(c2) || nsCRT::IsAsciiAlpha(c2)))
                                   {
                                          *tmpDst++ = (UNHEX(c1) << 4) | UNHEX(c2);
                                          tmpSrc +=2;
                                          didEscape = PR_TRUE;
                                   }
                            }
                            if (!didEscape)
                                   *tmpDst++ = *tmpSrc;
                     }
                     break;
                     default:
                            /* Just a plain old char -- copy it over */
                            *tmpDst++ = *tmpSrc;
                     }
                     tmpSrc++;
              }
              *tmpDst = '\0';
       }

       return dest;
}

Definition at line 4056 of file nsDirPrefs.cpp.

{
       nsVoidArray *list = server->customAttributes;
       DIR_Attribute *walkList = nsnull;

       PRInt32  count = list->Count();
       PRInt32  i;
       for (i = 0; i < count; i++)
       {
              if ((walkList = (DIR_Attribute *)list->ElementAt(i)) != nsnull)
                     if (walkList->id == id)
                            return PR_TRUE;
       }
       return PR_FALSE;
}

Here is the call graph for this function:

Definition at line 493 of file nsDirPrefs.cpp.

{
  /* right now the only invalid description is a duplicate...so check for duplicates */
  if (wholeList && serverToValidate && serverToValidate->description)
  {
    PRInt32 numItems = wholeList->Count();
    PRInt32 i;
    for (i = 0; i < numItems; i++)
    {
      DIR_Server *s = (DIR_Server *)(dir_ServerList->ElementAt(i));
      /* don't check the description if it is the same directory as the one we are comparing against */
      if (s != serverToValidate && s->description && !nsCRT::strcasecmp(s->description, serverToValidate->description))
        return DIR_DuplicateDescription;
    }
    
  }
  
  return DIR_ValidDescription;
}

Here is the call graph for this function: