From bc140cf411fc452cf046325ffca45dcdf78aedde Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Fri, 2 Apr 1999 05:17:42 +0000 Subject: [PATCH] Added progID versions of methods to nsServiceManager (the static interface). git-svn-id: svn://10.0.0.236/trunk@26018 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/components/nsIServiceManager.h | 40 ++++++++++++++---- mozilla/xpcom/components/nsServiceManager.cpp | 42 +++++++++++++++++++ mozilla/xpcom/public/nsIServiceManager.h | 40 ++++++++++++++---- mozilla/xpcom/src/nsServiceManager.cpp | 42 +++++++++++++++++++ 4 files changed, 146 insertions(+), 18 deletions(-) diff --git a/mozilla/xpcom/components/nsIServiceManager.h b/mozilla/xpcom/components/nsIServiceManager.h index 3615b1440b2..a73e5e83e9e 100644 --- a/mozilla/xpcom/components/nsIServiceManager.h +++ b/mozilla/xpcom/components/nsIServiceManager.h @@ -158,19 +158,41 @@ public: class NS_COM nsServiceManager { public: - static nsresult RegisterService(const nsCID& aClass, nsISupports* aService); + static nsresult + RegisterService(const nsCID& aClass, nsISupports* aService); - static nsresult UnregisterService(const nsCID& aClass); + static nsresult + UnregisterService(const nsCID& aClass); - static nsresult GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener = NULL); + static nsresult + GetService(const nsCID& aClass, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL); - static nsresult ReleaseService(const nsCID& aClass, nsISupports* service, - nsIShutdownListener* shutdownListener = NULL); + static nsresult + ReleaseService(const nsCID& aClass, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL); + + //////////////////////////////////////////////////////////////////////////// + // let's do it again, this time with ProgIDs... + + static nsresult + RegisterService(const char* aProgID, nsISupports* aService); + + static nsresult + UnregisterService(const char* aProgID); + + static nsresult + GetService(const char* aProgID, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL); + + static nsresult + ReleaseService(const char* aProgID, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL); + + //////////////////////////////////////////////////////////////////////////// - // Since the global Service Manager is truly global, there's no need to - // release it. static nsresult GetGlobalServiceManager(nsIServiceManager* *result); // This method can be called when shutting down the application. It diff --git a/mozilla/xpcom/components/nsServiceManager.cpp b/mozilla/xpcom/components/nsServiceManager.cpp index b71247ade32..a7628321faa 100644 --- a/mozilla/xpcom/components/nsServiceManager.cpp +++ b/mozilla/xpcom/components/nsServiceManager.cpp @@ -473,6 +473,48 @@ nsServiceManager::UnregisterService(const nsCID& aClass) return mgr->UnregisterService(aClass); } +//////////////////////////////////////////////////////////////////////////////// +// let's do it again, this time with ProgIDs... + +nsresult +nsServiceManager::GetService(const char* aProgID, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->GetService(aProgID, aIID, result, shutdownListener); +} + +nsresult +nsServiceManager::ReleaseService(const char* aProgID, nsISupports* service, + nsIShutdownListener* shutdownListener) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->ReleaseService(aProgID, service, shutdownListener); +} + +nsresult +nsServiceManager::RegisterService(const char* aProgID, nsISupports* aService) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->RegisterService(aProgID, aService); +} + +nsresult +nsServiceManager::UnregisterService(const char* aProgID) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->UnregisterService(aProgID); +} + //////////////////////////////////////////////////////////////////////////////// // XPCOM initialization diff --git a/mozilla/xpcom/public/nsIServiceManager.h b/mozilla/xpcom/public/nsIServiceManager.h index 3615b1440b2..a73e5e83e9e 100644 --- a/mozilla/xpcom/public/nsIServiceManager.h +++ b/mozilla/xpcom/public/nsIServiceManager.h @@ -158,19 +158,41 @@ public: class NS_COM nsServiceManager { public: - static nsresult RegisterService(const nsCID& aClass, nsISupports* aService); + static nsresult + RegisterService(const nsCID& aClass, nsISupports* aService); - static nsresult UnregisterService(const nsCID& aClass); + static nsresult + UnregisterService(const nsCID& aClass); - static nsresult GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener = NULL); + static nsresult + GetService(const nsCID& aClass, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL); - static nsresult ReleaseService(const nsCID& aClass, nsISupports* service, - nsIShutdownListener* shutdownListener = NULL); + static nsresult + ReleaseService(const nsCID& aClass, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL); + + //////////////////////////////////////////////////////////////////////////// + // let's do it again, this time with ProgIDs... + + static nsresult + RegisterService(const char* aProgID, nsISupports* aService); + + static nsresult + UnregisterService(const char* aProgID); + + static nsresult + GetService(const char* aProgID, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL); + + static nsresult + ReleaseService(const char* aProgID, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL); + + //////////////////////////////////////////////////////////////////////////// - // Since the global Service Manager is truly global, there's no need to - // release it. static nsresult GetGlobalServiceManager(nsIServiceManager* *result); // This method can be called when shutting down the application. It diff --git a/mozilla/xpcom/src/nsServiceManager.cpp b/mozilla/xpcom/src/nsServiceManager.cpp index b71247ade32..a7628321faa 100644 --- a/mozilla/xpcom/src/nsServiceManager.cpp +++ b/mozilla/xpcom/src/nsServiceManager.cpp @@ -473,6 +473,48 @@ nsServiceManager::UnregisterService(const nsCID& aClass) return mgr->UnregisterService(aClass); } +//////////////////////////////////////////////////////////////////////////////// +// let's do it again, this time with ProgIDs... + +nsresult +nsServiceManager::GetService(const char* aProgID, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->GetService(aProgID, aIID, result, shutdownListener); +} + +nsresult +nsServiceManager::ReleaseService(const char* aProgID, nsISupports* service, + nsIShutdownListener* shutdownListener) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->ReleaseService(aProgID, service, shutdownListener); +} + +nsresult +nsServiceManager::RegisterService(const char* aProgID, nsISupports* aService) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->RegisterService(aProgID, aService); +} + +nsresult +nsServiceManager::UnregisterService(const char* aProgID) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->UnregisterService(aProgID); +} + //////////////////////////////////////////////////////////////////////////////// // XPCOM initialization