home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / wrlapija.zip / TryWindow.java < prev   
Text File  |  2002-05-31  |  37KB  |  816 lines

  1. import com.IBM.WirelessClient.API.*;
  2. import javax.swing.*;
  3. import javax.swing.event.*;
  4. import java.awt.*;
  5. import java.io.*;
  6. import java.util.*;
  7. import java.awt.event.*;
  8.  
  9. public class TryWindow extends JFrame implements eWirelessAPIListener, WindowListener, ActionListener
  10. {
  11.  
  12.     protected String rcStrings[] = 
  13.      { "eOK",
  14.      "eOperationPending",
  15.      "eErrFailed",
  16.      "eErrMemoryFailure",
  17.      "eErrInvalidParameter",
  18.      "eErrQueueAlreadyRegistered",
  19.      "eErrForcePasswordChange",
  20.      "eErrCoreNotStarted",
  21.      "eErrNotInitialized",
  22.      "eErrNotSupported",
  23.      "eErrModemInitFailed",
  24.      "eErrCommPort",
  25.      "eErrTooManyInterfaces",
  26.      "eErrInvalidConfiguration",
  27.      "eErrBadState",
  28.      "eErrNdisNotConfigured",
  29.      "eErrNoActiveInterface",
  30.      "eErrTimeout",
  31.      "eErrPassword",
  32.      "eErrProtocol",
  33.      "eErrAuthorizationRequired",
  34.      "eErrGatewayDown",
  35.      "eErrAccountDeleted",
  36.      "eErrAccountUnknown",
  37.      "eErrAlreadyConnected",
  38.      "eErrOperator",
  39.      "eErrVersion",
  40.      "eErrAccountLocked",
  41.      "eErrAccountExpired",
  42.      "eErrInvalidNewPassword",
  43.      "eErrInitUnknown",
  44.      "eErrModemConnectFailed",
  45.      "eErrAddressNotAvailable",
  46.      "eErrAddressInUse",
  47.      "eErrDestinationInvalid",
  48.      "eErrBufferTooSmall"};
  49.  
  50.  
  51.  
  52.     protected eWirelessAPI api;
  53.     protected eInterfaceHandle hInterface;
  54.     Vector hInterfaces;
  55.     protected String displayString;
  56.     //The window object
  57.     static JFrame aWindow;
  58.  
  59.     JScrollPane logevents;
  60. JTextArea logging;
  61. JTextField cName;
  62. JButton conButton,startButton,stopButton;
  63. public JMenuBar menuBar = new JMenuBar();   //Window menu bar
  64.  
  65. public JMenuItem dConnectMenuItem,getActIntMenuItem,getAllIntMenuItem,getConIntMenuItem,getNetCapMenuItem,getNetStatMenuItem,getStatMenuItem,getNetSpecMenuItem,resetStatMenuItem,
  66.                  getSigStrengthMenuItem,getSigQualityMenuItem,shutdownMenuItem,battStrengthMenuItem,resumeMenuItem,suspendMenuItem,disableMenuItem,enableMenuItem,battModeMenuItem,
  67.                  sendMenuItem,getIntNamesMenuItem,getConNamesMenuItem, rfModemStatusMenuItem, rfModemStatisticsMenuItem;
  68. JMenu tcMenu,intMenu,sigMenu,infoMenu,battMenu,nameMenu;
  69. JTextField enName,enBattName,enActIntName;
  70. JPasswordField passwd,changePasswd;
  71. eInterfaceHandle newInterfaceHandle = new eInterfaceHandle(-1);
  72.  
  73.     public TryWindow()
  74.     {
  75.         super();
  76.         initFrame();
  77.         api = new eWirelessAPI();
  78.         hInterface = new eInterfaceHandle(-1);
  79.         api.addeWirelessAPIListener(this);
  80.  
  81.         displayString = "";
  82.  
  83.     }
  84.  
  85.     public static void main(String[] args){
  86.         TryWindow  tests = new TryWindow();
  87.  
  88.     }
  89.  
  90.     //Other Testcases menu items
  91.                      
  92.  
  93.     public void initFrame()
  94.     {
  95.         aWindow = new JFrame();
  96.         aWindow.setTitle("Java API Test for Wireless Client 5.1.2");
  97.         aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  98.  
  99.         aWindow.setJMenuBar(menuBar);
  100.  
  101.         tcMenu = new JMenu("Other Testcases");
  102.  
  103.         //Construct the "Other Testcases" pull down menu
  104.         dConnectMenuItem = tcMenu.add("Disconnect");
  105.         dConnectMenuItem.addActionListener(this);
  106.         tcMenu.addSeparator();
  107.  
  108.         intMenu = new JMenu("Interfaces");
  109.         tcMenu.add(intMenu);       //Add the Interfaces sub-menu
  110.         getActIntMenuItem = tcMenu.add("Active Interface");
  111.         getActIntMenuItem.addActionListener(this);
  112.         getAllIntMenuItem = tcMenu.add("All Interface Handles");
  113.         getAllIntMenuItem.addActionListener(this);
  114.         intMenu.add(getActIntMenuItem);
  115.         intMenu.add(getAllIntMenuItem);
  116.  
  117.         nameMenu = new JMenu("Names");
  118.         tcMenu.add(nameMenu);       //Add the Names sub-menu
  119.         getConNamesMenuItem = tcMenu.add("Configured Connections");
  120.         getConNamesMenuItem.addActionListener(this);
  121.         getIntNamesMenuItem = tcMenu.add("Configured Interfaces");
  122.         getIntNamesMenuItem.addActionListener(this);
  123.         nameMenu.add(getConNamesMenuItem);
  124.         nameMenu.add(getIntNamesMenuItem);
  125.  
  126.  
  127.  
  128.         sigMenu = new JMenu("Signal");
  129.         tcMenu.add(sigMenu);       //Add the Interfaces sub-menu
  130.         getSigStrengthMenuItem = tcMenu.add("Signal Strength");
  131.         getSigStrengthMenuItem.addActionListener(this);
  132.         getSigQualityMenuItem = tcMenu.add("Signal Quality");
  133.         getSigQualityMenuItem.addActionListener(this);
  134.         sigMenu.add(getSigStrengthMenuItem);
  135.         sigMenu.add(getSigQualityMenuItem);
  136.  
  137.  
  138.         infoMenu = new JMenu("Network Information");
  139.         tcMenu.add(infoMenu);    //Add the Information sub-menu
  140.   
  141.         getConIntMenuItem = tcMenu.add("Connection Info");
  142.         getConIntMenuItem.addActionListener(this);
  143.         getNetSpecMenuItem = tcMenu.add("Network Specific");
  144.         getNetSpecMenuItem.addActionListener(this);
  145.         getStatMenuItem = tcMenu.add("Statistics");
  146.         getStatMenuItem.addActionListener(this);
  147.         getNetCapMenuItem = tcMenu.add("Network Capabilities");
  148.         getNetCapMenuItem.addActionListener(this);
  149.         getNetStatMenuItem = tcMenu.add("Network Status");
  150.         getNetStatMenuItem.addActionListener(this);
  151.         infoMenu.add(getConIntMenuItem);
  152.         infoMenu.add(getNetSpecMenuItem);
  153.         infoMenu.add(getStatMenuItem);
  154.         infoMenu.add(getNetCapMenuItem);
  155.         infoMenu.add(getNetStatMenuItem);
  156.   
  157.         battMenu = new JMenu("Battery Information");
  158.         tcMenu.add(battMenu);  //Add the Battery Info sub-menu
  159.         battStrengthMenuItem = tcMenu.add("Battery Strength");
  160.         battStrengthMenuItem.addActionListener(this);
  161.         battModeMenuItem = tcMenu.add("Battery Mode");
  162.         battModeMenuItem.addActionListener(this);
  163.         battMenu.add(battStrengthMenuItem);
  164.         battMenu.add(battModeMenuItem);
  165.   
  166.  
  167.         tcMenu.addSeparator();
  168.         enableMenuItem = tcMenu.add("Enable Transmitter");
  169.         enableMenuItem.addActionListener(this);
  170.         disableMenuItem = tcMenu.add("Disable Transmitter");
  171.         disableMenuItem.addActionListener(this);
  172.         suspendMenuItem = tcMenu.add("Suspend Interface");
  173.         suspendMenuItem.addActionListener(this);
  174.         resumeMenuItem = tcMenu.add("Resume Interface");
  175.         resumeMenuItem.addActionListener(this);
  176.         sendMenuItem = tcMenu.add("Send Redial Message");
  177.         sendMenuItem.addActionListener(this);
  178.         resetStatMenuItem = tcMenu.add("Reset Statistics");
  179.         resetStatMenuItem.addActionListener(this);
  180.         tcMenu.addSeparator();
  181.         
  182.         rfModemStatusMenuItem = tcMenu.add("Get RF Modem Status");
  183.         rfModemStatusMenuItem.addActionListener( this);
  184.         rfModemStatisticsMenuItem = tcMenu.add("Get RF Modem Statistics");
  185.         rfModemStatisticsMenuItem.addActionListener( this);
  186.  
  187.         tcMenu.addSeparator();
  188.         shutdownMenuItem = tcMenu.add("Shutdown");
  189.         shutdownMenuItem.addActionListener(this);
  190.  
  191.  
  192.  
  193.  
  194.         menuBar.add(tcMenu);     //Add the "other testcases" menu
  195.         
  196.  
  197.  
  198.         Toolkit theKit = aWindow.getToolkit();  //Get the window toolkit
  199.         Dimension wndSize = theKit.getScreenSize(); //Get screen size
  200.  
  201.         //Set the position to screen center & size to 2/3 screen size
  202.         aWindow.setBounds(wndSize.width/6, wndSize.height/6,  //Position
  203.                           2*wndSize.width/3, 2*wndSize.height/3); //Size
  204.         aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  205.         aWindow.getContentPane().setLayout(new BorderLayout()); 
  206.         JPanel panel1 = new JPanel();
  207.         panel1.setLayout(new GridLayout(3,0,10,10));
  208.  
  209.         JLabel uName = new JLabel("Username");
  210.         JLabel pWord = new JLabel("Password");
  211.         JLabel conName = new JLabel("Connection Definition Name");
  212.         enName = new JTextField();
  213.         passwd = new JPasswordField();
  214.         cName = new JTextField();
  215.         cName.addActionListener(this);
  216.         conButton = new JButton("Connect");
  217.         conButton.addActionListener(this);
  218.         startButton = new JButton("Logon");
  219.         startButton.addActionListener(this);
  220.         stopButton = new JButton("Logoff");
  221.         stopButton.addActionListener(this);
  222.         panel1.add(conName);
  223.         panel1.add(uName);
  224.         panel1.add(pWord);
  225.         panel1.add(cName);
  226.         panel1.add(enName);
  227.         panel1.add(passwd);
  228.         panel1.add(conButton);
  229.         panel1.add(startButton);
  230.         panel1.add(stopButton);
  231.      //   panel1.setBackground(Color.pink);
  232.         aWindow.getContentPane().add(panel1, BorderLayout.NORTH);
  233.  
  234.         JPanel panel2 = new JPanel();
  235.         panel2.setLayout(new GridLayout(2,0));
  236.      //   panel2.setBackground(Color.pink);
  237.         JLabel theEvents = new JLabel("API Events");
  238.         logging = new JTextArea(15,3);
  239.         logging.setText("");
  240.         logevents = new JScrollPane(logging);
  241.         panel2.add(theEvents);
  242.         panel2.add(logevents);
  243.         aWindow.getContentPane().add(panel2, BorderLayout.CENTER);
  244.         JPanel panel3 = new JPanel();
  245.         panel3.setLayout(new GridLayout(2,0,5,5));
  246.  
  247.         JLabel actInt = new JLabel("Set Active Interface");
  248.         JLabel changePword = new JLabel("Change Password");
  249.         JLabel setBattMode = new JLabel("Set Battery Mode");
  250.         enActIntName = new JTextField();
  251.         enActIntName.addActionListener(this);
  252.         changePasswd = new JPasswordField();
  253.         changePasswd.addActionListener(this);
  254.         enBattName = new JTextField();
  255.         enBattName.addActionListener(this);
  256.         panel3.add(actInt);
  257.         panel3.add(changePword);
  258.         panel3.add(setBattMode);
  259.         panel3.add(enActIntName);
  260.         panel3.add(changePasswd);
  261.         panel3.add(enBattName);
  262.  
  263.         aWindow.getContentPane().add(panel3, BorderLayout.SOUTH);
  264.         aWindow.addWindowListener(this);
  265.         aWindow.setVisible(true);         //Display the window
  266.     }
  267.  
  268.  
  269.     public void actionPerformed(ActionEvent evt)
  270.     {
  271.         //handle events here
  272.         Object src = evt.getSource();
  273.         if (src == conButton) {
  274.             if (api == null)
  275.                 { 
  276.                     api = new eWirelessAPI();
  277.                     hInterface = new eInterfaceHandle(-1);
  278.                     api.addeWirelessAPIListener(this);
  279.                 }
  280.  
  281.             int rc = api.eOpenInterface(cName.getText(),"",hInterface);
  282.             logging.append(" rc = eOpenInterface() = "+ rcStrings[rc]+"\r\n");
  283.         }
  284.         if (src == startButton) {
  285.             String thePassword = new String(passwd.getPassword());
  286.             Vector connections = new Vector();
  287.             api.eGetConnectionNames(connections);
  288.             String[] a = new String[connections.size()];
  289.             connections.copyInto(a);
  290.             //this logon assumes the first name returned from eGetConnectionNames is the currentConnection
  291.             int rc = api.eLogon(a[0],enName.getText(),thePassword,"");
  292.             logging.append(" rc = eLogon() = " + rcStrings[rc] + "\r\n");
  293.         }
  294.         if (src == stopButton) {
  295.             int rc = api.eLogoff();
  296.             logging.append(" rc = eLogoff() = " + rcStrings[rc] + "\r\n");
  297.         }
  298.         if (src == enableMenuItem) {
  299.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  300.             api.eGetActiveInterface(currentInterface);
  301.             int rc = api.eEnableTransmitter(currentInterface);
  302.             logging.append(" rc = eEnableTransmitter() = " + rcStrings[rc]
  303.                 + "\r\n");
  304.         }
  305.         if (src == disableMenuItem) {
  306.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  307.             api.eGetActiveInterface(currentInterface);
  308.             int rc = api.eDisableTransmitter(currentInterface);
  309.             logging.append(" rc = eDisableTransmitter() = " + rcStrings[rc]
  310.                 + "\r\n");
  311.         }
  312.         if (src == resumeMenuItem) {
  313.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  314.             api.eGetActiveInterface(currentInterface);
  315.             int rc = api.eResumeInterface(currentInterface);
  316.             logging.append(" rc = eResumeInterface() = " + rcStrings[rc]
  317.                 + "\r\n");
  318.         }
  319.         if (src == sendMenuItem) {
  320.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  321.             api.eGetActiveInterface(currentInterface);
  322.             int rc = api.eSendRedialMessage(currentInterface);
  323.             logging.append(" rc = eSendRedialMessage() = " + rcStrings[rc]
  324.                 + "\r\n");
  325.         }
  326.         if (src == resetStatMenuItem) {
  327.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  328.             api.eGetActiveInterface(currentInterface);
  329.             int rc = api.eResetStatistics(currentInterface);
  330.             logging.append( " rc = eResetStatistics() = " + rcStrings[rc]
  331.                 + "\r\n");
  332.         }
  333.         if (src == rfModemStatusMenuItem) {
  334.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  335.             api.eGetActiveInterface(currentInterface);
  336.             int rc = api.eGetRFModemStatus(currentInterface);
  337.             logging.append(" rc = eGetRFModemStatus() = " + rcStrings[rc]
  338.                 + "\r\n");
  339.         }
  340.         if (src == rfModemStatisticsMenuItem) {
  341.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  342.             api.eGetActiveInterface(currentInterface);
  343.             int rc = api.eGetRFModemStatistics(currentInterface);
  344.             logging.append( " rc = eRFGetModemStatistics() = " + rcStrings[rc]
  345.                 + "\r\n");
  346.         }
  347.         if (src == shutdownMenuItem) {
  348.             int rc = api.eShutdown();
  349.             logging.append(" rc = eShutdown() = " + rcStrings[rc]
  350.                 + "\r\n");
  351.             try {
  352.                 FileOutputStream file = new FileOutputStream("apptrace.txt");
  353.                 byte[] log = displayString.getBytes();
  354.                 for (int i = 0; i < log.length; i++) {
  355.                     file.write(log[i]);
  356.                 }
  357.                 file.close();
  358.             } catch (IOException e){
  359.                 System.out.println("Error writing log info to file " + e.toString());
  360.             }
  361.             
  362.             // tsr - force clean up 
  363.             api.removeeWirelessAPIListener(this);
  364.             api = null;
  365.             System.gc();
  366.  
  367.         }
  368.         if (src == getSigQualityMenuItem) {
  369.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  370.             api.eGetActiveInterface(currentInterface);
  371.             int rc = api.eGetSignalQuality(currentInterface);
  372.             logging.append(" rc = eGetSignalQuality() = " + rcStrings[rc]
  373.                 + "\r\n");
  374.         }
  375.         if (src == getSigStrengthMenuItem) {
  376.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  377.             api.eGetActiveInterface(currentInterface);
  378.             int rc = api.eGetSignalStrength(currentInterface);
  379.             logging.append(" rc = eGetSignalStrength() = "+ rcStrings[rc]
  380.                 + "\r\n");
  381.         }
  382.         if (src == battStrengthMenuItem) {
  383.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  384.             api.eGetActiveInterface(currentInterface);
  385.             int rc = api.eGetBatteryStrength(currentInterface);
  386.             logging.append(" rc = eGetBatteryStrength() = " + rcStrings[rc]
  387.                 + "\r\n");
  388.         }
  389.         if (src == battModeMenuItem) {
  390.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  391.             api.eGetActiveInterface(currentInterface);
  392.             int rc = api.eGetBatteryMode(currentInterface);
  393.             logging.append( " rc = eGetBatteryMode() = " + rcStrings[rc]
  394.                 + "\r\n");
  395.         }
  396.         if (src == getConIntMenuItem) {
  397.             int rc = api.eGetConnectionInfo();
  398.             logging.append(" rc = eGetConnectionInfo() = " + rcStrings[rc] 
  399.                 + "\r\n");
  400.         }
  401.         if (src == getNetSpecMenuItem) {
  402.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  403.             api.eGetActiveInterface(currentInterface);
  404.             int rc = api.eGetNetworkSpecific(currentInterface);
  405.             logging.append( " rc = eGetNetworkSpecific() = " + rcStrings[rc]
  406.                 + "\r\n");
  407.         }
  408.         if (src == getStatMenuItem) {
  409.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  410.             api.eGetActiveInterface(currentInterface);
  411.             eStats stats = new eStats(); 
  412.             int rc = api.eGetStatistics(currentInterface, stats);
  413.             logging.append( " rc = eGetStatistics() = " + rcStrings[rc] 
  414.                 + "\r\n" + "bytes sent:  " + String.valueOf(stats.getBytes_sent()) 
  415.                 + " bytes received:  " + String.valueOf(stats.getBytes_received())
  416.                 + " packets sent:  " + String.valueOf(stats.getPkts_sent())
  417.                 + " packets received:  " + String.valueOf(stats.getPkts_received())
  418.                 + " reserved1:  " + String.valueOf(stats.getReserved1())
  419.                 + " connect time:  " + String.valueOf(stats.getConnectTime())
  420.                 + "\r\n");
  421.         }
  422.         if (src == enActIntName) {
  423.             api.eOpenInterface(enActIntName.getText(),"",hInterface);
  424.             int rc = api.eSetActiveInterface(hInterface);
  425.             logging.append(" rc = eSetActiveInterface() = " + rcStrings[rc]
  426.                 + "\r\n");
  427.         }
  428.         if (src == enBattName) {
  429.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  430.             api.eGetActiveInterface(currentInterface);
  431.             int rc = api.eSetBatteryMode(currentInterface, Integer.parseInt(enBattName.getText()) );
  432.             logging.append(" rc = eSetBatteryMode() = " 
  433.                 + rcStrings[rc] + "\r\n");
  434.         }
  435.         if (src == getNetCapMenuItem) {
  436.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  437.             api.eGetActiveInterface(currentInterface);
  438.             int rc = api.eGetNetworkCapabilities(currentInterface);
  439.             logging.append(" rc = eGetNetworkCapabilities() = "
  440.                 + rcStrings[rc] + "\r\n");
  441.         }
  442.         if (src == getNetStatMenuItem) {
  443.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  444.             api.eGetActiveInterface(currentInterface);
  445.             int rc = api.eGetNetworkStatus(currentInterface);
  446.             logging.append( " rc = eGetNetworkStatus() = " + rcStrings[rc]
  447.                 + "\r\n");
  448.         }
  449.         if (src == changePasswd) {
  450.             String oldPassword = new String(passwd.getPassword());
  451.             String newPassword = new String(changePasswd.getPassword());
  452.             int rc = api.eChangePassword(oldPassword,newPassword);
  453.             logging.append( " rc = eChangePassword("+oldPassword+","+newPassword+") = " + rcStrings[rc] + "\r\n");
  454.         }
  455.         if (src == dConnectMenuItem) {
  456.             //you can only disconnect the active interface
  457.             eInterfaceHandle theActiveOne = new eInterfaceHandle(-1);
  458.             api.eGetActiveInterface(theActiveOne);
  459.             int rc = api.eCloseInterface(theActiveOne);
  460.             logging.append(" rc = eCloseInterface() = " + rcStrings[rc]
  461.                             +"\r\n"); 
  462.         }                                         
  463.         if (src == getConNamesMenuItem) {
  464.             Vector names = new Vector();
  465.             int rc = api.eGetConnectionNames(names);
  466.             String[] a = new String[names.size()];
  467.             names.copyInto(a);
  468.             String conNames = "";
  469.             for (int j =0; j<a.length;j++) {
  470.                   conNames = conNames  + a[j] + " ";
  471.             }
  472.             logging.append( " rc = eGetConnectionNames() = " + rcStrings[rc]
  473.                             + " Connection Names: " + conNames + " Size of Vector:  " + names.size()+"\r\n");
  474.         }
  475.         if (src == getIntNamesMenuItem) {
  476.             Vector connections = new Vector();
  477.             api.eGetConnectionNames(connections);
  478.             String[] a = new String[connections.size()];
  479.             connections.copyInto(a);
  480.             Vector names = new Vector();
  481.             String tmpString = new String("");
  482.             for (int i = 0; i < a.length; i++){
  483.                 int rc = api.eGetInterfaceNames(a[i], names);  
  484.                 String[] b = new String[names.size()];
  485.                 names.copyInto(b);
  486.                 String seeNames = " ";
  487.                 for (int j = 0; j< b.length; j++)
  488.                    seeNames = seeNames + b[j] + " ";
  489.                 tmpString += " rc = eGetInterfaceNames("+a[i]+", ) = " + rcStrings[rc]
  490.                          + " Interface Names:  " + seeNames + " Size of vector:"  
  491.                          + names.size() +"\r\n";
  492.                 names.clear();
  493.             }
  494.             logging.append(tmpString);
  495.         }
  496.         if (src == getActIntMenuItem) {
  497.             int rc = api.eGetActiveInterface(hInterface);
  498.             logging.append( " rc = eGetActiveInterface() = " + rcStrings[rc]
  499.                             + " Interface handle:  " + hInterface.getInterfaceHandle() 
  500.                             + "\r\n");
  501.         }
  502.         if (src == suspendMenuItem) {
  503.             eInterfaceHandle currentInterface = new eInterfaceHandle(-1);
  504.             api.eGetActiveInterface(currentInterface);
  505.             int rc = api.eSuspendInterface(currentInterface);
  506.             logging.append( " rc = eSuspendInterface() = " + rcStrings[rc] + "\r\n");
  507.         }
  508.         if (src == getAllIntMenuItem) {
  509.             Vector interfaceHandles = new Vector();
  510.             int rc = api.eGetAllInterfaceHandles(interfaceHandles);
  511.             eInterfaceHandle[] a = new eInterfaceHandle[interfaceHandles.size()];
  512.             interfaceHandles.copyInto(a);
  513.             String handles = "";
  514.             for (int j =0; j<a.length;j++) {
  515.                   handles = handles  + a[j].getInterfaceHandle() + " ";
  516.             }
  517.             logging.append(" rc = eGetAllInterfaceHandles() = " + rcStrings[rc]
  518.                             + " Interface handle: " + handles + "Size of Vector:  " + interfaceHandles.size()+"\r\n");
  519.         }
  520.     }
  521.  
  522.     public void windowClosing(WindowEvent e)
  523.     {
  524.         aWindow.removeWindowListener(this);
  525.         aWindow.dispose();
  526.         System.exit(0);
  527.     }
  528.  
  529.     //Listener interface functions we must implement - but don't need
  530.     public void windowOpened(WindowEvent e){
  531.     }
  532.     public void windowClosed(WindowEvent e){
  533.     }
  534.     public void windowIconified(WindowEvent e){
  535.     }
  536.     public void windowDeiconified(WindowEvent e){
  537.     }
  538.     public void windowActivated(WindowEvent e){
  539.     }
  540.     public void windowDeactivated(WindowEvent e){
  541.     }
  542.  
  543.     // wireless api listener interface
  544.     public void eMsg_AdapterInitialized( eInterfaceHandle theInterfaceHandle, String theInterfaceName)
  545.     {
  546.         String rcString = "event eMsg_AdapterInitialized rcvd for " +
  547.                                   "interface " + theInterfaceName + 
  548.                                   "and InterfaceHandle " + theInterfaceHandle.getInterfaceHandle() +"\r\n";
  549.             logging.append(rcString);
  550.     }
  551.     
  552.     public void eMsg_AdapterResetInProgress( eInterfaceHandle theInterfaceHandle)
  553.     {
  554.         String rcString = "event eMsg_AdapterResetInProgress rcvd" + "\r\n";
  555.             logging.append(rcString);
  556.     }
  557.     
  558.     public void eMsg_BatteryMode( eInterfaceHandle theInterfaceHandle, int theReturnCode, int theBatteryMode)
  559.     {
  560.         String rcString = "event eMsg_BatteryMode rcvd, rc = " + rcStrings[theReturnCode] + ", batterymode = " + String.valueOf( theBatteryMode) +  "\r\n";
  561.             logging.append(rcString);
  562.        }    
  563.     
  564.     public void eMsg_BatteryStrength(eInterfaceHandle theInterfaceHandle, int theReturnCode,    
  565.                                         int theNormalizedStrength, int theRawStrength)
  566.     {
  567.         String rcString = "event eMsg_BatteryStrength rcvd, rc = " + rcStrings[theReturnCode] + ", normalized strength = " + String.valueOf( theNormalizedStrength) +  ", raw strength = " + String.valueOf( theRawStrength) + "\r\n";
  568.             logging.append(rcString);
  569.         }    
  570.     
  571.     public void eMsg_ChangePassword( int theReturnCode)
  572.     {
  573.         String rcString = "event eMsg_ChangePassword rcvd, rc = " + rcStrings[theReturnCode] +  "\r\n";
  574.             logging.append(rcString);
  575.         }     
  576.     
  577.     public void eMsg_CloseInterface( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  578.     {
  579.         String rcString = "event eMsg_CloseInterface rcvd, rc = " + rcStrings[theReturnCode] +  "\r\n";
  580.             logging.append(rcString);
  581.     }    
  582.     
  583.     public void eMsg_ConnectionInfo( eInterfaceHandle theInterfaceHandle, int theReturnCode, 
  584.                                         eConnectionInfo theConnectionInfo)
  585.     {
  586.         String statusStrings[] = { "LOGGED_OFF", "LOGGING_ON", "LOGGED_ON", "LOGGING_OFF" };
  587.         String rcString = "event eMsg_ConnectionInfo rcvd, rc = " + rcStrings[theReturnCode] + ", gw ipaddr = " + theConnectionInfo.getGateway_ipaddr() + ", local ipaddr = " + theConnectionInfo.getLocal_ipaddr() + ", status = " + statusStrings[theConnectionInfo.getStatus()] + "\r\n";
  588.             logging.append(rcString);
  589.     }    
  590.             
  591.     public void eMsg_DisableTransmitter( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  592.     {
  593.         String rcString = "event eMsg_DisableTransmitter rcvd, rc =" + rcStrings[theReturnCode] +  "\r\n";
  594.             logging.append(rcString);
  595.     }    
  596.     
  597.     public void eMsg_EnableTransmitter( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  598.     {
  599.         String rcString = "event eMsg_EnableTransmitter rcvd, rc = " + rcStrings[theReturnCode] +  "\r\n";
  600.             logging.append(rcString);
  601.     }    
  602.     
  603.     public void eMsg_HardwareEvent( eInterfaceHandle theInterfaceHandle, int theEventID)
  604.     {
  605.         String rcString = "event eMsg_HardwareEvent rcvd, theEventID = " + String.valueOf( theEventID) +  "\r\n";
  606.             logging.append(rcString);
  607.     }    
  608.     
  609.     public void eMsg_Logoff( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  610.     {
  611.         String rcString = "event eMsg_Logoff rcvd, rc = " + rcStrings[theReturnCode] +  "\r\n";
  612.             logging.append(rcString);
  613.     }    
  614.     
  615.     public void eMsg_Logon( eInterfaceHandle theInterfaceHandle, int theReturnCode, String theConnectionConfigName)
  616.     {
  617.         String rcString = "event eMsg_Logon rcvd, rc = " + rcStrings[theReturnCode] +  ", connectionname = " + theConnectionConfigName + "\r\n";
  618.             logging.append(rcString);
  619.     }    
  620.     
  621.     public void eMsg_NetworkCapabilities( eInterfaceHandle theInterfaceHandle, int theReturnCode, 
  622.                                             eNetworkCapabilities theNetworkCapabilities)
  623.     {
  624.         String rcString = "event eMsg_NetworkCapabilities rcvd, rc = " + rcStrings[theReturnCode] + ", capabilitiesflag = " + String.valueOf( theNetworkCapabilities.getCapabilities()) + ", averagebps = " + String.valueOf( theNetworkCapabilities.getAverageBPS()) + ", mtusize = " + String.valueOf( theNetworkCapabilities.getMtuSize() + "\r\n");
  625.             logging.append(rcString);
  626.     }    
  627.         
  628.     public void eMsg_NetworkCongested( eInterfaceHandle theInterfaceHandle)
  629.     {
  630.         String rcString = "event eMsg_NetworkCongested rcvd " + "\r\n";
  631.             logging.append(rcString);
  632.     }    
  633.         
  634.     public void eMsg_NetworkInRange( eInterfaceHandle theInterfaceHandle)
  635.     {
  636.         String rcString = "event eMsg_NetworkInRange rcvd " + "\r\n";
  637.             logging.append(rcString);
  638.     }    
  639.     
  640.     public void eMsg_NetworkMessage( eInterfaceHandle theInterfaceHandle, String theNetworkMessage)
  641.     {
  642.         String rcString = "event eMsg_NetworkMessage rcvd, " + " nwmessage = " + theNetworkMessage + "\r\n";
  643.             logging.append(rcString);
  644.     }    
  645.     
  646.     public void eMsg_NetworkNoLongerCongested( eInterfaceHandle theInterfaceHandle)
  647.     {
  648.         String rcString = "event eMsg_NetworkNoLongerCongested rcvd " + "\r\n";
  649.             logging.append(rcString);
  650.     }    
  651.     
  652.     public void eMsg_NetworkOutOfRange( eInterfaceHandle theInterfaceHandle)
  653.     {
  654.         String rcString = "event eMsg_NetworkOutOfRange rcvd " + "\r\n";
  655.             logging.append(rcString);
  656.     }    
  657.     
  658.     public void eMsg_NetworkSpecific( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  659.                                     int theNetworkCapabilities,
  660.                                     String theNetworkSpecificMessage)
  661.     {
  662.         String rcString = "event eMsg_NetworkSpecific rcvd,  rc = " + rcStrings[theReturnCode] +  ", nwcapabilitiesflag = " + String.valueOf( theNetworkCapabilities) + ", thenwspecificmsg = " + theNetworkSpecificMessage + "\r\n";
  663.             logging.append(rcString);
  664.     }    
  665.     
  666.     public void eMsg_NetworkStatus( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  667.                                     eNetworkStatus theNetworkStatus)
  668.     {
  669.         String rcString = "event eMsg_NetworkStatus rcvd,  rc = " + rcStrings[theReturnCode] +  ", iscongested = " + String.valueOf( theNetworkStatus.isCongested()) + ", isoutofrange = " + String.valueOf( theNetworkStatus.isOutOfRange()) + ", issuspended = " + String.valueOf( theNetworkStatus.isSuspended()) + ", istransmitter disabled = "  + String.valueOf( theNetworkStatus.isTransmitterDisabled()) + "\r\n";
  670.             logging.append(rcString);
  671.     }    
  672.     
  673.     public void eMsg_OpenInterface( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  674.                         int theNetworkSpecificRC, String theInterfaceName)
  675.     {
  676.                 String rcString = "event eMsg_OpenInterface rcvd, Interface Handle = " + theInterfaceHandle.getInterfaceHandle() + ",rc = " + rcStrings[theReturnCode] +  ", Network Specific Return Code = " + String.valueOf( theNetworkSpecificRC) + ", interfacename = " + theInterfaceName + "\r\n";
  677.             logging.append(rcString);
  678.     }    
  679.     
  680.     public void eMsg_PacketReceived( eInterfaceHandle theInterfaceHandle, int thePacketSize)
  681.     {
  682.         String rcString = "event eMsg_PacketReceived rcvd, packetsize = " + String.valueOf( thePacketSize) +  "\r\n";
  683.             logging.append(rcString);
  684.     }    
  685.     
  686.     public void eMsg_PacketReceiveFailed( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  687.     {
  688.         String rcString = "event eMsg_PacketReceiveFailed rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  689.             logging.append(rcString);
  690.     }    
  691.     
  692.     public void eMsg_PacketTransmitFailed( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  693.     {
  694.         String rcString = "event eMsg_PacketTransmitFailed rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  695.             logging.append(rcString);
  696.     }    
  697.     
  698.     public void eMsg_PacketTransmitted( eInterfaceHandle theInterfaceHandle, int thePacketSize)
  699.     {
  700.         String rcString = "event eMsg_PacketTransmitted rcvd, packetsize = " + String.valueOf( thePacketSize) +  "\r\n";
  701.             logging.append(rcString);
  702.     }    
  703.     
  704.     public void eMsg_RedialAttempt( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  705.     {
  706.         String rcString = "event eMsg_RedialAttempt rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  707.             logging.append(rcString);
  708.     }    
  709.     
  710.     public void eMsg_ResumeInterface( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  711.     {
  712.         String rcString = "event eMsg_ResumeInterface rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  713.             logging.append(rcString);
  714.     }    
  715.     
  716.     public void eMsg_SetActiveInterface( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  717.                         eInterfaceHandle theNewActiveInterface, eInterfaceHandle theOldActiveInterface)
  718.     {
  719.                 hInterface = theInterfaceHandle;
  720.         String rcString = "event eMsg_SetActiveInterface rcvd, rc = " + rcStrings[theReturnCode] + " the Interface Handle:  " + theInterfaceHandle.getInterfaceHandle() + ", new Active Interface: " + theNewActiveInterface.getInterfaceHandle() + ", old Active Interface: " + theOldActiveInterface.getInterfaceHandle() +"\r\n";
  721.             logging.append(rcString);
  722.     }    
  723.     
  724.     public void eMsg_Shutdown( )
  725.     {
  726.         String rcString = "event eMsg_Shutdown rcvd " + "\r\n";
  727.             logging.append(rcString);
  728. }    
  729.     
  730.     public void eMsg_SignalQuality( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  731.                             int theNormalizedQuality, int theRawQuality)
  732.     {
  733.         String rcString = "event eMsg_SignalQuality rcvd, rc = " + rcStrings[theReturnCode] + ", normalized = " + String.valueOf( theNormalizedQuality) +  ", raw = " + String.valueOf( theRawQuality) + "\r\n";
  734.             logging.append(rcString);
  735.     }    
  736.     
  737.     public void eMsg_SignalStrength ( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  738.                             int theNormalizedStrength, int theRawStrength)
  739.     {
  740.         String rcString = "event eMsg_SignalStrength rcvd, rc = " + rcStrings[theReturnCode] + ", normalized = " + String.valueOf( theNormalizedStrength) +  ", raw = " + String.valueOf( theRawStrength) + "\r\n";
  741.             logging.append(rcString);
  742.     }    
  743.     
  744.     public void eMsg_SuspendInterface( eInterfaceHandle theInterfaceHandle, int theReturnCode)
  745.     {
  746.         String rcString = "event eMsg_SuspendInterface rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  747.             logging.append(rcString);
  748.     }        
  749.  
  750.         public void eMsg_Logon(int theReturnCode, String theConnectionConfigName)
  751.         {
  752.             String rcString = "event eMsg_Logon rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  753.             logging.append(rcString);
  754.         }
  755.  
  756.         public void eMsg_Logoff(int theReturnCode)
  757.         {
  758.             String rcString = "event eMsg_Logoff rcvd, rc = " + rcStrings[theReturnCode] + "\r\n";
  759.             logging.append(rcString);
  760.         }
  761.  
  762.         public void eMsg_PacketTransmitFailed(eInterfaceHandle hInterface, int one, int two)
  763.         {
  764.             logging.append("eMsg_PacketTransmitFailed"  + "\r\n");
  765.         }
  766.  
  767.     public void eMsg_NotifyTray(eInterfaceHandle hInterface, int one)
  768.         {
  769.             logging.append("eMsg_NotifyTray" + "\r\n");
  770.         }
  771.  
  772.     public void eMsg_ConnectionInfo(int one, eConnectionInfo two)
  773.         {
  774.             logging.append("eMsg_ConnectionInfo" + "\r\n");
  775.         }
  776.     
  777.     public void eMsg_RadiusAuthentication(eInterfaceHandle hInterface, int one)
  778.     {
  779.         logging.append("eMsg_RadiusAuthentication" + "\r\n");
  780.     }
  781.  
  782.     public void eMsg_PacketReceiveFailed(eInterfaceHandle hInterface, int one, int two)
  783.     {
  784.         logging.append("eMsg_PacketReceiveFailed" + "\r\n");
  785.     }
  786.  
  787.     public void eMsg_NetworkAdapters( eInterfaceHandle theInterfaceHandle, int theReturnCode,
  788.                                     eNetworkAdapters theNetworkAdapters)
  789.     {
  790.         String rcString = "event eMsg_NetworkAdapters rcvd,  rc = " + rcStrings[theReturnCode] + " ActiveAdapter is " + theNetworkAdapters.getAdapterName(theNetworkAdapters.getIndexOfActive()) + "\r\n";
  791.         logging.append(rcString);
  792.     }
  793.     public void eMsg_RFModemStatus( eInterfaceHandle theInterfaceHandle, int theReturnCode, eRFModemStatus theRFModemStatus)
  794.     {
  795.         String rcString = "event eMsg_RFModemStatus rcvd,  rc = " + rcStrings[theReturnCode]  + "\r\n";
  796.         rcString = rcString + "      range = " + theRFModemStatus.Range() + ", " + ((theRFModemStatus.Range() == theRFModemStatus.eIN_RANGE) ? "eIN_RANGE" : "eOUT_OF_RANGE") + "\r\n";
  797.         rcString = rcString + "      transmitter = " + theRFModemStatus.Transmitter() + ", " + ((theRFModemStatus.Transmitter() == theRFModemStatus.eDISABLED) ? "eDISABLED" : "eENABLED") + "\r\n";
  798.         rcString = rcString + "      receiver = " + theRFModemStatus.Receiver() + ", " + ((theRFModemStatus.Receiver() == theRFModemStatus.eDISABLED) ? "eDISABLED" : "eENABLED") + "\r\n";
  799.         rcString = rcString + "      antenna = " + theRFModemStatus.Antenna() + "\r\n";
  800.         rcString = rcString + "      flowControl = " + theRFModemStatus.FlowControl() + ", " + ((theRFModemStatus.FlowControl() == theRFModemStatus.eNONE) ? "eNONE" : ((theRFModemStatus.FlowControl() == theRFModemStatus.eXONXOFF) ? "eXONXOFF" : "eRTSCTS")) + "\r\n";
  801.         rcString = rcString + "      receivemode = " + theRFModemStatus.ReceiveMode() + ", " + ((theRFModemStatus.ReceiveMode() == theRFModemStatus.eCONFIRMED) ? "eCONFIRMED" : "eUNCONFIRMED") + "\r\n";
  802.         rcString = rcString + "      basestationid = " + theRFModemStatus.BaseStationID() + "\r\n";
  803.         rcString = rcString + "      rxquality = " + theRFModemStatus.RxQuality() + "\r\n";
  804.         rcString = rcString + "      modemstate = " + theRFModemStatus.ModemState() + "\r\n";
  805.         rcString = rcString + "      queuetobesent = " + theRFModemStatus.QueuedToBeSent() + "\r\n";
  806.         rcString = rcString + "      queuetobereceived = " + theRFModemStatus.QueuedToBeReceived() + "\r\n";
  807.         rcString = rcString + "      radiochannel = " + theRFModemStatus.RadioChannel() + "\r\n";
  808.         logging.append( rcString);
  809.     }
  810.     public void eMsg_RFModemStatistics( eInterfaceHandle theInterfaceHandle, int theReturnCode, eRFModemStatistics theRFModemStatistics)
  811.     {
  812.         String rcString = "event eMsg_RFModemStatistics rcvd,  rc = " + rcStrings[theReturnCode]  + "\r\n";
  813.         logging.append( rcString);
  814.     }
  815. }
  816.