From 52514c7ffcd45e0e06d48fb2b2bcf3efebf90bbd Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Fri, 8 Sep 2000 04:57:33 +0000 Subject: [PATCH] Bug 46772. Added nsIDirectoryService::UnregisterProvider --- xpcom/io/nsDirectoryService.cpp | 24 +++++++++++++++++++----- xpcom/io/nsIDirectoryService.idl | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp index 8ec08fa88913..b81a3fe0fccb 100644 --- a/xpcom/io/nsDirectoryService.cpp +++ b/xpcom/io/nsDirectoryService.cpp @@ -547,13 +547,14 @@ typedef struct FileData static PRBool FindProviderFile(nsISupports* aElement, void *aData) { + nsresult rv; nsCOMPtr prov = do_QueryInterface(aElement); if (!prov) return PR_FALSE; FileData* fileData = (FileData*)aData; - prov->GetFile(fileData->property, &fileData->persistent, &(fileData->file) ); - if (fileData->file) + rv = prov->GetFile(fileData->property, &fileData->persistent, &(fileData->file) ); + if (NS_SUCCEEDED(rv) && fileData->file) return PR_FALSE; return PR_TRUE; @@ -661,12 +662,25 @@ nsDirectoryService::RegisterProvider(nsIDirectoryServiceProvider *prov) // AppendElement returns TRUE if it succeeded. // Until this is fixed, fix up the result here. - nsresult invertedResult; - invertedResult = mProviders->AppendElement(supports); - return invertedResult ? NS_OK : NS_ERROR_FAILURE; + rv = mProviders->AppendElement(supports) ? NS_OK : NS_ERROR_FAILURE; + return rv; } +NS_IMETHODIMP +nsDirectoryService::UnregisterProvider(nsIDirectoryServiceProvider *prov) +{ + nsresult rv; + if (!prov) + return NS_ERROR_FAILURE; + nsCOMPtr supports = do_QueryInterface(prov, &rv); + if (NS_FAILED(rv)) return rv; + + // AppendElement returns TRUE if it succeeded. + // Until this is fixed, fix up the result here. + rv = mProviders->RemoveElement(supports) ? NS_OK : NS_ERROR_FAILURE; + return rv; +} // DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com. // This is meant to be a place of xpcom or system specific file locations, not diff --git a/xpcom/io/nsIDirectoryService.idl b/xpcom/io/nsIDirectoryService.idl index d68ad6ab7412..321906521d48 100644 --- a/xpcom/io/nsIDirectoryService.idl +++ b/xpcom/io/nsIDirectoryService.idl @@ -34,6 +34,7 @@ interface nsIDirectoryService: nsISupports { void init(in string productName); void registerProvider(in nsIDirectoryServiceProvider prov); + void unregisterProvider(in nsIDirectoryServiceProvider prov); }; %{C++