mailnews/import/src/nsImportService.h
author Martin Schroeder <mschroeder@mozilla.x-home.org>
Sat, 29 Mar 2014 17:36:26 +0100
changeset 15953 43b4a4ac9623ae1bda93eee8851defc294f07e60
parent 13566 9eb3e41bab9bff569c7c6b939e593b390c67c287
child 16470 21e13ac2fe1f124fd027a0b1b111c6b04154f443
permissions -rw-r--r--
Bug 924837 - Update internal timezone database from version 2014a to version 2014b. r=philipp CLOSED TREE

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */

#ifndef nsImportService_h__
#define nsImportService_h__

#include "nsICharsetConverterManager.h"

#include "nsStringGlue.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIImportModule.h"
#include "nsIImportService.h"
#include "nsICategoryManager.h"
#include "nsIStringBundle.h"

class nsImportModuleList;

class nsImportService : public nsIImportService
{
public:

  nsImportService();
  virtual ~nsImportService();

  NS_DECL_THREADSAFE_ISUPPORTS

    NS_DECL_NSIIMPORTSERVICE

private:
    nsresult LoadModuleInfo(const char*pClsId, const char *pSupports);
  nsresult DoDiscover(void);

private:
    nsImportModuleList * m_pModules;
  bool m_didDiscovery;
  nsCString m_sysCharset;
  nsIUnicodeDecoder * m_pDecoder;
  nsIUnicodeEncoder * m_pEncoder;
  nsCOMPtr<nsIStringBundle> m_stringBundle;
};

class ImportModuleDesc {
public:
  ImportModuleDesc() { m_pModule = nullptr;}
  ~ImportModuleDesc() { ReleaseModule();  }

  void  SetCID(const nsCID& cid) { m_cid = cid;}
  void  SetName(const char16_t *pName) { m_name = pName;}
  void  SetDescription(const char16_t *pDesc) { m_description = pDesc;}
  void  SetSupports(const char *pSupports) { m_supports = pSupports;}

  nsCID      GetCID(void) { return m_cid;}
  const char16_t *GetName(void) { return m_name.get();}
  const char16_t *GetDescription(void) { return m_description.get();}
  const char *  GetSupports(void) { return m_supports.get();}

  nsIImportModule *  GetModule(bool keepLoaded = false); // Adds ref
  void        ReleaseModule(void);

  bool        SupportsThings(const char *pThings);

private:
    nsCID m_cid;
  nsString m_name;
  nsString m_description;
  nsCString m_supports;
  nsIImportModule *m_pModule;
};

class nsImportModuleList {
public:
  nsImportModuleList() { m_pList = nullptr; m_alloc = 0; m_count = 0;}
  ~nsImportModuleList() { ClearList(); }

  void  AddModule(const nsCID& cid, const char *pSupports, const char16_t *pName, const char16_t *pDesc);

  void  ClearList(void);

  int32_t  GetCount(void) { return m_count;}

  ImportModuleDesc *  GetModuleDesc(int32_t idx)
    { if ((idx < 0) || (idx >= m_count)) return nullptr; else return m_pList[idx];}

private:

private:
    ImportModuleDesc **  m_pList;
  int32_t        m_alloc;
  int32_t        m_count;
};

#endif // nsImportService_h__