Create our param block that allows us to pass nsISupport references to

dialogs and clean up a little bit of the UI.
This commit is contained in:
javi%netscape.com 2001-03-10 03:09:20 +00:00
Родитель 98667ffc0f
Коммит cbc174f060
13 изменённых файлов: 268 добавлений и 68 удалений

Просмотреть файл

@ -25,6 +25,6 @@ topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DIRS = resources src
DIRS = public resources src
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,41 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Terry Hayes <thayes@netscape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License Version 2 or later (the
# "GPL"), in which case the provisions of the GPL are applicable
# instead of those above. If you wish to allow use of your
# version of this file only under the terms of the GPL and not to
# allow others to use your version of this file under the MPL,
# indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by
# the GPL. If you do not delete the provisions above, a recipient
# may use your version of this file under either the MPL or the
# GPL.
#
DEPTH=..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = src resources
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -45,6 +45,10 @@ function onLoad()
setText("message2", message2);
}
function viewCert()
{
}
function doOK()
{
params.SetInt(1,1);

Просмотреть файл

@ -25,7 +25,7 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
debug="false"
height="350"
height="230"
width="400"
onload="onLoad();"
>
@ -39,13 +39,12 @@
<separator/>
<html id="message2" />
<!--
<box>
<button id="examineCert-button" class="dialog" value="Examine Certificate"
onclick=""/>
<button id="examineCert-button" class="dialog" value="&examineCert.label;"
onclick="viewCert();"/>
</box>
<separator/>
-->
<box>
<button id="ok-button" class="dialog" value="&ok.label;"
style="width: 8ex" onclick="doOK();" disabled="false"/>

Просмотреть файл

@ -18,7 +18,12 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://pippki/locale/newserver.dtd">
<!DOCTYPE window [
<!ENTITY % newserverDTD SYSTEM "chrome://pippki/locale/newserver.dtd" >
%newserverDTD;
<!ENTITY % pippkiDTD SYSTEM "chrome://pippki/locale/pippki.dtd" >
%pippkiDTD;
]>
<window
@ -26,7 +31,7 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
debug="false"
height="350"
height="360"
width="400"
onload="onLoad();"
>
@ -58,19 +63,18 @@
value="&newserver.reject;" data="2"/>
</radiogroup>
<!--
<box>
<button id="examineCert-button" class="dialog" value="Examine Certificate"
<button id="examineCert-button" class="dialog" value="&examineCert.label;"
onclick=""/>
</box>
<separator/>
-->
<box>
<button id="ok-button" class="dialog" value="&newserver.okButton.label;"
<button id="ok-button" class="dialog" value="&ok.label;"
style="width: 10ex" onclick="doOK();" disabled="false"/>
<button id="cancel-button" class="dialog" value="&newserver.cancelButton.label;"
<button id="cancel-button" class="dialog" value="&cancel.label;"
style="width: 10ex" onclick="doCancel();" />
<button id="help-button" class="dialog" value="&newserver.helpButton.label;"
<button id="help-button" class="dialog" value="&help.label;"
style="width: 10ex" onclick="alert('Will bring up help one day');" />
</box>
</box>

Просмотреть файл

@ -22,6 +22,3 @@
<!ENTITY newserver.acceptperm "Accept this certificate permanently">
<!ENTITY newserver.accepttemp "Accept this certificate temporarily for this session">
<!ENTITY newserver.reject "Do not accept this certificate and do not connect to this web site">
<!ENTITY newserver.helpButton.label "Help">
<!ENTITY newserver.okButton.label "OK">
<!ENTITY newserver.cancelButton.label "Cancel">

Просмотреть файл

@ -62,6 +62,7 @@
<!-- Strings for the MismatchDomain dialog -->
<!ENTITY domainMismatch.title "Security Error: Domain Name Mismatch">
<!ENTITY examineCert.label "Examine Certificate">
<!-- Strings for the Server cert expired dialog -->
<!ENTITY serverCertExpired.title "Security Error: Security Certificate Expired">

Просмотреть файл

@ -52,6 +52,7 @@ CPPSRCS = \
nsNSSDialogs.cpp \
nsPKIModule.cpp \
nsCertificateManager.cpp \
nsPKIParamBlock.cpp \
$(NULL)
REQUIRES = nspr security js

Просмотреть файл

@ -63,6 +63,7 @@ OBJS = \
.\$(OBJDIR)\nsNSSDialogs.obj \
.\$(OBJDIR)\nsPKIModule.obj \
.\$(OBJDIR)\nsCertificateManager.obj \
.\$(OBJDIR)\nsPKIParamBlock.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsDateTimeFormatCID.h"
#include "nsNSSDialogs.h"
#include "nsPKIParamBlock.h"
#define PIPSTRING_BUNDLE_URL "chrome://pippki/locale/pippki.properties"
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
@ -73,7 +74,7 @@ public:
static nsresult openDialog(
nsIDOMWindowInternal *window,
const char *url,
nsIDialogParamBlock *params);
nsIPKIParamBlock *params);
static nsresult openDialogVA(nsIDOMWindowInternal *window,
const char *format, ...);
@ -121,7 +122,7 @@ nsresult
nsNSSDialogHelper::openDialog(
nsIDOMWindowInternal *window,
const char *url,
nsIDialogParamBlock *params)
nsIPKIParamBlock *params)
{
nsresult rv;
nsCOMPtr<nsIDOMWindowInternal> hiddenWindow;
@ -144,7 +145,7 @@ nsNSSDialogHelper::openDialog(
url,
"_blank",
nsNSSDialogHelper::kDefaultOpenWindowParam,
&NS_GET_IID(nsIDialogParamBlock),
&NS_GET_IID(nsIPKIParamBlock),
(nsISupports*)params
);
if ( !argv ) return NS_ERROR_FAILURE;
@ -191,7 +192,7 @@ nsNSSDialogHelper::openDialogVA(nsIDOMWindowInternal *window,
}
/* ==== */
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
static NS_DEFINE_CID(kDialogParamBlockCID, NS_PKIPARAMBLOCK_CID);
nsNSSDialogs::nsNSSDialogs()
{
@ -239,7 +240,7 @@ nsNSSDialogs::SetPassword(nsIInterfaceRequestor *ctx,
// Get the parent window for the dialog
nsCOMPtr<nsIDOMWindowInternal> parent = do_GetInterface(ctx);
nsCOMPtr<nsIDialogParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
nsCOMPtr<nsIPKIParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
if (!block) return NS_ERROR_FAILURE;
// void ChangePassword(in wstring tokenName, out int status);
@ -274,7 +275,7 @@ nsNSSDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
*_retval = PR_FALSE;
nsCOMPtr<nsIDialogParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
nsCOMPtr<nsIPKIParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
if (!block)
return NS_ERROR_FAILURE;
@ -338,7 +339,7 @@ nsNSSDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
*_retval = PR_FALSE;
nsCOMPtr<nsIDialogParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
nsCOMPtr<nsIPKIParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
if (!block)
return NS_ERROR_FAILURE;
@ -386,7 +387,7 @@ nsNSSDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
*_retval = PR_FALSE;
nsCOMPtr<nsIDialogParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
nsCOMPtr<nsIPKIParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
if (!block)
return NS_ERROR_FAILURE;
@ -609,7 +610,7 @@ nsNSSDialogs::DownloadCACert(nsIInterfaceRequestor *ctx,
// Get the parent window for the dialog
nsCOMPtr<nsIDOMWindowInternal> parent = do_GetInterface(ctx);
nsCOMPtr<nsIDialogParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
nsCOMPtr<nsIPKIParamBlock> block = do_CreateInstance(kDialogParamBlockCID);
if (!block) return NS_ERROR_FAILURE;
nsXPIDLString commonName;

Просмотреть файл

@ -26,9 +26,11 @@
#include "nsNSSDialogs.h"
#include "nsCertificateManager.h"
#include "nsPKIParamBlock.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNSSDialogs, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCertificateManager)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPKIParamBlock, Init)
static nsModuleComponentInfo components[] =
{
@ -43,8 +45,13 @@ static nsModuleComponentInfo components[] =
NS_CERTIFICATEMANAGER_CID,
NS_CERTIFICATEMANAGER_CONTRACTID,
nsCertificateManagerConstructor
}
},
{ "PKI Parm Block",
NS_PKIPARAMBLOCK_CID,
NS_PKIPARAMBLOCK_CONTRACTID,
nsPKIParamBlockConstructor
}
};
NS_IMPL_NSGETMODULE("PKI", components)

Просмотреть файл

@ -0,0 +1,155 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Javier Delgadillo <javi@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "nsPKIParamBlock.h"
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
NS_IMPL_THREADSAFE_ISUPPORTS2(nsPKIParamBlock, nsIPKIParamBlock,
nsIDialogParamBlock)
nsPKIParamBlock::nsPKIParamBlock() : mSupports(nsnull),mNumISupports(0)
{
NS_INIT_REFCNT();
}
nsresult
nsPKIParamBlock::Init()
{
mDialogParamBlock = do_CreateInstance(kDialogParamBlockCID);
return (mDialogParamBlock == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
nsPKIParamBlock::~nsPKIParamBlock()
{
if (mNumISupports > 0) {
NS_ASSERTION (mSupports, "mNumISupports and mSupports out of sync");
if (mSupports) {
PRIntn i;
for (i=0; i<mNumISupports; i++) {
NS_IF_RELEASE(mSupports[i]);
}
delete [] mSupports;
}
}
}
NS_IMETHODIMP
nsPKIParamBlock::SetNumberStrings( PRInt32 inNumStrings )
{
return mDialogParamBlock->SetNumberStrings(inNumStrings);
}
NS_IMETHODIMP
nsPKIParamBlock::SetInt(PRInt32 inIndex, PRInt32 inInt)
{
return mDialogParamBlock->SetInt(inIndex, inInt);
}
NS_IMETHODIMP
nsPKIParamBlock::GetInt(PRInt32 inIndex, PRInt32 *outInt)
{
return mDialogParamBlock->GetInt(inIndex, outInt);
}
NS_IMETHODIMP
nsPKIParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval)
{
return mDialogParamBlock->GetString(inIndex, _retval);
}
NS_IMETHODIMP
nsPKIParamBlock::SetString(PRInt32 inIndex, const PRUnichar *inString)
{
return mDialogParamBlock->SetString(inIndex, inString);
}
/* void setNumberISupports (in PRInt32 numISupports); */
NS_IMETHODIMP
nsPKIParamBlock::SetNumberISupports(PRInt32 numISupports)
{
if (mSupports) {
return NS_ERROR_ALREADY_INITIALIZED;
}
NS_ASSERTION(numISupports > 0, "passing in invalid number");
mNumISupports = numISupports;
mSupports = new nsISupports*[mNumISupports];
if (mSupports == nsnull) {
mNumISupports = 0;
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
/* void setISupportAtIndex (in PRInt32 index, in nsISupports object); */
NS_IMETHODIMP
nsPKIParamBlock::SetISupportAtIndex(PRInt32 index, nsISupports *object)
{
if (!mSupports) {
mNumISupports = kNumISupports;
mSupports = new nsISupports*[mNumISupports];
if (mSupports == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
nsresult rv = InBounds(index, mNumISupports);
if (rv != NS_OK)
return rv;
mSupports[index-1] = object;
NS_ADDREF(mSupports[index-1]);
return NS_OK;
}
/* nsISupports getISupportAtIndex (in PRInt32 index); */
NS_IMETHODIMP
nsPKIParamBlock::GetISupportAtIndex(PRInt32 index, nsISupports **_retval)
{
NS_ENSURE_ARG(_retval);
nsresult rv = InBounds(index, mNumISupports);
if (rv != NS_OK)
return rv;
*_retval = mSupports[index-1];
NS_IF_ADDREF(*_retval);
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Javier Delgadillo <javi@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef _NSPKIPARAMBLOCK_
#define _NSPKIPARAMBLOCK_
#include "nsCOMPtr.h"
#include "nsIPKIParamBlock.h"
#define NS_PKIPARAMBLOCK_CID \
{ 0x0bec75a8, 0x1dd2, 0x11b2, \
{ 0x86, 0x3a, 0xf6, 0x9f, 0x77, 0xc3, 0x13, 0x71 }}
#define NS_PKIPARAMBLOCK_CONTRACTID "@mozilla.org/security/pkiparamblock;1"
class nsPKIParamBlock : public nsIPKIParamBlock
{
public:
enum { kNumISupports = 4 };
nsPKIParamBlock();
virtual ~nsPKIParamBlock();
nsresult Init();
NS_DECL_NSIPKIPARAMBLOCK
NS_DECL_NSIDIALOGPARAMBLOCK
NS_DECL_ISUPPORTS
private:
nsresult InBounds( PRInt32 inIndex, PRInt32 inMax )
{
if ( inIndex >= 0 && inIndex< inMax )
return NS_OK;
else
return NS_ERROR_ILLEGAL_VALUE;
}
nsCOMPtr<nsIDialogParamBlock> mDialogParamBlock;
nsISupports **mSupports;
PRIntn mNumISupports;
};
#endif //_NSPKIPARAMBLOCK_