Back to index

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

#include <nsCharsetConverterManager.h>

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

List of all members.

Public Member Functions

 nsCharsetConverterManager ()
virtual ~nsCharsetConverterManager ()
nsIUnicodeDecoder getUnicodeDecoder (in string charset)
 Get the Unicode decoder for the given charset.
nsIUnicodeDecoder getUnicodeDecoderRaw (in string charset)
nsIUnicodeEncoder getUnicodeEncoder (in string charset)
 Get the Unicode encoder for the given charset.
nsIUnicodeEncoder getUnicodeEncoderRaw (in string charset)
ACString getCharsetAlias (in string charset)
 A shortcut to calling nsICharsetAlias to do alias resolution.
nsIUTF8StringEnumerator getDecoderList ()
 Get the complete list of available decoders.
nsIUTF8StringEnumerator getEncoderList ()
 Get the complete list of available encoders.
nsIUTF8StringEnumerator GetCharsetDetectorList ()
 Get the complete list of available charset detectors.
AString getCharsetTitle (in string charset)
 Get the human-readable name for the given charset.
AString getCharsetData (in string charset, in wstring prop)
 Get some data about the given charset.
nsIAtom getCharsetLangGroup (in string charset)
 Get the language group for the given charset.
nsIAtom getCharsetLangGroupRaw (in string charset)

Static Public Member Functions

static nsresult RegisterConverterManagerData ()

Private Member Functions

nsresult LoadExtensibleBundle (const char *aRegistryKey, nsIStringBundle **aResult)
nsresult GetBundleValue (nsIStringBundle *aBundle, const char *aName, const nsAFlatString &aProp, PRUnichar **aResult)
nsresult GetBundleValue (nsIStringBundle *aBundle, const char *aName, const nsAFlatString &aProp, nsAString &aResult)
nsresult GetList (const nsACString &aCategory, const nsACString &aPrefix, nsIUTF8StringEnumerator **aResult)

Static Private Member Functions

static nsresult RegisterConverterCategory (nsICategoryManager *, const char *aCategory, const char *aURL)

Private Attributes

nsIStringBundlemDataBundle
nsIStringBundlemTitleBundle

Detailed Description

Definition at line 49 of file nsCharsetConverterManager.h.


Constructor & Destructor Documentation


Member Function Documentation

nsresult nsCharsetConverterManager::GetBundleValue ( nsIStringBundle aBundle,
const char *  aName,
const nsAFlatString aProp,
PRUnichar **  aResult 
) [private]

Definition at line 134 of file nsCharsetConverterManager.cpp.

