void
GPrefsMgr::EditPrefs()
{
	assert(itsDialog == NULL);
	itsDialog =
		new GMailPrefsDialog(JXGetApplication(), ShowingStateInTitle(),
								AutoInsertingQuote(), ShowingSenderString(),
								GetSenderString(), GetDefaultMonoFont(),
								GetDefaultFontSize(), GetMaxQuote()/1024,
								(JXGetSpellChecker())->WillReportNoErrors(),
								GetTabCharWidth(),
								IsBeepingOnNewMail(), (JIndex)GetEncryptionType(),
								GetFilterFile(), GetDefaultInbox(), 
								IsOpeningMailboxWindow());
	assert(itsDialog != NULL);
	ListenTo(itsDialog);
	itsDialog->BeginDialog();
}
NS_IMETHODIMP
nsBeckyFilters::Import(char16_t **aError,
                       bool *_retval)
{
  NS_ENSURE_ARG_POINTER(aError);
  NS_ENSURE_ARG_POINTER(_retval);

  // If mLocation is null, set it to the default filter directory.
  // If mLocation is a file, we import it as incoming folder.
  // If mLocation is a directory, we try to import incoming and outgoing folders
  // from it (in default files).

  *_retval = false;
  nsresult rv;
  nsCOMPtr<nsIFile> filterFile;

  bool haveFile = false;

  if (!mLocation) {
    bool retval = false;
    rv = AutoLocate(nullptr, getter_AddRefs(mLocation), &retval);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!retval)
      return NS_ERROR_FILE_NOT_FOUND;
  }

  // What type of location do we have?
  bool isDirectory = false;
  rv = mLocation->IsDirectory(&isDirectory);
  NS_ENSURE_SUCCESS(rv, rv);
  if (isDirectory) {
    haveFile = false;
  } else {
    bool isFile = false;
    rv = mLocation->IsFile(&isFile);
    NS_ENSURE_SUCCESS(rv, rv);
    if (isFile) {
      haveFile = true;
      mLocation->Clone(getter_AddRefs(filterFile));
    } else {
      // mLocation is neither file nor directory.
      return NS_ERROR_UNEXPECTED;
    }
  }

  bool haveIncoming = true;
  if (haveFile) {
    // If the passed filename equals OFilter.def, import as outgoing filters.
    // Everything else is considered incoming.
    nsAutoString fileName;
    rv = mLocation->GetLeafName(fileName);
    NS_ENSURE_SUCCESS(rv, rv);
    if (fileName.EqualsLiteral("OFilter.def"))
      haveIncoming = false;
  }

  // Try importing from the passed in file or the default incoming filters file.
  if ((haveFile && haveIncoming) || (!haveFile &&
      NS_SUCCEEDED(GetFilterFile(true, mLocation, getter_AddRefs(filterFile)))))
  {
    rv = CollectServers();
    NS_ENSURE_SUCCESS(rv, rv);

    rv = nsBeckyUtils::ConvertToUTF8File(filterFile, getter_AddRefs(mConvertedFile));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = ParseFilterFile(mConvertedFile, true);
    if (NS_SUCCEEDED(rv))
      *_retval = true;

    (void)RemoveConvertedFile();
  }

  // If we didn't have a file passed (but a directory), try finding also outgoing filters.
  if ((haveFile && !haveIncoming) || (!haveFile &&
      NS_SUCCEEDED(GetFilterFile(false, mLocation, getter_AddRefs(filterFile)))))
  {
    rv = CollectServers();
    NS_ENSURE_SUCCESS(rv, rv);

    rv = nsBeckyUtils::ConvertToUTF8File(filterFile, getter_AddRefs(mConvertedFile));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = ParseFilterFile(mConvertedFile, false);
    if (NS_SUCCEEDED(rv))
      *_retval = true;

    (void)RemoveConvertedFile();
  }

  return rv;
}