mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
add two new files
This commit is contained in:
parent
97caa1dffb
commit
99234f64b6
@ -30,12 +30,14 @@ CPPSRCS = \
|
||||
nsCharsetConverterManager.cpp \
|
||||
nsUnicodeDecodeUtil.cpp \
|
||||
nsUConvDll.cpp \
|
||||
nsWinCharset.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCharsetConverterManager.obj \
|
||||
.\$(OBJDIR)\nsUnicodeDecodeUtil.obj \
|
||||
.\$(OBJDIR)\nsUConvDll.obj \
|
||||
.\$(OBJDIR)\nsWinCharset.obj \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = \
|
||||
|
113
intl/uconv/src/nsMacCharset.cpp
Normal file
113
intl/uconv/src/nsMacCharset.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsPlatformCharsetFactory.h"
|
||||
#include "pratom.h"
|
||||
|
||||
#include "nsUConvDll.h"
|
||||
|
||||
|
||||
|
||||
class nsMacCharset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsMacCharset();
|
||||
~nsMacCharset();
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMacCharset, kIPlatformCharsetIID);
|
||||
|
||||
nsMacCharset::nsMacCharset()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
nsMacCharset::~nsMacCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
{
|
||||
oResult = "ISO-8859-1"; // XXX- hack to be implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsMacCharsetFactory : public nsIFactory {
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
nsMacCharsetFactory() {
|
||||
}
|
||||
~nsMacCharsetFactory() {
|
||||
}
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS( nsMacCharsetFactory , NS_IFACTORY_IID);
|
||||
|
||||
NS_IMETHODIMP nsMacCharsetFactory::CreateInstance(
|
||||
nsISupports* aDelegate, const nsIID &aIID, void** aResult)
|
||||
{
|
||||
if(NULL == aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(NULL != aDelegate)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = NULL;
|
||||
nsISupports *inst = new nsMacCharset();
|
||||
if(NULL == inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res =inst->QueryInterface(aIID, aResult);
|
||||
if(NS_FAILED(res)) {
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
NS_IMETHODIMP nsMacCharsetFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if(aLock)
|
||||
PR_AtomicIncrement( &g_LockCount );
|
||||
else
|
||||
PR_AtomicDecrement( &g_LockCount );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFactory* NEW_PLATFORMCHARSETFACTORY()
|
||||
{
|
||||
return new nsMacCharsetFactory();
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "nsRepository.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsCharsetConverterManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsPlatformCharsetFactory.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
@ -54,6 +56,9 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi
|
||||
|
||||
return res;
|
||||
}
|
||||
if (aCID.Equals(kPlatformCharsetCID)) {
|
||||
*aFactory = NEW_PLATFORMCHARSETFACTORY();
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
@ -64,6 +69,8 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path)
|
||||
|
||||
res = nsRepository::RegisterFactory(kCharsetConverterManagerCID, path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
res = nsRepository::RegisterFactory(kPlatformCharsetCID, path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -72,5 +79,6 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path)
|
||||
nsresult res;
|
||||
|
||||
res = nsRepository::UnregisterFactory(kCharsetConverterManagerCID, path);
|
||||
res = nsRepository::UnregisterFactory(kPlatformCharsetCID, path);
|
||||
return res;
|
||||
}
|
||||
|
113
intl/uconv/src/nsUNIXCharset.cpp
Normal file
113
intl/uconv/src/nsUNIXCharset.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsPlatformCharsetFactory.h"
|
||||
#include "pratom.h"
|
||||
|
||||
#include "nsUConvDll.h"
|
||||
|
||||
|
||||
|
||||
class nsUNIXCharset : public nsIPlatformCharset
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsUNIXCharset();
|
||||
~nsUNIXCharset();
|
||||
|
||||
NS_IMETHOD GetCharset(nsPlatformCharsetSel selector, nsString& oResult);
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsUNIXCharset, kIPlatformCharsetIID);
|
||||
|
||||
nsUNIXCharset::nsUNIXCharset()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
nsUNIXCharset::~nsUNIXCharset()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUNIXCharset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult)
|
||||
{
|
||||
oResult = "ISO-8859-1"; // XXX- hack to be implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsUNIXCharsetFactory : public nsIFactory {
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
nsUNIXCharsetFactory() {
|
||||
}
|
||||
~nsUNIXCharsetFactory() {
|
||||
}
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS( nsUNIXCharsetFactory , NS_IFACTORY_IID);
|
||||
|
||||
NS_IMETHODIMP nsUNIXCharsetFactory::CreateInstance(
|
||||
nsISupports* aDelegate, const nsIID &aIID, void** aResult)
|
||||
{
|
||||
if(NULL == aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(NULL != aDelegate)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = NULL;
|
||||
nsISupports *inst = new nsUNIXCharset();
|
||||
if(NULL == inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res =inst->QueryInterface(aIID, aResult);
|
||||
if(NS_FAILED(res)) {
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
NS_IMETHODIMP nsUNIXCharsetFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if(aLock)
|
||||
PR_AtomicIncrement( &g_LockCount );
|
||||
else
|
||||
PR_AtomicDecrement( &g_LockCount );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFactory* NEW_PLATFORMCHARSETFACTORY()
|
||||
{
|
||||
return new nsUNIXCharsetFactory();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user