AppHandleEvt.cpp

       1  #include <PalmOS.h>
          #include "AppHandleEvt.h"
          #include "NetControls.h"
          #include "AppResources.h"
          
          /***********************************************************************
           *
           * FUNCTION: MainFormDoCommand
           *
           * DESCRIPTION: This routine performs the menu command specified.
           *
           * PARAMETERS: command - menu item id
           *
           * RETURNED: nothing
           *
           * REVISION HISTORY: 6.0
           *
           *
           ***********************************************************************/
      20  Boolean AppHandleEvt::MainFormDoCommand(  UInt16 command )
          {
           bool handled = false;
           FormType * pForm;
          
           switch (  command ) {
           case MainOptionsAboutStarterApp:
           pForm = FrmInitForm(  AboutForm );
           FrmDoDialog(  pForm ); // Display the About Box.
           FrmDeleteForm(  pForm );
           handled = true;
           break;
           case MainOptionsSelectFileStarterApp:
           pForm = FrmInitForm(  SelectFileForm );
           FrmDoDialog(  pForm ); // Display the Select File Box.
           FrmDeleteForm(  pForm );
           handled = true;
           break;
           case MainOptionsTransferSettingsStarterApp:
           FrmGotoForm(  MainTransferForm );
           handled = true;
           break;
          // pForm = FrmInitForm(  MainTransferForm );
          // FrmGotoForm(  MainTransferForm );
          // FrmDoDialog(  pForm ); // Display the Transfer Video Box.
          // FrmDeleteForm(  pForm );
          // handled = true;
          // break;
          // - removed this feature from the menu
          
           }
          
           return handled;
          }
          
          /***********************************************************************
           *
           * FUNCTION: MainFormHandleEvent
           *
           * DESCRIPTION: This routine is the event handler for the
           * "MainForm" of this application.
           *
           * PARAMETERS: pEvent - a pointer to an EventType structure
           *
           * RETURNED: true if the event has handled and should not be passed
           * to a higher level handler.
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
      71  Boolean AppHandleEvt::MainFormHandleEvent(  EventType* pEvent )
          {
           bool handled = false;
           FormType* pForm;
           NetControls nControl;
          
           switch (  pEvent->eType ) {
           case menuEvent:
           return MainFormDoCommand(  pEvent->data.menu.itemID );
          
           case frmOpenEvent:
           pForm = FrmGetActiveForm(   );
           FrmDrawForm(  pForm );
           handled = true;
           break;
          
           //Here we look at which button was pressed in the mainForm
           //the IDs are defined in AppResources.h
           case ctlSelectEvent:
           switch (  pEvent->data.ctlSelect.controlID )
           {
           case NavigateBackButton:
           break;
          
           case NavigateNextButton:
           break;
          
           case ConnectNetworkButton:
          // WinDrawChars(   "Hello,   world!",   13,   55,   60  );
          // -- used to test that the button is active in the form.
           handled = nControl.TransferFormHandleEvent(  pEvent );
           break;
          
           case TransferVideoButton:
           FrmGotoForm(  MainTransferForm );
           break;
           }
          
           default:
           break;
           }
          
           return handled;
          }
     115  Boolean AppHandleEvt::TransferFormHandleEvent(  EventType* pEvent )
          {
           bool handled = false;
           FormType* pForm;
           NetControls nControl;
          
          
           switch (  pEvent->eType ) {
           //case menuEvent:
           //return MainFormDoCommand(  pEvent->data.menu.itemID );
          
           case frmOpenEvent:
           pForm = FrmGetActiveForm(   );
           FrmDrawForm(  pForm );
           handled = true;
           break;
           case ctlSelectEvent:
           switch (  pEvent->data.ctlSelect.controlID ) {
           case MainSendTCPButton:
           nControl.SendTCP(   );
           handled = true;
           break;
           case MainSendOKButton:
           FrmGotoForm(  MainForm );
           handled = true;
           break;
           default:
           break;
           }
           default:
           break;
           }
           return handled;
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: AppHandleEvent
           *
           * DESCRIPTION: This routine loads form resources and set the event
           * handler for the form loaded.
           *
           * PARAMETERS: event - a pointer to an EventType structure
           *
           * RETURNED: true if the event has handle and should not be passed
           * to a higher level handler.
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
          
     168  Boolean AppHandleEvt::AppHandleEvent(  EventType* pEvent )
          {
           UInt16 formId;
           FormType* pForm;
           bool handled = false;
          
           if (  pEvent->eType == frmLoadEvent ) {
           // Load the form resource.
           formId = pEvent->data.frmLoad.formID;
          
           pForm = FrmInitForm(  formId );
           FrmSetActiveForm(  pForm );
          
           // Set the event handler for the form. The handler of the currently
           // active form is called by FrmHandleEvent each time is receives an
           // event.
           switch (  formId ) {
           case MainForm:
           FrmSetEventHandler(  pForm,   MainFormHandleEvent );
           break;
           case ConnectForm:
          // FrmSetEventHandler(  pForm,   UIControl::ConnectFormHandleEvent );
           break;
           case MainTransferForm:
           FrmSetEventHandler(  pForm,   TransferFormHandleEvent );
           break;
          
           default:
           break;
           }
           handled = true;
           }
          
           return handled;
          }
          
          

AppMain.cpp

       1  /******************************************************************************
           *
           * Palm Interactive Boardroom (  PIB )
           * Handheld presentation tool using a networked projector as a display.
           *
           * This source code is based on default IDE source as well as royalty-free
           * samples provided with the IDE. This file shell was generated by the Palm OS
           * Developer Suite IDE.
           *
           * Other royalty-free source code from HelloNetLib.c (  provided by
           * Palm at www.palmsource.com ) to send TCP and UDP traffic to an IP
           * address + port number was modified significanlty in support of
           * the PIB requirements.
           *
           * Programming environment: Palm OS Developer Suite
           *
           * Created by Scott Armstrong for UIUC CS-427/428,   Group 30
           * based on UML and requirements outlined by Group 30 members.
           *
           * File: AppMain.cpp
           *
           * Notes:
           * - This version is a complete re-write (  tossed theold stuff out )
           * now that we've learned a bit more about PalmOS
           *
           * Version 6.0.1
           * - Each feature,   menu and form should be its own object
           *
           *****************************************************************************/
          #include <PalmOS.h>
          #include "AppResources.h"
          #include "AppHandleEvt.h"
          #include "NetControls.h"
          
          /***********************************************************************
           *
           * Entry Points
           *
           ***********************************************************************/
          
          
          /***********************************************************************
           *
           * Internal Constants
           *
           ***********************************************************************/
          #define appFileCreator 'cPIB' // register your own at http://www.palmos.com/dev/creatorid/
          #define appVersionNum 0x01
          #define appPrefID 0x00
          #define appPrefVersionNum 0x01
          
          /***********************************************************************
           *
           * Internal Functions
           *
           ***********************************************************************/
          
          
          
          
          
          
          /***********************************************************************
           *
           * FUNCTION: AppStart
           *
           * DESCRIPTION: Get the current application's preferences.
           *
           * PARAMETERS: nothing
           *
           * RETURNED: Err value errNone if nothing went wrong
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
      77  static Err AppStart(  void )
          {
           FrmGotoForm(  MainForm );
           return errNone;
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: AppStop
           *
           * DESCRIPTION: Save the current state of the application.
           *
           * PARAMETERS: nothing
           *
           * RETURNED: nothing
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
      98  static void AppStop(  void )
          {
           // Close all the open forms.
           FrmCloseAllForms(   );
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: AppEventLoop
           *
           * DESCRIPTION: This routine is the event loop for the application
           * and is a default function.
           *
           * PARAMETERS: nothing
           *
           * RETURNED: nothing
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
     120  static void AppEventLoop(  void )
          {
           Err error;
           EventType event;
          
           do {
           EvtGetEvent(  &event,   evtWaitForever );
          
           if (  SysHandleEvent(  &event ) )
           continue;
          
           if (  MenuHandleEvent(  0,   &event,   &error ) )
           continue;
          
           if (  AppHandleEvt::AppHandleEvent(  &event ) )
           continue;
          
           FrmDispatchEvent(  &event );
          
           } while (  event.eType != appStopEvent );
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: PilotMain
           *
           * DESCRIPTION: This is the main entry point for the application.
           *
           * PARAMETERS: cmd - word value specifying the launch code.
           * cmdPB - pointer to a structure that is associated with the launch code.
           * launchFlags - word value providing extra information about the launch.
           * RETURNED: Result of launch
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
     158  UInt32 PilotMain(  UInt16 cmd,   MemPtr cmdPBP,   UInt16 launchFlags )
          {
           Err error = errNone;
          
           switch (  cmd ) {
           case sysAppLaunchCmdNormalLaunch:
           if (  (  error = AppStart(   ) ) == 0 ) {
           AppEventLoop(   );
           AppStop(   );
           }
           break;
          
           default:
           break;
           }
          
           return error;
          }
          
          

NetControls.cpp

       1  /******************************************************************************
           *
           * Copyright (  c ) 2003-2004 PalmSource,   Inc. All rights reserved.
           *
           * File: AppMain.c (  Transfer/Project + Connect )
           *
           * Description:
           * This is the main source module for a Palm OS application.
           *
           * This is the initial implementation of Transfer (  based heavily on existing
           * PalmOS code using Net.Lib ).
           *
           * This implementation automatically looks for and initiates the network
           * connection (  the Connect use case ). Future implementations need to have
           * an interactive network configuration and conneciton feature.
           *
           * Version:
           * - Accompanies version 6.0,   demonstrates the functionality that isn't
           * yet integrated into the primary application.
           *
           *****************************************************************************/
          
          #include <PalmOS.h>
          #include "NetControls.h"
          #include "AppResources.h"
          
          /***********************************************************************
           *
           *
           *
           ***********************************************************************/
          
          
          /***********************************************************************
           *
           * Internal Structures
           *
           ***********************************************************************/
          
          typedef struct
          {
           NetIPAddr addr;
           UInt16 port;
          } NetLibPreferenceType;
          
          /***********************************************************************
           *
           * Globals
           *
           ***********************************************************************/
          
          NetLibPreferenceType gPrefs = {};
          const UInt16 bufLen = 16;
          char buf[16] = "testing 1-2\n"; // earlier attempt to localize this
           // character array resulted in compile errors.
          
          /***********************************************************************
           *
           * Internal Constants
           *
           ***********************************************************************/
          
          #define appVersionNum 0x01
          #define appPrefID 0x00
          #define appPrefVersionNum 0x01
          // Define the minimum OS version supported
          #define ourMinVersion sysMakeROMVersion(  3,  0,  0,  sysROMStageRelease,  0 )
          #define kPalmOS10Version sysMakeROMVersion(  1,  0,  0,  sysROMStageRelease,  0 )
          
          #define CLEAR_RESULT -1
          #define PROCESSING_RESULT -2
          
          /***********************************************************************
           *
           * FUNCTION: ShowResult
           *
           * DESCRIPTION: This routine updates the UI to show the results of each
           * of the function calls involved in the current network
           * operation.
           *
           * PARAMETERS: id - ID of the label to update
           * error - error code returned by the corresponding
           * function. If this is -1 the result is cleared
           *
           * RETURNED: none
           *
           ***********************************************************************/
      88  void NetControls::ShowResult(  UInt16 id,   Err error )
          {
           char resultString[11];
           FormType *formPtr;
           UInt16 objIndex;
          
           // Prepare the result as a string
           switch (  error ){
           case CLEAR_RESULT:
           StrCopy(  resultString,   " " );
           break;
           case PROCESSING_RESULT:
           StrCopy(  resultString,   " .... " );
           break;
           default:
           StrPrintF(  resultString,   "0x%04X",   error );
           break;
           }
          
           // Update the specified field label
           formPtr = FrmGetFormPtr(  MainTransferForm );
           objIndex = FrmGetObjectIndex(  formPtr,   id );
           FrmHideObject(  formPtr,   objIndex );
           FrmCopyLabel(  formPtr,   id,   resultString );
           FrmShowObject(  formPtr,   objIndex );
          }
          
          /***********************************************************************
           *
           * FUNCTION: ClearResults
           *
           * DESCRIPTION: This routine clears all the results listed on the main
           * form.
           *
           * PARAMETERS: none
           *
           * RETURNED: none
           *
           ***********************************************************************/
     127  void NetControls::ClearResults(  void )
          {
          // ShowResult(  MainSysLibFindResultLabel,   -1 );
          // ShowResult(  MainNetLibOpenResultLabel,   -1 );
          // ShowResult(  MainNetLibOpenIFResultLabel,   -1 );
          // ShowResult(  MainNetLibSocketOpenResultLabel,   -1 );
          // ShowResult(  MainNetLibSocketConnectResultLabel,   -1 );
          // ShowResult(  MainNetLibSendResultLabel,   -1 );
          // ShowResult(  MainBytesSentResultLabel,   -1 );
          // ShowResult(  MainNetLibSocketCloseResultLabel,   -1 );
          // ShowResult(  MainNetLibCloseResultLabel,   -1 );
          // commented out the ShowResult(  Main....Label,   -1 ) functions
          // to get to functional testing of SendTCP(   )
          
          }
          
          /***********************************************************************
           *
           * FUNCTION: GetValue
           *
           * DESCRIPTION: This routine gets the numeric value of the specified
           * text field.
           *
           * PARAMETERS: objID - ID of the field on the main form
           * valueP - pointer to memory where value is returned
           *
           * RETURNED: True if successful,   false otherwise.
           *
           ***********************************************************************/
     156  Boolean NetControls::GetValue(  UInt16 objID,   Int32 *valueP )
          {
           FormType *formPtr;
           UInt16 objIndex;
           FieldType *fieldPtr;
           Char *text;
          
           formPtr = FrmGetFormPtr(  MainTransferForm );
           if (  !formPtr ) return false;
          
           objIndex = FrmGetObjectIndex(  formPtr,   objID );
           fieldPtr = (  FieldType* )FrmGetObjectPtr(  formPtr,   objIndex );
           if (  !fieldPtr ) return false;
          
           text = FldGetTextPtr(  fieldPtr );
           if (  !text ) return false;
          
           *valueP = StrAToI(  text );
           return true;
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: SetValue
           *
           * DESCRIPTION: This routine sets the numeric value of the specified
           * text field.
           *
           * PARAMETERS: objID - ID of the field on the main form
           * value - the value to insert
           *
           * RETURNED: True if successful,   false otherwise.
           *
           * NOTES: Determines the maximum length to use based upon the ID
           *
           ***********************************************************************/
     193  Boolean NetControls::SetValue(  UInt16 objID,   Int32 value )
          {
           FormType *formPtr;
           UInt16 objIndex;
           FieldType *fieldPtr;
           MemHandle h,   oldHandle;
           Char *text;
          
           formPtr = FrmGetFormPtr(  MainTransferForm );
           if (  !formPtr ) return false;
          
           objIndex = FrmGetObjectIndex(  formPtr,   objID );
           fieldPtr = (  FieldType* )FrmGetObjectPtr(  formPtr,   objIndex );
           if (  !fieldPtr ) return false;
          
           if (  MainPortField == objID ) {
           h = MemHandleNew(  6 );
           } else {
           h = MemHandleNew(  4 );
           }
           if (  !h ) return false;
          
          // text = MemHandleLock(  h );
          // MemHandleLock(   ) returns (  void )
           if (  MainPortField == objID ) {
           StrPrintF(  text,   "%u",   (  UInt16 )value );
           } else {
           StrPrintF(  text,   "%u",   (  UInt8 )value );
           }
           MemHandleUnlock(  h );
           oldHandle = FldGetTextHandle(  fieldPtr );
           FldSetTextHandle(  fieldPtr,   h );
           if (  oldHandle ) MemHandleFree(  oldHandle );
          
           return true;
          }
          
          /***********************************************************************
           *
           * FUNCTION: GetAddr
           *
           * DESCRIPTION: This routine gets the IP address and port that the user
           * has entered.
           *
           * PARAMETERS: AppNetRefnum - Reference number of NetLib
           * addrP - pointer to memory where address is
           * returned
           * portP - pointer to memory where port is
           * returned
           *
           * RETURNED: True if the IP address and port are valid,   false
           * otherwise.
           *
           * NOTES: The only check peformed is to see whether the values
           * are in the appropriate numeric ranges. This doesn't
           * check whether the specified host exists or is listening
           * on the specified port.
           *
           ***********************************************************************/
     252  Boolean NetControls::GetAddr(  UInt16 AppNetRefnum,   NetIPAddr *addrP,   UInt16 *portP )
          {
           UInt8 i;
           Int32 ip[4];
           Int32 port;
           Char textIP[16];
          
           // Get the values
           for (  i = 0; i < 4; i++ ) {
           if (  !GetValue(  MainIP1Field + i,   &(  ip[i] ) ) ||
           ip[i] > 255 ||
           ip[i] < 0 ) {
           return false;
           }
           }
          
           if (  !GetValue(  MainPortField,   &port ) ||
           port > 65535 ||
           port < 1 ) {
           return false;
           }
          
           StrPrintF(  textIP,   "%u.%u.%u.%u",   (  UInt8 )ip[0],   (  UInt8 )ip[1],   (  UInt8 )ip[2],   (  UInt8 )ip[3] );
           *addrP = NetLibAddrAToIN(  AppNetRefnum,   textIP );
           *portP = (  UInt16 )port;
           return true;
          }
          
          /**********************************************************************
           * FUNCTION: EstablishConnection
           *
           * Different approach to sendTCP,   first we will establish a socketed
           * connection,   then we will send data once we have this confirmed.
           * *******************************************************************/
     286   void NetControls::EstablishConnection(  void )
           {
           Err error;
           UInt16 AppNetRefnum;
           error = SysLibFind(  "Net.lib",   &AppNetRefnum ); //find library
          
           //GetAddr(  AppNetRefnum,   &gPrefs.addr,   &gPrefs.port );
           if (  !GetAddr(  AppNetRefnum,   &gPrefs.addr,   &gPrefs.port ) ) {
           FrmAlert(  InvalidDestAlert );
           return;
           }
          
           }
          /***********************************************************************
           *
           * FUNCTION: SendTCP
           *
           * DESCRIPTION: This routine uses NetLib to send TCP data. You should
           * change destAddr.addr and destAddr.port to point to a
           * useful destination.
           *
           * PARAMETERS: none
           *
           * RETURNED: none
           *
           ***********************************************************************/
     312  void NetControls::SendTCP(  void )
          {
           Err error;
           UInt16 AppNetRefnum;
           UInt16 ifErrs;
           NetSocketRef socket;
           Int16 result;
           NetSocketAddrINType destAddr;
          // const UInt16 bufLen = 15; // using global variables for now
          // char buf[bufLen] = "xxxxxx\n"; // will need to substitute a file
           // wrapped for TCP/IP to be received
           // and used as a video signal
           UInt16 sentBytes = 0;
          
           ClearResults(   );
          
           // Find the network library and start tne network connection (  Connect function )
           ShowResult(  MainSysLibFindResultLabel,   PROCESSING_RESULT );
           error = SysLibFind(  "Net.lib",   &AppNetRefnum );
           ShowResult(  MainSysLibFindResultLabel,   error );
           if (  error ) return;
          
           // Get and validate the destination
           if (  !GetAddr(  AppNetRefnum,   &gPrefs.addr,   &gPrefs.port ) ) {
           FrmAlert(  InvalidDestAlert );
           return;
           }
          
           // Open the network library
           ShowResult(  MainNetLibOpenResultLabel,   PROCESSING_RESULT );
           ShowResult(  MainNetLibOpenIFResultLabel,   PROCESSING_RESULT );
           error = NetLibOpen(  AppNetRefnum,   &ifErrs );
           ShowResult(  MainNetLibOpenResultLabel,   error );
           ShowResult(  MainNetLibOpenIFResultLabel,   ifErrs );
           if (  ifErrs || (  error && error != netErrAlreadyOpen ) ) goto CloseNetLib;
          
           // Open a socket
           ShowResult(  MainNetLibSocketOpenResultLabel,   PROCESSING_RESULT );
           socket = NetLibSocketOpen(  AppNetRefnum,   // Network library
           netSocketAddrINET,   // Address domain
           netSocketTypeStream,   // Socket type
           netSocketProtoIPTCP,   // Protocol
           -1,   // Timeout
           &error // Error result
            );
           ShowResult(  MainNetLibSocketOpenResultLabel,   error );
           if (  error ) goto CloseNetLib;
          
           // Connect the socket to its destination
           MemSet(  &destAddr,   sizeof(  destAddr ),   0 );
           destAddr.family = netSocketAddrINET; // This should match the second argument to NetLibSocketOpen
           destAddr.port = gPrefs.port;
           destAddr.addr = gPrefs.addr;
           error = 0;
           ShowResult(  MainNetLibSocketConnectResultLabel,   PROCESSING_RESULT );
           result = NetLibSocketConnect(  AppNetRefnum,   // Network library
           socket,   // Socket reference
           (  NetSocketAddrType* )&destAddr,   // Destination address
           sizeof(  destAddr ),   // Length of destAddr
           -1,   // Timeout
           &error // Error result
            );
           if (  result == -1 ) {
           ShowResult(  MainNetLibSocketConnectResultLabel,   error );
           goto CloseSocket;
           } else {
           ShowResult(  MainNetLibSocketConnectResultLabel,   0 );
           }
          
           // Send data
           ShowResult(  MainBytesSentResultLabel,   PROCESSING_RESULT );
           while (  sentBytes < bufLen ) {
           ShowResult(  MainNetLibSendResultLabel,   PROCESSING_RESULT );
           result = NetLibSend (  AppNetRefnum,   // Network library
           socket,   // Socket reference
           buf + sentBytes,   // Buffer to send
           bufLen - sentBytes,   // Bytes to send from buffer
           0,   // Flags
           NULL,   // Destination address -- does not apply to TCP sockets
           0,   // Length of destination address
           -1,   // Timeout
           &error // Error result
            );
           if (  result == -1 ) {
           ShowResult(  MainNetLibSendResultLabel,   error );
           goto CloseSocket;
           }
           sentBytes += result;
           ShowResult(  MainBytesSentResultLabel,   sentBytes );
           }
           ShowResult(  MainNetLibSendResultLabel,   0 );
          
           // Close the socket
           CloseSocket:
           ShowResult(  MainNetLibSocketCloseResultLabel,   PROCESSING_RESULT );
           result = NetLibSocketClose (  AppNetRefnum,   // Network Library
           socket,   // Socket reference
           -1,   // Timeout
           &error // Error result
            );
           if (  result == -1 ) {
           ShowResult(  MainNetLibSocketCloseResultLabel,   error );
           } else {
           ShowResult(  MainNetLibSocketCloseResultLabel,   0 );
           }
          
           // Close the network library
           CloseNetLib:
           ShowResult(  MainNetLibCloseResultLabel,   PROCESSING_RESULT );
           error = NetLibClose(  AppNetRefnum,   false );
           ShowResult(  MainNetLibCloseResultLabel,   error );
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: RomVersionCompatible
           *
           * DESCRIPTION: This routine checks that a ROM version is meet your
           * minimum requirement. Older versions of PalmOS didn't
           * network well.
           *
           * PARAMETERS: requiredVersion - minimum rom version required
           * (  see sysFtrNumROMVersion in SystemMgr.h
           * for format )
           * launchFlags - flags that indicate if the application
           * UI is initialized.
           *
           * RETURNED: error code or zero if rom is compatible
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
     446  Err NetControls::RomVersionCompatible(  UInt32 requiredVersion,   UInt16 launchFlags )
          {
           UInt32 romVersion;
          
           // See if we're on in minimum required version of the ROM or later.
           FtrGet(  sysFtrCreator,   sysFtrNumROMVersion,   &romVersion );
           if (  romVersion < requiredVersion ) {
           if (  (  launchFlags & (  sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp ) ) ==
           (  sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp ) ) {
           FrmAlert (  RomIncompatibleAlert );
          
           // Palm OS 1.0 will continuously relaunch this app unless we switch to
           // another safe one.
           if (  romVersion <= kPalmOS10Version ) {
           AppLaunchWithCommand(  sysFileCDefaultApp,   sysAppLaunchCmdNormalLaunch,   NULL );
           }
           }
          
           return sysErrRomIncompatible;
           }
          
           return errNone;
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: GetObjectPtr
           *
           * DESCRIPTION: This routine returns a pointer to an object in the current
           * form.
           *
           * PARAMETERS: formId - id of the form to display
           *
           * RETURNED: void *
           *
           * REVISION HISTORY:
           * - V3.0,   3.1,   3.2 - not currently used,   but will be in future
           * iterations.
           *
           *
           ***********************************************************************/
          //static void * GetObjectPtr(  UInt16 objectID )
          //{
          // FormPtr frmP;
          
          // frmP = FrmGetActiveForm(   );
          // return FrmGetObjectPtr(  frmP,   FrmGetObjectIndex(  frmP,   objectID ) );
          //}
          
          
          /***********************************************************************
           *
           * FUNCTION: MainFormInit
           *
           * DESCRIPTION: This routine initializes the MainForm form.
           *
           * PARAMETERS: frm - pointer to the MainForm form.
           *
           * RETURNED: nothing
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
     511  void NetControls::MainFormInit(  FormPtr frmP ) // uncommented frmp
          {
           ClearResults(   );
          }
          
          
          /***********************************************************************
           *
           * FUNCTION: MainFormDoCommand
           *
           * DESCRIPTION: This routine performs the menu command specified.
           *
           * PARAMETERS: command - menu item id
           *
           * RETURNED: nothing
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
          //static Boolean MainFormDoCommand(  UInt16 command )
          //{
          // Boolean handled = false;
          // FormPtr frmP;
          
          // switch (  command ) {
          // case MainOptionsAboutNetLib:
          // MenuEraseStatus(  0 ); // Clear the menu status from the display.
          // frmP = FrmInitForm (  AboutForm );
          // FrmDoDialog (  frmP ); // Display the About Box.
          // FrmDeleteForm (  frmP );
          // handled = true;
          // break;
          
          // }
          
          // return handled;
          //}
          
          
          /***********************************************************************
           *
           * FUNCTION: TransferFormHandleEvent
           *
           * DESCRIPTION: This routine is the event handler for the
           * "TransferForm" of this application.
           *
           * PARAMETERS: eventP - a pointer to an EventType structure
           *
           * RETURNED: true if the event has handle and should not be passed
           * to a higher level handler.
           *
           * REVISION HISTORY:
           *
           *
           ***********************************************************************/
     567  Boolean NetControls::TransferFormHandleEvent(  EventPtr eventP )
          {
           Boolean handled = false;
           FormPtr frmP;
          
           switch (  eventP->eType ) {
          // case menuEvent:
          // return MainFormDoCommand(  eventP->data.menu.itemID );
          // - commented out to get to the SendTCP feature
          // - we may not need this feature on that form
          
           case frmOpenEvent:
           frmP = FrmGetActiveForm(   );
           MainFormInit(   frmP );
          
           // Load initial values from prefs
           SetValue(  MainIP1Field,   (  gPrefs.addr & 0xFF000000 ) >> 24 );
           SetValue(  MainIP2Field,   (  gPrefs.addr & 0x00FF0000 ) >> 16 );
           SetValue(  MainIP3Field,   (  gPrefs.addr & 0x0000FF00 ) >> 8 );
           SetValue(  MainIP4Field,   gPrefs.addr & 0x000000FF );
           SetValue(  MainPortField,   gPrefs.port );
          
           FrmDrawForm (  frmP );
           handled = true;
           break;
          
           case frmUpdateEvent:
           break;
          
           case ctlSelectEvent:
           switch (  eventP->data.ctlSelect.controlID ) {
           case MainSendTCPButton:
           SendTCP(   );
           break;
          // case MainSendUDPButton:
          // SendUDP(   );
          // break;
           default:
           break;
           }
           break;
          
           default:
           break;
           }
          
           return handled;