diff --git a/accessible/build/nsAccessibilityFactory.cpp b/accessible/build/nsAccessibilityFactory.cpp index c6d522130e9..54262e3aa4c 100644 --- a/accessible/build/nsAccessibilityFactory.cpp +++ b/accessible/build/nsAccessibilityFactory.cpp @@ -78,6 +78,6 @@ static const nsModuleComponentInfo components[] = }, }; -NS_IMPL_NSGETMODULE(nsAccessibilityModule, components); +NS_IMPL_NSGETMODULE(nsAccessibilityModule, components) diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 3de20984510..809f0db5155 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -130,7 +130,7 @@ nsAccessibilityService::~nsAccessibilityService() } NS_IMPL_THREADSAFE_ISUPPORTS5(nsAccessibilityService, nsIAccessibilityService, nsIAccessibleRetrieval, - nsIObserver, nsIWebProgressListener, nsISupportsWeakReference); + nsIObserver, nsIWebProgressListener, nsISupportsWeakReference) // nsIObserver diff --git a/accessible/src/base/nsAccessibleEventData.cpp b/accessible/src/base/nsAccessibleEventData.cpp index 784a4d50b25..82aeecd9f62 100755 --- a/accessible/src/base/nsAccessibleEventData.cpp +++ b/accessible/src/base/nsAccessibleEventData.cpp @@ -38,7 +38,7 @@ #include "nsAccessibleEventData.h" -NS_IMPL_ISUPPORTS1(nsAccessibleEventData, nsIAccessibleEvent); +NS_IMPL_ISUPPORTS1(nsAccessibleEventData, nsIAccessibleEvent) nsAccessibleEventData::nsAccessibleEventData(PRUint32 aEventType, nsIAccessible *aAccessible, nsIAccessibleDocument *aDocAccessible, diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 2c5aa431be6..a212e5eb146 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -87,8 +87,8 @@ NS_INTERFACE_MAP_BEGIN(nsRootAccessible) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFormListener) NS_INTERFACE_MAP_END_INHERITING(nsDocAccessible) -NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsDocAccessible); -NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsDocAccessible); +NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsDocAccessible) +NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsDocAccessible) //----------------------------------------------------- diff --git a/browser/components/bookmarks/src/nsBookmarksService.cpp b/browser/components/bookmarks/src/nsBookmarksService.cpp index bef15d4134f..302f29c6b0c 100644 --- a/browser/components/bookmarks/src/nsBookmarksService.cpp +++ b/browser/components/bookmarks/src/nsBookmarksService.cpp @@ -2490,7 +2490,7 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo //////////////////////////////////////////////////////////////////////// // nsISupports methods -NS_IMPL_ADDREF(nsBookmarksService); +NS_IMPL_ADDREF(nsBookmarksService) NS_IMETHODIMP_(nsrefcnt) nsBookmarksService::Release() diff --git a/browser/components/build/nsModule.cpp b/browser/components/build/nsModule.cpp index ca650b3a2ff..2a0e064c93c 100644 --- a/browser/components/build/nsModule.cpp +++ b/browser/components/build/nsModule.cpp @@ -68,4 +68,4 @@ static const nsModuleComponentInfo components[] = nsDownloadProxyConstructor } }; -NS_IMPL_NSGETMODULE(nsBrowserCompsModule, components); +NS_IMPL_NSGETMODULE(nsBrowserCompsModule, components) diff --git a/calendar/libxpical/oeICalContainerImpl.cpp b/calendar/libxpical/oeICalContainerImpl.cpp index ad3d26d5f15..10fb45c7e03 100644 --- a/calendar/libxpical/oeICalContainerImpl.cpp +++ b/calendar/libxpical/oeICalContainerImpl.cpp @@ -220,7 +220,7 @@ oeICalContainerImpl::~oeICalContainerImpl() * Notice that the second parameter to the macro is the static IID accessor * method, and NOT the #defined IID. */ -NS_IMPL_ISUPPORTS1(oeICalContainerImpl, oeIICalContainer); +NS_IMPL_ISUPPORTS1(oeICalContainerImpl, oeIICalContainer) NS_IMETHODIMP oeICalContainerImpl::AddCalendar( const char *server ) { diff --git a/calendar/libxpical/oeICalFactory.cpp b/calendar/libxpical/oeICalFactory.cpp index 9a546d968da..3d593588a90 100644 --- a/calendar/libxpical/oeICalFactory.cpp +++ b/calendar/libxpical/oeICalFactory.cpp @@ -44,12 +44,12 @@ -NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalImpl); -NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalContainerImpl); -NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalEventImpl); -NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalTodoImpl); -NS_GENERIC_FACTORY_CONSTRUCTOR(oeDateTimeImpl); -NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalStartupHandler); +NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalContainerImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalEventImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalTodoImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(oeDateTimeImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalStartupHandler) static const nsModuleComponentInfo pModuleInfo[] = { diff --git a/calendar/libxpical/oeICalImpl.cpp b/calendar/libxpical/oeICalImpl.cpp index fab8895bb36..1fd95343160 100644 --- a/calendar/libxpical/oeICalImpl.cpp +++ b/calendar/libxpical/oeICalImpl.cpp @@ -300,7 +300,7 @@ oeICalImpl::~oeICalImpl() * Notice that the second parameter to the macro is the static IID accessor * method, and NOT the #defined IID. */ -NS_IMPL_ISUPPORTS1(oeICalImpl, oeIICal); +NS_IMPL_ISUPPORTS1(oeICalImpl, oeIICal) EventList *oeICalImpl::GetEventList() { diff --git a/calendar/libxpical/oeICalStartupHandler.cpp b/calendar/libxpical/oeICalStartupHandler.cpp index e890cef0fcf..6d7311b32f3 100644 --- a/calendar/libxpical/oeICalStartupHandler.cpp +++ b/calendar/libxpical/oeICalStartupHandler.cpp @@ -39,7 +39,7 @@ #include "nsString.h" #include "oeICalStartupHandler.h" -NS_IMPL_ISUPPORTS1(oeICalStartupHandler, nsICmdLineHandler); +NS_IMPL_ISUPPORTS1(oeICalStartupHandler, nsICmdLineHandler) oeICalStartupHandler::oeICalStartupHandler() { diff --git a/caps/src/nsAggregatePrincipal.cpp b/caps/src/nsAggregatePrincipal.cpp index 29dc43e36d1..e69de29bb2d 100644 --- a/caps/src/nsAggregatePrincipal.cpp +++ b/caps/src/nsAggregatePrincipal.cpp @@ -1,479 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Mitch Stoltz - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/*describes principals which combine one or more principals*/ -#include "nsAggregatePrincipal.h" -#include "nsIURI.h" - -static NS_DEFINE_IID(kIAggregatePrincipalIID, NS_IAGGREGATEPRINCIPAL_IID); - -NS_IMPL_QUERY_INTERFACE5_CI(nsAggregatePrincipal, nsIAggregatePrincipal, - nsICertificatePrincipal, nsICodebasePrincipal, - nsIPrincipal, nsISerializable) -NS_IMPL_CI_INTERFACE_GETTER5(nsAggregatePrincipal, nsIAggregatePrincipal, - nsICertificatePrincipal, nsICodebasePrincipal, - nsIPrincipal, nsISerializable) - -NSBASEPRINCIPALS_ADDREF(nsAggregatePrincipal); -NSBASEPRINCIPALS_RELEASE(nsAggregatePrincipal); - -////////////////////////////////////////////////// -// Methods implementing nsICertificatePrincipal // -////////////////////////////////////////////////// -NS_IMETHODIMP -nsAggregatePrincipal::GetCertificateID(char** aCertificateID) -{ - if (!mCertificate) - { - *aCertificateID = nsnull; - return NS_OK; - } - - nsCOMPtr certificate = do_QueryInterface(mCertificate); - return certificate->GetCertificateID(aCertificateID); -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetCommonName(char** aCommonName) -{ - if (!mCertificate) - { - *aCommonName = nsnull; - return NS_OK; - } - - nsCOMPtr certificate = do_QueryInterface(mCertificate); - return certificate->GetCommonName(aCommonName); -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetCommonName(const char* aCommonName) -{ - if (!mCertificate) - return NS_ERROR_FAILURE; - - nsCOMPtr certificate = do_QueryInterface(mCertificate); - return certificate->SetCommonName(aCommonName); -} - -/////////////////////////////////////////////// -// Methods implementing nsICodebasePrincipal // -/////////////////////////////////////////////// -NS_IMETHODIMP -nsAggregatePrincipal::GetURI(nsIURI** aURI) -{ - if (!mCodebase) - { - *aURI = nsnull; - return NS_ERROR_FAILURE; - } - - nsCOMPtr codebase = do_QueryInterface(mCodebase); - return codebase->GetURI(aURI); -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetOrigin(char** aOrigin) -{ - if (!mCodebase) - { - *aOrigin = nsnull; - return NS_ERROR_FAILURE; - } - - nsCOMPtr codebase = do_QueryInterface(mCodebase); - return codebase->GetOrigin(aOrigin); -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetSpec(char** aSpec) -{ - if (!mCodebase) - { - *aSpec = nsnull; - return NS_ERROR_FAILURE; - } - - nsCOMPtr codebase = do_QueryInterface(mCodebase); - return codebase->GetSpec(aSpec); -} - -//////////////////////////////////////////////// -// Methods implementing nsIAggregatePrincipal // -//////////////////////////////////////////////// -NS_IMETHODIMP -nsAggregatePrincipal::GetCertificate(nsIPrincipal** result) -{ - *result = mCertificate; - NS_IF_ADDREF(*result); - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetCodebase(nsIPrincipal** result) -{ - *result = mCodebase; - NS_IF_ADDREF(*result); - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetCertificate(nsIPrincipal* aCertificate) -{ - nsresult rv; - //-- Make sure this really is a certificate principal - if (aCertificate) - { - nsCOMPtr tempCertificate = - do_QueryInterface(aCertificate, &rv); - if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; - } - - //-- If aCertificate is an aggregate, get its underlying certificate - nsCOMPtr agg = - do_QueryInterface(aCertificate, &rv); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr underlying; - rv = agg->GetCertificate(getter_AddRefs(underlying)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - mCertificate = underlying.get(); - } - else - mCertificate = aCertificate; - // New certificate, so forget cached security policy - mCachedSecurityPolicy = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetCodebase(nsIPrincipal* aCodebase) -{ - nsresult rv; - nsCOMPtr newCodebase(aCodebase); - - //-- If newCodebase is an aggregate, get its underlying codebase - nsCOMPtr agg = - do_QueryInterface(newCodebase, &rv); - if (NS_SUCCEEDED(rv)) - { - rv = agg->GetCodebase(getter_AddRefs(newCodebase)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } - else - { //-- Make sure this really is a codebase principal - nsCOMPtr tempCodebase = - do_QueryInterface(newCodebase, &rv); - if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; - } - - mCodebase = newCodebase; - - //-- If this is the first codebase set, remember it. - if (!mOriginalCodebase) - mOriginalCodebase = newCodebase; - else - { - mDomainChanged = PR_TRUE; - // Codebase has changed, forget cached security policy - mCachedSecurityPolicy = nsnull; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetOriginalCodebase(nsIPrincipal** aOriginalCodebase) -{ - NS_ENSURE_ARG_POINTER(aOriginalCodebase); - - *aOriginalCodebase = mOriginalCodebase; - NS_IF_ADDREF(*aOriginalCodebase); - - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetPrimaryChild(nsIPrincipal** aPrimaryChild) -{ - //-- If a certificate is present, then that's the PrimaryChild principal. - // Otherwise we use the codebase. - if (mCertificate) - *aPrimaryChild = mCertificate.get(); - else if (mCodebase) - *aPrimaryChild = mCodebase.get(); - else - { - *aPrimaryChild = nsnull; - return NS_ERROR_FAILURE; - } - - NS_IF_ADDREF(*aPrimaryChild); - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::Intersect(nsIPrincipal* other) -{ - NS_ASSERTION(mCodebase, "Principal without codebase"); - - if (mCertificate) - { - PRBool sameCert = PR_FALSE; - if (NS_FAILED(mCertificate->Equals(other, &sameCert))) - return NS_ERROR_FAILURE; - if (!sameCert) - SetCertificate(nsnull); - } - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetDomainChanged(PRBool aDomainChanged) -{ - mDomainChanged = aDomainChanged; - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetDomainChanged(PRBool* aDomainChanged) -{ - *aDomainChanged = mDomainChanged; - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetCachedSecurityPolicy(void** aCachedSecurityPolicy) -{ - *aCachedSecurityPolicy = mCachedSecurityPolicy; - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetCachedSecurityPolicy(void* aCachedSecurityPolicy) -{ - mCachedSecurityPolicy = aCachedSecurityPolicy; - return NS_OK; -} - - -/////////////////////////////////////// -// Methods implementing nsIPrincipal // -/////////////////////////////////////// -NS_IMETHODIMP -nsAggregatePrincipal::ToString(char **result) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->ToString(result); -} - -NS_IMETHODIMP -nsAggregatePrincipal::ToUserVisibleString(char **result) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->ToUserVisibleString(result); -} - -NS_IMETHODIMP -nsAggregatePrincipal::Equals(nsIPrincipal * other, PRBool * result) -{ - *result = PR_FALSE; - if (this == other) { - *result = PR_TRUE; - return NS_OK; - } - if (!other) - return NS_OK; - - nsresult rv; - nsCOMPtr otherAgg = - do_QueryInterface(other, &rv); - if (NS_FAILED(rv)) - return NS_OK; - //-- Two aggregates are equal if both codebase and certificate are equal - PRBool certEqual = PR_TRUE; - if (mCertificate) - { - rv = mCertificate->Equals(other, &certEqual); - if(NS_FAILED(rv)) return rv; - } - PRBool cbEqual = PR_TRUE; - if (mCodebase) - { - rv = mCodebase->Equals(other, &cbEqual); - if(NS_FAILED(rv)) return rv; - } - if (mCertificate || mCodebase) // At least one must be present - *result = certEqual && cbEqual; - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::HashValue(PRUint32 *result) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->HashValue(result); -} - -NS_IMETHODIMP -nsAggregatePrincipal::CanEnableCapability(const char *capability, - PRInt16 *result) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->CanEnableCapability(capability, result); -} - -NS_IMETHODIMP -nsAggregatePrincipal::SetCanEnableCapability(const char *capability, - PRInt16 canEnable) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->SetCanEnableCapability(capability, canEnable); -} - -NS_IMETHODIMP -nsAggregatePrincipal::IsCapabilityEnabled(const char *capability, void *annotation, - PRBool *result) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->IsCapabilityEnabled(capability, annotation, result); -} - -NS_IMETHODIMP -nsAggregatePrincipal::EnableCapability(const char *capability, void **annotation) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->EnableCapability(capability, annotation); -} - -NS_IMETHODIMP -nsAggregatePrincipal::RevertCapability(const char *capability, void **annotation) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->RevertCapability(capability, annotation); -} - -NS_IMETHODIMP -nsAggregatePrincipal::DisableCapability(const char *capability, void **annotation) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->DisableCapability(capability, annotation); -} - -NS_IMETHODIMP -nsAggregatePrincipal::GetPreferences(char** aPrefName, char** aID, - char** aGrantedList, char** aDeniedList) -{ - nsCOMPtr PrimaryChild; - if (NS_FAILED(GetPrimaryChild(getter_AddRefs(PrimaryChild)))) - return NS_ERROR_FAILURE; - return PrimaryChild->GetPreferences(aPrefName, aID, - aGrantedList, aDeniedList); -} - -////////////////////////////////////////// -// Methods implementing nsISerializable // -////////////////////////////////////////// - -NS_IMETHODIMP -nsAggregatePrincipal::Read(nsIObjectInputStream* aStream) -{ - nsresult rv; - - rv = nsBasePrincipal::Read(aStream); - if (NS_FAILED(rv)) return rv; - - rv = NS_ReadOptionalObject(aStream, PR_TRUE, getter_AddRefs(mCertificate)); - if (NS_FAILED(rv)) return rv; - - rv = NS_ReadOptionalObject(aStream, PR_TRUE, getter_AddRefs(mCodebase)); - if (NS_FAILED(rv)) return rv; - - return NS_OK; -} - -NS_IMETHODIMP -nsAggregatePrincipal::Write(nsIObjectOutputStream* aStream) -{ - nsresult rv; - - rv = nsBasePrincipal::Write(aStream); - if (NS_FAILED(rv)) return rv; - - rv = NS_WriteOptionalObject(aStream, mCertificate, PR_TRUE); - if (NS_FAILED(rv)) return rv; - - rv = NS_WriteOptionalCompoundObject(aStream, mCodebase, NS_GET_IID(nsIPrincipal), PR_TRUE); - if (NS_FAILED(rv)) return rv; - - return NS_OK; -} - -///////////////////////////////////////////// -// Constructor, Destructor, initialization // -///////////////////////////////////////////// - -nsAggregatePrincipal::nsAggregatePrincipal() : mCachedSecurityPolicy(nsnull), - mDomainChanged(PR_FALSE) -{ -} - -nsAggregatePrincipal::~nsAggregatePrincipal() -{ -} diff --git a/caps/src/nsCertificatePrincipal.cpp b/caps/src/nsCertificatePrincipal.cpp index b8fefcecf58..e69de29bb2d 100644 --- a/caps/src/nsCertificatePrincipal.cpp +++ b/caps/src/nsCertificatePrincipal.cpp @@ -1,227 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Mitch Stoltz - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/*describes principals for use in signed scripts*/ -#include "nsCertificatePrincipal.h" -#include "prmem.h" -#include "nsCOMPtr.h" -#include "nsReadableUtils.h" -#include "nsCRT.h" - -static NS_DEFINE_IID(kICertificatePrincipalIID, NS_ICERTIFICATEPRINCIPAL_IID); - -NS_IMPL_QUERY_INTERFACE3_CI(nsCertificatePrincipal, - nsICertificatePrincipal, - nsIPrincipal, - nsISerializable) -NS_IMPL_CI_INTERFACE_GETTER3(nsCertificatePrincipal, - nsICertificatePrincipal, - nsIPrincipal, - nsISerializable) - -NSBASEPRINCIPALS_ADDREF(nsCertificatePrincipal); -NSBASEPRINCIPALS_RELEASE(nsCertificatePrincipal); - -////////////////////////////////////////////////// -// Methods implementing nsICertificatePrincipal // -////////////////////////////////////////////////// -NS_IMETHODIMP -nsCertificatePrincipal::GetCertificateID(char** aCertificateID) -{ - *aCertificateID = ToNewCString(mCertificateID); - return *aCertificateID ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -nsCertificatePrincipal::GetCommonName(char** aCommonName) -{ - *aCommonName = ToNewCString(mCommonName); - return *aCommonName ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -nsCertificatePrincipal::SetCommonName(const char* aCommonName) -{ - mCommonName = aCommonName; - return NS_OK; -} - -/////////////////////////////////////// -// Methods implementing nsIPrincipal // -/////////////////////////////////////// -NS_IMETHODIMP -nsCertificatePrincipal::CanEnableCapability(const char *capability, - PRInt16 *result) -{ - if(NS_FAILED(nsBasePrincipal::CanEnableCapability(capability, result))) - return NS_ERROR_FAILURE; - if (*result == nsIPrincipal::ENABLE_UNKNOWN) - *result = ENABLE_WITH_USER_PERMISSION; - return NS_OK; -} - -NS_IMETHODIMP -nsCertificatePrincipal::ToString(char **result) -{ - return GetCertificateID(result); -} - -NS_IMETHODIMP -nsCertificatePrincipal::ToUserVisibleString(char **result) -{ - return GetCommonName(result); -} - -NS_IMETHODIMP -nsCertificatePrincipal::GetPreferences(char** aPrefName, char** aID, - char** aGrantedList, char** aDeniedList) -{ - if (mPrefName.IsEmpty()) { - mPrefName.Assign("capability.principal.certificate.p"); - mPrefName.AppendInt(mCapabilitiesOrdinal++); - mPrefName.Append(".id"); - } - return nsBasePrincipal::GetPreferences(aPrefName, aID, - aGrantedList, aDeniedList); -} - -NS_IMETHODIMP -nsCertificatePrincipal::Equals(nsIPrincipal * other, PRBool * result) -{ - *result = PR_FALSE; - if (this == other) { - *result = PR_TRUE; - return NS_OK; - } - if (!other) - return NS_OK; - nsresult rv; - nsCOMPtr otherCertificate = - do_QueryInterface(other, &rv); - if (NS_FAILED(rv)) - return NS_OK; - //-- Compare cert ID's - char* otherID; - rv = otherCertificate->GetCertificateID(&otherID); - if (NS_FAILED(rv)) - { - PR_FREEIF(otherID); - return rv; - } - *result = mCertificateID.Equals(otherID); - PR_FREEIF(otherID); - return NS_OK; -} - -NS_IMETHODIMP -nsCertificatePrincipal::HashValue(PRUint32 *result) -{ - char* str; - if (NS_FAILED(ToString(&str)) || !str) return NS_ERROR_FAILURE; - *result = nsCRT::HashCode(str, nsnull); - nsCRT::free(str); - return NS_OK; -} - -////////////////////////////////////////// -// Methods implementing nsISerializable // -////////////////////////////////////////// - -NS_IMETHODIMP -nsCertificatePrincipal::Read(nsIObjectInputStream* aStream) -{ - nsresult rv; - - rv = nsBasePrincipal::Read(aStream); - if (NS_FAILED(rv)) return rv; - - rv = aStream->ReadCString(mCertificateID); - if (NS_FAILED(rv)) return rv; - - rv = NS_ReadOptionalCString(aStream, mCommonName); - if (NS_FAILED(rv)) return rv; - - return NS_OK; -} - -NS_IMETHODIMP -nsCertificatePrincipal::Write(nsIObjectOutputStream* aStream) -{ - nsresult rv; - - rv = nsBasePrincipal::Write(aStream); - if (NS_FAILED(rv)) return rv; - - rv = aStream->WriteStringZ(mCertificateID.get()); - if (NS_FAILED(rv)) return rv; - - rv = NS_WriteOptionalStringZ(aStream, mCommonName.get()); - if (NS_FAILED(rv)) return rv; - - return NS_OK; -} - -///////////////////////////////////////////// -// Constructor, Destructor, initialization // -///////////////////////////////////////////// -nsresult -nsCertificatePrincipal::InitFromPersistent(const char* aPrefName, const char* aCertID, - const char* aGrantedList, const char* aDeniedList) -{ - if (NS_FAILED(Init(aCertID))) - return NS_ERROR_FAILURE; - - return nsBasePrincipal::InitFromPersistent(aPrefName, aCertID, - aGrantedList, aDeniedList); -} - -NS_IMETHODIMP -nsCertificatePrincipal::Init(const char* aCertificateID) -{ - mCertificateID = aCertificateID; - return NS_OK; -} - -nsCertificatePrincipal::nsCertificatePrincipal() -{ -} - -nsCertificatePrincipal::~nsCertificatePrincipal() -{ -} diff --git a/caps/src/nsCodebasePrincipal.cpp b/caps/src/nsCodebasePrincipal.cpp index 6ddac6a3394..4dac94b7dec 100644 --- a/caps/src/nsCodebasePrincipal.cpp +++ b/caps/src/nsCodebasePrincipal.cpp @@ -61,8 +61,8 @@ NS_IMPL_CI_INTERFACE_GETTER3(nsCodebasePrincipal, nsIPrincipal, nsISerializable) -NSBASEPRINCIPALS_ADDREF(nsCodebasePrincipal); -NSBASEPRINCIPALS_RELEASE(nsCodebasePrincipal); +NSBASEPRINCIPALS_ADDREF(nsCodebasePrincipal) +NSBASEPRINCIPALS_RELEASE(nsCodebasePrincipal) /////////////////////////////////////// // Methods implementing nsIPrincipal // diff --git a/caps/src/nsSecurityManagerFactory.cpp b/caps/src/nsSecurityManagerFactory.cpp index 2d4eb8c2023..f1fa7933863 100644 --- a/caps/src/nsSecurityManagerFactory.cpp +++ b/caps/src/nsSecurityManagerFactory.cpp @@ -463,5 +463,5 @@ CapsModuleDtor(nsIModule* thisModules) } NS_IMPL_NSGETMODULE_WITH_DTOR(nsSecurityManagerModule, capsComponentInfo, - CapsModuleDtor); + CapsModuleDtor) diff --git a/caps/src/nsSystemPrincipal.cpp b/caps/src/nsSystemPrincipal.cpp index c5095037fc8..e2f9b64b8eb 100644 --- a/caps/src/nsSystemPrincipal.cpp +++ b/caps/src/nsSystemPrincipal.cpp @@ -52,8 +52,8 @@ NS_IMPL_QUERY_INTERFACE2_CI(nsSystemPrincipal, nsIPrincipal, nsISerializable) NS_IMPL_CI_INTERFACE_GETTER2(nsSystemPrincipal, nsIPrincipal, nsISerializable) -NSBASEPRINCIPALS_ADDREF(nsSystemPrincipal); -NSBASEPRINCIPALS_RELEASE(nsSystemPrincipal); +NSBASEPRINCIPALS_ADDREF(nsSystemPrincipal) +NSBASEPRINCIPALS_RELEASE(nsSystemPrincipal) ///////////////////////////////////////