Back to index

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

#include <nsAbOutlookDirectory.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED nsAbOutlookDirectory (void)
virtual ~nsAbOutlookDirectory (void)
NS_IMETHOD GetChildCards (nsIEnumerator **aCards)
NS_IMETHOD GetChildNodes (nsISimpleEnumerator **aNodes)
NS_IMETHOD HasCard (nsIAbCard *aCard, PRBool *aHasCard)
NS_IMETHOD HasDirectory (nsIAbDirectory *aDirectory, PRBool *aHasDirectory)
NS_IMETHOD DeleteCards (nsISupportsArray *aCardList)
NS_IMETHOD ModifyDirectory (nsIAbDirectory *directory, nsIAbDirectoryProperties *aProperties)
NS_IMETHOD DeleteDirectory (nsIAbDirectory *aDirectory)
NS_IMETHOD AddCard (nsIAbCard *aData, nsIAbCard **addedCard)
NS_IMETHOD DropCard (nsIAbCard *aData, PRBool needToCopyCard)
NS_IMETHOD AddMailList (nsIAbDirectory *aMailList)
NS_IMETHOD EditMailListToDatabase (const char *aUri, nsIAbCard *listCard)
NS_IMETHOD Init (const char *aUri)
NS_DECL_NSIABDIRECTORYQUERY
NS_DECL_NSIABDIRECTORYSEARCH
nsresult 
OnSearchFinished (PRInt32 aResult)
nsresult OnSearchFoundCard (nsIAbCard *aCard)
nsresult ExecuteQuery (nsIAbDirectoryQueryArguments *aArguments, nsIAbDirectoryQueryResultListener *aListener, PRInt32 aResultLimit, PRInt32 aTimeout, PRInt32 aThreadId)
void Init (in string uri)
 This method is called by the nsIRDFService after constructing a resource object to initialize it's URI.
NS_DECL_ISUPPORTS NS_IMETHOD EqualsNode (nsIRDFNode *aNode, PRBool *aResult)
boolean EqualsNode (in nsIRDFNode aNode)
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)
long doQuery (in nsIAbDirectoryQueryArguments arguments, in nsIAbDirectoryQueryResultListener listener, in long resultLimit, in long timeOut)
 Initiates a query on a directory and sub-directories for properties on cards.
void stopQuery (in long contextID)
 Stops an existing query operation if query operation is asynchronous.
void startSearch ()
 Starts a search on the directory.
void stopSearch ()
 Stops a search on the directory.

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 GetChildCards (nsISupportsArray **aCards, void *aRestriction)
nsresult GetChildNodes (nsISupportsArray **aNodes)
nsresult CreateCard (nsIAbCard *aData, nsIAbCard **aNewCard)
nsresult NotifyItemDeletion (nsISupports *aItem)
nsresult NotifyItemAddition (nsISupports *aItem)
nsresult CommitAddressList (void)
nsresult UpdateAddressList (void)
nsresult GetAttributeName (PRUnichar **aName, nsString &value)
nsresult SetAttributeName (const PRUnichar *aName, nsString &arrtibute)

Protected Attributes

nsMapiEntrymMapiData
nsHashtable mQueryThreads
PRInt32 mCurrentQueryId
PRLockmProtector
nsSupportsHashtable mCardList
PRInt32 mSearchContext
PRUint32 mAbWinType
PRBool mIsValidURI
PRBool mIsQueryURI
nsCString mPath
nsCString mQueryString
nsCString mURINoQuery
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 52 of file nsAbOutlookDirectory.h.


Constructor & Destructor Documentation

Definition at line 95 of file nsAbOutlookDirectory.cpp.

