gcompris r3520 - branches/gcomprixogoo/src/gcompris
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3520 - branches/gcomprixogoo/src/gcompris
- Date: Sun, 31 Aug 2008 17:28:30 +0000 (UTC)
Author: bcoudoin
Date: Sun Aug 31 17:28:30 2008
New Revision: 3520
URL: http://svn.gnome.org/viewvc/gcompris?rev=3520&view=rev
Log:
Now, even in database compiled in, if a single activity is requested
we no more reload the database which has the undesired effect to flush it.
Modified:
branches/gcomprixogoo/src/gcompris/gcompris.c
branches/gcomprixogoo/src/gcompris/gcompris_db.c
branches/gcomprixogoo/src/gcompris/gcompris_db.h
Modified: branches/gcomprixogoo/src/gcompris/gcompris.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris.c (original)
+++ branches/gcomprixogoo/src/gcompris/gcompris.c Sun Aug 31 17:28:30 2008
@@ -1492,7 +1492,7 @@
printf(_("Use -l to access an activity directly.\n"));
printf(_("The list of available activities is :\n"));
- gc_db_init();
+ gc_db_init(FALSE /* ENABLE DATABASE */);
gc_board_init();
gc_menu_load();
@@ -1521,8 +1521,7 @@
}
}
}
- /* FIXME: Need to translate */
- printf("Number of activities: %d\n", board_count);
+ printf(_("Number of activities: %d\n"), board_count);
exit(0);
}
@@ -1637,7 +1636,10 @@
* And after a possible alternate database as been provided
*
*/
- gc_db_init();
+ if (popt_root_menu)
+ gc_db_init(TRUE /* DISABLE DATABASE */);
+ else
+ gc_db_init(FALSE /* ENABLE DATABASE */);
/* An alternate profile is requested, check it does exists */
if (popt_profile){
Modified: branches/gcomprixogoo/src/gcompris/gcompris_db.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris_db.c (original)
+++ branches/gcomprixogoo/src/gcompris/gcompris_db.c Sun Aug 31 17:28:30 2008
@@ -22,6 +22,13 @@
#include <glib/gstdio.h>
#ifdef USE_SQLITE
+static gboolean disable_database;
+#define SUPPORT_OR_RETURN(rv) {if(disable_database) return rv;}
+#else
+#define SUPPORT_OR_RETURN(rv) { return rv; }
+#endif
+
+#ifdef USE_SQLITE
static char *escape_quote(const char *input);
static sqlite3 *gcompris_db=NULL;
#endif
@@ -116,9 +123,12 @@
END;"
-int gc_db_init()
+gboolean gc_db_init(gboolean disable_database_)
{
+
#ifdef USE_SQLITE
+ disable_database = disable_database_;
+ SUPPORT_OR_RETURN(FALSE);
gboolean creation = FALSE;
char *zErrMsg;
char **result;
@@ -343,21 +353,25 @@
#endif
}
-void gc_db_exit()
+gboolean gc_db_exit()
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
sqlite3_close(gcompris_db);
g_warning("Database closed");
+ return TRUE;
#endif
}
#define BOARDS_SET_DATE(date) \
"UPDATE informations SET init_date=\'%s\';",date
-void gc_db_set_date(gchar *date)
+gboolean gc_db_set_date(gchar *date)
{
-#ifdef USE_SQLITE
+ SUPPORT_OR_RETURN(FALSE);
+#ifdef USE_SQLITE
char *zErrMsg;
char **result;
int rc;
@@ -380,14 +394,17 @@
sqlite3_free_table(result);
+ return TRUE;
#endif
}
#define BOARDS_UPDATE_VERSION(version) \
"UPDATE informations SET gcompris_version=\'%s\';",version
-void gc_db_set_version(gchar *version)
+gboolean gc_db_set_version(gchar *version)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
char *zErrMsg;
@@ -412,6 +429,7 @@
sqlite3_free_table(result);
+ return TRUE;
#endif
}
@@ -419,6 +437,7 @@
"SELECT gcompris_version, init_date FROM informations;"
gboolean gc_db_check_boards()
{
+ SUPPORT_OR_RETURN(FALSE);
#ifdef USE_SQLITE
char *zErrMsg;
@@ -444,8 +463,6 @@
sqlite3_free_table(result);
return ret_value;
-#else
- return FALSE;
#endif
}
@@ -466,7 +483,7 @@
"SELECT board_id FROM boards WHERE name=\'%s\';",n
-void
+gboolean
gc_db_board_update(guint *board_id,
guint *section_id,
gchar *name,
@@ -488,6 +505,8 @@
gchar *credit
)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
char *zErrMsg;
@@ -632,6 +651,7 @@
sqlite3_free(request);
+ return TRUE;
#endif
}
@@ -641,6 +661,8 @@
GList *gc_menu_load_db(GList *boards_list)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GcomprisProperties *properties = gc_prop_get();
@@ -712,8 +734,6 @@
return boards;
-#else
- return NULL;
#endif
}
@@ -728,6 +748,8 @@
GList *gc_db_get_board_id(GList *list)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GList *board_id_list = list;
@@ -763,16 +785,16 @@
return board_id_list;
-#else
- return list;
#endif
}
#define DELETE_BOARD(table, board_id) \
"DELETE FROM %s WHERE board_id=%d;", table, board_id
-void gc_db_remove_board(int board_id)
+gboolean gc_db_remove_board(int board_id)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -833,6 +855,8 @@
}
g_free(request);
+
+ return TRUE;
#endif
}
@@ -851,6 +875,8 @@
GcomprisProfile *gc_db_get_profile_from_id(gint profile_id)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
GcomprisProfile *profile = NULL;
@@ -958,8 +984,6 @@
}
return profile;
-#else
- return NULL;
#endif
}
@@ -972,6 +996,8 @@
GcomprisProfile *
gc_db_profile_from_name_get(gchar *profile_name)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
GcomprisProfile *profile = NULL;
@@ -1010,8 +1036,6 @@
return profile;
-#else
- return NULL;
#endif
}
@@ -1022,6 +1046,8 @@
GcomprisProfile *gc_db_get_profile()
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1048,8 +1074,6 @@
return gc_db_get_profile_from_id(profile_id);
-#else
- return NULL;
#endif
}
@@ -1058,6 +1082,8 @@
GList *gc_db_users_from_group_get(gint group_id)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1113,6 +1139,8 @@
GcomprisUser *gc_db_get_user_from_id(gint user_id)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1155,8 +1183,6 @@
return user ;
-#else
- return NULL;
#endif
}
@@ -1168,6 +1194,8 @@
GcomprisClass *gc_db_get_class_from_id(gint class_id)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1247,8 +1275,6 @@
}
return class ;
-#else
- return NULL;
#endif
}
@@ -1262,11 +1288,14 @@
#define UPDATE_KEY \
"UPDATE board_profile_conf SET conf_value=%Q WHERE profile_id=%d AND board_id=%d AND conf_key=%Q;"
-void gc_db_set_board_conf(GcomprisProfile *profile,
- GcomprisBoard *board,
- gchar *key,
- gchar *value)
+gboolean
+gc_db_set_board_conf(GcomprisProfile *profile,
+ GcomprisBoard *board,
+ gchar *key,
+ gchar *value)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1336,16 +1365,21 @@
sqlite3_free(request);
}
+
+ return TRUE;
#endif
}
#define GET_CONF(p, b) \
"SELECT conf_key, conf_value FROM board_profile_conf WHERE profile_id=%d AND board_id=%d;", p, b
-GHashTable *gc_db_conf_with_table_get(int profile_id, int board_id, GHashTable *table )
+GHashTable *gc_db_conf_with_table_get(int profile_id, int board_id,
+ GHashTable *table )
{
GHashTable *hash_conf = table;
+ SUPPORT_OR_RETURN(hash_conf);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1387,18 +1421,19 @@
}
sqlite3_free_table(result);
-#endif
+
return hash_conf;
+#endif
}
GHashTable *gc_db_get_conf(GcomprisProfile *profile, GcomprisBoard *board )
{
GHashTable *hash_result = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ SUPPORT_OR_RETURN(hash_result);
+
#ifdef USE_SQLITE
return gc_db_conf_with_table_get( profile->profile_id, board->board_id, hash_result) ;
-#else
- return hash_result;
#endif
}
@@ -1434,6 +1469,8 @@
GList *gc_db_profiles_list_get()
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
@@ -1552,8 +1589,6 @@
sqlite3_free_table(result);
return profiles_list;
-#else
- return NULL;
#endif
}
@@ -1562,6 +1597,8 @@
GcomprisGroup *gc_db_get_group_from_id(int group_id)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
char *zErrMsg;
@@ -1607,8 +1644,6 @@
return group ;
-#else
- return NULL;
#endif
}
@@ -1617,6 +1652,8 @@
GList *gc_db_get_groups_list()
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GList *groups_list = NULL;
@@ -1661,9 +1698,6 @@
}
return groups_list;
-
-#else
- return NULL;
#endif
}
@@ -1673,6 +1707,8 @@
GcomprisBoard *gc_db_get_board_from_id(int board_id)
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GcomprisProperties *properties = gc_prop_get();
@@ -1743,8 +1779,6 @@
sqlite3_free_table(result);
return gcomprisBoard;
-#else
- return NULL;
#endif
}
@@ -1753,6 +1787,8 @@
GList *gc_db_get_users_list()
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GList *users_list = NULL;
@@ -1797,9 +1833,6 @@
}
return users_list;
-
-#else
- return NULL;
#endif
}
@@ -1808,6 +1841,8 @@
GList *gc_db_get_classes_list()
{
+ SUPPORT_OR_RETURN(NULL);
+
#ifdef USE_SQLITE
GList *classes_list = NULL;
@@ -1850,9 +1885,6 @@
}
return classes_list;
-
-#else
- return NULL;
#endif
}
@@ -1862,6 +1894,8 @@
int gc_db_is_activity_in_profile(GcomprisProfile *profile, char *activity_name)
{
+ SUPPORT_OR_RETURN(TRUE);
+
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
@@ -1893,20 +1927,19 @@
/* IS NOT IN THE PROFILE */
return FALSE;
-
-#else
- return TRUE;
#endif
}
/** \brief insert a new log in the database
*
*/
-void gc_db_log(gchar *date, int duration,
- int user_id, int board_id,
- int level, int sublevel,
- int status, gchar *comment)
+gboolean gc_db_log(gchar *date, int duration,
+ int user_id, int board_id,
+ int level, int sublevel,
+ int status, gchar *comment)
{
+ SUPPORT_OR_RETURN(FALSE);
+
#ifdef USE_SQLITE
char *zErrMsg;
int rc;
@@ -1924,6 +1957,8 @@
if(comment)
g_free(comment_quoted);
+
+ return TRUE;
#endif
}
Modified: branches/gcomprixogoo/src/gcompris/gcompris_db.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris_db.h (original)
+++ branches/gcomprixogoo/src/gcompris/gcompris_db.h Sun Aug 31 17:28:30 2008
@@ -25,16 +25,16 @@
#endif
/* Database management */
-int gc_db_init();
-void gc_db_exit();
+int gc_db_init(gboolean disable_database);
+gboolean gc_db_exit();
gboolean gc_db_check_boards();
-void gc_db_set_date(gchar *date);
+gboolean gc_db_set_date(gchar *date);
-void gc_db_set_version(gchar *version);
+gboolean gc_db_set_version(gchar *version);
-void gc_db_board_update(guint *board_id,
+gboolean gc_db_board_update(guint *board_id,
guint *section_id,
gchar *name,
gchar *section,
@@ -55,7 +55,7 @@
gchar *credit
);
-void gc_db_save_user(int *user_id,
+gboolean gc_db_save_user(int *user_id,
gchar *login,
gchar *name,
gchar *firstname,
@@ -68,7 +68,7 @@
GList *gc_db_get_board_id(GList *list);
-void gc_db_remove_board(int board_id);
+gboolean gc_db_remove_board(int board_id);
/* Profile management */
@@ -96,7 +96,7 @@
GList *gc_db_users_from_group_get(gint group_id);
-void gc_db_set_board_conf(GcomprisProfile *profile,
+gboolean gc_db_set_board_conf(GcomprisProfile *profile,
GcomprisBoard *board,
gchar *key,
gchar *value);
@@ -117,7 +117,7 @@
int gc_db_is_activity_in_profile(GcomprisProfile *profile, char *activity_name);
-void gc_db_log(gchar *date, int duration,
+gboolean gc_db_log(gchar *date, int duration,
int user_id, int board_id,
int level, int sublevel,
int status, gchar *comment);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]