Bug 673381, first part, allow to to query NSPR/NSS library version numbers from JS, r=honzab

This commit is contained in:
Kai Engert 2012-03-01 17:29:48 +01:00
parent dbfe01e356
commit 75ac364082
6 changed files with 208 additions and 1 deletions

View File

@ -56,6 +56,7 @@ SDK_XPIDLSRCS = \
nsIX509Cert.idl \
nsIX509CertDB.idl \
nsIX509CertValidity.idl \
nsINSSVersion.idl \
$(NULL)
XPIDLSRCS = \

View File

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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
* Red Hat, Inc.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kai Engert <kaie@redhat.com>
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{C++
#define NS_NSSVERSION_CONTRACTID "@mozilla.org/security/nssversion;1"
%}
[scriptable, uuid(5f6c8e09-3311-4b24-b0d5-d6e75e7478a4)]
interface nsINSSVersion : nsISupports {
readonly attribute AString NSPR_Version;
readonly attribute AString NSS_Version;
readonly attribute AString NSSUTIL_Version;
readonly attribute AString NSSSSL_Version;
readonly attribute AString NSSSMIME_Version;
};

View File

@ -104,6 +104,7 @@ CPPSRCS = \
NSSErrorsService.cpp \
nsNSSCertificateFakeTransport.cpp \
PSMRunnable.cpp \
nsNSSVersion.cpp \
$(NULL)
ifdef MOZ_XUL

View File

@ -78,6 +78,7 @@
#include "nsSSLStatus.h"
#include "nsNSSIOLayer.h"
#include "NSSErrorsService.h"
#include "nsNSSVersion.h"
#include "nsXULAppAPI.h"
#define NS_IS_PROCESS_DEFAULT \
@ -253,6 +254,7 @@ NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsureOnChromeOnly, nsNSSSocketInfo)
typedef mozilla::psm::NSSErrorsService NSSErrorsService;
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NSSErrorsService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNSSVersion)
NS_DEFINE_NAMED_CID(NS_NSSCOMPONENT_CID);
NS_DEFINE_NAMED_CID(NS_SSLSOCKETPROVIDER_CID);
@ -289,7 +291,7 @@ NS_DEFINE_NAMED_CID(NS_RECENTBADCERTS_CID);
NS_DEFINE_NAMED_CID(NS_SSLSTATUS_CID);
NS_DEFINE_NAMED_CID(NS_NSSSOCKETINFO_CID);
NS_DEFINE_NAMED_CID(NS_NSSERRORSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_NSSVERSION_CID);
static const mozilla::Module::CIDEntry kNSSCIDs[] = {
{ &kNS_NSSCOMPONENT_CID, false, NULL, nsNSSComponentConstructor },
@ -327,12 +329,14 @@ static const mozilla::Module::CIDEntry kNSSCIDs[] = {
{ &kNS_SSLSTATUS_CID, false, NULL, nsSSLStatusConstructor },
{ &kNS_NSSSOCKETINFO_CID, false, NULL, nsNSSSocketInfoConstructor },
{ &kNS_NSSERRORSSERVICE_CID, false, NULL, NSSErrorsServiceConstructor },
{ &kNS_NSSVERSION_CID, false, NULL, nsNSSVersionConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kNSSContracts[] = {
{ PSM_COMPONENT_CONTRACTID, &kNS_NSSCOMPONENT_CID },
{ NS_NSS_ERRORS_SERVICE_CONTRACTID, &kNS_NSSERRORSSERVICE_CID },
{ NS_NSSVERSION_CONTRACTID, &kNS_NSSVERSION_CID },
{ NS_SSLSOCKETPROVIDER_CONTRACTID, &kNS_SSLSOCKETPROVIDER_CID },
{ NS_STARTTLSSOCKETPROVIDER_CONTRACTID, &kNS_STARTTLSSOCKETPROVIDER_CID },
{ NS_SDR_CONTRACTID, &kNS_SDR_CID },

View File

@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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
* Red Hat, Inc.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kai Engert <kengert@redhat.com>
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsNSSVersion.h"
#include "nsString.h"
#include "prinit.h"
#include "nss.h"
#include "nssutil.h"
#include "ssl.h"
#include "smime.h"
NS_IMPL_ISUPPORTS1(nsNSSVersion, nsINSSVersion)
nsNSSVersion::nsNSSVersion()
{
}
nsNSSVersion::~nsNSSVersion()
{
}
NS_IMETHODIMP
nsNSSVersion::GetNSPR_Version(nsAString & v)
{
CopyUTF8toUTF16(PR_GetVersion(), v);
return NS_OK;
}
NS_IMETHODIMP
nsNSSVersion::GetNSS_Version(nsAString & v)
{
CopyUTF8toUTF16(NSS_GetVersion(), v);
return NS_OK;
}
NS_IMETHODIMP
nsNSSVersion::GetNSSUTIL_Version(nsAString & v)
{
CopyUTF8toUTF16(NSSUTIL_GetVersion(), v);
return NS_OK;
}
NS_IMETHODIMP
nsNSSVersion::GetNSSSSL_Version(nsAString & v)
{
CopyUTF8toUTF16(NSSSSL_GetVersion(), v);
return NS_OK;
}
NS_IMETHODIMP
nsNSSVersion::GetNSSSMIME_Version(nsAString & v)
{
CopyUTF8toUTF16(NSSSMIME_GetVersion(), v);
return NS_OK;
}

View File

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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
* Red Hat, Inc.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kai Engert <kengert@redhat.com>
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _NS_NSSVERSION_H_
#define _NS_NSSVERSION_H_
#include "nsINSSVersion.h"
class nsNSSVersion : public nsINSSVersion
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSINSSVERSION
nsNSSVersion();
private:
~nsNSSVersion();
};
#define NS_NSSVERSION_CID \
{ 0x23ad3531, 0x11d2, 0x4e8e, { 0x80, 0x5a, 0x6a, 0x75, 0x2e, 0x91, 0x68, 0x1a } }
#endif