Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/gcompris
diff options
context:
space:
mode:
authorBruno Coudoin <bruno.coudoin@free.fr>2009-08-31 21:13:52 (GMT)
committer Bruno Coudoin <bruno.coudoin@free.fr>2009-08-31 21:13:52 (GMT)
commit1790d49f60a86ed5d937d1c94f72ab31e53e8aa9 (patch)
tree351ba7ac3dffb286965a5eb38a15265b04460e8c /src/gcompris
parentd523dc47a383650f76ce08157989c6d6d9342f1b (diff)
Better support for demonstration.
Diffstat (limited to 'src/gcompris')
-rw-r--r--src/gcompris/board.c6
-rw-r--r--src/gcompris/gcompris.c29
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");