- Change default exe type to be console on win32 during debug builds
- Add support for Set/Get Colors on Background/Foreground/Border via Scripting - Add nsXPFCError.h header file for XPFC specific errors and macros - Changed CommandServer to block upon calls across network. This is to allow returns values on queries like GetBackgroundColor() to return synchronously - Added support for 'class' type commands in zulutest - Threw JS on it's own thread for interactive testing purposes - support for command-line useage for zulutest includes verbose, quiet, console output & source JS script file - ZuluTest implements nsIStreamListener for obtaining JS over network
This commit is contained in:
Родитель
96a5740a48
Коммит
cd53b5220f
|
@ -46,7 +46,7 @@
|
|||
#include "nscalcids.h"
|
||||
#include "capi.h"
|
||||
#include "nsICapi.h"
|
||||
|
||||
#include "nsxpfcstrings.h"
|
||||
#include "nsCoreCIID.h"
|
||||
#include "nsLayer.h"
|
||||
#include "nsLayerCollection.h"
|
||||
|
@ -1055,13 +1055,12 @@ extern "C" int XP_ReBuffer (const char *net_buffer, int32 net_buffer_size,
|
|||
|
||||
/* mozilla/include/xp_trace.h */
|
||||
|
||||
#if defined(NS_DEBUG)
|
||||
extern "C" void XP_Trace( const char *, ... )
|
||||
{
|
||||
printf("XP_Trace not implemented, stubbed in CalendarShell.cpp\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// XXX: Move Me. This code was in the CommandCanvas, but is really
|
||||
// independent of any UI
|
||||
|
@ -1073,7 +1072,7 @@ nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply)
|
|||
* Extract the CanvasName, method and params out
|
||||
*/
|
||||
|
||||
nsString name, method, param;
|
||||
nsString target, name, method, param;
|
||||
|
||||
aCommand.Trim(" \r\n\t");
|
||||
|
||||
|
@ -1081,7 +1080,16 @@ nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply)
|
|||
|
||||
if (offset == kNotFound)
|
||||
return NS_OK;
|
||||
|
||||
|
||||
aCommand.Left(target,offset);
|
||||
aCommand.Cut(0,offset);
|
||||
aCommand.Trim(" \r\n\t",PR_TRUE,PR_FALSE);
|
||||
|
||||
offset = aCommand.Find(' ');
|
||||
|
||||
if (offset == kNotFound)
|
||||
return NS_OK;
|
||||
|
||||
aCommand.Left(name,offset);
|
||||
aCommand.Cut(0,offset);
|
||||
aCommand.Trim(" \r\n\t",PR_TRUE,PR_FALSE);
|
||||
|
@ -1105,59 +1113,64 @@ nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply)
|
|||
* Fint the canvas by this name
|
||||
*/
|
||||
|
||||
nsIXPFCCanvas * root = nsnull;
|
||||
nsIXPFCCanvas * canvas = nsnull;
|
||||
if (target.EqualsIgnoreCase(XPFC_STRING_PANEL))
|
||||
{
|
||||
nsIXPFCCanvas * root = nsnull;
|
||||
nsIXPFCCanvas * canvas = nsnull;
|
||||
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
|
||||
canvas = root->CanvasFromName(name);
|
||||
canvas = root->CanvasFromName(name);
|
||||
|
||||
NS_RELEASE(root);
|
||||
NS_RELEASE(root);
|
||||
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
/*
|
||||
* Send this command directly to the the canvas.
|
||||
*/
|
||||
/*
|
||||
* Send this command directly to the the canvas.
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kCXPFCMethodInvokerCommandCID, NS_XPFC_METHODINVOKER_COMMAND_CID);
|
||||
static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
static NS_DEFINE_IID(kCXPFCMethodInvokerCommandCID, NS_XPFC_METHODINVOKER_COMMAND_CID);
|
||||
static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
|
||||
nsXPFCMethodInvokerCommand * command;
|
||||
nsXPFCMethodInvokerCommand * command;
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCXPFCMethodInvokerCommandCID,
|
||||
nsnull,
|
||||
kXPFCCommandIID,
|
||||
(void **)&command);
|
||||
nsresult res = nsRepository::CreateInstance(kCXPFCMethodInvokerCommandCID,
|
||||
nsnull,
|
||||
kXPFCCommandIID,
|
||||
(void **)&command);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
command->Init();
|
||||
command->Init();
|
||||
|
||||
command->mMethod = method;
|
||||
command->mParams = param;
|
||||
command->mMethod = method;
|
||||
command->mParams = param;
|
||||
|
||||
/*
|
||||
* Pass this Command onto the Observer interface of the target canvas directly.
|
||||
* There is no need to go through the ObserverManager since we have the
|
||||
* necessary info
|
||||
*/
|
||||
/*
|
||||
* Pass this Command onto the Observer interface of the target canvas directly.
|
||||
* There is no need to go through the ObserverManager since we have the
|
||||
* necessary info
|
||||
*/
|
||||
|
||||
nsIXPFCObserver * observer = nsnull;
|
||||
nsIXPFCSubject * subject = nsnull;
|
||||
nsIXPFCObserver * observer = nsnull;
|
||||
nsIXPFCSubject * subject = nsnull;
|
||||
|
||||
res = canvas->QueryInterface(kCXPFCObserverIID, (void **)&observer);
|
||||
if (res == NS_OK)
|
||||
observer->Update(subject,command);
|
||||
res = canvas->QueryInterface(kCXPFCObserverIID, (void **)&observer);
|
||||
if (res == NS_OK)
|
||||
observer->Update(subject,command);
|
||||
|
||||
aReply = command->mReply;
|
||||
aReply = command->mReply;
|
||||
|
||||
NS_IF_RELEASE(command);
|
||||
NS_IF_RELEASE(observer);
|
||||
NS_IF_RELEASE(command);
|
||||
NS_IF_RELEASE(observer);
|
||||
} else {
|
||||
aReply = "ERROR: target class unknown\n";
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsITextAreaWidget.h"
|
||||
#include "nspr.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#define TCP_MESG_SIZE 1024
|
||||
#define TCP_SERVER_PORT 666
|
||||
|
@ -47,8 +48,10 @@ typedef struct buffer {
|
|||
char data[TCP_MESG_SIZE * 2];
|
||||
} buffer;
|
||||
|
||||
class nsIURL;
|
||||
|
||||
class nsTrexTestShell : public nsITrexTestShell
|
||||
class nsTrexTestShell : public nsITrexTestShell,
|
||||
public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
nsTrexTestShell();
|
||||
|
@ -69,11 +72,16 @@ public:
|
|||
NS_IMETHOD GetWebViewerContainer(nsIWebViewerContainer ** aWebViewerContainer) ;
|
||||
NS_IMETHOD StartCommandServer();
|
||||
NS_IMETHOD SendCommand(nsString& aCommand);
|
||||
NS_IMETHOD ExecuteJS();
|
||||
|
||||
private:
|
||||
NS_METHOD RegisterFactories();
|
||||
NS_IMETHOD SendJS(nsString& aCommand);
|
||||
NS_IMETHOD LoadScript(nsString& aScript);
|
||||
NS_IMETHOD ReceiveCommand(nsString& aCommand, nsString& aReply);
|
||||
NS_METHOD ParseCommandLine();
|
||||
NS_IMETHOD LoadUI();
|
||||
NS_IMETHOD InitNetwork();
|
||||
|
||||
private:
|
||||
nsIShellInstance * mShellInstance ;
|
||||
|
@ -92,10 +100,27 @@ private:
|
|||
PRMonitor * mClientMon;
|
||||
PRNetAddr mClientAddr;
|
||||
nsString mCommand;
|
||||
JSRuntime * mJSRuntime ;
|
||||
JSContext * mJSContext;
|
||||
JSRuntime * mJSRuntime ;
|
||||
JSContext * mJSContext;
|
||||
JSObject * mJSGlobal;
|
||||
JSObject * mJSZuluObject;
|
||||
JSObject * mJSZuluObject;
|
||||
nsString mScript;
|
||||
nsIURL * mURL;
|
||||
nsIStreamListener * mListener;
|
||||
nsString mJSData;
|
||||
PRBool mQuiet;
|
||||
PRBool mVerbose;
|
||||
PRBool mStdOut;
|
||||
|
||||
// nsIStreamListener interfaces
|
||||
public:
|
||||
NS_IMETHOD GetBindInfo(nsIURL* aURL);
|
||||
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, PRInt32 aLength) ;
|
||||
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg);
|
||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- 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.0 (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) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
var colors = new Array(12);
|
||||
colors[0] = "#FF0000";
|
||||
colors[1] = "#00FF00";
|
||||
colors[2] = "#0000FF";
|
||||
colors[3] = "#FF00FF";
|
||||
colors[4] = "#000000";
|
||||
colors[5] = "#00FFFF";
|
||||
colors[6] = "#FFFFFF";
|
||||
colors[7] = "#808000";
|
||||
colors[8] = "#B00080";
|
||||
colors[9] = "#00B080";
|
||||
colors[10] = "#B0B080";
|
||||
colors[11] = "#FFBB44";
|
||||
|
||||
var index = 0;
|
||||
|
||||
function changeColor()
|
||||
{
|
||||
while (index < 11)
|
||||
{
|
||||
zulucommand("panel","timebarscale","setbackgroundcolor",colors[index]);
|
||||
zulucommand("panel","timebarscale","getbackgroundcolor");
|
||||
zulucommand("panel","timebarscale","setforegroundcolor",colors[index+1]);
|
||||
zulucommand("panel","timebarscale","getforegroundcolor");
|
||||
zulucommand("panel","timebarscale","setbordercolor",colors[index+2]);
|
||||
zulucommand("panel","timebarscale","getbordercolor");
|
||||
|
||||
zulucommand("panel","prevday","setforegroundcolor",colors[index+1]);
|
||||
zulucommand("panel","prevday","getforegroundcolor");
|
||||
zulucommand("panel","nextday","setforegroundcolor",colors[index+1]);
|
||||
zulucommand("panel","nextday","getforegroundcolor");
|
||||
zulucommand("panel","prevhour","setforegroundcolor",colors[index+1]);
|
||||
zulucommand("panel","prevhour","getforegroundcolor");
|
||||
zulucommand("panel","nexthour","setforegroundcolor",colors[index+1]);
|
||||
zulucommand("panel","nexthour","getforegroundcolor");
|
||||
|
||||
index++;
|
||||
if (index >= 10) {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeColor();
|
|
@ -1,27 +0,0 @@
|
|||
#
|
||||
# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
# NETSCAPE COMMUNICATIONS CORPORATION
|
||||
# Copyright (C) 1996 Netscape Communications Corporation. All Rights
|
||||
# Reserved. Use of this Source Code is subject to the terms of the
|
||||
# applicable license agreement from Netscape Communications Corporation.
|
||||
# The copyright notice(s) in this Source Code does not indicate actual or
|
||||
# intended publication of this Source Code.
|
||||
#
|
||||
GDEPTH = ../../../..
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
PRIVATE_EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
MODULE = trex
|
||||
|
||||
CPPSRCS = \
|
||||
nsTrexTestShell.cpp \
|
||||
nsTrexTestShellFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
REQUIRES = xpcom raptor julian nls netlib pref js xpfc trex
|
||||
|
|
@ -32,21 +32,12 @@
|
|||
#include "nsIDeviceContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nspr.h"
|
||||
|
||||
#define HEIGHT 30
|
||||
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);
|
||||
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
|
||||
nsITrexTestShell * gShell = nsnull;
|
||||
|
||||
nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent);
|
||||
|
||||
// All Applications must specify this *special* application CID
|
||||
// to their own unique IID.
|
||||
nsIID kIXPCOMApplicationShellCID = NS_TREXTEST_SHELL_CID ;
|
||||
#include "plgetopt.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsCRT.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
#ifdef NS_UNIX
|
||||
#include "Xm/Xm.h"
|
||||
|
@ -54,31 +45,89 @@ nsIID kIXPCOMApplicationShellCID = NS_TREXTEST_SHELL_CID ;
|
|||
#include "Xm/Frame.h"
|
||||
#include "Xm/XmStrDefs.h"
|
||||
#include "Xm/DrawingA.h"
|
||||
|
||||
extern XtAppContext app_context;
|
||||
extern Widget topLevel;
|
||||
#endif
|
||||
|
||||
|
||||
#include "nsCRT.h"
|
||||
static void PR_CALLBACK TrexTestClientThread(void *arg);
|
||||
|
||||
|
||||
#include "jsapi.h"
|
||||
void PR_CALLBACK ZuluErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
PR_STATIC_CALLBACK(JSBool) Zulu(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
/*
|
||||
* Enums
|
||||
*/
|
||||
|
||||
enum Zulu_slots {
|
||||
ZULU_ZULU = -1,
|
||||
ZULU_ALIVE = -2
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
|
||||
#define HEIGHT 30
|
||||
|
||||
/*
|
||||
* Local Consts
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);
|
||||
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
|
||||
/*
|
||||
* External refs
|
||||
*/
|
||||
|
||||
#ifdef NS_UNIX
|
||||
extern XtAppContext app_context;
|
||||
extern Widget topLevel;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local Globals
|
||||
*/
|
||||
|
||||
nsITrexTestShell * gShell = nsnull;
|
||||
nsIID kIXPCOMApplicationShellCID = NS_TREXTEST_SHELL_CID ;
|
||||
static PRFileDesc *output = nsnull;
|
||||
static PRFileDesc *fd_stdout = nsnull;
|
||||
|
||||
/*
|
||||
* Forward Declarations
|
||||
*/
|
||||
|
||||
nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent);
|
||||
static void PR_CALLBACK TrexTestClientThread(void *arg);
|
||||
static void PR_CALLBACK JSThread(void *arg);
|
||||
void PR_CALLBACK ZuluErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
PR_STATIC_CALLBACK(JSBool) Zulu(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
PR_STATIC_CALLBACK(JSBool) ZuluCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
|
||||
|
||||
/*
|
||||
* Useage
|
||||
*/
|
||||
|
||||
static nsresult Usage(void)
|
||||
{
|
||||
PR_fprintf(output, "\nzulutest [-q] [-d] [-o] [-v] [-s <filename>]\n");
|
||||
PR_fprintf(output, " -d\t\tdebug mode\n");
|
||||
PR_fprintf(output, " -q\t\tquiet mode, no interactive UI\n");
|
||||
PR_fprintf(output, " -o\t\tredirect output to stdout\n");
|
||||
PR_fprintf(output, " -v\t\tverbose output\n");
|
||||
PR_fprintf(output, " -s <filename>\tlaunch command script \t(implies -c)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetZuluProperty
|
||||
*/
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool) GetZuluProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsTrexTestShell * a = (nsTrexTestShell*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -103,32 +152,44 @@ PR_STATIC_CALLBACK(JSBool) GetZuluProperty(JSContext *cx, JSObject *obj, jsval i
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* SetZuluProperty
|
||||
*/
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool) SetZuluProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* FinalizeZulu
|
||||
*/
|
||||
|
||||
PR_STATIC_CALLBACK(void) FinalizeZulu(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* EnumerateZulu
|
||||
*/
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool) EnumerateZulu(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* ResolveZulu
|
||||
*/
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool) ResolveZulu(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool) ZuluCommand(JSContext *cx,
|
||||
JSObject *obj,
|
||||
uintN argc,
|
||||
jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
/*
|
||||
* JS Zulu class prototype
|
||||
*/
|
||||
|
||||
JSClass ZuluClass =
|
||||
{
|
||||
|
@ -199,23 +260,34 @@ nsTrexTestShell::nsTrexTestShell()
|
|||
mJSZuluObject = nsnull;
|
||||
|
||||
Zulu(nsnull,nsnull,0,nsnull,nsnull);
|
||||
|
||||
mScript = "";
|
||||
mURL = nsnull;
|
||||
mListener = nsnull;
|
||||
mJSData = "";
|
||||
|
||||
mQuiet = PR_FALSE;
|
||||
mVerbose = PR_FALSE;
|
||||
mStdOut = PR_FALSE;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* nsTrexTestShell dtor
|
||||
*/
|
||||
|
||||
nsTrexTestShell::~nsTrexTestShell()
|
||||
{
|
||||
if (mJSContext) JS_DestroyContext(mJSContext);
|
||||
if (mJSRuntime) JS_Finish(mJSRuntime);
|
||||
|
||||
mJSContext = NULL;
|
||||
mJSRuntime = NULL;
|
||||
|
||||
NS_IF_RELEASE(mInput);
|
||||
NS_IF_RELEASE(mDisplay);
|
||||
NS_IF_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mListener);
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
|
||||
/*
|
||||
* nsISupports stuff
|
||||
*/
|
||||
|
||||
nsresult nsTrexTestShell::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -232,6 +304,9 @@ nsresult nsTrexTestShell::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
else if(aIID.Equals(kIAppShellIID)) { //do nsIContentSink base class...
|
||||
*aInstancePtr = (nsIAppShell*)(this);
|
||||
}
|
||||
else if(aIID.Equals(kIStreamListenerIID)) { //do nsIContentSink base class...
|
||||
*aInstancePtr = (nsIStreamListener*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
|
@ -243,6 +318,10 @@ nsresult nsTrexTestShell::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
NS_IMPL_ADDREF(nsTrexTestShell)
|
||||
NS_IMPL_RELEASE(nsTrexTestShell)
|
||||
|
||||
/*
|
||||
* Init
|
||||
*/
|
||||
|
||||
nsresult nsTrexTestShell::Init()
|
||||
{
|
||||
|
||||
|
@ -257,6 +336,103 @@ nsresult nsTrexTestShell::Init()
|
|||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
/*
|
||||
* Parse the command line
|
||||
*/
|
||||
|
||||
res = ParseCommandLine();
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
/*
|
||||
* Load UI if not in quiet mode
|
||||
*/
|
||||
|
||||
if (PR_FALSE == mQuiet)
|
||||
LoadUI();
|
||||
|
||||
/*
|
||||
* Get the basic networking stuff
|
||||
*/
|
||||
|
||||
InitNetwork();
|
||||
|
||||
/*
|
||||
* Load a Script if it was specified on the command line
|
||||
*/
|
||||
|
||||
|
||||
LoadScript(mScript);
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsTrexTestShell::Create(int* argc, char ** argv)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::InitNetwork()
|
||||
{
|
||||
mClientMon = PR_NewMonitor();
|
||||
PR_EnterMonitor(mClientMon);
|
||||
|
||||
PRFileDesc * sockfd = nsnull;
|
||||
PRNetAddr netaddr;
|
||||
PRInt32 i = 0;
|
||||
|
||||
sockfd = PR_NewTCPSocket();
|
||||
|
||||
if (sockfd == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
nsCRT::memset(&netaddr, 0 , sizeof(netaddr));
|
||||
|
||||
netaddr.inet.family = PR_AF_INET;
|
||||
netaddr.inet.port = PR_htons(TCP_SERVER_PORT);
|
||||
netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
||||
|
||||
while (PR_Bind(sockfd, &netaddr) < 0)
|
||||
{
|
||||
if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR)
|
||||
{
|
||||
netaddr.inet.port += 2;
|
||||
if (i++ < SERVER_MAX_BIND_COUNT)
|
||||
continue;
|
||||
}
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_Listen(sockfd, 32) < 0)
|
||||
{
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_GetSockName(sockfd, &netaddr) < 0)
|
||||
{
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mClientAddr.inet.family = netaddr.inet.family;
|
||||
mClientAddr.inet.port = netaddr.inet.port;
|
||||
mClientAddr.inet.ip = netaddr.inet.ip;
|
||||
|
||||
PR_Close(sockfd);
|
||||
|
||||
PR_ExitMonitor(mClientMon);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::LoadUI()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
nsRect aRect(100,100,800, 600) ;
|
||||
|
||||
nsIAppShell * appshell ;
|
||||
|
@ -272,7 +448,7 @@ nsresult nsTrexTestShell::Init()
|
|||
* create the 2 widgets
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kInsTextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
static NS_DEFINE_IID(kInsTextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
|
||||
nsRepository::CreateInstance(kCTextAreaCID,
|
||||
nsnull,
|
||||
|
@ -336,91 +512,9 @@ nsresult nsTrexTestShell::Init()
|
|||
|
||||
mShellInstance->ShowApplicationWindow(PR_TRUE) ;
|
||||
|
||||
|
||||
mClientMon = PR_NewMonitor();
|
||||
PR_EnterMonitor(mClientMon);
|
||||
|
||||
PRFileDesc * sockfd = nsnull;
|
||||
PRNetAddr netaddr;
|
||||
PRInt32 i = 0;
|
||||
|
||||
sockfd = PR_NewTCPSocket();
|
||||
|
||||
if (sockfd == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
nsCRT::memset(&netaddr, 0 , sizeof(netaddr));
|
||||
|
||||
netaddr.inet.family = PR_AF_INET;
|
||||
netaddr.inet.port = PR_htons(TCP_SERVER_PORT);
|
||||
netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
||||
|
||||
while (PR_Bind(sockfd, &netaddr) < 0)
|
||||
{
|
||||
if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR)
|
||||
{
|
||||
netaddr.inet.port += 2;
|
||||
if (i++ < SERVER_MAX_BIND_COUNT)
|
||||
continue;
|
||||
}
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_Listen(sockfd, 32) < 0)
|
||||
{
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_GetSockName(sockfd, &netaddr) < 0)
|
||||
{
|
||||
PR_Close(sockfd);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mClientAddr.inet.family = netaddr.inet.family;
|
||||
mClientAddr.inet.port = netaddr.inet.port;
|
||||
mClientAddr.inet.ip = netaddr.inet.ip;
|
||||
|
||||
PR_Close(sockfd);
|
||||
|
||||
// Kick off JS - Later on, we need to look at the DOM
|
||||
mJSRuntime = JS_Init((uint32) 0xffffffffL);
|
||||
|
||||
if (nsnull != mJSRuntime)
|
||||
mJSContext = JS_NewContext(mJSRuntime, 8192);
|
||||
|
||||
mJSGlobal = JS_NewObject(mJSContext, &ZuluClass, nsnull, nsnull);
|
||||
|
||||
if (nsnull != mJSGlobal)
|
||||
{
|
||||
JS_SetPrivate(mJSContext, mJSGlobal, this);
|
||||
|
||||
JS_DefineProperties(mJSContext, mJSGlobal, ZuluProperties);
|
||||
JS_DefineFunctions(mJSContext, mJSGlobal, ZuluMethods);
|
||||
|
||||
//JS_AddNamedRoot(mJSContext, aSlot, "zulu_object");
|
||||
|
||||
JS_InitStandardClasses(mJSContext, mJSGlobal);
|
||||
JS_SetGlobalObject(mJSContext, mJSGlobal);
|
||||
|
||||
// Init our Zulu object here!
|
||||
//JS_DefineProperties(mJSContext, mJSGlobal, ZuluProperties);
|
||||
//JS_DefineFunctions(mJSContext, mJSGlobal, ZuluMethods);
|
||||
|
||||
JS_SetErrorReporter(mJSContext, ZuluErrorReporter);
|
||||
|
||||
}
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsTrexTestShell::Create(int* argc, char ** argv)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::Exit()
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -480,25 +574,131 @@ nsresult nsTrexTestShell::GetWebViewerContainer(nsIWebViewerContainer ** aWebVie
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::LoadScript(nsString& aScript)
|
||||
{
|
||||
/*
|
||||
* aScript represents a URL to load. Let's use Netlib to grab the
|
||||
* script and pass the contents off to JS
|
||||
*/
|
||||
|
||||
if (mScript.Length() == 0)
|
||||
return NS_OK;
|
||||
|
||||
/*
|
||||
* Create a URL
|
||||
*/
|
||||
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_TRUE == mStdOut)
|
||||
{
|
||||
char * c = mScript.ToNewCString();
|
||||
PR_fprintf(fd_stdout, "STATUS: Loading JS URL %s\n",c);
|
||||
delete c;
|
||||
}
|
||||
|
||||
res = NS_NewURL(&mURL, mScript);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
res = QueryInterface(kIStreamListenerIID, (void **) &mListener);
|
||||
|
||||
if (NS_OK == res)
|
||||
mURL->Open(mListener);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::SendJS(nsString& aCommand)
|
||||
{
|
||||
nsIWidget * iw = nsnull;
|
||||
nsresult res = mInput->QueryInterface(kIWidgetIID, (void**)&iw);
|
||||
nsIWidget * dw = nsnull;
|
||||
res = mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_FALSE == mQuiet)
|
||||
{
|
||||
nsIWidget * iw = nsnull;
|
||||
res = mInput->QueryInterface(kIWidgetIID, (void**)&iw);
|
||||
nsIWidget * dw = nsnull;
|
||||
res = mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
|
||||
|
||||
mInput->RemoveText();
|
||||
iw->Invalidate(PR_TRUE);
|
||||
nsString string("COMMAND: ");
|
||||
PRUint32 length;
|
||||
mDisplay->InsertText(string,0x7fffffff,0x7fffffff,length);
|
||||
NS_RELEASE(iw);
|
||||
NS_RELEASE(dw);
|
||||
}
|
||||
|
||||
if (PR_TRUE == mStdOut)
|
||||
PR_fprintf(fd_stdout, "STATUS: Creating JS Thread to Execute Code\n");
|
||||
|
||||
mInput->RemoveText();
|
||||
iw->Invalidate(PR_TRUE);
|
||||
nsString string("COMMAND: ");
|
||||
PRUint32 length;
|
||||
mDisplay->InsertText(string,0x7fffffff,0x7fffffff,length);
|
||||
mCommand.Truncate(0);
|
||||
aCommand.Copy(mCommand);
|
||||
|
||||
mClientAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);
|
||||
|
||||
/*
|
||||
* Launch JS on a separate thread so the UI will be responsive
|
||||
*/
|
||||
|
||||
|
||||
PRThread *t;
|
||||
|
||||
t = PR_CreateThread(PR_USER_THREAD,
|
||||
JSThread,
|
||||
(void *) this,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD,
|
||||
0);
|
||||
|
||||
#if 0
|
||||
mNumThreads++;
|
||||
|
||||
PR_EnterMonitor(mClientMon);
|
||||
|
||||
while (mNumThreads) {
|
||||
PR_Wait(mClientMon, PR_INTERVAL_NO_TIMEOUT);
|
||||
}
|
||||
|
||||
PR_ExitMonitor(mClientMon);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::ExecuteJS()
|
||||
{
|
||||
jsval rval;
|
||||
|
||||
// Kick off JS - Later on, we need to look at the DOM
|
||||
mJSRuntime = JS_Init((uint32) 0xffffffffL);
|
||||
|
||||
if (nsnull != mJSRuntime)
|
||||
mJSContext = JS_NewContext(mJSRuntime, 8192);
|
||||
|
||||
mJSGlobal = JS_NewObject(mJSContext, &ZuluClass, nsnull, nsnull);
|
||||
|
||||
if (nsnull != mJSGlobal)
|
||||
{
|
||||
JS_SetPrivate(mJSContext, mJSGlobal, this);
|
||||
|
||||
JS_DefineProperties(mJSContext, mJSGlobal, ZuluProperties);
|
||||
JS_DefineFunctions(mJSContext, mJSGlobal, ZuluMethods);
|
||||
|
||||
JS_InitStandardClasses(mJSContext, mJSGlobal);
|
||||
JS_SetGlobalObject(mJSContext, mJSGlobal);
|
||||
|
||||
// Init our Zulu object here!
|
||||
//JS_DefineProperties(mJSContext, mJSGlobal, ZuluProperties);
|
||||
//JS_DefineFunctions(mJSContext, mJSGlobal, ZuluMethods);
|
||||
|
||||
JS_SetErrorReporter(mJSContext, ZuluErrorReporter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
JS_EvaluateUCScriptForPrincipals(mJSContext,
|
||||
JS_GetGlobalObject(mJSContext),
|
||||
nsnull,
|
||||
|
@ -508,32 +708,43 @@ nsresult nsTrexTestShell::SendJS(nsString& aCommand)
|
|||
0,
|
||||
&rval);
|
||||
|
||||
while (mNumThreads) {
|
||||
PR_Wait(mClientMon, PR_INTERVAL_NO_TIMEOUT);
|
||||
}
|
||||
|
||||
PR_ExitMonitor(mClientMon);
|
||||
|
||||
NS_RELEASE(iw);
|
||||
NS_RELEASE(dw);
|
||||
|
||||
ReceiveCommand(mCommand,mCommand);
|
||||
if (mJSContext) JS_DestroyContext(mJSContext);
|
||||
if (mJSRuntime) JS_Finish(mJSRuntime);
|
||||
|
||||
mJSContext = NULL;
|
||||
mJSRuntime = NULL;
|
||||
|
||||
if (PR_TRUE == mStdOut)
|
||||
PR_fprintf(fd_stdout, "STATUS: Exiting JS Thread\n");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTrexTestShell::ReceiveCommand(nsString& aCommand, nsString& aReply)
|
||||
{
|
||||
PRUint32 length;
|
||||
mDisplay->InsertText(aReply,0x7fffffff,0x7fffffff,length);
|
||||
mDisplay->InsertText("\r\n",0x7fffffff,0x7fffffff,length);
|
||||
if (PR_FALSE == mQuiet)
|
||||
{
|
||||
PRUint32 length;
|
||||
mDisplay->InsertText(aReply,0x7fffffff,0x7fffffff,length);
|
||||
mDisplay->InsertText("\r\n",0x7fffffff,0x7fffffff,length);
|
||||
|
||||
nsIWidget * dw = nsnull;
|
||||
nsIWidget * dw = nsnull;
|
||||
|
||||
mDisplay->QueryInterface(kIWidgetIID,(void**)&dw);
|
||||
mDisplay->QueryInterface(kIWidgetIID,(void**)&dw);
|
||||
|
||||
dw->Invalidate(PR_TRUE);
|
||||
|
||||
NS_RELEASE(dw);
|
||||
}
|
||||
|
||||
if (PR_TRUE == mStdOut)
|
||||
{
|
||||
char * c = aReply.ToNewCString();
|
||||
PR_fprintf(fd_stdout, "ReceiveCommand: %s\n",c);
|
||||
delete c;
|
||||
}
|
||||
|
||||
dw->Invalidate(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -592,22 +803,25 @@ nsEventStatus nsTrexTestShell::HandleEvent(nsGUIEvent *aEvent)
|
|||
|
||||
case NS_SIZE:
|
||||
{
|
||||
nsRect * rect = ((nsSizeEvent*)aEvent)->windowSize;
|
||||
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
if (PR_FALSE == mQuiet)
|
||||
{
|
||||
nsRect * rect = ((nsSizeEvent*)aEvent)->windowSize;
|
||||
|
||||
nsIWidget * iw = nsnull;
|
||||
mInput->QueryInterface(kIWidgetIID, (void**)&iw);
|
||||
nsIWidget * dw = nsnull;
|
||||
mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
|
||||
dw->Resize(rect->x,rect->y,rect->width,rect->height-HEIGHT,PR_TRUE);
|
||||
iw->Resize(rect->x,rect->height-HEIGHT,rect->width,HEIGHT,PR_TRUE);
|
||||
nsIWidget * iw = nsnull;
|
||||
mInput->QueryInterface(kIWidgetIID, (void**)&iw);
|
||||
nsIWidget * dw = nsnull;
|
||||
mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
|
||||
|
||||
NS_RELEASE(iw);
|
||||
NS_RELEASE(dw);
|
||||
dw->Resize(rect->x,rect->y,rect->width,rect->height-HEIGHT,PR_TRUE);
|
||||
iw->Resize(rect->x,rect->height-HEIGHT,rect->width,HEIGHT,PR_TRUE);
|
||||
|
||||
NS_RELEASE(iw);
|
||||
NS_RELEASE(dw);
|
||||
}
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break ;
|
||||
|
@ -640,6 +854,14 @@ static void PR_CALLBACK TrexTestClientThread(void *arg)
|
|||
|
||||
}
|
||||
|
||||
static void PR_CALLBACK JSThread(void *arg)
|
||||
{
|
||||
nsTrexTestShell * app = (nsTrexTestShell *) arg;
|
||||
|
||||
app->ExecuteJS();
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult nsTrexTestShell :: RunThread()
|
||||
{
|
||||
|
@ -780,7 +1002,12 @@ PR_STATIC_CALLBACK(JSBool) ZuluCommand(JSContext *cx,
|
|||
nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
|
||||
{
|
||||
/*
|
||||
* Launch a thread to deal with this
|
||||
* We no longer launch a separate thread for dealing
|
||||
* with Zulu Specific commands. The reason is simply that
|
||||
* future commands may depend upon return paramaters on
|
||||
* this command. Since the JS thread is what calls this
|
||||
* API, the JS code being executed will wait until return
|
||||
* of the calling function.
|
||||
*/
|
||||
|
||||
PRThread *t;
|
||||
|
@ -791,6 +1018,16 @@ nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
|
|||
|
||||
mCommand = aCommand;
|
||||
|
||||
if (PR_TRUE == mStdOut)
|
||||
{
|
||||
char * c = mCommand.ToNewCString();
|
||||
PR_fprintf(fd_stdout, "SendCommand: %s\n",c);
|
||||
delete c;
|
||||
}
|
||||
|
||||
RunThread();
|
||||
|
||||
#if 0
|
||||
t = PR_CreateThread(PR_USER_THREAD,
|
||||
TrexTestClientThread,
|
||||
(void *) this,
|
||||
|
@ -800,7 +1037,13 @@ nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
|
|||
0);
|
||||
|
||||
mNumThreads++;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX: we've actually gotten the response back from SendCommand
|
||||
*/
|
||||
|
||||
ReceiveCommand(mCommand,mCommand);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -808,3 +1051,89 @@ nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
|
|||
|
||||
|
||||
|
||||
|
||||
nsresult nsTrexTestShell::ParseCommandLine()
|
||||
{
|
||||
PLOptStatus os;
|
||||
PLOptState *opt;
|
||||
|
||||
output = PR_GetSpecialFD(PR_StandardError);
|
||||
|
||||
mShellInstance->GetCommandLineOptions(&opt,"hoqvdl:s:");
|
||||
|
||||
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
|
||||
{
|
||||
if (PL_OPT_BAD == os)
|
||||
continue;
|
||||
|
||||
switch (opt->option)
|
||||
{
|
||||
case 'd':
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
mQuiet = PR_TRUE;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
mStdOut = PR_TRUE;
|
||||
fd_stdout = PR_GetSpecialFD(PR_StandardOutput);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
mVerbose = PR_TRUE;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
{
|
||||
mScript = opt->value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h': /* confused */
|
||||
default:
|
||||
return Usage();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsTrexTestShell::GetBindInfo(nsIURL* aURL)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult nsTrexTestShell::OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, PRInt32 aLength)
|
||||
{
|
||||
PRInt32 count;
|
||||
char * buffer = (char *)PR_Malloc(sizeof(char) * (aLength+1));
|
||||
|
||||
aIStream->Read(buffer, 0, aLength, &count);
|
||||
|
||||
buffer[aLength] = '\0';
|
||||
|
||||
mJSData += buffer;
|
||||
|
||||
PR_Free(buffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult nsTrexTestShell::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
||||
{
|
||||
mJSData = "";
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult nsTrexTestShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult nsTrexTestShell::OnStatus(nsIURL* aURL, const nsString &aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult nsTrexTestShell::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg)
|
||||
{
|
||||
SendJS(mJSData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nspr.h"
|
||||
#include "nsViewsCID.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsXPFCError.h"
|
||||
|
||||
#define DEFAULT_WIDTH 100
|
||||
#define DEFAULT_HEIGHT 100
|
||||
|
@ -1959,7 +1960,9 @@ nsEventStatus nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
|
|||
if (NS_OK == res)
|
||||
{
|
||||
|
||||
if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBACKGROUNDCOLOR))
|
||||
if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBACKGROUNDCOLOR)
|
||||
|| methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETFOREGROUNDCOLOR)
|
||||
|| methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBORDERCOLOR))
|
||||
{
|
||||
nscolor color;
|
||||
|
||||
|
@ -1967,18 +1970,44 @@ nsEventStatus nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
|
|||
|
||||
NS_HexToRGB(ccolor, &color);
|
||||
|
||||
SetBackgroundColor(color);
|
||||
if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBACKGROUNDCOLOR))
|
||||
SetBackgroundColor(color);
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETFOREGROUNDCOLOR))
|
||||
SetForegroundColor(color);
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBORDERCOLOR))
|
||||
SetBorderColor(color);
|
||||
|
||||
delete ccolor;
|
||||
}
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBACKGROUNDCOLOR))
|
||||
{
|
||||
nsString reply_string("ABGR = ");
|
||||
|
||||
reply_string.Append(GetBackgroundColor(),16);
|
||||
NSRESULT_TO_NSTRING(NS_OK,methodinvoker_command->mReply);
|
||||
}
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBACKGROUNDCOLOR)
|
||||
|| methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETFOREGROUNDCOLOR)
|
||||
|| methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBORDERCOLOR))
|
||||
{
|
||||
nscolor color;
|
||||
|
||||
if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBACKGROUNDCOLOR))
|
||||
color = GetBackgroundColor();
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETFOREGROUNDCOLOR))
|
||||
color = GetForegroundColor();
|
||||
else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBORDERCOLOR))
|
||||
color = GetBorderColor();
|
||||
|
||||
nsString reply_string("#");
|
||||
|
||||
nscolor r = NS_GET_R(color);
|
||||
nscolor g = NS_GET_G(color);
|
||||
nscolor b = NS_GET_B(color);
|
||||
|
||||
reply_string.Append(r,16);
|
||||
if (0 == r) reply_string.Append(r,16);
|
||||
reply_string.Append(g,16);
|
||||
if (0 == g) reply_string.Append(g,16);
|
||||
reply_string.Append(b,16);
|
||||
if (0 == b) reply_string.Append(b,16);
|
||||
|
||||
methodinvoker_command->mReply = reply_string;
|
||||
|
||||
}
|
||||
|
||||
NS_RELEASE(methodinvoker_command);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
# NETSCAPE COMMUNICATIONS CORPORATION
|
||||
# Copyright (C) 1996 Netscape Communications Corporation. All Rights
|
||||
# Reserved. Use of this Source Code is subject to the terms of the
|
||||
# applicable license agreement from Netscape Communications Corporation.
|
||||
# The copyright notice(s) in this Source Code does not indicate actual or
|
||||
# intended publication of this Source Code.
|
||||
#
|
||||
GDEPTH = ../../..
|
||||
|
||||
EXPORTS = \
|
||||
nsxpfcCIID.h \
|
||||
nsxpfcstrings.h \
|
||||
nsxpfc.h \
|
||||
nsxpfcFactory.h \
|
||||
$(NULL)
|
||||
|
||||
PRIVATE_EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
MODULE = xpfc
|
||||
|
||||
REQUIRES = raptor
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsXPFCError_h
|
||||
#define nsXPFCError_h
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
#define NSRESULT_TO_NSTRING(a,b) \
|
||||
if (NS_OK == a) \
|
||||
b = "NS_OK"; \
|
||||
else \
|
||||
b = "RESULTS UNDEFINED"
|
||||
|
||||
#endif
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
#define XPFC_STRING_FULLHOVERIMAGE "fullhoverimage"
|
||||
#define XPFC_STRING_FULLPRESSEDIMAGE "fullpressedimage"
|
||||
#define XPFC_STRING_GETBACKGROUNDCOLOR "getbackgroundcolor"
|
||||
#define XPFC_STRING_GETBORDERCOLOR "getbordercolor"
|
||||
#define XPFC_STRING_GETFOREGROUNDCOLOR "getforegroundcolor"
|
||||
#define XPFC_STRING_HALIGN "halign"
|
||||
#define XPFC_STRING_HEIGHT "height"
|
||||
#define XPFC_STRING_HELP "help"
|
||||
|
@ -49,8 +51,11 @@
|
|||
#define XPFC_STRING_MINIPRESSEDIMAGE "minipressedimage"
|
||||
#define XPFC_STRING_MENUCONTAINER "menucontainer"
|
||||
#define XPFC_STRING_NAME "name"
|
||||
#define XPFC_STRING_PANEL "panel"
|
||||
#define XPFC_STRING_RIGHT "right"
|
||||
#define XPFC_STRING_SETBACKGROUNDCOLOR "setbackgroundcolor"
|
||||
#define XPFC_STRING_SETBORDERCOLOR "setbordercolor"
|
||||
#define XPFC_STRING_SETFOREGROUNDCOLOR "setforegroundcolor"
|
||||
#define XPFC_STRING_SRC "src"
|
||||
#define XPFC_STRING_TABGROUP "tabgroup"
|
||||
#define XPFC_STRING_TABID "tabid"
|
||||
|
|
|
@ -47,6 +47,7 @@ nsCommandServer :: nsCommandServer()
|
|||
|
||||
nsCommandServer :: ~nsCommandServer()
|
||||
{
|
||||
ExitThread();
|
||||
NS_IF_RELEASE(mApplicationShell);
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,7 @@ nsresult nsCommandServer :: RunThread()
|
|||
* the communication
|
||||
*/
|
||||
|
||||
for (i = 0; i < (NUM_TCP_CLIENTS * NUM_TCP_CONNECTIONS_PER_CLIENT); i++)
|
||||
while(mNumThreads)//for (i = 0; i < (NUM_TCP_CLIENTS * NUM_TCP_CONNECTIONS_PER_CLIENT); i++)
|
||||
{
|
||||
newsockfd = PR_Accept(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT);
|
||||
|
||||
|
@ -193,7 +194,9 @@ static void PR_CALLBACK CommandServerThread(void * arg)
|
|||
|
||||
command_server->RunThread();
|
||||
|
||||
#if 0
|
||||
command_server->ExitThread();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -282,7 +285,7 @@ nsresult nsCommandServer :: ExitThread()
|
|||
--(*mExitCounter);
|
||||
PR_Notify(mExitMon);
|
||||
PR_ExitMonitor(mExitMon);
|
||||
|
||||
mNumThreads--;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче