Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsCategoryManager.cpp File Reference
#include "nsICategoryManager.h"
#include "nsCategoryManager.h"
#include "plarena.h"
#include "prio.h"
#include "prprf.h"
#include "prlock.h"
#include "nsCOMPtr.h"
#include "nsTHashtable.h"
#include "nsClassHashtable.h"
#include "nsIFactory.h"
#include "nsIStringEnumerator.h"
#include "nsSupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "nsQuickSort.h"
#include "nsEnumeratorUtils.h"
#include "nsIProxyObjectManager.h"

Go to the source code of this file.

Classes

class  BaseStringEnumerator
class  EntryEnumerator
struct  persistent_userstruct
class  CategoryEnumerator
struct  writecat_struct
class  nsCategoryManagerFactory

Defines

#define PL_ARENA_CONST_ALIGN_MASK   7
#define NS_CATEGORYMANAGER_ARENA_SIZE   (1024 * 8)

Functions

char * ArenaStrdup (const char *s, PLArenaPool *aArena)
PLDHashOperator PR_CALLBACK enumfunc_pentries (CategoryLeaf *aLeaf, void *userArg)
PLDHashOperator PR_CALLBACK enumfunc_categories (const char *aKey, CategoryNode *aCategory, void *userArg)
nsresult NS_CategoryManagerGetFactory (nsIFactory **aFactory)
NS_COM nsresult NS_CreateServicesFromCategory (const char *category, nsISupports *origin, const char *observerTopic)

Class Documentation

struct persistent_userstruct

Definition at line 375 of file nsCategoryManager.cpp.

Collaboration diagram for persistent_userstruct:
Class Members
const char * categoryName
PRFileDesc * fd
PRBool success
struct writecat_struct

Definition at line 716 of file nsCategoryManager.cpp.

Collaboration diagram for writecat_struct:
Class Members
PRFileDesc * fd
PRBool success

Define Documentation

Definition at line 77 of file nsCategoryManager.cpp.

Definition at line 39 of file nsCategoryManager.cpp.


Function Documentation

char* ArenaStrdup ( const char *  s,
PLArenaPool aArena 
)

Definition at line 272 of file nsComponentManager.cpp.

{
    return ArenaStrndup(s, strlen(s), arena);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PLDHashOperator PR_CALLBACK enumfunc_categories ( const char *  aKey,
CategoryNode aCategory,
void userArg 
)

Definition at line 722 of file nsCategoryManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 382 of file nsCategoryManager.cpp.

{
  persistent_userstruct* args =
    NS_STATIC_CAST(persistent_userstruct*, userArg);

  PLDHashOperator status = PL_DHASH_NEXT;

  if (aLeaf->pValue) {
    if (PR_fprintf(args->fd,
                   "%s,%s,%s\n",
                   args->categoryName,
                   aLeaf->GetKey(),
                   aLeaf->pValue) == (PRUint32) -1) {
      args->success = PR_FALSE;
      status = PL_DHASH_STOP;
    }
  }

  return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 804 of file nsCategoryManager.cpp.

  {
    // assert(aFactory);

    nsresult status;

    *aFactory = 0;
    nsIFactory* new_factory = NS_STATIC_CAST(nsIFactory*, new nsCategoryManagerFactory);
    if (new_factory)
      {
        *aFactory = new_factory;
        NS_ADDREF(*aFactory);
        status = NS_OK;
      }
    else
      status = NS_ERROR_OUT_OF_MEMORY;

    return status;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

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: