Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
nsCategoryManager Class Reference

The main implementation of nsICategoryManager. More...

#include <nsCategoryManager.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSICATEGORYMANAGER
NS_METHOD 
WriteCategoryManagerToRegistry (PRFileDesc *fd)
 Write the categories to the XPCOM persistent registry.
NS_METHOD SuppressNotifications (PRBool aSuppress)
 Suppress or unsuppress notifications of category changes to the observer service.
 nsCategoryManager ()
string getCategoryEntry (in string aCategory, in string aEntry)
 Get the value for the given category's entry.
string addCategoryEntry (in string aCategory, in string aEntry, in string aValue, in boolean aPersist, in boolean aReplace)
 Add an entry to a category.
void deleteCategoryEntry (in string aCategory, in string aEntry, in boolean aPersist)
 Delete an entry from the category.
void deleteCategory (in string aCategory)
 Delete a category and all entries.
nsISimpleEnumerator enumerateCategory (in string aCategory)
 Enumerate the entries in a category.
nsISimpleEnumerator enumerateCategories ()
 Enumerate all existing categories.

Private Member Functions

 ~nsCategoryManager ()
CategoryNodeget_category (const char *aName)
void NotifyObservers (const char *aTopic, const char *aCategoryName, const char *aEntryName)

Static Private Member Functions

static nsCategoryManagerCreate ()

Private Attributes

PLArenaPool mArena
nsClassHashtable
< nsDepCharHashKey,
CategoryNode
mTable
PRLockmLock
PRBool mSuppressNotifications

Friends

class nsCategoryManagerFactory

Detailed Description

The main implementation of nsICategoryManager.

This implementation is thread-safe.

Definition at line 132 of file nsCategoryManager.h.


Constructor & Destructor Documentation

Definition at line 152 of file nsCategoryManager.h.

Definition at line 500 of file nsCategoryManager.cpp.

{
  if (mLock)
    PR_DestroyLock(mLock);

  // the hashtable contains entries that must be deleted before the arena is
  // destroyed, or else you will have PRLocks undestroyed and other Really
  // Bad Stuff (TM)
  mTable.Clear();

  PL_FinishArenaPool(&mArena);
}

Here is the call graph for this function:


Member Function Documentation

string nsICategoryManager::addCategoryEntry ( in string  aCategory,
in string  aEntry,
in string  aValue,
in boolean  aPersist,
in boolean  aReplace 
) [inherited]

Add an entry to a category.

Parameters:
aCategoryThe name of the category ("protocol")
aEntryThe entry to be added ("http")
aValueThe value for the entry ("moz.httprulez.1")
aPersistShould this data persist between invocations?
aReplaceShould we replace an existing entry?
Returns:
Previous entry, if any

Definition at line 475 of file nsCategoryManager.cpp.

{
  nsCategoryManager* manager = new nsCategoryManager();
  
  if (!manager)
    return nsnull;

  PL_INIT_ARENA_POOL(&(manager->mArena), "CategoryManagerArena",
                     NS_CATEGORYMANAGER_ARENA_SIZE); // this never fails

  if (!manager->mTable.Init()) {
    delete manager;
    return nsnull;
  }

  manager->mLock = PR_NewLock();

  if (!manager->mLock) {
    delete manager;
    return nsnull;
  }

  return manager;
}

Here is the call graph for this function:

void nsICategoryManager::deleteCategory ( in string  aCategory) [inherited]

Delete a category and all entries.

Parameters:
aCategoryThe category to be deleted.
void nsICategoryManager::deleteCategoryEntry ( in string  aCategory,
in string  aEntry,
in boolean  aPersist 
) [inherited]

Delete an entry from the category.

Parameters:
aCategoryThe name of the category ("protocol")
aEntryThe entry to be added ("http")
aPersistDelete persistent data from registry, if present?

Enumerate all existing categories.

Parameters:
aCategoryThe category to be enumerated.
Returns:
a simple enumerator, each result QIs to nsISupportsCString.

Enumerate the entries in a category.

Parameters:
aCategoryThe category to be enumerated.
Returns:
a simple enumerator, each result QIs to nsISupportsCString.
CategoryNode * nsCategoryManager::get_category ( const char *  aName) [inline, private]

Definition at line 514 of file nsCategoryManager.cpp.

                                                 {
  CategoryNode* node;
  if (!mTable.Get(aName, &node)) {
    return nsnull;
  }
  return node;
}

Here is the call graph for this function:

string nsICategoryManager::getCategoryEntry ( in string  aCategory,
in string  aEntry 
) [inherited]

Get the value for the given category's entry.

Parameters:
aCategoryThe name of the category ("protocol")
aEntryThe entry you're looking for ("http")
Returns:
The value.
void nsCategoryManager::NotifyObservers ( const char *  aTopic,
const char *  aCategoryName,
const char *  aEntryName 
) [private]

Definition at line 523 of file nsCategoryManager.cpp.

{
  if (mSuppressNotifications)
    return;

  nsCOMPtr<nsIObserverService> observerService
    (do_GetService("@mozilla.org/observer-service;1"));
  if (!observerService)
    return;

  nsCOMPtr<nsIObserverService> obsProxy;
  NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
                       NS_GET_IID(nsIObserverService),
                       observerService,
                       PROXY_ASYNC,
                       getter_AddRefs(obsProxy));
  if (!obsProxy) return;

  if (aEntryName) {
    nsCOMPtr<nsISupportsCString> entry
      (do_CreateInstance (NS_SUPPORTS_CSTRING_CONTRACTID));
    if (!entry)
      return;

    nsresult rv = entry->SetData(nsDependentCString(aEntryName));
    if (NS_FAILED(rv))
      return;

    obsProxy->NotifyObservers(entry, aTopic,
                              NS_ConvertUTF8toUTF16(aCategoryName).get());
  } else {
    obsProxy->NotifyObservers(this, aTopic,
                              NS_ConvertUTF8toUTF16(aCategoryName).get());
  }
}

Here is the call graph for this function:

Suppress or unsuppress notifications of category changes to the observer service.

This is to be used by nsComponentManagerImpl on startup while reading the stored category list.

Definition at line 756 of file nsCategoryManager.cpp.

{
  mSuppressNotifications = aSuppress;
  return NS_OK;
}

Write the categories to the XPCOM persistent registry.

This is to be used by nsComponentManagerImpl (and NO ONE ELSE).

Definition at line 737 of file nsCategoryManager.cpp.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class nsCategoryManagerFactory [friend]

Definition at line 155 of file nsCategoryManager.h.


Member Data Documentation

Definition at line 165 of file nsCategoryManager.h.

Definition at line 167 of file nsCategoryManager.h.

Definition at line 168 of file nsCategoryManager.h.

Definition at line 166 of file nsCategoryManager.h.


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