2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsServiceManagerUtils_h__
|
|
|
|
#define nsServiceManagerUtils_h__
|
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
inline const nsGetServiceByCID
|
2007-03-22 10:30:00 -07:00
|
|
|
do_GetService(const nsCID& aCID)
|
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
return nsGetServiceByCID(aCID);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
inline const nsGetServiceByCIDWithError
|
|
|
|
do_GetService(const nsCID& aCID, nsresult* aError)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
return nsGetServiceByCIDWithError(aCID, aError);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
inline const nsGetServiceByContractID
|
2007-03-22 10:30:00 -07:00
|
|
|
do_GetService(const char* aContractID)
|
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
return nsGetServiceByContractID(aContractID);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
inline const nsGetServiceByContractIDWithError
|
|
|
|
do_GetService(const char* aContractID, nsresult* aError)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
return nsGetServiceByContractIDWithError(aContractID, aError);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class nsGetServiceFromCategory : public nsCOMPtr_helper
|
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
public:
|
|
|
|
nsGetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aErrorPtr)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mEntry(aEntry)
|
|
|
|
, mErrorPtr(aErrorPtr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
|
|
|
|
protected:
|
|
|
|
const char* mCategory;
|
|
|
|
const char* mEntry;
|
|
|
|
nsresult* mErrorPtr;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
inline const nsGetServiceFromCategory
|
|
|
|
do_GetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aError = 0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
return nsGetServiceFromCategory(aCategory, aEntry, aError);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
NS_COM_GLUE nsresult CallGetService(const nsCID& aClass, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
NS_COM_GLUE nsresult CallGetService(const char* aContractID, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// type-safe shortcuts for calling |GetService|
|
2014-06-26 18:35:39 -07:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const nsCID& aClass,
|
|
|
|
DestinationType** aDestination)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aClass,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const char* aContractID,
|
|
|
|
DestinationType** aDestination)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-26 18:35:39 -07:00
|
|
|
NS_PRECONDITION(aContractID, "null parameter");
|
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aContractID,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|