Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r483 committed - Re-architect class layout

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r483 committed - Re-architect class layout


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r483 committed - Re-architect class layout
  • Date: Wed, 10 Aug 2011 20:59:31 +0000

Revision: 483
Author:

Date: Wed Aug 10 13:58:17 2011
Log: Re-architect class layout
http://code.google.com/p/ndt/source/detail?r=483

Added:
/branches/kkumar_code_organize/Applet/Message.java
/branches/kkumar_code_organize/Applet/Protocol.java
/branches/kkumar_code_organize/Applet/ResultsTextPane.java
/branches/kkumar_code_organize/Applet/StatusPanel.java
/branches/kkumar_code_organize/Applet/UserAgentTools.java
Modified:
/branches/kkumar_code_organize/Applet/NDTConstants.java
/branches/kkumar_code_organize/Applet/Tcpbw100.java

=======================================
--- /dev/null
+++ /branches/kkumar_code_organize/Applet/Message.java Wed Aug 10 13:58:17 2011
@@ -0,0 +1,15 @@
+/* Class to define Message.
+ * Messages are composed of a "type" and a body
+ * Some examples of message types are : COMM_FAILURE, SRV_QUEUE, MSG_LOGIN, TEST_PREPARE etc
+ * @see MessageType.java for more examples
+ * TODO: NDTP messages are defined to have a "length" field in wiki. Not defined here. Why?
+ * Looks like all of the tests (MID, SFW, C2S, s2c, META are using this message type..so,
+ * no specific "mesage type" which does not contain length exists
+ * TODO: Is it a good idea to merge MessageTypes into this class?
+ *
+ */
+public class Message {
+
+ byte type;
+ byte[] body;
+}
=======================================
--- /dev/null
+++ /branches/kkumar_code_organize/Applet/Protocol.java Wed Aug 10 13:58:17 2011
@@ -0,0 +1,80 @@
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+/* Class to define Protocol
+ * TODO :summarize methods below to give a brief explanation of the Protocol class
+ * */
+
+
+public class Protocol {
+ private InputStream _ctlin;
+ private OutputStream _ctlout;
+
+ public Protocol(Socket ctlSocket) throws IOException
+ {
+ _ctlin = ctlSocket.getInputStream();
+ _ctlout = ctlSocket.getOutputStream();
+ }
+
+ public void send_msg(byte type, byte toSend) throws IOException
+ {
+ byte[] tab = new byte[] { toSend };
+ send_msg(type, tab);
+ }
+
+ public void send_msg(byte type, byte[] tab) throws IOException
+ {
+ byte[] header = new byte[3];
+ header[0] = type;
+ header[1] = (byte) (tab.length >> 8);
+ header[2] = (byte) tab.length;
+
+ _ctlout.write(header);
+ _ctlout.write(tab);
+ }
+
+ public int readn(Message msg, int amount) throws IOException
+ {
+ int read = 0;
+ int tmp;
+ msg.body = new byte[amount];
+ while (read != amount) {
+ tmp = _ctlin.read(msg.body, read, amount - read);
+ if (tmp <= 0) {
+ return read;
+ }
+ read += tmp;
+ }
+ return read;
+ }
+
+ public int recv_msg(Message msg) throws IOException
+ {
+ int length;
+ if (readn(msg, 3) != 3) {
+ return 1;
+ }
+ msg.type = msg.body[0];
+ length = ((int) msg.body[1] & 0xFF) << 8;
+ length += (int) msg.body[2] & 0xFF;
+ if (readn(msg, length) != length) {
+ return 3;
+ }
+ return 0;
+ }
+
+ public void close()
+ {
+ try {
+ _ctlin.close();
+ _ctlout.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
=======================================
--- /dev/null
+++ /branches/kkumar_code_organize/Applet/ResultsTextPane.java Wed Aug 10 13:58:17 2011
@@ -0,0 +1,38 @@
+import java.awt.Component;
+
+import javax.swing.JTextPane;
+import javax.swing.text.BadLocationException;
+
+/*Class used to extend textPane to be used to display results
+ * of tests
+ */
+public class ResultsTextPane extends JTextPane
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void append(String text)
+ {
+ try {
+ getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
+ }
+ catch (BadLocationException e) {
+ System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
+ }
+ }
+
+ public void insertComponent(Component c)
+ {
+ /*
+ setSelectionStart(results.getStyledDocument().getLength());
+ setSelectionEnd(results.getStyledDocument().getLength());
+ */
+ //change "results" to "this". re-arch
+ setSelectionStart(this.getStyledDocument().getLength());
+ setSelectionEnd(this.getStyledDocument().getLength());
+ super.insertComponent(c);
+ }
+}
+
=======================================
--- /dev/null
+++ /branches/kkumar_code_organize/Applet/StatusPanel.java Wed Aug 10 13:58:17 2011
@@ -0,0 +1,96 @@
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+
+/* Class that displays status of tests being run Status
+ * TODO: Can this be named better? */
+
+public class StatusPanel extends JPanel
+{
+ private int _testNo;
+ private int _testsNum;
+ private boolean _stop = false;
+
+ private JLabel testNoLabel = new JLabel();
+ private JButton stopButton;
+ private JProgressBar progressBar = new JProgressBar();
+
+ /* Constructor
+ * @param testsNum Total number of tests scheduled to be run
+ * @param sParamaEnableMultiple Are multiple tests scheduled?*/
+ StatusPanel(int testsNum, String sParamEnableMultiple) {
+ this._testNo = 1;
+ this._testsNum = testsNum;
+
+ setTestNoLabelText();
+ //re-arch
+ //If multiple tests are enabled to be run, then add
information about the
+ //test number being run
+ if ( sParamEnableMultiple != null) {
+ add(testNoLabel);
+ }
+ /*
+ if ( getParameter("enableMultipleTests") != null ) {
+ add(testNoLabel);
+ }*/
+ progressBar.setMinimum(0);
+ progressBar.setMaximum(_testsNum);
+ progressBar.setValue(0);
+ progressBar.setStringPainted(true);
+ if (_testsNum == 0) {
+ progressBar.setString("");
+ progressBar.setIndeterminate(true);
+ }
+ else {
+
progressBar.setString(NDTConstants.getMessageString("initialization"));
+ }
+ add(progressBar);
+ stopButton= new
JButton(NDTConstants.getMessageString("stop"));
+ stopButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ _stop = true;
+ stopButton.setEnabled(false);
+
StatusPanel.this.setText(NDTConstants.getMessageString("stopping"));
+ }
+
+ });
+ /*
+ if ( getParameter("enableMultipleTests") != null ) {
+ add(stopButton);
+ }*/
+ //If multiple tests are enabled to be run, provide user
option to
+ // stop the one currently running
+ if (sParamEnableMultiple != null) {
+ add(stopButton);
+ }
+ }
+
+ /*Set Test number being run*/
+ private void setTestNoLabelText() {
+ testNoLabel.setText(NDTConstants.getMessageString("test") + " " + _testNo + " " + NDTConstants.getMessageString("of") + " " +_testsNum);
+ }
+
+ /*record intention to stop tests */
+ public boolean wantToStop() {
+ return _stop;
+ }
+
+ /*end the currently runnig test */
+ public void endTest() {
+ progressBar.setValue(_testNo);
+ _testNo++;
+ setTestNoLabelText();
+ }
+
+ /* Set progress text */
+ public void setText(String text) {
+ if (!progressBar.isIndeterminate()) {
+ progressBar.setString(text);
+ }
+ }
+} //end class StatusPanel
=======================================
--- /dev/null
+++ /branches/kkumar_code_organize/Applet/UserAgentTools.java Wed Aug 10 13:58:17 2011
@@ -0,0 +1,412 @@
+/* This class has
+* code taken from http://nerds.palmdrive.net/useragent/code.html
+*
+* It has been move out and made into a non-static , outer class that can be replaced more quickly, if need be
+* TODO: this comment may be removed
+*/
+//private static class UserAgentTools {
+public class UserAgentTools {
+
+ public static String getFirstVersionNumber(String a_userAgent, int a_position, int numDigits) {
+ String ver = getVersionNumber(a_userAgent, a_position);
+ if (ver==null) return "";
+ int i = 0;
+ String res="";
+ while (i<ver.length() && i<numDigits) {
+ res+=String.valueOf(ver.charAt(i));
+ i++;
+ }
+ return res;
+ }
+ public static String getVersionNumber(String a_userAgent, int a_position) {
+ if (a_position<0) return "";
+ StringBuffer res = new StringBuffer();
+ int status = 0;
+
+ while (a_position < a_userAgent.length()) {
+ char c = a_userAgent.charAt(a_position);
+ switch (status) {
+ case 0: //<SPAN class="codecomment"> No valid digits encountered yet</span>
+ if (c == ' ' || c=='/') break;
+ if (c == ';' || c==')') return "";
+ status = 1;
+ case 1: //<SPAN class="codecomment"> Version number in
progress</span>
+ if (c == ';' || c=='/' || c==')' || c=='(' || c=='[') return res.toString().trim();
+ if (c == ' ') status = 2;
+ res.append(c);
+ break;
+ case 2: //<SPAN class="codecomment"> Space encountered - Might need to end the parsing</span>
+ if ((Character.isLetter(c) &&
+ Character.isLowerCase(c)) ||
+ Character.isDigit(c)) {
+ res.append(c);
+ status=1;
+ } else
+ return res.toString().trim();
+ break;
+ }
+ a_position++;
+ }
+ return res.toString().trim();
+ }
+
+ public static String[]getArray(String a, String b, String c) {
+ String[]res = new String[3];
+ res[0]=a;
+ res[1]=b;
+ res[2]=c;
+ return res;
+ }
+
+ public static String[] getBotName(String userAgent) {
+ userAgent = userAgent.toLowerCase();
+ int pos=0;
+ String res=null;
+ if ((pos=userAgent.indexOf("help.yahoo.com/"))>-1) {
+ res= "Yahoo";
+ pos+=7;
+ } else
+ if ((pos=userAgent.indexOf("google/"))>-1) {
+ res= "Google";
+ pos+=7;
+ } else
+ if ((pos=userAgent.indexOf("msnbot/"))>-1) {
+ res= "MSNBot";
+ pos+=7;
+ } else
+ if
((pos=userAgent.indexOf("googlebot/"))>-1) {
+ res= "Google";
+ pos+=10;
+ } else
+ if
((pos=userAgent.indexOf("webcrawler/"))>-1) {
+ res= "WebCrawler";
+ pos+=11;
+ } else
+ //<SPAN class="codecomment"> The following two bots don't have any version number in their User-Agent strings.</span>
+ if
((pos=userAgent.indexOf("inktomi"))>-1) {
+ res=
"Inktomi";
+ pos=-1;
+ } else
+ if
((pos=userAgent.indexOf("teoma"))>-1) {
+ res=
"Teoma";
+
pos=-1;
+ }
+ if (res==null) return null;
+ return getArray(res,res,res +
getVersionNumber(userAgent,pos));
+ }
+
+
+ public static String[] getOS(String userAgent) {
+ if (getBotName(userAgent)!=null) return
getArray("Bot","Bot","Bot");
+ String[]res = null;
+ int pos;
+ if ((pos=userAgent.indexOf("Windows-NT"))>-1) {
+ res =
getArray("Win","WinNT","Win"+getVersionNumber(userAgent,pos+8));
+ } else
+ if (userAgent.indexOf("Windows NT")>-1) {
+ //<SPAN class="codecomment"> The different versions of Windows NT are decoded in the verbosity level 2</span>
+ //<SPAN class="codecomment"> ie: Windows NT 5.1 =
Windows XP</span>
+ if ((pos=userAgent.indexOf("Windows NT
5.1"))>-1) {
+ res =
getArray("Win","WinXP","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if ((pos=userAgent.indexOf("Windows NT
6.0"))>-1) {
+ res = getArray("Win","Vista","Vista"+getVersionNumber(userAgent,pos+7));
+ } else
+ if ((pos=userAgent.indexOf("Windows
NT 6.1"))>-1) {
+ res = getArray("Win","Seven","Seven "+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows NT 5.0"))>-1) {
+ res = getArray("Win","Win2000","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows NT 5.2"))>-1) {
+ res = getArray("Win","Win2003","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows NT 4.0"))>-1) {
+ res = getArray("Win","WinNT4","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows NT)"))>-1) {
+ res =
getArray("Win","WinNT","WinNT");
+
} else
+ if
((pos=userAgent.indexOf("Windows NT;"))>-1) {
+ res =
getArray("Win","WinNT","WinNT");
+
} else
+ res =
getArray("Win","WinNT?","WinNT?");
+ } else
+ if (userAgent.indexOf("Win")>-1) {
+ if (userAgent.indexOf("Windows")>-1) {
+ if ((pos=userAgent.indexOf("Windows
98"))>-1) {
+ res = getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows_98"))>-1) {
+ res = getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+8));
+ } else
+ if
((pos=userAgent.indexOf("Windows 2000"))>-1) {
+ res = getArray("Win","Win2000","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows 95"))>-1) {
+ res = getArray("Win","Win95","Win"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Windows 9x"))>-1) {
+ res = getArray("Win","Win9x","Win"+getVersionNumber(userAgent,pos+7));
+
} else
+ if
((pos=userAgent.indexOf("Windows ME"))>-1) {
+ res = getArray("Win","WinME","Win"+getVersionNumber(userAgent,pos+7));
+
} else
+
if ((pos=userAgent.indexOf("Windows CE;"))>-1) {
+ res
= getArray("Win","WinCE","WinCE");
+
} else
+
if ((pos=userAgent.indexOf("Windows 3.1"))>-1) {
+ res = getArray("Win","Win31","Win"+getVersionNumber(userAgent,pos+7));
+
}
+ //<SPAN class="codecomment"> If no version was found, rely on the following code to detect "WinXX"</span>
+ //<SPAN class="codecomment"> As some User-Agents include two references to Windows</span>
+ //<SPAN class="codecomment"> Ex: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5)</span>
+ }
+ if (res == null) {
+ if
((pos=userAgent.indexOf("Win98"))>-1) {
+ res = getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+3));
+ } else
+ if
((pos=userAgent.indexOf("Win31"))>-1) {
+ res = getArray("Win","Win31","Win"+getVersionNumber(userAgent,pos+3));
+ } else
+ if
((pos=userAgent.indexOf("Win95"))>-1) {
+ res = getArray("Win","Win95","Win"+getVersionNumber(userAgent,pos+3));
+ } else
+ if
((pos=userAgent.indexOf("Win 9x"))>-1) {
+ res = getArray("Win","Win9x","Win"+getVersionNumber(userAgent,pos+3));
+ } else
+ if
((pos=userAgent.indexOf("WinNT4.0"))>-1) {
+ res = getArray("Win","WinNT4","Win"+getVersionNumber(userAgent,pos+3));
+
} else
+ if
((pos=userAgent.indexOf("WinNT"))>-1) {
+ res = getArray("Win","WinNT","Win"+getVersionNumber(userAgent,pos+3));
+
}
+ }
+ if (res == null) {
+ if
((pos=userAgent.indexOf("Windows"))>-1) {
+ res = getArray("Win","Win?","Win?"+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("Win"))>-1) {
+ res = getArray("Win","Win?","Win?"+getVersionNumber(userAgent,pos+3));
+ } else
+ //<SPAN
class="codecomment"> Should not happen at this point</span>
+ res =
getArray("Win","Win?","Win?");
+ }
+ } else
+ if ((pos=userAgent.indexOf("Mac OS
X"))>-1) {
+ if
((userAgent.indexOf("iPhone"))>-1) {
+ pos =
userAgent.indexOf("iPhone OS");
+ if
((userAgent.indexOf("iPod"))>-1) {
+ res = getArray("iOS","iOS-iPod","iOS-iPod "+((pos<0)?"":getVersionNumber(userAgent,pos+9)));
+ } else {
+ res = getArray("iOS","iOS-iPhone","iOS-iPhone "+((pos<0)?"":getVersionNumber(userAgent,pos+9)));
+ }
+ } else
+ if
((userAgent.indexOf("iPad"))>-1) {
+ pos =
userAgent.indexOf("CPU OS");
+ res = getArray("iOS","iOS-iPad","iOS-iPad "+((pos<0)?"":getVersionNumber(userAgent,pos+6)));
+ } else
+ res = getArray("Mac","MacOSX","MacOS "+getVersionNumber(userAgent,pos+8));
+ } else
+ if
((pos=userAgent.indexOf("Android"))>-1) {
+ res = getArray("Linux","Android","Android "+getVersionNumber(userAgent,pos+8));
+ } else
+ if
((pos=userAgent.indexOf("Mac_PowerPC"))>-1) {
+ res = getArray("Mac","MacPPC","MacOS "+getVersionNumber(userAgent,pos+3));
+ } else
+ if
((pos=userAgent.indexOf("Macintosh"))>-1) {
+ if
(userAgent.indexOf("PPC")>-1)
+ res =
getArray("Mac","MacPPC","Mac PPC");
+ else
+ res =
getArray("Mac?","Mac?","MacOS?");
+ } else
+ if
((pos=userAgent.indexOf("FreeBSD"))>-1) {
+ res = getArray("*BSD","*BSD FreeBSD","FreeBSD "+getVersionNumber(userAgent,pos+7));
+ } else
+ if
((pos=userAgent.indexOf("OpenBSD"))>-1) {
+ res = getArray("*BSD","*BSD OpenBSD","OpenBSD "+getVersionNumber(userAgent,pos+7));
+
} else
+ if
((pos=userAgent.indexOf("Linux"))>-1) {
+
String detail = "Linux "+getVersionNumber(userAgent,pos+5);
+
String med = "Linux";
+
if ((pos=userAgent.indexOf("Ubuntu/"))>-1) {
+
detail = "Ubuntu "+getVersionNumber(userAgent,pos+7);
+
med+=" Ubuntu";
+
}
+
res = getArray("Linux",med,detail);
+
} else
+
if ((pos=userAgent.indexOf("CentOS"))>-1) {
+ res
= getArray("Linux","Linux CentOS","CentOS");
+
} else
+
if ((pos=userAgent.indexOf("NetBSD"))>-1) {
+ res = getArray("*BSD","*BSD NetBSD","NetBSD "+getVersionNumber(userAgent,pos+6));
+
} else
+
if ((pos=userAgent.indexOf("Unix"))>-1) {
+ res = getArray("Linux","Linux","Linux "+getVersionNumber(userAgent,pos+4));
+
} else
+
if ((pos=userAgent.indexOf("SunOS"))>-1) {
+ res = getArray("Unix","SunOS","SunOS"+getVersionNumber(userAgent,pos+5));
+
} else
+
if ((pos=userAgent.indexOf("IRIX"))>-1) {
+ res = getArray("Unix","IRIX","IRIX"+getVersionNumber(userAgent,pos+4));
+
} else
+
if
((pos=userAgent.indexOf("SonyEricsson"))>-1) {
+ res = getArray("SonyEricsson","SonyEricsson","SonyEricsson"+getVersionNumber(userAgent,pos+12));
+
} else
+
if
((pos=userAgent.indexOf("Nokia"))>-1) {
+ res = getArray("Nokia","Nokia","Nokia"+getVersionNumber(userAgent,pos+5));
+
} else
+
if
((pos=userAgent.indexOf("BlackBerry"))>-1) {
+ res = getArray("BlackBerry","BlackBerry","BlackBerry"+getVersionNumber(userAgent,pos+10));
+
}
else
+
if
((pos=userAgent.indexOf("SymbianOS"))>-1) {
+ res = getArray("SymbianOS","SymbianOS","SymbianOS"+getVersionNumber(userAgent,pos+10));
+

} else
+
if
((pos=userAgent.indexOf("BeOS"))>-1) {
+
res =
getArray("BeOS","BeOS","BeOS");
+

} else
+
if
((pos=userAgent.indexOf("Nintendo Wii"))>-1) {
+ res = getArray("Nintendo Wii","Nintendo Wii","Nintendo Wii"+getVersionNumber(userAgent,pos+10));
+

} else
+

if ((pos=userAgent.indexOf("J2ME/MIDP"))>-1) {
+
res =
getArray("Java","J2ME","J2ME/MIDP");
+

} else
+
res =
getArray("?","?","?");
+ return res;
+ }
+
+
+ public static String []getBrowser(String userAgent) {
+ if (userAgent == null) {
+ return getArray("?","?","?");
+ }
+ String []botName;
+ if ((botName=getBotName(userAgent))!=null) return botName;
+ String[]res = null;
+ int pos;
+ if ((pos=userAgent.indexOf("Lotus-Notes/"))>-1) {
+ res = getArray("LotusNotes","LotusNotes","LotusNotes"+getVersionNumber(userAgent,pos+12));
+ } else
+ if ((pos=userAgent.indexOf("Opera"))>-1) {
+ String ver =
getVersionNumber(userAgent,pos+5);
+ res = getArray("Opera","Opera"+getFirstVersionNumber(userAgent,pos+5,1),"Opera"+ver);
+ if ((pos=userAgent.indexOf("Opera
Mini/"))>-1) {
+ String ver2 =
getVersionNumber(userAgent,pos+11);
+ res = getArray("Opera","Opera Mini","Opera
Mini "+ver2);
+ } else
+ if ((pos=userAgent.indexOf("Opera
Mobi/"))>-1) {
+ String ver2 =
getVersionNumber(userAgent,pos+11);
+ res = getArray("Opera","Opera
Mobi","Opera Mobi "+ver2);
+ }
+ } else
+ if (userAgent.indexOf("MSIE")>-1) {
+ if ((pos=userAgent.indexOf("MSIE
6.0"))>-1) {
+ res = getArray("MSIE","MSIE6","MSIE"+getVersionNumber(userAgent,pos+4));
+ } else
+ if ((pos=userAgent.indexOf("MSIE
5.0"))>-1) {
+ res = getArray("MSIE","MSIE5","MSIE"+getVersionNumber(userAgent,pos+4));
+ } else
+ if
((pos=userAgent.indexOf("MSIE 5.5"))>-1) {
+ res = getArray("MSIE","MSIE5.5","MSIE"+getVersionNumber(userAgent,pos+4));
+ } else
+ if
((pos=userAgent.indexOf("MSIE 5."))>-1) {
+ res = getArray("MSIE","MSIE5.x","MSIE"+getVersionNumber(userAgent,pos+4));
+ } else
+ if
((pos=userAgent.indexOf("MSIE 4"))>-1) {
+ res = getArray("MSIE","MSIE4","MSIE"+getVersionNumber(userAgent,pos+4));
+ } else
+ if ((pos=userAgent.indexOf("MSIE 7"))>-1 && userAgent.indexOf("Trident/4.0")<0) {
+ res = getArray("MSIE","MSIE7","MSIE"+getVersionNumber(userAgent,pos+4));
+
} else
+ if ((pos=userAgent.indexOf("MSIE 8"))>-1 || userAgent.indexOf("Trident/4.0")>-1) {
+ res = getArray("MSIE","MSIE8","MSIE"+getVersionNumber(userAgent,pos+4));
+
} else
+ if ((pos=userAgent.indexOf("MSIE 9"))>-1 || userAgent.indexOf("Trident/4.0")>-1) {
+ res = getArray("MSIE","MSIE9","MSIE"+getVersionNumber(userAgent,pos+4));
+
} else
+ res = getArray("MSIE","MSIE?","MSIE?"+getVersionNumber(userAgent,userAgent.indexOf("MSIE")+4));
+ } else
+ if
((pos=userAgent.indexOf("Gecko/"))>-1) {
+ res = getArray("Gecko","Gecko","Gecko"+getFirstVersionNumber(userAgent,pos+5,4));
+ if
((pos=userAgent.indexOf("Camino/"))>-1) {
+ res[1]+="(Camino)";
+
res[2]+="(Camino"+getVersionNumber(userAgent,pos+7)+")";
+ } else
+ if
((pos=userAgent.indexOf("Chimera/"))>-1) {
+
res[1]+="(Chimera)";
+
res[2]+="(Chimera"+getVersionNumber(userAgent,pos+8)+")";
+ } else
+ if
((pos=userAgent.indexOf("Firebird/"))>-1) {
+
res[1]+="(Firebird)";
+
res[2]+="(Firebird"+getVersionNumber(userAgent,pos+9)+")";
+ } else
+ if
((pos=userAgent.indexOf("Phoenix/"))>-1) {
+
res[1]+="(Phoenix)";
+
res[2]+="(Phoenix"+getVersionNumber(userAgent,pos+8)+")";
+ } else
+ if
((pos=userAgent.indexOf("Galeon/"))>-1) {
+
res[1]+="(Galeon)";
+
res[2]+="(Galeon"+getVersionNumber(userAgent,pos+7)+")";
+
} else
+ if
((pos=userAgent.indexOf("Firefox/"))>-1) {
+
res[1]+="(Firefox)";
+
res[2]+="(Firefox"+getVersionNumber(userAgent,pos+8)+")";
+
} else
+
if ((pos=userAgent.indexOf("Netscape/"))>-1) {
+
if ((pos=userAgent.indexOf("Netscape/6"))>-1) {
+
res[1]+="(NS6)";
+
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
+
} else
+
if ((pos=userAgent.indexOf("Netscape/7"))>-1) {
+
res[1]+="(NS7)";
+
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
+
} else
+
if ((pos=userAgent.indexOf("Netscape/8"))>-1) {
+
res[1]+="(NS8)";
+

res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
+
} else
+
if
((pos=userAgent.indexOf("Netscape/9"))>-1) {
+
res[1]+="(NS9)";
+

res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
+
} else {
+
res[1]+="(NS?)";
+ res[2]+="(NS?"+getVersionNumber(userAgent,userAgent.indexOf("Netscape/")+9)+")";
+
}
+
}
+ } else
+ if
((pos=userAgent.indexOf("Netscape/"))>-1) {
+ if
((pos=userAgent.indexOf("Netscape/4"))>-1) {
+ res =
getArray("NS","NS4","NS"+getVersionNumber(userAgent,pos+9));
+ } else
+ res =
getArray("NS","NS?","NS?"+getVersionNumber(userAgent,pos+9));
+ } else
+ if
((pos=userAgent.indexOf("Chrome/"))>-1) {
+ res = getArray("KHTML","KHTML(Chrome)","KHTML(Chrome"+getVersionNumber(userAgent,pos+6)+")");
+ } else
+ if
((pos=userAgent.indexOf("Safari/"))>-1) {
+ res = getArray("KHTML","KHTML(Safari)","KHTML(Safari"+getVersionNumber(userAgent,pos+6)+")");
+ } else
+ if
((pos=userAgent.indexOf("Konqueror/"))>-1) {
+ res = getArray("KHTML","KHTML(Konqueror)","KHTML(Konqueror"+getVersionNumber(userAgent,pos+9)+")");
+ } else
+ if
((pos=userAgent.indexOf("KHTML"))>-1) {
+ res = getArray("KHTML","KHTML?","KHTML?("+getVersionNumber(userAgent,pos+5)+")");
+
} else
+ if
((pos=userAgent.indexOf("NetFront"))>-1) {
+ res = getArray("NetFront","NetFront","NetFront "+getVersionNumber(userAgent,pos+8));
+
} else
+
if ((pos=userAgent.indexOf("BlackBerry"))>-1) {
+
pos=userAgent.indexOf("/",pos+2);
+ res = getArray("BlackBerry","BlackBerry","BlackBerry"+getVersionNumber(userAgent,pos+1));
+
} else
+ //<SPAN class="codecomment"> We will interpret Mozilla/4.x as Netscape Communicator is and only if x</span>
+
//<SPAN class="codecomment"> is not 0 or 5</span>
+
if (userAgent.indexOf("Mozilla/4.")==0 &&
+
userAgent.indexOf("Mozilla/4.0")<0 &&
+
userAgent.indexOf("Mozilla/4.5 ")<0) {
+ res = getArray("Communicator","Communicator","Communicator"+getVersionNumber(userAgent,pos+8));
+
} else
+
return getArray("?","?","?");
+ return res;
+ }
+}
=======================================
--- /branches/kkumar_code_organize/Applet/NDTConstants.java Fri Aug 5 13:49:42 2011
+++ /branches/kkumar_code_organize/Applet/NDTConstants.java Wed Aug 10 13:58:17 2011
@@ -1,3 +1,8 @@
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.swing.JOptionPane;
+
/**
*
*/
@@ -42,5 +47,36 @@
public static final int SFW_POSSIBLE = 3;

public static final double VIEW_DIFF = 0.1;
+
+
+ /*Method to initialise a few constants */
+ private static ResourceBundle messages;
+ public static String TCPBW100_MSGS = "Tcpbw100_msgs";
+
+ public static void initConstants(Locale paramLocale) {
+ try {
+ messages = ResourceBundle.getBundle( TCPBW100_MSGS, paramLocale);
+ System.out.println("Obtained messages ");
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
+ e.printStackTrace();
+ }
+
+ } //end method
+
+ public static void initConstants(String lang, String country) {
+ try {
+ Locale locale = new Locale(lang, country);
+ messages =
ResourceBundle.getBundle("Tcpbw100_msgs", locale);
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
+ e.printStackTrace();
+ }
+ }//end method initconstants
+
+
+ public static String getMessageString(String paramStrName) {
+ return messages.getString(paramStrName);
+ }

}
=======================================
--- /branches/kkumar_code_organize/Applet/Tcpbw100.java Fri Aug 5 13:49:42 2011
+++ /branches/kkumar_code_organize/Applet/Tcpbw100.java Wed Aug 10 13:58:17 2011
@@ -100,502 +100,514 @@
/**
*
*/
-
- JTextArea _txtDiagnosis, _txtStatistics;
- MyTextPane results;
- String inresult, outresult, errmsg;
- JButton startTest;
- JButton disMiss, disMiss2;
- JButton copy, copy2;
- JButton deTails;
- JButton sTatistics;
- JButton mailTo;
- JButton options;
- JCheckBox defaultTest, preferIPv6;
- JSpinner numOfTests = new JSpinner();
- String[] delays = { "immediate", "1min","5mins","10mins","30mins","2hours","12hours","1day" };
- JComboBox delay;
-
- boolean Randomize, failed, cancopy;
- URL location;
- clsFrame frameWeb100Vars, frameDetailedStats, frameOptions;
- String s;
- double t;
- int ECNEnabled, NagleEnabled, MSSSent, MSSRcvd;
- int SACKEnabled, TimestampsEnabled, WinScaleRcvd, WinScaleSent;
- int FastRetran, AckPktsOut, SmoothedRTT, CurrentCwnd, MaxCwnd;
- int SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender;
- int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
- int SumRTT, CountRTT, CurrentMSS, Timeouts, PktsRetrans;
- int SACKsRcvd, DupAcksIn, MaxRwinRcvd, MaxRwinSent;
- int DataPktsOut, Rcvbuf, Sndbuf, AckPktsIn, DataBytesOut;
- int PktsOut, CongestionSignals, RcvWinScale;
- int pkts, lth=8192, CurrentRTO;
- int c2sData, c2sAck, s2cData, s2cAck;
- // added for mailto url
- protected URL targetURL;
- private String TARGET1 = "U";
- private String TARGET2 = "H";
- String emailText;
- double s2cspd, c2sspd, sc2sspd, ss2cspd;
- int ssndqueue;
- double sbytes;
-
- /*************************************************************************
- * JavaScript access API extension
- * Added by Seth Peery and Gregory Wilson, Virginia Tech
- * October 28, 2009
- * This section adds classwide variables, written to at runtime,
- * which are then exposed by public accessor methods that can be called
- * from web applications using NDT as a back-end.
- */
-
-
- private double pub_c2sspd = 0.0;
- private double pub_s2cspd = 0.0;
- private int pub_CurRwinRcvd = 0; // source variable does not exist
- private int pub_MaxRwinRcvd = 0;
- private int pub_MinRTT = 0; // source variable does not exist
- private int pub_MaxRTT = 0; // source variable does not exist
- private double pub_loss = 0.0;
- private double pub_avgrtt = 0.0;
- //TODO:Getter/setter commented out for both below. Why?
- private int pub_MinRTO = 0; // source variable does not exist
- private int pub_MaxRTO = 0; // source variable does not exist
- private int pub_CurRTO = 0;
- // private String pub_CWNDpeaks = ""; // source variable does not exist
- private int pub_SACKsRcvd = 0;
- private String pub_osVer = "unknown";
- private String pub_javaVer = "unknown";
- private String pub_host = "unknown";
- private String pub_osName = "unknown";
- private String pub_osArch = "unknown";
- private int pub_mismatch = 0;
- private int pub_Bad_cable = 0;
- private int pub_congestion = 0;
- private double pub_cwndtime = 0.0;
- private double pub_pctRcvrLimited = 0.0;
- private String pub_AccessTech = "unknown";
- private String pub_natBox = "unknown";
- private int pub_DupAcksOut = 0;
- private Date pub_TimeStamp;
- private String pub_isReady = new String("no");
- private String pub_clientIP = "unknown";
- private int pub_jitter = 0; //unused. TODO: find out use
- private int pub_Timeouts = 0;
- private String pub_errmsg = "Test not run.";
- private String pub_diagnosis = "Test not run.";
- private String pub_statistics = "Test not run.";
- private String pub_status = "notStarted";
- private double pub_time = 0.0;
- private int pub_bytes = 0;
- private String isAutoRun;
- private String userAgent = null;
-
- /**
- * Accessor methods for public variables
- **/
-
- public String get_c2sspd()
- {
- // Expressed as MiB using base 10
- return Double.toString((pub_c2sspd));
- }
-
- public String get_s2cspd()
- {
- // Expressed as MiB using base 10
- return Double.toString(pub_s2cspd);
- }
-
- public String get_CurRwinRcvd()
- {
- return Integer.toString(pub_CurRwinRcvd);
- }
-
- public String get_MaxRwinRcvd()
- {
- return Integer.toString(pub_MaxRwinRcvd);
- }
-
- public String get_Ping()
- {
- return Integer.toString(pub_MinRTT);
- }
-
- public String get_MaxRTT()
- {
- return Integer.toString(pub_MaxRTT);
- }
-
- public String get_loss()
- {
- return Double.toString(pub_loss);
- }
-
- public String get_avgrtt()
- {
- return Double.toString(pub_avgrtt);
- }
-
- /* public String get_MinRTO()
+
+ JTextArea _txtDiagnosis, _txtStatistics;
+ ResultsTextPane results;
+ String inresult, outresult, errmsg;
+ JButton startTest;
+ JButton disMiss, disMiss2;
+ JButton copy, copy2;
+ JButton deTails;
+ JButton sTatistics;
+ JButton mailTo;
+ JButton options;
+ JCheckBox defaultTest, preferIPv6;
+ JSpinner numOfTests = new JSpinner();
+ String[] delays = { "immediate", "1min","5mins","10mins","30mins","2hours","12hours","1day" };
+ JComboBox delay;
+
+ boolean Randomize, failed, cancopy;
+ URL location;
+ NewFrame frameWeb100Vars, frameDetailedStats, frameOptions;
+ String s;
+ double t;
+ int ECNEnabled, NagleEnabled, MSSSent, MSSRcvd;
+ int SACKEnabled, TimestampsEnabled, WinScaleRcvd, WinScaleSent;
+ int FastRetran, AckPktsOut, SmoothedRTT, CurrentCwnd, MaxCwnd;
+ int SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender;
+ int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
+ int SumRTT, CountRTT, CurrentMSS, Timeouts, PktsRetrans;
+ int SACKsRcvd, DupAcksIn, MaxRwinRcvd, MaxRwinSent;
+ int DataPktsOut, Rcvbuf, Sndbuf, AckPktsIn, DataBytesOut;
+ int PktsOut, CongestionSignals, RcvWinScale;
+ int pkts, lth=8192, CurrentRTO;
+ int c2sData, c2sAck, s2cData, s2cAck;
+ // added for mailto url
+ protected URL targetURL;
+ private String TARGET1 = "U";
+ private String TARGET2 = "H";
+ String emailText;
+ double s2cspd, c2sspd, sc2sspd, ss2cspd;
+ int ssndqueue;
+ double sbytes;
+
+
/*************************************************************************
+ * JavaScript access API extension
+ * Added by Seth Peery and Gregory Wilson, Virginia Tech
+ * October 28, 2009
+ * This section adds classwide variables, written to at runtime,
+ * which are then exposed by public accessor methods that can be
called
+ * from web applications using NDT as a back-end.
+ */
+
+
+ private double pub_c2sspd = 0.0;
+ private double pub_s2cspd = 0.0;
+ private int pub_CurRwinRcvd = 0; // source variable does not exist
+ private int pub_MaxRwinRcvd = 0;
+ private int pub_MinRTT = 0; // source variable does not exist
+ private int pub_MaxRTT = 0; // source variable does not exist
+ private double pub_loss = 0.0;
+ private double pub_avgrtt = 0.0;
+ //TODO:Getter/setter commented out for both below. Why?
+ private int pub_MinRTO = 0; // source variable does not exist
+ private int pub_MaxRTO = 0; // source variable does not exist
+ private int pub_CurRTO = 0;
+ // private String pub_CWNDpeaks = ""; // source variable does not
exist
+ private int pub_SACKsRcvd = 0;
+ private String pub_osVer = "unknown";
+ private String pub_javaVer = "unknown";
+ private String pub_host = "unknown";
+ private String pub_osName = "unknown";
+ private String pub_osArch = "unknown";
+ private int pub_mismatch = 0;
+ private int pub_Bad_cable = 0;
+ private int pub_congestion = 0;
+ private double pub_cwndtime = 0.0;
+ private double pub_pctRcvrLimited = 0.0;
+ private String pub_AccessTech = "unknown";
+ private String pub_natBox = "unknown";
+ private int pub_DupAcksOut = 0;
+ private Date pub_TimeStamp;
+ private String pub_isReady = new String("no");
+ private String pub_clientIP = "unknown";
+ private int pub_jitter = 0; //unused. TODO: find out use
+ private int pub_Timeouts = 0;
+ private String pub_errmsg = "Test not run.";
+ private String pub_diagnosis = "Test not run.";
+ private String pub_statistics = "Test not run.";
+ private String pub_status = "notStarted";
+ private double pub_time = 0.0;
+ private int pub_bytes = 0;
+ private String isAutoRun;
+ private String userAgent = null;
+
+ /**
+ * Accessor methods for public variables
+ **/
+
+ public String get_c2sspd()
+ {
+ // Expressed as MiB using base 10
+ return Double.toString((pub_c2sspd));
+ }
+
+ public String get_s2cspd()
+ {
+ // Expressed as MiB using base 10
+ return Double.toString(pub_s2cspd);
+ }
+
+ public String get_CurRwinRcvd()
+ {
+ return Integer.toString(pub_CurRwinRcvd);
+ }
+
+ public String get_MaxRwinRcvd()
+ {
+ return Integer.toString(pub_MaxRwinRcvd);
+ }
+
+ public String get_Ping()
+ {
+ return Integer.toString(pub_MinRTT);
+ }
+
+ public String get_MaxRTT()
+ {
+ return Integer.toString(pub_MaxRTT);
+ }
+
+ public String get_loss()
+ {
+ return Double.toString(pub_loss);
+ }
+
+ public String get_avgrtt()
+ {
+ return Double.toString(pub_avgrtt);
+ }
+
+ /* public String get_MinRTO()
{
return pub_MinRTO;
}*/
-
- /* public String get_MaxRTO()
+
+ /* public String get_MaxRTO()
{
return pub_MaxRTO;
}*/

- public String get_CurRTO()
- {
- return Integer.toString(pub_CurRTO);
- }
-
-/*
+ public String get_CurRTO()
+ {
+ return Integer.toString(pub_CurRTO);
+ }
+
+ /*
public String get_CWNDpeaks()
{
return pub_CWNDpeaks;
} */

- public String get_SACKsRcvd()
- {
- return Integer.toString(pub_SACKsRcvd);
- }
-
- public String get_osVer()
- {
- return pub_osVer;
- }
-
- public String get_javaVer()
- {
- return pub_javaVer;
- }
-
- public String get_host()
- {
- return pub_host;
- }
-
- public String get_osName()
- {
- return pub_osName;
- }
-
- public String get_osArch()
- {
- return pub_osArch;
- }
-
- public String get_mismatch()
- {
- String result;
- if (pub_mismatch==0) {
- result = "no";
- } else {
- result = "yes";
- }
- return result;
- }
-
- public String get_Bad_cable()
- {
- String result;
- if (pub_Bad_cable ==1) {
- result = "yes";
- } else {
- result = "no";
- }
- return result;
- }
-
- public String get_congestion()
- {
- String result;
- if (pub_congestion == 1) {
- result = "yes";
- } else {
- result = "no";
- }
- return result;
- }
-
- public String get_cwndtime()
- {
- return Double.toString(pub_cwndtime);
- }
-
- public String get_AccessTech()
- {
- return pub_AccessTech;
- }
-
- public String get_rcvrLimiting()
- {
- return Double.toString(pub_pctRcvrLimited);
- }
-
- public String get_optimalRcvrBuffer()
- {
- return Integer.toString(pub_MaxRwinRcvd*1024);
- }
-
- public String get_clientIP()
- {
- return pub_clientIP;
- }
-
- public String get_natStatus()
- {
- return pub_natBox;
- }
-
- public String get_DupAcksOut()
- {
- return Integer.toString(pub_DupAcksOut);
- }
-
- public String get_TimeStamp()
- {
- String result = "unknown";
- if (pub_TimeStamp != null) {
- result = pub_TimeStamp.toString();
- }
- return result;
- }
-
- public String isReady()
- {
-
- // if ((pub_isReady == null) || (pub_isReady.equals(""))) {
- // pub_isReady = "no";
- // }
- // String result = "foo";
-
- //if (failed) {
- // pub_isReady = "failed1";
- //}
- //result = pub_isReady;
- // return result;
- return pub_isReady;
- }
-
- public String get_jitter()
- {
- return Integer.toString((pub_MaxRTT - pub_MinRTT));
- }
-
- public String get_WaitSec()
- {
- return Integer.toString((pub_CurRTO * pub_Timeouts)/1000);
- }
-
- public String get_errmsg()
- {
- //String result = "Test not run";
- //result = pub_errmsg;
- //return result;
- return pub_errmsg;
- }
-
- public String get_diagnosis()
- {
- return pub_diagnosis;
- }
-
- public String get_statistics()
- {
- return pub_statistics;
- }
-
- public String get_status()
- {
- return pub_status;
- }
-
- public String get_instSpeed()
- {
- return Double.toString((8.0 * pub_bytes) / (System.currentTimeMillis() - pub_time));
- }
-
- // "Remote Control" function - invoke NDT' runtest() method from the API
- public void run_test()
- {
- // The Java security model considers calling a method that opens a socket
- // from JavaScript to be a privileged action. By using
- // java.security.privilegedAction here, we can grant JavaScript the
- // same expanded privileges as the signed applet to open a socket.
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- pub_errmsg = "Test in progress.";
- runtest();
- return null;
- }
- });
- }
-
- public String getUserAgent() {
- return userAgent;
- }
-
- public void setUserAgent(String userAgent) {
- this.userAgent = userAgent;
- }
-
-/**
+ public String get_SACKsRcvd()
+ {
+ return Integer.toString(pub_SACKsRcvd);
+ }
+
+ public String get_osVer()
+ {
+ return pub_osVer;
+ }
+
+ public String get_javaVer()
+ {
+ return pub_javaVer;
+ }
+
+ public String get_host()
+ {
+ return pub_host;
+ }
+
+ public String get_osName()
+ {
+ return pub_osName;
+ }
+
+ public String get_osArch()
+ {
+ return pub_osArch;
+ }
+
+ public String get_mismatch()
+ {
+ String result;
+ if (pub_mismatch==0) {
+ result = "no";
+ } else {
+ result = "yes";
+ }
+ return result;
+ }
+
+ public String get_Bad_cable()
+ {
+ String result;
+ if (pub_Bad_cable ==1) {
+ result = "yes";
+ } else {
+ result = "no";
+ }
+ return result;
+ }
+
+ public String get_congestion()
+ {
+ String result;
+ if (pub_congestion == 1) {
+ result = "yes";
+ } else {
+ result = "no";
+ }
+ return result;
+ }
+
+ public String get_cwndtime()
+ {
+ return Double.toString(pub_cwndtime);
+ }
+
+ public String get_AccessTech()
+ {
+ return pub_AccessTech;
+ }
+
+ public String get_rcvrLimiting()
+ {
+ return Double.toString(pub_pctRcvrLimited);
+ }
+
+ public String get_optimalRcvrBuffer()
+ {
+ return Integer.toString(pub_MaxRwinRcvd*1024);
+ }
+
+ public String get_clientIP()
+ {
+ return pub_clientIP;
+ }
+
+ public String get_natStatus()
+ {
+ return pub_natBox;
+ }
+
+ public String get_DupAcksOut()
+ {
+ return Integer.toString(pub_DupAcksOut);
+ }
+
+ public String get_TimeStamp()
+ {
+ String result = "unknown";
+ if (pub_TimeStamp != null) {
+ result = pub_TimeStamp.toString();
+ }
+ return result;
+ }
+
+ public String isReady()
+ {
+
+ // if ((pub_isReady == null) || (pub_isReady.equals(""))) {
+ // pub_isReady = "no";
+ // }
+ // String result = "foo";
+
+ //if (failed) {
+ // pub_isReady = "failed1";
+ //}
+ //result = pub_isReady;
+ // return result;
+ return pub_isReady;
+ }
+
+ public String get_jitter()
+ {
+ return Integer.toString((pub_MaxRTT - pub_MinRTT));
+ }
+
+ public String get_WaitSec()
+ {
+ return Integer.toString((pub_CurRTO * pub_Timeouts)/1000);
+ }
+
+ public String get_errmsg()
+ {
+ //String result = "Test not run";
+ //result = pub_errmsg;
+ //return result;
+ return pub_errmsg;
+ }
+
+ public String get_diagnosis()
+ {
+ return pub_diagnosis;
+ }
+
+ public String get_statistics()
+ {
+ return pub_statistics;
+ }
+
+ public String get_status()
+ {
+ return pub_status;
+ }
+
+ public String get_instSpeed()
+ {
+ return Double.toString((8.0 * pub_bytes) / (System.currentTimeMillis() - pub_time));
+ }
+
+ // "Remote Control" function - invoke NDT' runtest() method from the
API
+ public void run_test()
+ {
+ // The Java security model considers calling a method that
opens a socket
+ // from JavaScript to be a privileged action. By using
+ // java.security.privilegedAction here, we can grant
JavaScript the
+ // same expanded privileges as the signed applet to open a
socket.
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ pub_errmsg = "Test in progress.";
+ runtest();
+ return null;
+ }
+ });
+ }
+
+ public String getUserAgent() {
+ return userAgent;
+ }
+
+ public void setUserAgent(String userAgent) {
+ this.userAgent = userAgent;
+ }
+
+ /**
End of accessor methods
-**/
- /************************************************************************/
-
- /**
- * Added by Martin Sandsmark, UNINETT AS
- * Internationalization
- */
- private Locale locale;
- private ResourceBundle messages;
- private String lang="en";
- private String country="US";
- //private static String lang="nb";
- //private static String country="NO";
- /***/
-
- int half_duplex, congestion, bad_cable, mismatch;
- double mylink;
- double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
- double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
- double aspd;
-
- boolean isApplication = false;
- boolean testInProgress = false;
- String host = null;
- String tmpstr, tmpstr2;
- byte tests = NDTConstants.TEST_MID | NDTConstants.TEST_C2S | NDTConstants.TEST_S2C |
- NDTConstants.TEST_SFW | NDTConstants.TEST_STATUS | NDTConstants.TEST_META;
- int c2sResult = NDTConstants.SFW_NOTTESTED;
- int s2cResult = NDTConstants.SFW_NOTTESTED;
-
- public void showStatus(String msg)
- {
- if (!isApplication) {
- super.showStatus(msg);
- }
- }
-
- public String getParameter(String name)
- {
- if (!isApplication) {
- return super.getParameter(name);
- }
- return null;
- }
-
-
- public void init() {
- if (getParameter("country") != null) country = getParameter("country");
- if (getParameter("language") != null) lang = getParameter("language");
-
- try {
- locale = new Locale(lang, country);
- messages = ResourceBundle.getBundle("Tcpbw100_msgs", locale);
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
- e.printStackTrace();
- }
-
- getContentPane().setLayout(new BorderLayout());
- showStatus(messages.getString("ready"));
- failed = false ;
- Randomize = false;
- cancopy = false;
- results = new MyTextPane();
- results.append("TCP/Web100 Network Diagnostic Tool v" + NDTConstants.VERSION + "\n");
- results.setEditable(false);
- getContentPane().add(new JScrollPane(results));
- results.append(messages.getString("clickStart") + "\n");
- Panel mPanel = new Panel();
- startTest = new JButton(messages.getString("start"));
- startTest.addActionListener(this);
- mPanel.add(startTest);
- sTatistics = new JButton(messages.getString("statistics"));
- sTatistics.addActionListener(this);
- if (getParameter("disableStatistics") == null) {
- mPanel.add(sTatistics);
- }
- sTatistics.setEnabled(false);
- deTails = new JButton(messages.getString("moreDetails"));
- deTails.addActionListener(this);
- if (getParameter("disableDetails") == null) {
- mPanel.add(deTails);
- }
- deTails.setEnabled(false);
- mailTo = new JButton(messages.getString("reportProblem"));
- mailTo.addActionListener(this);
- if (getParameter("disableMailto") == null) {
- mPanel.add(mailTo);
- }
- mailTo.setEnabled(false);
- options = new JButton(messages.getString("options") + "...");
- options.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- options.setEnabled(false);
- showOptions();
- options.setEnabled(true);
- }
-
- });
- if (getParameter("disableOptions") == null) {
- mPanel.add(options);
- }
- getContentPane().add(BorderLayout.SOUTH, mPanel);
- preferIPv6 = new JCheckBox(messages.getString("preferIPv6"));
- preferIPv6.setSelected(true);
- defaultTest = new JCheckBox(messages.getString("defaultTests"));
- defaultTest.setSelected(true);
- defaultTest.setEnabled(false);
- SpinnerNumberModel model = new SpinnerNumberModel();
- model.setMinimum(new Integer(0));
- model.setValue(new Integer(1));
- numOfTests.setModel(model);
- numOfTests.setPreferredSize(new Dimension(60, 20));
- delay = new JComboBox();
- for (int i = 0; i < delays.length; i++) {
- delay.addItem(messages.getString(delays[i]));
- }
- delay.setSelectedIndex(0);
-
- //Autorun functionality
- isAutoRun = getParameter("autoRun");
- if ((isAutoRun != null) && isAutoRun.equals("true")) {
- pub_errmsg = "Test in progress.";
- runtest();
- }
-
- }
-
-
- class MyTextPane extends JTextPane
- {
- public void append(String text)
- {
- try {
- getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
- }
- catch (BadLocationException e) {
- System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
- }
- }
-
- public void insertComponent(Component c)
- {
+ **/
+
/************************************************************************/
+
+ /**
+ * Added by Martin Sandsmark, UNINETT AS
+ * Internationalization
+ */
+ private Locale locale;
+ private ResourceBundle messages;
+ private String lang="en";
+ private String country="US";
+ //private static String lang="nb";
+ //private static String country="NO";
+ /***/
+
+ int half_duplex, congestion, bad_cable, mismatch;
+ double mylink;
+ double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
+ double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
+ double aspd;
+
+ boolean isApplication = false;
+ boolean testInProgress = false;
+ String host = null;
+ String tmpstr, tmpstr2;
+ byte tests = NDTConstants.TEST_MID | NDTConstants.TEST_C2S | NDTConstants.TEST_S2C |
+ NDTConstants.TEST_SFW | NDTConstants.TEST_STATUS | NDTConstants.TEST_META;
+ int c2sResult = NDTConstants.SFW_NOTTESTED;
+ int s2cResult = NDTConstants.SFW_NOTTESTED;
+
+
+ /* Method to initialize the base NDT window */
+ public void init() {
+ if (getParameter("country") != null) country =
getParameter("country");
+ if (getParameter("language") != null) lang =
getParameter("language");
+
+ try {
+ locale = new Locale(lang, country);
+ messages = ResourceBundle.getBundle("Tcpbw100_msgs",
locale);
+
+ //Replaced method call to initialize messages for
access by class
+ //NDTConstants.initConstants(locale);
+ NDTConstants.initConstants(lang, country);
+
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
+ e.printStackTrace();
+ }
+
+ getContentPane().setLayout(new BorderLayout());
+ showStatus(messages.getString("ready"));
+ failed = false ;
+ Randomize = false;
+ cancopy = false;
+ results = new ResultsTextPane();
+ results.append("TCP/Web100 Network Diagnostic Tool v" + NDTConstants.VERSION + "\n");
+ results.setEditable(false);
+ getContentPane().add(new JScrollPane(results));
+ results.append(messages.getString("clickStart") + "\n");
+ Panel mPanel = new Panel();
+ startTest = new JButton(messages.getString("start"));
+ startTest.addActionListener(this);
+ mPanel.add(startTest);
+ sTatistics = new JButton(messages.getString("statistics"));
+ sTatistics.addActionListener(this);
+ if (getParameter("disableStatistics") == null) {
+ mPanel.add(sTatistics);
+ }
+ sTatistics.setEnabled(false);
+ deTails = new JButton(messages.getString("moreDetails"));
+ deTails.addActionListener(this);
+ if (getParameter("disableDetails") == null) {
+ mPanel.add(deTails);
+ }
+ deTails.setEnabled(false);
+ mailTo = new JButton(messages.getString("reportProblem"));
+ mailTo.addActionListener(this);
+ if (getParameter("disableMailto") == null) {
+ mPanel.add(mailTo);
+ }
+ mailTo.setEnabled(false);
+ options = new JButton(messages.getString("options") + "...");
+ options.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ options.setEnabled(false);
+ showOptions();
+ options.setEnabled(true);
+ }
+
+ });
+ if (getParameter("disableOptions") == null) {
+ mPanel.add(options);
+ }
+ getContentPane().add(BorderLayout.SOUTH, mPanel);
+ preferIPv6 = new JCheckBox(messages.getString("preferIPv6"));
+ preferIPv6.setSelected(true);
+ defaultTest = new
JCheckBox(messages.getString("defaultTests"));
+ defaultTest.setSelected(true);
+ defaultTest.setEnabled(false);
+ SpinnerNumberModel model = new SpinnerNumberModel();
+ model.setMinimum(new Integer(0));
+ model.setValue(new Integer(1));
+ numOfTests.setModel(model);
+ numOfTests.setPreferredSize(new Dimension(60, 20));
+ delay = new JComboBox();
+ for (int i = 0; i < delays.length; i++) {
+ delay.addItem(messages.getString(delays[i]));
+ }
+ delay.setSelectedIndex(0);
+
+ //Autorun functionality
+ isAutoRun = getParameter("autoRun");
+ if ((isAutoRun != null) && isAutoRun.equals("true")) {
+ pub_errmsg = "Test in progress.";
+ runtest();
+ }
+
+ }
+
+ /* Method to display status
+ * @param String value of status
+ * @return void */
+ public void showStatus(String msg) {
+ if (!isApplication) {
+ super.showStatus(msg);
+ }
+ }
+
+ /* Utility method to get parameter value
+ * @param Key String whose value has to be found
+ * @return Value of key requested for */
+ public String getParameter(String name) {
+ if (!isApplication) {
+ return super.getParameter(name);
+ }
+ return null;
+ }
+
+ /*
+ class ResultsTextPane extends JTextPane
+ {
+ public void append(String text)
+ {
+ try {
+ getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
+ }
+ catch (BadLocationException e) {
+ System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
+ }
+ }
+
+ public void insertComponent(Component c)
+ {
setSelectionStart(results.getStyledDocument().getLength());
setSelectionEnd(results.getStyledDocument().getLength());
- super.insertComponent(c);
- }
- }
-
+ super.insertComponent(c);
+ }
+ }
+ */
+
+ /*
class StatusPanel extends JPanel
{
private int _testNo;
@@ -611,9 +623,15 @@
this._testsNum = testsNum;

***The diff for this file has been truncated for email.***


  • [ndt-dev] [ndt] r483 committed - Re-architect class layout, ndt, 08/10/2011

Archive powered by MHonArc 2.6.16.

Top of Page