more prompt stuff moved to embedding components. bug 72112 continues

This commit is contained in:
danm%netscape.com 2001-04-09 00:43:14 +00:00
parent 18fdae0c56
commit 71fd6db98c
9 changed files with 203 additions and 2 deletions

View File

@ -21,16 +21,19 @@
*/
#include "nsIGenericFactory.h"
#include "nsDialogParamBlock.h"
#include "nsPromptService.h"
#include "nsWindowWatcher.h"
#include "nsAppStartupNotifier.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPromptService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowWatcher, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppStartupNotifier)
static nsModuleComponentInfo components[] = {
{ "Dialog ParamBlock", NS_DIALOGPARAMBLOCK_CID, NS_DIALOGPARAMBLOCK_CONTRACTID, nsDialogParamBlockConstructor },
{ "Prompt Service", NS_PROMPTSERVICE_CID, NS_PROMPTSERVICE_CONTRACTID, nsPromptServiceConstructor },
{ "Window Watcher", NS_WINDOWWATCHER_CID, NS_WINDOWWATCHER_CONTRACTID, nsWindowWatcherConstructor },
{ NS_APPSTARTUPNOTIFIER_CLASSNAME, NS_APPSTARTUPNOTIFIER_CID, NS_APPSTARTUPNOTIFIER_CONTRACTID, nsAppStartupNotifierConstructor }

View File

@ -1,3 +1,5 @@
nsIDialogParamBlock.idl
nsIPromptService.idl
nsPIPromptService.idl
nsIWindowWatcher.idl
nsPIWindowWatcher.idl

View File

@ -29,7 +29,9 @@ include $(DEPTH)/config/autoconf.mk
MODULE = windowwatcher
XPIDL_MODULE = windowwatcher
XPIDLSRCS = nsIPromptService.idl \
XPIDLSRCS = nsIDialogParamBlock.idl \
nsIPromptService.idl \
nsPIPromptService.idl \
nsIWindowWatcher.idl \
nsPIWindowWatcher.idl \
$(NULL)

View File

@ -23,7 +23,9 @@ DEPTH=..\..\..\..
MODULE=windowwatcher
XPIDLSRCS = \
.\nsIDialogParamBlock.idl \
.\nsIPromptService.idl \
.\nsPIPromptService.idl \
.\nsIWindowWatcher.idl \
.\nsPIWindowWatcher.idl \
$(NULL)

View File

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(f76c0901-437a-11d3-b7a0-e35db351b4bc)]
interface nsIDialogParamBlock: nsISupports {
void SetNumberStrings( in PRInt32 inNumStrings );
PRInt32 GetInt( in PRInt32 inIndex );
void SetInt( in PRInt32 inIndex, in PRInt32 inInt );
wstring GetString( in PRInt32 inIndex );
void SetString( in PRInt32 inIndex, in wstring inString);
};
%{C++
// {f76c0901-437a-11d3-b7a0-e35db351b4bc}
#define NS_DIALOGPARAMBLOCK_IID \
{0xf76c0901, 0x437a, 0x11d3, {0xb7, 0xa0, 0xe3, 0x5d, 0xb3, 0x51, 0xb4, 0xbc}}
%}

View File

@ -28,7 +28,8 @@ MODULE = embedcomponents
LIBRARY_NAME = windowwatcher_s
REQUIRES = xpcom string dom windowwatcher widget js xpconnect caps layout uriloader necko docshell locale webbrwsr embed_base gfx2 wallet intl appshell
CPPSRCS = nsPrompt.cpp \
CPPSRCS = nsDialogParamBlock.cpp \
nsPrompt.cpp \
nsPromptService.cpp \
nsWWJSUtils.cpp \
nsWindowWatcher.cpp \

View File

@ -24,6 +24,7 @@ MODULE=embedcomponents
LIBRARY_NAME=windowwatcher_s
CPP_OBJS= \
.\$(OBJDIR)\nsDialogParamBlock.obj \
.\$(OBJDIR)\nsPrompt.obj \
.\$(OBJDIR)\nsPromptService.obj \
.\$(OBJDIR)\nsWWJSUtils.obj \

View File

@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsDialogParamBlock.h"
#include "nsString.h"
NS_IMPL_ISUPPORTS1(nsDialogParamBlock, nsIDialogParamBlock)
nsDialogParamBlock::nsDialogParamBlock() : mNumStrings(0), mString(NULL)
{
NS_INIT_REFCNT();
for(PRInt32 i = 0; i < kNumInts; i++)
mInt[i] = 0;
}
nsDialogParamBlock::~nsDialogParamBlock()
{
delete [] mString;
}
NS_IMETHODIMP nsDialogParamBlock::SetNumberStrings(PRInt32 inNumStrings)
{
if (mString != NULL)
return NS_ERROR_ALREADY_INITIALIZED;
mString = new nsString[inNumStrings];
if (!mString)
return NS_ERROR_OUT_OF_MEMORY;
mNumStrings = inNumStrings;
return NS_OK;
}
NS_IMETHODIMP nsDialogParamBlock::GetInt(PRInt32 inIndex, PRInt32 *_retval)
{
nsresult rv = InBounds(inIndex, kNumInts);
if (rv == NS_OK)
*_retval = mInt[inIndex];
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::SetInt(PRInt32 inIndex, PRInt32 inInt)
{
nsresult rv = InBounds(inIndex, kNumInts);
if (rv == NS_OK)
mInt[inIndex]= inInt;
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval)
{
if (mNumStrings == 0)
SetNumberStrings(kNumStrings);
nsresult rv = InBounds(inIndex, mNumStrings);
if (rv == NS_OK)
*_retval = mString[inIndex].ToNewUnicode();
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::SetString(PRInt32 inIndex, const PRUnichar *inString)
{
if (mNumStrings == 0)
SetNumberStrings(kNumStrings);
nsresult rv = InBounds(inIndex, mNumStrings);
if (rv == NS_OK)
mString[inIndex]= inString;
return rv;
}

View File

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __nsDialogParamBlock_h
#define __nsDialogParamBlock_h
#include "nsIDialogParamBlock.h"
// {c01ad085-4915-11d3-b7a0-85cf55c3523c}
#define NS_DIALOGPARAMBLOCK_CID \
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
#define NS_DIALOGPARAMBLOCK_CONTRACTID \
"@mozilla.org/embedcomp/dialogparam;1"
class nsString;
class nsDialogParamBlock: public nsIDialogParamBlock
{
public:
nsDialogParamBlock();
virtual ~nsDialogParamBlock();
NS_DECL_NSIDIALOGPARAMBLOCK
NS_DECL_ISUPPORTS
private:
enum {kNumInts = 8, kNumStrings = 16};
nsresult InBounds(PRInt32 inIndex, PRInt32 inMax) {
return inIndex >= 0 && inIndex < inMax ? NS_OK : NS_ERROR_ILLEGAL_VALUE;
}
PRInt32 mInt[kNumInts];
PRInt32 mNumStrings;
nsString* mString;
};
#endif