// Path: src/fr/xtof54/jsgo/EventManager.java
// enum eventType {loginStarted, loginEnd, downloadListStarted, downloadListEnd, downloadListGamesEnd, downloadGameStarted, downloadGameEnd, GameOK, moveSentStart, moveSentEnd, gobanReady,
// 	msgSendStart, msgSendEnd, ladderStart, ladderEnd, ladderChallengeStart, ladderChallengeEnd, showMessage, copyEidogoStart, copyEidogoEnd};


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import android.webkit.CookieManager;
import fr.xtof54.jsgo.EventManager.eventType;
						if (s==null) break;
						System.out.println("DGSAPP request answer "+s);
						sb.append(s);
					}
					res = sb.toString();
				} else {
					System.out.println("DGSAPP saving res in file "+saveInFile);
					PrintWriter fout = new PrintWriter(new FileWriter(saveInFile));
					for (;;) {
						String s = fin.readLine();
						if (s==null) break;
						fout.print(s);
					}
					fout.close();
					res=null;
				}
				fin.close();
				GoJsActivity.main.updateTraffic();
				return res;
			}
		},httpctxt);
		System.out.println("DGSAPP just after execute...");
	} catch (Exception e) {
		e.printStackTrace();
		GoJsActivity.main.updateTraffic();
	}
	return res;
}

public void ladderChallenge(final String rid, final int pos) {
// Path: src/fr/xtof54/jsgo/EventManager.java
// enum eventType {loginStarted, loginEnd, downloadListStarted, downloadListEnd, downloadListGamesEnd, downloadGameStarted, downloadGameEnd, GameOK, moveSentStart, moveSentEnd, gobanReady,
// 	msgSendStart, msgSendEnd, ladderStart, ladderEnd, ladderChallengeStart, ladderChallengeEnd, showMessage, copyEidogoStart, copyEidogoEnd};


// Path: src/fr/xtof54/jsgo/AndroidServerConnection.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import android.webkit.CookieManager;
import fr.xtof54.jsgo.EventManager.eventType;

						if (s==null) break;
						System.out.println("DGSAPP request answer "+s);
						sb.append(s);
					}
					res = sb.toString();
				} else {
					System.out.println("DGSAPP saving res in file "+saveInFile);
					PrintWriter fout = new PrintWriter(new FileWriter(saveInFile));
					for (;;) {
						String s = fin.readLine();
						if (s==null) break;
						fout.print(s);
					}
					fout.close();
					res=null;
				}
				fin.close();
				GoJsActivity.main.updateTraffic();
				return res;
			}
		},httpctxt);
		System.out.println("DGSAPP just after execute...");
	} catch (Exception e) {
		e.printStackTrace();
		GoJsActivity.main.updateTraffic();
	}
	return res;
}

public void ladderChallenge(final String rid, final int pos) {
	EventManager.getEventManager().sendEvent(eventType.ladderChallengeStart);