Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
nsAbBSDirectory Class Reference

#include <nsAbBSDirectory.h>

Inheritance diagram for nsAbBSDirectory:
Inheritance graph
[legend]
Collaboration diagram for nsAbBSDirectory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED nsAbBSDirectory ()
virtual ~nsAbBSDirectory ()
NS_IMETHOD GetChildNodes (nsISimpleEnumerator **result)
NS_IMETHOD CreateNewDirectory (nsIAbDirectoryProperties *aProperties)
NS_IMETHOD CreateDirectoryByURI (const PRUnichar *dirName, const char *uri, PRBool migrating)
NS_IMETHOD ModifyDirectory (nsIAbDirectory *directory, nsIAbDirectoryProperties *aProperties)
NS_IMETHOD DeleteDirectory (nsIAbDirectory *directory)
NS_IMETHOD HasDirectory (nsIAbDirectory *dir, PRBool *hasDir)
NS_DECL_ISUPPORTS NS_IMETHOD EqualsNode (nsIRDFNode *aNode, PRBool *aResult)
boolean EqualsNode (in nsIRDFNode aNode)
NS_IMETHOD Init (const char *aURI)
void Init (in string uri)
 This method is called by the nsIRDFService after constructing a resource object to initialize it's URI.
NS_IMETHOD GetValue (char **aURI)
NS_IMETHOD GetValueUTF8 (nsACString &aResult)
NS_IMETHOD GetValueConst (const char **aURI)
void GetValueConst ([shared] out string aConstValue)
 An unscriptable version used to avoid a string copy.
NS_IMETHOD EqualsString (const char *aURI, PRBool *aResult)
boolean EqualsString (in string aURI)
 Determine if the resource has the given URI.
NS_IMETHOD GetDelegate (const char *aKey, REFNSIID aIID, void **aResult)
void GetDelegate (in string aKey, in nsIIDRef aIID,[iid_is(aIID), retval] out nsQIResult aResult)
 Retrieve the "delegate" object for this resource.
NS_IMETHOD ReleaseDelegate (const char *aKey)
void ReleaseDelegate (in string aKey)
 Force a delegate to be "unbound" from the resource.
void modifyDirectory (in nsIAbDirectory directory, in nsIAbDirectoryProperties aProperties)
void deleteDirectory (in nsIAbDirectory dierctory)
void deleteCards (in nsISupportsArray cards)
boolean hasCard (in nsIAbCard cards)
boolean hasDirectory (in nsIAbDirectory dir)
nsIAbCard addCard (in nsIAbCard card)
 return value is the card that got added we need to do this, as the card we pass in might be an abstract nsIAbCard, and the caller might need the "real" card (the mdbcard) to get / set non-standard card values
void dropCard (in nsIAbCard card, in boolean needToCopyCard)
void addMailList (in nsIAbDirectory list)
void addMailListWithKey (in nsIAbDirectory list, out PRUint32 key)
void editMailListToDatabase (in string uri, in nsIAbCard listCard)
 Edits an existing mailing list (specified as listCard) into the directory specified by the uri XXX javadoc me.
void copyMailList (in nsIAbDirectory srcList)
void createNewDirectory (in nsIAbDirectoryProperties aProperties)
void createDirectoryByURI (in wstring displayName, in string uri, in boolean migrating)
wstring getValueForCard (in nsIAbCard card, in string name)
void setValueForCard (in nsIAbCard card, in string name, in wstring value)

Public Attributes

readonly attribute string Value
 The single-byte string value of the resource.
readonly attribute AUTF8String ValueUTF8
 The UTF-8 URI of the resource.
const long opRead = 0x1
const long opWrite = 0x2
const long opSearch = 0x4
readonly attribute long operations
attribute wstring dirName
attribute unsigned long lastModifiedDate
attribute PRBool isMailList
readonly attribute
nsIAbDirectoryProperties 
directoryProperties
readonly attribute
nsISimpleEnumerator 
childNodes
readonly attribute nsIEnumerator childCards
readonly attribute boolean isRemote
 directory is local (example, mork based) or remote (example, LDAP)
readonly attribute boolean isSecure
 directory is secure (as in LDAP over SSL)
