From 302bf1b523012e11b60425d6eee1221ebc2724eb Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 3 Nov 2019 00:17:46 -0400 Subject: Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1 --- mailnews/jsaccount/src/JaUrl.h | 121 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 mailnews/jsaccount/src/JaUrl.h (limited to 'mailnews/jsaccount/src/JaUrl.h') diff --git a/mailnews/jsaccount/src/JaUrl.h b/mailnews/jsaccount/src/JaUrl.h new file mode 100644 index 000000000..57c902eee --- /dev/null +++ b/mailnews/jsaccount/src/JaUrl.h @@ -0,0 +1,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 mFolder; + + // nsIMsgMessageUrl variables. + + // the uri for the original message, like ews-message://server/folder#123 + nsCString mUri; + nsCOMPtr 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 mJsIMsgMailNewsUrl; + nsCOMPtr mJsIURI; + nsCOMPtr mJsIURIWithQuery; + nsCOMPtr mJsIURL; + nsCOMPtr mJsIMsgMessageUrl; + nsCOMPtr mJsIInterfaceRequestor; + + // Owning reference to the JS override. + nsCOMPtr mJsISupports; + + // Class to bypass JS delegates. nsCOMPtr for when we do cycle collection. + nsCOMPtr mCppBase; + + RefPtr mDelegateList; + nsDataHashtable *mMethods; +}; + +} // namespace mailnews +} // namespace mozilla + +#endif -- cgit v1.2.3