[gcompris] Better support for demonstration.



commit 1790d49f60a86ed5d937d1c94f72ab31e53e8aa9
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Mon Aug 31 23:13:52 2009 +0200

    Better support for demonstration.

 src/gcompris/board.c    |    6 +++---
 src/gcompris/gcompris.c |   29 ++++++++++++++++++-----------
 2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/gcompris/board.c b/src/gcompris/board.c
index 6861f94..6b0ab0a 100644
--- a/src/gcompris/board.c
+++ b/src/gcompris/board.c
@@ -28,7 +28,7 @@ static struct BoardPluginData *bp_data;
 static gboolean	 get_board_playing(void);
 
 #ifdef STATIC_MODULE
-int gc_activation_check(char *code);
+gint gc_activation_check(char *code);
 extern BoardPlugin * get_advanced_colors_bplugin_info();
 extern BoardPlugin * get_algebra_bplugin_info();
 extern BoardPlugin * get_algebra_guesscount_bplugin_info();
@@ -220,7 +220,7 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
   GcomprisProperties	*properties = gc_prop_get();
   BoardPlugin *bp;
   guint        i=0;
-  guint        key_is_valid = 0;
+  gint         key_is_valid = 0;
 
   g_assert(gcomprisBoard!=NULL);
   g_assert(properties->key!=NULL);
@@ -236,7 +236,7 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
     key_is_valid = gc_activation_check(properties->key);
 
   i = 0;
-  if(key_is_valid == 1)
+  if(key_is_valid >= 1)
     {
       while(static_boards[i++] != NULL) {
 
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 7c901c4..d4208a5 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -73,7 +73,7 @@ static void single_instance_release();
  * For the Activation dialog
  */
 #ifdef STATIC_MODULE
-int gc_activation_check(const char *code);
+gint gc_activation_check(const char *code);
 static void activation_enter_callback(GtkWidget *widget,
 				      GtkWidget *entry );
 static void activation_done();
@@ -815,13 +815,18 @@ display_activation_dialog()
   int board_count = 0;
   int gc_board_number_in_demo = 0;
   GList *list;
-  guint  key_is_valid = 0;
+  gint  key_is_valid = 0;
 
   key_is_valid = gc_activation_check(properties->key);
 
   if(key_is_valid == 1)
     return FALSE;
-
+  else if(key_is_valid == 2)
+    {
+      g_free ( gc_prop_get()->key );
+      gc_prop_get()->key = strdup("");
+      gc_prop_save(properties);
+    }
   /* Count non menu boards */
   for (list = gc_menu_get_boards(); list != NULL; list = list->next)
     {
@@ -869,8 +874,9 @@ display_activation_dialog()
  * Return -1 if the code is not valid
  *        0  if the code is valid but out of date
  *        1  if the code is valid and under 2 years
+ *        2  this is a demo code, must request the code again
  */
-int gc_activation_check(const char *code)
+gint gc_activation_check(const char *code)
 {
 #ifdef  DISABLE_ACTIVATION_CODE
   return 1;
@@ -884,6 +890,13 @@ int gc_activation_check(const char *code)
   if(strlen(code) != 6)
     return -1;
 
+  // A special code to test the full version without
+  // saving the activation
+  if (strncmp(code, "123321", 6) == 0)
+    {
+      return 2;
+    }
+
   for(i=3; i>=0; i--)
     {
       value |= code[i] & 0x07;
@@ -927,17 +940,11 @@ activation_enter_callback( GtkWidget *entry,
 			   GtkWidget *notused )
 {
   const char *code = gtk_entry_get_text(GTK_ENTRY(entry));
-  // A special code to test the full version without
-  // saving the activation
-  if (strncmp(code, "123321", 6) == 0)
-    {
-      gtk_entry_set_text(GTK_ENTRY(entry), "GOOD");
-      return;
-    }
 
   switch(gc_activation_check(code))
     {
     case 1:
+    case 2:
       gc_prop_get()->key = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
       gc_prop_save(properties);
       gtk_entry_set_text(GTK_ENTRY(entry), "GOOD");



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