From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mailnews/jsaccount/src/JaAbDirectory.cpp | 81 +++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 comm/mailnews/jsaccount/src/JaAbDirectory.cpp (limited to 'comm/mailnews/jsaccount/src/JaAbDirectory.cpp') diff --git a/comm/mailnews/jsaccount/src/JaAbDirectory.cpp b/comm/mailnews/jsaccount/src/JaAbDirectory.cpp new file mode 100644 index 0000000000..11b29e99ab --- /dev/null +++ b/comm/mailnews/jsaccount/src/JaAbDirectory.cpp @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; 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/. */ + +#include "JaAbDirectory.h" +#include "nsComponentManagerUtils.h" + +namespace mozilla { +namespace mailnews { + +NS_IMPL_ISUPPORTS_INHERITED(JaBaseCppAbDirectory, nsAbDirProperty, + nsIInterfaceRequestor) + +// nsIInterfaceRequestor implementation +NS_IMETHODIMP JaBaseCppAbDirectory::GetInterface(const nsIID& aIID, + void** aSink) { + return QueryInterface(aIID, aSink); +} + +// Delegator +NS_IMPL_ISUPPORTS_INHERITED(JaCppAbDirectoryDelegator, JaBaseCppAbDirectory, + msgIOverride) + +// Delegator object to bypass JS method override. +NS_IMPL_ISUPPORTS(JaCppAbDirectoryDelegator::Super, nsIAbDirectory, + nsIInterfaceRequestor) + +JaCppAbDirectoryDelegator::JaCppAbDirectoryDelegator() + : mCppBase(new Super(this)), mMethods(nullptr) {} + +NS_IMETHODIMP JaCppAbDirectoryDelegator::SetMethodsToDelegate( + msgIDelegateList* aDelegateList) { + if (!aDelegateList) { + NS_WARNING("Null delegate list"); + return NS_ERROR_NULL_POINTER; + } + // We static_cast since we want to use the hash object directly. + mDelegateList = static_cast(aDelegateList); + mMethods = &(mDelegateList->mMethods); + return NS_OK; +} +NS_IMETHODIMP JaCppAbDirectoryDelegator::GetMethodsToDelegate( + msgIDelegateList** aDelegateList) { + if (!mDelegateList) mDelegateList = new DelegateList(); + mMethods = &(mDelegateList->mMethods); + NS_ADDREF(*aDelegateList = mDelegateList); + return NS_OK; +} + +NS_IMETHODIMP JaCppAbDirectoryDelegator::SetJsDelegate( + nsISupports* aJsDelegate) { + // If these QIs fail, then overrides are not provided for methods in that + // interface, which is OK. + mJsISupports = aJsDelegate; + mJsIAbDirectory = do_QueryInterface(aJsDelegate); + mJsIInterfaceRequestor = do_QueryInterface(aJsDelegate); + return NS_OK; +} +NS_IMETHODIMP JaCppAbDirectoryDelegator::GetJsDelegate( + nsISupports** aJsDelegate) { + NS_ENSURE_ARG_POINTER(aJsDelegate); + if (mJsISupports) { + NS_ADDREF(*aJsDelegate = mJsISupports); + return NS_OK; + } + return NS_ERROR_NOT_INITIALIZED; +} + +NS_IMETHODIMP JaCppAbDirectoryDelegator::GetCppBase(nsISupports** aCppBase) { + nsCOMPtr cppBaseSupports; + cppBaseSupports = NS_ISUPPORTS_CAST(nsIAbDirectory*, mCppBase); + NS_ENSURE_STATE(cppBaseSupports); + cppBaseSupports.forget(aCppBase); + + return NS_OK; +} + +} // namespace mailnews +} // namespace mozilla -- cgit v1.2.3