summaryrefslogtreecommitdiffstats
path: root/mailnews/extensions/mdn/src/nsMsgMdnGenerator.h
blob: 54b6efab4e95329c0a2ccb0d0e0ccfe1d3acf5a8 (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
87
88
89
90
/* -*- 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 _nsMsgMdnGenerator_H_
#define _nsMsgMdnGenerator_H_

#include "nsIMsgMdnGenerator.h"
#include "nsCOMPtr.h"
#include "nsIUrlListener.h"
#include "nsIMsgIncomingServer.h"
#include "nsIOutputStream.h"
#include "nsIFile.h"
#include "nsIMsgIdentity.h"
#include "nsIMsgWindow.h"
#include "nsIMimeHeaders.h"
#include "nsStringGlue.h"
#include "MailNewsTypes2.h"

#define eNeverSendOp ((int32_t) 0)
#define eAutoSendOp ((int32_t) 1)
#define eAskMeOp ((int32_t) 2)
#define eDeniedOp ((int32_t) 3)

class nsMsgMdnGenerator : public nsIMsgMdnGenerator, public nsIUrlListener
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIMSGMDNGENERATOR
  NS_DECL_NSIURLLISTENER

  nsMsgMdnGenerator();

private:
  virtual ~nsMsgMdnGenerator();

  // Sanity Check methods
  bool ProcessSendMode(); // must called prior ValidateReturnPath
  bool ValidateReturnPath();
  bool NotInToOrCc();
  bool MailAddrMatch(const char *addr1, const char *addr2);

  nsresult StoreMDNSentFlag(nsIMsgFolder *folder, nsMsgKey key);
  nsresult ClearMDNNeededFlag(nsIMsgFolder *folder, nsMsgKey key);
  nsresult NoteMDNRequestHandled();

  nsresult CreateMdnMsg();
  nsresult CreateFirstPart();
  nsresult CreateSecondPart();
  nsresult CreateThirdPart();
  nsresult SendMdnMsg();

  // string bundle helper methods
  nsresult GetStringFromName(const char16_t *aName, char16_t **aResultString);
  nsresult FormatStringFromName(const char16_t *aName,
                                const char16_t *aString,
                                char16_t **aResultString);

  // other helper methods
  nsresult InitAndProcess(bool *needToAskUser);
  nsresult OutputAllHeaders();
  nsresult WriteString(const char *str);

private:
  EDisposeType m_disposeType;
  nsCOMPtr<nsIMsgWindow> m_window;
  nsCOMPtr<nsIOutputStream> m_outputStream;
  nsCOMPtr<nsIFile> m_file;
  nsCOMPtr<nsIMsgIdentity> m_identity;
  nsMsgKey m_key;
  nsCString m_charset;
  nsCString m_email;
  nsCString m_mimeSeparator;
  nsCString m_messageId;
  nsCOMPtr<nsIMsgFolder> m_folder;
  nsCOMPtr<nsIMsgIncomingServer> m_server;
  nsCOMPtr<nsIMimeHeaders> m_headers;
  nsCString m_dntRrt;
  int32_t m_notInToCcOp;
  int32_t m_outsideDomainOp;
  int32_t m_otherOp;
  bool m_reallySendMdn;
  bool m_autoSend;
  bool m_autoAction;
  bool m_mdnEnabled;
};

#endif // _nsMsgMdnGenerator_H_