Bug 664105 Ensure mailnews URLs are equal to their clones r=bienvenu
This commit is contained in:
Родитель
08e134fa84
Коммит
f974e8e99b
|
@ -41,6 +41,7 @@
|
|||
#include "nsStringGlue.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// addbook url definition
|
||||
|
@ -62,7 +63,7 @@ NS_IMETHODIMP
|
|||
nsAddbookUrl::SetSpec(const nsACString &aSpec)
|
||||
{
|
||||
m_baseURL->SetSpec(aSpec);
|
||||
return ParseUrl();
|
||||
return ParseUrl();
|
||||
}
|
||||
|
||||
nsresult nsAddbookUrl::ParseUrl()
|
||||
|
@ -173,7 +174,8 @@ NS_IMETHODIMP nsAddbookUrl::GetPath(nsACString &aPath)
|
|||
|
||||
NS_IMETHODIMP nsAddbookUrl::SetPath(const nsACString &aPath)
|
||||
{
|
||||
return m_baseURL->SetPath(aPath);
|
||||
m_baseURL->SetPath(aPath);
|
||||
return ParseUrl();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddbookUrl::GetAsciiHost(nsACString &aHostA)
|
||||
|
@ -209,12 +211,23 @@ NS_IMETHODIMP nsAddbookUrl::Equals(nsIURI *other, PRBool *_retval)
|
|||
|
||||
NS_IMETHODIMP nsAddbookUrl::Clone(nsIURI **_retval)
|
||||
{
|
||||
return m_baseURL->Clone(_retval);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsRefPtr<nsAddbookUrl> clone = new nsAddbookUrl();
|
||||
|
||||
if (!clone)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = m_baseURL->Clone(getter_AddRefs(clone->m_baseURL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = clone.forget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddbookUrl::Resolve(const nsACString &relativePath, nsACString &result)
|
||||
{
|
||||
return m_baseURL->Resolve(relativePath, result);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -226,18 +239,36 @@ nsAddbookUrl::GetRef(nsACString &result)
|
|||
NS_IMETHODIMP
|
||||
nsAddbookUrl::SetRef(const nsACString &aRef)
|
||||
{
|
||||
return m_baseURL->SetRef(aRef);
|
||||
m_baseURL->SetRef(aRef);
|
||||
return ParseUrl();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddbookUrl::EqualsExceptRef(nsIURI *other, PRBool *result)
|
||||
NS_IMETHODIMP nsAddbookUrl::EqualsExceptRef(nsIURI *other, PRBool *_retval)
|
||||
{
|
||||
return m_baseURL->EqualsExceptRef(other, result);
|
||||
// The passed-in URI might be an nsMailtoUrl. Pass our inner URL to its
|
||||
// Equals method. The other nsMailtoUrl will then pass its inner URL to
|
||||
// to the Equals method of our inner URL. Other URIs will return false.
|
||||
if (other)
|
||||
return other->EqualsExceptRef(m_baseURL, _retval);
|
||||
|
||||
return m_baseURL->EqualsExceptRef(other, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddbookUrl::CloneIgnoringRef(nsIURI** result)
|
||||
nsAddbookUrl::CloneIgnoringRef(nsIURI** _retval)
|
||||
{
|
||||
return m_baseURL->CloneIgnoringRef(result);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsRefPtr<nsAddbookUrl> clone = new nsAddbookUrl();
|
||||
|
||||
if (!clone)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = m_baseURL->CloneIgnoringRef(getter_AddRefs(clone->m_baseURL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = clone.forget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -515,35 +515,38 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetBaseURI(nsIURI **aBaseURI)
|
|||
|
||||
NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval)
|
||||
{
|
||||
return EqualsInternal(other, eIgnoreRef, _retval);
|
||||
// The passed-in URI might be a mail news url. Pass our inner URL to its
|
||||
// Equals method. The other mail news url will then pass its inner URL to
|
||||
// to the Equals method of our inner URL. Other URIs will return false.
|
||||
if (other)
|
||||
return other->Equals(m_baseURL, _retval);
|
||||
|
||||
return m_baseURL->Equals(other, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMailNewsUrl::EqualsExceptRef(nsIURI *other, PRBool *result)
|
||||
{
|
||||
return EqualsInternal(other, eIgnoreRef, result);
|
||||
// The passed-in URI might be a mail news url. Pass our inner URL to its
|
||||
// Equals method. The other mail news url will then pass its inner URL to
|
||||
// to the Equals method of our inner URL. Other URIs will return false.
|
||||
if (other)
|
||||
return other->EqualsExceptRef(m_baseURL, result);
|
||||
|
||||
return m_baseURL->EqualsExceptRef(other, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailNewsUrl::CloneIgnoringRef(nsIURI** result)
|
||||
{
|
||||
return m_baseURL->CloneIgnoringRef(result);
|
||||
}
|
||||
nsCOMPtr<nsIURI> clone;
|
||||
nsresult rv = Clone(getter_AddRefs(clone));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult nsMsgMailNewsUrl::EqualsInternal(nsIURI *other,
|
||||
RefHandlingEnum refHandlingMode,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsCOMPtr <nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(other);
|
||||
// we really want to compare the base uris to each other, not our base URI
|
||||
// with the other's real URI.
|
||||
if (mailUrl)
|
||||
{
|
||||
nsCOMPtr <nsIURI> baseURI;
|
||||
mailUrl->GetBaseURI(getter_AddRefs(baseURI));
|
||||
if (baseURI)
|
||||
return m_baseURL->Equals(baseURI, _retval);
|
||||
}
|
||||
return m_baseURL->Equals(other, _retval);
|
||||
rv = clone->SetRef(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
clone.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMailNewsUrl::SchemeIs(const char *aScheme, PRBool *_retval)
|
||||
|
|
|
@ -80,12 +80,6 @@ public:
|
|||
|
||||
protected:
|
||||
virtual ~nsMsgMailNewsUrl();
|
||||
enum RefHandlingEnum {
|
||||
eIgnoreRef,
|
||||
eHonorRef
|
||||
};
|
||||
nsresult EqualsInternal(nsIURI *other, RefHandlingEnum refHandlingMode,
|
||||
PRBool *_retval);
|
||||
|
||||
nsCOMPtr<nsIURL> m_baseURL;
|
||||
nsWeakPtr m_statusFeedbackWeak;
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// mailto url definition
|
||||
|
@ -657,7 +658,18 @@ NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, PRBool *_retval)
|
|||
|
||||
NS_IMETHODIMP nsMailtoUrl::Clone(nsIURI **_retval)
|
||||
{
|
||||
return m_baseURL->Clone(_retval);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsRefPtr<nsMailtoUrl> clone = new nsMailtoUrl();
|
||||
|
||||
if (!clone)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = m_baseURL->Clone(getter_AddRefs(clone->m_baseURL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = clone.forget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailtoUrl::Resolve(const nsACString &relativePath, nsACString &result)
|
||||
|
@ -678,13 +690,27 @@ nsMailtoUrl::GetRef(nsACString &result)
|
|||
|
||||
NS_IMETHODIMP nsMailtoUrl::EqualsExceptRef(nsIURI *other, PRBool *result)
|
||||
{
|
||||
// The passed-in URI might be an nsMailtoUrl. Pass our inner URL to its
|
||||
// Equals method. The other nsMailtoUrl will then pass its inner URL to
|
||||
// to the Equals method of our inner URL. Other URIs will return false.
|
||||
if (other)
|
||||
return other->EqualsExceptRef(m_baseURL, result);
|
||||
|
||||
return m_baseURL->EqualsExceptRef(other, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailtoUrl::CloneIgnoringRef(nsIURI** result)
|
||||
{
|
||||
return m_baseURL->CloneIgnoringRef(result);
|
||||
nsCOMPtr<nsIURI> clone;
|
||||
nsresult rv = Clone(getter_AddRefs(clone));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = clone->SetRef(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
clone.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче