gcompris r3723 - in branches/GCOMPRIS_8_3: . boards/missing_letter src/boards src/boards/python/admin src/gcompris



Author: bcoudoin
Date: Tue Feb 17 23:18:08 2009
New Revision: 3723
URL: http://svn.gnome.org/viewvc/gcompris?rev=3723&view=rev

Log:
merged 3722 from trunk


Added:
   branches/GCOMPRIS_8_3/boards/missing_letter/board2.xml.in
      - copied unchanged from r3722, /trunk/boards/missing_letter/board2.xml.in
   branches/GCOMPRIS_8_3/boards/missing_letter/board3.xml.in
      - copied unchanged from r3722, /trunk/boards/missing_letter/board3.xml.in
   branches/GCOMPRIS_8_3/boards/missing_letter/board4.xml.in
      - copied unchanged from r3722, /trunk/boards/missing_letter/board4.xml.in
   branches/GCOMPRIS_8_3/src/boards/missingletter_config.c
      - copied unchanged from r3722, /trunk/src/boards/missingletter_config.c
Removed:
   branches/GCOMPRIS_8_3/src/gcompris/cache.c
Modified:
   branches/GCOMPRIS_8_3/   (props changed)
   branches/GCOMPRIS_8_3/ChangeLog
   branches/GCOMPRIS_8_3/boards/missing_letter/Makefile.am
   branches/GCOMPRIS_8_3/boards/missing_letter/board1.xml.in
   branches/GCOMPRIS_8_3/configure.in
   branches/GCOMPRIS_8_3/src/boards/Makefile.am
   branches/GCOMPRIS_8_3/src/boards/advanced_colors.c
   branches/GCOMPRIS_8_3/src/boards/imageid.c
   branches/GCOMPRIS_8_3/src/boards/missingletter.c
   branches/GCOMPRIS_8_3/src/boards/python/admin/board_list.py
   branches/GCOMPRIS_8_3/src/boards/read_colors.c
   branches/GCOMPRIS_8_3/src/boards/reading.c
   branches/GCOMPRIS_8_3/src/boards/shapegame.c
   branches/GCOMPRIS_8_3/src/boards/superbrain.c
   branches/GCOMPRIS_8_3/src/boards/wordprocessor.c
   branches/GCOMPRIS_8_3/src/gcompris/Makefile.am
   branches/GCOMPRIS_8_3/src/gcompris/board_config_wordlist.c
   branches/GCOMPRIS_8_3/src/gcompris/config.c
   branches/GCOMPRIS_8_3/src/gcompris/dialog.c
   branches/GCOMPRIS_8_3/src/gcompris/gameutil.c
   branches/GCOMPRIS_8_3/src/gcompris/gameutil.h
   branches/GCOMPRIS_8_3/src/gcompris/gc_core.h
   branches/GCOMPRIS_8_3/src/gcompris/gc_net.c
   branches/GCOMPRIS_8_3/src/gcompris/gc_net.h
   branches/GCOMPRIS_8_3/src/gcompris/gcompris.c
   branches/GCOMPRIS_8_3/src/gcompris/images_selector.c
   branches/GCOMPRIS_8_3/src/gcompris/skin.c
   branches/GCOMPRIS_8_3/src/gcompris/wordlist.c

Modified: branches/GCOMPRIS_8_3/boards/missing_letter/Makefile.am
==============================================================================
--- branches/GCOMPRIS_8_3/boards/missing_letter/Makefile.am	(original)
+++ branches/GCOMPRIS_8_3/boards/missing_letter/Makefile.am	Tue Feb 17 23:18:08 2009
@@ -2,7 +2,10 @@
 xmldir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/missing_letter
 
 xml_in_files = \
-	board1.xml.in
+	board1.xml.in \
+	board2.xml.in \
+	board3.xml.in \
+	board4.xml.in
 
 xml_DATA = $(xml_in_files:.xml.in=.xml)
 

Modified: branches/GCOMPRIS_8_3/boards/missing_letter/board1.xml.in
==============================================================================
--- branches/GCOMPRIS_8_3/boards/missing_letter/board1.xml.in	(original)
+++ branches/GCOMPRIS_8_3/boards/missing_letter/board1.xml.in	Tue Feb 17 23:18:08 2009
@@ -36,113 +36,5 @@
   	<pixmapfile>imageid/bed.png</pixmapfile>
 	<_data>bed/_ed/b/l/f</_data>
   </Board>
-  <Board>
-  	<pixmapfile>imageid/bottle.png</pixmapfile>
-	<_data>bottle/_ottle/b/t/p</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/cake.png</pixmapfile>
-	<_data>cake/_ake/c/p/d</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/ballon.png</pixmapfile>
-	<_data>ball/_all/b/p/d</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/avion.png</pixmapfile>
-	<_data>plane/p_ane/l/j/i</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/chien.png</pixmapfile>
-	<_data>dog/d_g/o/g/a</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/fish.png</pixmapfile>
-	<_data>fish/_ish/f/h/l</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/car.png</pixmapfile>
-	<_data>car/_ar/c/k/b</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/cartable.png</pixmapfile>
-	<_data>satchel/_atchel/s/c/l</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/banana.png</pixmapfile>
-	<_data>banana/_anana/b/p/d</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/maison.png</pixmapfile>
-	<_data>house/h_use/o/f/u</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/pomme.png</pixmapfile>
-	<_data>apple/appl_/e/h/a</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/bed.png</pixmapfile>
-	<_data>bed/b_d/e/a/i</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/bottle.png</pixmapfile>
-	<_data>bottle/b_ttle/o/u/d</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/cake.png</pixmapfile>
-	<_data>cake/c_ke/a/o/e</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/ballon.png</pixmapfile>
-	<_data>ball/b_ll/a/u/o</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/avion.png</pixmapfile>
-	<_data>plane/pl_ne/a/o/s</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/chien.png</pixmapfile>
-	<_data>dog/do_/g/p/q</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/fish.png</pixmapfile>
-	<_data>fish/fis_/h/o/i</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/car.png</pixmapfile>
-	<_data>car/ca_/r/w/k</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/cartable.png</pixmapfile>
-	<_data>satchel/sa_chel/t/p/c</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/banana.png</pixmapfile>
-	<_data>banana/ba_ana/n/m/b</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/maison.png</pixmapfile>
-	<_data>house/_ouse/h/e/j</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/pomme.png</pixmapfile>
-	<_data>apple/app_e/l/h/n</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/bed.png</pixmapfile>
-	<_data>bed/be_/d/p/b</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/bottle.png</pixmapfile>
-	<_data>bottle/bott_e/l/y/r</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/cake.png</pixmapfile>
-	<_data>cake/ca_e/k/q/c</_data>
-  </Board>
-  <Board>
-  	<pixmapfile>imageid/ballon.png</pixmapfile>
-	<_data>ball/bal_/l/h/s</_data>
-  </Board>
 </missing_letter>
 

Modified: branches/GCOMPRIS_8_3/configure.in
==============================================================================
--- branches/GCOMPRIS_8_3/configure.in	(original)
+++ branches/GCOMPRIS_8_3/configure.in	Tue Feb 17 23:18:08 2009
@@ -398,6 +398,20 @@
   AC_MSG_WARN(Couldn't find texi2html usualy in the tetex package, please install it)
 fi
 
+ 
+dnl GNET support
+AC_MSG_CHECKING([wether we build with GNET (if not, networking will be disabled)])
+AC_ARG_ENABLE(gnet,
+          AC_HELP_STRING(
+          [--disable-gnet],
+          [Turn on gnet (will let GCompris fetch content from a web server)]),
+          with_gnet="$enableval", with_gnet="no")
+AC_MSG_RESULT($with_gnet)
+
+if test x$with_gnet = xyes; then
+  PKG_CHECK_MODULES(GNET, gnet-2.0,, AC_MSG_ERROR([*** GNET not found!]))
+  AC_DEFINE([USE_GNET], 1,[Networking is enabled])
+fi
 
 dnl SQLITE support
 AC_MSG_CHECKING([wether we build with SQLITE (if not profile will be disabled)])

Modified: branches/GCOMPRIS_8_3/src/boards/Makefile.am
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/Makefile.am	(original)
+++ branches/GCOMPRIS_8_3/src/boards/Makefile.am	Tue Feb 17 23:18:08 2009
@@ -170,7 +170,7 @@
 
 libmissingletter_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS)
 libmissingletter_la_LIBADD =
-libmissingletter_la_SOURCES = missingletter.c
+libmissingletter_la_SOURCES = missingletter.c missingletter_config.c
 
 
 libclick_on_letter_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs)

Modified: branches/GCOMPRIS_8_3/src/boards/advanced_colors.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/advanced_colors.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/advanced_colors.c	Tue Feb 17 23:18:08 2009
@@ -521,7 +521,7 @@
   g_return_val_if_fail(fname!=NULL,FALSE);
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
 
   /* in case something went wrong */
   if(!doc)

Modified: branches/GCOMPRIS_8_3/src/boards/imageid.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/imageid.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/imageid.c	Tue Feb 17 23:18:08 2009
@@ -633,7 +633,7 @@
   g_return_val_if_fail(fname!=NULL,FALSE);
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
 
   /* in case something went wrong */
   if(!doc)

Modified: branches/GCOMPRIS_8_3/src/boards/missingletter.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/missingletter.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/missingletter.c	Tue Feb 17 23:18:08 2009
@@ -27,7 +27,7 @@
 
 #define SOUNDLISTFILE PACKAGE
 
-static GcomprisBoard *gcomprisBoard = NULL;
+GcomprisBoard *gcomprisBoard_missing = NULL;
 static gboolean board_paused = TRUE;
 
 static void		 start_board (GcomprisBoard *agcomprisBoard);
@@ -43,6 +43,9 @@
 					     GcomprisProfile *aProfile);
 static void		 config_stop(void);
 
+/* from missingletter_config.c */
+void config_missing_letter(GcomprisBoardConf *config);
+
 typedef struct _Board Board;
 struct _Board {
   char  *pixmapfile;
@@ -56,12 +59,10 @@
 static Board * board;
 
 /* XML */
-static gboolean		 read_xml_file(char *fname);
 static void		 init_xml(void);
-static void		 add_xml_data(xmlDocPtr, xmlNodePtr, GNode *);
-static void		 parse_doc(xmlDocPtr doc);
-static gboolean		 read_xml_file(char *fname);
-static void		 destroy_board_list();
+static void		 add_xml_data(xmlDocPtr, xmlNodePtr, GList**);
+gboolean		 missing_read_xml_file(char *fname, GList**);
+void			 missing_destroy_board_list(GList *);
 static void		 destroy_board(Board * board);
 
 /* This is the list of boards */
@@ -70,12 +71,7 @@
 #define VERTICAL_SEPARATION 30
 #define HORIZONTAL_SEPARATION 30
 
-//NUMBER_OF_SUBLEVELS*NUMBER_OF_LEVELS must equal the number of boards in XML file
-#define NUMBER_OF_SUBLEVELS 9
-#define NUMBER_OF_LEVELS 4
-
 /* ================================================================ */
-static int board_number; // between 0 and board_list.length-1
 static int right_word; // between 1 and 3, indicates which choice is the right one (the player clicks on it
 
 static GnomeCanvasGroup *boardRootItem = NULL;
@@ -132,7 +128,7 @@
  */
 static void pause_board (gboolean pause)
 {
-  if(gcomprisBoard==NULL)
+  if(gcomprisBoard_missing==NULL)
     return;
 
   gc_bar_hide(FALSE);
@@ -150,6 +146,7 @@
 static void start_board (GcomprisBoard *agcomprisBoard)
 {
   GHashTable *config = gc_db_get_board_conf();
+  gchar * filename;
 
   gc_locale_set(g_hash_table_lookup( config, "locale"));
 
@@ -157,19 +154,23 @@
 
   if(agcomprisBoard!=NULL)
     {
-      gcomprisBoard=agcomprisBoard;
-      gc_set_background(gnome_canvas_root(gcomprisBoard->canvas),
+      gcomprisBoard_missing=agcomprisBoard;
+      gc_set_background(gnome_canvas_root(gcomprisBoard_missing->canvas),
 			"opt/missingletter-bg.jpg");
-      gcomprisBoard->level=1;
-      gcomprisBoard->maxlevel=NUMBER_OF_LEVELS;
-      gcomprisBoard->sublevel=1;
-      gcomprisBoard->number_of_sublevel=NUMBER_OF_SUBLEVELS; /* Go to next level after this number of 'play' */
+      gcomprisBoard_missing->level=1;
+
+      /* Calculate the maxlevel based on the available data file for this board */
+      gcomprisBoard_missing->maxlevel = 1;
+      while((filename = gc_file_find_absolute("%s/board%d.xml",
+      	gcomprisBoard_missing->boarddir, ++gcomprisBoard_missing->maxlevel)))
+	  g_free(filename);
+
+      gcomprisBoard_missing->maxlevel--;
+
+      gcomprisBoard_missing->sublevel=1;
+      gcomprisBoard_missing->number_of_sublevel=G_MAXINT;
+
       init_xml();
-      g_assert(NUMBER_OF_LEVELS*NUMBER_OF_SUBLEVELS == g_list_length(board_list));
-      gc_score_start(SCORESTYLE_NOTE,
-			   50,
-			   gcomprisBoard->height - 50,
-			   gcomprisBoard->number_of_sublevel);
       gc_bar_set(GC_BAR_CONFIG | GC_BAR_LEVEL);
 
       missing_letter_next_level();
@@ -182,27 +183,29 @@
 static void end_board ()
 {
 
-  if(gcomprisBoard!=NULL)
+  if(gcomprisBoard_missing!=NULL)
     {
       pause_board(TRUE);
       gc_score_end();
       missing_letter_destroy_all_items();
-      destroy_board_list();
+      missing_destroy_board_list(board_list);
+      board_list = NULL;
     }
 
   gc_locale_reset();
 
-  gcomprisBoard = NULL;
+  gcomprisBoard_missing = NULL;
 }
 
 static void
 set_level (guint level)
 {
 
-  if(gcomprisBoard!=NULL)
+  if(gcomprisBoard_missing!=NULL)
     {
-      gcomprisBoard->level=level;
-      gcomprisBoard->sublevel=1;
+      gcomprisBoard_missing->level=level;
+      gcomprisBoard_missing->sublevel=1;
+      init_xml();
       missing_letter_next_level();
     }
 }
@@ -228,16 +231,16 @@
 /* set initial values for the next level */
 static void missing_letter_next_level()
 {
-  gc_bar_set_level(gcomprisBoard);
+  gc_bar_set_level(gcomprisBoard_missing);
 
   missing_letter_destroy_all_items();
   selected_button = NULL;
   gamewon = FALSE;
 
-  gc_score_set(gcomprisBoard->sublevel);
+  gc_score_set(gcomprisBoard_missing->sublevel);
 
   /* Try the next level */
-  missing_letter_create_item(gnome_canvas_root(gcomprisBoard->canvas));
+  missing_letter_create_item(gnome_canvas_root(gcomprisBoard_missing->canvas));
 
 }
 /* ==================================== */
@@ -268,27 +271,24 @@
   gint txt_area_x = 515;
   gint txt_area_y = 435;
 
-  board_number = (gcomprisBoard->level-1) * NUMBER_OF_SUBLEVELS + gcomprisBoard->sublevel-1;
-
-  g_assert(board_number >= 0  && board_number < g_list_length(board_list));
   place = g_random_int_range( 0, 3);
   g_assert(place >= 0  && place < 3);
 
   right_word = place+1;
 
   boardRootItem = GNOME_CANVAS_GROUP(
-				     gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
+				     gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard_missing->canvas),
 							    gnome_canvas_group_get_type (),
 							    "x", (double) 0,
 							    "y", (double) 0,
 							    NULL));
   button_pixmap = gc_skin_pixmap_load("button.png");
   /* display the image */
-  board = g_list_nth_data(board_list, board_number);
+  board = g_list_nth_data(board_list, gcomprisBoard_missing->sublevel-1);
   g_assert(board != NULL);
   pixmap = gc_pixmap_load(board->pixmapfile);
 
-  yOffset = (gcomprisBoard->height - gdk_pixbuf_get_height(button_pixmap) - gdk_pixbuf_get_height(pixmap) - 2*VERTICAL_SEPARATION)/2;
+  yOffset = (gcomprisBoard_missing->height - gdk_pixbuf_get_height(button_pixmap) - gdk_pixbuf_get_height(pixmap) - 2*VERTICAL_SEPARATION)/2;
 
   text_s = gnome_canvas_item_new (boardRootItem,
 				gnome_canvas_text_get_type (),
@@ -345,7 +345,7 @@
     break;
   }
 
-  yOffset = ( gcomprisBoard->height - 3*gdk_pixbuf_get_height(button_pixmap) - 2*VERTICAL_SEPARATION) / 2;
+  yOffset = ( gcomprisBoard_missing->height - 3*gdk_pixbuf_get_height(button_pixmap) - 2*VERTICAL_SEPARATION) / 2;
   xOffset = (img_area_x-gdk_pixbuf_get_width(button_pixmap))/2;
   button1 = gnome_canvas_item_new (boardRootItem,
 				   gnome_canvas_pixbuf_get_type (),
@@ -438,13 +438,15 @@
 }
 /* ==================================== */
 static void game_won() {
-  gcomprisBoard->sublevel++;
+  gcomprisBoard_missing->sublevel++;
 
-  if(gcomprisBoard->sublevel>gcomprisBoard->number_of_sublevel) {
+  if(gcomprisBoard_missing->sublevel>gcomprisBoard_missing->number_of_sublevel) {
     /* Try the next level */
-    gcomprisBoard->sublevel=1;
-    gcomprisBoard->level++;
-    if(gcomprisBoard->level>gcomprisBoard->maxlevel) {
+    gcomprisBoard_missing->sublevel=1;
+    gcomprisBoard_missing->level++;
+    init_xml();
+
+    if(gcomprisBoard_missing->level>gcomprisBoard_missing->maxlevel) {
 	gc_bonus_end_display(GC_BOARD_FINISHED_TUXPLANE);
 	return;
     }
@@ -563,16 +565,27 @@
 {
   char *filename;
 
-  filename = gc_file_find_absolute("%s/board1.xml",
-				   gcomprisBoard->boarddir);
-
-  g_assert(read_xml_file(filename)== TRUE);
-
+  if(board_list)
+  {
+    missing_destroy_board_list(board_list);
+    board_list = NULL;
+  }
+  filename = gc_file_find_absolute("%s/board%d.xml",
+				   gcomprisBoard_missing->boarddir,
+				   gcomprisBoard_missing->level);
+  missing_read_xml_file(filename, &board_list);
+  gcomprisBoard_missing->number_of_sublevel = g_list_length(board_list);
   g_free(filename);
+
+  gc_score_end();
+  gc_score_start(SCORESTYLE_NOTE,
+		  50,
+		  gcomprisBoard_missing->height - 50,
+		  gcomprisBoard_missing->number_of_sublevel);
 }
 
 /* ==================================== */
-static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child)
+static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GList **list)
 {
   gchar *pixmapfile = NULL;
   gchar *question = NULL, *answer = NULL;
@@ -594,22 +607,17 @@
       {
 	if(data==NULL)
 	  {
-	    data = gettext((gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1));
+	    gchar *tmp;
+	    tmp = (gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1);
+	    data = g_strdup(gettext(tmp));
+	    g_free(tmp);
 	  }
       }
     xmlnode = xmlnode->next;
   }
 
-  // I really don't know why this test, but otherwise, the list is doubled
-  // with 1 line on 2 filled with NULL elements
-  if ( pixmapfile == NULL || data == NULL)
-    return;
-
-/*  if ((i=sscanf(data, "%s / %s / %s / %s / %s", answer, question, l1, l2, l3)) != 5)
-		printf("Error sscanf result != 5 = %i\n",i);
-*/
   gchar **all_answer = g_strsplit(data, "/", 5);
-  /* Dont free data, it's a gettext static message */
+  g_free(data);
 
   answer = all_answer[0];
   question = all_answer[1];
@@ -628,33 +636,23 @@
 
   g_strfreev(all_answer);
 
-  board_list = g_list_append (board_list, board);
+  *list = g_list_append (*list, board);
 }
 
-/* ==================================== */
-static void parse_doc(xmlDocPtr doc)
-{
-  xmlNodePtr node;
-
-  for(node = doc->children->children; node != NULL; node = node->next) {
-    if ( g_strcasecmp((gchar *)node->name, "Board") == 0 )
-      add_xml_data(doc, node,NULL);
-  }
-
-}
 
 /* ==================================== */
 /* read an xml file into our memory structures and update our view,
    dump any old data we have in memory if we can load a new set */
-static gboolean read_xml_file(char *fname)
+gboolean missing_read_xml_file(char *fname, GList **list)
 {
   /* pointer to the new doc */
   xmlDocPtr doc;
+  xmlNodePtr node;
 
   g_return_val_if_fail(fname!=NULL,FALSE);
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
 
   /* in case something went wrong */
   if(!doc)
@@ -670,17 +668,21 @@
     return FALSE;
   }
 
-  parse_doc(doc);
+  for(node = doc->children->children; node != NULL; node = node->next) {
+    if ( g_strcasecmp((gchar *)node->name, "Board") == 0 )
+      add_xml_data(doc, node, list);
+  }
   xmlFreeDoc(doc);
   return TRUE;
 }
+
 /* ======================================= */
-static void destroy_board_list() {
+void missing_destroy_board_list(GList *list) {
   Board *board;
-  while(g_list_length(board_list)>0)
+  while(g_list_length(list)>0)
     {
-      board = g_list_nth_data(board_list, 0);
-      board_list = g_list_remove (board_list, board);
+      board = g_list_nth_data(list, 0);
+      list = g_list_remove (list, board);
       destroy_board(board);
     }
 }
@@ -722,14 +724,14 @@
 static GcomprisConfCallback conf_ok(GHashTable *table)
 {
   if (!table){
-    if (gcomprisBoard)
+    if (gcomprisBoard_missing)
       pause_board(FALSE);
     return NULL;
   }
 
   g_hash_table_foreach(table, (GHFunc) save_table, NULL);
 
-  if (gcomprisBoard){
+  if (gcomprisBoard_missing){
     gc_locale_reset();
 
     GHashTable *config;
@@ -744,8 +746,6 @@
     if (profile_conf)
       g_hash_table_destroy(config);
 
-    destroy_board_list();
-
     init_xml();
 
     missing_letter_next_level();
@@ -754,6 +754,7 @@
 
     board_conf = NULL;
   profile_conf = NULL;
+  pause_board(FALSE);
 
   return NULL;
 }
@@ -765,7 +766,7 @@
   board_conf = agcomprisBoard;
   profile_conf = aProfile;
 
-  if (gcomprisBoard)
+  if (gcomprisBoard_missing)
     pause_board(TRUE);
 
   gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"),
@@ -783,7 +784,7 @@
   gchar *locale = g_hash_table_lookup( config, "locale");
 
   gc_board_config_combo_locales(bconf, locale);
-
+  config_missing_letter(bconf);
 }
 
 

Modified: branches/GCOMPRIS_8_3/src/boards/python/admin/board_list.py
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/python/admin/board_list.py	(original)
+++ branches/GCOMPRIS_8_3/src/boards/python/admin/board_list.py	Tue Feb 17 23:18:08 2009
@@ -167,13 +167,6 @@
       self.button_locales_sound.show()
       box3.pack_end(self.button_locales_sound, False, False, 0)
 
-      self.button_wordlist = gtk.Button(_('Wordlist'))
-      self.button_wordlist.connect("clicked", self.wordlist)
-      self.button_wordlist.show()
-      box3.pack_end(self.button_wordlist, False, False, 0)
-      #not ready yet
-      self.button_wordlist.set_sensitive(False)
-
       self.button_login = gtk.Button(_('Login'))
       self.button_login.connect("clicked", self.login_configure)
       self.button_login.show()

Modified: branches/GCOMPRIS_8_3/src/boards/read_colors.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/read_colors.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/read_colors.c	Tue Feb 17 23:18:08 2009
@@ -473,7 +473,7 @@
   g_return_val_if_fail(fname!=NULL,FALSE);
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
 
   /* in case something went wrong */
   if(!doc)

Modified: branches/GCOMPRIS_8_3/src/boards/reading.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/reading.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/reading.c	Tue Feb 17 23:18:08 2009
@@ -458,7 +458,15 @@
       word = g_strdup(textToFind);
     }
 
-  g_assert(word!=NULL);
+  if(word==NULL)
+  {
+  	gc_dialog(_("Skip this level. Not enough word in the list !"),
+		(DialogBoxCallBack)reading_next_level);
+	gcomprisBoard->level++;
+	if(gcomprisBoard->level>gcomprisBoard->maxlevel) // the current board is finished : bail out
+		gc_bonus_end_display(GC_BOARD_FINISHED_RANDOM);
+	return FALSE;
+  }
 
   if(textToFindIndex>=0)
     textToFindIndex--;
@@ -777,6 +785,7 @@
 get_random_word(const gchar* except)
 {
   gchar *word;
+  int count=0;
 
   word = gc_wordlist_random_word_get(gc_wordlist, gcomprisBoard->level);
 
@@ -784,6 +793,12 @@
     while(strcmp(except, word)==0)
       {
 	g_free(word);
+
+	if(count++>100)
+	{
+		word = NULL;
+		break;
+	}
 	word = gc_wordlist_random_word_get(gc_wordlist, gcomprisBoard->level);
       }
 

Modified: branches/GCOMPRIS_8_3/src/boards/shapegame.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/shapegame.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/shapegame.c	Tue Feb 17 23:18:08 2009
@@ -1743,7 +1743,7 @@
   g_return_val_if_fail(fname!=NULL,FALSE);
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
   /* in case something went wrong */
   if(!doc)
     return FALSE;

Modified: branches/GCOMPRIS_8_3/src/boards/superbrain.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/superbrain.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/superbrain.c	Tue Feb 17 23:18:08 2009
@@ -618,6 +618,10 @@
 
   current_y_position -= Y_STEP;
 
+  GList *l;
+  for(l=listPieces; l; l= l->next)
+  	g_free(l->data);
+
   g_list_free(listPieces);
 
   superbrain_create_item(boardRootItem);

Modified: branches/GCOMPRIS_8_3/src/boards/wordprocessor.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/wordprocessor.c	(original)
+++ branches/GCOMPRIS_8_3/src/boards/wordprocessor.c	Tue Feb 17 23:18:08 2009
@@ -1027,7 +1027,7 @@
   GtkTextIter iter_start, iter_end;
 
   /* parse the new file and put the result into newdoc */
-  doc = gc_net_load_xml(file);
+  doc = xmlParseFile(file);
 
   /* in case something went wrong */
   if(!doc)

Modified: branches/GCOMPRIS_8_3/src/gcompris/Makefile.am
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/Makefile.am	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/Makefile.am	Tue Feb 17 23:18:08 2009
@@ -77,7 +77,6 @@
 	board_config.h board_config.c \
 	bonus.c \
 	bonus.h \
-	cache.c \
 	config.c \
 	dialog.c \
 	drag.c \

Modified: branches/GCOMPRIS_8_3/src/gcompris/board_config_wordlist.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/board_config_wordlist.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/board_config_wordlist.c	Tue Feb 17 23:18:08 2009
@@ -49,7 +49,7 @@
 	}
 
 	wordsArray = g_malloc0(sizeof(gpointer)*(g_slist_length(lw->words)+1));
-	
+
 	for(i=0, list = lw->words; list; list=list->next)
 	{
 		wordsArray[i]=(gchar*)list->data;
@@ -118,6 +118,22 @@
 	gtk_widget_set_sensitive(GTK_WIDGET(u->button), TRUE);
 }
 
+static void _return_clicked(GtkWidget *w, gpointer data)
+{
+	int level;
+	user_param_type_wordlist *u = (user_param_type_wordlist*)data;
+	gchar *filename;
+
+	filename = gc_file_find_absolute_writeable(u->wordlist->filename);
+	gc_cache_remove(filename);
+	g_free(filename);
+
+	level = gtk_combo_box_get_active(u->combo_level)+1;
+	_combo_lang_changed(u->combo_lang, u);
+	gtk_combo_box_set_active(u->combo_level, level-1);
+	_combo_level_changed(u->combo_level, u);
+}
+
 static void _button_clicked(GtkWidget *w, gpointer data)
 {
 	user_param_type_wordlist *u = (user_param_type_wordlist*)data;
@@ -143,7 +159,7 @@
 static void _destroy(GtkWidget *w, gpointer data)
 {
 	user_param_type_wordlist *u = (user_param_type_wordlist*)data;
-	
+
 	gc_wordlist_free(u->wordlist);
 	g_free(u);
 }
@@ -161,7 +177,7 @@
 	const gchar *locale;
 
 	/* frame */
-	frame = gtk_frame_new("Change wordlist");
+	frame = gtk_frame_new(_("Configure the list of words"));
 	gtk_widget_show(frame);
 	gtk_box_pack_start(GTK_BOX(config->main_conf_box), frame, FALSE, FALSE, 8);
 
@@ -190,7 +206,7 @@
 
 	gtk_widget_show(combo_lang);
 	hbox = gtk_hbox_new(FALSE, 8);
-	label = gtk_label_new(_("Choice language"));
+	label = gtk_label_new(_("Choice of the language"));
 	gtk_widget_show(label);
 	gtk_widget_show(hbox);
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
@@ -202,7 +218,7 @@
 
 	gtk_widget_show(combo_level);
 	hbox = gtk_hbox_new(FALSE, 8);
-	label = gtk_label_new(_("Choice level"));
+	label = gtk_label_new(_("Choice of the level"));
 	gtk_widget_show(label);
 	gtk_widget_show(hbox);
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
@@ -223,10 +239,18 @@
 	gtk_container_add (GTK_CONTAINER(scroll), textview);
 
 	/* valid button */
+	hbox = gtk_hbox_new(FALSE, 8);
+	gtk_widget_show(hbox);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8);
+
+	GtkWidget * b_default = gtk_button_new_with_label(_("Back to default"));
+	gtk_widget_show(b_default);
+	gtk_box_pack_start(GTK_BOX(hbox), b_default, FALSE, FALSE, 8);
+
 	button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
 	gtk_widget_show(button);
 	gtk_widget_set_sensitive(button, FALSE);
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 8);
+	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 8);
 
 	/* user_data */
 	user_data = g_malloc0(sizeof(user_param_type_wordlist));
@@ -246,6 +270,8 @@
 		G_CALLBACK(_textview_changed), (gpointer)user_data);
 	g_signal_connect(G_OBJECT(button), "clicked",
 		G_CALLBACK(_button_clicked), (gpointer)user_data);
+	g_signal_connect(G_OBJECT(b_default), "clicked",
+		G_CALLBACK(_return_clicked), (gpointer)user_data);
 
 
 	_combo_lang_changed(GTK_COMBO_BOX(combo_lang), user_data);

Modified: branches/GCOMPRIS_8_3/src/gcompris/config.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/config.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/config.c	Tue Feb 17 23:18:08 2009
@@ -630,7 +630,7 @@
 
   if(filename)
     {
-      pixmap = gc_net_load_pixmap(filename);
+      pixmap = gdk_pixbuf_new_from_file(filename,NULL);
 
       gnome_canvas_item_set (item_locale_flag,
 			     "pixbuf", pixmap,

Modified: branches/GCOMPRIS_8_3/src/gcompris/dialog.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/dialog.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/dialog.c	Tue Feb 17 23:18:08 2009
@@ -27,9 +27,6 @@
 static GnomeCanvasItem *itemDialogText = NULL;
 static gint item_event_ok(GnomeCanvasItem *item, GdkEvent *event, DialogBoxCallBack dbcb);
 
-typedef void (*sighandler_t)(int);
-
-
 /*
  * Close the dialog box if it was open. It not, do nothing.
  */

Modified: branches/GCOMPRIS_8_3/src/gcompris/gameutil.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gameutil.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gameutil.c	Tue Feb 17 23:18:08 2009
@@ -32,10 +32,6 @@
 
 #include "gcompris.h"
 
-extern GnomeCanvas *canvas;
-
-typedef void (*sighandler_t)(int);
-
 /* GdkPixbuf RGBA C-Source image dump for a NULL image*/
 #ifdef __SUNPRO_C
 #pragma align 4 (null_img)
@@ -87,7 +83,7 @@
   filename = gc_file_find_absolute(pixmapfile);
 
   if(filename)
-    pixmap = gc_net_load_pixmap(filename);
+     pixmap = gdk_pixbuf_new_from_file(filename,NULL);
 
   if (!filename || !pixmap)
     {
@@ -542,8 +538,7 @@
   va_end (args);
 
   /* Check it's already found */
-  if( g_file_test (filename, G_FILE_TEST_EXISTS)
-      || gc_net_is_url(filename) )
+  if( g_file_test (filename, G_FILE_TEST_EXISTS))
     {
       return filename;
     }
@@ -552,6 +547,9 @@
    * Search it on the file system
    */
 
+  if(properties->server)
+  	dir_to_search[i++] = "";
+  dir_to_search[i++] = properties->user_dir;
   dir_to_search[i++] = properties->package_data_dir;
   dir_to_search[i++] = NULL;
 
@@ -602,6 +600,7 @@
 		  g_free(filename2);
 		  goto FOUND;
 		}
+	      g_free(absolute_filename);
 
 	      /* Now check if this file is on the net */
 	      if((absolute_filename = gc_net_get_url_from_file(filename2, NULL)))
@@ -640,6 +639,35 @@
   return absolute_filename;
 }
 
+gchar*
+gc_file_find_absolute_writeable(const gchar *format, ...)
+{
+  gchar *filename, *absolute_filename, *dirname;
+  GcomprisProperties *prop;
+  va_list args;
+
+  va_start (args, format);
+  filename = g_strdup_vprintf (format, args);
+  va_end (args);
+
+  prop = gc_prop_get();
+  absolute_filename = g_build_filename(prop->user_dir, filename,NULL);
+  g_free(filename);
+  dirname = g_path_get_dirname(absolute_filename);
+  if(!g_file_test(dirname, G_FILE_TEST_IS_DIR))
+    {
+      if(g_mkdir_with_parents(dirname, 0755))
+      {
+      	g_free(absolute_filename);
+	absolute_filename=NULL;
+      }
+    }
+  g_free(dirname);
+  if(absolute_filename)
+  	gc_cache_add(absolute_filename);
+  return absolute_filename;
+}
+
 /** Create a directory if needed.
  *
  * \param rootdir: the directory to create

Modified: branches/GCOMPRIS_8_3/src/gcompris/gameutil.h
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gameutil.h	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gameutil.h	Tue Feb 17 23:18:08 2009
@@ -63,6 +63,7 @@
 
 /* find the complete filename looking for the file everywhere (printf formatting supported) */
 gchar		 *gc_file_find_absolute(const gchar *filename, ...);
+gchar		 *gc_file_find_absolute_writeable(const gchar *filename, ...);
 int               gc_util_create_rootdir (gchar *rootdir);
 
 void		 gc_activity_intro_play (GcomprisBoard *gcomprisBoard);

Modified: branches/GCOMPRIS_8_3/src/gcompris/gc_core.h
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gc_core.h	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gc_core.h	Tue Feb 17 23:18:08 2009
@@ -49,11 +49,4 @@
 /** log */
 void gc_log_start (GcomprisBoard *gcomprisBoard);
 
-/** cache */
-void gc_cache_init(int max_size);
-void gc_cache_end();
-void gc_cache_clear();
-gchar *gc_cache_get(gchar *url);
-gchar *gc_cache_insert(const gchar *url, const char *buffer, gssize length);
-
 #endif

Modified: branches/GCOMPRIS_8_3/src/gcompris/gc_net.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gc_net.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gc_net.c	Tue Feb 17 23:18:08 2009
@@ -21,10 +21,11 @@
 
 #include "gc_net.h"
 #include "gc_core.h"
-
+#include <string.h>
 #ifdef USE_GNET
 #include <gnet.h>
 #endif
+#include <glib/gstdio.h>
 
 /* FIXME: Should not be needed, a bug in gnet header ? */
 gboolean         gnet_http_get                     (const gchar      *url,
@@ -32,17 +33,33 @@
                                                     gsize            *length,
                                                     guint            *response);
 
-#include <string.h>
-
 #ifdef USE_GNET
-static GSList *server_content_list = NULL;
+static GHashTable *server_content = NULL;
 #define	SUPPORT_OR_RETURN(rv)	{if(!gc_prop_get()->server) return rv;}
 #else
 #define	SUPPORT_OR_RETURN(rv)	{ return rv; }
 #endif
 
+static void load_md5file(GHashTable *ht, gchar *content)
+{
+	gchar **lines, **keyval;
+	int i;
 
-static inline int my_strcmp(gchar *a, gchar *b) { return strcmp( a, b); }
+	lines = g_strsplit(content, "\n", 0);
+	if(lines && lines[0])
+	{
+		for(i=0; lines[i]; i++)
+		{
+			keyval = g_strsplit(lines[i], "  ", 2);
+			if(keyval && keyval[0])
+			{
+				g_hash_table_insert(ht, g_strdup(keyval[1]), g_strdup(keyval[0]));
+			}
+			g_strfreev(keyval);
+		}
+	}
+	g_strfreev(lines);
+}
 
 /** Init the network library, must be called once before using it
  *
@@ -70,15 +87,8 @@
 
   if(gnet_http_get(url, &buf, &buflen, &response) && response == 200)
     {
-      char line[200];
-      int i = 0;
-      /* Parse each line of the buffer and save it in 'server_content_list' */
-      while( i < buflen)
-	{
-	  sscanf(buf+i, "%s", (char *)&line);
-	  server_content_list = g_slist_prepend(server_content_list, g_strdup(line));
-	  i+=strlen(line)+1;
-	}
+      server_content = g_hash_table_new(g_str_hash, g_str_equal);
+	  load_md5file(server_content, buf);
     }
   else
     {
@@ -93,81 +103,11 @@
 #endif
 }
 
-/** Load a pixmap localy or from the network
- *
- * \param pixmapfile : a full URL to the file to load as an image
- *                     in case a local file is given, it will be loaded.
- * \return a GdkPixbuf or NULL
- */
-GdkPixbuf *gc_net_load_pixmap(const char *url)
+void gc_net_destroy(void)
 {
-  if(!gc_net_is_url(url))
-    return(gdk_pixbuf_new_from_file (url, NULL));
-
-  SUPPORT_OR_RETURN(NULL);
-
-#ifdef USE_GNET
-  gchar *buf = NULL;
-  gsize  buflen;
-  guint  response;
-
-  g_warning("Loading image from url '%s'", url);
-
-  if(gnet_http_get(url, &buf, &buflen, &response) && response == 200)
-    {
-      GdkPixbuf *pixmap=NULL;
-      GdkPixbufLoader* loader;
-      loader = gdk_pixbuf_loader_new();
-      gdk_pixbuf_loader_write(loader, (guchar *)buf, buflen, NULL);
-      g_free(buf);
-      gdk_pixbuf_loader_close(loader, NULL);
-      pixmap = gdk_pixbuf_loader_get_pixbuf(loader);
-      if(!pixmap)
-	g_warning("Loading image from url '%s' returned a null pointer", url);
-
-      return(pixmap);
-    }
-
-  g_free(buf);
-  return(NULL);
-
-#endif
-}
-
-/** Load an xml file from the network
- *
- * \param xmlfile : a full URL to the xml file to load as an xmlDocPtr
- *                     in case a local file is given, it will be loaded.
- * \return a xmlDocPtr or NULL
- */
-xmlDocPtr gc_net_load_xml(const char *url)
-{
-  if(!gc_net_is_url(url))
-    return(xmlParseFile(url));
-
-  SUPPORT_OR_RETURN(NULL);
-
-#ifdef USE_GNET
-  gchar *buf = NULL;
-  gsize  buflen;
-  guint  response;
-
-  g_warning("Loading xml file from url '%s'", url);
-
-  if(gnet_http_get(url, &buf, &buflen, &response) && response == 200)
-    {
-      xmlDocPtr	doc = xmlParseMemory((const char *)buf, buflen);
-      g_free(buf);
-      if(!buf)
-	g_warning("Loading xml file from url '%s' returned a null pointer", url);
-
-      return(doc);
-    }
-
-  g_free(buf);
-  return(NULL);
-
-#endif
+  if(server_content)
+    g_hash_table_destroy(server_content);
+  server_content = NULL;
 }
 
 /** return an absolute URL if the given file is part of the file available on our server
@@ -182,51 +122,70 @@
 
 #ifdef USE_GNET
   GcomprisProperties *properties = gc_prop_get();
-  gchar *file, *url;
+  gchar *file, *cache=NULL, *value;
   va_list args;
+  gboolean cache_ok=FALSE;
 
   va_start (args, format);
   file = g_strdup_vprintf (format, args);
   va_end (args);
 
-  /* FIXME: In case the file does not starts with boards/, preprend it */
+  g_warning("gc_net_get_url_from_file '%s'", file);
+  
+  value = g_hash_table_lookup(server_content, (gpointer) file);
+  if(value)
   {
-    if(strncmp(file, "boards/", 7))
-      {
-	gchar *file2 = g_strconcat("boards/", file, NULL);
-	g_free(file);
-	file = file2;
-      }
-  }
+    cache = g_strconcat(properties->cache_dir, "/", file, NULL);
+    if(g_file_test(cache, G_FILE_TEST_IS_REGULAR))
+    {
+      gchar * content;
+      gsize length;
+      GMD5 *md5cache, *md5serv;
 
-  g_warning("gc_net_get_url_from_file '%s'", file);
-  if(!g_slist_find_custom(server_content_list,(gconstpointer) file, (GCompareFunc) my_strcmp))
+      /* calc md5 of cache file */
+      g_file_get_contents(cache, &content, &length, NULL);
+      md5cache = gnet_md5_new(content, length);
+      g_free(content);
+
+      md5serv = gnet_md5_new_string(value);
+
+      cache_ok = gnet_md5_equal(md5serv, md5cache);
+
+      gnet_md5_delete(md5serv);
+      gnet_md5_delete(md5cache);
+    }
+    if(cache_ok==0)
     {
-      g_free(file);
-      return NULL;
+      gchar *url;
+      gchar *buf = NULL;
+      gsize  buflen;
+      guint  response;
+      
+      url = g_strconcat(properties->server, "/", file, NULL);
+      if(gnet_http_get(url, &buf, &buflen, &response) && response == 200)
+      {
+        gchar *dirname;
+
+	dirname = g_path_get_dirname(cache);
+	g_mkdir_with_parents(dirname, 0755);
+	g_free(dirname);
+        g_file_set_contents(cache, buf, buflen, NULL);
+	g_free(buf);
+      }
+      else
+      { /* file is in content.txt but not in server */
+      	g_free(cache);
+      	cache = NULL;
+      }
     }
-  url = g_strconcat(properties->server, "/", file, NULL);
+  }
   g_free(file);
 
