Added SetWebShellWindow to toolbar core

Made ToolBarCore a StreamObserver and nsINetSupport listener
Commented out status bar code
This commit is contained in:
rods%netscape.com 1999-02-10 16:46:47 +00:00
Родитель 902c63f62d
Коммит ef5a5af6a2
5 изменённых файлов: 371 добавлений и 8 удалений

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

@ -84,10 +84,10 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).lib $(DIST)\lib
$(MAKE_INSTALL) $(DLL) $(DIST)\bin
$(MAKE_INSTALL) ..\xul\MailAppShell.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) ..\xul\MailAppShellNoTB.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) ..\xul\MailFrame.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) ..\xul\MailToolbar.xml $(DIST)\bin\res\samples
# $(MAKE_INSTALL) ..\xul\MailAppShell.html $(DIST)\bin\res\samples
# $(MAKE_INSTALL) ..\xul\MailAppShellNoTB.html $(DIST)\bin\res\samples
# $(MAKE_INSTALL) ..\xul\MailFrame.html $(DIST)\bin\res\samples
# $(MAKE_INSTALL) ..\xul\MailToolbar.xml $(DIST)\bin\res\samples
$(MAKE_INSTALL) ..\xul\resources\Mail_SendMsg.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) ..\xul\resources\Mail_GetMsg.gif $(DIST)\bin\res\toolbar

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

@ -172,6 +172,48 @@ ToolbarCoreSetWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
}
//
// Native method SetWebShellWindow
//
PR_STATIC_CALLBACK(JSBool)
ToolbarCoreSetWebShellWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMToolbarCore *nativeThis = (nsIDOMToolbarCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMWindowPtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kIWindowIID,
"Window",
cx,
argv[0])) {
return JS_FALSE;
}
if (NS_OK != nativeThis->SetWebShellWindow(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function SetWebShellWindow requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetStatus
//
@ -241,6 +283,7 @@ static JSPropertySpec ToolbarCoreProperties[] =
static JSFunctionSpec ToolbarCoreMethods[] =
{
{"SetWindow", ToolbarCoreSetWindow, 1},
{"SetWebShellWindow", ToolbarCoreSetWebShellWindow, 1},
{"SetStatus", ToolbarCoreSetStatus, 1},
{0}
};

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

@ -157,7 +157,6 @@ nsMailCore::SendMail(const nsString& aAddrTo, const nsString& aSubject, const ns
PRBool isUndefined = PR_FALSE;
nsString rVal;
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
//printf("SendMail [%s] %d [%s]\n", mScript.ToNewCString(), isUndefined, rVal.ToNewCString());
}
return NS_OK;
}

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

@ -24,6 +24,8 @@
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
#include "nsAppCoresManager.h"
#include "nsCOMPtr.h"
#include "nsIWebShell.h"
#include "nsIScriptContext.h"
#include "nsIDOMDocument.h"
@ -32,6 +34,9 @@
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIDOMCharacterData.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
// Globals
@ -44,6 +49,11 @@ static NS_DEFINE_IID(kIDOMCharacterDataIID, nsIDOMCharacterData::IID());
static NS_DEFINE_IID(kToolbarCoreCID, NS_TOOLBARCORE_CID);
static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID);
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID);
/////////////////////////////////////////////////////////////////////////
// nsToolbarCore
@ -55,6 +65,7 @@ nsToolbarCore::nsToolbarCore()
mWindow = nsnull;
mStatusText = nsnull;
mWebShellWin = nsnull;
IncInstanceCount();
NS_INIT_REFCNT();
@ -63,6 +74,7 @@ nsToolbarCore::nsToolbarCore()
nsToolbarCore::~nsToolbarCore()
{
NS_IF_RELEASE(mWindow);
NS_IF_RELEASE(mWebShellWin);
NS_IF_RELEASE(mStatusText);
DecInstanceCount();
}
@ -87,6 +99,16 @@ nsToolbarCore::QueryInterface(REFNSIID aIID,void** aInstancePtr)
AddRef();
return NS_OK;
}
if (aIID.Equals(kINetSupportIID)) {
*aInstancePtr = (void*) ((nsINetSupport*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStreamObserverIID)) {
*aInstancePtr = (void*) ((nsIStreamObserver*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return nsBaseAppCore::QueryInterface(aIID, aInstancePtr);
}
@ -130,7 +152,7 @@ nsToolbarCore::Init(const nsString& aId)
NS_IMETHODIMP
nsToolbarCore::SetStatus(const nsString& aMsg)
{
if (nsnull == mStatusText) {
/* if (nsnull == mStatusText) {
nsIDOMDocument * domDoc;
mWindow->GetDocument(&domDoc);
if (!domDoc)
@ -154,20 +176,289 @@ nsToolbarCore::SetStatus(const nsString& aMsg)
NS_RELEASE(domDoc);
}
mStatusText->SetData(aMsg);
mStatusText->SetData(aMsg); */
DoDialog();
return NS_OK;
}
NS_IMETHODIMP
nsToolbarCore::SetWebShellWindow(nsIDOMWindow* aWin)
{
mWindow = aWin;
NS_ADDREF(aWin);
nsCOMPtr<nsIScriptGlobalObject> globalObj( mWindow );
if (!globalObj) {
return NS_ERROR_FAILURE;
}
nsIWebShell * webShell;
globalObj->GetWebShell(&webShell);
if (nsnull != webShell) {
webShell->SetObserver(this);
PRUnichar * name;
webShell->GetName( &name);
nsAutoString str(name);
printf("attaching to [%s]\n", str.ToNewCString());
nsIWebShellContainer * webShellContainer;
webShell->GetContainer(webShellContainer);
if (nsnull != webShellContainer) {
if (NS_OK == webShellContainer->QueryInterface(kIWebShellWindowIID, (void**) &mWebShellWin)) {
}
NS_RELEASE(webShellContainer);
}
NS_RELEASE(webShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsToolbarCore::SetWindow(nsIDOMWindow* aWin)
{
mWindow = aWin;
NS_ADDREF(aWin);
nsCOMPtr<nsIScriptGlobalObject> globalObj( mWindow );
if (!globalObj) {
return NS_ERROR_FAILURE;
}
nsIWebShell * webShell;
globalObj->GetWebShell(&webShell);
if (nsnull != webShell) {
webShell->SetObserver(this);
PRUnichar * name;
webShell->GetName( &name);
nsAutoString str(name);
printf("attaching to [%s]\n", str.ToNewCString());
NS_RELEASE(webShell);
}
/* nsCOMPtr<nsIDOMNode> oldNode( node );
oldNode->GetNextSibling(getter_AddRefs(node));
nsCOMPtr<nsIDOMDocument> domDoc; // result == nsnull;
// first get the toolbar child WebShell
nsCOMPtr<nsIWebShell> childWebShell;
mWebShell->FindChildWithName(aWebShellName, *getter_AddRefs(childWebShell));
if (!childWebShell)
return domDoc;
nsCOMPtr<nsIContentViewer> cv;
childWebShell->GetContentViewer(getter_AddRefs(cv));
if (!cv)
return domDoc;
nsCOMPtr<nsIDocumentViewer> docv(cv);
if (!docv)
return domDoc;
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(*getter_AddRefs(doc));
if (doc)
return nsCOMPtr<nsIDOMDocument>(doc);
return domDoc;*/
return NS_OK;
}
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsIWidget.h"
#include "plevent.h"
#include "nsIAppShell.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
/* Define Class IDs */
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
/* Define Interface IDs */
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
NS_IMETHODIMP
nsToolbarCore::DoDialog()
{
nsresult rv;
nsString controllerCID;
char * urlstr=nsnull;
char * progname = nsnull;
char * width=nsnull, *height=nsnull;
char * iconic_state=nsnull;
nsIAppShellService* appShell = nsnull;
urlstr = "resource:/res/samples/Password.html";
/*
* Create the Application Shell instance...
*/
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (!NS_SUCCEEDED(rv)) {
goto done;
}
/*
* Initialize the Shell...
*/
rv = appShell->Initialize();
if (!NS_SUCCEEDED(rv)) {
goto done;
}
/*
* Post an event to the shell instance to load the AppShell
* initialization routines...
*
* This allows the application to enter its event loop before having to
* deal with GUI initialization...
*/
///write me...
nsIURL* url;
nsIWidget* newWindow;
rv = NS_NewURL(&url, urlstr);
if (NS_FAILED(rv)) {
goto done;
}
nsIWidget * parent;
mWebShellWin->GetWidget(parent);
/*
* XXX: Currently, the CID for the "controller" is passed in as an argument
* to CreateTopLevelWindow(...). Once XUL supports "controller"
* components this will be specified in the XUL description...
*/
controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";
appShell->CreateDialogWindow(parent, url, controllerCID, newWindow, (nsIStreamObserver *)this);
NS_RELEASE(url);
NS_RELEASE(parent);
/*
* Start up the main event loop...
*/
//rv = appShell->Run();
rv = NS_OK;
while (rv == NS_OK) {
void * data;
PRBool inWin;
PRBool isMouseEvent;
rv = appShell->GetNativeEvent(data, newWindow, inWin, isMouseEvent);
if (rv == NS_OK) {
printf("In win %d is mouse %d\n", inWin, isMouseEvent);
} else {
rv = NS_OK;
}
if (rv == NS_OK && (inWin || (!inWin && !isMouseEvent))) {
appShell->DispatchNativeEvent(data);
}
}
/*
* Shut down the Shell instance... This is done even if the Run(...)
* method returned an error.
*/
(void) appShell->Shutdown();
done:
/* Release the shell... */
if (nsnull != appShell) {
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsToolbarCore::OnStartBinding(nsIURL* aURL, const char *aContentType)
{
nsresult rv = NS_OK;
printf("OnStartBinding\n");
return rv;
}
NS_IMETHODIMP
nsToolbarCore::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
{
nsresult rv = NS_OK;
printf("OnStartBinding\n");
return rv;
}
NS_IMETHODIMP
nsToolbarCore::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
printf("OnStartBinding\n");
return rv;
}
NS_IMETHODIMP
nsToolbarCore::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
printf("OnStartBinding\n");
return rv;
}
//----------------------------------------------------------------------
NS_IMETHODIMP_(void)
nsToolbarCore::Alert(const nsString &aText)
{
printf("Alert\n");
}
NS_IMETHODIMP_(PRBool)
nsToolbarCore::Confirm(const nsString &aText)
{
PRBool bResult = PR_FALSE;
printf("Confirm\n");
return bResult;
}
NS_IMETHODIMP_(PRBool)
nsToolbarCore::Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult)
{
PRBool bResult = PR_FALSE;
printf("Prompt\n");
return bResult;
}
NS_IMETHODIMP_(PRBool)
nsToolbarCore::PromptUserAndPassword(const nsString &aText,
nsString &aUser,
nsString &aPassword)
{
PRBool bResult = PR_FALSE;
printf("PromptUserAndPassword\n");
DoDialog();
return bResult;
}
NS_IMETHODIMP_(PRBool)
nsToolbarCore::PromptPassword(const nsString &aText,
nsString &aPassword)
{
PRBool bResult = PR_FALSE;
printf("PromptPassword\n");
return bResult;
}

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

@ -27,6 +27,8 @@
#include "nsIDOMToolbarCore.h"
#include "nsBaseAppCore.h"
#include "nsINetSupport.h"
#include "nsIStreamObserver.h"
class nsIBrowserWindow;
class nsIWebShell;
@ -34,13 +36,16 @@ class nsIScriptContext;
class nsIDOMWindow;
class nsIDOMDocument;
class nsIDOMCharacterData;
class nsIWebShellWindow;
////////////////////////////////////////////////////////////////////////////////
// nsToolbarCore:
////////////////////////////////////////////////////////////////////////////////
class nsToolbarCore : public nsBaseAppCore,
public nsIDOMToolbarCore
public nsIDOMToolbarCore,
public nsINetSupport,
public nsIStreamObserver
{
public:
@ -54,11 +59,36 @@ class nsToolbarCore : public nsBaseAppCore,
NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); }
NS_IMETHOD SetWindow(nsIDOMWindow* aWin);
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin);
NS_IMETHOD SetStatus(const nsString& aMsg);
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg);
// nsINetSupport
NS_IMETHOD_(void) Alert(const nsString &aText);
NS_IMETHOD_(PRBool) Confirm(const nsString &aText);
NS_IMETHOD_(PRBool) Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult);
NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText,
nsString &aUser,
nsString &aPassword);
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
private:
NS_IMETHOD DoDialog();
nsIDOMWindow *mWindow;
nsIWebShellWindow *mWebShellWin;
nsIDOMCharacterData *mStatusText;
};