readonly attribute boolean searchDuringLocalAutocomplete
 directory should be searched when doing local autocomplete
readonly attribute boolean supportsMailingLists
attribute nsISupportsArray addressLists
attribute wstring listNickName
attribute wstring description
attribute ACString dirPrefId

Protected Member Functions

nsresult CreateDirectoriesFromFactory (nsIAbDirectoryProperties *aProperties, DIR_Server *aServer, PRBool aNotify)
nsresult GetAttributeName (PRUnichar **aName, nsString &value)
nsresult SetAttributeName (const PRUnichar *aName, nsString &arrtibute)

Protected Attributes

PRBool mInitialized
nsCOMArray< nsIAbDirectorymSubDirectories
nsHashtable mServers
nsCString mURI
DelegateEntrymDelegates
nsString m_DirName
PRUint32 m_LastModifiedDate
nsString m_ListName
nsString m_ListNickName
nsString m_Description
PRBool m_IsMailList
nsCString m_DirPrefId
nsCOMPtr< nsISupportsArraym_AddressList

Static Protected Attributes

static nsIRDFServicegRDFService = nsnull
static nsrefcnt gRDFServiceRefCnt = 0

Detailed Description

Definition at line 48 of file nsAbBSDirectory.h.


Constructor & Destructor Documentation

Definition at line 60 of file nsAbBSDirectory.cpp.

Definition at line 67 of file nsAbBSDirectory.cpp.

{
}

Member Function Documentation

return value is the card that got added we need to do this, as the card we pass in might be an abstract nsIAbCard, and the caller might need the "real" card (the mdbcard) to get / set non-standard card values

nsresult nsAbBSDirectory::CreateDirectoriesFromFactory ( nsIAbDirectoryProperties aProperties,
DIR_Server aServer,
PRBool  aNotify 
) [protected]

