summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-04-09 11:36:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-04-09 11:36:09 (GMT)
commit9b7dfd449b08637c4b4fc6d95acf3a8fcb5fd58d (patch)
tree8d8a1fb3a3bdc9d93a2b9f061bfc8c2d6b4d2e6d /src/analysis
parentfd8421351331f5d9b676e054af22f573402033a2 (diff)
Built interfaces using Glade and GLib resources.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c91
-rw-r--r--src/analysis/binary.h10
2 files changed, 71 insertions, 30 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index e617767..d934c76 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -60,9 +60,10 @@ struct _GLoadedBinary
char *username; /* Identifiant de l'utilisateur*/
bool username_changed; /* Mémorise les changements */
+
+ bool local_storage; /* Enregistrements locaux ? */
char *remote_host; /* Nom du serveur distant */
unsigned short remote_port; /* Port du serveur distant */
- bool use_remote_server; /* Indique une utilisation */
GDbClient *local; /* Enregistrements locaux */
GDbClient *remote; /* Enregistrements distants */
@@ -195,9 +196,9 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
{
binary->username = strdup("default");
+ binary->local_storage = true;
binary->remote_host = strdup("localhost");
- binary->remote_port = 9999;
- binary->use_remote_server = false;
+ binary->remote_port = 1337;
binary->storages[DBF_COMMENTS] = DBS_ALL_LOCAL;
binary->storages[DBF_DISPLAY_SWITCHERS] = DBS_ALL_LOCAL;
@@ -611,8 +612,8 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContextP
{
bool result; /* Bilan à faire remonter */
char *storage_path; /* Partie "Enregistrement" */
- char *access; /* Chemin d'accès à un élément */
char *value; /* Valeur lue à partie du XML */
+ char *access; /* Chemin d'accès à un élément */
unsigned short port; /* Port de communication */
bool use; /* Usage d'un serveur distant */
DBFeatures i; /* Boucle de parcours */
@@ -622,6 +623,13 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContextP
storage_path = strdup(path);
storage_path = stradd(storage_path, "/Storage");
+ value = get_node_prop_value(context, storage_path, "local");
+ if (value == NULL) goto glbls_features;
+
+ binary->local_storage = (strcmp(value, "true") == 0);
+
+ free(value);
+
/* Nom d'utilisateur */
access = strdup(storage_path);
@@ -649,17 +657,10 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContextP
free(value);
- value = get_node_prop_value(context, access, "use");
- if (value == NULL) goto glbls_features;
-
- use = (strcmp(value, "true") == 0);
-
- free(value);
-
value = get_node_prop_value(context, access, "host");
if (value == NULL) goto glbls_features;
- g_loaded_binary_set_remote_server(binary, value, port, use);
+ g_loaded_binary_set_remote_server(binary, value, port);
free(value);
@@ -738,6 +739,9 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDocPtr
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");
+
/* Nom d'utilisateur */
access = strdup(storage_path);
@@ -757,9 +761,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDocPtr
sprintf(port_str, "%hu", binary->remote_port);
result &= add_string_attribute_to_node(xdoc, context, access, "port", port_str);
- result &= add_string_attribute_to_node(xdoc, context, access, "use",
- binary->use_remote_server ? "true" : "false");
-
free(access);
/* Fonctionnalités */
@@ -847,24 +848,66 @@ void g_loaded_binary_set_username(GLoadedBinary *binary, const char *username)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
+* *
+* Description : Détermine si tous les enregistrements sont locaux ou non. *
+* *
+* Retour : Statut de l'utilisation du serveur local. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
+{
+ return binary->local_storage;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* local = statut de l'utilisation du serveur local. *
+* *
+* Description : Définit si tous les enregistrements sont locaux ou non. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_loaded_binary_set_local_storage(GLoadedBinary *binary, bool local)
+{
+ binary->local_storage = local;
+
+ if (local)
+ /* TODO : reload conn ! */;
+ else
+ /* TODO : stop conn ! */;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
* host = nom du serveur distant à contacter. [OUT] *
* port = port de communication avec le serveur distant. [OUT]*
* *
* Description : Identifie le serveur distant associé au binaire courant. *
* *
-* Retour : Statut de l'utilisation du serveur distant. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char **host, unsigned short *port)
+void g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char **host, unsigned short *port)
{
*host = binary->remote_host;
*port = binary->remote_port;
- return binary->use_remote_server;
-
}
@@ -873,7 +916,6 @@ bool g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char *
* Paramètres : binary = élément binaire à consulter. *
* host = nom du serveur distant à contacter. *
* port = port de communication avec le serveur distant. *
-* use = statut de l'utilisation du serveur distant. *
* *
* Description : Définit le serveur distant associé au binaire courant. *
* *
@@ -883,20 +925,13 @@ bool g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char *
* *
******************************************************************************/
-void g_loaded_binary_set_remote_server(GLoadedBinary *binary, const char *host, unsigned short port, bool use)
+void g_loaded_binary_set_remote_server(GLoadedBinary *binary, const char *host, unsigned short port)
{
free(binary->remote_host);
binary->remote_host = strdup(host);
binary->remote_port = port;
- binary->use_remote_server = use;
-
- if (use)
- /* TODO : reload conn ! */;
- else
- /* TODO : stop conn ! */;
-
}
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index a725110..9447d17 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -109,11 +109,17 @@ const char *g_loaded_binary_get_username(const GLoadedBinary *);
/* Définit l'utilisateur analysant le binaire courant. */
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 *);
+
+/* Définit si tous les enregistrements sont locaux ou non. */
+void g_loaded_binary_set_local_storage(GLoadedBinary *, bool);
+
/* Identifie le serveur distant associé au binaire courant. */
-bool g_loaded_binary_get_remote_server(const GLoadedBinary *, const char **, unsigned short *);
+void g_loaded_binary_get_remote_server(const GLoadedBinary *, const char **, unsigned short *);
/* Définit le serveur distant associé au binaire courant. */
-void g_loaded_binary_set_remote_server(GLoadedBinary *, const char *, unsigned short, bool);
+void g_loaded_binary_set_remote_server(GLoadedBinary *, const char *, unsigned short);
/* Indique la forme d'enregistrement d'une fonctionnalité. */
DBStorage g_loaded_binary_get_storage(const GLoadedBinary *, DBFeatures);