summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/import/src/nsAppleMailImport.h
blob: dd799b06be3f3bfba8a215b390a3f53d4a15dff9 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* -*- Mode: C++; tab-width: 2; 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/. */

#ifndef nsAppleMailImport_h___
#define nsAppleMailImport_h___

#include "mozilla/Logging.h"
#include "nsIImportModule.h"
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#include "nsIImportMail.h"
#include "ImportDebug.h"

#define NS_APPLEMAILIMPL_CID                         \
  {                                                  \
    0x9117a1ea, 0xe012, 0x43b5, {                    \
      0xa0, 0x20, 0xcb, 0x8a, 0x66, 0xcc, 0x09, 0xe1 \
    }                                                \
  }

#define NS_APPLEMAILIMPORT_CID                       \
  {                                                  \
    0x6d3f101c, 0x70ec, 0x4e04, {                    \
      0xb6, 0x8d, 0x99, 0x08, 0xd1, 0xae, 0xdd, 0xf3 \
    }                                                \
  }

#define NS_APPLEMAILIMPL_CONTRACTID "@mozilla.org/import/import-appleMailImpl;1"

#define kAppleMailSupportsString "mail"

class nsIImportService;

class nsAppleMailImportModule : public nsIImportModule {
 public:
  nsAppleMailImportModule();

  NS_DECL_THREADSAFE_ISUPPORTS
  NS_DECL_NSIIMPORTMODULE

 private:
  virtual ~nsAppleMailImportModule();

  nsCOMPtr<nsIStringBundle> mBundle;
};

class nsAppleMailImportMail : public nsIImportMail {
 public:
  nsAppleMailImportMail();

  NS_DECL_THREADSAFE_ISUPPORTS
  NS_DECL_NSIIMPORTMAIL

  nsresult Initialize();

 private:
  virtual ~nsAppleMailImportMail();

  void FindAccountMailDirs(
      nsIFile* aRoot,
      nsTArray<RefPtr<nsIImportMailboxDescriptor>>& aMailboxDescs,
      nsIImportService* aImportService);
  nsresult FindMboxDirs(
      nsIFile* aFolder,
      nsTArray<RefPtr<nsIImportMailboxDescriptor>>& aMailboxDescs,
      nsIImportService* aImportService);
  nsresult AddMboxDir(
      nsIFile* aFolder,
      nsTArray<RefPtr<nsIImportMailboxDescriptor>>& aMailboxDescs,
      nsIImportService* aImportService);

  // aInfoString is the format to a "foo %s" string. It may be NULL if the error
  // string needs no such format.
  void ReportStatus(const char16_t* aErrorName, nsString& aName,
                    nsAString& aStream);
  static void SetLogs(const nsAString& success, const nsAString& error,
                      char16_t** aOutErrorLog, char16_t** aSuccessLog);

  nsCOMPtr<nsIStringBundle> mBundle;
  uint32_t mProgress;
  uint16_t mCurDepth;
};

#endif /* nsAppleMailImport_h___ */