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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 _JaUrl_H_
#define _JaUrl_H_
#include "DelegateList.h"
#include "msgCore.h"
#include "msgIOverride.h"
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsDataHashtable.h"
#include "nsIFile.h"
#include "nsIInterfaceRequestor.h"
#include "nsIMsgFolder.h"
#include "nsISupports.h"
#include "nsMsgMailNewsUrl.h"
#include "nsWeakReference.h"
namespace mozilla {
namespace mailnews {
/* Header file */
// This class is an XPCOM component, usable in JS, that calls the methods
// in the C++ base class (bypassing any JS override).
class JaBaseCppUrl : public nsMsgMailNewsUrl,
public nsIMsgMessageUrl,
public nsIInterfaceRequestor,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMSGMESSAGEURL
NS_DECL_NSIINTERFACEREQUESTOR
JaBaseCppUrl() { }
// nsIMsgMailNewsUrl overrides
NS_IMETHOD GetFolder(nsIMsgFolder **aFolder) override;
NS_IMETHOD SetFolder(nsIMsgFolder *aFolder) override;
protected:
virtual ~JaBaseCppUrl() { }
// nsIMsgMailUrl variables.
nsCOMPtr<nsIMsgFolder> mFolder;
// nsIMsgMessageUrl variables.
// the uri for the original message, like ews-message://server/folder#123
nsCString mUri;
nsCOMPtr<nsIFile> mMessageFile;
bool mCanonicalLineEnding;
nsCString mOriginalSpec;
};
class JaCppUrlDelegator : public JaBaseCppUrl,
public msgIOverride
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_MSGIOVERRIDE
NS_FORWARD_NSIMSGMAILNEWSURL(DELEGATE_JS(nsIMsgMailNewsUrl, mJsIMsgMailNewsUrl)->)
NS_FORWARD_NSIURI(DELEGATE_JS(nsIURI, mJsIURI)->)
NS_FORWARD_NSIURIWITHQUERY(DELEGATE_JS(nsIURIWithQuery, mJsIURIWithQuery)->)
NS_FORWARD_NSIURL(DELEGATE_JS(nsIURL, mJsIURL)->)
NS_FORWARD_NSIMSGMESSAGEURL(DELEGATE_JS(nsIMsgMessageUrl, mJsIMsgMessageUrl)->)
NS_FORWARD_NSIINTERFACEREQUESTOR(DELEGATE_JS(nsIInterfaceRequestor, mJsIInterfaceRequestor)->)
JaCppUrlDelegator();
class Super : public nsIMsgMailNewsUrl,
public nsIMsgMessageUrl,
public nsIInterfaceRequestor
{
public:
Super(JaCppUrlDelegator *aFakeThis) {mFakeThis = aFakeThis;}
NS_DECL_ISUPPORTS
NS_FORWARD_NSIMSGMAILNEWSURL(mFakeThis->JaBaseCppUrl::)
NS_FORWARD_NSIURI(mFakeThis->JaBaseCppUrl::)
NS_FORWARD_NSIURIWITHQUERY(mFakeThis->JaBaseCppUrl::)
NS_FORWARD_NSIURL(mFakeThis->JaBaseCppUrl::)
NS_FORWARD_NSIMSGMESSAGEURL(mFakeThis->JaBaseCppUrl::)
NS_FORWARD_NSIINTERFACEREQUESTOR(mFakeThis->JaBaseCppUrl::)
private:
virtual ~Super() {}
JaCppUrlDelegator *mFakeThis;
};
private:
virtual ~JaCppUrlDelegator() {
}
// Interfaces that may be overridden by JS.
nsCOMPtr<nsIMsgMailNewsUrl> mJsIMsgMailNewsUrl;
nsCOMPtr<nsIURI> mJsIURI;
nsCOMPtr<nsIURIWithQuery> mJsIURIWithQuery;
nsCOMPtr<nsIURL> mJsIURL;
nsCOMPtr<nsIMsgMessageUrl> mJsIMsgMessageUrl;
nsCOMPtr<nsIInterfaceRequestor> mJsIInterfaceRequestor;
// Owning reference to the JS override.
nsCOMPtr<nsISupports> mJsISupports;
// Class to bypass JS delegates. nsCOMPtr for when we do cycle collection.
nsCOMPtr<nsIMsgMailNewsUrl> mCppBase;
RefPtr<DelegateList> mDelegateList;
nsDataHashtable<nsCStringHashKey, bool> *mMethods;
};
} // namespace mailnews
} // namespace mozilla
#endif
|