Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsNativeDetector Class Reference
Inheritance diagram for nsNativeDetector:
Inheritance graph
[legend]
Collaboration diagram for nsNativeDetector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsNativeDetector (PRUint32 aCodePage)
virtual ~nsNativeDetector ()
NS_IMETHOD Init (nsICharsetDetectionObserver *aObserver)
NS_IMETHOD DoIt (const char *aBuf, PRUint32 aLen, PRBool *oDontFeedMe)
NS_IMETHOD Done ()

Private Attributes

nsICharsetDetectionObservermObserver
IMultiLanguage * mMultiLanguage
IMLangConvertCharset * mMLangConvertCharset
PRUint32 mCodePage
char mCharset [65]

Detailed Description

Definition at line 105 of file nsNativeDetectors.cpp.


Constructor & Destructor Documentation

Definition at line 137 of file nsNativeDetectors.cpp.

{
  NS_IF_RELEASE(mObserver);
  if (NULL != mMultiLanguage)
    mMultiLanguage->Release();
  if (NULL != mMLangConvertCharset)
    mMLangConvertCharset->Release();
  CoUninitialize();
}

Member Function Documentation

NS_IMETHODIMP nsNativeDetector::DoIt ( const char *  aBuf,
PRUint32  aLen,
PRBool oDontFeedMe 
) [virtual]

Implements nsICharsetDetector.

Definition at line 166 of file nsNativeDetectors.cpp.

{
  NS_ASSERTION(mObserver != nsnull , "have not init yet");

  if((nsnull == aBuf) || (nsnull == oDontFeedMe))
     return NS_ERROR_ILLEGAL_VALUE;

  UINT theSize = (UINT) aLen;
  nsDetectionConfident aConfidence;
  if (SUCCEEDED(DetectCharsetUsingMLang(mMultiLanguage, mMLangConvertCharset, 
                                        mCharset, aConfidence, (BYTE *) aBuf, &theSize))) {
    if (eNoAnswerMatch != aConfidence) {
      mObserver->Notify(mCharset, aConfidence);
    }
  }
  else {
    mObserver->Notify("", eNoAnswerMatch);
  }

  *oDontFeedMe = PR_TRUE;

  return NS_OK;
}

Here is the call graph for this function:

Implements nsICharsetDetector.

Definition at line 191 of file nsNativeDetectors.cpp.

{
  NS_ASSERTION(mObserver != nsnull , "have not init yet");
  return NS_OK;
}

Implements nsICharsetDetector.

Definition at line 147 of file nsNativeDetectors.cpp.

{
  NS_ASSERTION(mObserver == nsnull , "Init twice");
  if(nsnull == aObserver)
     return NS_ERROR_ILLEGAL_VALUE;

  mObserver = aObserver;

  HRESULT hr = CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, 
                                IID_IMultiLanguage, (LPVOID *)&mMultiLanguage);
  if (SUCCEEDED(hr)) {
    DWORD dwProperty = 0;
    hr = mMultiLanguage->CreateConvertCharset(mCodePage, 1200, dwProperty, &mMLangConvertCharset);
  }

  return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
}

Member Data Documentation

char nsNativeDetector::mCharset[65] [private]

Definition at line 122 of file nsNativeDetectors.cpp.

Definition at line 121 of file nsNativeDetectors.cpp.

IMLangConvertCharset* nsNativeDetector::mMLangConvertCharset [private]

Definition at line 120 of file nsNativeDetectors.cpp.

IMultiLanguage* nsNativeDetector::mMultiLanguage [private]

Definition at line 119 of file nsNativeDetectors.cpp.

Definition at line 118 of file nsNativeDetectors.cpp.


The documentation for this class was generated from the following file: