Bug 1489949 - Backed out changeset 995fe17c5348 for being incorrect. a=backout
authorJorg K <jorgk@jorgk.com>
Wed, 12 Sep 2018 08:48:26 +0200
changeset 33133 9dc7f65220a4a9b888d916d40d08cedbf673b416
parent 33132 a4f58095ed048c01694c7f66c1ad9f4f2431da57
child 33134 4d4e022e66970521a0962db37b3d07071638a854
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersbackout
bugs1489949
Bug 1489949 - Backed out changeset 995fe17c5348 for being incorrect. a=backout
mailnews/mime/src/comi18n.cpp
mailnews/mime/src/moz.build
--- a/mailnews/mime/src/comi18n.cpp
+++ b/mailnews/mime/src/comi18n.cpp
@@ -1,27 +1,21 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "comi18n.h"
-#include "nsICharsetDetector.h"
 #include "nsIStringCharsetDetector.h"
-#include "nsCyrillicDetector.h"
-#include "nsUniversalDetector.h"
-#include "nsUdetXPCOMWrapper.h"
 #include "nsMsgUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgMimeCID.h"
 #include "nsIMimeConverter.h"
-#include "mozilla/Preferences.h"
 
-using namespace mozilla;
 
 ////////////////////////////////////////////////////////////////////////////////
 // BEGIN PUBLIC INTERFACE
 extern "C" {
 
 
 void MIME_DecodeMimeHeader(const char *header, const char *default_charset,
                            bool override_charset, bool eatContinuations,
@@ -34,64 +28,38 @@ void MIME_DecodeMimeHeader(const char *h
     result.Truncate();
     return;
   }
   mimeConverter->DecodeMimeHeaderToUTF8(nsDependentCString(header),
                                         default_charset, override_charset,
                                         eatContinuations, result);
 }
 
-class nsJAStringPSMDetector : public nsXPCOMStringDetector
-{
-public:
-  nsJAStringPSMDetector()
-    : nsXPCOMStringDetector() {}
-};
-
-class nsRUStringProbDetector : public nsCyrXPCOMStringDetector
-{
-  public:
-    nsRUStringProbDetector()
-      : nsCyrXPCOMStringDetector(5, gCyrillicCls, gRussian) {}
-};
-
-class nsUKStringProbDetector : public nsCyrXPCOMStringDetector
-{
-  public:
-    nsUKStringProbDetector()
-      : nsCyrXPCOMStringDetector(5, gCyrillicCls, gUkrainian) {}
-};
-
 // UTF-8 utility functions.
 //detect charset soly based on aBuf. return in aCharset
 nsresult
 MIME_detect_charset(const char *aBuf, int32_t aLength, const char** aCharset)
 {
   nsresult res = NS_ERROR_UNEXPECTED;
+  nsString detector_name;
   *aCharset = nullptr;
-  nsCOMPtr<nsIStringCharsetDetector> detector;
-  nsAutoCString detectorName;
-  Preferences::GetLocalizedCString("intl.charset.detector", detectorName);
+
+  NS_GetLocalizedUnicharPreferenceWithDefault(nullptr, "intl.charset.detector", EmptyString(), detector_name);
 
-  if (!detectorName.IsEmpty()) {
-    // We recognize one of the three magic strings for the following languages.
-    if (detectorName.EqualsLiteral("ruprob")) {
-      detector = new nsRUStringProbDetector();
-    } else if (detectorName.EqualsLiteral("ukprob")) {
-      detector = new nsUKStringProbDetector();
-    } else if (detectorName.EqualsLiteral("ja_parallel_state_machine")) {
-      detector = new nsJAStringPSMDetector();
-    }
-  }
-
-  if (detector) {
-    nsDetectionConfident oConfident;
-    res = detector->DoIt(aBuf, aLength, aCharset, oConfident);
-    if (NS_SUCCEEDED(res) && (eBestAnswer == oConfident || eSureAnswer == oConfident)) {
-      return NS_OK;
+  if (!detector_name.IsEmpty()) {
+    nsAutoCString detector_contractid;
+    detector_contractid.AssignLiteral(NS_STRCDETECTOR_CONTRACTID_BASE);
+    detector_contractid.Append(NS_ConvertUTF16toUTF8(detector_name));
+    nsCOMPtr<nsIStringCharsetDetector> detector = do_CreateInstance(detector_contractid.get(), &res);
+    if (NS_SUCCEEDED(res)) {
+      nsDetectionConfident oConfident;
+      res = detector->DoIt(aBuf, aLength, aCharset, oConfident);
+      if (NS_SUCCEEDED(res) && (eBestAnswer == oConfident || eSureAnswer == oConfident)) {
+        return NS_OK;
+      }
     }
   }
   return res;
 }
 
 } /* end of extern "C" */
 // END PUBLIC INTERFACE
 
--- a/mailnews/mime/src/moz.build
+++ b/mailnews/mime/src/moz.build
@@ -66,22 +66,19 @@ SOURCES += [
     'nsCMS.cpp',
     'nsCMSSecureMessage.cpp',
     'nsMimeObjectClassAccess.cpp',
     'nsSimpleMimeConverterStub.cpp',
     'nsStreamConverter.cpp',
 ]
 
 LOCAL_INCLUDES += [
-    '/%s/extensions/universalchardet/src/base' % CONFIG['mozreltopsrcdir'],
-    '/%s/extensions/universalchardet/src/xpcom' % CONFIG['mozreltopsrcdir'],
-    '/%s/intl/chardet' % CONFIG['mozreltopsrcdir'],
-    '/%s/security/certverifier' % CONFIG['mozreltopsrcdir'],
-    '/%s/security/manager/ssl' % CONFIG['mozreltopsrcdir'],
-    '/%s/security/pkix/include' % CONFIG['mozreltopsrcdir'],
+     '/%s/security/certverifier' % CONFIG['mozreltopsrcdir'],
+     '/%s/security/manager/ssl' % CONFIG['mozreltopsrcdir'],
+     '/%s/security/pkix/include' % CONFIG['mozreltopsrcdir'],
 ]
 
 EXTRA_COMPONENTS += [
     'mimeJSComponents.js',
     'msgMime.manifest',
 ]
 
 EXTRA_JS_MODULES += [