From 478efe7481a18d2f4314357540c85d8d566529e1 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Thu, 5 Apr 2001 23:09:35 +0000 Subject: [PATCH] new embedding promptservice component. bug 72112 r=hyatt,pinkerton git-svn-id: svn://10.0.0.236/trunk@91503 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/allmakefiles.sh | 3 + .../mac/build_scripts/MozillaBuildList.pm | 1 + mozilla/embedding/components/Makefile.in | 2 +- .../embedding/components/build/Makefile.in | 5 +- .../build/macbuild/EmbedComponents.mcp | Bin 112506 -> 112506 bytes .../build/macbuild/EmbedComponentsIDL.mcp | Bin 58927 -> 57647 bytes .../embedding/components/build/makefile.win | 2 + .../embedding/components/build/nsModule.cpp | 3 + mozilla/embedding/components/makefile.win | 1 + .../components/promptservice/Makefile.in | 29 ++ .../components/promptservice/makefile.win | 25 + .../promptservice/public/MANIFEST_IDL | 1 + .../promptservice/public/Makefile.in | 36 ++ .../promptservice/public/makefile.win | 30 ++ .../promptservice/public/nsIPromptService.idl | 125 +++++ .../components/promptservice/src/Makefile.in | 40 ++ .../components/promptservice/src/makefile.win | 36 ++ .../promptservice/src/nsPromptService.cpp | 455 ++++++++++++++++++ .../promptservice/src/nsPromptService.h | 61 +++ 19 files changed, 853 insertions(+), 2 deletions(-) create mode 100644 mozilla/embedding/components/promptservice/Makefile.in create mode 100644 mozilla/embedding/components/promptservice/makefile.win create mode 100644 mozilla/embedding/components/promptservice/public/MANIFEST_IDL create mode 100644 mozilla/embedding/components/promptservice/public/Makefile.in create mode 100644 mozilla/embedding/components/promptservice/public/makefile.win create mode 100644 mozilla/embedding/components/promptservice/public/nsIPromptService.idl create mode 100644 mozilla/embedding/components/promptservice/src/Makefile.in create mode 100644 mozilla/embedding/components/promptservice/src/makefile.win create mode 100644 mozilla/embedding/components/promptservice/src/nsPromptService.cpp create mode 100644 mozilla/embedding/components/promptservice/src/nsPromptService.h diff --git a/mozilla/allmakefiles.sh b/mozilla/allmakefiles.sh index 2792a385310..b7dc071e3f1 100755 --- a/mozilla/allmakefiles.sh +++ b/mozilla/allmakefiles.sh @@ -745,6 +745,9 @@ embedding/browser/photon/src/Makefile embedding/browser/photon/tests/Makefile embedding/components/Makefile embedding/components/build/Makefile +embedding/components/promptservice/Makefile +embedding/components/promptservice/public/Makefile +embedding/components/promptservice/src/Makefile embedding/components/windowwatcher/Makefile embedding/components/windowwatcher/public/Makefile embedding/components/windowwatcher/src/Makefile diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index 060b3469812..bf323b47b23 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -719,6 +719,7 @@ sub BuildClientDist() #EMBEDDING InstallFromManifest(":mozilla:embedding:base:MANIFEST_IDL", "$distdirectory:idl:"); InstallFromManifest(":mozilla:embedding:browser:webbrowser:MANIFEST_IDL", "$distdirectory:idl:"); + InstallFromManifest(":mozilla:embedding:components:promptservice:public:MANIFEST_IDL", "$distdirectory:idl:"); InstallFromManifest(":mozilla:embedding:components:windowwatcher:public:MANIFEST_IDL", "$distdirectory:idl:"); InstallFromManifest(":mozilla:embedding:components:appstartup:src:MANIFEST", "$distdirectory:embedding:components:"); diff --git a/mozilla/embedding/components/Makefile.in b/mozilla/embedding/components/Makefile.in index 9e8806a1bc7..1fa8f6af894 100644 --- a/mozilla/embedding/components/Makefile.in +++ b/mozilla/embedding/components/Makefile.in @@ -24,6 +24,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = windowwatcher appstartup build +DIRS = promptservice windowwatcher appstartup build include $(topsrcdir)/config/rules.mk diff --git a/mozilla/embedding/components/build/Makefile.in b/mozilla/embedding/components/build/Makefile.in index 07c2d483d7d..a4f17da5753 100644 --- a/mozilla/embedding/components/build/Makefile.in +++ b/mozilla/embedding/components/build/Makefile.in @@ -27,12 +27,13 @@ MODULE = embedcomponents LIBRARY_NAME = embedcomponents SHORT_LIBNAME = embedcmp IS_COMPONENT = 1 -REQUIRES = js xpcom string windowwatcher embed_base +REQUIRES = js xpcom string promptservice windowwatcher embed_base CPPSRCS = nsModule.cpp ifeq ($(MOZ_WIDGET_TOOLKIT),os2) EXTRA_DSO_LIBS = \ + promptservice_s \ windowwatcher_s \ appstartupnotifier_s \ $(NULL) @@ -45,6 +46,7 @@ endif else SHARED_LIBRARY_LIBS = \ + $(DIST)/lib/libpromptservice_s.$(LIB_SUFFIX) \ $(DIST)/lib/libwindowwatcher_s.$(LIB_SUFFIX) \ $(DIST)/lib/libappstartupnotifier_s.$(LIB_SUFFIX) \ $(NULL) @@ -56,6 +58,7 @@ endif endif LOCAL_INCLUDES = \ + -I$(srcdir)/../promptservice/src \ -I$(srcdir)/../windowwatcher/src \ -I$(srcdir)/../appstartup/src \ $(NULL) diff --git a/mozilla/embedding/components/build/macbuild/EmbedComponents.mcp b/mozilla/embedding/components/build/macbuild/EmbedComponents.mcp index 28e6ed0d4fba7d2f946e91cdcc2c2529018d1584..4f45ae9e9016bd87fd1bf26628e415ca8b67e7d0 100644 GIT binary patch delta 740 zcmZ8fT}YEr7(VaWx9{_3n?DnWO>4W*A_jURm|oQUE7RPEle`J1)Ut(}V}3J(F6u^1 zyl@=ou$zn`(hQlN^b0ByiXf=)sxAzTu0le@pq2&peoHUx9L_oK5AXXt=Q(G4L*Cwy zQ!`+-5JFsl8?F}i1UyBCfqo`I(ZJOv(lBKl*RewP?`->Aro463n#a8&aLV?&|yL7uWgDO1!S$eyumAc?SnWeUWf5qSaqLD*~NkHMxd#QU=bZA9O*T1Vk*S zEmXp|Riu76sBA%5p%&RGlx<#+n3~LHl_lk@{?_+|`qBsqHR+RuufNd5H^X3_pD2?P zs&h9}XA;%iK}9r~1~GdN0HtUI@p-ME zh$Bg_2}>oDXkG5f67FxEvht5_p18KPkFE{rmQZ}P|Hz7h9qLXr9pc>%Xw-|VVF7fz z3*L`H75_2?cjb;r)NqN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FbSR~EIu0nT7v#p(7oc^lI_68p7q?-KbNUq_dK~%}>euiEkx!;CyLh`rUpg${l$D0TzAyBJ_b67ZSkOu!0 z#!)%pOE>gF$+ZTIF3HC$p%+R1$^brG;f=?vV9!Y&$YZrvc9l=wSWzY7jNum80p)en zhd9#;u8Ae?*Ud_v1g>)9Y%Z-!L}3!QudJ<|n3s&u_oAa&MXF_KsQvh`l43y#N$i1; zrJ*j}fxb~tLXJ*9C=K0K?ym9 zHBl4#zMm8}f{05(8+sQ))`TVE1?W2kB_uEdA!|b2@hbFPf)a8X$qd(odR+X)?A9@9 Q5&s}gxxt@v(Dw-bHy=r&!~g&Q diff --git a/mozilla/embedding/components/build/makefile.win b/mozilla/embedding/components/build/makefile.win index 58cba14bf6a..f75a15f2374 100644 --- a/mozilla/embedding/components/build/makefile.win +++ b/mozilla/embedding/components/build/makefile.win @@ -35,11 +35,13 @@ LLIBS = \ $(LIBNSPR) \ $(DIST)\lib\js3250.lib \ $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\promptservice_s.lib \ $(DIST)\lib\windowwatcher_s.lib \ $(DIST)\lib\appstartupnotifier_s.lib \ $(NULL) INCS = $(INCS) \ + -I$(DEPTH)\embedding\components\promptservice\src \ -I$(DEPTH)\embedding\components\windowwatcher\src \ -I$(DEPTH)\embedding\components\appstartup\src \ $(NULL) diff --git a/mozilla/embedding/components/build/nsModule.cpp b/mozilla/embedding/components/build/nsModule.cpp index 7ed9a0d279a..7ba88a3f1b5 100644 --- a/mozilla/embedding/components/build/nsModule.cpp +++ b/mozilla/embedding/components/build/nsModule.cpp @@ -21,14 +21,17 @@ */ #include "nsIGenericFactory.h" +#include "nsPromptService.h" #include "nsWindowWatcher.h" #include "nsAppStartupNotifier.h" +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPromptService, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowWatcher, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppStartupNotifier) static nsModuleComponentInfo components[] = { + { "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 } }; diff --git a/mozilla/embedding/components/makefile.win b/mozilla/embedding/components/makefile.win index 6f343158981..e2d153a85f9 100644 --- a/mozilla/embedding/components/makefile.win +++ b/mozilla/embedding/components/makefile.win @@ -21,6 +21,7 @@ DEPTH=..\.. DIRS= \ + promptservice \ windowwatcher \ appstartup \ build \ diff --git a/mozilla/embedding/components/promptservice/Makefile.in b/mozilla/embedding/components/promptservice/Makefile.in new file mode 100644 index 00000000000..fb4382806d9 --- /dev/null +++ b/mozilla/embedding/components/promptservice/Makefile.in @@ -0,0 +1,29 @@ +# +# 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, Inc. Portions created by Netscape are +# Copyright (C) 2001, Mozilla. All Rights Reserved. +# +# Contributor(s): + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DIRS = public src + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/embedding/components/promptservice/makefile.win b/mozilla/embedding/components/promptservice/makefile.win new file mode 100644 index 00000000000..5375f8a56b5 --- /dev/null +++ b/mozilla/embedding/components/promptservice/makefile.win @@ -0,0 +1,25 @@ +#!nmake +# +# 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, Inc. Portions created by Netscape are +# Copyright (C) 2001, Mozilla. All Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\.. + +DIRS=public src + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/embedding/components/promptservice/public/MANIFEST_IDL b/mozilla/embedding/components/promptservice/public/MANIFEST_IDL new file mode 100644 index 00000000000..5bfcd909f8b --- /dev/null +++ b/mozilla/embedding/components/promptservice/public/MANIFEST_IDL @@ -0,0 +1 @@ +nsIPromptService.idl diff --git a/mozilla/embedding/components/promptservice/public/Makefile.in b/mozilla/embedding/components/promptservice/public/Makefile.in new file mode 100644 index 00000000000..feb6d1f8f7c --- /dev/null +++ b/mozilla/embedding/components/promptservice/public/Makefile.in @@ -0,0 +1,36 @@ +# +# 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): +# + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = promptservice +XPIDL_MODULE = promptservice + +XPIDLSRCS = nsIPromptService.idl \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/embedding/components/promptservice/public/makefile.win b/mozilla/embedding/components/promptservice/public/makefile.win new file mode 100644 index 00000000000..3fbd94065ed --- /dev/null +++ b/mozilla/embedding/components/promptservice/public/makefile.win @@ -0,0 +1,30 @@ +#!nmake +# +# 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, Inc. Portions created by Netscape are +# Copyright (C) 2001, Mozilla. All Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. + +MODULE=promptservice + +XPIDLSRCS = \ + .\nsIPromptService.idl \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> + diff --git a/mozilla/embedding/components/promptservice/public/nsIPromptService.idl b/mozilla/embedding/components/promptservice/public/nsIPromptService.idl new file mode 100644 index 00000000000..4fb76e792ce --- /dev/null +++ b/mozilla/embedding/components/promptservice/public/nsIPromptService.idl @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 2; 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): + */ + +/* This is the interface to the embeddable prompt service; the service + that implements nsIPrompt. Its interface is designed to be just + nsIPrompt, each method modified to take a parent window parameter. + See nsIPrompt for all documentation and ancillary documentation. + + One note: in all cases, the parent window parameter can be null. + However, these windows are all intended to have parents. So when + no parent is specified, the implementation should try hard to find + a suitable foster parent. */ + +#include "nsISupports.idl" + +interface nsIDOMWindow; + +[scriptable, uuid(1630C61A-325E-49ca-8759-A31B16C47AA5)] +interface nsIPromptService : nsISupports +{ +%{C++ + enum {eMsg=0, eCheckboxMsg=1, eIconURL=2, eTitleMessage=3, eEditfield1Msg=4, + eEditfield2Msg=5, eEditfield1Value=6, eEditfield2Value=7, + eButton0Text=8, eButton1Text=9, eButton2Text=10, eButton3Text=11, + eDialogTitle=12}; + enum {eButtonPressed=0, eCheckboxState=1, eNumberButtons=2, + eNumberEditfields=3, eEditField1Password=4}; +%} + + void alert(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text); + + void alertCheck(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in wstring checkMsg, + out boolean checkValue); + + boolean confirm(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text); + + boolean confirmCheck(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in wstring checkMsg, + out boolean checkValue); + + boolean prompt(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, + in PRUint32 savePassword, + in wstring defaultText, + out wstring result); + + boolean promptUsernameAndPassword(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, + in PRUint32 savePassword, + out wstring user, + out wstring pwd); + + boolean promptPassword(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, + in PRUint32 savePassword, + out wstring pwd); + + boolean select(in nsIDOMWindow parent, + in wstring dialogTitle, + in wstring text, + in PRUint32 count, + [array, size_is(count)] in wstring selectList, + out long outSelection); + + void universalDialog(in nsIDOMWindow parent, + in wstring titleMessage, + in wstring dialogTitle, + in wstring text, + in wstring checkboxMsg, + in wstring button0Text, + in wstring button1Text, + in wstring button2Text, + in wstring button3Text, + in wstring editfield1Msg, + in wstring editfield2Msg, + inout wstring editfield1Value, + inout wstring editfield2Value, + in wstring iconURL, + inout boolean checkboxState, + in PRInt32 numberButtons, + in PRInt32 numberEditfields, + in PRInt32 editField1Password, + out PRInt32 buttonPressed); +}; + +%{C++ +// {1630C61A-325E-49ca-8759-A31B16C47AA5} +#define NS_PROMPTSERVICE_IID \ + {0x1630C61A, 0x325E, 0x49ca, {0x87, 0x59, 0xA3, 0x1B, 0x16, 0xC4, 0x7A, 0xA5}} +%} + diff --git a/mozilla/embedding/components/promptservice/src/Makefile.in b/mozilla/embedding/components/promptservice/src/Makefile.in new file mode 100644 index 00000000000..fcafc389ec8 --- /dev/null +++ b/mozilla/embedding/components/promptservice/src/Makefile.in @@ -0,0 +1,40 @@ +# +# 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, Inc. Portions created by Netscape are +# Copyright (C) 2001, Mozilla. All Rights Reserved. +# +# Contributor(s): + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = embedcomponents +LIBRARY_NAME = promptservice_s +REQUIRES = xpcom string dom promptservice widget js xpconnect caps layout uriloader necko docshell locale webbrwsr embed_base gfx2 + +CPPSRCS = nsPromptService.cpp \ + $(NULL) + +# we don't want the shared lib, but we want to force the creation of a +# static lib. +override NO_SHARED_LIB=1 +override NO_STATIC_LIB= + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/embedding/components/promptservice/src/makefile.win b/mozilla/embedding/components/promptservice/src/makefile.win new file mode 100644 index 00000000000..ddfa2294bcd --- /dev/null +++ b/mozilla/embedding/components/promptservice/src/makefile.win @@ -0,0 +1,36 @@ +#!nmake +# +# 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, Inc. Portions created by Netscape are +# Copyright (C) 2001, Mozilla. All Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. + +MODULE=embedcomponents +LIBRARY_NAME=promptservice_s + +CPP_OBJS= \ + .\$(OBJDIR)\nsPromptService.obj \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> + +install:: $(LIBRARY) + $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib + +clobber:: + rm -f $(DIST)\lib\$(LIBRARY_NAME).lib diff --git a/mozilla/embedding/components/promptservice/src/nsPromptService.cpp b/mozilla/embedding/components/promptservice/src/nsPromptService.cpp new file mode 100644 index 00000000000..0a9174ad634 --- /dev/null +++ b/mozilla/embedding/components/promptservice/src/nsPromptService.cpp @@ -0,0 +1,455 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsPromptService.h" + +#include "nsXPComFactory.h" +#include "nsIComponentManager.h" +#include "nsIDialogParamBlock.h" +#include "nsIDOMWindow.h" +#include "nsIServiceManager.h" +#include "nsISupportsUtils.h" + +static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); + +const char *kPromptURL="chrome://global/content/commonDialog.xul"; +const char *kSelectPromptURL="chrome://global/content/selectDialog.xul"; +const char *kQuestionIconURL ="chrome://global/skin/question-icon.gif"; +const char *kAlertIconURL ="chrome://global/skin/alert-icon.gif"; +const char *kWarningIconURL ="chrome://global/skin/message-icon.gif"; + +/**************************************************************** + ************************* ParamBlock *************************** + ****************************************************************/ + +class ParamBlock { + +public: + ParamBlock() { + mBlock = 0; + } + ~ParamBlock() { + NS_IF_RELEASE(mBlock); + } + nsresult Init() { + return nsComponentManager::CreateInstance(kDialogParamBlockCID, + 0, NS_GET_IID(nsIDialogParamBlock), + (void**) &mBlock); + } + nsIDialogParamBlock * operator->() const { return mBlock; } + operator nsIDialogParamBlock * const () { return mBlock; } + +private: + nsIDialogParamBlock *mBlock; +}; + + +/**************************************************************** + ************************ nsPromptService *********************** + ****************************************************************/ + +NS_IMPL_ISUPPORTS1(nsPromptService, nsIPromptService) + +nsPromptService::nsPromptService() { + NS_INIT_REFCNT(); +} + +nsPromptService::~nsPromptService() { +} + +nsresult +nsPromptService::Init() +{ + nsresult rv; + mWatcher = do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv); + return rv; +} + +NS_IMETHODIMP +nsPromptService::Alert(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text) +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt(eNumberButtons, 1); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; + url.AssignWithConversion(kAlertIconURL); + block->SetString(eIconURL, url.GetUnicode()); + + rv = DoDialog(parent, block, kPromptURL); + + return rv; +} + + + +NS_IMETHODIMP +nsPromptService::AlertCheck(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *checkMsg, PRBool *checkValue) + +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt( eNumberButtons,1 ); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; + url.AssignWithConversion(kAlertIconURL); + + block->SetString(eIconURL, url.GetUnicode()); + block->SetString(eCheckboxMsg, checkMsg); + block->SetInt(eCheckboxState, *checkValue); + + rv = DoDialog(parent, block, kPromptURL); + + block->GetInt(eCheckboxState, checkValue); + + return rv; +} + +NS_IMETHODIMP +nsPromptService::Confirm(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text, + PRBool *_retval) +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + // Stuff in Parameters + block->SetInt(eNumberButtons, 2); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; + url.AssignWithConversion(kQuestionIconURL); + block->SetString(eIconURL, url.GetUnicode()); + + rv = DoDialog(parent, block, kPromptURL); + + PRInt32 buttonPressed = 0; + block->GetInt(eButtonPressed, &buttonPressed); + *_retval = buttonPressed ? PR_FALSE : PR_TRUE; + + return rv; +} + +NS_IMETHODIMP +nsPromptService::ConfirmCheck(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *checkMsg, PRBool *checkValue, + PRBool *_retval) +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt( eNumberButtons,2 ); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; url.AssignWithConversion( kQuestionIconURL ); + block->SetString(eIconURL, url.GetUnicode()); + block->SetString(eCheckboxMsg, checkMsg); + block->SetInt(eCheckboxState, *checkValue); + + rv = DoDialog(parent, block, kPromptURL); + PRInt32 tempInt = 0; + block->GetInt(eButtonPressed, &tempInt); + *_retval = tempInt ? PR_FALSE : PR_TRUE; + + block->GetInt(eCheckboxState, & tempInt); + *checkValue = PRBool( tempInt ); + + return rv; +} + +NS_IMETHODIMP +nsPromptService::UniversalDialog(nsIDOMWindow *parent, + const PRUnichar *titleMessage, const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *checkboxMsg, + const PRUnichar *button0Text, const PRUnichar *button1Text, + const PRUnichar *button2Text, const PRUnichar *button3Text, + const PRUnichar *editfield1Msg, const PRUnichar *editfield2Msg, + PRUnichar **editfield1Value, PRUnichar **editfield2Value, + const PRUnichar *iconURL, PRBool *checkboxState, + PRInt32 numberButtons, PRInt32 numberEditfields, + PRInt32 editfield1Password, PRInt32 *buttonPressed) +{ + nsresult rv; + + /* check for at least one button */ + if (numberButtons < 1) + rv = NS_ERROR_FAILURE; + + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + /* load up input parameters */ + + block->SetString(eTitleMessage, titleMessage); + block->SetString(eDialogTitle, dialogTitle); + block->SetString(eMsg, text); + block->SetString(eCheckboxMsg, checkboxMsg); + if (numberButtons >= 4) + block->SetString(eButton3Text, button3Text); + + if (numberButtons >= 3) + block->SetString(eButton2Text, button2Text); + + if (numberButtons >= 2) + block->SetString(eButton1Text, button1Text); + + if (numberButtons >= 1) + block->SetString(eButton0Text, button0Text); + + if (numberEditfields >= 2) { + block->SetString(eEditfield2Msg, editfield2Msg); + block->SetString(eEditfield2Value, *editfield2Value); + } + if (numberEditfields >= 1) { + block->SetString(eEditfield1Msg, editfield1Msg); + block->SetString(eEditfield1Value, *editfield1Value); + block->SetInt(eEditField1Password, editfield1Password); + } + if (iconURL) + block->SetString(eIconURL, iconURL); + else + block->SetString(eIconURL, NS_ConvertASCIItoUCS2(kQuestionIconURL).GetUnicode()); + + if (checkboxMsg) + block->SetInt(eCheckboxState, *checkboxState); + + block->SetInt(eNumberButtons, numberButtons); + block->SetInt(eNumberEditfields, numberEditfields); + + /* perform the dialog */ + + rv = DoDialog(parent, block, kPromptURL); + + /* get back output parameters */ + + if (buttonPressed) + block->GetInt(eButtonPressed, buttonPressed); + + if (checkboxMsg && checkboxState) + block->GetInt(eCheckboxState, checkboxState); + + if (numberEditfields >= 2 && editfield2Value) + block->GetString(eEditfield2Value, editfield2Value); + + if (numberEditfields >= 1 && editfield1Value) + block->GetString(eEditfield1Value, editfield1Value); + + return rv; +} + +// XXX use passwordRealm and savePassword, here and in +// PromptUsernameAndPassword and PromptPassword +NS_IMETHODIMP +nsPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *passwordRealm, + PRUint32 savePassword, const PRUnichar *defaultText, + PRUnichar **result, PRBool *_retval) +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt(eNumberButtons, 2); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; url.AssignWithConversion(kQuestionIconURL); + block->SetString(eIconURL, url.GetUnicode()); + block->SetInt(eNumberEditfields, 1); + block->SetString(eEditfield1Value, defaultText); + + rv = DoDialog(parent, block, kPromptURL); + + block->GetString(eEditfield1Value, result); + PRInt32 tempInt = 0; + block->GetInt(eButtonPressed, &tempInt); + *_retval = tempInt ? PR_FALSE : PR_TRUE; + + return rv; +} + +NS_IMETHODIMP +nsPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRUint32 savePassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) + +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt(eNumberButtons, 2); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; + url.AssignWithConversion(kQuestionIconURL); + block->SetString(eIconURL, url.GetUnicode()); + block->SetInt( eNumberEditfields, 2 ); + block->SetString(eEditfield1Value, *user); + block->SetString(eEditfield2Value, *pwd); + + rv = DoDialog(parent, block, kPromptURL); + + block->GetString(eEditfield1Value, user); + block->GetString(eEditfield2Value, pwd); + PRInt32 tempInt = 0; + block->GetInt(eButtonPressed, &tempInt); + *_retval = tempInt ? PR_FALSE : PR_TRUE; + + return rv; +} + +NS_IMETHODIMP nsPromptService::PromptPassword(nsIDOMWindow *parent, + const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRUint32 savePassword, + PRUnichar **pwd, PRBool *_retval) +{ + nsresult rv; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetInt(eNumberButtons, 2); + block->SetString(eMsg, text); + + block->SetString(eDialogTitle, dialogTitle); + + nsString url; + url.AssignWithConversion(kQuestionIconURL); + block->SetString(eIconURL, url.GetUnicode()); + block->SetInt(eNumberEditfields, 1); + block->SetInt(eEditField1Password, 1); + + rv = DoDialog(parent, block, kPromptURL); + + block->GetString(eEditfield1Value, pwd); + PRInt32 tempInt = 0; + block->GetInt(eButtonPressed, &tempInt); + *_retval = tempInt ? PR_FALSE : PR_TRUE; + + return rv; +} + +NS_IMETHODIMP +nsPromptService::Select(nsIDOMWindow *parent, const PRUnichar *dialogTitle, + const PRUnichar* text, PRUint32 count, + const PRUnichar **selectList, PRInt32 *outSelection, + PRBool *_retval) +{ + nsresult rv; + const PRInt32 eSelection = 2; + ParamBlock block; + rv = block.Init(); + if (NS_FAILED(rv)) + return rv; + + block->SetNumberStrings(count + 2); + if (dialogTitle) + block->SetString(0, dialogTitle); + + block->SetString(1, text); + block->SetInt(eSelection, count); + for (PRUint32 i = 2; i <= count+1; i++) { + nsAutoString temp(selectList[i-2]); + const PRUnichar* text = temp.GetUnicode(); + block->SetString(i, text); + } + + *outSelection = -1; + rv = DoDialog(parent, block, kSelectPromptURL); + + PRInt32 buttonPressed = 0; + block->GetInt(eButtonPressed, &buttonPressed); + block->GetInt(eSelection, outSelection); + *_retval = buttonPressed ? PR_FALSE : PR_TRUE; + + return rv; +} + +nsresult +nsPromptService::DoDialog(nsIDOMWindow *aParent, + nsIDialogParamBlock *aParamBlock, const char *aChromeURL) +{ + NS_ENSURE_ARG(aParamBlock); + NS_ENSURE_ARG(aChromeURL); + if (!mWatcher) + return NS_ERROR_FAILURE; + + nsresult rv = NS_OK; + + // get a parent, if at all possible + // (though we'd rather this didn't fail, it's OK if it does. so there's + // no failure or null check.) + nsCOMPtr activeParent; // retain ownership for method lifetime + if (!aParent) { + mWatcher->GetActiveWindow(getter_AddRefs(activeParent)); + aParent = activeParent; + } + + nsCOMPtr arguments(do_QueryInterface(aParamBlock)); + nsCOMPtr dialog; + mWatcher->OpenWindow(aParent, aChromeURL, "_blank", + "centerscreen,chrome,modal,titlebar", arguments, + getter_AddRefs(dialog)); + + return rv; +} + diff --git a/mozilla/embedding/components/promptservice/src/nsPromptService.h b/mozilla/embedding/components/promptservice/src/nsPromptService.h new file mode 100644 index 00000000000..9f700938abd --- /dev/null +++ b/mozilla/embedding/components/promptservice/src/nsPromptService.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 Communicator client 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 __nsPromptService_h +#define __nsPromptService_h + +// {A2112D6A-0E28-421f-B46A-25C0B308CBD0} +#define NS_PROMPTSERVICE_CID \ + {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}} +#define NS_PROMPTSERVICE_CONTRACTID \ + "@mozilla.org/embedcomp/prompt-service;1" + +#include "nsCOMPtr.h" +#include "nsIPromptService.h" +#include "nsIWindowWatcher.h" + +class nsIDOMWindow; +class nsIDialogParamBlock; + +class nsPromptService: public nsIPromptService { + +public: + + nsPromptService(); + virtual ~nsPromptService(); + + nsresult Init(); + + NS_DECL_NSIPROMPTSERVICE + NS_DECL_ISUPPORTS + +private: + + nsresult DoDialog(nsIDOMWindow *aParent, + nsIDialogParamBlock *aParamBlock, + const char *aChromeURL); + + nsCOMPtr mWatcher; +}; + +#endif +