Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsCategoryManagerUtils.h File Reference
#include "nsICategoryManager.h"
#include "nsCOMPtr.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

protocol  NS_COM
 A string set that takes up minimal size when there are 0 or 1 strings in the set. More...

Functions

NS_COM nsresult NS_CreateServicesFromCategory (const char *category, nsISupports *origin, const char *observerTopic)
const nsCreateInstanceFromCategory do_CreateInstanceFromCategory (const char *aCategory, const char *aEntry, nsresult *aErrorPtr=0)
const nsCreateInstanceFromCategory do_CreateInstanceFromCategory (const char *aCategory, const char *aEntry, nsISupports *aOuter, nsresult *aErrorPtr=0)

Function Documentation

const nsCreateInstanceFromCategory do_CreateInstanceFromCategory ( const char *  aCategory,
const char *  aEntry,
nsresult aErrorPtr = 0 
) [inline]

Definition at line 74 of file nsCategoryManagerUtils.h.

{
    return nsCreateInstanceFromCategory(aCategory, aEntry, 0, aErrorPtr);
}

Here is the caller graph for this function:

const nsCreateInstanceFromCategory do_CreateInstanceFromCategory ( const char *  aCategory,
const char *  aEntry,
nsISupports *  aOuter,
nsresult aErrorPtr = 0 
) [inline]

Definition at line 82 of file nsCategoryManagerUtils.h.

{
    return nsCreateInstanceFromCategory(aCategory, aEntry, aOuter, aErrorPtr);
}
NS_COM nsresult NS_CreateServicesFromCategory ( const char *  category,
nsISupports *  origin,
const char *  observerTopic 
)

Definition at line 836 of file nsCategoryManager.cpp.

{
    nsresult rv = NS_OK;
    
    int nFailed = 0; 
    nsCOMPtr<nsICategoryManager> categoryManager = 
        do_GetService("@mozilla.org/categorymanager;1", &rv);
    if (!categoryManager) return rv;

    nsCOMPtr<nsISimpleEnumerator> enumerator;
    rv = categoryManager->EnumerateCategory(category, 
            getter_AddRefs(enumerator));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsISupports> entry;
    while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
        // From here on just skip any error we get.
        nsCOMPtr<nsISupportsCString> catEntry = do_QueryInterface(entry, &rv);
        if (NS_FAILED(rv)) {
            nFailed++;
            continue;
        }
        nsCAutoString entryString;
        rv = catEntry->GetData(entryString);
        if (NS_FAILED(rv)) {
            nFailed++;
            continue;
        }
        nsXPIDLCString contractID;
        rv = categoryManager->GetCategoryEntry(category,entryString.get(), getter_Copies(contractID));
        if (NS_FAILED(rv)) {
            nFailed++;
            continue;
        }
        
        nsCOMPtr<nsISupports> instance = do_GetService(contractID, &rv);
        if (NS_FAILED(rv)) {
            nFailed++;
            continue;
        }

        if (observerTopic) {
            // try an observer, if it implements it.
            nsCOMPtr<nsIObserver> observer = do_QueryInterface(instance, &rv);
            if (NS_SUCCEEDED(rv) && observer)
                observer->Observe(origin, observerTopic, EmptyString().get());
        }
    }
    return (nFailed ? NS_ERROR_FAILURE : NS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function: