summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-07-22 21:23:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-07-22 21:23:49 (GMT)
commit21537636cd8318cf5a720211619ad3c3023b52e9 (patch)
tree93380a9152f18e39cf0ba427ede96533c5c6f16a /src/core
parent361a0953c73635c6c383516280a8d634768f8226 (diff)
Fortified the client/server protocol and first exchanges.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@554 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/core')
-rw-r--r--src/core/collections.c38
-rw-r--r--src/core/collections.h7
2 files changed, 17 insertions, 28 deletions
diff --git a/src/core/collections.c b/src/core/collections.c
index c867d57..08c97e1 100644
--- a/src/core/collections.c
+++ b/src/core/collections.c
@@ -32,20 +32,13 @@
#include "../analysis/db/collection.h"
#include "../analysis/db/protocol.h"
#include "../analysis/db/items/bookmark.h"
+#include "../analysis/db/items/comment.h"
+#include "../analysis/db/items/switcher.h"
-/* Caractéristiques d'une collection */
-typedef struct _collec_t
-{
- GType items; /* Type d'éléments rassemblés */
- create_db_table_fc create; /* Création de la BD associée */
-
-} collec_t;
-
-
/* Mémorisation des types de collection enregistrés */
-static collec_t *_collection_definitions = NULL;
+static GType *_collection_definitions = NULL;
static uint32_t _collection_definitions_count = 0;
/* Verrou pour des accès atomiques */
@@ -55,8 +48,7 @@ static uint32_t _collection_definitions_count = 0;
/******************************************************************************
* *
-* Paramètres : items = type GLib des éléments constituant une collection. *
-* create = création de la base de données correspondante. *
+* Paramètres : items = type GLib des éléments constituant une collection. *
* *
* Description : Enregistre un type d'élément à gérer par collection. *
* *
@@ -66,7 +58,7 @@ static uint32_t _collection_definitions_count = 0;
* *
******************************************************************************/
-uint32_t register_collection_type(GType items, create_db_table_fc create)
+uint32_t register_collection_type(GType items)
{
uint32_t result; /* Identifiant à retourner */
@@ -74,11 +66,10 @@ uint32_t register_collection_type(GType items, create_db_table_fc create)
result = _collection_definitions_count++;
- _collection_definitions = (collec_t *)realloc(_collection_definitions,
- _collection_definitions_count * sizeof(collec_t));
+ _collection_definitions = (GType *)realloc(_collection_definitions,
+ _collection_definitions_count * sizeof(GType));
- _collection_definitions[result].items = items;
- _collection_definitions[result].create = create;
+ _collection_definitions[result] = items;
/* TODO : unlock */
@@ -109,9 +100,15 @@ bool load_hard_coded_collection_definitions(void)
* afin de garder la correspondance entre les identifiants.
*/
- id = register_collection_type(G_TYPE_BM_COLLECTION, create_bookmark_db_table);
+ id = register_collection_type(G_TYPE_BM_COLLECTION);
assert(id == DBF_BOOKMARKS);
+ id = register_collection_type(G_TYPE_COMMENT_COLLECTION);
+ assert(id == DBF_COMMENTS);
+
+ id = register_collection_type(G_TYPE_SWITCHER_COLLECTION);
+ assert(id == DBF_DISPLAY_SWITCHERS);
+
return true;
}
@@ -156,16 +153,13 @@ GList *create_collections_list(void)
{
GList *result; /* Groupe à retourner */
uint32_t i; /* Boucle de parcours */
- const collec_t *def; /* Définition brute à lire */
GDbCollection *collec; /* Nouveau groupe à intégrer */
result = NULL;
for (i = 0; i < _collection_definitions_count; i++)
{
- def = &_collection_definitions[i];
- //collec = g_db_collection_new(i, def->items, "Bookmarks");
- collec = g_object_new(def->items, NULL);
+ collec = g_object_new(_collection_definitions[i], NULL);
result = g_list_append(result, collec);
diff --git a/src/core/collections.h b/src/core/collections.h
index b84bdd9..dbe869a 100644
--- a/src/core/collections.h
+++ b/src/core/collections.h
@@ -32,13 +32,8 @@
-/* Crée la table dans une base de données. */
-typedef bool (* create_db_table_fc) (sqlite3 *);
-
-
-
/* Enregistre un type d'élément à gérer par collection. */
-uint32_t register_collection_type(GType, create_db_table_fc);
+uint32_t register_collection_type(GType);
/* Charge les définitions de collections "natives". */
bool load_hard_coded_collection_definitions(void);