2014-05-05 17:30:39 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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/. */
|
2000-07-22 05:38:43 +00:00
|
|
|
|
|
|
|
#include "nsErrorService.h"
|
2013-09-19 18:29:31 +00:00
|
|
|
#include "nsCRTGlue.h"
|
2013-08-05 15:16:53 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2000-07-22 05:38:43 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsErrorService, nsIErrorService)
|
2000-07-22 05:38:43 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
nsresult
|
2014-08-25 19:17:15 +00:00
|
|
|
nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID,
|
|
|
|
void** aInstancePtr)
|
2000-07-22 05:38:43 +00:00
|
|
|
{
|
2014-05-13 17:41:38 +00:00
|
|
|
if (NS_WARN_IF(aOuter)) {
|
2014-05-05 17:30:39 +00:00
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
2014-05-13 17:41:38 +00:00
|
|
|
}
|
2014-05-05 17:30:39 +00:00
|
|
|
nsRefPtr<nsErrorService> serv = new nsErrorService();
|
|
|
|
return serv->QueryInterface(aIID, aInstancePtr);
|
2000-07-22 05:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-08-25 19:17:15 +00:00
|
|
|
nsErrorService::RegisterErrorStringBundle(int16_t aErrorModule,
|
|
|
|
const char* aStringBundleURL)
|
2000-07-22 05:38:43 +00:00
|
|
|
{
|
2014-05-09 20:47:37 +00:00
|
|
|
mErrorStringBundleURLMap.Put(aErrorModule, new nsCString(aStringBundleURL));
|
2014-05-09 20:47:36 +00:00
|
|
|
return NS_OK;
|
2000-07-22 05:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-05-09 20:47:36 +00:00
|
|
|
nsErrorService::UnregisterErrorStringBundle(int16_t aErrorModule)
|
2000-07-22 05:38:43 +00:00
|
|
|
{
|
2014-05-09 20:47:37 +00:00
|
|
|
mErrorStringBundleURLMap.Remove(aErrorModule);
|
2014-05-09 20:47:36 +00:00
|
|
|
return NS_OK;
|
2000-07-22 05:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-05-09 20:47:36 +00:00
|
|
|
nsErrorService::GetErrorStringBundle(int16_t aErrorModule, char** aResult)
|
2000-07-22 05:38:43 +00:00
|
|
|
{
|
2014-05-09 20:47:37 +00:00
|
|
|
nsCString* bundleURL = mErrorStringBundleURLMap.Get(aErrorModule);
|
2014-07-25 23:41:24 +00:00
|
|
|
if (!bundleURL) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2014-05-09 20:47:37 +00:00
|
|
|
*aResult = ToNewCString(*bundleURL);
|
2014-05-05 17:30:39 +00:00
|
|
|
return NS_OK;
|
2000-07-22 05:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|