Back to index

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

#include <nsAbDirectoryRDFResource.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED nsAbDirectoryRDFResource ()
virtual ~nsAbDirectoryRDFResource ()
NS_IMETHOD Init (const char *aURI)
NS_DECL_ISUPPORTS NS_IMETHOD EqualsNode (nsIRDFNode *aNode, PRBool *aResult)
boolean EqualsNode (in nsIRDFNode aNode)
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.

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.

Protected Attributes

PRBool mIsValidURI
PRBool mIsQueryURI
nsCString mPath
nsCString mQueryString
nsCString mURINoQuery
nsCString mURI
DelegateEntrymDelegates

Static Protected Attributes

static nsIRDFServicegRDFService = nsnull
static nsrefcnt gRDFServiceRefCnt = 0

Detailed Description

Definition at line 46 of file nsAbDirectoryRDFResource.h.


Constructor & Destructor Documentation

Definition at line 59 of file nsAbDirectoryRDFResource.cpp.

{
}

Member Function Documentation

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.

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:

NS_IMETHODIMP nsRDFResource::GetValueUTF8 ( nsACString &  aResult) [inherited]

Definition at line 142 of file nsRDFResource.cpp.

{
    aResult = mURI;
    return NS_OK;
}

Reimplemented from nsRDFResource.

Reimplemented in nsAbOSXDirectory, nsAbOutlookDirectory, and nsAbLDAPDirectory.

Definition at line 65 of file nsAbDirectoryRDFResource.cpp.

{
    nsresult rv;
    rv = nsRDFResource::Init (aURI);
    NS_ENSURE_SUCCESS(rv, rv);

    mURINoQuery = aURI;

    nsCOMPtr<nsIURI> uri = do_CreateInstance (NS_STANDARDURL_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = uri->SetSpec(nsDependentCString(aURI));
    NS_ENSURE_SUCCESS(rv, rv);

    mIsValidURI = PR_TRUE;

    nsCOMPtr<nsIURL> url = do_QueryInterface(uri);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCAutoString queryString;
    rv = url->GetQuery (queryString);

    nsCAutoString path;
    rv = url->GetPath (path);
    mPath = path;

    PRUint32 queryStringLength;
    if (queryString.get () && (queryStringLength = queryString.Length ()))
    {
        int pathLength = path.Length () - queryStringLength - 1;
        mPath.Truncate (pathLength);

        mURINoQuery.Truncate (mURINoQuery.Length () - queryStringLength - 1);

        mQueryString = queryString;

        mIsQueryURI = PR_TRUE;
    }
    else 
      mIsQueryURI = PR_FALSE;

    return rv;
}

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

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.


Member Data Documentation

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.

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 60 of file nsAbDirectoryRDFResource.h.

Definition at line 61 of file nsAbDirectoryRDFResource.h.

nsCString nsRDFResource::mURI [protected, inherited]

Definition at line 79 of file nsRDFResource.h.

Definition at line 62 of file nsAbDirectoryRDFResource.h.

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: