зеркало из https://github.com/mozilla/gecko-dev.git
Bug 110486
Removing NSGetFactory from UCONV /r=shanjian; /sr=brendan
This commit is contained in:
Родитель
a56bdfcf11
Коммит
f592983723
|
@ -64,11 +64,11 @@ class nsICharsetAlias : public nsISupports
|
|||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICHARSETALIAS_IID)
|
||||
|
||||
NS_IMETHOD GetPreferred(const nsAString& aAlias, nsAString& aResult) = 0;
|
||||
NS_IMETHOD GetPreferred(const nsAReadableString& aAlias, nsAWritableString& aResult) = 0;
|
||||
NS_IMETHOD GetPreferred(const PRUnichar* aAlias, const PRUnichar** aResult) = 0;
|
||||
NS_IMETHOD GetPreferred(const char* aAlias, char* aResult, PRInt32 aBufLength) = 0;
|
||||
|
||||
NS_IMETHOD Equals(const nsAString& aCharset1, const nsAString& aCharset2, PRBool* aResult) = 0;
|
||||
NS_IMETHOD Equals(const nsAReadableString& aCharset1, const nsAReadableString& aCharset2, PRBool* aResult) = 0;
|
||||
NS_IMETHOD Equals(const PRUnichar* aCharset1, const PRUnichar* aCharset2, PRBool* aResult) = 0;
|
||||
NS_IMETHOD Equals(const char* aCharset1, const char* aCharset2, PRBool* aResult) = 0;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPLATFORMCHARSET_IID)
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult) = 0;
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult) = 0;
|
||||
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue) = 0;
|
||||
|
||||
|
|
|
@ -39,31 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsCP1252ToUnicode.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewCP1252ToUnicode(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsCP1252ToUnicode * inst = new nsCP1252ToUnicode();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsCharsetAlias_h__
|
||||
#define nsCharsetAlias_h__
|
||||
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsURLProperties.h"
|
||||
|
||||
//==============================================================
|
||||
class nsCharsetAlias2 : public nsICharsetAlias
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsCharsetAlias2();
|
||||
virtual ~nsCharsetAlias2();
|
||||
|
||||
NS_IMETHOD GetPreferred(const nsAReadableString& aAlias, nsAWritableString& oResult);
|
||||
NS_IMETHOD GetPreferred(const PRUnichar* aAlias, const PRUnichar** oResult) ;
|
||||
NS_IMETHOD GetPreferred(const char* aAlias, char* oResult, PRInt32 aBufLength) ;
|
||||
|
||||
NS_IMETHOD Equals(const nsAReadableString& aCharset1, const nsAReadableString& aCharset2, PRBool* oResult) ;
|
||||
NS_IMETHOD Equals(const PRUnichar* aCharset1, const PRUnichar* aCharset2, PRBool* oResult) ;
|
||||
NS_IMETHOD Equals(const char* aCharset1, const char* aCharset2, PRBool* oResult) ;
|
||||
|
||||
private:
|
||||
nsURLProperties* mDelegate;
|
||||
};
|
||||
|
||||
#endif // nsCharsetAlias_h__
|
||||
|
||||
|
|
@ -51,27 +51,7 @@
|
|||
#include "nsUnicharUtils.h"
|
||||
#include "nsURLProperties.h"
|
||||
#include "nsITimelineService.h"
|
||||
//==============================================================
|
||||
class nsCharsetAlias2 : public nsICharsetAlias
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsCharsetAlias2();
|
||||
virtual ~nsCharsetAlias2();
|
||||
|
||||
NS_IMETHOD GetPreferred(const nsAString& aAlias, nsAString& oResult);
|
||||
NS_IMETHOD GetPreferred(const PRUnichar* aAlias, const PRUnichar** oResult) ;
|
||||
NS_IMETHOD GetPreferred(const char* aAlias, char* oResult, PRInt32 aBufLength) ;
|
||||
|
||||
NS_IMETHOD Equals(const nsAString& aCharset1, const nsAString& aCharset2, PRBool* oResult) ;
|
||||
NS_IMETHOD Equals(const PRUnichar* aCharset1, const PRUnichar* aCharset2, PRBool* oResult) ;
|
||||
NS_IMETHOD Equals(const char* aCharset1, const char* aCharset2, PRBool* oResult) ;
|
||||
|
||||
private:
|
||||
nsURLProperties* mDelegate;
|
||||
};
|
||||
#include "nsCharsetAlias.h"
|
||||
|
||||
//--------------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS1(nsCharsetAlias2, nsICharsetAlias);
|
||||
|
@ -89,7 +69,7 @@ nsCharsetAlias2::~nsCharsetAlias2()
|
|||
delete mDelegate;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsAString& aAlias, nsAString& oResult)
|
||||
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsAReadableString& aAlias, nsAWritableString& oResult)
|
||||
{
|
||||
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
|
||||
NS_TIMELINE_START_TIMER("nsCharsetAlias2:GetPreferred");
|
||||
|
@ -117,10 +97,9 @@ NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsAString& aAlias, nsAString&
|
|||
return NS_OK;
|
||||
}
|
||||
//load charsetalias.properties string bundle with all remaining aliases
|
||||
nsAutoString propertyURL; propertyURL.AssignWithConversion("resource:/res/charsetalias.properties");
|
||||
// we may need to protect the following section with a lock so we won't call the
|
||||
// 'new nsURLProperties' from two different threads
|
||||
mDelegate = new nsURLProperties( propertyURL );
|
||||
mDelegate = new nsURLProperties( NS_LITERAL_STRING("resource:/res/charsetalias.properties") );
|
||||
NS_ASSERTION(mDelegate, "cannot create nsURLProperties");
|
||||
if(nsnull == mDelegate)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -144,7 +123,7 @@ NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const char* aAlias, char* oResult, P
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
NS_IMETHODIMP nsCharsetAlias2::Equals(const nsAString& aCharset1, const nsAString& aCharset2, PRBool* oResult)
|
||||
NS_IMETHODIMP nsCharsetAlias2::Equals(const nsAReadableString& aCharset1, const nsAReadableString& aCharset2, PRBool* oResult)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
|
@ -185,29 +164,3 @@ NS_IMETHODIMP nsCharsetAlias2::Equals(const char* aCharset1, const char* aCharse
|
|||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewCharsetAlias(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsCharsetAlias2* inst = new nsCharsetAlias2();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
// just for CIDs
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsCharsetConverterManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kRegistryNodeIID, NS_IREGISTRYNODE_IID);
|
||||
static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||
|
@ -65,138 +66,7 @@ static NS_DEFINE_CID(kSupportsArrayCID, NS_SUPPORTSARRAY_CID);
|
|||
// Pattern of cached, commonly used, single byte decoder
|
||||
#define NS_1BYTE_CODER_PATTERN "ISO-8859"
|
||||
#define NS_1BYTE_CODER_PATTERN_LEN 8
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsCharsetConverterManager [declaration]
|
||||
|
||||
/**
|
||||
* The actual implementation of the nsICharsetConverterManager2 interface. It
|
||||
* alsoimplements the soon to be deprecated nsICharsetConverterManager.
|
||||
*
|
||||
* XXX completely deprecate the nsICharsetConverterManager interface
|
||||
* XXX optimise the memory allocations in "scriptable" and "friendly" methods
|
||||
*
|
||||
* @created 15/Nov/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsCharsetConverterManager : public nsICharsetConverterManager,
|
||||
public nsICharsetConverterManager2
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
|
||||
nsIStringBundle * mDataBundle;
|
||||
nsIStringBundle * mTitleBundle;
|
||||
|
||||
nsresult LoadExtensibleBundle(const char * aRegistryKey,
|
||||
nsIStringBundle ** aResult);
|
||||
|
||||
static nsresult RegisterConverterTitles(nsIRegistry * aRegistry,
|
||||
const char * aRegistryPath);
|
||||
|
||||
static nsresult RegisterConverterData(nsIRegistry * aRegistry,
|
||||
const char * aRegistryPath);
|
||||
|
||||
nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName,
|
||||
const nsAFlatString& aProp, PRUnichar ** aResult);
|
||||
|
||||
nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName,
|
||||
const nsAFlatString& aProp, nsIAtom ** aResult);
|
||||
|
||||
nsresult GetRegistryEnumeration(const char * aRegistryKey,
|
||||
const char * aAddPrefix, nsISupportsArray ** aArray);
|
||||
|
||||
nsresult GetRegistryEnumeration2(const char * aRegistryKey, PRBool aDecoder,
|
||||
nsISupportsArray ** aArray);
|
||||
|
||||
public:
|
||||
|
||||
nsCharsetConverterManager();
|
||||
virtual ~nsCharsetConverterManager();
|
||||
|
||||
static nsresult RegisterConverterManagerData();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Interface nsICharsetConverterManager [declaration]
|
||||
|
||||
NS_IMETHOD GetUnicodeEncoder(const nsString * aDest,
|
||||
nsIUnicodeEncoder ** aResult);
|
||||
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
||||
nsIUnicodeDecoder ** aResult);
|
||||
|
||||
NS_IMETHOD GetCharsetLangGroup(nsString * aCharset, nsIAtom ** aResult);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Interface nsICharsetConverterManager2 [declaration]
|
||||
|
||||
NS_IMETHOD GetUnicodeDecoder(const nsIAtom * aCharset,
|
||||
nsIUnicodeDecoder ** aResult);
|
||||
NS_IMETHOD GetUnicodeEncoder(const nsIAtom * aCharset,
|
||||
nsIUnicodeEncoder ** aResult);
|
||||
|
||||
NS_IMETHOD GetDecoderList(nsISupportsArray ** aResult);
|
||||
NS_IMETHOD GetEncoderList(nsISupportsArray ** aResult);
|
||||
NS_IMETHOD GetCharsetDetectorList(nsISupportsArray ** aResult);
|
||||
|
||||
NS_IMETHOD GetCharsetAtom(const PRUnichar * aCharset, nsIAtom ** aResult);
|
||||
NS_IMETHOD GetCharsetAtom2(const char * aCharset, nsIAtom ** aResult);
|
||||
NS_IMETHOD GetCharsetTitle(const nsIAtom * aCharset, PRUnichar ** aResult);
|
||||
NS_IMETHOD GetCharsetTitle2(const nsIAtom * aCharset, nsString * aResult);
|
||||
NS_IMETHOD GetCharsetData(const nsIAtom * aCharset, const PRUnichar * aProp,
|
||||
PRUnichar ** aResult);
|
||||
NS_IMETHOD GetCharsetData2(const nsIAtom * aCharset, const PRUnichar * aProp,
|
||||
nsString * aResult);
|
||||
NS_IMETHOD GetCharsetLangGroup(const nsIAtom * aCharset, nsIAtom ** aResult);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global functions and data [implementation]
|
||||
|
||||
NS_IMETHODIMP NS_NewCharsetConverterManager(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsCharsetConverterManager * inst = new nsCharsetConverterManager();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_RegisterConverterManagerData(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char *aLocation,
|
||||
const char *aType,
|
||||
const nsModuleComponentInfo* aInfo)
|
||||
{
|
||||
return nsCharsetConverterManager::RegisterConverterManagerData();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_UnregisterConverterManagerData(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const nsModuleComponentInfo* aInfo)
|
||||
{
|
||||
// XXX TODO remove converter manager cruft
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsCharsetConverterManager [implementation]
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsCharsetConverterManager,
|
||||
|
@ -561,8 +431,6 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetLangGroup(
|
|||
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||
*aResult = NULL;
|
||||
|
||||
nsAutoString prop; prop.AssignWithConversion(".LangGroup");
|
||||
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
nsresult res = GetCharsetAtom(aCharset->get(), getter_AddRefs(atom));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -571,9 +439,6 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetLangGroup(
|
|||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Interface nsICharsetConverterManager2 [implementation]
|
||||
|
||||
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeDecoder(
|
||||
const nsIAtom * aCharset,
|
||||
nsIUnicodeDecoder ** aResult)
|
||||
|
@ -685,7 +550,6 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle(
|
|||
*aResult = NULL;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsAutoString prop; prop.AssignWithConversion(".title");
|
||||
|
||||
if (mTitleBundle == NULL) {
|
||||
res = LoadExtensibleBundle(NS_TITLE_BUNDLE_REGISTRY_KEY, &mTitleBundle);
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsCharsetConverterManager_h__
|
||||
#define nsCharsetConverterManager_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIRegistry.h"
|
||||
|
||||
class nsCharsetConverterManager : public nsICharsetConverterManager,
|
||||
public nsICharsetConverterManager2
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICHARSETCONVERTERMANAGER2
|
||||
|
||||
public:
|
||||
|
||||
nsCharsetConverterManager();
|
||||
virtual ~nsCharsetConverterManager();
|
||||
|
||||
NS_IMETHOD GetUnicodeEncoder(const nsString * aDest,
|
||||
nsIUnicodeEncoder ** aResult);
|
||||
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
||||
nsIUnicodeDecoder ** aResult);
|
||||
NS_IMETHOD GetCharsetLangGroup(nsString * aCharset, nsIAtom ** aResult);
|
||||
|
||||
private:
|
||||
|
||||
nsIStringBundle * mDataBundle;
|
||||
nsIStringBundle * mTitleBundle;
|
||||
|
||||
nsresult LoadExtensibleBundle(const char * aRegistryKey,
|
||||
nsIStringBundle ** aResult);
|
||||
|
||||
static nsresult RegisterConverterTitles(nsIRegistry * aRegistry,
|
||||
const char * aRegistryPath);
|
||||
|
||||
static nsresult RegisterConverterData(nsIRegistry * aRegistry,
|
||||
const char * aRegistryPath);
|
||||
|
||||
nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName,
|
||||
const nsAFlatString& aProp, PRUnichar ** aResult);
|
||||
|
||||
nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName,
|
||||
const nsAFlatString& aProp, nsIAtom ** aResult);
|
||||
|
||||
nsresult GetRegistryEnumeration(const char * aRegistryKey, const char * aAddPrefix,
|
||||
nsISupportsArray ** aArray);
|
||||
|
||||
nsresult GetRegistryEnumeration2(const char * aRegistryKey, PRBool aDecoder,
|
||||
nsISupportsArray ** aArray);
|
||||
|
||||
public:
|
||||
static nsresult RegisterConverterManagerData();
|
||||
|
||||
};
|
||||
|
||||
#endif // nsCharsetConverterManager_h__
|
||||
|
||||
|
|
@ -39,30 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsISO88591ToUnicode.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewISO88591ToUnicode(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsISO88591ToUnicode * inst = new nsISO88591ToUnicode();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -46,36 +46,19 @@
|
|||
#include "nsIMacLocale.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsPlatformCharset.h"
|
||||
|
||||
static nsURLProperties *gInfo = nsnull;
|
||||
static PRInt32 gCnt = 0;
|
||||
|
||||
class nsMacCharset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_ISUPPORTS1(nsPlatformCharset, nsIPlatformCharset);
|
||||
|
||||
public:
|
||||
|
||||
nsMacCharset();
|
||||
virtual ~nsMacCharset();
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue);
|
||||
|
||||
private:
|
||||
nsresult InitInfo();
|
||||
nsresult MapToCharset(short script, short region, nsString& outCharset);
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMacCharset, nsIPlatformCharset);
|
||||
|
||||
nsMacCharset::nsMacCharset()
|
||||
nsPlatformCharset::nsPlatformCharset()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&gCnt);
|
||||
}
|
||||
nsMacCharset::~nsMacCharset()
|
||||
nsPlatformCharset::~nsPlatformCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&gCnt);
|
||||
if((0 == gCnt) && (nsnull != gInfo)) {
|
||||
|
@ -84,14 +67,11 @@ nsMacCharset::~nsMacCharset()
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsMacCharset::InitInfo()
|
||||
nsresult nsPlatformCharset::InitInfo()
|
||||
{
|
||||
// load the .property file if necessary
|
||||
if (gInfo == nsnull) {
|
||||
|
||||
nsAutoString propertyURL(NS_LITERAL_STRING("resource:/res/maccharset.properties"));
|
||||
|
||||
nsURLProperties *info = new nsURLProperties( propertyURL );
|
||||
nsURLProperties *info = new nsURLProperties( NS_LITERAL_STRING("resource:/res/maccharset.properties") );
|
||||
NS_ASSERTION(info , "cannot open properties file");
|
||||
NS_ENSURE_TRUE(info, NS_ERROR_FAILURE);
|
||||
gInfo = info;
|
||||
|
@ -100,7 +80,7 @@ nsresult nsMacCharset::InitInfo()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMacCharset::MapToCharset(short script, short region, nsString& outCharset)
|
||||
nsresult nsPlatformCharset::MapToCharset(short script, short region, nsAWritableString& outCharset)
|
||||
{
|
||||
switch (region) {
|
||||
case verUS:
|
||||
|
@ -123,12 +103,12 @@ nsresult nsMacCharset::MapToCharset(short script, short region, nsString& outCha
|
|||
|
||||
rv = gInfo->Get(key, outCharset);
|
||||
if (NS_FAILED(rv)) {
|
||||
key.AssignWithConversion("script.");
|
||||
key.Assign(NS_LITERAL_STRING("script."));
|
||||
key.AppendInt(script, 10);
|
||||
rv = gInfo->Get(key, outCharset);
|
||||
// not found in the .property file, assign x-mac-roman
|
||||
if (NS_FAILED(rv)) {
|
||||
outCharset.AssignWithConversion("x-mac-roman");
|
||||
outCharset.Assign(NS_LITERAL_STRING("x-mac-roman"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +116,7 @@ nsresult nsMacCharset::MapToCharset(short script, short region, nsString& outCha
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult)
|
||||
{
|
||||
if (mCharset.IsEmpty()) {
|
||||
nsresult rv = MapToCharset((short)(0x0000FFFF & ::GetScriptManagerVariable(smSysScript)),
|
||||
|
@ -150,7 +130,7 @@ nsMacCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
nsPlatformCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
{
|
||||
nsCOMPtr<nsIMacLocale> pMacLocale;
|
||||
nsAutoString localeAsString(localeName), charset(NS_LITERAL_STRING("x-mac-roman"));
|
||||
|
@ -170,29 +150,32 @@ nsMacCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar*
|
|||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewPlatformCharset(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
NS_IMETHODIMP
|
||||
nsPlatformCharset::Init()
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsMacCharset* inst = new nsMacCharset();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(nsString& inANSICodePage, nsAWritableString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsAWritableString &oString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsAWritableString& oResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,30 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsMacRomanToUnicode.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewMacRomanToUnicode(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsMacRomanToUnicode * inst = new nsMacRomanToUnicode();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -32,28 +32,14 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsPlatformCharset.h"
|
||||
|
||||
static nsURLProperties *gInfo = nsnull;
|
||||
static PRInt32 gCnt= 0;
|
||||
|
||||
class nsOS2Charset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_ISUPPORTS1(PlatformCharset, nsIPlatformCharset);
|
||||
|
||||
public:
|
||||
|
||||
nsOS2Charset();
|
||||
virtual ~nsOS2Charset();
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue);
|
||||
private:
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsOS2Charset, nsIPlatformCharset);
|
||||
|
||||
nsOS2Charset::nsOS2Charset()
|
||||
PlatformCharset::PlatformCharset()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&gCnt); // count for gInfo
|
||||
|
@ -61,132 +47,96 @@ nsOS2Charset::nsOS2Charset()
|
|||
// XXX We should make the following block critical section
|
||||
if(nsnull == gInfo)
|
||||
{
|
||||
nsAutoString propertyURL; propertyURL.AssignWithConversion("resource:/res/os2charset.properties");
|
||||
|
||||
nsURLProperties *info = new nsURLProperties( propertyURL );
|
||||
NS_ASSERTION( info , " cannot create nsURLProperties");
|
||||
gInfo = info;
|
||||
nsURLProperties *info = new nsURLProperties(NS_LITERAL_STRING("resource:/res/os2charset.properties"));
|
||||
NS_ASSERTION( info , " cannot create nsURLProperties");
|
||||
gInfo = info;
|
||||
}
|
||||
NS_ASSERTION(gInfo, "Cannot open property file");
|
||||
if( gInfo )
|
||||
{
|
||||
UINT acp = ::WinQueryCp(HMQ_CURRENT);
|
||||
PRInt32 acpint = (PRInt32)(acp & 0x00FFFF);
|
||||
nsAutoString acpKey; acpKey.AssignWithConversion("os2.");
|
||||
nsAutoString acpKey; acpKey.Assign(NS_LITERAL_STRING("os2."));
|
||||
acpKey.AppendInt(acpint, 10);
|
||||
|
||||
nsresult res = gInfo->Get(acpKey, mCharset);
|
||||
if(NS_FAILED(res)) {
|
||||
mCharset.AssignWithConversion("IBM850");
|
||||
mCharset.Assign(NS_LITERAL_STRING("IBM850"));
|
||||
}
|
||||
|
||||
} else {
|
||||
mCharset.AssignWithConversion("IBM850");
|
||||
mCharset.Assign(NS_LITERAL_STRING("IBM850"));
|
||||
}
|
||||
}
|
||||
|
||||
nsOS2Charset::~nsOS2Charset()
|
||||
PlatformCharset::~PlatformCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&gCnt);
|
||||
if(0 == gCnt) {
|
||||
delete gInfo;
|
||||
gInfo = nsnull;
|
||||
delete gInfo;
|
||||
gInfo = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOS2Charset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
PlatformCharset::GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult)
|
||||
{
|
||||
if (selector == kPlatformCharsetSel_4xBookmarkFile) {
|
||||
if ((mCharset.Find("IBM850", IGNORE_CASE) != -1) || (mCharset.Find("IBM437", IGNORE_CASE) != -1))
|
||||
oResult.AssignWithConversion("ISO-8859-1");
|
||||
else if (mCharset.Find("IBM852", IGNORE_CASE) != -1)
|
||||
oResult.AssignWithConversion("windows-1250");
|
||||
else if ((mCharset.Find("IBM855", IGNORE_CASE) != -1) || (mCharset.Find("IBM866", IGNORE_CASE) != -1))
|
||||
oResult.AssignWithConversion("windows-1251");
|
||||
else if ((mCharset.Find("IBM869", IGNORE_CASE) != -1) || (mCharset.Find("IBM813", IGNORE_CASE) != -1))
|
||||
oResult.AssignWithConversion("windows-1253");
|
||||
else if (mCharset.Find("IBM857", IGNORE_CASE) != -1)
|
||||
oResult.AssignWithConversion("windows-1254");
|
||||
else
|
||||
oResult = mCharset;
|
||||
} else {
|
||||
if (selector == kPlatformCharsetSel_4xBookmarkFile) {
|
||||
if ((mCharset.Find("IBM850", IGNORE_CASE) != -1) || (mCharset.Find("IBM437", IGNORE_CASE) != -1))
|
||||
oResult.Assign(NS_LITERAL_STRING("ISO-8859-1"));
|
||||
else if (mCharset.Find("IBM852", IGNORE_CASE) != -1)
|
||||
oResult.Assign(NS_LITERAL_STRING("windows-1250"));
|
||||
else if ((mCharset.Find("IBM855", IGNORE_CASE) != -1) || (mCharset.Find("IBM866", IGNORE_CASE) != -1))
|
||||
oResult.Assign(NS_LITERAL_STRING("windows-1251"));
|
||||
else if ((mCharset.Find("IBM869", IGNORE_CASE) != -1) || (mCharset.Find("IBM813", IGNORE_CASE) != -1))
|
||||
oResult.Assign(NS_LITERAL_STRING("windows-1253"));
|
||||
else if (mCharset.Find("IBM857", IGNORE_CASE) != -1)
|
||||
oResult.Assign(NS_LITERAL_STRING("windows-1254"));
|
||||
else
|
||||
oResult = mCharset;
|
||||
}
|
||||
return NS_OK;
|
||||
} else {
|
||||
oResult = mCharset;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsOS2CharsetFactory : public nsIFactory {
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
nsOS2CharsetFactory() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
virtual ~nsOS2CharsetFactory() {
|
||||
}
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1( nsOS2CharsetFactory , nsIFactory)
|
||||
|
||||
NS_IMETHODIMP nsOS2CharsetFactory::CreateInstance(
|
||||
nsISupports* aDelegate, const nsIID &aIID, void** aResult)
|
||||
NS_IMETHODIMP
|
||||
nsPlatformCharset::Init()
|
||||
{
|
||||
if( !aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if( aDelegate)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = NULL;
|
||||
nsISupports *inst = new nsOS2Charset;
|
||||
if( !inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res =inst->QueryInterface(aIID, aResult);
|
||||
if(NS_FAILED(res))
|
||||
delete inst;
|
||||
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsOS2CharsetFactory::LockFactory(PRBool aLock)
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(short script, short region, nsAWritableString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOS2Charset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(nsString& inANSICodePage, nsAWritableString& outCharset)
|
||||
{
|
||||
// OS2TODO
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewPlatformCharset(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsAWritableString &oString)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsOS2Charset* inst = new nsOS2Charset();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsAWritableString& oResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitInfo()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsPlatformCharset_h__
|
||||
#define nsPlatformCharset_h__
|
||||
|
||||
#include "nsIPlatformCharset.h"
|
||||
|
||||
class nsPlatformCharset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsPlatformCharset();
|
||||
virtual ~nsPlatformCharset();
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult);
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue);
|
||||
|
||||
private:
|
||||
nsString mCharset;
|
||||
nsString mLocale; // remember the locale & charset
|
||||
|
||||
nsresult InitInfo();
|
||||
nsresult MapToCharset(short script, short region, nsAWritableString& outCharset);
|
||||
nsresult MapToCharset(nsString& inANSICodePage, nsAWritableString& outCharset);
|
||||
nsresult InitGetCharset(nsAWritableString& oString);
|
||||
nsresult ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsAWritableString& oResult);
|
||||
nsresult VerifyCharset(nsString &aCharset);
|
||||
};
|
||||
|
||||
#endif // nsPlatformCharset_h__
|
||||
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
#ifndef __nsScriptableUConv_h_
|
||||
#define __nsScriptableUConv_h_
|
||||
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIScriptableUConv.h"
|
||||
|
||||
class nsScriptableUnicodeConverter : public nsIScriptableUnicodeConverter
|
||||
|
|
|
@ -44,18 +44,11 @@
|
|||
#include "nsUConvDll.h"
|
||||
#include "nsEscape.h"
|
||||
#include "prmem.h"
|
||||
#include "nsTextToSubURI.h"
|
||||
|
||||
static NS_DEFINE_CID(kITextToSubURIIID, NS_ITEXTTOSUBURI_IID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
class nsTextToSubURI: public nsITextToSubURI {
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
nsTextToSubURI();
|
||||
virtual ~nsTextToSubURI();
|
||||
NS_DECL_NSITEXTTOSUBURI
|
||||
};
|
||||
|
||||
nsTextToSubURI::nsTextToSubURI()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -164,28 +157,3 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewTextToSubURI(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsTextToSubURI* inst = new nsTextToSubURI();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsTextToSubURI_h__
|
||||
#define nsTextToSubURI_h__
|
||||
|
||||
#include "nsITextToSubURI.h"
|
||||
|
||||
//==============================================================
|
||||
class nsTextToSubURI: public nsITextToSubURI {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITEXTTOSUBURI
|
||||
|
||||
public:
|
||||
nsTextToSubURI();
|
||||
virtual ~nsTextToSubURI();
|
||||
};
|
||||
|
||||
#endif // nsTextToSubURI_h__
|
||||
|
|
@ -60,201 +60,3 @@
|
|||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
static NS_DEFINE_CID(kTextToSubURICID, NS_TEXTTOSUBURI_CID);
|
||||
|
||||
PRInt32 g_InstanceCount = 0;
|
||||
PRInt32 g_LockCount = 0;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [implementation]
|
||||
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (aFactory == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aFactory = NULL;
|
||||
// the converter manager
|
||||
if (aClass.Equals(kCharsetConverterManagerCID)) {
|
||||
nsManagerFactory *factory = new nsManagerFactory();
|
||||
|
||||
if(nsnull == factory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// the Unicode Decode helper
|
||||
if (aClass.Equals(kUnicodeDecodeHelperCID)) {
|
||||
nsDecodeHelperFactory *factory = new nsDecodeHelperFactory();
|
||||
if(nsnull == factory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// the Unicode Encode helper
|
||||
if (aClass.Equals(kUnicodeEncodeHelperCID)) {
|
||||
nsEncodeHelperFactory *factory = new nsEncodeHelperFactory();
|
||||
if(nsnull == factory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (aClass.Equals(kPlatformCharsetCID)) {
|
||||
nsIFactory *factory = NEW_PLATFORMCHARSETFACTORY();
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (aClass.Equals(kCharsetAliasCID)) {
|
||||
nsIFactory *factory = NEW_CHARSETALIASFACTORY();
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (aClass.Equals(kTextToSubURICID)) {
|
||||
nsIFactory *factory = NEW_TEXTTOSUBURI_FACTORY();
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kUnicodeDecodeHelperCID,
|
||||
"Unicode Decode Helper",
|
||||
NS_UNICODEDECODEHELPER_CONTRACTID,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kUnicodeEncodeHelperCID,
|
||||
"Unicode Encode Helper",
|
||||
NS_UNICODEENCODEHELPER_CONTRACTID,
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kCharsetAliasCID,
|
||||
"Charset Alias Information",
|
||||
NS_CHARSETALIAS_CONTRACTID,
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kTextToSubURICID,
|
||||
"Text To Sub URI Helper",
|
||||
NS_ITEXTTOSUBURI_CONTRACTID,
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kCharsetConverterManagerCID,
|
||||
"Charset Conversion Manager",
|
||||
NS_CHARSETCONVERTERMANAGER_CONTRACTID,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kPlatformCharsetCID,
|
||||
"Platform Charset Information",
|
||||
NS_PLATFORMCHARSET_CONTRACTID,
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kUnicodeDecodeHelperCID, path);
|
||||
if(NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kUnicodeEncodeHelperCID, path);
|
||||
if(NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kCharsetAliasCID, path);
|
||||
if(NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kTextToSubURICID, path);
|
||||
if(NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kCharsetConverterManagerCID, path);
|
||||
if(NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kPlatformCharsetCID, path);
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -44,75 +44,4 @@ class nsIComponentManager;
|
|||
class nsIFile;
|
||||
struct nsModuleComponentInfo;
|
||||
|
||||
// Factory methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewCharsetConverterManager(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeDecodeHelper(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeEncodeHelper(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewPlatformCharset(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewCharsetAlias(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewTextToSubURI(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_RegisterConverterManagerData(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char *aLocation,
|
||||
const char *aType,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_UnregisterConverterManagerData(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewISO88591ToUnicode(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewCP1252ToUnicode(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewMacRomanToUnicode(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUTF8ToUnicode(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeToISO88591(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeToCP1252(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeToMacRoman(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeToUTF8(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aResult);
|
||||
|
||||
#endif /* nsUConvDll_h___ */
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
|
@ -55,6 +56,12 @@
|
|||
#include "nsConverterInputStream.h"
|
||||
|
||||
#include "nsUCvMinSupport.h"
|
||||
#include "nsCharsetConverterManager.h"
|
||||
#include "nsUnicodeDecodeHelper.h"
|
||||
#include "nsUnicodeEncodeHelper.h"
|
||||
#include "nsPlatformCharset.h"
|
||||
#include "nsCharsetAlias.h"
|
||||
#include "nsTextToSubURI.h"
|
||||
#include "nsISO88591ToUnicode.h"
|
||||
#include "nsCP1252ToUnicode.h"
|
||||
#include "nsMacRomanToUnicode.h"
|
||||
|
@ -65,160 +72,135 @@
|
|||
#include "nsUnicodeToUTF8.h"
|
||||
#include "nsScriptableUConv.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
NS_IMPL_NSUCONVERTERREGSELF
|
||||
|
||||
/**
|
||||
* Extra information about charset converters that is stored in the
|
||||
* component registry.
|
||||
*/
|
||||
struct ConverterInfo {
|
||||
nsCID mCID;
|
||||
const char* mSource;
|
||||
const char* mDestination;
|
||||
};
|
||||
|
||||
static ConverterInfo gConverterInfo[] = {
|
||||
{ NS_ISO88591TOUNICODE_CID, "ISO-8859-1", "Unicode" },
|
||||
{ NS_CP1252TOUNICODE_CID, "windows-1252", "Unicode" },
|
||||
{ NS_MACROMANTOUNICODE_CID, "x-mac-roman", "Unicode" },
|
||||
{ NS_UTF8TOUNICODE_CID, "UTF-8", "Unicode" },
|
||||
{ NS_UNICODETOISO88591_CID, "Unicode", "ISO-8859-1" },
|
||||
{ NS_UNICODETOCP1252_CID, "Unicode", "windows-1252" },
|
||||
{ NS_UNICODETOMACROMAN_CID, "Unicode", "x-mac-roman" },
|
||||
{ NS_UNICODETOUTF8_CID, "Unicode", "UTF-8" },
|
||||
};
|
||||
|
||||
#define NUM_CONVERTERS (sizeof(gConverterInfo) / sizeof(gConverterInfo[0]))
|
||||
|
||||
/**
|
||||
* Register the to/from information about a converter.
|
||||
*/
|
||||
static NS_IMETHODIMP
|
||||
RegisterConverter(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char *aLocation,
|
||||
const char *aType,
|
||||
const nsModuleComponentInfo* aInfo)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Find the relevant information for the converter we're registering
|
||||
const ConverterInfo* info = gConverterInfo;
|
||||
const ConverterInfo* limit = gConverterInfo + NUM_CONVERTERS;
|
||||
for ( ; info < limit; ++info) {
|
||||
if (info->mCID.Equals(aInfo->mCID))
|
||||
break;
|
||||
}
|
||||
|
||||
if (info == limit) {
|
||||
NS_ERROR("failed to find converter info");
|
||||
return NS_OK; // so as not to completely kill component registration
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRegistry> registry = do_GetService(NS_REGISTRY_CONTRACTID);
|
||||
if (! registry)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Open the registry
|
||||
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Register source and destination strings under the key
|
||||
// ``software/netscape/intl/uconv/[cid]''.
|
||||
static NS_NAMED_LITERAL_CSTRING(kConverterKeyPrefix, "software/netscape/intl/uconv/");
|
||||
nsXPIDLCString cid;
|
||||
cid.Adopt(info->mCID.ToString());
|
||||
|
||||
nsRegistryKey key;
|
||||
rv = registry->AddSubtree(nsIRegistry::Common,
|
||||
PromiseFlatCString(kConverterKeyPrefix + cid).get(),
|
||||
&key);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
registry->SetStringUTF8(key, "source", info->mSource);
|
||||
registry->SetStringUTF8(key, "destination", info->mDestination);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the extra converter information.
|
||||
*/
|
||||
static NS_IMETHODIMP
|
||||
UnregisterConverter(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const nsModuleComponentInfo* aInfo)
|
||||
{
|
||||
// XXX TODO: remove converter key
|
||||
return NS_OK;
|
||||
}
|
||||
NS_UCONV_REG_UNREG(nsISO88591ToUnicode, "ISO-8859-1", "Unicode", NS_ISO88591TOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsCP1252ToUnicode, "windows-1252", "Unicode", NS_CP1252TOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsMacRomanToUnicode, "x-mac-roman", "Unicode", NS_MACROMANTOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUTF8ToUnicode, "UTF-8", "Unicode", NS_UTF8TOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToISO88591, "Unicode", "ISO-8859-1", NS_UNICODETOISO88591_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToCP1252, "Unicode", "windows-1252", NS_UNICODETOCP1252_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMacRoman, "Unicode", "x-mac-roman", NS_UNICODETOMACROMAN_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToUTF8, "Unicode", "UTF-8", NS_UNICODETOUTF8_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetConverterManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeDecodeHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeEncodeHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextToSubURI)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableUnicodeConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConverterInputStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsISO88591ToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCP1252ToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacRomanToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUTF8ToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToISO88591);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToCP1252);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMacRoman);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToUTF8);
|
||||
|
||||
// The list of components we register
|
||||
static nsModuleComponentInfo gComponents[] = {
|
||||
{ "Charset Conversion Manager", NS_ICHARSETCONVERTERMANAGER_CID,
|
||||
NS_CHARSETCONVERTERMANAGER_CONTRACTID, NS_NewCharsetConverterManager,
|
||||
NS_RegisterConverterManagerData,
|
||||
NS_UnregisterConverterManagerData },
|
||||
NS_IMETHODIMP
|
||||
nsConverterManagerDataRegister(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char *aLocation,
|
||||
const char *aType,
|
||||
const nsModuleComponentInfo* aInfo)
|
||||
{
|
||||
return nsCharsetConverterManager::RegisterConverterManagerData();
|
||||
}
|
||||
|
||||
{ "Unicode Decode Helper", NS_UNICODEDECODEHELPER_CID,
|
||||
NS_UNICODEDECODEHELPER_CONTRACTID, NS_NewUnicodeDecodeHelper },
|
||||
|
||||
{ "Unicode Encode Helper", NS_UNICODEENCODEHELPER_CID,
|
||||
NS_UNICODEENCODEHELPER_CONTRACTID, NS_NewUnicodeEncodeHelper },
|
||||
|
||||
{ "Platform Charset Information", NS_PLATFORMCHARSET_CID,
|
||||
NS_PLATFORMCHARSET_CONTRACTID, NS_NewPlatformCharset },
|
||||
|
||||
{ "Charset Alias Information", NS_CHARSETALIAS_CID,
|
||||
NS_CHARSETALIAS_CONTRACTID, NS_NewCharsetAlias },
|
||||
|
||||
{ "Text To Sub URI Helper", NS_TEXTTOSUBURI_CID,
|
||||
NS_ITEXTTOSUBURI_CONTRACTID, NS_NewTextToSubURI },
|
||||
|
||||
{ "Unicode Encoder / Decoder for Script", NS_ISCRIPTABLEUNICODECONVERTER_CID,
|
||||
NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID, nsScriptableUnicodeConverterConstructor },
|
||||
|
||||
{ "Unicode converter input stream", NS_CONVERTERINPUTSTREAM_CID,
|
||||
NS_CONVERTERINPUTSTREAM_CONTRACTID, nsConverterInputStreamConstructor },
|
||||
|
||||
// Converters
|
||||
{ "ISO-8859-1 To Unicode Converter", NS_ISO88591TOUNICODE_CID,
|
||||
NS_ISO88591TOUNICODE_CONTRACTID, NS_NewISO88591ToUnicode,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "windows-1252 To Unicode Converter", NS_CP1252TOUNICODE_CID,
|
||||
NS_CP1252TOUNICODE_CONTRACTID, NS_NewCP1252ToUnicode,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "x-mac-roman To Unicode Converter", NS_MACROMANTOUNICODE_CID,
|
||||
NS_MACROMANTOUNICODE_CONTRACTID, NS_NewMacRomanToUnicode,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "UTF-8 To Unicode Converter", NS_UTF8TOUNICODE_CID,
|
||||
NS_UTF8TOUNICODE_CONTRACTID, NS_NewUTF8ToUnicode,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "Unicode To ISO-8859-1 Converter", NS_UNICODETOISO88591_CID,
|
||||
NS_UNICODETOISO88591_CONTRACTID, NS_NewUnicodeToISO88591,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "Unicode To windows-1252 Converter", NS_UNICODETOCP1252_CID,
|
||||
NS_UNICODETOCP1252_CONTRACTID, NS_NewUnicodeToCP1252,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "Unicode To x-mac-roman Converter", NS_UNICODETOMACROMAN_CID,
|
||||
NS_UNICODETOMACROMAN_CONTRACTID, NS_NewUnicodeToMacRoman,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
|
||||
{ "Unicode To UTF-8 Converter", NS_UNICODETOUTF8_CID,
|
||||
NS_UNICODETOUTF8_CONTRACTID, NS_NewUnicodeToUTF8,
|
||||
RegisterConverter, UnregisterConverter },
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Charset Conversion Manager", NS_ICHARSETCONVERTERMANAGER_CID,
|
||||
NS_CHARSETCONVERTERMANAGER_CONTRACTID,
|
||||
nsCharsetConverterManagerConstructor,
|
||||
nsConverterManagerDataRegister,
|
||||
},
|
||||
{
|
||||
"Unicode Decode Helper", NS_UNICODEDECODEHELPER_CID,
|
||||
NS_UNICODEDECODEHELPER_CONTRACTID,
|
||||
nsUnicodeDecodeHelperConstructor
|
||||
},
|
||||
{
|
||||
"Unicode Encode Helper", NS_UNICODEENCODEHELPER_CID,
|
||||
NS_UNICODEENCODEHELPER_CONTRACTID,
|
||||
nsUnicodeEncodeHelperConstructor
|
||||
},
|
||||
{
|
||||
"Platform Charset Information", NS_PLATFORMCHARSET_CID,
|
||||
NS_PLATFORMCHARSET_CONTRACTID,
|
||||
nsPlatformCharsetConstructor
|
||||
},
|
||||
{
|
||||
"Charset Alias Information", NS_CHARSETALIAS_CID,
|
||||
NS_CHARSETALIAS_CONTRACTID,
|
||||
nsCharsetAlias2Constructor
|
||||
},
|
||||
{
|
||||
"Text To Sub URI Helper", NS_TEXTTOSUBURI_CID,
|
||||
NS_ITEXTTOSUBURI_CONTRACTID,
|
||||
nsTextToSubURIConstructor
|
||||
},
|
||||
{
|
||||
"Unicode Encoder / Decoder for Script", NS_ISCRIPTABLEUNICODECONVERTER_CID,
|
||||
NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID,
|
||||
nsScriptableUnicodeConverterConstructor
|
||||
},
|
||||
{ "Unicode converter input stream", NS_CONVERTERINPUTSTREAM_CID,
|
||||
NS_CONVERTERINPUTSTREAM_CONTRACTID,
|
||||
nsConverterInputStreamConstructor
|
||||
},
|
||||
{
|
||||
"ISO-8859-1 To Unicode Converter", NS_ISO88591TOUNICODE_CID,
|
||||
NS_ISO88591TOUNICODE_CONTRACTID,
|
||||
nsISO88591ToUnicodeConstructor,
|
||||
nsISO88591ToUnicodeRegSelf, nsISO88591ToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
"windows-1252 To Unicode Converter", NS_CP1252TOUNICODE_CID,
|
||||
NS_CP1252TOUNICODE_CONTRACTID,
|
||||
nsCP1252ToUnicodeConstructor,
|
||||
nsCP1252ToUnicodeRegSelf, nsCP1252ToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
"x-mac-roman To Unicode Converter", NS_MACROMANTOUNICODE_CID,
|
||||
NS_MACROMANTOUNICODE_CONTRACTID,
|
||||
nsMacRomanToUnicodeConstructor,
|
||||
nsMacRomanToUnicodeRegSelf, nsMacRomanToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
"UTF-8 To Unicode Converter", NS_UTF8TOUNICODE_CID,
|
||||
NS_UTF8TOUNICODE_CONTRACTID,
|
||||
nsUTF8ToUnicodeConstructor,
|
||||
nsUTF8ToUnicodeRegSelf, nsUTF8ToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
"Unicode To ISO-8859-1 Converter", NS_UNICODETOISO88591_CID,
|
||||
NS_UNICODETOISO88591_CONTRACTID,
|
||||
nsUnicodeToISO88591Constructor,
|
||||
nsUnicodeToISO88591RegSelf, nsUnicodeToISO88591UnRegSelf
|
||||
},
|
||||
{
|
||||
"Unicode To windows-1252 Converter", NS_UNICODETOCP1252_CID,
|
||||
NS_UNICODETOCP1252_CONTRACTID,
|
||||
nsUnicodeToCP1252Constructor,
|
||||
nsUnicodeToCP1252RegSelf, nsUnicodeToCP1252UnRegSelf
|
||||
},
|
||||
{
|
||||
"Unicode To x-mac-roman Converter", NS_UNICODETOMACROMAN_CID,
|
||||
NS_UNICODETOMACROMAN_CONTRACTID,
|
||||
nsUnicodeToMacRomanConstructor,
|
||||
nsUnicodeToMacRomanRegSelf, nsUnicodeToMacRomanUnRegSelf
|
||||
},
|
||||
{
|
||||
"Unicode To UTF-8 Converter", NS_UNICODETOUTF8_CID,
|
||||
NS_UNICODETOUTF8_CONTRACTID,
|
||||
nsUnicodeToUTF8Constructor,
|
||||
nsUnicodeToUTF8RegSelf, nsUnicodeToUTF8UnRegSelf
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsUConvModule, gComponents)
|
||||
NS_IMPL_NSGETMODULE(nsUConvModule, components);
|
||||
|
||||
|
|
|
@ -59,105 +59,82 @@
|
|||
#if HAVE_NL_LANGINFO
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#include "nsPlatformCharset.h"
|
||||
|
||||
class nsUNIXCharset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsUNIXCharset();
|
||||
virtual ~nsUNIXCharset();
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue);
|
||||
|
||||
private:
|
||||
nsString mCharset;
|
||||
nsString mLocale; // remember the locale & charset
|
||||
|
||||
NS_IMETHOD InitGetCharset(nsString&);
|
||||
NS_IMETHOD ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString&, nsString&);
|
||||
NS_IMETHOD VerifyCharset(nsString &aCharset);
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsUNIXCharset, nsIPlatformCharset);
|
||||
NS_IMPL_ISUPPORTS1(nsPlatformCharset, nsIPlatformCharset);
|
||||
|
||||
static nsURLProperties *gNLInfo = nsnull;
|
||||
static nsURLProperties *gInfo_deprecated = nsnull;
|
||||
static PRInt32 gCnt=0;
|
||||
|
||||
nsUNIXCharset::nsUNIXCharset()
|
||||
nsPlatformCharset::nsPlatformCharset()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&gCnt);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsString& oResult)
|
||||
nsresult
|
||||
nsPlatformCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsAWritableString& oResult)
|
||||
{
|
||||
|
||||
// XXX for thread safety the following block should be locked
|
||||
if(nsnull == gInfo_deprecated)
|
||||
{
|
||||
nsAutoString propertyURL;
|
||||
propertyURL.AssignWithConversion("resource:/res/unixcharset.properties");
|
||||
nsURLProperties *info = new nsURLProperties( propertyURL );
|
||||
NS_ASSERTION( info, "cannot create nsURLProperties");
|
||||
gInfo_deprecated = info;
|
||||
nsURLProperties *info = new nsURLProperties( NS_LITERAL_STRING("resource:/res/unixcharset.properties") );
|
||||
NS_ASSERTION( info, "cannot create nsURLProperties");
|
||||
gInfo_deprecated = info;
|
||||
}
|
||||
|
||||
if(gInfo_deprecated && locale.Length())
|
||||
{
|
||||
nsAutoString platformLocaleKey;
|
||||
// note: NS_LITERAL_STRING("locale." OSTYPE ".") does not compile on AIX
|
||||
platformLocaleKey.Assign(NS_LITERAL_STRING("locale."));
|
||||
platformLocaleKey.AppendWithConversion(OSTYPE);
|
||||
platformLocaleKey.Append(NS_LITERAL_STRING("."));
|
||||
platformLocaleKey.Append(locale.get());
|
||||
nsAutoString platformLocaleKey;
|
||||
// note: NS_LITERAL_STRING("locale." OSTYPE ".") does not compile on AIX
|
||||
platformLocaleKey.Assign(NS_LITERAL_STRING("locale."));
|
||||
platformLocaleKey.AppendWithConversion(OSTYPE);
|
||||
platformLocaleKey.Append(NS_LITERAL_STRING("."));
|
||||
platformLocaleKey.Append(locale.get());
|
||||
|
||||
nsresult res = gInfo_deprecated->Get(platformLocaleKey, oResult);
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoString localeKey;
|
||||
localeKey.Assign(NS_LITERAL_STRING("locale.all."));
|
||||
localeKey.Append(locale.get());
|
||||
res = gInfo_deprecated->Get(localeKey, oResult);
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult res = gInfo_deprecated->Get(platformLocaleKey, oResult);
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoString localeKey;
|
||||
localeKey.Assign(NS_LITERAL_STRING("locale.all."));
|
||||
localeKey.Append(locale.get());
|
||||
res = gInfo_deprecated->Get(localeKey, oResult);
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(0, "unable to convert locale to charset using deprecated config");
|
||||
mCharset.AssignWithConversion("ISO-8859-1");
|
||||
mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
|
||||
return NS_ERROR_USING_FALLBACK_LOCALE;
|
||||
}
|
||||
|
||||
nsUNIXCharset::~nsUNIXCharset()
|
||||
nsPlatformCharset::~nsPlatformCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&gCnt);
|
||||
if(0 == gCnt) {
|
||||
if (gNLInfo) {
|
||||
delete gNLInfo;
|
||||
gNLInfo = nsnull;
|
||||
}
|
||||
if (gInfo_deprecated) {
|
||||
delete gInfo_deprecated;
|
||||
gInfo_deprecated = nsnull;
|
||||
}
|
||||
if (gNLInfo) {
|
||||
delete gNLInfo;
|
||||
gNLInfo = nsnull;
|
||||
}
|
||||
if (gInfo_deprecated) {
|
||||
delete gInfo_deprecated;
|
||||
gInfo_deprecated = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult)
|
||||
{
|
||||
oResult = mCharset;
|
||||
return NS_OK;
|
||||
oResult = mCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
nsPlatformCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
{
|
||||
nsAutoString localeNameAsString(localeName);
|
||||
|
||||
|
@ -166,8 +143,8 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar
|
|||
// we already determined at initialization
|
||||
//
|
||||
if (mLocale.Equals(localeNameAsString) ||
|
||||
// support the 4.x behavior
|
||||
(mLocale.EqualsIgnoreCase("en_US") && localeNameAsString.EqualsIgnoreCase("C"))) {
|
||||
// support the 4.x behavior
|
||||
(mLocale.EqualsIgnoreCase("en_US") && localeNameAsString.EqualsIgnoreCase("C"))) {
|
||||
*_retValue = ToNewUnicode(mCharset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -204,43 +181,8 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar
|
|||
return NS_ERROR_USING_FALLBACK_LOCALE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewPlatformCharset(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUNIXCharset* inst = new nsUNIXCharset();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->Init();
|
||||
if (NS_FAILED(res)) {
|
||||
if (res != NS_ERROR_USING_FALLBACK_LOCALE) {
|
||||
delete inst;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::InitGetCharset(nsString &oString)
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsAWritableString &oString)
|
||||
{
|
||||
char* nl_langinfo_codeset = nsnull;
|
||||
nsString aCharset;
|
||||
|
@ -290,11 +232,11 @@ nsUNIXCharset::InitGetCharset(nsString &oString)
|
|||
localeKey.AppendWithConversion(nl_langinfo_codeset);
|
||||
res = gNLInfo->Get(localeKey, aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = VerifyCharset(aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
oString = aCharset;
|
||||
return res;
|
||||
}
|
||||
res = VerifyCharset(aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
oString = aCharset;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -306,11 +248,11 @@ nsUNIXCharset::InitGetCharset(nsString &oString)
|
|||
localeKey.AppendWithConversion(nl_langinfo_codeset);
|
||||
res = gNLInfo->Get(localeKey, aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = VerifyCharset(aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
oString = aCharset;
|
||||
return res;
|
||||
}
|
||||
res = VerifyCharset(aCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
oString = aCharset;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +270,7 @@ nsUNIXCharset::InitGetCharset(nsString &oString)
|
|||
}
|
||||
|
||||
#if HAVE_NL_LANGINFO
|
||||
NS_ASSERTION(0, "unable to use nl_langinfo(CODESET)");
|
||||
NS_ASSERTION(0, "unable to use nl_langinfo(CODESET)");
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -347,7 +289,7 @@ nsUNIXCharset::InitGetCharset(nsString &oString)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::Init()
|
||||
nsPlatformCharset::Init()
|
||||
{
|
||||
nsString charset;
|
||||
nsresult res;
|
||||
|
@ -376,8 +318,8 @@ nsUNIXCharset::Init()
|
|||
return NS_ERROR_USING_FALLBACK_LOCALE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::VerifyCharset(nsString &aCharset)
|
||||
nsresult
|
||||
nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
||||
{
|
||||
nsresult res;
|
||||
//
|
||||
|
@ -429,3 +371,20 @@ nsUNIXCharset::VerifyCharset(nsString &aCharset)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(short script, short region, nsAWritableString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(nsString& inANSICodePage, nsAWritableString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitInfo()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ static NS_DEFINE_IID(kIOServiceCID, NS_IOSERVICE_CID);
|
|||
nsIIOService* nsURLProperties::gIOService = nsnull;
|
||||
nsrefcnt nsURLProperties::gRefCnt = 0;
|
||||
|
||||
nsURLProperties::nsURLProperties(nsString& aUrl)
|
||||
nsURLProperties::nsURLProperties(const nsAFlatString& aUrl)
|
||||
{
|
||||
mDelegate = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
|
@ -102,7 +102,7 @@ nsURLProperties::~nsURLProperties()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURLProperties::Get(const nsAString& aKey, nsAString& oValue)
|
||||
NS_IMETHODIMP nsURLProperties::Get(const nsAReadableString& aKey, nsAWritableString& oValue)
|
||||
{
|
||||
if(mDelegate)
|
||||
return mDelegate->GetStringProperty(aKey, oValue);
|
||||
|
|
|
@ -45,11 +45,11 @@
|
|||
|
||||
class nsURLProperties {
|
||||
public:
|
||||
nsURLProperties(nsString& aUrl);
|
||||
nsURLProperties(const nsAFlatString& aUrl);
|
||||
virtual ~nsURLProperties();
|
||||
|
||||
NS_IMETHOD DidLoad(PRBool&);
|
||||
NS_IMETHOD Get( const nsAString& aKey, nsAString& value);
|
||||
NS_IMETHOD Get( const nsAReadableString& aKey, nsAWritableString& value);
|
||||
|
||||
private:
|
||||
static nsIIOService* gIOService; // to speed up creating URLs
|
||||
|
|
|
@ -43,56 +43,7 @@
|
|||
#include "nsMappingCache.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeDecodeHelper [declaration]
|
||||
|
||||
/**
|
||||
* The actual implementation of the nsIUnicodeDecodeHelper interface.
|
||||
*
|
||||
* @created 18/Mar/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsUnicodeDecodeHelper : public nsIUnicodeDecodeHelper
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeDecodeHelper();
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsUnicodeDecodeHelper();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsIUnicodeDecodeHelper [declaration]
|
||||
|
||||
NS_IMETHOD ConvertByTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByFastTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateFastTable( uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aResult);
|
||||
};
|
||||
#include "nsUnicodeDecodeHelper.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeDecodeHelper [implementation]
|
||||
|
@ -314,29 +265,3 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::CreateFastTable(
|
|||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeDecodeHelper(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeDecodeHelper* inst = new nsUnicodeDecodeHelper();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsUnicodeDecodeHelper_h__
|
||||
#define nsUnicodeDecodeHelper_h__
|
||||
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeDecodeHelper [declaration]
|
||||
|
||||
/**
|
||||
* The actual implementation of the nsIUnicodeDecodeHelper interface.
|
||||
*
|
||||
* @created 18/Mar/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsUnicodeDecodeHelper : public nsIUnicodeDecodeHelper
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeDecodeHelper();
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsUnicodeDecodeHelper();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsIUnicodeDecodeHelper [declaration]
|
||||
|
||||
NS_IMETHOD ConvertByTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByFastTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateFastTable( uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aResult);
|
||||
};
|
||||
|
||||
#endif // nsUnicodeDecodeHelper_h__
|
||||
|
||||
|
|
@ -43,50 +43,7 @@
|
|||
#include "nsUConvDll.h"
|
||||
#include "nsIMappingCache.h"
|
||||
#include "nsMappingCache.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeEncodeHelper [declaration]
|
||||
|
||||
/**
|
||||
* The actual implementation of the nsIUnicodeEncodeHelper interface.
|
||||
*
|
||||
* @created 22/Nov/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsUnicodeEncodeHelper : public nsIUnicodeEncodeHelper
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeEncodeHelper();
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsUnicodeEncodeHelper();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsIUnicodeEncodeHelper [declaration]
|
||||
|
||||
NS_IMETHOD ConvertByTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aCache);
|
||||
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, uMappingTable * aMappingTable);
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable);
|
||||
};
|
||||
#include "nsUnicodeEncodeHelper.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeEncodeHelper [implementation]
|
||||
|
@ -211,30 +168,3 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, PRInt32 aTableCou
|
|||
uFillInfo((uTable*) aMappingTable[i], aInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewUnicodeEncodeHelper(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeEncodeHelper* inst = new nsUnicodeEncodeHelper();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsUnicodeEncodeHelper_h__
|
||||
#define nsUnicodeEncodeHelper_h__
|
||||
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeEncodeHelper [declaration]
|
||||
|
||||
/**
|
||||
* The actual implementation of the nsIUnicodeEncodeHelper interface.
|
||||
*
|
||||
* @created 22/Nov/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsUnicodeEncodeHelper : public nsIUnicodeEncodeHelper
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeEncodeHelper();
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsUnicodeEncodeHelper();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsIUnicodeEncodeHelper [declaration]
|
||||
|
||||
NS_IMETHOD ConvertByTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aCache);
|
||||
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, uMappingTable * aMappingTable);
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
#endif // nsUnicodeEncodeHelper_h__
|
||||
|
||||
|
|
@ -39,31 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsUnicodeToCP1252.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewUnicodeToCP1252(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeToCP1252 * inst = new nsUnicodeToCP1252();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -39,30 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsUnicodeToISO88591.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewUnicodeToISO88591(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeToISO88591 * inst = new nsUnicodeToISO88591();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -39,30 +39,6 @@
|
|||
#include "nsUCvMinSupport.h"
|
||||
#include "nsUnicodeToMacRoman.h"
|
||||
|
||||
NS_IMETHODIMP NS_NewUnicodeToMacRoman(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeToMacRoman * inst = new nsUnicodeToMacRoman();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
||||
|
|
|
@ -42,31 +42,6 @@
|
|||
#include "nsUnicodeToUTF8.h"
|
||||
#include <string.h>
|
||||
|
||||
NS_IMETHODIMP NS_NewUnicodeToUTF8(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsUnicodeToUTF8 * inst = new nsUnicodeToUTF8();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static const PRUint16 g_UTF8MappingTable[] = {
|
||||
0x0001, 0x0004, 0x0005, 0x0008, 0x0000, 0x0000, 0xFFFF, 0x0000
|
||||
};
|
||||
|
|
|
@ -47,64 +47,43 @@
|
|||
#include "nsLocaleCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsPlatformCharset.h"
|
||||
|
||||
static nsURLProperties *gInfo = nsnull;
|
||||
static PRInt32 gCnt= 0;
|
||||
|
||||
class nsWinCharset : public nsIPlatformCharset
|
||||
NS_IMPL_ISUPPORTS1(nsPlatformCharset, nsIPlatformCharset)
|
||||
|
||||
nsPlatformCharset::nsPlatformCharset()
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsWinCharset();
|
||||
virtual ~nsWinCharset();
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
NS_IMETHOD GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue);
|
||||
|
||||
private:
|
||||
|
||||
nsString mCharset;
|
||||
|
||||
private:
|
||||
|
||||
nsresult InitInfo();
|
||||
nsresult MapToCharset(nsString& inANSICodePage, nsString& outCharset);
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWinCharset, nsIPlatformCharset)
|
||||
|
||||
nsWinCharset::nsWinCharset()
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsWinCharset()");
|
||||
NS_TIMELINE_START_TIMER("nsPlatformCharset()");
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
UINT acp = ::GetACP();
|
||||
PRInt32 acpint = (PRInt32)(acp & 0x00FFFF);
|
||||
nsAutoString acpKey; acpKey.AssignWithConversion("acp.");
|
||||
acpKey.AppendInt(acpint, 10);
|
||||
UINT acp = ::GetACP();
|
||||
PRInt32 acpint = (PRInt32)(acp & 0x00FFFF);
|
||||
nsAutoString acpKey; acpKey.Assign(NS_LITERAL_STRING("acp."));
|
||||
acpKey.AppendInt(acpint, 10);
|
||||
nsresult res = MapToCharset(acpKey, mCharset);
|
||||
|
||||
NS_TIMELINE_STOP_TIMER("nsWinCharset()");
|
||||
NS_TIMELINE_MARK_TIMER("nsWinCharset()");
|
||||
NS_TIMELINE_STOP_TIMER("nsPlatformCharset()");
|
||||
NS_TIMELINE_MARK_TIMER("nsPlatformCharset()");
|
||||
}
|
||||
nsWinCharset::~nsWinCharset()
|
||||
nsPlatformCharset::~nsPlatformCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&gCnt);
|
||||
if ((0 == gCnt) && (nsnull != gInfo)) {
|
||||
delete gInfo;
|
||||
gInfo = nsnull;
|
||||
delete gInfo;
|
||||
gInfo = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWinCharset::InitInfo()
|
||||
nsPlatformCharset::InitInfo()
|
||||
{
|
||||
PR_AtomicIncrement(&gCnt); // count for gInfo
|
||||
|
||||
if (gInfo == nsnull) {
|
||||
nsURLProperties *info = new nsURLProperties(nsAutoString(NS_LITERAL_STRING("resource:/res/wincharset.properties")));
|
||||
nsURLProperties *info = new nsURLProperties(NS_LITERAL_STRING("resource:/res/wincharset.properties"));
|
||||
|
||||
NS_ASSERTION(info , "cannot open properties file");
|
||||
NS_ENSURE_TRUE(info, NS_ERROR_FAILURE);
|
||||
|
@ -114,7 +93,7 @@ nsWinCharset::InitInfo()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsWinCharset::MapToCharset(nsString& inANSICodePage, nsString& outCharset)
|
||||
nsPlatformCharset::MapToCharset(nsString& inANSICodePage, nsAWritableString& outCharset)
|
||||
{
|
||||
//delay loading wincharset.properties bundle if possible
|
||||
if (inANSICodePage.Equals(NS_LITERAL_STRING("acp.1252"))) {
|
||||
|
@ -143,63 +122,69 @@ nsWinCharset::MapToCharset(nsString& inANSICodePage, nsString& outCharset)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWinCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector, nsAWritableString& oResult)
|
||||
{
|
||||
oResult = mCharset;
|
||||
return NS_OK;
|
||||
oResult = mCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWinCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
nsPlatformCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue)
|
||||
{
|
||||
nsCOMPtr<nsIWin32Locale> winLocale;
|
||||
LCID localeAsLCID;
|
||||
char acp_name[6];
|
||||
nsAutoString charset;
|
||||
nsAutoString localeAsNSString(localeName);
|
||||
nsCOMPtr<nsIWin32Locale> winLocale;
|
||||
LCID localeAsLCID;
|
||||
char acp_name[6];
|
||||
nsAutoString charset;
|
||||
nsAutoString localeAsNSString(localeName);
|
||||
|
||||
//
|
||||
// convert locale name to a code page (through the LCID)
|
||||
//
|
||||
nsresult result;
|
||||
//
|
||||
// convert locale name to a code page (through the LCID)
|
||||
//
|
||||
nsresult result;
|
||||
winLocale = do_CreateInstance(NS_WIN32LOCALE_CONTRACTID, &result);
|
||||
result = winLocale->GetPlatformLocale(&localeAsNSString,&localeAsLCID);
|
||||
result = winLocale->GetPlatformLocale(&localeAsNSString,&localeAsLCID);
|
||||
|
||||
if (NS_FAILED(result)) { *_retValue = ToNewUnicode(charset); return result; }
|
||||
if (NS_FAILED(result)) { *_retValue = ToNewUnicode(charset); return result; }
|
||||
|
||||
if (GetLocaleInfo(localeAsLCID,LOCALE_IDEFAULTANSICODEPAGE,acp_name,sizeof(acp_name))==0) { *_retValue = ToNewUnicode(charset); return NS_ERROR_FAILURE; }
|
||||
nsAutoString acp_key; acp_key.AssignWithConversion("acp.");
|
||||
acp_key.AppendWithConversion(acp_name);
|
||||
if (GetLocaleInfo(localeAsLCID,LOCALE_IDEFAULTANSICODEPAGE,acp_name,sizeof(acp_name))==0) {
|
||||
*_retValue = ToNewUnicode(charset);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString acp_key; acp_key.Assign(NS_LITERAL_STRING("acp."));
|
||||
acp_key.AppendWithConversion(acp_name);
|
||||
|
||||
result = MapToCharset(acp_key,charset);
|
||||
|
||||
*_retValue = ToNewUnicode(charset);
|
||||
return result;
|
||||
result = MapToCharset(acp_key,charset);
|
||||
|
||||
*_retValue = ToNewUnicode(charset);
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewPlatformCharset(nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
NS_IMETHODIMP
|
||||
nsPlatformCharset::Init()
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsWinCharset* inst = new nsWinCharset();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(res)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(short script, short region, nsAWritableString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsAWritableString &oString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAutoString& locale, nsAWritableString& oResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче