[Jrisk-cvs] SF.net SVN: jrisk:[447] Grasshopper/src/net/yura/grasshopper
Brought to you by:
yuranet
|
From: <yu...@us...> - 2010-09-21 17:48:01
|
Revision: 447
http://jrisk.svn.sourceforge.net/jrisk/?rev=447&view=rev
Author: yuranet
Date: 2010-09-21 17:47:55 +0000 (Tue, 21 Sep 2010)
Log Message:
-----------
bug submit almost finished
Modified Paths:
--------------
Grasshopper/src/net/yura/grasshopper/BugSubmitter.java
Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java
Grasshopper/src/net/yura/grasshopper/PopupBug.java
Grasshopper/src/net/yura/grasshopper/SimpleBug.java
Grasshopper/src/net/yura/grasshopper/SimplePrintStream.java
Modified: Grasshopper/src/net/yura/grasshopper/BugSubmitter.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/BugSubmitter.java 2010-09-21 16:35:08 UTC (rev 446)
+++ Grasshopper/src/net/yura/grasshopper/BugSubmitter.java 2010-09-21 17:47:55 UTC (rev 447)
@@ -6,6 +6,8 @@
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.util.Enumeration;
import java.util.Hashtable;
/**
@@ -13,16 +15,80 @@
*/
public class BugSubmitter {
+ static void submitBug(String toString) {
+ submitBug(toString, "no-email");
+ }
+ static void submitBug(String text, String email) {
+ submitBug(text, email, "GRASSHOPPER BUG "+ BugSystemInfo.appName+" "+BugSystemInfo.version +" "+BugSystemInfo.locale );
+ }
- public static String submitBug(String url, Hashtable map) throws IOException {
+ static void submitBug(String text, String email,String subject) {
+ Hashtable map = new Hashtable();
+ map.put("text", text);
+ map.put("appName", BugSystemInfo.appName);
+ map.put("appVersion", BugSystemInfo.version);
+ map.put("appLocale", BugSystemInfo.locale);
+
+ try {
+ String send = send("http://yura.net/cgi-sys/FormMail.cgi", email, subject, map);
+ System.out.println("send ok: "+send);
+ }
+ catch(Throwable th) {
+ System.out.println("error sending: "+th.toString());
+ }
+ }
+
+
+ public static String send(String url, String from, String subject, Hashtable map) throws IOException {
+
+
+/*
+ RiskUtil.RISK_POST_URL;
+ RiskUtil.GAME_NAME+" "+Risk.RISK_VERSION+" "+title;
+
+ map.put("info",getSystemInfoText());
+ map.put("text", text);
+*/
+
+ map.put("recipient","yu...@yu...");
+ map.put("subject",subject);
+ map.put("email",from);
+ map.put("env_report","REMOTE_HOST,HTTP_USER_AGENT");
+
+ return doPost(url, map);
+ }
+
+ public static String doPost(String url, Hashtable map) throws IOException {
+
+ StringBuffer getpostb = new StringBuffer();
+ Enumeration enu = map.keys();
+ while(enu.hasMoreElements()) {
+ Object key = enu.nextElement();
+ getpostb.append( URLEncoder.encode( String.valueOf( key ) , "UTF-8") );
+ getpostb.append("=");
+ getpostb.append( URLEncoder.encode( String.valueOf( map.get(key) ) , "UTF-8"));
+ getpostb.append("&");
+ }
+ if (getpostb.length() >0) {
+ getpostb.deleteCharAt( getpostb.length()-1 );
+ }
+ String postdata = getpostb.toString();
+
+ return doPost(url, postdata);
+
+ }
+
+
+ public static String doPost(String url, String data) throws IOException {
+
StringBuffer buffer = new StringBuffer();
URLConnection conn = new URL(url).openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- //wr.write(data);
+ wr.write(data);
wr.flush();
// Get the response
@@ -41,28 +107,6 @@
}
-
- static void submitBug(String toString) {
-
- System.out.println("submitting:\n"+toString);
-
- }
-
- static void submitBug(String text, String email) {
- System.out.println("submitting: "+email+"\n"+text);
- }
-
-
-
-
- static void submitBug(String appname,String version,String locale, String toString) {
-
- //"http://url/", null
-
- }
-
-
-
/* this is doing a get, throws a 414 error on big messages
//t = t.replaceAll("\n","%0A").replaceAll(" ","+").replaceAll("&","%26");
Modified: Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java 2010-09-21 16:35:08 UTC (rev 446)
+++ Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java 2010-09-21 17:47:55 UTC (rev 447)
@@ -13,9 +13,6 @@
public static String appName,version,locale;
-
-
-
public static String getSysInfo() {
Modified: Grasshopper/src/net/yura/grasshopper/PopupBug.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/PopupBug.java 2010-09-21 16:35:08 UTC (rev 446)
+++ Grasshopper/src/net/yura/grasshopper/PopupBug.java 2010-09-21 17:47:55 UTC (rev 447)
@@ -21,7 +21,7 @@
*/
public class PopupBug extends Writer {
- static Object instance;
+ static PopupBug instance;
private JFrame errFrame;
private JTextArea debugText;
@@ -29,9 +29,10 @@
private PopupBug() {
debugText = new JTextArea();
+ debugText.setEditable(false);
SimplePrintStream.interceptAndAlert(this, new SimplePrintStream() {
- void action() {
+ protected void action() {
action2();
}
});
@@ -50,6 +51,13 @@
BugSystemInfo.locale = locale;
}
+ public static void log(String text) {
+ instance.debugText.append(text);
+ }
+ public static void clearLog() {
+ instance.debugText.setText("");
+ }
+
private void action2() {
// only create all this stuff if an error has happened
@@ -69,8 +77,6 @@
}
});
- debugText.setEditable(false);
-
JScrollPane errScroll = new JScrollPane(debugText);
Dimension size = new Dimension(400,400);
@@ -93,7 +99,7 @@
doSubmit(email);
JOptionPane.showMessageDialog(errFrame, "SENT!");
}
- catch(Exception ex) {
+ catch(Throwable ex) {
JOptionPane.showMessageDialog(errFrame, "ERROR: "+ex.getMessage() );
}
errFrame.setVisible(false);
@@ -107,16 +113,15 @@
errFrame.pack();
- String n = System.getProperty("line.separator");
- debugText.append(n+n+"Date: "+new java.util.Date().toString()+n+n+n);
-
}
+ String n = System.getProperty("line.separator");
+ debugText.append(n+n+"Date: "+new java.util.Date().toString()+n+n+n);
+
errFrame.setVisible(true);
}
private void doSubmit(String email) {
-
BugSubmitter.submitBug(debugText.getText(),email);
}
@@ -179,7 +184,6 @@
// Write your code here what to do if user has canceled Save dialog
}
-
*/
}
Modified: Grasshopper/src/net/yura/grasshopper/SimpleBug.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/SimpleBug.java 2010-09-21 16:35:08 UTC (rev 446)
+++ Grasshopper/src/net/yura/grasshopper/SimpleBug.java 2010-09-21 17:47:55 UTC (rev 447)
@@ -14,7 +14,7 @@
if (instance!=null) return;
SimplePrintStream.interceptAndAlert(this, new SimplePrintStream() {
- void action() {
+ protected void action() {
action2();
}
});
Modified: Grasshopper/src/net/yura/grasshopper/SimplePrintStream.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/SimplePrintStream.java 2010-09-21 16:35:08 UTC (rev 446)
+++ Grasshopper/src/net/yura/grasshopper/SimplePrintStream.java 2010-09-21 17:47:55 UTC (rev 447)
@@ -10,7 +10,7 @@
public abstract class SimplePrintStream {
- abstract void action();
+ protected abstract void action();
public static void interceptAndAlert(final Writer a,final SimplePrintStream b) {
System.setOut( SimplePrintStream.getSimplePrintStream( a, FileDescriptor.out ,null) );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|