Definition at line 73 of file nsAbBSDirectory.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG_POINTER(aProperties);
  
  // Get the directory factory service
  nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = 
    do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv);
  NS_ENSURE_SUCCESS (rv, rv);
              
  // Get the directory factory from the URI
  nsXPIDLCString uri;
  rv = aProperties->GetURI(getter_Copies(uri));
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCOMPtr<nsIAbDirFactory> dirFactory;
  rv = dirFactoryService->GetDirFactory(uri.get(), getter_AddRefs(dirFactory));
  NS_ENSURE_SUCCESS (rv, rv);
  
  // Create the directories
  nsCOMPtr<nsISimpleEnumerator> newDirEnumerator;
  rv = dirFactory->CreateDirectory(aProperties, getter_AddRefs(newDirEnumerator));
  NS_ENSURE_SUCCESS (rv, rv);
  
  // Enumerate through the directories adding them
  // to the sub directories array
  PRBool hasMore;
  nsCOMPtr<nsIAddrBookSession> abSession = 
    do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv); 

  while (NS_SUCCEEDED(newDirEnumerator->HasMoreElements(&hasMore)) && hasMore)
  {
    nsCOMPtr<nsISupports> newDirSupports;
    rv = newDirEnumerator->GetNext(getter_AddRefs(newDirSupports));
    if(NS_FAILED(rv))
      continue;
    
    nsCOMPtr<nsIAbDirectory> childDir = do_QueryInterface(newDirSupports, &rv); 
    if(NS_FAILED(rv))
      continue;
    
    // Define a relationship between the preference
    // entry and the directory
    nsVoidKey key((void *)childDir);
    mServers.Put (&key, (void *)aServer);
    
    mSubDirectories.AppendObject(childDir);
    
    // Inform the listener, i.e. the RDF directory data
    // source that a new address book has been added
    if (aNotify && abSession)
      abSession->NotifyDirectoryItemAdded(this, childDir);
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsAbBSDirectory::CreateDirectoryByURI ( const PRUnichar dirName,
const char *  uri,
PRBool  migrating 
)

Definition at line 279 of file nsAbBSDirectory.cpp.

{
  NS_ENSURE_ARG_POINTER(aURI);
  NS_ENSURE_ARG_POINTER(aDisplayName);

  nsresult rv = NS_OK;

  const char* fileName = nsnull;
  if (StringBeginsWith(nsDependentCString(aURI), NS_LITERAL_CSTRING(kMDBDirectoryRoot)))
    fileName = aURI + kMDBDirectoryRootLen;

  DIR_Server * server = nsnull;
  rv = DIR_AddNewAddressBook(aDisplayName, fileName, migrating, aURI, 0, nsnull, PABDirectory, &server);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr <nsIAbDirectoryProperties> properties;
  properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  rv = properties->SetDescription(nsDependentString(aDisplayName));
  NS_ENSURE_SUCCESS(rv,rv);
       
  rv = properties->SetFileName(server->fileName);
  NS_ENSURE_SUCCESS(rv,rv);

  rv = properties->SetURI(aURI);
  NS_ENSURE_SUCCESS(rv,rv);

  rv = properties->SetPrefName(server->prefName);
  NS_ENSURE_SUCCESS(rv,rv);

  rv = properties->SetDirType(server->dirType);
  NS_ENSURE_SUCCESS(rv,rv);

  rv = CreateDirectoriesFromFactory(properties, server, PR_TRUE /* notify */);
  NS_ENSURE_SUCCESS(rv,rv);
       return rv;
}

Here is the call graph for this function:

void nsIAbDirectory::createDirectoryByURI ( in wstring  displayName,
in string  uri,
in boolean  migrating 
) [inherited]

Definition at line 205 of file nsAbBSDirectory.cpp.

{
/*
* TODO
* This procedure is still MDB specific
* due to the dependence on the current
* nsDirPref.cpp code
*
        */
  NS_ENSURE_ARG_POINTER(aProperties);
  nsresult rv;
  
  nsAutoString description;
  nsXPIDLCString fileName;
  nsXPIDLCString uri;
  nsXPIDLCString authDn;
  
  rv = aProperties->GetDescription(description);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = aProperties->GetFileName(getter_Copies(fileName));
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = aProperties->GetURI(getter_Copies(uri));
  NS_ENSURE_SUCCESS(rv, rv);
  
  PRUint32 dirType;
  rv = aProperties->GetDirType(&dirType);
  NS_ENSURE_SUCCESS(rv, rv);
  
  PRUint32 maxHits;
  rv = aProperties->GetMaxHits(&maxHits);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = aProperties->GetAuthDn(getter_Copies(authDn));
  NS_ENSURE_SUCCESS(rv, rv);
  
  /*
   * The creation of the address book in the preferences
   * is very MDB implementation specific.
   * If the fileName attribute is null then it will
   * create an appropriate file name.
   * Somehow have to resolve this issue so that it
   * is more general.
   *
   */
  DIR_Server* server = nsnull;
  rv = DIR_AddNewAddressBook(description.get(),
    (fileName.Length ()) ? fileName.get () : nsnull,
    PR_FALSE /* is_migrating */, uri.get(),
    maxHits, authDn,
    (DirectoryType)dirType, 
    &server);
  NS_ENSURE_SUCCESS (rv, rv);
  
  // Update the file name property
  rv = aProperties->SetFileName(server->fileName);
  NS_ENSURE_SUCCESS(rv, rv);
  
  if (dirType != LDAPDirectory) {
    // Add the URI property
    nsCAutoString URI(NS_LITERAL_CSTRING(kMDBDirectoryRoot) + nsDependentCString(server->fileName));
    rv = aProperties->SetURI(URI.get());
    NS_ENSURE_SUCCESS(rv, rv);
  }
  
  rv = aProperties->SetPrefName(server->prefName);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = CreateDirectoriesFromFactory(aProperties, server, PR_TRUE /* notify */);
  NS_ENSURE_SUCCESS(rv,rv);
  return rv;
}

Here is the call graph for this function:

Definition at line 345 of file nsAbBSDirectory.cpp.

{
       nsresult rv;
       
       NS_ENSURE_ARG_POINTER(directory);

       // if addressbook is not launched yet mSevers will not be initialized
       // calling GetChildNodes will initialize mServers
       if (!mInitialized) {
              nsCOMPtr<nsISimpleEnumerator> subDirectories;
              rv = GetChildNodes(getter_AddRefs(subDirectories));
              NS_ENSURE_SUCCESS(rv, rv);
       }

       nsVoidKey key((void *)directory);
       DIR_Server *server = (DIR_Server* )mServers.Get (&key);

       if (!server)
              return NS_ERROR_FAILURE;

       GetDirectories getDirectories (server);
       mServers.Enumerate (GetDirectories_getDirectory, (void *)&getDirectories);

       DIR_DeleteServerFromList(server);
       
       nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = 
                     do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv);
       NS_ENSURE_SUCCESS (rv, rv);

       PRUint32 count;
       rv = getDirectories.directories->Count (&count);
       NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIAddrBookSession> abSession =
    do_GetService(NS_ADDRBOOKSESSION_CONTRACTID);
  
       for (PRUint32 i = 0; i < count; i++)
       {
              nsCOMPtr<nsIAbDirectory> d;
              getDirectories.directories->GetElementAt (i, getter_AddRefs(d));

              nsVoidKey k((void *)d);
              mServers.Remove(&k);

              rv = mSubDirectories.RemoveObject(d);

    if (abSession)
      abSession->NotifyDirectoryDeleted(this, d);

              nsCOMPtr<nsIRDFResource> resource (do_QueryInterface (d, &rv));
              const char* uri;
              resource->GetValueConst (&uri);

              nsCOMPtr<nsIAbDirFactory> dirFactory;
              rv = dirFactoryService->GetDirFactory (uri, getter_AddRefs(dirFactory));
              if (NS_FAILED(rv))
                            continue;

              rv = dirFactory->DeleteDirectory(d);
       }

       return rv;
}

Here is the call graph for this function:

void nsIAbDirectory::dropCard ( in nsIAbCard  card,
in boolean  needToCopyCard 
) [inherited]
void nsIAbDirectory::editMailListToDatabase ( in string  uri,
in nsIAbCard  listCard 
) [inherited]

Edits an existing mailing list (specified as listCard) into the directory specified by the uri XXX javadoc me.

boolean nsIRDFNode::EqualsNode ( in nsIRDFNode  aNode) [inherited]
NS_IMETHODIMP nsRDFResource::EqualsNode ( nsIRDFNode aNode,
PRBool aResult 
) [inherited]

Definition at line 84 of file nsRDFResource.cpp.

{
    NS_PRECONDITION(aNode != nsnull, "null ptr");
    if (! aNode)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;
    nsIRDFResource* resource;
    rv = aNode->QueryInterface(NS_GET_IID(nsIRDFResource), (void**)&resource);
    if (NS_SUCCEEDED(rv)) {
        *aResult = (NS_STATIC_CAST(nsIRDFResource*, this) == resource);
        NS_RELEASE(resource);
        return NS_OK;
    }
    else if (rv == NS_NOINTERFACE) {
        *aResult = PR_FALSE;
        return NS_OK;
    }
    else {
        return rv;
    }
}
NS_IMETHODIMP nsRDFResource::EqualsString ( const char *  aURI,
PRBool aResult 
) [inherited]

Definition at line 156 of file nsRDFResource.cpp.

{
    NS_PRECONDITION(aURI != nsnull, "null ptr");
    if (! aURI)
        return NS_ERROR_NULL_POINTER;

    NS_PRECONDITION(aResult, "null ptr");

    *aResult = mURI.Equals(aURI);
    return NS_OK;
}

Determine if the resource has the given URI.

nsresult nsAbDirProperty::GetAttributeName ( PRUnichar **  aName,
nsString value 
) [protected, inherited]

Definition at line 135 of file nsAbDirProperty.cpp.

{
       if (aName)
       {
              *aName = ToNewUnicode(value);
              if (!(*aName)) 
                     return NS_ERROR_OUT_OF_MEMORY;
              else
                     return NS_OK;
       }
       else
              return NS_ERROR_NULL_POINTER;

}

Here is the call graph for this function:

Definition at line 133 of file nsAbBSDirectory.cpp.

{
  if (!mInitialized) 
  {
    nsresult rv;
    nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = 
      do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv);
    NS_ENSURE_SUCCESS (rv, rv);
    
    nsVoidArray *directories = DIR_GetDirectories();
    if (!directories)
      return NS_ERROR_FAILURE;
    
    PRInt32 count = directories->Count();
    for (PRInt32 i = 0; i < count; i++)
    {
      DIR_Server *server = (DIR_Server *)(directories->ElementAt(i));
      
      // if this is a 4.x, local .na2 addressbook (PABDirectory)
      // we must skip it.
      // mozilla can't handle 4.x .na2 addressbooks
      // note, the filename might be na2 for 4.x LDAP directories
      // (we used the .na2 file for replication), and we don't want to skip
      // those.  see bug #127007
      PRUint32 fileNameLen = strlen(server->fileName);
      if (((fileNameLen > kABFileName_PreviousSuffixLen) && 
        strcmp(server->fileName + fileNameLen - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) &&
        (server->dirType == PABDirectory))
        continue;
      
      nsCOMPtr<nsIAbDirectoryProperties> properties(do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv));
      NS_ENSURE_SUCCESS(rv,rv);
      
      NS_ConvertUTF8toUCS2 description (server->description);
      rv = properties->SetDescription(description);
      NS_ENSURE_SUCCESS(rv,rv);
      
      rv = properties->SetFileName(server->fileName);
      NS_ENSURE_SUCCESS(rv,rv);
      
      // Set the uri property
      nsCAutoString URI (server->uri);
      // This is in case the uri is never set
      // in the nsDirPref.cpp code.
      if (!server->uri)
        URI = NS_LITERAL_CSTRING(kMDBDirectoryRoot) + nsDependentCString(server->fileName);
      
      /*
      * Check that we are not converting from a
      * a 4.x address book file e.g. pab.na2
      * check if the URI ends with ".na2"
      */
      if (StringEndsWith(URI, NS_LITERAL_CSTRING(kABFileName_PreviousSuffix))) 
        URI.ReplaceSubstring(URI.get() + kMDBDirectoryRootLen, server->fileName);
      
      rv = properties->SetPrefName(server->prefName);
      NS_ENSURE_SUCCESS(rv,rv);
      
      rv = properties->SetURI(URI.get());
      NS_ENSURE_SUCCESS(rv,rv);
      
      // Create the directories
      rv = CreateDirectoriesFromFactory(properties,
        server, PR_FALSE /* notify */);
    }
    
    mInitialized = PR_TRUE;
    // sort directories by position...
  }
  return NS_NewArrayEnumerator(aResult, mSubDirectories);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRDFResource::GetDelegate ( const char *  aKey,
REFNSIID  aIID,
void **  aResult 
) [inherited]

Definition at line 169 of file nsRDFResource.cpp.

{
    NS_PRECONDITION(aKey != nsnull, "null ptr");
    if (! aKey)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;
    *aResult = nsnull;

    DelegateEntry* entry = mDelegates;
    while (entry) {
        if (entry->mKey.Equals(aKey)) {
            rv = entry->mDelegate->QueryInterface(aIID, aResult);
            return rv;
        }

        entry = entry->mNext;
    }

    // Construct a ContractID of the form "@mozilla.org/rdf/delegate/[key]/[scheme];1
    nsCAutoString contractID(NS_RDF_DELEGATEFACTORY_CONTRACTID_PREFIX);
    contractID.Append(aKey);
    contractID.Append("&scheme=");

    PRInt32 i = mURI.FindChar(':');
    contractID += StringHead(mURI, i);

    nsCOMPtr<nsIRDFDelegateFactory> delegateFactory =
             do_CreateInstance(contractID.get(), &rv);
    if (NS_FAILED(rv)) return rv;

    rv = delegateFactory->CreateDelegate(this, aKey, aIID, aResult);
    if (NS_FAILED(rv)) return rv;

    // Okay, we've successfully created a delegate. Let's remember it.
    entry = new DelegateEntry;
    if (! entry) {
        NS_RELEASE(*NS_REINTERPRET_CAST(nsISupports**, aResult));
        return NS_ERROR_OUT_OF_MEMORY;
    }
    
    entry->mKey      = aKey;
    entry->mDelegate = do_QueryInterface(*NS_REINTERPRET_CAST(nsISupports**, aResult), &rv);
    if (NS_FAILED(rv)) {
        NS_ERROR("nsRDFResource::GetDelegate(): can't QI to nsISupports!");

        delete entry;
        NS_RELEASE(*NS_REINTERPRET_CAST(nsISupports**, aResult));
        return NS_ERROR_FAILURE;
    }

    entry->mNext     = mDelegates;

    mDelegates = entry;

    return NS_OK;
}

