зеркало из https://github.com/mozilla/pjs.git
Bug 655655 - decom nsIPosixLocale. r=smontagu
--HG-- rename : intl/locale/public/nsIPosixLocale.h => intl/locale/public/nsPosixLocale.h
This commit is contained in:
Родитель
253f894c83
Коммит
e704626a80
|
@ -96,7 +96,6 @@ NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
|
|||
NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
NS_DEFINE_NAMED_CID(NS_POSIXLOCALE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
|
||||
#endif
|
||||
|
@ -132,7 +131,6 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
|
|||
{ &kNS_DATETIMEFORMAT_CID, false, NULL, nsDateTimeFormatWinConstructor },
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
{ &kNS_POSIXLOCALE_CID, false, NULL, nsPosixLocaleConstructor },
|
||||
{ &kNS_COLLATION_CID, false, NULL, nsCollationUnixConstructor },
|
||||
{ &kNS_DATETIMEFORMAT_CID, false, NULL, nsDateTimeFormatUnixConstructor },
|
||||
#endif
|
||||
|
@ -170,7 +168,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
|
|||
{ NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
{ NS_POSIXLOCALE_CONTRACTID, &kNS_POSIXLOCALE_CID },
|
||||
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
|
||||
{ NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ EXPORTS = \
|
|||
nsDateTimeFormatCID.h \
|
||||
nsIDateTimeFormat.h \
|
||||
nsILanguageAtomService.h \
|
||||
nsIPosixLocale.h \
|
||||
nsPosixLocale.h \
|
||||
nsIOS2Locale.h \
|
||||
nsWin32Locale.h \
|
||||
nsICharsetAlias.h \
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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):
|
||||
* Henry Sobotka <sobotka@axess.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIPosixLocale_h__
|
||||
#define nsIPosixLocale_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/* a434957c-6514-447c-991b-2117b633359c */
|
||||
#define NS_IPOSIXLOCALE_IID \
|
||||
{ 0xa434957c, \
|
||||
0x6514, \
|
||||
0x447c, \
|
||||
{0x99, 0x1b, 0x21, 0x17, 0xb6, 0x33, 0x35, 0x9c} }
|
||||
|
||||
#define MAX_LANGUAGE_CODE_LEN 3
|
||||
#define MAX_COUNTRY_CODE_LEN 3
|
||||
#define MAX_LOCALE_LEN 128
|
||||
#define MAX_EXTRA_LEN 65
|
||||
|
||||
class nsIPosixLocale : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPOSIXLOCALE_IID)
|
||||
|
||||
NS_IMETHOD GetPlatformLocale(const nsAString& locale, nsACString& posixLocale) = 0;
|
||||
NS_IMETHOD GetXPLocale(const char* posixLocale, nsAString& locale) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPosixLocale, NS_IPOSIXLOCALE_IID)
|
||||
|
||||
#endif
|
|
@ -37,27 +37,6 @@
|
|||
#ifndef nsLocaleCID_h__
|
||||
#define nsLocaleCID_h__
|
||||
|
||||
// {D92D57C3-BA1D-11d2-AF0C-0060089FE59B}
|
||||
#define NS_WIN32LOCALE_CID \
|
||||
{ 0xd92d57c3, 0xba1d, 0x11d2, \
|
||||
{ 0xaf, 0xc, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
#define NS_WIN32LOCALE_CONTRACTID "@mozilla.org/locale/win32-locale;1"
|
||||
|
||||
// {D92D57C4-BA1D-11d2-AF0C-0060089FE59B}
|
||||
#define NS_MACLOCALE_CID \
|
||||
{ 0xd92d57c4, 0xba1d, 0x11d2, \
|
||||
{ 0xaf, 0xc, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
#define NS_MACLOCALE_CONTRACTID "@mozilla.org/locale/mac-locale;1"
|
||||
|
||||
// {D92D57C5-BA1D-11d2-AF0C-0060089FE59B}
|
||||
#define NS_POSIXLOCALE_CID \
|
||||
{ 0xd92d57c5, 0xba1d, 0x11d2, \
|
||||
{ 0xaf, 0xc, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
#define NS_POSIXLOCALE_CONTRACTID "@mozilla.org/locale/posix-locale;1"
|
||||
|
||||
// {F25F74F1-FB59-11d3-A9F2-00203522A03C}
|
||||
#define NS_OS2LOCALE_CID \
|
||||
{ 0xf25f74f1, 0xfb59, 0x11d3, \
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Henry Sobotka <sobotka@axess.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -34,33 +35,23 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsPosixLocale_h__
|
||||
#define nsPosixLocale_h__
|
||||
#ifndef nsIPosixLocale_h__
|
||||
#define nsIPosixLocale_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPosixLocale.h"
|
||||
|
||||
#define MAX_LANGUAGE_CODE_LEN 3
|
||||
#define MAX_COUNTRY_CODE_LEN 3
|
||||
#define MAX_LOCALE_LEN 128
|
||||
#define MAX_EXTRA_LEN 65
|
||||
|
||||
|
||||
class nsPosixLocale : public nsIPosixLocale {
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
class nsPosixLocale {
|
||||
|
||||
public:
|
||||
|
||||
nsPosixLocale();
|
||||
virtual ~nsPosixLocale();
|
||||
|
||||
NS_IMETHOD GetPlatformLocale(const nsAString& locale, nsACString& posixLocale);
|
||||
NS_IMETHOD GetXPLocale(const char* posixLocale, nsAString& locale);
|
||||
|
||||
protected:
|
||||
inline PRBool ParseLocaleString(const char* locale_string, char* language, char* country, char* extra, char separator);
|
||||
|
||||
static nsresult GetPlatformLocale(const nsAString& locale, nsACString& posixLocale);
|
||||
static nsresult GetXPLocale(const char* posixLocale, nsAString& locale);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -77,7 +77,6 @@
|
|||
#ifdef USE_UNIX_LOCALE
|
||||
#include "nsCollationUnix.h"
|
||||
#include "nsDateTimeFormatUnix.h"
|
||||
#include "nsPosixLocale.h"
|
||||
#endif
|
||||
|
||||
#define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_) \
|
||||
|
@ -110,7 +109,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
|
|||
#endif
|
||||
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPosixLocale)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatUnix)
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#elif defined(XP_UNIX)
|
||||
# include <locale.h>
|
||||
# include <stdlib.h>
|
||||
# include "nsIPosixLocale.h"
|
||||
# include "nsPosixLocale.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -157,55 +157,47 @@ nsLocaleService::nsLocaleService(void)
|
|||
NS_ENSURE_SUCCESS(rv, );
|
||||
#endif
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
nsCOMPtr<nsIPosixLocale> posixConverter = do_GetService(NS_POSIXLOCALE_CONTRACTID);
|
||||
|
||||
nsAutoString xpLocale, platformLocale;
|
||||
if (posixConverter) {
|
||||
nsAutoString category, category_platform;
|
||||
int i;
|
||||
|
||||
nsRefPtr<nsLocale> resultLocale(new nsLocale());
|
||||
if ( resultLocale == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<nsLocale> resultLocale(new nsLocale());
|
||||
NS_ENSURE_TRUE(resultLocale, );
|
||||
|
||||
#ifdef MOZ_WIDGET_QT
|
||||
const char* lang = QLocale::system().name().toAscii();
|
||||
const char* lang = QLocale::system().name().toAscii();
|
||||
#else
|
||||
// Get system configuration
|
||||
const char* lang = getenv("LANG");
|
||||
// Get system configuration
|
||||
const char* lang = getenv("LANG");
|
||||
#endif
|
||||
|
||||
for( i = 0; i < LocaleListLength; i++ ) {
|
||||
nsresult result;
|
||||
// setlocale( , "") evaluates LC_* and LANG
|
||||
char* lc_temp = setlocale(posix_locale_category[i], "");
|
||||
CopyASCIItoUTF16(LocaleList[i], category);
|
||||
category_platform = category;
|
||||
category_platform.AppendLiteral("##PLATFORM");
|
||||
if (lc_temp != nsnull) {
|
||||
result = posixConverter->GetXPLocale(lc_temp, xpLocale);
|
||||
CopyASCIItoUTF16(lc_temp, platformLocale);
|
||||
nsAutoString xpLocale, platformLocale;
|
||||
nsAutoString category, category_platform;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < LocaleListLength; i++ ) {
|
||||
nsresult result;
|
||||
// setlocale( , "") evaluates LC_* and LANG
|
||||
char* lc_temp = setlocale(posix_locale_category[i], "");
|
||||
CopyASCIItoUTF16(LocaleList[i], category);
|
||||
category_platform = category;
|
||||
category_platform.AppendLiteral("##PLATFORM");
|
||||
if (lc_temp != nsnull) {
|
||||
result = nsPosixLocale::GetXPLocale(lc_temp, xpLocale);
|
||||
CopyASCIItoUTF16(lc_temp, platformLocale);
|
||||
} else {
|
||||
if ( lang == nsnull ) {
|
||||
platformLocale.AssignLiteral("en_US");
|
||||
result = nsPosixLocale::GetXPLocale("en-US", xpLocale);
|
||||
} else {
|
||||
if ( lang == nsnull ) {
|
||||
platformLocale.AssignLiteral("en_US");
|
||||
result = posixConverter->GetXPLocale("en-US", xpLocale);
|
||||
}
|
||||
else {
|
||||
CopyASCIItoUTF16(lang, platformLocale);
|
||||
result = posixConverter->GetXPLocale(lang, xpLocale);
|
||||
}
|
||||
CopyASCIItoUTF16(lang, platformLocale);
|
||||
result = nsPosixLocale::GetXPLocale(lang, xpLocale);
|
||||
}
|
||||
if (NS_FAILED(result)) {
|
||||
return;
|
||||
}
|
||||
resultLocale->AddCategory(category, xpLocale);
|
||||
resultLocale->AddCategory(category_platform, platformLocale);
|
||||
}
|
||||
mSystemLocale = do_QueryInterface(resultLocale);
|
||||
mApplicationLocale = do_QueryInterface(resultLocale);
|
||||
} // if ( NS_SUCCEEDED )...
|
||||
if (NS_FAILED(result)) {
|
||||
return;
|
||||
}
|
||||
resultLocale->AddCategory(category, xpLocale);
|
||||
resultLocale->AddCategory(category_platform, platformLocale);
|
||||
}
|
||||
mSystemLocale = do_QueryInterface(resultLocale);
|
||||
mApplicationLocale = do_QueryInterface(resultLocale);
|
||||
|
||||
#endif // XP_UNIX
|
||||
#ifdef XP_OS2
|
||||
|
|
|
@ -41,10 +41,9 @@
|
|||
#include "nsCollationUnix.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIPosixLocale.h"
|
||||
#include "nsPosixLocale.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
@ -126,10 +125,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
|
|||
localeStr.AssignLiteral("C");
|
||||
}
|
||||
|
||||
nsCOMPtr <nsIPosixLocale> posixLocale = do_GetService(NS_POSIXLOCALE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = posixLocale->GetPlatformLocale(localeStr, mLocale);
|
||||
}
|
||||
nsPosixLocale::GetPlatformLocale(localeStr, mLocale);
|
||||
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
|
|
|
@ -41,10 +41,9 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsDateTimeFormatUnix.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIPosixLocale.h"
|
||||
#include "nsPosixLocale.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
@ -103,10 +102,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
|
|||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mLocale = localeStr; // cache locale name
|
||||
|
||||
nsCOMPtr <nsIPosixLocale> posixLocale = do_GetService(NS_POSIXLOCALE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = posixLocale->GetPlatformLocale(mLocale, mPlatformLocale);
|
||||
}
|
||||
nsPosixLocale::GetPlatformLocale(mLocale, mPlatformLocale);
|
||||
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
|
|
|
@ -35,28 +35,17 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsPosixLocale.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "prprf.h"
|
||||
#include "plstr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
/* nsPosixLocale ISupports */
|
||||
NS_IMPL_ISUPPORTS1(nsPosixLocale, nsIPosixLocale)
|
||||
static PRBool
|
||||
ParseLocaleString(const char* locale_string, char* language, char* country, char* extra, char separator);
|
||||
|
||||
nsPosixLocale::nsPosixLocale(void)
|
||||
{
|
||||
}
|
||||
|
||||
nsPosixLocale::~nsPosixLocale(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsPosixLocale::GetPlatformLocale(const nsAString& locale, nsACString& posixLocale)
|
||||
{
|
||||
char country_code[MAX_COUNTRY_CODE_LEN+1];
|
||||
|
@ -96,7 +85,7 @@ nsPosixLocale::GetPlatformLocale(const nsAString& locale, nsACString& posixLocal
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsPosixLocale::GetXPLocale(const char* posixLocale, nsAString& locale)
|
||||
{
|
||||
char country_code[MAX_COUNTRY_CODE_LEN+1];
|
||||
|
@ -140,8 +129,8 @@ nsPosixLocale::GetXPLocale(const char* posixLocale, nsAString& locale)
|
|||
|
||||
//
|
||||
// returns PR_FALSE/PR_TRUE depending on if it was of the form LL-CC.Extra
|
||||
PRBool
|
||||
nsPosixLocale::ParseLocaleString(const char* locale_string, char* language, char* country, char* extra, char separator)
|
||||
static PRBool
|
||||
ParseLocaleString(const char* locale_string, char* language, char* country, char* extra, char separator)
|
||||
{
|
||||
const char *src = locale_string;
|
||||
char modifier[MAX_EXTRA_LEN+1];
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsUConvPropertySearch.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче