[gcompris/gcomprixogoo] Fixes for demo activation code to work again.



commit ac649c9a647267d59ae06957fa139b6d95ea153e
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sat Feb 6 16:32:34 2010 +0100

    Fixes for demo activation code to work again.

 src/gcompris/board.c    |    2 +-
 src/gcompris/gcompris.c |   28 ++++++++++++++++++----------
 2 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/src/gcompris/board.c b/src/gcompris/board.c
index 2a7c75f..ca70c01 100644
--- a/src/gcompris/board.c
+++ b/src/gcompris/board.c
@@ -239,7 +239,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 715ae0a..fda24e1 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -78,6 +78,7 @@ static void single_instance_release();
 /*
  * For the Activation dialog
  */
+#define STATIC_MODULE 1
 #ifdef STATIC_MODULE
 int gc_activation_check(const char *code);
 static void activation_enter_callback(GtkWidget *widget,
@@ -870,13 +871,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)
     {
@@ -929,8 +935,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  if the code is valid and under 2 years
  */
-int gc_activation_check(const char *code)
+gint gc_activation_check(const char *code)
 {
 #ifdef  DISABLE_ACTIVATION_CODE
   return 1;
@@ -944,6 +951,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;
@@ -987,17 +1001,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]