Here is the call graph for this function:

void nsIRDFResource::GetDelegate ( in string  aKey,
in nsIIDRef  aIID,
[iid_is(aIID), retval] out nsQIResult  aResult 
) [inherited]

Retrieve the "delegate" object for this resource.

A resource may have several delegate objects, each of whose lifetimes is bound to the life of the resource object.

This method will return the delegate for the given key after QueryInterface()-ing it to the requested IID.

If no delegate exists for the specified key, this method will attempt to create one using the component manager. Specifically, it will combine aKey with the resource's URI scheme to produce a ContractID as follows:

component:/rdf/delegate-factory/[key]/[scheme]

This ContractID will be used to locate a factory using the FindFactory() method of nsIComponentManager. If the nsIFactory exists, it will be used to create a "delegate factory"; that is, an object that supports nsIRDFDelegateFactory. The delegate factory will be used to construct the delegate object.

Here is the caller graph for this function:

NS_IMETHODIMP nsRDFResource::GetValue ( char **  aURI) [inherited]

Definition at line 129 of file nsRDFResource.cpp.

{
    NS_ASSERTION(aURI, "Null out param.");
    
    *aURI = ToNewCString(mURI);

    if (!*aURI)
        return NS_ERROR_OUT_OF_MEMORY;

    return NS_OK;
}

Here is the call graph for this function:

void nsIRDFResource::GetValueConst ( [shared] out string  aConstValue) [inherited]

An unscriptable version used to avoid a string copy.

Meant for use as a performance optimization. The string is encoded in UTF-8.

NS_IMETHODIMP nsRDFResource::GetValueConst ( const char **  aURI) [inherited]

Definition at line 149 of file nsRDFResource.cpp.

{
    *aURI = mURI.get();
    return NS_OK;
}

Here is the call graph for this function:

wstring nsIAbDirectory::getValueForCard ( in nsIAbCard  card,
in string  name 
) [inherited]
NS_IMETHODIMP nsRDFResource::GetValueUTF8 ( nsACString &  aResult) [inherited]

Definition at line 142 of file nsRDFResource.cpp.

{
    aResult = mURI;
    return NS_OK;
}
boolean nsIAbDirectory::hasCard ( in nsIAbCard  cards) [inherited]

Here is the caller graph for this function:

Definition at line 492 of file nsAbBSDirectory.cpp.

