summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/import/src/nsImportService.h
blob: 37dd95b935f27da59db8c2205617297196f3cca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* -*- 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 "nsString.h"
#include "nsMemory.h"
#include "nsIImportModule.h"
#include "nsIImportService.h"
#include "nsIStringBundle.h"
#include "nsTArray.h"

class ImportModuleDesc {
 public:
  explicit ImportModuleDesc(nsIImportModule* importModule);

  const nsAString& GetName(void) { return m_name; }
  const nsAString& GetDescription(void) { return m_description; }

  nsCOMPtr<nsIImportModule>& GetModule() { return m_pModule; }

  bool SupportsThings(const nsACString& pThings);

 private:
  nsString m_name;
  nsString m_description;
  nsCString m_supports;
  nsCOMPtr<nsIImportModule> m_pModule;
};

class nsImportService : public nsIImportService {
 public:
  nsImportService();

  NS_DECL_THREADSAFE_ISUPPORTS
  NS_DECL_NSIIMPORTSERVICE

 private:
  virtual ~nsImportService();
  nsresult LoadModuleInfo(const nsCString& contractId);
  nsresult DoDiscover(void);
  ImportModuleDesc* GetImportModule(const char* filter, int32_t index);

 private:
  AutoTArray<ImportModuleDesc, 10> m_importModules;
  bool m_didDiscovery;
  nsCString m_sysCharset;
  nsCOMPtr<nsIStringBundle> m_stringBundle;
};

#endif  // nsImportService_h__