Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Private Member Functions
nsMsgFilterDelegateFactory Class Reference

#include <nsMsgFilterDelegateFactory.h>

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

List of all members.

Public Member Functions

 nsMsgFilterDelegateFactory ()
virtual ~nsMsgFilterDelegateFactory ()
void CreateDelegate (in nsIRDFResource aOuter, in string aKey, in nsIIDRef aIID,[retval, iid_is(aIID)] out nsQIResult aResult)
 Create a delegate for the specified RDF resource.

Static Private Member Functions

static nsresult getFilterListDelegate (nsIRDFResource *aOuter, nsIMsgFilterList **aResult)
static nsresult getFilterDelegate (nsIRDFResource *aOuter, nsIMsgFilter **aResult)
static const char * getFilterName (const char *filterTag)
static nsresult getFilterList (const char *aUri, PRInt32 aTagPosition, nsIMsgFilterList **aResult)

Detailed Description

Definition at line 49 of file nsMsgFilterDelegateFactory.h.


Constructor & Destructor Documentation

Definition at line 65 of file nsMsgFilterDelegateFactory.cpp.

{
  /* member initializers and constructor code */
}

Definition at line 70 of file nsMsgFilterDelegateFactory.cpp.

{
  /* destructor code */
}

Member Function Documentation

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

Create a delegate for the specified RDF resource.

The created delegate should forward AddRef() and Release() calls to the aOuter object.

nsresult nsMsgFilterDelegateFactory::getFilterDelegate ( nsIRDFResource aOuter,
nsIMsgFilter **  aResult 
) [static, private]

Definition at line 136 of file nsMsgFilterDelegateFactory.cpp.

{
    nsresult rv;
    // now try to find ";filterName="
    nsXPIDLCString uri;
    rv = aOuter->GetValue(getter_Copies(uri));
    if (NS_FAILED(rv)) return rv;
    
    PRInt32 separatorPosition = 0;
    const char *filterTag = uri;
    while (filterTag && *filterTag != ';') {
        separatorPosition++;
        filterTag++;
    }
    
    // if no ;, and it's not a folder,
    // I don't know what the heck it is.
    if (!filterTag)
        return NS_ERROR_FAILURE;

    const char *filterName = getFilterName(filterTag);

    nsCOMPtr<nsIMsgFilterList> filterList;
    rv = getFilterList(uri, separatorPosition, getter_AddRefs(filterList));

        // now that we have the filter list and index, retrieve the filter.

    // XXX convert from UTF8
    nsAutoString filterString;
    PRUnichar *unicodeString =
        nsTextFormatter::smprintf(unicodeFormatter, filterName);
    NS_ENSURE_TRUE(unicodeString, NS_ERROR_OUT_OF_MEMORY);
    
    filterString.Assign(unicodeString);

    nsTextFormatter::smprintf_free(unicodeString);
    
    nsCOMPtr<nsIMsgFilter> filter;
    rv = filterList->GetFilterNamed(filterString.get(), getter_AddRefs(filter));
    if (NS_FAILED(rv)) return rv;

    *aResult = filter;
    NS_IF_ADDREF(*aResult);
    
    return NS_OK;
}

Here is the call graph for this function:

nsresult nsMsgFilterDelegateFactory::getFilterList ( const char *  aUri,
PRInt32  aTagPosition,
nsIMsgFilterList **  aResult 
) [static, private]

Definition at line 198 of file nsMsgFilterDelegateFactory.cpp.

{
    nsresult rv;
    // now we actually need the filter list, so we truncate the string
    // and use getdelegate to get the filter delegate
    nsCAutoString folderUri((const char*)aUri);
    folderUri.Truncate(aTagPosition);
    
    // convert URI to resource
    nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIRDFResource> filterListResource;
    rdf->GetResource(folderUri, getter_AddRefs(filterListResource));
    NS_ENSURE_SUCCESS(rv, rv);

    return filterListResource->GetDelegate("filter",
                                           NS_GET_IID(nsIMsgFilterList),
                                           (void **)aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file nsMsgFilterDelegateFactory.cpp.

{
    nsresult rv;
    
    nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(aOuter, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    
    nsCOMPtr<nsIMsgFilterList> filterList;
    rv = folder->GetFilterList(nsnull, getter_AddRefs(filterList));
    NS_ENSURE_SUCCESS(rv, rv);
    
    *aResult = filterList;
    NS_IF_ADDREF(*aResult);
    return NS_OK;
}

Here is the call graph for this function:

const char * nsMsgFilterDelegateFactory::getFilterName ( const char *  filterTag) [static, private]

Definition at line 186 of file nsMsgFilterDelegateFactory.cpp.

{
    
    if (nsCRT::strncmp(filterTag, MSGFILTER_TAG, MSGFILTER_TAG_LENGTH) != 0)
        return nsnull;
    
    const char *filterNameStr = filterTag + MSGFILTER_TAG_LENGTH;

    return filterNameStr;
}

Here is the caller graph for this function:


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