mailnews/import/eudora/src/nsEudoraMac.h
author Stefan Sitter <ssitter@gmail.com>
Mon, 29 Jun 2015 16:25:25 +0200
changeset 22819 99d02f70de9aff76228a13857aaf4020863c6974
parent 22208 94adb5945ec3147c246b55b123676c324274fd25
permissions -rw-r--r--
Bug 1163306 - enable icaljs by default only on comm-central, use libical on comm-aurora. r=philipp

/* -*- 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 nsEudoraMac_h__
#define nsEudoraMac_h__

#include "mozilla/Attributes.h"
#include "nscore.h"
#include "nsStringGlue.h"
#include "nsIFile.h"
#include "nsEudoraMailbox.h"
#include "nsEudoraAddress.h"

#include <CoreServices/CoreServices.h>

class nsIImportService;
class nsIMsgAccountManager;
class nsIMsgAccount;
class nsIMutableArray;


class nsEudoraMac : public nsEudoraMailbox, public nsEudoraAddress {
public:
  nsEudoraMac();
  ~nsEudoraMac();

    // retrieve the mail folder
  virtual bool      FindMailFolder(nsIFile **pFolder) override;
    // get the list of mailboxes
  virtual nsresult  FindMailboxes(nsIFile *pRoot,
                                  nsIMutableArray *pArray) override;
    // get a TOC file from a mailbox file
  virtual nsresult  FindTOCFile(nsIFile *pMailFile,
                                nsIFile **pTOCFile,
                                bool *pDeleteToc) override;

  virtual nsresult  GetAttachmentInfo(const char *pFileName,
                                      nsIFile *pFile,
                                      nsCString& mimeType,
                                      nsCString& aAttachment) override;

    // Address book stuff
  virtual bool      FindAddressFolder(nsIFile **pFolder) override;
    // get the list of mailboxes
  virtual nsresult  FindAddressBooks(nsIFile *pRoot,
                                     nsIMutableArray *pArray) override;

    // import settings
  static bool    ImportSettings(nsIFile *pIniFile,
                                nsIMsgAccount **localMailAccount);
  static bool    FindSettingsFile(nsIFile **pIniFile) { return FindEudoraLocation(pIniFile, true);}

  static bool    FindFiltersFile(nsIFile **pFiltersFile);

private:
  static bool    FindEudoraLocation(nsIFile **pFolder,
                                    bool findIni = false,
                                    nsIFile *pLookIn = nullptr);
  static bool    FindEudoraLocation(nsIFile **pFolder,
                                    bool findIni,
                                    const char *specialDirName);
  static bool    VerifyEudoraLocation(nsIFile **pFolder, bool findIni);


  nsresult  ScanMailDir(nsIFile *pFolder,
                        nsIMutableArray *pArray,
                        nsIImportService *pImport);
  nsresult  IterateMailDir(nsIFile *pFolder,
                           nsIMutableArray *pArray,
                           nsIImportService *pImport);
  nsresult  FoundMailFolder(nsIFile *mailFolder,
                            const char *pName,
                            nsIMutableArray *pArray,
                            nsIImportService *pImport);
  nsresult  FoundMailbox(nsIFile *mailFile,
                         const char *pName,
                         nsIMutableArray *pArray,
                         nsIImportService *pImport);

  bool      IsValidMailFolderName(nsCString& name);
  bool      IsValidMailboxName(nsCString& fName);
  bool      IsValidMailboxFile(nsIFile *pFile);

  bool      CreateTocFromResource(nsIFile *pMail, nsIFile **pToc);



    // Settings support
  static bool    BuildPOPAccount(nsIMsgAccountManager *accMgr,
                                 nsCString **pStrs,
                                 nsIMsgAccount **ppAccount,
                                 nsString& accName);
  static bool    BuildIMAPAccount(nsIMsgAccountManager *accMgr,
                                  nsCString **pStrs,
                                  nsIMsgAccount **ppAccount,
                                  nsString& accName);
  static void    SetIdentities(nsIMsgAccountManager *accMgr,
                               nsIMsgAccount *acc,
                               const char *userName,
                               const char *serverName,
                               nsCString **pStrs);
  static void    SetSmtpServer(nsIMsgAccountManager *pMgr,
                               nsIMsgAccount *pAcc,
                               const char *pServer,
                               const char *pUser);
  static bool    GetSettingsFromResource(nsIFile *pSettings,
                                         short resId,
                                         nsCString **pStrs,
                                         bool *pIMAP);


private:
  uint32_t m_depth;
  nsCOMPtr <nsIFile> m_mailImportLocation;
  bool HasResourceFork(FSRef *fsRef);
};


#endif /* nsEudoraMac_h__ */