{
    if (mMapiData) { delete mMapiData ; }
    if (mProtector) { PR_DestroyLock(mProtector) ; }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 370 of file nsAbOutlookDirectory.cpp.

{
    if (mIsQueryURI)
      return NS_ERROR_NOT_IMPLEMENTED;

    NS_ENSURE_ARG_POINTER(aData);

    nsresult retCode = NS_OK ;
    PRBool hasCard = PR_FALSE ;
    
    retCode = HasCard(aData, &hasCard) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (hasCard) {
        PRINTF(("Has card.\n")) ;
        NS_IF_ADDREF(*addedCard = aData);
        return NS_OK ; 
    }
    retCode = CreateCard(aData, addedCard) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    nsVoidKey newKey (NS_STATIC_CAST(void *, *addedCard)) ;
    
    mCardList.Put(&newKey, *addedCard) ;
    if (m_IsMailList) { m_AddressList->AppendElement(*addedCard) ; }
    NotifyItemAddition(*addedCard) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 403 of file nsAbOutlookDirectory.cpp.

{
    if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
    if (!aMailList) { return NS_ERROR_NULL_POINTER ; }
    if (m_IsMailList) { return NS_OK ; }
    nsresult retCode = NS_OK ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
    nsCAutoString entryString ;
    nsMapiEntry newEntry ;
    PRBool didCopy = PR_FALSE ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    retCode = ExtractDirectoryEntry(aMailList, entryString) ;
    if (NS_SUCCEEDED(retCode) && !entryString.IsEmpty()) {
        nsMapiEntry sourceEntry ;

        sourceEntry.Assign(entryString) ;
        mapiAddBook->CopyEntry(*mMapiData, sourceEntry, newEntry) ;
    }
    if (newEntry.mByteCount == 0) {
        if (!mapiAddBook->CreateDistList(*mMapiData, newEntry)) {
            return NS_ERROR_FAILURE ; 
        }
    }
    else { didCopy = PR_TRUE ; }
    newEntry.ToString(entryString) ;
    nsCAutoString uri ;

    buildAbWinUri(kOutlookDirectoryScheme, mAbWinType, uri) ;
    uri.Append(entryString) ;
    nsCOMPtr<nsIRDFResource> resource ;
    retCode = gRDFService->GetResource(uri, getter_AddRefs(resource)) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    nsCOMPtr<nsIAbDirectory> newList(do_QueryInterface(resource, &retCode)) ;
    
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (!didCopy) {
        retCode = newList->CopyMailList(aMailList) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        retCode = newList->EditMailListToDatabase(mURINoQuery.get(), nsnull) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
    }
    m_AddressList->AppendElement(newList) ;
    NotifyItemAddition(newList) ;
    return retCode ;
}

Here is the call graph for this function:

Definition at line 1192 of file nsAbOutlookDirectory.cpp.

{
    nsresult retCode = NS_OK ;
    nsCOMPtr<nsISupportsArray> oldList ;
    PRUint32 nbCards = 0 ;
    PRUint32 i = 0 ;
    
    if (!m_IsMailList) { 
        PRINTF(("We are not in a mailing list, no commit can be done.\n")) ;
        return NS_ERROR_UNEXPECTED ;
    }
    retCode = GetChildCards(getter_AddRefs(oldList), nsnull) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    retCode = m_AddressList->Count(&nbCards) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    nsCOMPtr<nsISupports> element ;
    nsCOMPtr<nsIAbCard> newCard ;

    for (i = 0 ; i < nbCards ; ++ i) {
        retCode = m_AddressList->GetElementAt(i, getter_AddRefs(element)) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        if (!oldList->RemoveElement(element)) {
            // The entry was not already there
            nsCOMPtr<nsIAbCard> card (do_QueryInterface(element, &retCode)) ;
            
            NS_ENSURE_SUCCESS(retCode, retCode) ;

            retCode = CreateCard(card, getter_AddRefs(newCard)) ;
            NS_ENSURE_SUCCESS(retCode, retCode) ;
            m_AddressList->ReplaceElementAt(newCard, i) ;
        }
    }
    retCode = DeleteCards(oldList) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAbOutlookDirectory::CreateCard ( nsIAbCard aData,
nsIAbCard **  aNewCard 
) [protected]

Definition at line 1241 of file nsAbOutlookDirectory.cpp.

{
    if (!aData || !aNewCard) { return NS_ERROR_NULL_POINTER ; }
    *aNewCard = nsnull ;
    nsresult retCode = NS_OK ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
    nsMapiEntry newEntry ;
    nsCAutoString entryString ;
    PRBool didCopy = PR_FALSE ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    // If we get a RDF resource and it maps onto an Outlook card uri,
    // we simply copy the contents of the Outlook card.
    retCode = ExtractCardEntry(aData, entryString) ;
    if (NS_SUCCEEDED(retCode) && !entryString.IsEmpty()) {
        nsMapiEntry sourceEntry ;
        
        
        sourceEntry.Assign(entryString) ;
        if (m_IsMailList) {
            // In the case of a mailing list, we can use the address
            // as a direct template to build the new one (which is done
            // by CopyEntry).
            mapiAddBook->CopyEntry(*mMapiData, sourceEntry, newEntry) ;
            didCopy = PR_TRUE ;
        }
        else {
            // Else, we have to create a temporary address and copy the
            // source into it. Yes it's silly.
            mapiAddBook->CreateEntry(*mMapiData, newEntry) ;
        }
    }
    // If this approach doesn't work, well we're back to creating and copying.
    if (newEntry.mByteCount == 0) {
        // In the case of a mailing list, we cannot directly create a new card,
        // we have to create a temporary one in a real folder (to be able to use
        // templates) and then copy it to the mailing list.
        if (m_IsMailList) {
            nsMapiEntry parentEntry ;
            nsMapiEntry temporaryEntry ;

            if (!mapiAddBook->GetDefaultContainer(parentEntry)) {
                return NS_ERROR_FAILURE ;
            }
            if (!mapiAddBook->CreateEntry(parentEntry, temporaryEntry)) {
                return NS_ERROR_FAILURE ;
            }
            if (!mapiAddBook->CopyEntry(*mMapiData, temporaryEntry, newEntry)) {
                return NS_ERROR_FAILURE ;
            }
            if (!mapiAddBook->DeleteEntry(parentEntry, temporaryEntry)) {
                return NS_ERROR_FAILURE ;
            }
        }
        // If we're on a real address book folder, we can directly create an
        // empty card.
        else if (!mapiAddBook->CreateEntry(*mMapiData, newEntry)) {
            return NS_ERROR_FAILURE ;
        }
    }
    newEntry.ToString(entryString) ;
    nsCAutoString uri ;

    buildAbWinUri(kOutlookCardScheme, mAbWinType, uri) ;
    uri.Append(entryString) ;
    nsCOMPtr<nsIRDFResource> resource ;
    
    nsCOMPtr<nsIAbCard> newCard = do_CreateInstance(NS_ABOUTLOOKCARD_CONTRACTID, &retCode);
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    resource = do_QueryInterface(newCard, &retCode) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    retCode = resource->Init(uri.get()) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (!didCopy) {
        retCode = newCard->Copy(aData) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        retCode = newCard->EditCardToDatabase(mURINoQuery.get()) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
    }
    *aNewCard = newCard ;
    NS_ADDREF(*aNewCard) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 288 of file nsAbOutlookDirectory.cpp.

{
    if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
    if (!aCardList) { return NS_ERROR_NULL_POINTER ; }
    PRUint32 nbCards = 0 ;
    nsresult retCode = NS_OK ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    
    retCode = aCardList->Count(&nbCards) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    PRUint32 i = 0 ;
    nsCOMPtr<nsISupports> element ;
    nsCAutoString entryString ;
    nsMapiEntry cardEntry ;

    for (i = 0 ; i < nbCards ; ++ i) {
        retCode = aCardList->GetElementAt(i, getter_AddRefs(element)) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        nsCOMPtr<nsIAbCard> card (do_QueryInterface(element, &retCode)) ;
        
        NS_ENSURE_SUCCESS(retCode, retCode) ;

        retCode = ExtractCardEntry(card, entryString) ;
        if (NS_SUCCEEDED(retCode) && !entryString.IsEmpty()) {

            cardEntry.Assign(entryString) ;
            if (!mapiAddBook->DeleteEntry(*mMapiData, cardEntry)) {
                PRINTF(("Cannot delete card %s.\n", entryString.get())) ;
            }
            else {
                nsVoidKey key (NS_STATIC_CAST(void *, element)) ;
                
                mCardList.Remove(&key) ;
                if (m_IsMailList) { m_AddressList->RemoveElement(element) ; }
                retCode = NotifyItemDeletion(element) ;
                NS_ENSURE_SUCCESS(retCode, retCode) ;
            }
        }
        else {
            PRINTF(("Card doesn't belong in this directory.\n")) ;
        }
    }
    return NS_OK ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 341 of file nsAbOutlookDirectory.cpp.

{
    if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
    if (!aDirectory) { return NS_ERROR_NULL_POINTER ; }
    nsresult retCode = NS_OK ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
    nsCAutoString entryString ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    retCode = ExtractDirectoryEntry(aDirectory, entryString) ;
    if (NS_SUCCEEDED(retCode) && !entryString.IsEmpty()) {
        nsMapiEntry directoryEntry ;

        directoryEntry.Assign(entryString) ;
        if (!mapiAddBook->DeleteEntry(*mMapiData, directoryEntry)) {
            PRINTF(("Cannot delete directory %s.\n", entryString.get())) ;
        }
        else {
            m_AddressList->RemoveElement(aDirectory) ;
            retCode = NotifyItemDeletion(aDirectory) ;
            NS_ENSURE_SUCCESS(retCode, retCode) ;
        }
    }
    else {
        PRINTF(("Directory doesn't belong to this folder.\n")) ;
    }
    return retCode ;
}

Here is the call graph for this function:

long nsIAbDirectoryQuery::doQuery ( in nsIAbDirectoryQueryArguments  arguments,
in nsIAbDirectoryQueryResultListener  listener,
in long  resultLimit,
in long  timeOut 
) [inherited]

Initiates a query on a directory and sub-directories for properties on cards.

Parameters:
argumentsThe properties and values to match Value could of type nsIAbDirectoryQueryMatchItem for matches other than ?contains?
listenerThe listener which will obtain individual query results
resultLimitLimits the results returned to a specifed maximum value
Returns:
Unique number representing the context ID of the query
NS_IMETHODIMP nsAbOutlookDirectory::DropCard ( nsIAbCard aData,
PRBool  needToCopyCard 
)

Definition at line 397 of file nsAbOutlookDirectory.cpp.

{
    nsCOMPtr <nsIAbCard> addedCard;
    return AddCard(aData, getter_AddRefs(addedCard));
}

Here is the call graph for this function:

void nsIAbDirectory::dropCard ( in nsIAbCard  card,
in boolean  needToCopyCard 
) [inherited]

Definition at line 450 of file nsAbOutlookDirectory.cpp.

{
    if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
    nsresult retCode = NS_OK ;
    nsXPIDLString name ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    retCode = GetDirName(getter_Copies(name)) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (!mapiAddBook->SetPropertyUString(*mMapiData, PR_DISPLAY_NAME_W, name.get())) {
        return NS_ERROR_FAILURE ;
    }
    retCode = CommitAddressList() ;
    return retCode ;
}

Here is the call graph for this function:

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 nsAbOutlookDirectory::ExecuteQuery ( nsIAbDirectoryQueryArguments aArguments,
nsIAbDirectoryQueryResultListener aListener,
PRInt32  aResultLimit,
PRInt32  aTimeout,
PRInt32  aThreadId 
)

Definition at line 1039 of file nsAbOutlookDirectory.cpp.

{
    if (!aArguments || !aListener) { 
        return NS_ERROR_NULL_POINTER ; 
    }
    SRestriction arguments ;
    nsresult retCode = NS_OK ;
    
    retCode = BuildRestriction(aArguments, arguments) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    nsCOMPtr<nsISupportsArray> resultsArray ;
    PRUint32 nbResults = 0 ;
    
    retCode = GetChildCards(getter_AddRefs(resultsArray), 
                            arguments.rt == RES_COMMENT ? nsnull : &arguments) ;
    DestroyRestriction(arguments) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    retCode = resultsArray->Count(&nbResults) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    nsCOMPtr<nsIAbDirectoryQueryResult> result ;
    nsAbDirectoryQueryResult *newResult = nsnull ;

    if (aResultLimit > 0 && nbResults > NS_STATIC_CAST(PRUint32, aResultLimit)) { 
        nbResults = NS_STATIC_CAST(PRUint32, aResultLimit) ; 
    }
    PRUint32 i = 0 ;
    nsCOMPtr<nsISupports> element ;
    nsCOMPtr<nsISupportsArray> propertyValues ;
    
    for (i = 0 ; i < nbResults ; ++ i) {
        retCode = resultsArray->GetElementAt(i, getter_AddRefs(element)) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        nsCOMPtr<nsIAbCard> card (do_QueryInterface(element, &retCode)) ;
        
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        FillPropertyValues(card, aArguments, getter_AddRefs(propertyValues)) ;
        newResult = new nsAbDirectoryQueryResult(0, aArguments,
                                                 nsIAbDirectoryQueryResult::queryResultMatch, 
                                                 propertyValues) ;
        if (!newResult) { return NS_ERROR_OUT_OF_MEMORY ; }
        result = newResult ;
        aListener->OnQueryItem(result) ;
    }
    nsIntegerKey hashKey(aThreadId) ;
    
    mQueryThreads.Remove(&hashKey) ;
    newResult = new nsAbDirectoryQueryResult(0, aArguments,
                                             nsIAbDirectoryQueryResult::queryResultComplete, 
                                             0) ;
    result = newResult ;
    aListener->OnQueryItem(result) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 166 of file nsAbOutlookDirectory.cpp.

{
    if (!aCards) { return NS_ERROR_NULL_POINTER ; }
    *aCards = nsnull ;
    nsCOMPtr<nsISupportsArray> cardList ;
    nsresult retCode ;
    
    mCardList.Reset() ;
    if (mIsQueryURI) {
        retCode = StartSearch() ;
        NS_NewISupportsArray(getter_AddRefs(cardList)) ;
    }
    else {
        retCode = GetChildCards(getter_AddRefs(cardList), nsnull) ;
    }
    if (NS_SUCCEEDED(retCode)) {
        // Fill the results array and update the card list
        // Also update the address list and notify any changes.
        PRUint32 nbCards = 0 ;
        nsCOMPtr<nsISupports> element ;
        
        cardList->Enumerate(aCards) ;
        cardList->Count(&nbCards) ;
        for (PRUint32 i = 0 ; i < nbCards ; ++ i) {
            cardList->GetElementAt(i, getter_AddRefs(element)) ;
            nsVoidKey newKey (NS_STATIC_CAST(void *, element)) ;
            nsCOMPtr<nsISupports> oldElement = mCardList.Get(&newKey) ;

            if (!oldElement) {
                // We are dealing with a new element (probably directly
                // added from Outlook), we may need to sync m_AddressList
                mCardList.Put(&newKey, element) ;
                nsCOMPtr<nsIAbCard> card (do_QueryInterface(element, &retCode)) ;

                NS_ENSURE_SUCCESS(retCode, retCode) ;
                PRBool isMailList = PR_FALSE ;

                retCode = card->GetIsMailList(&isMailList) ;
                NS_ENSURE_SUCCESS(retCode, retCode) ;
                if (isMailList) {
                    // We can have mailing lists only in folder, 
                    // we must add the directory to m_AddressList
                    nsXPIDLCString mailListUri ;

                    retCode = card->GetMailListURI(getter_Copies(mailListUri)) ;
                    NS_ENSURE_SUCCESS(retCode, retCode) ;
                    nsCOMPtr<nsIRDFResource> resource ;

                    retCode = gRDFService->GetResource(mailListUri, getter_AddRefs(resource)) ;
                    NS_ENSURE_SUCCESS(retCode, retCode) ;
                    nsCOMPtr<nsIAbDirectory> mailList(do_QueryInterface(resource, &retCode)) ;
                    
                    NS_ENSURE_SUCCESS(retCode, retCode) ;
                    m_AddressList->AppendElement(mailList) ;
                    NotifyItemAddition(mailList) ;
                }
                else if (m_IsMailList) {
                    m_AddressList->AppendElement(card) ;
                    NotifyItemAddition(card) ;
                }
            }
            else {
                NS_ASSERTION(oldElement == element, "Different card stored") ;
            }
        }
    }
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAbOutlookDirectory::GetChildCards ( nsISupportsArray **  aCards,
void aRestriction 
) [protected]

Definition at line 1096 of file nsAbOutlookDirectory.cpp.

{
    if (!aCards) { return NS_ERROR_NULL_POINTER ; }
    *aCards = nsnull ;
    nsresult retCode = NS_OK ;
    nsCOMPtr<nsISupportsArray> cards ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
    nsMapiEntryArray cardEntries ;
    LPSRestriction restriction = (LPSRestriction) aRestriction ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    retCode = NS_NewISupportsArray(getter_AddRefs(cards)) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (!mapiAddBook->GetCards(*mMapiData, restriction, cardEntries)) {
        PRINTF(("Cannot get cards.\n")) ;
        return NS_ERROR_FAILURE ;
    }
    nsCAutoString entryId ;
    nsCAutoString uriName ;
    nsCOMPtr<nsIRDFResource> resource ;
    nsCOMPtr <nsIAbCard> childCard;
        
    for (ULONG card = 0 ; card < cardEntries.mNbEntries ; ++ card) {
        cardEntries.mEntries [card].ToString(entryId) ;
        buildAbWinUri(kOutlookCardScheme, mAbWinType, uriName) ;
        uriName.Append(entryId) ;
        childCard = do_CreateInstance(NS_ABOUTLOOKCARD_CONTRACTID, &retCode);
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        resource = do_QueryInterface(childCard, &retCode) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        retCode = resource->Init(uriName.get()) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        cards->AppendElement(childCard) ;
    }
    *aCards = cards ;
    NS_ADDREF(*aCards) ;
    return retCode ;
}

Here is the call graph for this function:

Definition at line 148 of file nsAbOutlookDirectory.cpp.

{
    if (!aNodes) { return NS_ERROR_NULL_POINTER ; }
    *aNodes = nsnull ;
    nsCOMPtr<nsISupportsArray> nodeList ;
    nsresult retCode = NS_OK ;
    
    if (mIsQueryURI) {
        NS_NewISupportsArray(getter_AddRefs(nodeList)) ;
    }
    else {
        retCode = GetChildNodes(getter_AddRefs(nodeList)) ;
    }
    if (NS_SUCCEEDED(retCode))
      retCode = NS_NewArrayEnumerator(aNodes, nodeList);
    return retCode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1136 of file nsAbOutlookDirectory.cpp.

{
    if (!aNodes) { return NS_ERROR_NULL_POINTER ; }
    *aNodes = nsnull ;
    nsresult retCode = NS_OK ;
    nsCOMPtr<nsISupportsArray> nodes ;
    nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
    nsMapiEntryArray nodeEntries ;

    if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
    retCode = NS_NewISupportsArray(getter_AddRefs(nodes)) ;
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    if (!mapiAddBook->GetNodes(*mMapiData, nodeEntries)) {
        PRINTF(("Cannot get nodes.\n")) ;
        return NS_ERROR_FAILURE ;
    }
    nsCAutoString entryId ;
    nsCAutoString uriName ;
    nsCOMPtr <nsIRDFResource> resource ;

    for (ULONG node = 0 ; node < nodeEntries.mNbEntries ; ++ node) {
        nodeEntries.mEntries [node].ToString(entryId) ;
        buildAbWinUri(kOutlookDirectoryScheme, mAbWinType, uriName) ;
        uriName.Append(entryId) ;
        retCode = gRDFService->GetResource(uriName, getter_AddRefs(resource)) ;
        NS_ENSURE_SUCCESS(retCode, retCode) ;
        nodes->AppendElement(resource) ;
    }
    *aNodes = nodes ;
    NS_ADDREF(*aNodes) ;
    return retCode ;
}

Here is the call 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:

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:

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.

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;
}

Definition at line 235 of file nsAbOutlookDirectory.cpp.

{
    if (!aCard || !aHasCard) { return NS_ERROR_NULL_POINTER ; }
    nsVoidKey key (NS_STATIC_CAST(void *, aCard)) ;

    *aHasCard = mCardList.Exists(&key) ;
    return NS_OK ;
}

Here is the caller graph for this function:

boolean nsIAbDirectory::hasCard ( in nsIAbCard  cards) [inherited]

Here is the caller graph for this function:

NS_IMETHODIMP nsAbOutlookDirectory::HasDirectory ( nsIAbDirectory aDirectory,
PRBool aHasDirectory 
)

Definition at line 244 of file nsAbOutlookDirectory.cpp.

{
    if (!aDirectory || !aHasDirectory ) { return NS_ERROR_NULL_POINTER ; }
    *aHasDirectory = (m_AddressList->IndexOf(aDirectory) >= 0) ;
    return NS_OK ;
}
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

Reimplemented from nsAbDirectoryRDFResource.

Definition at line 335 of file nsAbOutlookDirectory.cpp.

void nsIAbDirectory::modifyDirectory ( in nsIAbDirectory  directory,
in nsIAbDirectoryProperties  aProperties 
) [inherited]
nsresult nsAbOutlookDirectory::NotifyItemAddition ( nsISupports *  aItem) [protected]

Definition at line 1179 of file nsAbOutlookDirectory.cpp.

{
    nsresult retCode = NS_OK ;
    
    nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    retCode = abSession->NotifyDirectoryItemAdded(this, aItem) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAbOutlookDirectory::NotifyItemDeletion ( nsISupports *  aItem) [protected]

Definition at line 1169 of file nsAbOutlookDirectory.cpp.

{
    nsresult retCode = NS_OK ;
    
    nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
    NS_ENSURE_SUCCESS(retCode, retCode) ;
    retCode = abSession->NotifyDirectoryItemDeleted(this, aItem) ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsAbDirSearchListenerContext.

Definition at line 1023 of file nsAbOutlookDirectory.cpp.

{
    return NS_OK ;
}

Implements nsAbDirSearchListenerContext.

Definition at line 1028 of file nsAbOutlookDirectory.cpp.

{
    nsVoidKey newKey (NS_STATIC_CAST(void *, aCard)) ;
    nsresult retCode = NS_OK ;
    
    mCardList.Put(&newKey, aCard) ;
    nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
    if (NS_SUCCEEDED(retCode)) { abSession->NotifyDirectoryItemAdded(this, aCard) ; }
    return retCode ;
}

Here is the call graph for this function:

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]

Starts a search on the directory.

If a search is already being performed it is stopped.

The results from a search, cards, will returned by informing the address book session that a new card has been added to the directory.

The nsIAbDirectoryQuery implementation of the directory component (or a proxy) may be used as an implementation for this specialization of query.

This method is semantically equivalent to the nsIAbDirectory.getChildCards method when there is search criteria defined in the directory uri.

void nsIAbDirectoryQuery::stopQuery ( in long  contextID) [inherited]

Stops an existing query operation if query operation is asynchronous.

The nsIAbDirectoryQueryResultListener will be notified when query has stopped

It is implementation specific if notification synchronous or asynchronous

Parameters:
contextIDThe unique number returned from the doQuery methods

Stops a search on the directory.

Definition at line 1228 of file nsAbOutlookDirectory.cpp.

{
    nsresult retCode = S_OK ;
    
    if (m_IsMailList) {
        retCode = GetChildCards(getter_AddRefs(m_AddressList), nsnull) ; 
    }
    else { 
        retCode = GetChildNodes(getter_AddRefs(m_AddressList)) ; 
    }
    return retCode ;
}

Here is the call graph for this function:


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.

Definition at line 116 of file nsAbOutlookDirectory.h.

nsSupportsHashtable nsAbOutlookDirectory::mCardList [protected]

Definition at line 113 of file nsAbOutlookDirectory.h.

Definition at line 110 of file nsAbOutlookDirectory.h.

DelegateEntry* nsRDFResource::mDelegates [protected, inherited]

Definition at line 87 of file nsRDFResource.h.

Definition at line 59 of file nsAbDirectoryRDFResource.h.

Definition at line 58 of file nsAbDirectoryRDFResource.h.

Definition at line 107 of file nsAbOutlookDirectory.h.

Definition at line 60 of file nsAbDirectoryRDFResource.h.

Definition at line 111 of file nsAbOutlookDirectory.h.

Definition at line 61 of file nsAbDirectoryRDFResource.h.

nsHashtable nsAbOutlookDirectory::mQueryThreads [protected]

Definition at line 109 of file nsAbOutlookDirectory.h.

Definition at line 114 of file nsAbOutlookDirectory.h.

nsCString nsRDFResource::mURI [protected, inherited]

Definition at line 79 of file nsRDFResource.h.

Definition at line 62 of file nsAbDirectoryRDFResource.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: