Back to index

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

#include <nsServiceManagerUtils.h>

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

List of all members.

Public Member Functions

 nsGetServiceFromCategory (const char *aCategory, const char *aEntry, nsresult *aErrorPtr)
virtual nsresult NS_FASTCALL operator() (const nsIID &, void **) const

Protected Attributes

const char * mCategory
const char * mEntry
nsresultmErrorPtr

Detailed Description

Definition at line 72 of file nsServiceManagerUtils.h.


Constructor & Destructor Documentation

nsGetServiceFromCategory::nsGetServiceFromCategory ( const char *  aCategory,
const char *  aEntry,
nsresult aErrorPtr 
) [inline]

Definition at line 75 of file nsServiceManagerUtils.h.

        : mCategory(aCategory),
        mEntry(aEntry),
        mErrorPtr(aErrorPtr)
        {
            // nothing else to do
        }

Member Function Documentation

nsresult nsGetServiceFromCategory::operator() ( const nsIID aIID,
void **  aInstancePtr 
) const [virtual]

Implements nsCOMPtr_helper.

Definition at line 214 of file nsComponentManager.cpp.

{
    nsresult rv;
    nsXPIDLCString value;
    nsCOMPtr<nsICategoryManager> catman;
    nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
    if (!compMgr) {
        rv = NS_ERROR_NOT_INITIALIZED;
        goto error;
    }

    if (!mCategory || !mEntry) {
        // when categories have defaults, use that for null mEntry
        rv = NS_ERROR_NULL_POINTER;
        goto error;
    }

    rv = compMgr->nsComponentManagerImpl::GetService(kCategoryManagerCID,
                                                     NS_GET_IID(nsICategoryManager),
                                                     getter_AddRefs(catman));
    if (NS_FAILED(rv)) goto error;

    /* find the contractID for category.entry */
    rv = catman->GetCategoryEntry(mCategory, mEntry,
                                  getter_Copies(value));
    if (NS_FAILED(rv)) goto error;
    if (!value) {
        rv = NS_ERROR_SERVICE_NOT_AVAILABLE;
        goto error;
    }

    rv = compMgr->
        nsComponentManagerImpl::GetServiceByContractID(value,
                                                       aIID, aInstancePtr);
    if (NS_FAILED(rv)) {
    error:
        *aInstancePtr = 0;
    }
    if (mErrorPtr)
        *mErrorPtr = rv;
    return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 86 of file nsServiceManagerUtils.h.

Definition at line 87 of file nsServiceManagerUtils.h.

Definition at line 88 of file nsServiceManagerUtils.h.


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