From e370dcf06ec91745ccda8514270730e318e1af86 Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Mon, 2 Nov 1998 20:45:10 +0000 Subject: [PATCH] Some testing enhancements and fixes --- calendar/modules/shell/inc/manifest.mn | 1 + calendar/modules/shell/inc/nsCalTestStrings.h | 37 ++++++++ .../modules/shell/src/nsCalendarShell.cpp | 85 +++++++++++++------ .../commandserver/src/nsCommandServer.cpp | 7 +- 4 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 calendar/modules/shell/inc/nsCalTestStrings.h diff --git a/calendar/modules/shell/inc/manifest.mn b/calendar/modules/shell/inc/manifest.mn index 3fe45a427a70..5591b71c19fe 100644 --- a/calendar/modules/shell/inc/manifest.mn +++ b/calendar/modules/shell/inc/manifest.mn @@ -22,6 +22,7 @@ PRIVATE_EXPORTS = \ nsCalendarShell.h \ nsCalendarWidget.h \ nsCalShellFactory.h \ + nsCalTestStrings.h \ $(NULL) MODULE = trex diff --git a/calendar/modules/shell/inc/nsCalTestStrings.h b/calendar/modules/shell/inc/nsCalTestStrings.h new file mode 100644 index 000000000000..ff8c8c5fed50 --- /dev/null +++ b/calendar/modules/shell/inc/nsCalTestStrings.h @@ -0,0 +1,37 @@ +/* -*- 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 "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 nsCalTestStrings_h___ +#define nsCalTestStrings_h___ + +#define ZULUCOMMAND_HELP "Valid JS commands are:\r\n\r\n" \ + " zulucommand(\"help\",\"help\"); Get even more help on help\r\n" \ + " zulucommand(\"help\",\"panel\"); Get help on specifying methods for panels\r\n" + +#define ZULUCOMMAND_HELP_PANEL "***panel syntax is:***\r\n\r\n" \ + " zulucommand(\"panel\",\"name\",\"method\",\"param1\",...,\"paramN\");\r\n\r\n" \ + " where: \r\n" \ + " name: XML Name of the panel\r\n" \ + " method: Method to be invoked on panel\r\n" \ + " paramX: Arbitrary list of parameters to be passed to method\r\n\r\n" \ + "***Available Methods include:***\r\n" \ + " \"getbackgroundcolor\" - Get the background color for named canvas\r\n" \ + " \"setbackgroundcolor\",\"#RRGGBB\" - Set the background color to named canvas\r\n" \ + +#endif //nsCalTestStrings_h___ + diff --git a/calendar/modules/shell/src/nsCalendarShell.cpp b/calendar/modules/shell/src/nsCalendarShell.cpp index 3fcec0ccb58d..b0fa76f350f0 100644 --- a/calendar/modules/shell/src/nsCalendarShell.cpp +++ b/calendar/modules/shell/src/nsCalendarShell.cpp @@ -135,6 +135,8 @@ static NS_DEFINE_IID(kCMIMEServiceCID, NS_MIME_SERVICE_CID); #include "nsIXPFCObserver.h" #define kNotFound -1 +#include "nsCalTestStrings.h" + // All Application Must implement this function nsresult NS_RegisterApplicationShellFactory() { @@ -1228,6 +1230,7 @@ extern "C" void XP_Trace( const char *, ... ) // XXX: Move Me. This code was in the CommandCanvas, but is really // independent of any UI +// XXX: Lots of testing code is going here, needs to be moved... nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply) { @@ -1235,46 +1238,52 @@ nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply) /* * Extract the CanvasName, method and params out */ - + nsString target, name, method, param; aCommand.Trim(" \r\n\t"); PRInt32 offset = aCommand.Find(' '); - 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); - - offset = aCommand.Find(' '); - if (offset == kNotFound) { - method = aCommand; - param = ""; - } else - { - aCommand.Left(method,offset); + target = aCommand; + } else { + + aCommand.Left(target,offset); aCommand.Cut(0,offset); aCommand.Trim(" \r\n\t",PR_TRUE,PR_FALSE); - param = aCommand; + offset = aCommand.Find(' '); + + if (offset == kNotFound) + { + name = aCommand; + } else { + + aCommand.Left(name,offset); + aCommand.Cut(0,offset); + aCommand.Trim(" \r\n\t",PR_TRUE,PR_FALSE); + + offset = aCommand.Find(' '); + + if (offset == kNotFound) + { + method = aCommand; + param = ""; + } else + { + aCommand.Left(method,offset); + aCommand.Cut(0,offset); + aCommand.Trim(" \r\n\t",PR_TRUE,PR_FALSE); + + param = aCommand; + } + } } /* - * Fint the canvas by this name + * Find the canvas by this name */ if (target.EqualsIgnoreCase(XPFC_STRING_PANEL)) @@ -1332,8 +1341,30 @@ nsresult nsCalendarShell :: SendCommand(nsString& aCommand, nsString& aReply) NS_IF_RELEASE(command); NS_IF_RELEASE(observer); + } else if (target.EqualsIgnoreCase(XPFC_STRING_HELP)) { + + /* + * Return basic help? + */ + + if (name.Length() == 0) + { + aReply = ZULUCOMMAND_HELP; + + } else if (name.EqualsIgnoreCase(XPFC_STRING_PANEL)) { + + aReply = ZULUCOMMAND_HELP_PANEL; + + } else { + + aReply = "ERROR: Command Not Known:\r\n"; + aReply += ZULUCOMMAND_HELP; + + } + + } else { - aReply = "ERROR: target class unknown\n"; + aReply = "ERROR: target class unknown\r\n"; } return NS_OK; diff --git a/xpfc/network/commandserver/src/nsCommandServer.cpp b/xpfc/network/commandserver/src/nsCommandServer.cpp index 9a3e553c6a24..ef564e0d44b5 100644 --- a/xpfc/network/commandserver/src/nsCommandServer.cpp +++ b/xpfc/network/commandserver/src/nsCommandServer.cpp @@ -219,7 +219,7 @@ static void PR_CALLBACK CommandServerClientThread(void * arg) { nsString string = "BOBO"; - string.SetString(in_buf->data, bytes2); + string.SetString(in_buf->data, nsCRT::strlen(in_buf->data)); // XXX: We really need an interface for receiving string results // for CommandInvoker queries. Right now, we can dispatch @@ -232,6 +232,7 @@ static void PR_CALLBACK CommandServerClientThread(void * arg) // // I believe sman had an idea on how to do these things, check my notes... // +#if 0 if (string.EqualsIgnoreCase(XPFC_STRING_HELP) || string.EqualsIgnoreCase(XPFC_STRING_QUESTIONMARK)) { @@ -240,7 +241,7 @@ static void PR_CALLBACK CommandServerClientThread(void * arg) nsCRT::memcpy(in_buf->data, "Help Not Yet Implemented ... Sorry Steve!!!\n", bytes); } else { - +#endif nsString reply("Command Received and Executed!!!\n"); gApplicationShell->ReceiveCommand(string, reply); @@ -255,8 +256,10 @@ static void PR_CALLBACK CommandServerClientThread(void * arg) nsCRT::memcpy(in_buf->data, cstring, reply.Length()); delete cstring; +#if 0 } +#endif