michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsUdetXPCOMWrapper_h__ michael@0: #define _nsUdetXPCOMWrapper_h__ michael@0: #include "nsISupports.h" michael@0: #include "nsICharsetDetector.h" michael@0: #include "nsIStringCharsetDetector.h" michael@0: #include "nsICharsetDetectionObserver.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: #include "nsIFactory.h" michael@0: michael@0: // {374E0CDE-F605-4259-8C92-E639C6C2EEEF} michael@0: #define NS_UNIVERSAL_DETECTOR_CID \ michael@0: { 0x374e0cde, 0xf605, 0x4259, { 0x8c, 0x92, 0xe6, 0x39, 0xc6, 0xc2, 0xee, 0xef } } michael@0: michael@0: // {6EE5301A-3981-49bd-85F8-1A2CC228CF3E} michael@0: #define NS_UNIVERSAL_STRING_DETECTOR_CID \ michael@0: { 0x6ee5301a, 0x3981, 0x49bd, { 0x85, 0xf8, 0x1a, 0x2c, 0xc2, 0x28, 0xcf, 0x3e } } michael@0: michael@0: // {12BB8F1B-2389-11d3-B3BF-00805F8A6670} michael@0: #define NS_JA_PSMDETECTOR_CID \ michael@0: { 0x12bb8f1b, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {12BB8F1C-2389-11d3-B3BF-00805F8A6670} michael@0: #define NS_JA_STRING_PSMDETECTOR_CID \ michael@0: { 0x12bb8f1c, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {EA06D4E1-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_KO_PSMDETECTOR_CID \ michael@0: { 0xea06d4e1, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {EA06D4E2-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZHCN_PSMDETECTOR_CID \ michael@0: { 0xea06d4e2, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {EA06D4E3-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZHTW_PSMDETECTOR_CID \ michael@0: { 0xea06d4e3, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: michael@0: // {EA06D4E4-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_KO_STRING_PSMDETECTOR_CID \ michael@0: { 0xea06d4e4, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {EA06D4E5-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZHCN_STRING_PSMDETECTOR_CID \ michael@0: { 0xea06d4e5, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {EA06D4E6-2B3D-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZHTW_STRING_PSMDETECTOR_CID \ michael@0: { 0xea06d4e6, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: michael@0: // {FCACEF21-2B40-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZH_STRING_PSMDETECTOR_CID \ michael@0: { 0xfcacef21, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {FCACEF22-2B40-11d3-B3BF-00805F8A6670} michael@0: #define NS_CJK_STRING_PSMDETECTOR_CID \ michael@0: { 0xfcacef22, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: michael@0: // {FCACEF23-2B40-11d3-B3BF-00805F8A6670} michael@0: #define NS_ZH_PSMDETECTOR_CID \ michael@0: { 0xfcacef23, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: // {FCACEF24-2B40-11d3-B3BF-00805F8A6670} michael@0: #define NS_CJK_PSMDETECTOR_CID \ michael@0: { 0xfcacef24, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } } michael@0: michael@0: //===================================================================== michael@0: class nsXPCOMDetector : michael@0: public nsUniversalDetector, michael@0: public nsICharsetDetector michael@0: { michael@0: NS_DECL_ISUPPORTS michael@0: public: michael@0: nsXPCOMDetector(uint32_t aLanguageFilter); michael@0: virtual ~nsXPCOMDetector(); michael@0: NS_IMETHOD Init(nsICharsetDetectionObserver* aObserver); michael@0: NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen, bool *oDontFeedMe); michael@0: NS_IMETHOD Done(); michael@0: protected: michael@0: virtual void Report(const char* aCharset); michael@0: private: michael@0: nsCOMPtr mObserver; michael@0: }; michael@0: michael@0: michael@0: //===================================================================== michael@0: class nsXPCOMStringDetector : michael@0: public nsUniversalDetector, michael@0: public nsIStringCharsetDetector michael@0: { michael@0: NS_DECL_ISUPPORTS michael@0: public: michael@0: nsXPCOMStringDetector(uint32_t aLanguageFilter); michael@0: virtual ~nsXPCOMStringDetector(); michael@0: NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen, michael@0: const char** oCharset, nsDetectionConfident &oConf); michael@0: protected: michael@0: virtual void Report(const char* aCharset); michael@0: private: michael@0: nsCOMPtr mObserver; michael@0: const char* mResult; michael@0: }; michael@0: michael@0: //===================================================================== michael@0: class nsUniversalXPCOMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsUniversalXPCOMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_ALL) {} michael@0: }; michael@0: michael@0: class nsUniversalXPCOMStringDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsUniversalXPCOMStringDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_ALL) {} michael@0: }; michael@0: michael@0: class nsJAPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsJAPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_JAPANESE) {} michael@0: }; michael@0: michael@0: class nsJAStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsJAStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_JAPANESE) {} michael@0: }; michael@0: michael@0: class nsKOPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsKOPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_KOREAN) {} michael@0: }; michael@0: michael@0: class nsKOStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsKOStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_KOREAN) {} michael@0: }; michael@0: michael@0: class nsZHTWPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsZHTWPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_CHINESE_TRADITIONAL) {} michael@0: }; michael@0: michael@0: class nsZHTWStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsZHTWStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_CHINESE_TRADITIONAL) {} michael@0: }; michael@0: michael@0: class nsZHCNPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsZHCNPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_CHINESE_SIMPLIFIED) {} michael@0: }; michael@0: michael@0: class nsZHCNStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsZHCNStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_CHINESE_SIMPLIFIED) {} michael@0: }; michael@0: michael@0: class nsZHPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsZHPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_CHINESE) {} michael@0: }; michael@0: michael@0: class nsZHStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsZHStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_CHINESE) {} michael@0: }; michael@0: michael@0: class nsCJKPSMDetector : public nsXPCOMDetector michael@0: { michael@0: public: michael@0: nsCJKPSMDetector() michael@0: : nsXPCOMDetector(NS_FILTER_CJK) {} michael@0: }; michael@0: michael@0: class nsCJKStringPSMDetector : public nsXPCOMStringDetector michael@0: { michael@0: public: michael@0: nsCJKStringPSMDetector() michael@0: : nsXPCOMStringDetector(NS_FILTER_CJK) {} michael@0: }; michael@0: michael@0: #endif //_nsUdetXPCOMWrapper_h__