{
  nsAutoString key; 

  key.AssignWithConversion(aName);
  ToLowerCase(key); // we lowercase the main comparison key
  key.Append(aProp);

  return aBundle->GetStringFromName(key.get(), aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsCharsetConverterManager::GetBundleValue ( nsIStringBundle aBundle,
const char *  aName,
const nsAFlatString aProp,
nsAString &  aResult 
) [private]

Definition at line 148 of file nsCharsetConverterManager.cpp.

{
  nsresult rv = NS_OK;

  nsXPIDLString value;
  rv = GetBundleValue(aBundle, aName, aProp, getter_Copies(value));
  if (NS_FAILED(rv))
    return rv;

  aResult = value;

  return NS_OK;
}

Here is the call graph for this function:

ACString nsICharsetConverterManager::getCharsetAlias ( in string  charset) [inherited]

A shortcut to calling nsICharsetAlias to do alias resolution.

AString nsICharsetConverterManager::getCharsetData ( in string  charset,
in wstring  prop 
) [inherited]

Get some data about the given charset.

This includes whether the character encoding may be used for certain purposes, if it is multi-byte, and the language code for it. See charsetData.properties for the source of this data. Some known property names: notForBrowser - not to be used in the bowser. notForOutgoing - not to be used for exporting files. LangGroup - language code for charset, e.g. 'he' and 'zh-CN'. isMultibyte - is this a multi-byte charset?

Parameters:
charsetname of the character encoding, e.g. 'iso-8859-15'.
propproperty desired for the character encoding.
Returns:
the value of the property, for the character encoding.

Get the complete list of available charset detectors.

Get the language group for the given charset.

This is similar to calling getCharsetData with the prop "LangGroup".

Parameters:
charsetname of the character encoding, e.g. 'iso-8859-15'.
Returns:
the language code for the character encoding.
AString nsICharsetConverterManager::getCharsetTitle ( in string  charset) [inherited]

Get the human-readable name for the given charset.

Get the complete list of available decoders.

Get the complete list of available encoders.

nsresult nsCharsetConverterManager::GetList ( const nsACString &  aCategory,
const nsACString &  aPrefix,
nsIUTF8StringEnumerator **  aResult 
) [private]

Definition at line 291 of file nsCharsetConverterManager.cpp.

{
  if (aResult == NULL) 
    return NS_ERROR_NULL_POINTER;
  *aResult = NULL;

  nsresult rv;
  nsCAutoString alias;

  nsCStringArray* array = new nsCStringArray;
  if (!array)
    return NS_ERROR_OUT_OF_MEMORY;

  nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
  if (NS_FAILED(rv))
    return rv;
  
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  catman->EnumerateCategory(PromiseFlatCString(aCategory).get(), 
                            getter_AddRefs(enumerator));

  PRBool hasMore;
  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
    nsCOMPtr<nsISupports> supports;
    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(supports))))
      continue;
    
    nsCOMPtr<nsISupportsCString> supStr = do_QueryInterface(supports);
    if (!supStr)
      continue;

    nsCAutoString fullName(aPrefix);
    
    nsCAutoString name;
    if (NS_FAILED(supStr->GetData(name)))
      continue;

    fullName += name;
    rv = GetCharsetAlias(fullName.get(), alias);
    if (NS_FAILED(rv)) 
      continue;

    rv = array->AppendCString(alias);
  }
    
  return NS_NewAdoptingUTF8StringEnumerator(aResult, array);
}

Here is the call graph for this function:

Get the Unicode decoder for the given charset.

The "Raw" version skips charset alias resolution

Get the Unicode encoder for the given charset.

The "Raw" version skips charset alias resolution

nsresult nsCharsetConverterManager::LoadExtensibleBundle ( const char *  aRegistryKey,
nsIStringBundle **  aResult 
) [private]

Definition at line 120 of file nsCharsetConverterManager.cpp.

{
  nsresult rv = NS_OK;

  nsCOMPtr<nsIStringBundleService> sbServ = 
           do_GetService(kStringBundleServiceCID, &rv);
  if (NS_FAILED(rv))
    return rv;

  return sbServ->CreateExtensibleBundle(aCategory, aResult);
}

Here is the call graph for this function:

nsresult nsCharsetConverterManager::RegisterConverterCategory ( nsICategoryManager catman,
const char *  aCategory,
const char *  aURL 
) [static, private]

Definition at line 112 of file nsCharsetConverterManager.cpp.

{
  return catman->AddCategoryEntry(aCategory, aURL, "",
                                  PR_TRUE, PR_TRUE, nsnull);
}

Here is the caller graph for this function:

Definition at line 96 of file nsCharsetConverterManager.cpp.

{
  nsresult rv;
  nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
  if (NS_FAILED(rv))
    return rv;

  RegisterConverterCategory(catman, NS_TITLE_BUNDLE_CATEGORY,
                            "chrome://global/locale/charsetTitles.properties");
  RegisterConverterCategory(catman, NS_DATA_BUNDLE_CATEGORY,
                            "resource://gre/res/charsetData.properties");

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 61 of file nsCharsetConverterManager.h.

Definition at line 62 of file nsCharsetConverterManager.h.


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