summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-03 13:16:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-03 13:16:32 (GMT)
commit7b9727379e1c3f2aefc4ac0db0e91d0cfb0a481f (patch)
tree7f9f7d53b93c188b57848cdc4b337808594a0723 /src/analysis
parentd1df89e49a2e8723337570debcf36907b1eded62 (diff)
Built a dialog box to change storage options.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c48
-rw-r--r--src/analysis/binary.h15
-rw-r--r--src/analysis/db/collection.c22
-rw-r--r--src/analysis/db/collection.h3
-rw-r--r--src/analysis/db/protocol.h7
5 files changed, 64 insertions, 31 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index c327696..6cc3c74 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -69,7 +69,7 @@ struct _GLoadedBinary
char *username; /* Identifiant de l'utilisateur*/
bool username_changed; /* Mémorise les changements */
- bool local_storage; /* Enregistrements locaux ? */
+ bool use_remote; /* Enregistrements distants ? */
char *remote_host; /* Nom du serveur distant */
unsigned short remote_port; /* Port du serveur distant */
@@ -230,7 +230,7 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
{
binary->username = strdup("default");
- binary->local_storage = true;
+ binary->use_remote = false;
binary->remote_host = strdup("localhost");
binary->remote_port = 1337;
@@ -437,10 +437,10 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
storage_path = strdup(path);
storage_path = stradd(storage_path, "/Storage");
- value = get_node_prop_value(context, storage_path, "local");
+ value = get_node_prop_value(context, storage_path, "remote");
if (value == NULL) goto glbls_no_storage_config;
- binary->local_storage = (strcmp(value, "true") == 0);
+ binary->use_remote = (strcmp(value, "true") == 0);
free(value);
@@ -559,8 +559,8 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
storage_path = strdup(path);
storage_path = stradd(storage_path, "/Storage");
- result &= add_string_attribute_to_node(xdoc, context, storage_path, "local",
- binary->local_storage ? "true" : "false");
+ result &= add_string_attribute_to_node(xdoc, context, storage_path, "remote",
+ binary->use_remote ? "true" : "false");
/* Nom d'utilisateur */
@@ -681,9 +681,9 @@ void g_loaded_binary_set_username(GLoadedBinary *binary, const char *username)
* *
******************************************************************************/
-bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
+bool g_loaded_binary_use_remote_storage(const GLoadedBinary *binary)
{
- return binary->local_storage;
+ return binary->use_remote;
}
@@ -691,7 +691,7 @@ bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
-* local = statut de l'utilisation du serveur local. *
+* use = statut de l'utilisation du serveur distant. *
* *
* Description : Définit si tous les enregistrements sont locaux ou non. *
* *
@@ -701,11 +701,11 @@ bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
* *
******************************************************************************/
-void g_loaded_binary_set_local_storage(GLoadedBinary *binary, bool local)
+void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *binary, bool use)
{
- binary->local_storage = local;
+ binary->use_remote = use;
- if (local)
+ if (use)
/* TODO : reload conn ! */;
else
/* TODO : stop conn ! */;
@@ -1029,18 +1029,36 @@ GDbClient *g_loaded_binary_get_db_client(const GLoadedBinary *binary)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
+* count = taille de la liste constituée. [OUT] *
* *
* Description : Fournit l'ensemble des collections utilisées par un binaire. *
* *
-* Retour : Collections en place. *
+* Retour : Liste de collections en place à libérer après usage. *
* *
* Remarques : - *
* *
******************************************************************************/
-GList *g_loaded_binary_get_all_collections(const GLoadedBinary *binary)
+GDbCollection **g_loaded_binary_get_all_collections(const GLoadedBinary *binary, size_t *count)
{
- return binary->collections;
+ GDbCollection **result; /* Liste à retourner */
+ GList *c; /* Boucle de parcours #1 */
+ size_t i; /* Boucle de parcours #2 */
+
+ *count = g_list_length(binary->collections);
+
+ result = malloc(*count * sizeof(GDbCollection *));
+
+ for (c = g_list_first(binary->collections), i = 0; c != NULL; c = g_list_next(c), i++)
+ {
+ assert(i < *count);
+
+ result[i] = G_DB_COLLECTION(c->data);
+ g_object_ref(G_OBJECT(result[i]));
+
+ }
+
+ return result;
}
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 7c2c760..831cade 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -91,10 +91,10 @@ const char *g_loaded_binary_get_username(const GLoadedBinary *);
void g_loaded_binary_set_username(GLoadedBinary *, const char *);
/* Détermine si tous les enregistrements sont locaux ou non. */
-bool g_loaded_binary_get_local_storage(const GLoadedBinary *);
+bool g_loaded_binary_use_remote_storage(const GLoadedBinary *);
/* Définit si tous les enregistrements sont locaux ou non. */
-void g_loaded_binary_set_local_storage(GLoadedBinary *, bool);
+void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *, bool);
/* Identifie le serveur distant associé au binaire courant. */
void g_loaded_binary_get_remote_server(const GLoadedBinary *, const char **, unsigned short *);
@@ -120,7 +120,7 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *);
GDbClient *g_loaded_binary_get_db_client(const GLoadedBinary *);
/* Fournit l'ensemble des collections utilisées par un binaire. */
-GList *g_loaded_binary_get_all_collections(const GLoadedBinary *);
+GDbCollection **g_loaded_binary_get_all_collections(const GLoadedBinary *, size_t *);
/* Trouve une collection assurant une fonctionnalité donnée. */
GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *, DBFeatures);
@@ -139,15 +139,6 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *, DBFeatures, GDbIte
-/**
- * TODO :
- *
- * - connect_signal
- * - add_obj
- *
- */
-
-
diff --git a/src/analysis/db/collection.c b/src/analysis/db/collection.c
index a99c2de..adb3ad1 100644
--- a/src/analysis/db/collection.c
+++ b/src/analysis/db/collection.c
@@ -30,6 +30,9 @@
#include <string.h>
+#include <i18n.h>
+
+
#include "collection-int.h"
#include "misc/rlestr.h"
#include "../../common/extstr.h"
@@ -242,6 +245,25 @@ uint32_t g_db_collection_get_feature(const GDbCollection *collec)
}
+/******************************************************************************
+* *
+* Paramètres : collec = collection générique d'éléments à consulter. *
+* *
+* Description : Décrit le type de collection manipulée. *
+* *
+* Retour : Description humaine de la collection. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *g_db_collection_get_name(const GDbCollection *collec)
+{
+ return _(collec->name);
+
+}
+
+
diff --git a/src/analysis/db/collection.h b/src/analysis/db/collection.h
index 5292e89..0f0ad34 100644
--- a/src/analysis/db/collection.h
+++ b/src/analysis/db/collection.h
@@ -67,6 +67,9 @@ void g_db_collection_link_to_binary(GDbCollection *, GLoadedBinary *);
/* Décrit le type des éléments rassemblées dans une collection. */
uint32_t g_db_collection_get_feature(const GDbCollection *);
+/* Décrit le type de collection manipulée. */
+const char *g_db_collection_get_name(const GDbCollection *);
+
diff --git a/src/analysis/db/protocol.h b/src/analysis/db/protocol.h
index 202a923..025f92f 100644
--- a/src/analysis/db/protocol.h
+++ b/src/analysis/db/protocol.h
@@ -46,11 +46,10 @@
/* Comportement vis à vis des éléments */
typedef enum _DBStorage
{
- DBS_ALL_LOCAL = 0x01, /* Enregistrements locaux */
- DBS_ALL_REMOTE = 0x02, /* Enregistrements distants */
- DBS_LOCAL_AND_REMOTE = 0x03, /* Enreg. locaux + infos dists.*/
+ DBS_ALL_LOCAL = 0x00, /* Enregistrements locaux */
+ DBS_ALL_REMOTE = 0x01, /* Enregistrements distants */
- DBS_MAX = 3
+ DBS_MAX = 0x01
} DBStorage;