Debut de la parti reseau

This commit is contained in:
Bertrand BRUN 2011-01-27 19:12:22 +01:00
parent 9faee26dff
commit 2b1d8b859e
7 changed files with 74 additions and 5 deletions

View File

@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/gson-1.6.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PtiClic</string>
<string name="prefs_name">Préférences</string>
<string name="games_name">Jouer</string>
<string name="app_name">PtiClic</string>
<string name="prefs_name">Préférences</string>
<string name="games_name">Jouer</string>
</resources>

View File

@ -0,0 +1,5 @@
package org.pticlic.model;
public class Constant {
public static final String SERVER_URL = "SERVER_URL";
}

View File

@ -0,0 +1,5 @@
package org.pticlic.model;
public class GamePlayed {
}

View File

@ -0,0 +1,57 @@
package org.pticlic.model;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class Network {
public enum Action {
GET_GAMES
}
public enum Mode {
SIMPLE_GAME
}
private Mode mode;
private Context context;
public Network(Context context, Mode mode) {
this.mode = mode;
this.context = context;
}
// TODO : faire se qui est la
// http://developer.android.com/reference/java/net/URLConnection.html#addRequestProperty%28java.lang.String,%20java.lang.String%29
public GamePlayed getGames(int nbGames) {
DefaultHttpClient httpClient = new DefaultHttpClient();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
String serverUrl = sp.getString(Constant.SERVER_URL, "http://serveur/pticlic.php");
try {
HttpResponse res;
URI uri = new URI(serverUrl);
HttpPost methodPost = new HttpPost(uri);
//methodPost.setEntity(new StringEntity(s, charset));
} catch (URISyntaxException e) {
return null;
}
return null;
}
public boolean sendGame(GamePlayed game) {
throw new UnsupportedOperationException();
}
}

View File

@ -38,7 +38,7 @@ Outils :
Durée du projet 4 mois (4 itérations de 4 semaines)
Conventions de code : http://java.sun.com/docs/codeconv/html/CodeConventions.doc6.html
Conventions de code : \url{http://java.sun.com/docs/codeconv/html/CodeConventions.doc6.html}
Code (noms de variables, etc.) en anglais, commentaires en français, javadoc en français.