// 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.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
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.impl.client.DefaultHttpClient;
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.json.JSONObject;
import android.util.Log;
import fr.xtof54.jsgo.EventManager.eventType;
     * creates a connection to a specific server;
     * determines the correct credentials
     * @param num
     */
    public ServerConnection(int num, String userlogin, String userpwd) {
        server=serverNames[num];
        // TODO: this must be handled outside of this class
        //		String tu = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_USERNAME_KEY,null);
        //	    String tp = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_PASSWORD_KEY,null);
        //	    if (tu==null||tp==null) {
        //	    	logger.showMsg("Please enter your credentials first via menu Settings");
        //	        return;
        //	    }
        //		if (GoJsActivity.main.debugdevel==0) {
        //			GoJsActivity.main.debugdevel=1;
        //		} else if (GoJsActivity.main.debugdevel==1) {
        //			tu = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_USERNAME2_KEY,null);
        //			tp = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_PASSWORD2_KEY,null);
        //			GoJsActivity.main.debugdevel=0;
        //		}
        u=userlogin; p=userpwd;
    }

    /**
     * Login to this server
     * WARNING: asynchronous / non-blocking !!
     */
    public boolean loginok=false;
    public void startLogin() {
        final EventManager em = EventManager.getEventManager();
// 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/ServerConnection.java
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
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.impl.client.DefaultHttpClient;
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.json.JSONObject;
import android.util.Log;
import fr.xtof54.jsgo.EventManager.eventType;

     * creates a connection to a specific server;
     * determines the correct credentials
     * @param num
     */
    public ServerConnection(int num, String userlogin, String userpwd) {
        server=serverNames[num];
        // TODO: this must be handled outside of this class
        //		String tu = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_USERNAME_KEY,null);
        //	    String tp = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_PASSWORD_KEY,null);
        //	    if (tu==null||tp==null) {
        //	    	logger.showMsg("Please enter your credentials first via menu Settings");
        //	        return;
        //	    }
        //		if (GoJsActivity.main.debugdevel==0) {
        //			GoJsActivity.main.debugdevel=1;
        //		} else if (GoJsActivity.main.debugdevel==1) {
        //			tu = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_USERNAME2_KEY,null);
        //			tp = PrefUtils.getFromPrefs(GoJsActivity.main, PrefUtils.PREFS_LOGIN_PASSWORD2_KEY,null);
        //			GoJsActivity.main.debugdevel=0;
        //		}
        u=userlogin; p=userpwd;
    }

    /**
     * Login to this server
     * WARNING: asynchronous / non-blocking !!
     */
    public boolean loginok=false;
    public void startLogin() {
        final EventManager em = EventManager.getEventManager();
        em.sendEvent(eventType.loginStarted);