-  g_warning("gc_net_get_url_from_file returns url '%s'", url);
-  return url;
+  return cache;
 #endif
 }
 
-/** return TRUE if the url starts with http://
- *
- * \param url: an url to check
- * \return TRUE is the url starts with 'http://'
- */
-gboolean
-gc_net_is_url(const gchar *url)
-{
-  if( !url || strncmp(url, "http://";, 7) )
-    return FALSE;
-
-  return TRUE;
-}
-
+#if 0
 /** return a glist with the content of the files in the given directory
  *
  * \param dir: the directory to scan
@@ -256,3 +215,157 @@
   return(filelist);
 #endif
 }
+#endif
+
+
+#define CONTENT_FILENAME "content.txt"
+
+static GHashTable *cache_content=NULL;
+
+void gc_cache_init(void)
+{
+	gchar *filename;
+	gchar *buf;
+	gsize buflen;
+
+	cache_content = g_hash_table_new(g_str_hash, g_str_equal);
+	filename = gc_file_find_absolute_writeable(CONTENT_FILENAME);
+
+	if(g_file_get_contents(filename, &buf, &buflen,NULL))
+	{
+		load_md5file(cache_content, buf);
+		g_free(buf);
+	}
+	g_free(filename);
+}
+
+static gchar *gc_cache_get_relative(gchar *filename)
+{
+	gchar *filename_content, *dirname;
+
+	filename_content = gc_file_find_absolute_writeable(CONTENT_FILENAME);
+	dirname = g_path_get_dirname(filename_content);
+	if(g_str_has_prefix(filename, dirname))
+		filename = filename + strlen(dirname) + 1;
+	g_free(filename_content);
+	g_free(dirname);
+	return filename;
+}
+
+void gc_cache_add(gchar *filename)
+{
+	if(cache_content==NULL)
+		return;
+	if(g_str_has_suffix(filename, CONTENT_FILENAME))
+		return;
+
+	filename = gc_cache_get_relative(filename);
+	g_hash_table_insert(cache_content, g_strdup(filename), g_strdup("0"));
+}
+
+gchar* gc_cache_import_pixmap(gchar *filename, gchar *boarddir, gint width, gint height)
+{
+	GdkPixbuf *pixmap;
+	gchar *basename, *file, *ext, *name, *abs;
+
+	if(!g_path_is_absolute(filename))
+		return g_strdup(filename);
+	basename = g_path_get_basename(filename);
+	name = g_build_filename(boarddir, basename,NULL);
+	abs = gc_file_find_absolute(name);
+	if(abs && strcmp(abs,filename)==0)
+	{
+		g_free(basename);
+		g_free(abs);
+		return name;
+	}
+	pixmap = gdk_pixbuf_new_from_file_at_size(filename, width, height,NULL);
+	if(!pixmap)
+	{
+		g_free(abs);
+		g_free(basename);
+		g_free(name);
+		return NULL;
+	}
+
+	file = gc_file_find_absolute_writeable(name);
+	ext = strchr(basename, '.')+1;
+	if(strcmp(ext, "jpg")==0)
+		ext ="jpeg";
+
+	gdk_pixbuf_save(pixmap, file, ext, NULL,NULL);
+
+	g_free(abs);
+	g_free(basename);
+	g_free(file);
+	return name;
+}
+
+void gc_cache_remove(gchar *filename)
+{
+	g_remove(filename);
+	filename = gc_cache_get_relative(filename);
+	g_hash_table_remove(cache_content, filename);
+}
+
+struct _table_data
+{
+FILE *pf;
+gchar *path;
+};
+
+static void _table_foreach(gpointer key, gpointer value, gpointer user_data)
+{
+	struct _table_data *data = (struct _table_data*)user_data;
+	gchar * content, *filename;
+	gsize length;
+	GMD5 *md5;
+
+	if(strcmp(value, "0")==0)
+	{
+		filename = g_build_filename(data->path, (gchar*)key, NULL);
+		if(g_file_get_contents(filename, &content, &length, NULL))
+		{
+			md5 = gnet_md5_new(content, length);
+			value = gnet_md5_get_string(md5);
+			gnet_md5_delete(md5);
+			g_free(content);
+		}
+		g_free(filename);
+	}
+	if(strcmp(value, "0"))
+	{
+		fprintf(data->pf, "%s  %s\n", (gchar*)value, (gchar*)key);
+	}
+}
+
+void gc_cache_save(void)
+{
+	struct _table_data data;
+	FILE *pf;
+	gchar *filename;
+
+	filename = gc_file_find_absolute_writeable(CONTENT_FILENAME);
+	pf = fopen(filename, "w");
+	if(!pf)
+	{
+		g_warning("Couldn't save %s\n", filename);
+		return;
+	}
+	
+	data.pf = pf;
+	data.path = g_path_get_dirname(filename);
+	g_hash_table_foreach(cache_content, _table_foreach, &data);
+
+	g_free(filename);
+	g_free(data.path);
+	fclose(pf);
+}
+
+void gc_cache_destroy(void)
+{
+	gc_cache_save();
+	g_hash_table_destroy(cache_content);
+	cache_content = NULL;
+}
+

Modified: branches/GCOMPRIS_8_3/src/gcompris/gc_net.h
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gc_net.h	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gc_net.h	Tue Feb 17 23:18:08 2009
@@ -35,10 +35,15 @@
 #include "gcompris.h"
 
 void gc_net_init();
-GdkPixbuf *gc_net_load_pixmap(const char *url);
-xmlDocPtr  gc_net_load_xml(const char *url);
 gchar     *gc_net_get_url_from_file(const gchar *format, ...);
-gboolean   gc_net_is_url(const char *url);
 GSList    *gc_net_dir_read_name(const gchar* dir, const gchar *ext);
+void gc_net_destroy();
+
+void gc_cache_init(void);
+void gc_cache_add(gchar *filename);
+gchar* gc_cache_import_pixmap(gchar *filename, gchar *boarddir, gint width, gint height);
+void gc_cache_remove(gchar *filename);
+void gc_cache_save(void);
+void gc_cache_destroy(void);
 
 #endif

Modified: branches/GCOMPRIS_8_3/src/gcompris/gcompris.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gcompris.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gcompris.c	Tue Feb 17 23:18:08 2009
@@ -675,7 +675,7 @@
   if(!icon_file)
       g_warning ("Couldn't find file %s !", icon_file);
 
-  icon_pixbuf = gc_net_load_pixmap(icon_file);
+  icon_pixbuf = gdk_pixbuf_new_from_file(icon_file,NULL);
   if (!icon_pixbuf)
     {
       g_warning ("Failed to load pixbuf file: %s\n",
@@ -1057,6 +1057,8 @@
   xf86_vidmode_set_fullscreen(FALSE);
 #endif
   gc_menu_destroy();
+  gc_net_destroy();
+  gc_cache_destroy();
   gc_prop_destroy(gc_prop_get());
 }
 
@@ -1692,8 +1694,7 @@
 	  }
 	}
       }
-      /* FIXME: Need to translate */
-      printf("Number of activities: %d\n", board_count);
+      printf(_("Number of activities: %d\n"), board_count);
 
       exit(0);
     }
@@ -1729,7 +1730,7 @@
 	{
 	  if (g_access(properties->database, R_OK)==-1)
 	    {
-	      printf("%s exists but is not readable or writable", properties->database);
+	      printf(_("%s exists but is not readable or writable"), properties->database);
 	      exit(0);
 	    }
 	}
@@ -1788,8 +1789,10 @@
   if (popt_server){
 #ifdef USE_GNET
       properties->server = g_strdup(popt_server);
+      printf("   Server '%s'\n", properties->server);
 #else
-      printf("The --server option cannot be used because GCompris has been compiled without network support!");
+      printf(_("The --server option cannot be used because"
+	       "GCompris has been compiled without network support!"));
       exit(1);
 #endif
   }
@@ -1803,7 +1806,11 @@
   }
 
   if (popt_server){
+    if(popt_cache_dir)
       properties->cache_dir = g_strdup(popt_cache_dir);
+    else
+      properties->cache_dir = g_build_filename(g_get_user_cache_dir(), "gcompris", NULL);
+    printf("   Cache dir '%s'\n",properties->cache_dir);
   }
 
   if (popt_drag_mode){
@@ -1835,7 +1842,8 @@
 
     if(properties->profile == NULL)
       {
-	printf("ERROR: Profile '%s' is not found. Run 'gcompris --profile-list' to list available ones\n",
+	printf(_("ERROR: Profile '%s' is not found."
+		 " Run 'gcompris --profile-list' to list available ones\n"),
 	       popt_profile);
 	exit(1);
       }
@@ -1871,6 +1879,10 @@
 
   /*------------------------------------------------------------*/
 
+  /* networking init */
+  gc_net_init();
+  gc_cache_init();
+
   gc_skin_load(properties->skin);
 
   if(properties->music || properties->fx)
@@ -1879,12 +1891,6 @@
   /* Gdk-Pixbuf */
   gdk_rgb_init();
 
-  /* Cache init */
-  gc_cache_init(-1);
-
-  /* networking init */
-  gc_net_init();
-
   setup_window ();
 
   if (properties->fullscreen)

Modified: branches/GCOMPRIS_8_3/src/gcompris/images_selector.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/images_selector.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/images_selector.c	Tue Feb 17 23:18:08 2009
@@ -277,8 +277,8 @@
 
       g_free(dataseturl);
       dataseturl = g_strconcat("boards/", dataset, NULL);
-
-      filelist = gc_net_dir_read_name(dataseturl, ".xml");
+      /* TODO */
+      filelist = NULL; //gc_net_dir_read_name(dataseturl, ".xml");
 
       for (i = filelist; i != NULL; i = g_slist_next (i))
 	{
@@ -822,7 +822,7 @@
 
   g_return_val_if_fail(fname!=NULL, FALSE);
 
-  doc = gc_net_load_xml(fname);
+  doc = xmlParseFile(fname);
 
   /* in case something went wrong */
   if(!doc)

Modified: branches/GCOMPRIS_8_3/src/gcompris/skin.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/skin.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/skin.c	Tue Feb 17 23:18:08 2009
@@ -271,7 +271,7 @@
       return;
     }
 
-  xmldoc = gc_net_load_xml(xmlfilename);
+  xmldoc = xmlParseFile(xmlfilename);
   g_free(xmlfilename);
 
   if(!xmldoc)

Modified: branches/GCOMPRIS_8_3/src/gcompris/wordlist.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/wordlist.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/wordlist.c	Tue Feb 17 23:18:08 2009
@@ -385,7 +385,7 @@
 		}
 	}
 
-	filename = gc_file_find_absolute(wordlist->filename);
+	filename = gc_file_find_absolute_writeable(wordlist->filename);
 	if(filename)
 	{
 		if(xmlSaveFormatFileEnc(filename, doc, NULL, 1)<0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]