{
  if (!hasDir)
    return NS_ERROR_NULL_POINTER;
  
  nsVoidKey key((void *)dir);
  DIR_Server *dirServer = (DIR_Server* )mServers.Get (&key);
  return DIR_ContainsServer(dirServer, hasDir);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRDFResource::Init ( const char *  aURI) [inherited]

Reimplemented in nsAbOSXDirectory, NS_MSG_BASE, nsAbMDBDirectory, nsAbOutlookDirectory, nsAbOSXCard, nsAbLDAPDirectory, nsAbOutlookCard, and nsAbDirectoryRDFResource.

Definition at line 111 of file nsRDFResource.cpp.

{
    NS_PRECONDITION(aURI != nsnull, "null ptr");
    if (! aURI)
        return NS_ERROR_NULL_POINTER;

    mURI = aURI;

    if (gRDFServiceRefCnt++ == 0) {
        nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
        if (NS_FAILED(rv)) return rv;
    }

    // don't replace an existing resource with the same URI automatically
    return gRDFService->RegisterResource(this, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFResource::Init ( in string  uri) [inherited]

This method is called by the nsIRDFService after constructing a resource object to initialize it's URI.

You would not normally call this method directly

Definition at line 409 of file nsAbBSDirectory.cpp.

{
  nsresult rv;

  NS_ENSURE_ARG_POINTER(directory);
  NS_ENSURE_ARG_POINTER(aProperties);

  // if addressbook is not launched yet mSevers will not be initialized
  // calling GetChildNodes will initialize mServers
  if (!mInitialized) {
    nsCOMPtr<nsISimpleEnumerator> subDirectories;
    rv = GetChildNodes(getter_AddRefs(subDirectories));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  nsVoidKey key((void *)directory);
  DIR_Server *server = (DIR_Server* )mServers.Get(&key);

  if (!server)
    return NS_ERROR_FAILURE;
  GetDirectories getDirectories (server);
  mServers.Enumerate (GetDirectories_getDirectory, (void *)&getDirectories);

  nsAutoString description;
  nsXPIDLCString uri;
  nsXPIDLCString authDn;
  PRUint32 maxHits, palmSyncTimeStamp;
  PRInt32 palmCategoryId;

  rv = aProperties->GetDescription(description);
  NS_ENSURE_SUCCESS(rv, rv);
 
  NS_ConvertUTF8toUCS2 oldValue(server->description);
  nsCRT::free(server->description);
  NS_ConvertUCS2toUTF8 utf8str(description.get());
  server->description = ToNewCString(utf8str);

  rv = aProperties->GetURI(getter_Copies(uri));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCRT::free(server->uri);
  server->uri = ToNewCString(uri);

  rv = aProperties->GetMaxHits(&maxHits);
  NS_ENSURE_SUCCESS(rv, rv);
  server->maxHits = maxHits;
  
  rv = aProperties->GetAuthDn(getter_Copies(authDn));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCRT::free(server->authDn);
  server->authDn = ToNewCString(authDn);

  rv = aProperties->GetSyncTimeStamp(&palmSyncTimeStamp);
  NS_ENSURE_SUCCESS(rv, rv);
  server->PalmSyncTimeStamp = palmSyncTimeStamp;

  rv = aProperties->GetCategoryId(&palmCategoryId);
  NS_ENSURE_SUCCESS(rv, rv);
  server->PalmCategoryId = palmCategoryId;
  
  DIR_SavePrefsForOneServer(server);

  if (!oldValue.Equals(description)) {
    nsCOMPtr<nsIAbDirectory> modifiedDir;
    getDirectories.directories->GetElementAt (0, getter_AddRefs(modifiedDir));

    // First tell the directory it's new name
    rv = modifiedDir->SetDirName(description.get());
    NS_ENSURE_SUCCESS(rv, rv);

    // Then tell everyone else.
    nsCOMPtr<nsIAddrBookSession> abSession = 
              do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);

    if (NS_SUCCEEDED(rv))
      abSession->NotifyItemPropertyChanged(modifiedDir, "DirName", oldValue.get(), description.get());
  }

  // Save modified address book into pref file.
  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); 
  NS_ENSURE_SUCCESS(rv, rv);
  return prefService->SavePrefFile(nsnull);
}

Here is the call graph for this function:

void nsIAbDirectory::modifyDirectory ( in nsIAbDirectory  directory,
in nsIAbDirectoryProperties  aProperties 
) [inherited]
NS_IMETHODIMP nsRDFResource::ReleaseDelegate ( const char *  aKey) [inherited]

Definition at line 228 of file nsRDFResource.cpp.

{
    NS_PRECONDITION(aKey != nsnull, "null ptr");
    if (! aKey)
        return NS_ERROR_NULL_POINTER;

    DelegateEntry* entry = mDelegates;
    DelegateEntry** link = &mDelegates;

    while (entry) {
        if (entry->mKey.Equals(aKey)) {
            *link = entry->mNext;
            delete entry;
            return NS_OK;
        }

        link = &(entry->mNext);
        entry = entry->mNext;
    }

    NS_WARNING("nsRDFResource::ReleaseDelegate() no delegate found");
    return NS_OK;
}

Force a delegate to be "unbound" from the resource.

Normally, a delegate object's lifetime will be identical to that of the resource to which it is bound; this method allows a delegate to unlink itself from an RDF resource prematurely.

nsresult nsAbDirProperty::SetAttributeName ( const PRUnichar aName,
nsString arrtibute 
) [protected, inherited]

Definition at line 150 of file nsAbDirProperty.cpp.

{
       if (aName)
              arrtibute = aName;
       return NS_OK;
}
void nsIAbDirectory::setValueForCard ( in nsIAbCard  card,
in string  name,
in wstring  value 
) [inherited]

Member Data Documentation

Definition at line 163 of file nsIAbDirectory.idl.

Definition at line 103 of file nsIAbDirectory.idl.

Definition at line 98 of file nsIAbDirectory.idl.

Definition at line 177 of file nsIAbDirectory.idl.

Definition at line 95 of file nsIAbDirectory.idl.

attribute wstring nsIAbDirectory::dirName [inherited]

Definition at line 85 of file nsIAbDirectory.idl.

attribute ACString nsIAbDirectory::dirPrefId [inherited]

Definition at line 208 of file nsIAbDirectory.idl.

nsIRDFService * nsRDFResource::gRDFService = nsnull [static, protected, inherited]

Definition at line 75 of file nsRDFResource.h.

nsrefcnt nsRDFResource::gRDFServiceRefCnt = 0 [static, protected, inherited]

Definition at line 76 of file nsRDFResource.h.

Definition at line 92 of file nsIAbDirectory.idl.

directory is local (example, mork based) or remote (example, LDAP)

Definition at line 142 of file nsIAbDirectory.idl.

directory is secure (as in LDAP over SSL)

Definition at line 147 of file nsIAbDirectory.idl.

Definition at line 88 of file nsIAbDirectory.idl.

Definition at line 176 of file nsIAbDirectory.idl.

Definition at line 84 of file nsAbDirProperty.h.

nsString nsAbDirProperty::m_Description [protected, inherited]

Definition at line 79 of file nsAbDirProperty.h.

nsString nsAbDirProperty::m_DirName [protected, inherited]

Definition at line 74 of file nsAbDirProperty.h.

nsCString nsAbDirProperty::m_DirPrefId [protected, inherited]

Definition at line 81 of file nsAbDirProperty.h.

PRBool nsAbDirProperty::m_IsMailList [protected, inherited]

Definition at line 80 of file nsAbDirProperty.h.

Definition at line 75 of file nsAbDirProperty.h.

nsString nsAbDirProperty::m_ListName [protected, inherited]

Definition at line 77 of file nsAbDirProperty.h.

nsString nsAbDirProperty::m_ListNickName [protected, inherited]

Definition at line 78 of file nsAbDirProperty.h.

DelegateEntry* nsRDFResource::mDelegates [protected, inherited]

Definition at line 87 of file nsRDFResource.h.

Definition at line 70 of file nsAbBSDirectory.h.

nsHashtable nsAbBSDirectory::mServers [protected]

Definition at line 72 of file nsAbBSDirectory.h.

Definition at line 71 of file nsAbBSDirectory.h.

nsCString nsRDFResource::mURI [protected, inherited]

Definition at line 79 of file nsRDFResource.h.

Definition at line 82 of file nsIAbDirectory.idl.

const long nsIAbDirectory::opRead = 0x1 [inherited]

Definition at line 72 of file nsIAbDirectory.idl.

const long nsIAbDirectory::opSearch = 0x4 [inherited]

Definition at line 79 of file nsIAbDirectory.idl.

const long nsIAbDirectory::opWrite = 0x2 [inherited]

Definition at line 75 of file nsIAbDirectory.idl.

directory should be searched when doing local autocomplete

Definition at line 152 of file nsIAbDirectory.idl.

Definition at line 155 of file nsIAbDirectory.idl.

readonly attribute string nsIRDFResource::Value [inherited]

The single-byte string value of the resource.

Note:
THIS IS OBSOLETE. C++ should use GetValueConst and script should use .valueUTF8

Definition at line 53 of file nsIRDFResource.idl.

readonly attribute AUTF8String nsIRDFResource::ValueUTF8 [inherited]

The UTF-8 URI of the resource.

Definition at line 58 of file nsIRDFResource.idl.


The documentation for this class was generated from the following files: