summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/local/src/nsMailboxUrl.h
blob: 29b932e38cd7c5d30001f7f1ede9ef617b4884cd (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* -*- 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 nsMailboxUrl_h__
#define nsMailboxUrl_h__

#include "mozilla/Attributes.h"
#include "nsIMailboxUrl.h"
#include "nsMsgMailNewsUrl.h"
#include "nsIStreamListener.h"
#include "nsIFile.h"
#include "nsCOMPtr.h"
#include "MailNewsTypes.h"
#include "nsTArray.h"

class nsMailboxUrl : public nsIMailboxUrl,
                     public nsMsgMailNewsUrl,
                     public nsIMsgMessageUrl,
                     public nsIMsgI18NUrl {
 public:
  // nsIMsgMailNewsUrl override
  nsresult SetSpecInternal(const nsACString& aSpec) override;
  nsresult SetQuery(const nsACString& aQuery) override;
  nsresult CreateURL(const nsACString& aSpec, nsIURL** aURL) override;

  // from nsIMailboxUrl:
  NS_IMETHOD SetMailboxParser(nsIStreamListener* aConsumer) override;
  NS_IMETHOD GetMailboxParser(nsIStreamListener** aConsumer) override;
  NS_IMETHOD SetMailboxCopyHandler(nsIStreamListener* aConsumer) override;
  NS_IMETHOD GetMailboxCopyHandler(nsIStreamListener** aConsumer) override;

  NS_IMETHOD GetMessageKey(nsMsgKey* aMessageKey) override;
  NS_IMETHOD GetMessageSize(uint32_t* aMessageSize) override;
  NS_IMETHOD SetMessageSize(uint32_t aMessageSize) override;
  NS_IMETHOD GetMailboxAction(nsMailboxAction* result) override {
    NS_ENSURE_ARG_POINTER(result);
    *result = m_mailboxAction;
    return NS_OK;
  }
  NS_IMETHOD SetMailboxAction(nsMailboxAction aAction) override {
    m_mailboxAction = aAction;
    return NS_OK;
  }
  NS_IMETHOD IsUrlType(uint32_t type, bool* isType) override;
  NS_IMETHOD SetMoveCopyMsgKeys(const nsTArray<nsMsgKey>& keysToFlag) override;
  NS_IMETHOD GetMoveCopyMsgHdrForIndex(uint32_t msgIndex,
                                       nsIMsgDBHdr** msgHdr) override;
  NS_IMETHOD GetNumMoveCopyMsgs(uint32_t* numMsgs) override;
  NS_IMETHOD GetCurMoveCopyMsgIndex(uint32_t* result) override {
    NS_ENSURE_ARG_POINTER(result);
    *result = m_curMsgIndex;
    return NS_OK;
  }
  NS_IMETHOD SetCurMoveCopyMsgIndex(uint32_t aIndex) override {
    m_curMsgIndex = aIndex;
    return NS_OK;
  }

  NS_IMETHOD GetFolder(nsIMsgFolder** msgFolder) override;

  // nsMsgMailNewsUrl override
  nsresult Clone(nsIURI** _retval) override;

  // nsMailboxUrl
  nsMailboxUrl();
  NS_DECL_NSIMSGMESSAGEURL
  NS_DECL_ISUPPORTS_INHERITED
  NS_DECL_NSIMSGI18NURL

 protected:
  virtual ~nsMailboxUrl();
  // protocol specific code to parse a url...
  virtual nsresult ParseUrl();
  nsresult GetMsgHdrForKey(nsMsgKey msgKey, nsIMsgDBHdr** aMsgHdr);

  // mailboxurl specific state
  nsCOMPtr<nsIStreamListener> m_mailboxParser;
  nsCOMPtr<nsIStreamListener> m_mailboxCopyHandler;

  nsMailboxAction m_mailboxAction;  // the action this url represents...parse
                                    // mailbox, display messages, etc.
  nsCOMPtr<nsIFile> m_filePath;
  char* m_messageID;
  uint32_t m_messageSize;
  nsMsgKey m_messageKey;
  nsCString m_file;

  // used by save message to disk
  nsCOMPtr<nsIFile> m_messageFile;
  bool m_addDummyEnvelope;
  bool m_canonicalLineEnding;
  nsresult ParseSearchPart();

  // for multiple msg move/copy
  nsTArray<nsMsgKey> m_keys;
  int32_t m_curMsgIndex;

  // truncated message support
  nsCString m_originalSpec;
  nsCString mURI;           // the RDF URI associated with this url.
  bool mAutodetectCharset;  // used by nsIMsgI18NUrl...
};

#endif  // nsMailboxUrl_h__